From nobody Tue Sep 29 07:39:38 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 D58303B19A5 for ; Tue, 11 Aug 2026 02:45:52 +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=1786416365; cv=none; b=FVxVGcUJO5rQlvFx+Do7oamMAGIaLXgempFloq6yTBil2+0aHn/Dr5GfB6jYHQFlF+DfN6IxJsxLhTNYRpgBN1igdqqIFAIdC8wpDmyF/aX+XaPBTe1umEaDAkWx52frHtLD4g8mURRZJIvYbvPQn8rbFzXKFgptPv5/uwmWopc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786416365; c=relaxed/simple; bh=1tYkE6Rm1DfrZKIHMjwRAG2g1+xTsNua0nLGrevK7VA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ek2Vl6alCr5Z1cNJIgg4mUm79KHnca0rBLQvz9L8PsvKLkEBAlBMsE1VNc1kCx03GtpRsReX8edB1OyZiNK0hSl8K39yNfWytTbaNYcmCrLMJMnGoUY5GuzhUBYGILTN0tFdEK/PkAJXXENndWoGZyWWP4RkVgkKZ3n4kQ6LENE= 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=mO12DUb/; 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="mO12DUb/" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2cc891373e0so30886705ad.2 for ; Mon, 10 Aug 2026 19:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786416347; x=1787021147; 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=pIyiGsSgRZb7PjKqMe4zIlr1n1J2HKoXUtMDtA2XkPg=; b=mO12DUb/bUfFHa3373xffP0LqYjTcGNpoObQ4CN/4F6F/p2zRPjWSMmHS6GLgtekDD 9+CAVm4D7qT7lwWu27989cp9HDsJNJAGkHZhMLvUDMYcCYIwLu+4bb7w1vHgj6Ah4w0f Nqvxot39dioe8l5OCE4yG5WwdH7Mj3CN7VlENbtBiWRysO1r8Dir9I82r3kkCvdlAiXq O9V+c5XDTVvwbp7ogEBt9vGNcz4ugxpk6efZ/XY6PGEU4zl8ZRsycMeYHNdt43Llqazl Y7vj5hnv5SvMmcxqe8Fw0fZfg322t3ANUtgT9PuX96Nk8OYjC3Zh5c6Cu76Z+47E8rCg 3UUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786416347; x=1787021147; 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=pIyiGsSgRZb7PjKqMe4zIlr1n1J2HKoXUtMDtA2XkPg=; b=MqjTlD/qApKorUfdyVUXBDPB0LRCK395bEjFftcfU58m/O2jsOFtqwZJl26zB4fI2k tiuqbqWYvceQLQ2pPmrlSqnoRBR1cb9NdOa1mbt/SfuUNVzbipEkoAZjAl63OzInC5zM zdTP3Ri+ukQp7vezMZTL4xWnO1Q66XDkDovo2gWq24OcxpErMDYB8fgcwhhGc9PG9Drv tg4YhqP1f7Chhx7hzk/BmPh8NZlyiJWSr++jD3T7NZna8B6dwfQMw+X6V1vLh5cBFdKE G8ysifvEPpMZuW/AFoZS4x3lFEMOveXOP6UPyjNzmOM4Tk4v3DiO4nn+2KlHeNEGYwU0 Forw== X-Forwarded-Encrypted: i=1; AHgh+RoBpA97/WziTY/xpa0GblMb79urqVKvlLtpWk6jA9b7mYmnXc4DyRJl96IpfUSPMUB8pQCIsIbwC5DuocM=@vger.kernel.org X-Gm-Message-State: AOJu0YzC+YuwGwSL7/OVQbSCZCc3+j4x73onbMkDU5PPPQqtadnzDwlC Y7m+PgPe6vo8YTtvx/LRozAnVi9QmPhGaYy1YjS6t87i7l8aE12jA8x6 X-Gm-Gg: AR+sD13FH7YsqHMJmkrApeDKT14FTuZ/BbcAX49mlZ5w+/g9QBCHoy3BSstHBd+XUMo 1kir0Qi23oPOv3Qxdhu4jT055+2xf8cVOiTPgekQQq/csIlGvFuw3p1Rhg/UYs5yfMVurAUBGC8 /nYOfioPwD2JTFIHHADhqyMjERPqaR7ncRkn6bQZYMyUNxF8mjd1V8QTlfJWzbngB34KfNctu+H gDLXHOA7OOjo9+uYt2AzxNEw9QOP5O3vsAtfpFo2hzelOuT+oVf+dJkt6CT3iNAFtfDSDWigtJk pC9w1G7vgq0BY9ybjvGuDp8DB3zkx7Y+a3DtbTnWX6gN0xN4e81W8kXEHPVXUQEa1HSRf1adi3L UcNRvCxQobbG9pXYddE0m4GlIUbf2N5ituzhXQb0meJOD2kovaQKTRdn/zT/IHLvFyptMvEDTig QbJw82qodYzk3p3rA1gU2qGzdelkF82T0lJQdwQv0gKEYUVPSt5YR6uWSHdYSvb4LJm+nJ1E3oR rIkRSBhPylPShSrC7SpH9BxKtAD X-Received: by 2002:a17:903:3c63:b0:2ca:6c8:abde with SMTP id d9443c01a7336-2d3179240a8mr3048105ad.18.1786416347443; Mon, 10 Aug 2026 19:45:47 -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-2d31623091dsm470185ad.77.2026.08.10.19.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 19:45:46 -0700 (PDT) From: Kyle Hsieh Date: Tue, 11 Aug 2026 10:48:37 +0800 Subject: [PATCH v4 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: <20260811-ti-ads112c04-driver-v4-1-ae704ac17241@gmail.com> References: <20260811-ti-ads112c04-driver-v4-0-ae704ac17241@gmail.com> In-Reply-To: <20260811-ti-ads112c04-driver-v4-0-ae704ac17241@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 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=5286; i=kylehsieh1995@gmail.com; h=from:subject:message-id; bh=1tYkE6Rm1DfrZKIHMjwRAG2g1+xTsNua0nLGrevK7VA=; b=owGbwMvMwMW4tNlpO2fYkUbG02pJDFlVvZ1n+iP/VuevePiaX6r5+crL4Wc2fdY3S/031fbLF G52g12MnYzGLAyMXAyyYoosJ+WO9aY8j/hpeGzFdJhBrEwgUxi4OAVgIjxSHAy78zxTz1hpM3/q 33rlX4+ekupJvq+WnI8Xr5yTosMvwJBxVjx/9rSJxdeNi/oXsTGqi/X0WzEHnmQ/euK988PphTK h5QzOq051PpuyJtOkdLJD8A1ed36ZAKF/e9tdKthUKvpCZEO6fbSuSvgyWhRrZTu9XVqzIpopdF 8Im3HSoyX/9MTcmvr8/7Tek+5NXiU1982m568MHom9smebn6Cdavjoe4bU/2/vanbcVVGbojKLQ 1Bz/SLRTy6m+zy9v8yefrZ7FVO/p42IpPVag11Xj+hWhlR/nKsk0Bk10ejSjoN6LCvUj3zbxfRI xdXtt8qka6XenTONGrPOT40sLfFddZiHddpxVsGCD1/dAA== 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. Signed-off-by: Kyle Hsieh Acked-by: Conor Dooley Reviewed-by: David Lechner --- .../devicetree/bindings/iio/adc/ti,ads112c04.yaml | 148 +++++++++++++++++= ++++ MAINTAINERS | 6 + 2 files changed, 154 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..68a0df21cedd --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/ti,ads112c04.yaml @@ -0,0 +1,148 @@ +# 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. + + "#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: + items: + - enum: [10000, 50000, 100000, 250000, 500000, 1000000, 1500000] + + burn-out-current-nanoamp: + items: + - 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 Tue Sep 29 07:39:38 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 8FBEF3947AC for ; Tue, 11 Aug 2026 02:45:57 +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=1786416365; cv=none; b=Twpz3RHgCeFlcxIH7Jth2/R7qpmZaU07NWYdYdar6Nv5Dene6yMdPTCAAHHT3hyOmC0cDT9ViYct9GZ/If1UV9OVUFoFBuXzWMDhei6ptLy0cyqtJAzS6E2vn0pTGABt1WXfYCQi+SjV9WIr/d4bEC9T1LLFmB2nKM92kjhLSKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786416365; c=relaxed/simple; bh=f3WOfaCsiSdcBgUSB+PdQ7v8ScPebFBDtn+vzR4wI+M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aENfG46+PoOr4Ry9xGqbKBmPkWWuxUHGkh2174VCZH5u/O7hyenE7Sx3lJkoe9OaCMPAYHPOByE2rz5z1xbm89ipFkAmeF0+a0WZ5bI36PRNwZrgH6NvCsmsWIOhIrRMnGN2J5zcmp7SZKlaH3vty2nc52xT9Su5KSjBZHY2bvM= 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=XYVMsTZC; 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="XYVMsTZC" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2cfbbdfa60bso22550415ad.3 for ; Mon, 10 Aug 2026 19:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786416351; x=1787021151; 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=ZcHZXKYEl5buDnF5eCEZqTUNRWzf9SOm45D0Aau+YBI=; b=XYVMsTZCRfMzAcPSYYcPbgQcP6QYyPnp9PbVpyJ88VcQUV1hYggaXJaFwnyx/RWpl+ C9FoWKwHjYD0UcXEbzrRWL1PeYIf5IhH7fCEMTXqrYYbEkGHlQcWrHS+jVfGaf7UDqHs LgBvu1YshfBndpVfWlo8XZoE2WK1mQ3qsn7R9i27jEXDJdqRWcBVgTo5CfFZjXWd/Kmq iN3Wc2XxcMy/WNfGshLK7bd5iBX86hL9ZJrv6hbCXer0PcGgjRruuMk8gNocCQ/r+J/u 2Ud5lvxqyxYG1gXgFpsdveVVlPr0p/y1O2bFa4WFHA1nnTqJZAFJMDpsLf5tnemaKOv9 VxQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786416351; x=1787021151; 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=ZcHZXKYEl5buDnF5eCEZqTUNRWzf9SOm45D0Aau+YBI=; b=mLXxK7TEKpG17uUcmQV0tbH7gB4f5LjLbabDjkFAYFLRjxoFuVIW4kVO4FyDHRS8E/ aXbhMf6sojuJhWv1R1Y/+a8yjbdK/wiJhPPDhDLJ6C+uEdWWk38BPezJ/BUUuD06aVkh Fi5GfeERwwqzdL349++s9B3FPyeDLCe/ol3wtk+rFExZF/5b8NaH4nwXG9UTh2OTedrl YgRlkYS6uslZrBy/cTjzIbKYhizw4kwQEXH8AZcRODM5kbqFBC1sVBwFqKQXG4fcqBPS YHPwIfHA6ZCAgQDtMyicc45vlgL3OYQb2Ezp0HK0PowSxGRAp7nuKnn3L6yiiqyElwia NqXw== X-Forwarded-Encrypted: i=1; AHgh+RrIu7NSoYnozx5mjvF0fTnI7XZDzPmoBO2ha2PcapWvh3fwRqBLPrfA+Gm8wZJFw8nipA8wFrSAzSFrFhU=@vger.kernel.org X-Gm-Message-State: AOJu0YzUlMgk4N2waIuhiht/Uw/QxhVrX2mibJ/DB3sXj1jodRvkDS72 ICdG9fW5hgHlU9UiftMZXj3nbR2DZAep1xSM4mnupffU4fA3w+u+6VPwYa8x7A== X-Gm-Gg: AR+sD12HzB968B8rJ2jUlyPoBwfFVrHr7XOnb9WVrrcCDPVCVUnW/qTbYMSoyZj4AWr 2LEKjbMONNCKRSxeXkAnLV8SuFFG+YqCwoVWDgmbpbiu3Wyq2kWPu11QTp36H78Xx4xUABuQnEU 2XTYYe6ZD+x10UmnngoNYPt5K9gAFFNgKIwntn9EXc11atwJAPus3bQnBFMi5tErG8PtvD9ITBS cKm9DWc0ASM8fdHwnOJVJ9ZDZ0gD4hIqV2QdeLhvEMrXa4QG+fJO2w78uEiugjmYuF/488N+k5l Jcmk4MK9RAkX02E/uaTzzdalD0UOd38m5JEDkdnJW+QAjHgMBBoPQR0DdxSqUkwKLcoBeJ2ncht YtFw886e5fLwegHHR9h7gLne9ruuatrWnklrOlPkAjs7zdAZlLuqiajefDxkfSh3Yy/qA0ixSMU aNth9NCbqgsNm+MTn/5s0KVptsmFFf1clQz7iCm0tYQoRLlQTHugBiyaue4dF8gHN5FZz8ZzfCe hPKB1dojxzCHLDasnWQvPIH1PmF X-Received: by 2002:a17:902:ef46:b0:2cf:afa5:b19a with SMTP id d9443c01a7336-2d3178c5461mr2928135ad.11.1786416351035; Mon, 10 Aug 2026 19:45:51 -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-2d31623091dsm470185ad.77.2026.08.10.19.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 19:45:50 -0700 (PDT) From: Kyle Hsieh Date: Tue, 11 Aug 2026 10:48:38 +0800 Subject: [PATCH v4 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: <20260811-ti-ads112c04-driver-v4-2-ae704ac17241@gmail.com> References: <20260811-ti-ads112c04-driver-v4-0-ae704ac17241@gmail.com> In-Reply-To: <20260811-ti-ads112c04-driver-v4-0-ae704ac17241@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 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=14590; i=kylehsieh1995@gmail.com; h=from:subject:message-id; bh=f3WOfaCsiSdcBgUSB+PdQ7v8ScPebFBDtn+vzR4wI+M=; b=owEBbQGS/pANAwAKAaWDQrcJVsSBAcsmYgBqeo2JP4Ok03DWiy5q1IAvUpOcipc05qorkmB7V D0PaBAaPDqJATMEAAEKAB0WIQTJHsaNZOdY+THGqJelg0K3CVbEgQUCanqNiQAKCRClg0K3CVbE gV9AB/9pqP5R/onmJ0gxbzGUrM4sfeaLo3UhJbP18At7cdmtRVmTIt/z6l0L0zRWKLc2gEPIl7e oLQqrJV/Z/IykfmsiIHaW427M48lbhLwGRJ6C8NGMxAgP/lTE3wUaOJjQVHLL4af+1avcTi5zJX wCEnLxIccoVi8+j8RtPZc+/YU+bjWfZS/iY7xsL8mZbGt4AJUn2K4QzHmLlaj3kltoMP5gqzAQk AK1zDrBKviJh6Zfy4LdzE+UZpkzvEPbeqYw00ueEUqKAwNCbU8vAAwsPc2D/a77IxnkAyTPf/PW Ew97kmf8HCDSNJP6mPqrXJV0ZZNWVfpdqKSPjWZumNIO6T6v 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. - Scale calculation based on the internal 2.048V reference. - Reference voltage scaling via the regulator subsystem (refp-supply), falling back to the internal 2.048V reference if not specified. refn-supply is not yet supported. - Hardware reset fallback using GPIO. Signed-off-by: Kyle Hsieh --- MAINTAINERS | 1 + drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ti-ads112c04.c | 425 +++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 437 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..0ee50828f9e4 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..3a775da2ae23 --- /dev/null +++ b/drivers/iio/adc/ti-ads112c04.c @@ -0,0 +1,425 @@ +// 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_POWERDOWN 0x02 +#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_REG_CONFIG1 0x01 +#define ADS112C04_REG_CONFIG2 0x02 +#define ADS112C04_REG_CONFIG3 0x03 + +#define ADS112C04_CONFIG0_MUX GENMASK(7, 4) +#define ADS112C04_CONFIG0_PGA_BYPASS BIT(0) +#define ADS112C04_CONFIG2_DRDY BIT(7) + +struct ads112c04_state { + struct i2c_client *client; + /* Protects concurrent ADC reads and device configuration */ + struct mutex lock; + struct completion completion; + int vref_mV; + u8 config0; + u8 config1; + bool has_refp; +}; + +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) */ + ret =3D wait_for_completion_timeout(&st->completion, + msecs_to_jiffies(100)); + if (!ret) + return -ETIMEDOUT; + + return 0; + } + + err =3D read_poll_timeout(ads112c04_read_reg, ret, + (ret < 0 || (val & ADS112C04_CONFIG2_DRDY)), + 1000, 100 * USEC_PER_MSEC, false, + st->client, ADS112C04_REG_CONFIG2, &val); + + if (ret < 0) + return ret; + + return err; +} + +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, 15); + + return 0; +} + +static int ads112c04_get_adc_result(struct ads112c04_state *st, + struct iio_chan_spec const *chan, + int *val) +{ + u8 new_config0; + int ret; + + new_config0 =3D st->config0; + FIELD_MODIFY(ADS112C04_CONFIG0_MUX, &new_config0, chan->address); + + if (st->config0 !=3D new_config0) { + ret =3D ads112c04_write_reg(st->client, ADS112C04_REG_CONFIG0, new_confi= g0); + if (ret < 0) + return ret; + st->config0 =3D new_config0; + } + + 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; + + ret =3D ads112c04_read_data(st, val); + if (st->client->irq > 0) + enable_irq(st->client->irq); + + return ret; +} + +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); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + ret =3D ads112c04_get_adc_result(st, chan, val); + mutex_unlock(&st->lock); + + if (ret < 0) + return ret; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + *val =3D st->vref_mV; + *val2 =3D 15; + 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); + + disable_irq_nosync(irq); + complete(&st->completion); + + return IRQ_HANDLED; +} + +static const struct iio_info ads112c04_info =3D { + .read_raw =3D ads112c04_read_raw, +}; + +static int ads112c04_parse_channels(struct iio_dev *indio_dev) +{ + 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]; + int ret, i =3D 0; + + 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 > 12) + return dev_err_probe(dev, -EINVAL, + "num of channel nodes exceeds 12\n"); + + channels =3D devm_kcalloc(dev, num_channels, sizeof(*channels), GFP_KERNE= L); + if (!channels) + return -ENOMEM; + + device_for_each_named_child_node_scoped(dev, child, "channel") { + 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"); + + if (fwnode_property_present(child, "reference-sources")) { + const char *ref; + + ret =3D fwnode_property_read_string(child, "reference-sources", &ref); + if (ret) + return dev_err_probe(dev, ret, + "failed to read reference-sources\n"); + + if ((!strcmp(ref, "external") && !st->has_refp) || + (!strcmp(ref, "internal") && st->has_refp)) + return dev_err_probe(dev, -EINVAL, + "reference-sources does not match refp-supply\n"); + } + + 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, "single-channel")) { + ret =3D fwnode_property_read_u32(child, "single-channel", &pair[0]); + if (ret) + return dev_err_probe(dev, ret, + "failed to read single-channel property\n"); + + if (pair[0] > 3) + return dev_err_probe(dev, -EINVAL, + "single-channel must be 0-3\n"); + + spec->channel =3D pair[0]; + spec->address =3D 0x08 + pair[0]; + } else if (fwnode_property_present(child, "diff-channels")) { + ret =3D fwnode_property_read_u32_array(child, "diff-channels", pair, 2); + if (ret) + return dev_err_probe(dev, ret, + "failed to read diff-channels property\n"); + + if (pair[0] > 3 || pair[1] > 3) + return dev_err_probe(dev, -EINVAL, + "diff-channels must be 0-3\n"); + + spec->channel =3D pair[0]; + spec->channel2 =3D pair[1]; + spec->differential =3D 1; + + if (pair[0] =3D=3D 0 && pair[1] =3D=3D 1) + spec->address =3D 0x00; + else if (pair[0] =3D=3D 0 && pair[1] =3D=3D 2) + spec->address =3D 0x01; + else if (pair[0] =3D=3D 0 && pair[1] =3D=3D 3) + spec->address =3D 0x02; + else if (pair[0] =3D=3D 1 && pair[1] =3D=3D 0) + spec->address =3D 0x03; + else if (pair[0] =3D=3D 1 && pair[1] =3D=3D 2) + spec->address =3D 0x04; + else if (pair[0] =3D=3D 1 && pair[1] =3D=3D 3) + spec->address =3D 0x05; + else if (pair[0] =3D=3D 2 && pair[1] =3D=3D 3) + spec->address =3D 0x06; + else if (pair[0] =3D=3D 3 && pair[1] =3D=3D 2) + spec->address =3D 0x07; + else + return dev_err_probe(dev, -EINVAL, + "invalid diff-channels combination\n"); + } else { + return dev_err_probe(dev, -EINVAL, + "channel node must have single-channel or diff-channels\n"); + } + + i++; + } + + indio_dev->channels =3D channels; + indio_dev->num_channels =3D i; + + return 0; +} + +#define ADS112C04_VREF_INTERNAL_MV 2048 + +static int ads112c04_probe(struct i2c_client *client) +{ + struct device *dev =3D &client->dev; + struct iio_dev *indio_dev; + struct ads112c04_state *st; + struct gpio_desc *reset_gpio; + 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"); + + st->has_refp =3D device_property_present(dev, "refp-supply"); + + ret =3D ads112c04_parse_channels(indio_dev); + if (ret) + return ret; + + 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->vref_mV =3D ret / (MICRO / MILLI); + st->config1 =3D 0x02; + } else { + st->vref_mV =3D ADS112C04_VREF_INTERNAL_MV; + st->config1 =3D 0x00; + } + + /* Power-On Reset (POR) delay */ + fsleep(50 * USEC_PER_MSEC); + + /* Requesting OUT_HIGH asserts the active-low reset pin immediately */ + reset_gpio =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(reset_gpio)) + return PTR_ERR(reset_gpio); + + if (reset_gpio) { + fsleep(1000); + gpiod_set_value_cansleep(reset_gpio, 0); + } else { + ret =3D ads112c04_write_cmd(client, ADS112C04_CMD_RESET); + if (ret < 0) + return ret; + } + + fsleep(1000); + + /* Bypass PGA for now to allow full-scale single-ended measurements */ + st->config0 =3D ADS112C04_CONFIG0_PGA_BYPASS; + ret =3D ads112c04_write_reg(client, ADS112C04_REG_CONFIG0, st->config0); + if (ret) + return ret; + + 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