From nobody Mon Sep 28 08:46:34 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 C3DB626982C for ; Mon, 24 Aug 2026 08:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787561207; cv=none; b=LSio4wqE1GfuinXNjIXFO95uA9x9SkBqeUS7bJXfNMOGZxBheA1hRdCXrjwFzy4WL/M70ycRFIPMLWmbRSE5HKtqZYtIYEVINThHx0lGRxQpDTFDWyF6LEOn30VHGnErIkt/Y6tLvcpdAt3G8YAbDHx+5wuN1YxxVq+bqLBY+y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787561207; c=relaxed/simple; bh=mZLDs79Db2Zx+KUIRqHP990qtmdC8drsa//LHtCDuF8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fPumUdC2pwjEz8EQRSucl81keJgwvBZf9GYI5mU8Y46UhdZYlClxZLOA8iZLytmjUL4wW4Qeg5bGF0O16uDDxkclVDW6r4KkfENZunIiiBL3HIiaaCTSFt3G6dL9bBweC3FxHp9+brHeOxHBof4TaaO25m5NZwtRAWpkbhcZNwE= 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=ITmYATLL; arc=none smtp.client-ip=209.85.214.173 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="ITmYATLL" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2cacf197759so42069655ad.2 for ; Mon, 24 Aug 2026 01:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787561202; x=1788166002; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+4kiW1wmf6ThJa6PW0OMOTGTvahVVw3yujYchGBBZR4=; b=ITmYATLLQk6xsb4EEWBfg5nbQMVm30HjFM1VVhHGTpfs6nQPwg0PgOwoksiPJ1pJnZ xEqiUBQoTVoimEy0pQq8c2caxdwApGhNI4GoECtu7Z0+rpG9QZsFfeUuFB8LPO7UF5ac FaE+KcoEr7+J1Td9Cu15utX2kq4I8GY416WDLIJq1jmB7AUvZDmFFUwQf1ke840HDror W007obWhp5oAf6j1Z9ZEVvW9bfGeHcP7zUkmrx7NJ1qzw1892Im/ZOWkvZStiiVFLfvm kQK/92muSGCTooRqBRW0Eoum9xLHQ9lH+cyW0zhzVXn0uHU4YveWQy1QIaGyDOpnS3LE H/Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787561202; x=1788166002; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+4kiW1wmf6ThJa6PW0OMOTGTvahVVw3yujYchGBBZR4=; b=WLbBG04q/Z9Ydh+00jTgjj+68E3kxjPmDtyu/0dAkQ0xFmGQf4RQCrUdOSP6QE7Oxz XIYlY75a52L4LnXLZcDz3dykamaFC8DJRqA5XFIFvlGX1XZ4dkV6cEB58YDsO1Pw/RHP kwFVh5US0f6dua6daKiF8rovYmpfFHW4n1xZzMvdM3roexlkPUbRYH7zDacQBxgYP3du fZKwJUm8TQljH7PlMn5eP4UgvDO56IjzKE+saGSgEoX/OQGExNC+2sUJYZummxKo5bDh 65URhroE6er+II7sF8yn+QC7TRetpdATgSwtNPwXgoggMXoxeWV2cuyfn1KlXlSfoLvk 6iow== X-Forwarded-Encrypted: i=1; AHgh+Rqhw/6R2iKXGmlpY1o0GYQRFzhbz21V6imNGVm05E09M6TnMp+uGbbZBhZh9X3Ui+AwmgwpVlGtdjMz+Uo=@vger.kernel.org X-Gm-Message-State: AFuF++npF6pWdJ8rnh3tuI1LE58Ix8JoY/5AeUxEfrI3oVNMSlSQuEDH U26Hqb6Es7Ep/EZWLp5Ra8QxUnJkQVKri+lytGwMJfY9w5gP3jhC9lmC X-Gm-Gg: AR+sD12Bv5gB79oCATXjAYLRv0/IMCBtSMjRCEpLI4jPB4xBa/AxfvARubGBbja8AtL FidQBB5kRpqigC5sxgR6uXsLEaX1YLn4WZC0PWmLut5wKUV5HRwu8/xjB9VMCaB5h2JF0qBi8eO NeGzYHz/Kk2PCDA8cYCtHS1jDd6qvWximSlNSPo8weDoHx/ZE69nkkl3CqEzrmjSy96EJSZ+ifQ kGFYnT8hPU8xfQVHRyxB851eSoSxt99VG0nuo/UpgVqye7KYwhqYFR+DOzc/4eiR03o5zg/PMcS /YiucrQu9oBkEpMWiixw9O8sbEbsp/HUpFCes/fsW5s4chnTrCyedh/iXGBMDDzub44qUNCUiYV vVTeaX3EaEOrLBvyzeyRhn9NqejnJrU/Fpm0GbH0qbm46Zh/88j0MmGvX7gsahxXxJy1aL01xg5 QzjxzygGO/hqYznr5ovfUq5j8eE7IxOp03Q3Hm66Cd44fESa3L31+crXatSaz6zkfYpdRib8mib Jh553v1f5NCISbBHNnqMY5cMQ7I X-Received: by 2002:a17:903:b10:b0:2bf:dd0:c8b1 with SMTP id d9443c01a7336-2d64a9f80afmr469626455ad.0.1787561202264; Mon, 24 Aug 2026 01:46:42 -0700 (PDT) Received: from [127.0.1.1] (61-220-246-151.hinet-ip.hinet.net. [61.220.246.151]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d6768e9ebbsm15343265ad.80.2026.08.24.01.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 01:46:41 -0700 (PDT) From: Kyle Hsieh Date: Mon, 24 Aug 2026 16:49:38 +0800 Subject: [PATCH v7 1/2] dt-bindings: iio: adc: ti,ads112c04: Add binding for ADS112C04 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260824-ti-ads112c04-driver-v7-1-6b3c9c87d0e4@gmail.com> References: <20260824-ti-ads112c04-driver-v7-0-6b3c9c87d0e4@gmail.com> In-Reply-To: <20260824-ti-ads112c04-driver-v7-0-6b3c9c87d0e4@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , Philipp Zabel Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Hsieh , Conor Dooley X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5503; i=kylehsieh1995@gmail.com; h=from:subject:message-id; bh=mZLDs79Db2Zx+KUIRqHP990qtmdC8drsa//LHtCDuF8=; b=owEBbQGS/pANAwAKAaWDQrcJVsSBAcsmYgBqjAWwm3fjve7AXbTJLgNgabrI2ybDBtcQLkIv3 Y7IvbR3TCiJATMEAAEKAB0WIQTJHsaNZOdY+THGqJelg0K3CVbEgQUCaowFsAAKCRClg0K3CVbE gdzLCACTY/SsTMiu26pui6pH+4XJLAlbe+3ypqi+Y7oINPwQB6Ju9h3QBW6x3dwIRPR7Ef85k0M uN4zGKwsPY7jyQWeF5yl4UY067G/sgcB1GoQ6tKVnAySTAo+KSM7SdZx+zNP+CvTm2LXUMzLPov kPqYmwgMFkrAaCyzOAC9sF8Yg0rAMVxIdX1y0saY0gGe1cGXUUoVT2dfUe9DtFcvpqYO2Jg18Dy BCcX1pLafie3nLKIG51lP6jmm46zUsP8xje/61L20bE3mTJOeqOgHuseaxEb3x3qW4pUiu+pY6N sFd5l5my3SlSlFgUQqQ1w/A3HULNsBiKSuRl1TJ14FWUaDKR X-Developer-Key: i=kylehsieh1995@gmail.com; a=openpgp; fpr=C91EC68D64E758F931C6A897A58342B70956C481 Add device tree binding documentation for Texas Instruments ADS112C04 I2C Analog-to-Digital Converters. These devices provide 4-channel, 16-bit delta-sigma ADCs with an I2C interface, programmable gain amplifier (PGA), and data-ready (DRDY) interrupt output. The binding uses child nodes to dynamically define the connected single-ended or differential channels. Excitation current, burn-out current, and reference source properties are also included to fully describe the chip's hardware capabilities, aligned with the ti,ads112c14 binding conventions. Reviewed-by: David Lechner Acked-by: Conor Dooley Signed-off-by: Kyle Hsieh --- .../devicetree/bindings/iio/adc/ti,ads112c04.yaml | 149 +++++++++++++++++= ++++ MAINTAINERS | 6 + 2 files changed, 155 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/ti,ads112c04.yaml b/= Documentation/devicetree/bindings/iio/adc/ti,ads112c04.yaml new file mode 100644 index 000000000000..95a123cd7b67 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/ti,ads112c04.yaml @@ -0,0 +1,149 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/ti,ads112c04.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments ADS112C04 ADC + +maintainers: + - Kyle Hsieh + +description: + The ADS112C04 (16-bit) are precision analog-to-digital converters (ADCs) + with an I2C interface. They feature a flexible input multiplexer, a + low-noise programmable gain amplifier (PGA), two programmable excitation + current sources, a voltage reference, and a precision temperature sensor. + +properties: + compatible: + enum: + - ti,ads112c04 + + reg: + maxItems: 1 + description: I2C address of the device. + + interrupts: + maxItems: 1 + description: + Data ready (DRDY) interrupt output. DRDY pulses low when a conversion + result is ready and returns high once the result is latched, so an + edge trigger should be used. + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + reset-gpios: + maxItems: 1 + description: GPIO connected to the RESET pin. Active low. + + avdd-supply: true + dvdd-supply: true + + refp-supply: true + refn-supply: true + + ti,refp-refn-resistor-ohms: + description: Resistance of the external resistor between REFP and REFN. + +patternProperties: + "^channel@[0-9a-b]$": + $ref: adc.yaml + unevaluatedProperties: false + properties: + reg: + items: + - maximum: 11 + + single-channel: + maximum: 3 + + diff-channels: + items: + maximum: 3 + + excitation-channels: + maxItems: 2 + items: + maximum: 5 + description: + Additionally to AIN0-AIN3, IDAC1/IDAC2 can also be routed to + REFP0 (4) and REFN0 (5). + + excitation-current-nanoamp: + enum: [10000, 50000, 100000, 250000, 500000, 1000000, 1500000] + + burn-out-current-nanoamp: + const: 10000 + + reference-sources: + items: + - enum: [internal, external, avdd] + default: [ internal ] + + dependencies: + excitation-channels: [ excitation-current-nanoamp ] + excitation-current-nanoamp: [ excitation-channels ] + + oneOf: + - required: [ single-channel ] + - required: [ diff-channels ] + +required: + - compatible + - reg + - avdd-supply + - dvdd-supply + +dependencies: + refn-supply: [ refp-supply ] + +oneOf: + - required: + - refp-supply + - required: + - ti,refp-refn-resistor-ohms + - properties: + refp-supply: false + refn-supply: false + ti,refp-refn-resistor-ohms: false + +unevaluatedProperties: false + +examples: + - | + #include + #include + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + adc@40 { + compatible =3D "ti,ads112c04"; + reg =3D <0x40>; + interrupt-parent =3D <&gpio>; + interrupts =3D <12 IRQ_TYPE_EDGE_FALLING>; + + reset-gpios =3D <&gpio 13 GPIO_ACTIVE_LOW>; + avdd-supply =3D <&vdd_3v3_reg>; + dvdd-supply =3D <&vdd_3v3_reg>; + refp-supply =3D <&vref_reg>; + + #address-cells =3D <1>; + #size-cells =3D <0>; + + channel@0 { + reg =3D <0>; + diff-channels =3D <0>, <1>; + }; + + channel@1 { + reg =3D <1>; + single-channel =3D <2>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 04fa5322d9f7..417d74b6d6cc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26987,6 +26987,12 @@ S: Maintained F: Documentation/devicetree/bindings/iio/adc/ti,ads1119.yaml F: drivers/iio/adc/ti-ads1119.c =20 +TI ADS112C04 ADC DRIVER +M: Kyle Hsieh +L: linux-iio@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/iio/adc/ti,ads112c04.yaml + TI ADS112C14 ADC DRIVER M: David Lechner L: linux-iio@vger.kernel.org --=20 2.34.1 From nobody Mon Sep 28 08:46:34 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 AF2E33EDE57 for ; Mon, 24 Aug 2026 08:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787561212; cv=none; b=kOrLMR1ua6YpnO+CnsBaiGn/v6ouS2CynKjSYMEVpwdWM1JMLgl+N4ss5SGHlUeCm31RR9cbnmcUdPtIWEkg/UnExcdDJxsE/oWOjJ7E0RH3b4dvZF8bSKSC6x2h0VCpNhGwvWSdgtEssnLn0uLT1DcarQM1ObJuy/pAEIHOcBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787561212; c=relaxed/simple; bh=Zmc4UTC8Cyc7cRFaYuTJ6UebqJkFGo/yktm1Av823R4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OKGlRxpHgEigEJ20Gi+zNkEnmCrLNd0MQm/4+Nmc7IwBH3lzNPca5DV/vMtCzITgzYK8x1ZAbdOy7sqMpD+a0TlYD9tm43Qc/lp57ezx3D73+B7G3LEDj61Nlaw4B9z1qPNcqik77ysV2VT4sfvHPEh3U5W6UFchrHqKIbnLf+g= 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=iqkYWpfO; arc=none smtp.client-ip=209.85.214.172 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="iqkYWpfO" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2cf50c6f235so35572655ad.0 for ; Mon, 24 Aug 2026 01:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787561206; x=1788166006; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JPpjGcH4zng9ZOV28SjLrGGqQxlOLxlHDs251S7Goa4=; b=iqkYWpfOhqi0WBAQZ9pJpHmHZ8RBWSgo7mRaFQW+2meiHHMURPAQuV49gUI7LdEyIQ m8gCGvqslm3/2Q5iBHOhVyLxFDFUYe60k8rDHWnT/o2gVYvYDwqKFRdZuZrlOagFrzQT 0icZ/olrT4/Okv0C+e9KaECosoN8PZ3LalXa9oW0ZFRZxxs7zJnikM7r8uu3ln8Y3f0h ZQ/Pj9J8MeIibTOKWPzSnUe6o91nbP9cOvXpqI72k/4v3mS8OHdcIasm66AC82e/XywS saPs5xfABNuuB/8qwz+2eEL3WmWu5KhqTZ18sq42NWf/unLIuMmtG7fKaWppobJ3Y2ZF d12g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787561206; x=1788166006; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=JPpjGcH4zng9ZOV28SjLrGGqQxlOLxlHDs251S7Goa4=; b=TdQOOVNeuaazUVAaLEhlv/h6bM/yafIraia6fzpmFH+QITlJwGm5pFEHajqH7UWlls jxhjebF+CgsJuWhLUrh4+QaacD1OwO9iont8S74TPqsfplrpXOcV71Ca7lf5QLCb7ME0 8aeWnpbguYQq5QQoJWrTC8kPGSV28aErWhKuFM7ctxKEIQ9KtOzypJnFlWBvfW+KCZ/b 1Lk2iS0fe7V3ZCeS3y8I1teZLECdA6Q93LypxRp48dqMNdSoGYrU01RUToGd6oG8Aepc umrq51Njj+ZZd3pY7cWzzmxNJl4d5Bp2e1XNccpsTdTkIo8Ti3rT/4hay0Y25R6kYMPn Bs3w== X-Forwarded-Encrypted: i=1; AHgh+RqRiW84dj7CUP7YrU4738aUVTYchHCJuocYoJclY1VuzcKbnQiOr70LN80JLtDteN3Jdo6BvJVo94jxcsk=@vger.kernel.org X-Gm-Message-State: AFuF++kF04seoWElxp8dBU7zZZgNx9J2HCv1bmhgyGGQ4PyIA2iCR4wD Xizgakv/i/+wHELii8k4NQwjlPvgmXj+6y/LlGquf9XqEoZ+ZxeZMqTJ X-Gm-Gg: AR+sD13jjR/n1k4/+797caox2SKUuICVQaAQ2J0yFuCbXtGeIwVDlIEM2/kTnsaOizX +Qik6Wb1ALZZXy4Pm1mnXyZFe978vyYGdgeyLPaCTrbIyZYhS7E9UVwXoTrppzwqFem/8Ol561S NyLGgRgWh697CLvHkgG/yhboTUmS6W/nZm1L3oCpROvoFcLCbAcx0UC0ZWuYdJ/nlEsmmHtLDQW 4+90HTs1B4Xza3O6h63FrLKN23K0onR63FYzQpI6lNnh5yVGmLc3hZjuqKj0dOdDOTlpez64tlz fJXlrDYiyPWN1rpvHjf7zWfcrSkD5iepZRDyRXsBEpBc25P/U1/CZOOu0I6Rza9rIapEPZXFq/8 cfLRG0aiFAEifveez/ZnCeGd6dt70Cq/KXbLRp0HwhId8wgkNWJ15nau1OVsCDz2/VUDuU1WLsC ucZ19pMC13DZmibs1XM3qdw35gTjMEVkabsCgG+aSi7yhDhL9aGf8PcPykLraukDtOtdCaqbX38 u3bH3KTyTkMntsFNtAY+nVc3xo6 X-Received: by 2002:a17:903:390d:b0:2c9:fb11:1bf4 with SMTP id d9443c01a7336-2d64af4eea9mr474030975ad.7.1787561205491; Mon, 24 Aug 2026 01:46:45 -0700 (PDT) Received: from [127.0.1.1] (61-220-246-151.hinet-ip.hinet.net. [61.220.246.151]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d6768e9ebbsm15343265ad.80.2026.08.24.01.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 01:46:44 -0700 (PDT) From: Kyle Hsieh Date: Mon, 24 Aug 2026 16:49:39 +0800 Subject: [PATCH v7 2/2] iio: adc: ti-ads112c04: Add support for TI ADS112C04 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260824-ti-ads112c04-driver-v7-2-6b3c9c87d0e4@gmail.com> References: <20260824-ti-ads112c04-driver-v7-0-6b3c9c87d0e4@gmail.com> In-Reply-To: <20260824-ti-ads112c04-driver-v7-0-6b3c9c87d0e4@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , Philipp Zabel Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Hsieh X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=18299; i=kylehsieh1995@gmail.com; h=from:subject:message-id; bh=Zmc4UTC8Cyc7cRFaYuTJ6UebqJkFGo/yktm1Av823R4=; b=owEBbQGS/pANAwAKAaWDQrcJVsSBAcsmYgBqjAWxUBPsd2xfS/372NJuRQUpa3zf1pWqmodol tUkjsVhUKCJATMEAAEKAB0WIQTJHsaNZOdY+THGqJelg0K3CVbEgQUCaowFsQAKCRClg0K3CVbE gWu9B/4vBJhED8HmTCuYMYFyR2iKqZqJx5haE42mAkEuTxWcJQKQF2rNS/kfnJ456h/0IKJllaG ZYpE8SJ6qv8/w2I8P38cgLgG/eZl9p2HRZ8CV25mn6sZLU3hPGSJTeVJGuuFQESdoIRGs4VuxfZ h+hW7cYol49Y4U8F/OqNS//AnWlc8dETt6xDsBfNOsrUBP7WxQzyJlNOxOgtk5nOTAf04uc8nFI UOuGInDdRL+SK5NgnxU1zyEBgzOXvjmq7y0XBipGdtT0PkUqgPSC64MLMCYKE5ax7/ic2adRqdX ZjFfj0ghUHQj5sngRIo4bCCVJ1VRYXErF4D2mYfH9bWsXVaR X-Developer-Key: i=kylehsieh1995@gmail.com; a=openpgp; fpr=C91EC68D64E758F931C6A897A58342B70956C481 Add IIO driver support for the Texas Instruments ADS112C04 (16-bit) delta-sigma ADCs. The driver implements: - Single-shot conversions using the IIO raw read interface. - Dynamic parsing of single-ended and differential channels from device tree child nodes. - Hardware interrupt support via the DRDY pin, falling back to software polling if no IRQ is provided. - Per-channel reference source selection (internal 2.048V, external REFP/REFN, or AVDD) via the reference-sources device tree property. refn-supply is not yet supported. - Hardware reset via the reset controller framework, falling back to the RESET command when no reset controller is present. Signed-off-by: Kyle Hsieh Reviewed-by: Andy Shevchenko Reviewed-by: David Lechner --- MAINTAINERS | 1 + drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ti-ads112c04.c | 524 +++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 536 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 417d74b6d6cc..f51fbda9d4b9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26992,6 +26992,7 @@ M: Kyle Hsieh L: linux-iio@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/iio/adc/ti,ads112c04.yaml +F: drivers/iio/adc/ti-ads112c04.c =20 TI ADS112C14 ADC DRIVER M: David Lechner diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 990e7b3e7212..037fc7df8415 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1817,6 +1817,16 @@ config TI_ADS1119 This driver can also be built as a module. If so, the module will= be called ti-ads1119. =20 +config TI_ADS112C04 + tristate "Texas Instruments ADS112C04 ADC" + depends on I2C + help + If you say yes here you get support for Texas Instruments + ADS112C04 (16-bit) I2C analog to digital converters. + + This driver can also be built as a module. If so, the module will be + called ti-ads112c04. + config TI_ADS112C14 tristate "Texas Instruments ADS112C14/ADS122C14" depends on I2C diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index dcec0abb03b7..d8acf2831fd2 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -155,6 +155,7 @@ obj-$(CONFIG_TI_ADS1015) +=3D ti-ads1015.o obj-$(CONFIG_TI_ADS1018) +=3D ti-ads1018.o obj-$(CONFIG_TI_ADS1100) +=3D ti-ads1100.o obj-$(CONFIG_TI_ADS1119) +=3D ti-ads1119.o +obj-$(CONFIG_TI_ADS112C04) +=3D ti-ads112c04.o obj-$(CONFIG_TI_ADS112C14) +=3D ti-ads112c14.o obj-$(CONFIG_TI_ADS124S08) +=3D ti-ads124s08.o obj-$(CONFIG_TI_ADS1298) +=3D ti-ads1298.o diff --git a/drivers/iio/adc/ti-ads112c04.c b/drivers/iio/adc/ti-ads112c04.c new file mode 100644 index 000000000000..acf7209db761 --- /dev/null +++ b/drivers/iio/adc/ti-ads112c04.c @@ -0,0 +1,524 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Texas Instruments ADS112C04 16-bit I2C ADC driver + * + * Copyright (c) 2026 Kyle Hsieh + * + * Datasheet: https://www.ti.com/lit/ds/symlink/ads112c04.pdf + * Based on TI Reference Code and standard Linux IIO framework. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define ADS112C04_CMD_RESET 0x06 +#define ADS112C04_CMD_START_SYNC 0x08 +#define ADS112C04_CMD_RDATA 0x10 +#define ADS112C04_CMD_RREG(reg) (0x20 | ((reg) << 2)) +#define ADS112C04_CMD_WREG(reg) (0x40 | ((reg) << 2)) + +#define ADS112C04_REG_CONFIG0 0x00 +#define ADS112C04_CONF0_MUX GENMASK(7, 4) +#define ADS112C04_CONF0_MUX_AIN0_AIN1 0 +#define ADS112C04_CONF0_MUX_AIN_SINGLE_BASE 8 +#define ADS112C04_CONF0_GAIN GENMASK(3, 1) +#define ADS112C04_CONF0_GAIN_X1 0 +#define ADS112C04_CONF0_PGA_BYPASS BIT(0) + +#define ADS112C04_REG_CONFIG1 0x01 +#define ADS112C04_CONF1_DR GENMASK(7, 5) +#define ADS112C04_CONF1_DR_20SPS 0 +#define ADS112C04_CONF1_MODE BIT(4) +#define ADS112C04_CONF1_MODE_NORMAL 0 +#define ADS112C04_CONF1_CM BIT(3) +#define ADS112C04_CONF1_CM_SINGLE_SHOT 0 +#define ADS112C04_CONF1_VREF GENMASK(2, 1) +#define ADS112C04_CONF1_VREF_INTERNAL 0 +#define ADS112C04_CONF1_VREF_EXTERNAL 1 +#define ADS112C04_CONF1_VREF_AVDD 2 +#define ADS112C04_CONF1_TS BIT(0) +#define ADS112C04_CONF1_TS_DISABLED 0 + +#define ADS112C04_REG_CONFIG2 0x02 +#define ADS112C04_CONF2_DRDY BIT(7) + +#define ADS112C04_INT_REF_mV 2048 + +#define ADS112C04_MAX_CHANNELS 12 + +#define ADS112C04_RESOLUTION_BITS 16 + +enum { + ADS112C04_VREF_SOURCE_INTERNAL, + ADS112C04_VREF_SOURCE_EXTERNAL, + ADS112C04_VREF_SOURCE_AVDD, +}; + +static const char * const ads112c04_vref_names[] =3D { + [ADS112C04_VREF_SOURCE_INTERNAL] =3D "internal", + [ADS112C04_VREF_SOURCE_EXTERNAL] =3D "external", + [ADS112C04_VREF_SOURCE_AVDD] =3D "avdd", +}; + +static const u8 ads112c04_vref_reg_val[] =3D { + [ADS112C04_VREF_SOURCE_INTERNAL] =3D ADS112C04_CONF1_VREF_INTERNAL, + [ADS112C04_VREF_SOURCE_EXTERNAL] =3D ADS112C04_CONF1_VREF_EXTERNAL, + [ADS112C04_VREF_SOURCE_AVDD] =3D ADS112C04_CONF1_VREF_AVDD, +}; + +/* Indexed by [AINP][AINN], -1 means the combination is not available. */ +static const s8 ads112c04_diff_mux[4][4] =3D { + { -1, 0, 1, 2 }, + { 3, -1, 4, 5 }, + { -1, -1, -1, 6 }, + { -1, -1, 7, -1 }, +}; + +struct ads112c04_state { + struct i2c_client *client; + /* Protects concurrent ADC reads and device configuration */ + struct mutex lock; + struct completion completion; + u32 avdd_mV; + u32 ext_ref_mV; + u8 *vref_source; /* one entry per channel, indexed by scan order */ + u8 config0; + u8 config1; +}; + +static int ads112c04_write_cmd(struct i2c_client *client, u8 cmd) +{ + return i2c_smbus_write_byte(client, cmd); +} + +static int ads112c04_read_reg(struct i2c_client *client, u8 reg, u8 *val) +{ + int ret; + + ret =3D i2c_smbus_read_byte_data(client, ADS112C04_CMD_RREG(reg)); + if (ret < 0) + return ret; + + *val =3D ret; + + return 0; +} + +static int ads112c04_write_reg(struct i2c_client *client, u8 reg, u8 val) +{ + return i2c_smbus_write_byte_data(client, ADS112C04_CMD_WREG(reg), val); +} + +static int ads112c04_wait_for_data(struct ads112c04_state *st) +{ + int ret, err; + u8 val; + + if (st->client->irq > 0) { + /* Timeout is 100ms (slowest data rate is 20 SPS) */ + if (!wait_for_completion_timeout(&st->completion, msecs_to_jiffies(100))) + return -ETIMEDOUT; + + return 0; + } + + ret =3D read_poll_timeout(ads112c04_read_reg, err, + err < 0 || (val & ADS112C04_CONF2_DRDY), + 1 * USEC_PER_MSEC, 100 * USEC_PER_MSEC, false, + st->client, ADS112C04_REG_CONFIG2, &val); + if (err < 0) + return err; + + return ret; +} + +static int ads112c04_read_data(struct ads112c04_state *st, int *val) +{ + int ret; + + ret =3D i2c_smbus_read_word_swapped(st->client, ADS112C04_CMD_RDATA); + if (ret < 0) + return ret; + + *val =3D sign_extend32(ret, ADS112C04_RESOLUTION_BITS - 1); + + return 0; +} + +static int ads112c04_get_adc_result(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val) +{ + struct ads112c04_state *st =3D iio_priv(indio_dev); + unsigned int idx =3D chan - indio_dev->channels; + u8 new_config0, new_config1; + int ret; + + new_config0 =3D st->config0; + FIELD_MODIFY(ADS112C04_CONF0_MUX, &new_config0, chan->address); + + if (st->config0 !=3D new_config0) { + ret =3D ads112c04_write_reg(st->client, ADS112C04_REG_CONFIG0, + new_config0); + if (ret < 0) + return ret; + + st->config0 =3D new_config0; + } + + new_config1 =3D st->config1; + FIELD_MODIFY(ADS112C04_CONF1_VREF, &new_config1, + ads112c04_vref_reg_val[st->vref_source[idx]]); + + if (st->config1 !=3D new_config1) { + ret =3D ads112c04_write_reg(st->client, ADS112C04_REG_CONFIG1, + new_config1); + if (ret < 0) + return ret; + + st->config1 =3D new_config1; + } + + reinit_completion(&st->completion); + + ret =3D ads112c04_write_cmd(st->client, ADS112C04_CMD_START_SYNC); + if (ret < 0) + return ret; + + ret =3D ads112c04_wait_for_data(st); + if (ret < 0) + return ret; + + return ads112c04_read_data(st, val); +} + +static int ads112c04_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct ads112c04_state *st =3D iio_priv(indio_dev); + unsigned int idx =3D chan - indio_dev->channels; + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + ret =3D ads112c04_get_adc_result(indio_dev, chan, val); + mutex_unlock(&st->lock); + + if (ret < 0) + return ret; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + switch (st->vref_source[idx]) { + case ADS112C04_VREF_SOURCE_EXTERNAL: + *val =3D st->ext_ref_mV; + break; + case ADS112C04_VREF_SOURCE_AVDD: + *val =3D st->avdd_mV; + break; + default: + *val =3D ADS112C04_INT_REF_mV; + break; + } + *val2 =3D ADS112C04_RESOLUTION_BITS - 1; + return IIO_VAL_FRACTIONAL_LOG2; + + default: + return -EINVAL; + } +} + +static irqreturn_t ads112c04_irq_handler(int irq, void *private) +{ + struct iio_dev *indio_dev =3D private; + struct ads112c04_state *st =3D iio_priv(indio_dev); + + complete(&st->completion); + + return IRQ_HANDLED; +} + +static const struct iio_info ads112c04_info =3D { + .read_raw =3D ads112c04_read_raw, +}; + +static int ads112c04_parse_vref_source(struct fwnode_handle *child) +{ + if (!fwnode_property_present(child, "reference-sources")) + return ADS112C04_VREF_SOURCE_INTERNAL; + + return fwnode_property_match_property_string(child, "reference-sources", + ads112c04_vref_names, + ARRAY_SIZE(ads112c04_vref_names)); +} + +static int ads112c04_parse_channels(struct iio_dev *indio_dev, + bool *need_avdd_ref, bool *need_ext_ref) +{ + struct device *dev =3D indio_dev->dev.parent; + struct ads112c04_state *st =3D iio_priv(indio_dev); + struct iio_chan_spec *channels; + u32 num_channels, pair[2], channel; + unsigned int i; + int ret; + + num_channels =3D device_get_named_child_node_count(dev, "channel"); + if (!num_channels) + return dev_err_probe(dev, -EINVAL, "no channel subnodes found\n"); + + if (num_channels > ADS112C04_MAX_CHANNELS) + return dev_err_probe(dev, -EINVAL, + "num of channel nodes exceeds %d\n", + ADS112C04_MAX_CHANNELS); + + channels =3D devm_kcalloc(dev, num_channels, sizeof(*channels), GFP_KERNE= L); + if (!channels) + return -ENOMEM; + + st->vref_source =3D devm_kcalloc(dev, num_channels, + sizeof(*st->vref_source), GFP_KERNEL); + if (!st->vref_source) + return -ENOMEM; + + i =3D 0; + device_for_each_named_child_node_scoped(dev, child, "channel") { + const char *s_chan =3D "single-channel", *d_chan =3D "diff-channels"; + struct iio_chan_spec *spec =3D &channels[i]; + + if (fwnode_property_present(child, "excitation-channels")) + return dev_err_probe(dev, -EOPNOTSUPP, + "excitation-channels is not supported yet\n"); + + ret =3D ads112c04_parse_vref_source(child); + if (ret < 0) + return dev_err_probe(dev, ret, + "invalid reference-sources value\n"); + + st->vref_source[i] =3D ret; + + *need_ext_ref |=3D st->vref_source[i] =3D=3D ADS112C04_VREF_SOURCE_EXTER= NAL; + *need_avdd_ref |=3D st->vref_source[i] =3D=3D ADS112C04_VREF_SOURCE_AVDD; + + /* + * REVISIT: when ti,refp-refn-resistor-ohms is implemented, a + * channel using an external resistor reference is effectively + * a resistance measurement and should use IIO_RESISTANCE. + */ + spec->type =3D IIO_VOLTAGE; + spec->indexed =3D 1; + spec->info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_= SCALE); + + if (fwnode_property_present(child, s_chan)) { + ret =3D fwnode_property_read_u32(child, s_chan, &channel); + if (ret) + return dev_err_probe(dev, ret, + "failed to read %s property\n", s_chan); + + if (channel > 3) + return dev_err_probe(dev, -EINVAL, "%s must be 0-3\n", s_chan); + + spec->channel =3D channel; + spec->address =3D ADS112C04_CONF0_MUX_AIN_SINGLE_BASE + channel; + } else if (fwnode_property_present(child, d_chan)) { + ret =3D fwnode_property_read_u32_array(child, d_chan, pair, ARRAY_SIZE(= pair)); + if (ret) + return dev_err_probe(dev, ret, + "failed to read %s property\n", d_chan); + + if (pair[0] > 3 || pair[1] > 3) + return dev_err_probe(dev, -EINVAL, "%s must be 0-3\n", d_chan); + + spec->channel =3D pair[0]; + spec->channel2 =3D pair[1]; + spec->differential =3D 1; + + if (ads112c04_diff_mux[pair[0]][pair[1]] < 0) + return dev_err_probe(dev, -EINVAL, + "invalid %s combination\n", d_chan); + + spec->address =3D ads112c04_diff_mux[pair[0]][pair[1]]; + } else { + return dev_err_probe(dev, -EINVAL, + "channel node must have %s or %s\n", s_chan, d_chan); + } + + i++; + } + + indio_dev->channels =3D channels; + indio_dev->num_channels =3D i; + + return 0; +} + +static int ads112c04_probe(struct i2c_client *client) +{ + struct device *dev =3D &client->dev; + struct iio_dev *indio_dev; + struct ads112c04_state *st; + struct reset_control *reset; + bool need_avdd_ref =3D false, need_ext_ref =3D false; + int ret; + + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st =3D iio_priv(indio_dev); + st->client =3D client; + + ret =3D devm_mutex_init(dev, &st->lock); + if (ret) + return ret; + + init_completion(&st->completion); + + indio_dev->name =3D "ads112c04"; + indio_dev->modes =3D INDIO_DIRECT_MODE; + indio_dev->info =3D &ads112c04_info; + + /* Forward compatibility checks for unimplemented DT properties */ + if (device_property_present(dev, "refn-supply") || + device_property_present(dev, "ti,refp-refn-resistor-ohms")) + return dev_err_probe(dev, -EOPNOTSUPP, + "refn-supply and external resistors are not supported yet\n"); + + ret =3D ads112c04_parse_channels(indio_dev, &need_avdd_ref, &need_ext_ref= ); + if (ret) + return ret; + + if (need_avdd_ref) { + ret =3D devm_regulator_get_enable_read_voltage(dev, "avdd"); + if (ret < 0) + return dev_err_probe(dev, ret, "failed to get avdd voltage\n"); + + st->avdd_mV =3D ret / (MICRO / MILLI); + } else { + ret =3D devm_regulator_get_enable(dev, "avdd"); + if (ret) + return dev_err_probe(dev, ret, "failed to get avdd regulator\n"); + } + + ret =3D devm_regulator_get_enable(dev, "dvdd"); + if (ret) + return dev_err_probe(dev, ret, "failed to get dvdd regulator\n"); + + if (device_property_present(dev, "refp-supply")) { + ret =3D devm_regulator_get_enable_read_voltage(dev, "refp"); + if (ret < 0) + return dev_err_probe(dev, ret, "failed to get refp voltage\n"); + + st->ext_ref_mV =3D ret / (MICRO / MILLI); + } + + if (need_ext_ref && !st->ext_ref_mV) + return dev_err_probe(dev, -EINVAL, + "external reference measurements require refp-supply\n"); + + /* Datasheet: POR releases ~500us after supplies are stable */ + fsleep(500); + + reset =3D devm_reset_control_get_optional_exclusive(dev, NULL); + if (IS_ERR(reset)) + return dev_err_probe(dev, PTR_ERR(reset), "failed to get reset\n"); + + if (reset) { + /* Datasheet: tw(RSL), the RESET low pulse, is 250ns minimum */ + fsleep(1); + + ret =3D reset_control_deassert(reset); + if (ret) + return dev_err_probe(dev, ret, "failed to deassert reset\n"); + } else { + ret =3D ads112c04_write_cmd(client, ADS112C04_CMD_RESET); + if (ret < 0) + return ret; + } + + /* Datasheet: td(RSSTA) is 100ns minimum after the RESET rising edge */ + fsleep(1); + + /* + * Initialize CONFIG0 with all fields explicit: gain of 1 with the PGA + * bypassed, which allows full-scale single-ended measurements. The MUX + * field is updated per channel before each conversion. + */ + st->config0 =3D FIELD_PREP(ADS112C04_CONF0_MUX, + ADS112C04_CONF0_MUX_AIN0_AIN1) | + FIELD_PREP(ADS112C04_CONF0_GAIN, + ADS112C04_CONF0_GAIN_X1) | + ADS112C04_CONF0_PGA_BYPASS; + + ret =3D ads112c04_write_reg(client, ADS112C04_REG_CONFIG0, st->config0); + if (ret) + return ret; + + st->config1 =3D FIELD_PREP(ADS112C04_CONF1_DR, + ADS112C04_CONF1_DR_20SPS) | + FIELD_PREP(ADS112C04_CONF1_MODE, + ADS112C04_CONF1_MODE_NORMAL) | + FIELD_PREP(ADS112C04_CONF1_CM, + ADS112C04_CONF1_CM_SINGLE_SHOT) | + FIELD_PREP(ADS112C04_CONF1_VREF, + ADS112C04_CONF1_VREF_INTERNAL) | + FIELD_PREP(ADS112C04_CONF1_TS, + ADS112C04_CONF1_TS_DISABLED); + + ret =3D ads112c04_write_reg(client, ADS112C04_REG_CONFIG1, st->config1); + if (ret) + return ret; + + if (client->irq > 0) { + ret =3D devm_request_irq(dev, client->irq, ads112c04_irq_handler, 0, + indio_dev->name, indio_dev); + if (ret) + return ret; + } + + return devm_iio_device_register(dev, indio_dev); +} + +static const struct i2c_device_id ads112c04_id[] =3D { + { .name =3D "ads112c04" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ads112c04_id); + +static const struct of_device_id ads112c04_of_match[] =3D { + { .compatible =3D "ti,ads112c04" }, + { } +}; +MODULE_DEVICE_TABLE(of, ads112c04_of_match); + +static struct i2c_driver ads112c04_driver =3D { + .driver =3D { + .name =3D "ads112c04", + .of_match_table =3D ads112c04_of_match, + }, + .probe =3D ads112c04_probe, + .id_table =3D ads112c04_id, +}; +module_i2c_driver(ads112c04_driver); + +MODULE_AUTHOR("Kyle Hsieh "); +MODULE_DESCRIPTION("Texas Instruments ADS112C04 ADC driver"); +MODULE_LICENSE("GPL"); --=20 2.34.1