From patchwork Mon Mar 24 07:12:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14026878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73695C36002 for ; Mon, 24 Mar 2025 07:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=sowTRCf+Tb5j3/bsFU0jjdH3gxVyOrbSH7sFKvyOG64=; b=m14NZ9nXgKgyrVinteBGCtyKMb bCshlat6eiG0gtgvCXYzJoEWkhB4kwf1iu8L6QclDzHKZMMR4UgSDoHDq94PK3KIRhJk9ZBfpk8vY 1ATPEH+IoU+Ju4DaZRCjtbebksSclw1Bkrq6BSQ2kD0BGPU44Z4509Xlg8Sa8ZyPJjUWkCC3zylAM fVjBMWN0eYIGLabp4Pfm+iHVUiaToUzHZAsfr+Edccy57vYl8UKB8GEFX659nkf8A6kAlb2k55ZHm 2MNQhyJ5cdNEop7m4+92lxY2tq/g2V8087sVHl1POhs4WrzCKGD2gxF3VnS/MdT9LA9AyRTibUB9b f2jdTtcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1twc89-00000002RAi-1FWH; Mon, 24 Mar 2025 07:21:53 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1twbz4-00000002Pn7-2Ei6 for linux-arm-kernel@lists.infradead.org; Mon, 24 Mar 2025 07:12:31 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-307c13298eeso46357261fa.0 for ; Mon, 24 Mar 2025 00:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742800348; x=1743405148; darn=lists.infradead.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=sowTRCf+Tb5j3/bsFU0jjdH3gxVyOrbSH7sFKvyOG64=; b=Y8bjWLCJgD5/HMx9XuqwuHxGnzWNvzoEkvuXSjMGXtI/wLStIn2Z9veKSo1Klfo/hn IafCezO3nq2L8v+KL838Ae7QDTN/9noI8Y4/ebs6gObMbBdu0CtOvt3b5YnDuomjyIU6 zfevZ8ZyGXqNa1dfGQR9ytb7UmOzrE1A7+vhhARxeCuev/3g84HKcwVkuTDHAdywDxZB fpHFMgk8IE5OjSozfqsOk7K0TdOGQ/v6YrVWXM/CUCBFfyga7Wle4DJhQmdPynAj0vGh OuSWxXtpMlF17/yJPQZnx0l795woO8omcY3gP/IjzQrrrJ9KYjjlUBthgz1SL164u7Y6 J2fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742800348; x=1743405148; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sowTRCf+Tb5j3/bsFU0jjdH3gxVyOrbSH7sFKvyOG64=; b=qmmqgLNu/JcQQRn/tgVlXatj1mLLeqrTzDLHxCfHEZh9VntK6Mwrhj1dTFBmyjpzq+ lVr6MjBM1OOTJH37Ur6tHoXlTbQTGkaW00WnvKVZ7bc6wUM9QmNr1+GHx+PlU6qlWaGV n4PhpJqnbEN6v9hH5P+QyHEjRNLU1ozntOawzsJ+4wqsMX+UyotkWNe2UV656vW3bN8J esum84nKM7pf1/MhMX9Zxjwqj3+NCQGRwlhOCOTWAu5PyEqtNhlHKMptmmHXeFzPap6A bkF7t6o16jJY/bWi65cJTVOsNG18gCBz0byPh63u0q0q/yRBjCXl/ry/kx7ojpVr1MsK ft7Q== X-Forwarded-Encrypted: i=1; AJvYcCXqwm3GbcgDRYvK9Oi7BAl6l91ey5ufvq+KidctQfk404VTlqreOtc02bx5jyhCxKJcwParWzlTdmehXFiJBSHc@lists.infradead.org X-Gm-Message-State: AOJu0Yz7AjTzmbMmtLn7xuajPeC0di9fjX4aD3sSyuHNpQfHoCYCUnyZ pzc6OxsGsJmn1WE3nIznxxh6UNewydIPoFHZ8L4ISy7SY5RPrYlL X-Gm-Gg: ASbGnctK+RoLr2lvLJ1LlJIMhexIbvbxODmCaeyMN6aDNrAf/+HrDdd0tW+eeyC0M2b TaJgPieikV1I2pxlPWOowPCufbZLSOjaL8j+MlN+jOBZgxMN55aPI5az5FVHFaslmlg9kw86s5N n5FDrVLZmzzz7sqYonReLCfvkYSuwBBuWPa62driG8SKY0FfqxpiR+HtZiwLvi/ipylA+AJqs2l 5vqNGHvuiV0IshNDwAJHhTBoHDO0pmAViZn4g+8xUbQHwrVcA0OddBBx+r/G5XHX+c/YNJXKgJ8 QNMHdXLP35bwx/iHM+h9hlinKNzVtI3Zc7K21yk43zU5hlmky9s= X-Google-Smtp-Source: AGHT+IEnPPDATgowgnImDNLSvusoM0BTZl2CHm0V3kdZ6FVCrucX9v/2JU56loHRJqHxxkYiE05MEQ== X-Received: by 2002:a2e:6817:0:b0:30b:f599:d78f with SMTP id 38308e7fff4ca-30d727317a3mr56663871fa.7.1742800347972; Mon, 24 Mar 2025 00:12:27 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-30d7d7c19c3sm13336481fa.4.2025.03.24.00.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Mar 2025 00:12:26 -0700 (PDT) Date: Mon, 24 Mar 2025 09:12:17 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Matti Vaittinen , Lad Prabhakar , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Nuno Sa , David Lechner , Javier Carrasco , Guillaume Stols , Olivier Moysan , Dumitru Ceclan , Trevor Gamblin , Matteo Martelli , Alisa-Dariana Roman , AngeloGioacchino Del Regno , =?iso-8859-1?q?Jo=E3o_Paulo_Gon=E7alves?= , Ramona Alexandra Nechita , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v10 0/8] Support ROHM BD79124 ADC Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250324_001230_577375_7FBB5B71 X-CRM114-Status: GOOD ( 26.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Support ROHM BD79124 ADC. This series adds also couple of IIO ADC helper functions for parsing the channel information from the device tree. There are also new helpers included for iterating and counting firmware child nodes with a specific name. The rzg2l_adc and the sun20i-gpadc are converted to use the new ADC helper. There has been some discussion about how useful these ADC helpers are, and whether they should support also differential and single ended channel configurations. This version does not include support for those - with the benefit of reduced complexity and easier to use API. NOTE: The rzg2l_adc and the sun20i-gpadc are untested as I lack of relevant HW. They have been compile tested only. The ROHM BD79124 ADC itself is quite usual stuff. 12-bit, 8-channel ADC with threshold monitoring. Except that: - each ADC input pin can be configured as a general purpose output. - manually starting an ADC conversion and reading the result would require the I2C _master_ to do clock stretching(!) for the duration of the conversion... Let's just say this is not well supported. - IC supports 'autonomous measurement mode' and storing latest results to the result registers. This mode is used by the driver due to the "peculiar" I2C when doing manual reads. Furthermore, the ADC uses this continuous autonomous measuring, and the IC keeps producing new 'out of window' IRQs if measurements are out of window - the driver disables the event for 1 seconds when sending it to user. This prevents generating storm of events Revision history: v9 => v10: BD79124 driver fixes as suggested by Andy: - Use regmap_assign_bits() - dont change the mask for caller in bd79124gpo_set_multiple() - styling v8 => v9: - Drop the gianfar and the thp7312 drivers from the series to limit the review noise and to simplify the merging. They can be submitted later as separate changes. - Drop the fwnode_for_each_available_named_child() as suggested by Sakari. - BD79124 driver styling and fixes v7 => v8: property helpers: - Fix the example in fwnode_get_named_child_node_count() documentation to use the fwnode_get_named_child_node_count() and not the device_get_named_child_node_count() - Fix the rest of the new macro's indentiations adc helpers: - Treat 0 ADC channels as an error in devm_iio_adc_device_alloc_chaninfo_se(). rzg2l_adc / sun20i-gpadc: - Drop zero channels check from the ADC drivers using devm_iio_adc_device_alloc_chaninfo_se() BD79124: - Use unsigned for regmap values - Commit message fine tuning - Check devm_mutex_init() return value - Handle 'ALL pins as ADC or GPO' cleanly in BD79124 driver - BD79124 styling / typofixes v6 => v7: - Inline device_get_named_child_node_count() - Fix kernel-doc for fwnode_get_named_child_node_count() - Minor styling fixes More accurate changelog in individual patches. v5 => v6: - Drop applied patch - Add *_for_each_named_child_* iterators - Add a patch converting the thp7312 driver to use the new helper - Styling and minor things pointed by reviewers v4 => v5: Fixes as per various review comments. Most notably: - Drop the patch making the TI's ADC driver to respect device tree. - Add (RFC) patch converting gianfar driver to use new name child-node counting API as suggested by Andy. - Add fwnode_get_child_node_count_named() as suggested by Rob. - rebase to v6.14-rc5 More accurate changelog in individual patches. v3 => v4: - Drop the ADC helper support for differential channels - Drop the ADC helper for getting only channel IDs by fwnode. - "Promote" the function counting the number of child nodes with a specific name to the property.h (As suggested by Jonathan). - Add ADC helpers to a namespace. - Rebase on v6.14-rc3 - More minor changes described in individual patches. v2 => v3: - Restrict BD79124 channel numbers as suggested by Conor and add Conor's Reviewed-by tag. - Support differential and single-ended inputs - Convert couple of existing drivers to use the added ADC helpers - Minor fixes based on reviews Link to v2: https://lore.kernel.org/all/cover.1738761899.git.mazziesaccount@gmail.com/ RFC v1 => v2: - Drop MFD and pinmux. - Automatically re-enable events after 1 second. - Export fwnode parsing helpers for finding the ADC channels. --- Matti Vaittinen (8): dt-bindings: ROHM BD79124 ADC/GPO property: Add functions to iterate named child iio: adc: add helpers for parsing ADC nodes iio: adc: rzg2l_adc: Use adc-helpers iio: adc: sun20i-gpadc: Use adc-helpers iio: adc: Support ROHM BD79124 ADC MAINTAINERS: Add IIO ADC helpers MAINTAINERS: Add ROHM BD79124 ADC/GPO .../bindings/iio/adc/rohm,bd79124.yaml | 114 ++ MAINTAINERS | 12 + drivers/base/property.c | 27 + drivers/iio/adc/Kconfig | 17 + drivers/iio/adc/Makefile | 3 + drivers/iio/adc/industrialio-adc.c | 82 ++ drivers/iio/adc/rohm-bd79124.c | 1147 +++++++++++++++++ drivers/iio/adc/rzg2l_adc.c | 39 +- drivers/iio/adc/sun20i-gpadc-iio.c | 39 +- include/linux/iio/adc-helpers.h | 27 + include/linux/property.h | 20 + 11 files changed, 1479 insertions(+), 48 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/rohm,bd79124.yaml create mode 100644 drivers/iio/adc/industrialio-adc.c create mode 100644 drivers/iio/adc/rohm-bd79124.c create mode 100644 include/linux/iio/adc-helpers.h base-commit: 7eb172143d5508b4da468ed59ee857c6e5e01da6