From patchwork Wed Feb 19 12:29:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13982054 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EDE51DDA3B; Wed, 19 Feb 2025 12:30:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739968203; cv=none; b=tqETQ9qTklnLeOnVJG31fK0LsQH/SwM/dV10EJi8vbjK30rXKelOusQUzNP58ed/AdZ0C09KYk067d6KwXIqdScHGrN+02TsM9CBWY7Bewz+uZISFDzaHJB9UnddFZ2NmDUjJGwfYpsxbOVy3mFQLCfw5ldARzUQWJAUybvmXFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739968203; c=relaxed/simple; bh=SlKuG0AdBwn/S5pE8rkdaa+Z4RfGUwCknA7f5LLdKiI=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=NxxCPf+M/+FjBrbN8ceuABiU9JCXsQeoAI230yjc6iBTKCnKTznhoNc4Nt3azKeLBVCrONmihOLolBTiExy+VcpezFnlzrHkg4m8r+B5BzOo9NJaHtrPbDIaV4d6d7Fy+CIPn1iEgkw3Z64xQuKvcoJyjNn2e5CgoXnZWdp8jqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=C2MTT+q9; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C2MTT+q9" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-30737db1aa9so62782881fa.1; Wed, 19 Feb 2025 04:30:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739968199; x=1740572999; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=+24dvPWABcFd9MeuF3ZS2A94KuzubvQXMwsC3UbrqGc=; b=C2MTT+q90QiIPNteIYC5JHSmFGLICmiuotjQUYATnTbhyFIx4faaau8K+yog+ot4O8 MPgzThoz/Zd9J26CdQEgdH+1WZqBZNAeL+VZR73+4BRzSPIpCc1t2G7FK8nuXtsSRa8z Lg/b3yzQwxWOQhLwesC/XovGvQwGaOhZ/3i8sUb21KCYvWnNBZkdUEemlZTw+U7UOzJH XVSNXCRgVe4PIOa6JYUMqkNwQGzR10wwT2dejt4NbV64S6SrWxYQNoDn3BaIqelY4iUT 4cv9/j0EaSPbyOJyqkF1lv4ttnGsg/GNe0ZzThlUh4h6yw8MUTGhyXM1VdGJHVTAv3wP XYOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739968199; x=1740572999; 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=+24dvPWABcFd9MeuF3ZS2A94KuzubvQXMwsC3UbrqGc=; b=T4tEiIjxrv6E2KbnM8asLWLy3Vw0SAUG0hIV0BuwevscgJoqthv4sXNfTM2RJylnQw jqwE6H6vaIsS3lo7FtjWjyTSSS+6fZQSFOCNq2QYeBazvH7HorEh9nO7kSgmE1kBSBbC OBJwUSCK3NyxMNJk8QJymkQBNhOwMu3TkmDc/EB0+KcScymC5WoZBBVFyKxzJwI7jveL Z0ZOUa+9AcZKmqbZ2apP1oE7OU+jUJ4K6Z2psGn/NAwrfR2BMa7IvIgsfPFkVZwOqr0y j/nnWXoD0LOmJ1eobnghaVa811N5QmBYuNgFV+vJwV9j1D4MU66rxCEu8kiBr5Zi+WHS +gmw== X-Forwarded-Encrypted: i=1; AJvYcCU2zbcxIg3uKulKlCX5w2fAfZLSS9yWGf09AXxapcofwypWqlD1unFqRslBeMNr5EJah/4rZ5SoSRBfwvlY@vger.kernel.org, AJvYcCU9Wimoiok+CcpqWcC4jOOw5JkqnCHKM6sBz0HcHhUM8I+MrajFTH4Z2MWwfbmrKTUAb8aqHiHUwXbR@vger.kernel.org, AJvYcCW42NdxEle7rixBe1LLibE8yd0e6YJlGsh66VGXVKO8T82suOiwMKW3LKB1KyPs+OACvIBtU7XgiS4VmTRGcqC8ALU=@vger.kernel.org, AJvYcCWCS9//0CoDsFAh5uKFqiUjlg0uM42D0uhObXZBZmL3voH2aDW10VLHoJKxkNJcrUd2tjHfcviYPQLg@vger.kernel.org X-Gm-Message-State: AOJu0Yy1jjmH5Fxz0cA0Ro1hRkUxhRlz/8hXNfCiKIkgQlQlpYXqVAYp n68uTFs/dA+9BVcNxBAXn2QqlCyBZQXSSmQY5ziOdnjzHioiumyT8DvQDA== X-Gm-Gg: ASbGncsIHyDkDz5WODuRnuPlbPhs5T+YYvAF1f7sFKUuQCUVcGgveLF8yInv8x9RVjv JderfyZyGMTic2/kBP+Z50exySL0T6Fu4Qw8/WIUbSKF9QgV48v2qG6AgS4Tbfya9WlHZT030y+ wK5dgHKxffZ3Q9BMX1HH5OL71WMRoD6VIZM00/pqiLxQP6zgg6PasPth41TlevxtvNPdd8GOrb2 Tcyi9ZXJRU1Z8skRgT4Khd52Yh6fGUPzPgVnUMOyJM/KE0yawuEsWn9Y3fucR9uRK5sBTey4oor sVro2jqEfPe4PXcbI73qoQ== X-Google-Smtp-Source: AGHT+IFQyrXqy5NpHLF7+Lu4p1h9WASYPxxPIwKuoow2XXCkQtMPyIwZy0Fsi378ablFiyznjOaaqg== X-Received: by 2002:a2e:95ca:0:b0:308:da52:5672 with SMTP id 38308e7fff4ca-30a44dbb8eamr9477541fa.6.1739968199067; Wed, 19 Feb 2025 04:29:59 -0800 (PST) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3091029b75esm22556451fa.103.2025.02.19.04.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2025 04:29:56 -0800 (PST) Date: Wed, 19 Feb 2025 14:29:45 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , Lad Prabhakar , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Hugo Villeneuve , Nuno Sa , David Lechner , Javier Carrasco , Andy Shevchenko , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Linus Walleij Subject: [PATCH v3 0/9] Support ROHM BD79124 ADC Message-ID: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Support ROHM BD79124 ADC. This series adds also couple of helper functions for parsing the channel information from the device tree. There has been some discussion about how useful these are, and whether they should support also differential and single ended channel configurations. This version adds support for those - with the cost of added complexity and somewhat harder to use API. I've babbled more about that in the patch 2/9. (And, I actually wonder if I should've returned this to RFC?) The last couple of patches are examples of drivers which could utilize these added helpers: - 6/9 converts rzg2l_adc to use helpers - 7/9 converts sun20i-gpadc to use helpers - 9/9 makes the ti-ads7924 to respect the channel specification give in the device-tree using these helpers. patch 8/9 is small simplification for the ti-ads7924, and it can be taken independently from the rest of the series. NOTE: Patches 6...9 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: 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 (9): dt-bindings: ROHM BD79124 ADC/GPO iio: adc: add helpers for parsing ADC nodes iio: adc: Support ROHM BD79124 ADC MAINTAINERS: Add IIO ADC helpers MAINTAINERS: Add ROHM BD79124 ADC/GPO iio: adc: rzg2l_adc: Use adc-helpers iio: adc: sun20i-gpadc: Use adc-helpers iio: adc: ti-ads7924 Drop unnecessary function parameters iio: adc: ti-ads7924: Respect device tree config .../bindings/iio/adc/rohm,bd79124.yaml | 114 ++ MAINTAINERS | 12 + drivers/iio/adc/Kconfig | 15 + drivers/iio/adc/Makefile | 2 + drivers/iio/adc/industrialio-adc.c | 304 +++++ drivers/iio/adc/rohm-bd79124.c | 1162 +++++++++++++++++ drivers/iio/adc/rzg2l_adc.c | 41 +- drivers/iio/adc/sun20i-gpadc-iio.c | 42 +- drivers/iio/adc/ti-ads7924.c | 85 +- include/linux/iio/adc-helpers.h | 56 + 10 files changed, 1742 insertions(+), 91 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: 5bc55a333a2f7316b58edc7573e8e893f7acb532