From nobody Sat Jul 25 18:53:59 2026 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 3427943552B for ; Tue, 14 Jul 2026 19:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058947; cv=none; b=J7EzfXdYk5e82dluTHwnCY1ppR0JDC8g8uFG/7uY/etgSxKUVN4jSL1lmwbqCa34TbfJUJ+/mySBs6h2Pkg8E+WN0drltTrrY10oWNnUmazHaCvnMdbZdVfY7ZZg2ISx4CrjYfld21OSHX3AeKAC++JhFTPoKIRaqRw8Ha0sOGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058947; c=relaxed/simple; bh=r/XQGH/yp0z7+A9uwbCk2tceFw3oDx5VYnS38/gSh2g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fpfZg/3P2JygdJUd5cGWEf0yTicGhOP2vO7Yh/LOd92ZvMhvNF2SirCvOn0yoKSZyyOYWZoV5/pk4Vp8Bf6xbiKlRCEvmO+Uro93ujlcOqLtSAE/NLImQ0HRioisbfz/2Ie2RrJuTpVux6QJ3CSEqfPhssPCXu10P0tw1zoa4tM= 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=ZGF4rVNw; arc=none smtp.client-ip=209.85.167.43 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="ZGF4rVNw" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5b01cb18515so4410505e87.2 for ; Tue, 14 Jul 2026 12:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784058943; x=1784663743; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=a/ji6cByUOnY3CtiRZ9zb9jnxCe1/JgaItNeBfbBs8U=; b=ZGF4rVNwmhoazZP0FRyP4Lj0Ti/xI7yPkZCGQC2h3yWOKQof5RjOgYGC9vxUPTaDoI 6EDuFLq3m//Ew/nx5gtk1+H+HlHwF2oX8joROZbAxpUS6onrZ6Bnxblf2oxP81i0Wm+w //7JPq3tjaSymKQsTlrN9OxS64rJzqtM78H+ARuZgslb5pWCJinP9fNdSCtNThtJ+OwE xgBaF2e9b4LHH2nCGwIIGF/cvPgG/dJkfvTqyUoSveo459G9fy4qJYL58laNDs4GiZCr offVe+w0BH7PLdqpt5nqHPutXG0f/pRVAA3W02P9bE1I6qZU3IMkbv+mDEgR56q/FQDp d60Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784058943; x=1784663743; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=a/ji6cByUOnY3CtiRZ9zb9jnxCe1/JgaItNeBfbBs8U=; b=QNB8etE7IGTKDFCPWRiJbzUKlsDmlVvJKuFL2efsCkXPtjXBIePT0k9VUKzYwfWtHE LE5b6bBFzuAfsN2ep24DwjXpOIO9luyl3alK5hoKWNtF/fHopLdTo34kgHlszSFzkSz+ 7O3dLq6TxLezuC8cT/NT2LPEm/zaUcBXmMbjywlAkn25xzS7USCFJ4zKIiShtklMhomy eKYnStodAemdBPWRPbgA5A/tifsJtG+zIiOFc2ZklUJP0FLjcDZyep0gKswxGx2f1kwH FPuY5ljIwzkQ+c/fSU3YO30cVu2lCq4me0CJUzPYUgAYYcOt8gSmDYL3rEnaKw1+x646 frXg== X-Forwarded-Encrypted: i=1; AHgh+RpPkHhG+gnCvU/8pAIHef8kqkK6M6SRSOfer4oePmDtX2eu8gDIFNNSsybj6oXI38PKyi9PN1Kx2hp8iDc=@vger.kernel.org X-Gm-Message-State: AOJu0YwPPIAB23VYtEknmzRLglTFkdA8q9K1atw+zOBLdmlzSg7l8MSa /tj8NnIo/CdRr9nJLFUWk5pM8aa9rSRfidatZKQN3Wqa1JFv96VMJloG X-Gm-Gg: AfdE7ckWo4sT0Xi97IJw/mVk5YG4JiMbh8yKzLe61UDePKCFXFoztnpAzd+OMRGweAA emYupt1AnZ/Jtupa1TazoJgOEd/7tkZiT0QFQiv8LK/NEMWQ+PTcxsYZeFTphbBQs4U1F1/wMK3 Yw0fZgb8Xa139X+Y1188EwXlQpCTxMTfw3X4gXkfg2216BhDJGhJFss7sYW4a9P/jgo8Ovhh7x7 zPXHDuZsleAdhXrwJrL4/akyxju/I7cjIOjDQ9G05DjzKtX9CCjb4Ec0XBcUyZ+kVM23bKxEsi2 rJ7S9vhFeh/EdcwloxcLCxRurezrAt3I8jLeq7ZbDYP6dbrS2N7fZ6rclLKw1ZHqZS+8Aqvca96 bMHsJVIKPyMtgPSXxvmN8S78r9WK+c6bLbnniWQYV9QpScnIISA4WONHZS2i8HuVt3Sp6mQw8SU 0nXqqre7hAwB04Jqp3ho2m0VqzGB+esA0Pl9Hr4LByZt9kXm6P+6Tzs3jJxA== X-Received: by 2002:a05:6512:4205:b0:5b1:543f:f5c4 with SMTP id 2adb3069b0e04-5b159b88f35mr639383e87.43.1784058943177; Tue, 14 Jul 2026 12:55:43 -0700 (PDT) Received: from MSI-LINUX.kielce.vectranet.pl ([2a02:2a40:27ec:2900:822e:374d:22e8:16cf]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b01ca501bfsm3693490e87.26.2026.07.14.12.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 12:55:42 -0700 (PDT) From: Jakub Szczudlo To: linux-iio@vger.kernel.org Cc: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, marcelo.schmitt@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mike.looijmans@topic.nl, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, jorge.marques@analog.com, antoniu.miclaus@analog.com, mazziesaccount@gmail.com, jishnu.prakash@oss.qualcomm.com, duje@dujemihanovic.xyz, wens@kernel.org, sakari.ailus@linux.intel.com, linusw@kernel.org, Jakub Szczudlo Subject: [PATCH v7 1/3] iio: adc: ti-ads1100: Fix incorrect reading when datarate changed in single mode Date: Tue, 14 Jul 2026 21:55:26 +0200 Message-ID: <20260714195528.597753-2-jakubszczudlo40@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260714195528.597753-1-jakubszczudlo40@gmail.com> References: <20260714195528.597753-1-jakubszczudlo40@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When device is suspended and it is in single mode then changing datarate doesn't make it actually wait for new measurement, so to be sure that read after change is correct functions that changes datarate and gain will wait for a new data. Fixes: 541880542f2b ("iio: adc: Add TI ADS1100 and ADS1000") Signed-off-by: Jakub Szczudlo Reviewed-by: Andy Shevchenko Reviewed-by: David Lechner --- drivers/iio/adc/ti-ads1100.c | 71 ++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti-ads1100.c b/drivers/iio/adc/ti-ads1100.c index 9fe8d54cce83..f0a30ae139af 100644 --- a/drivers/iio/adc/ti-ads1100.c +++ b/drivers/iio/adc/ti-ads1100.c @@ -15,10 +15,12 @@ #include #include #include +#include #include #include #include #include +#include #include =20 #include @@ -43,6 +45,9 @@ static const int ads1100_data_rate[] =3D { 128, 32, 16, 8 }; static const int ads1100_data_rate_bits[] =3D { 12, 14, 15, 16 }; =20 +/* Timeout based on the minimum sample rate of 8 SPS (7500ms) */ +#define ADS1100_MAX_DRDY_TIMEOUT_US (7500 * USEC_PER_MSEC) + struct ads1100_data { struct i2c_client *client; struct regulator *reg_vdd; @@ -123,10 +128,50 @@ static int ads1100_get_adc_result(struct ads1100_data= *data, int chan, int *val) return 0; } =20 +static int ads1100_new_data_is_ready(struct ads1100_data *data) +{ + u8 buffer[3]; + int ret; + + ret =3D i2c_master_recv(data->client, (char *)&buffer, sizeof(buffer)); + if (ret < 0) { + dev_err(&data->client->dev, "I2C read fail: %d\n", ret); + return ret; + } + + return FIELD_GET(ADS1100_CFG_ST_BSY, buffer[2]); +} + +static int ads1100_poll_data_ready(struct ads1100_data *data) +{ + int data_rate_Hz =3D ads1100_data_rate[FIELD_GET(ADS1100_DR_MASK, data->c= onfig)]; + /* To be sure we wait 5 times more than data rate */ + unsigned long wait_time_us =3D DIV_ROUND_CLOSEST(USEC_PER_SEC, 5 * data_r= ate_Hz); + int data_ready; + u8 buffer[3]; + int ret; + + /* To be sure that polled value will have value after config change */ + ret =3D i2c_master_recv(data->client, (char *)&buffer, sizeof(buffer)); + if (ret < 0) { + dev_err(&data->client->dev, "I2C read fail: %d\n", ret); + return ret; + } + + ret =3D readx_poll_timeout(ads1100_new_data_is_ready, data, + data_ready, data_ready !=3D 0, + wait_time_us, ADS1100_MAX_DRDY_TIMEOUT_US); + if (ret) + return ret; + + return data_ready < 0 ? data_ready : 0; +} + static int ads1100_set_scale(struct ads1100_data *data, int val, int val2) { int microvolts; int gain; + int ret; =20 /* With Vdd between 2.7 and 5V, the scale is always below 1 */ if (val) @@ -135,6 +180,11 @@ static int ads1100_set_scale(struct ads1100_data *data= , int val, int val2) if (!val2) return -EINVAL; =20 + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(&data->client->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; + microvolts =3D regulator_get_voltage(data->reg_vdd); /* * val2 is in 'micro' units, n =3D val2 / 1000000 @@ -149,22 +199,35 @@ static int ads1100_set_scale(struct ads1100_data *dat= a, int val, int val2) =20 ads1100_set_config_bits(data, ADS1100_PGA_MASK, ffs(gain) - 1); =20 - return 0; + return ads1100_poll_data_ready(data); } =20 static int ads1100_set_data_rate(struct ads1100_data *data, int chan, int = rate) { unsigned int i; unsigned int size; + int ret; =20 size =3D data->supports_data_rate ? ARRAY_SIZE(ads1100_data_rate) : 1; for (i =3D 0; i < size; i++) { if (ads1100_data_rate[i] =3D=3D rate) - return ads1100_set_config_bits(data, ADS1100_DR_MASK, - FIELD_PREP(ADS1100_DR_MASK, i)); + break; } =20 - return -EINVAL; + if (i =3D=3D size) + return -EINVAL; + + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(&data->client->dev, pm); + ret =3D PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret) + return ret; + + ret =3D ads1100_set_config_bits(data, ADS1100_DR_MASK, + FIELD_PREP(ADS1100_DR_MASK, i)); + if (ret) + return ret; + + return ads1100_poll_data_ready(data); } =20 static int ads1100_get_vdd_millivolts(struct ads1100_data *data) --=20 2.47.3 From nobody Sat Jul 25 18:53:59 2026 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 6C11E43552A for ; Tue, 14 Jul 2026 19:55:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058949; cv=none; b=omtCO88zRJMmRtS62jRLGmo8HmiBtZMTD64gkcsgdZsZbdDepWk4j7O27PaATVDavJEFRTp/RBDAujQviU4yzPlgDeX5uaZjYawmtKaLte2+2nKJ9NmeebVgGPrZYx9uVI0S19LRKoAMMwYyEfB0YS+VgOH1DE30V2Udf+xDNJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058949; c=relaxed/simple; bh=U2YoNQx/hGloZRC8McPJss1WdTnU2vgI7Fy7zmdhFok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FCM40oYSCdnjEyBfBJBdj5xogIPFEgmDKKA+mJfjz8JoMIkyMS3ArFDfSkIyBidywROvURXmTwuxKBNW3U0NZmS/eN2NdoP9v/iIYJCr3Se0gPMKICTb7Ul1rWWP25UlYgV/FWDZti9ni689/nE8nx2nzcyLJSjVfm7QwZ8fCwI= 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=Ty514sjy; arc=none smtp.client-ip=209.85.167.48 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="Ty514sjy" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5b0148201fbso1090229e87.3 for ; Tue, 14 Jul 2026 12:55:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784058945; x=1784663745; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=L/Qd/2tRCLWffwMQFEM05180CiTbv4f9HSRyN2+W50k=; b=Ty514sjyAxemmdnG/rAqA9VgP6J/sgMb0NPHTUKzv6q10aqdjZRpJEfu4qSWhJqPvt 3Rkf+x5ZUMOv4VeVgQJwVi3ZDVoWS1WT7yNajMGTbyrZ0FOEoFQxHQ0oET3Ytccg55iD ZOyIbBPN2fZiPRLxVXaTzO3WFVE+mIPQqH56BHsF8hAtIx7HDbNWuLrXR5mGuVuQMNJf 8SFVX8LHA8e5mvZOHvsCQ0IKhdifWqgBaa29bEeSIhn1fcYCwRguu4yE2qESG8PJ5wvd 7IQ7H6E93DuYyY23MeBqyYkClWV1cDKmYxvxWHAse5fPPK2tmsgsDHC8qaLTet80PL7Z bUuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784058945; x=1784663745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=L/Qd/2tRCLWffwMQFEM05180CiTbv4f9HSRyN2+W50k=; b=N/V+3lA3FnkFJ3Hz+/RCOzuby6nMUvTk8BNMsrvGswvr/KVVKo3HNo/Zc/4xgqP1uY O8T8rR+sAhYX/fJ510xC4/7rzmDN/EnHGhLo0NIrESwaQnRtQIi0Jihnr09mTFRPACHF M4xLSTkIxkN7EJobtUcLBSuXTPVAqCAHBGXQ8gxBe8GalqK8RelsSKXlIysr6AvBKKT2 Rq41DOlldujr+QWG95r2YiFGR6CCsxdSWxG6eoUK3dvlyMlXuTVv1E1SNJohFF7NkJJv 5PeHsth0i1iQMqBEvga5uRlQB6CZVgKH7ErEYbTTLZrghpC33LvvIa+SV39jDYrl1TvK cCdQ== X-Forwarded-Encrypted: i=1; AHgh+RrrFTf2o9wfdVk8I8DgAwnn/lvxX+dpc/dKu0ITW7uooksf/QIZgE1hnaurvZZDorx3uY7jAjredihnLBQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5K5wxHBV+evCv9o+FRIZbG2ykRvmXAroezIRkNaV9Q2dij/DE 7cdNGkjnUcf2LbeVY7O9E8s6uQhxOWOcs0KQ/xHlUpxk2+TIbvjtlsni X-Gm-Gg: AfdE7cmI5CUzlZroQcDOAHbXGQ+g7Q+wv9SXPl9IJAZehc0srrrdiao9MkYHiVgiIv0 ZCLmsnM8MFrsZlXE7CzAmFNUYlCr743Cwq2KLrfKU2HhS+vFmU+M0YCtw/oFxOlHLJZS/ofDJs4 upYfjnZTeu4XGIa7TFl9g1nIbuYrWJXfwJyR6rZkSwH6ShFnAWm0gHtl038dni4YCLjiHyrvqyT NW38wU9X//pES4hyQlUyazv2UYs+TnqilmSYe2PMJ6TDISfzvLh1ViwGG81TnC7ZlumhVBHtu6z wtEIi1V6Rjng4NhaXJS165xdEcREdgORElpVDKMpB3Q3e4AV8CUmFmLp9joJimiJFHO8VNhMjtq QjqZ/e2IXYUB/5cG8XitCzQKHoR4uWxvH8TcOKubOSbG5mZXP74u4TWn2gidtk4GzpQBA8TLjko pvYCtS2eb2HPmVNG25vRgLt9cOuGsdOuPq/JFgSvWMZDwcDAwjVsR0LQue3A== X-Received: by 2002:ac2:457a:0:b0:5b0:1c19:2cf8 with SMTP id 2adb3069b0e04-5b023566565mr2278061e87.11.1784058945333; Tue, 14 Jul 2026 12:55:45 -0700 (PDT) Received: from MSI-LINUX.kielce.vectranet.pl ([2a02:2a40:27ec:2900:822e:374d:22e8:16cf]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b01ca501bfsm3693490e87.26.2026.07.14.12.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 12:55:44 -0700 (PDT) From: Jakub Szczudlo To: linux-iio@vger.kernel.org Cc: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, marcelo.schmitt@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mike.looijmans@topic.nl, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, jorge.marques@analog.com, antoniu.miclaus@analog.com, mazziesaccount@gmail.com, jishnu.prakash@oss.qualcomm.com, duje@dujemihanovic.xyz, wens@kernel.org, sakari.ailus@linux.intel.com, linusw@kernel.org, Jakub Szczudlo , Krzysztof Kozlowski Subject: [PATCH v7 2/3] dt-bindings: iio: adc: ti,ads1100: add support for ADS1110 Date: Tue, 14 Jul 2026 21:55:27 +0200 Message-ID: <20260714195528.597753-3-jakubszczudlo40@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260714195528.597753-1-jakubszczudlo40@gmail.com> References: <20260714195528.597753-1-jakubszczudlo40@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Register layouts are the same as for ADS1100 but ADS1110 have different data rates and have internal voltage reference that is always 2.048V. Also correct order of ads so they will be sorted alphabetically. Signed-off-by: Jakub Szczudlo Reviewed-by: Krzysztof Kozlowski Reviewed-by: Andy Shevchenko Reviewed-by: David Lechner --- .../devicetree/bindings/iio/adc/ti,ads1100.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/ti,ads1100.yaml b/Do= cumentation/devicetree/bindings/iio/adc/ti,ads1100.yaml index 970ccab15e1e..28c5e2dd0ad6 100644 --- a/Documentation/devicetree/bindings/iio/adc/ti,ads1100.yaml +++ b/Documentation/devicetree/bindings/iio/adc/ti,ads1100.yaml @@ -4,19 +4,23 @@ $id: http://devicetree.org/schemas/iio/adc/ti,ads1100.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: TI ADS1100/ADS1000 single channel I2C analog to digital converter +title: TI ADS1100 and similar single channel I2C Analog to Digital Convert= ers =20 maintainers: - Mike Looijmans =20 description: | - Datasheet at: https://www.ti.com/lit/gpn/ads1100 + Datasheets: + - https://www.ti.com/lit/gpn/ads1000 + - https://www.ti.com/lit/gpn/ads1100 + - https://www.ti.com/lit/gpn/ads1110 =20 properties: compatible: enum: - - ti,ads1100 - ti,ads1000 + - ti,ads1100 + - ti,ads1110 =20 reg: maxItems: 1 --=20 2.47.3 From nobody Sat Jul 25 18:53:59 2026 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 8ACF843A813 for ; Tue, 14 Jul 2026 19:55:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058952; cv=none; b=Uqg4p86ELbAhvsjTCy1YsvCEhojOJFMypzgVDnMyrL9NL8wXMmnzoiHjKIMSlO2TeXbw5nOHHHDlTZiI2Qhd2mbjsLcnHUUXMswhRXQWc8W7DfK+mtiU7n84MB2fUMLn+3iRBzD5paIa6hyr9GNK4vs23r3SejJpbuax2//vytk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058952; c=relaxed/simple; bh=cii1G3ic+VcA6JAeMUIU3jgPC6eG1P3jczjEU1l42Ek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sSYNJk0iX3GAXCMkjidI6d8/PatHfn6lW1vkklp93V1cI1oXE3HDWEUxenK48empET46wrSUyJHZYhvHq6rsG201lcAQ3YqX/eag2TGvR2WxMv3X84B0Pq/U1J5De4rxVYEajdgpqiRr7nHkiRlJ675UB3HH4etRrSDrmYh6BxU= 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=jtksgXja; arc=none smtp.client-ip=209.85.167.50 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="jtksgXja" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5aeb98460c6so1399561e87.2 for ; Tue, 14 Jul 2026 12:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784058948; x=1784663748; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=tr5NsWPWcjaYE0XW3mtUvZHR+Y1ij5DruwTL98K42t4=; b=jtksgXjawBUpdNcS8gQ/p2Dkh6TsrGYKqtyMoNQ/DoOyeEKc+sU7ydZhdiBeseY1Aj wcQBmDuWfK1fH6PX6FhgPiracvkG4XAndO31CspHQ1ZMl9Q0CkbD1zMco1Abx2fAVisG r81PBOWfZYxmSp4uYAktw/yA7fhsu4p4B8Hhs+bjEqO2ZlEFG7le+l6BMfTSvcKGkZ95 jnkmWJPA8/N2CEItBnh8VkIBH+5dntS5laT2AQtGajRR0UfLz5fVPeLEZv4hAkQlQ2Ri ImMmy+i8VhU7RXTuFffg+WnqcpIyPxtl7iQVptB5Z2AwDoiYmW36tZcFUjPFl+eYFiA1 0nSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784058948; x=1784663748; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=tr5NsWPWcjaYE0XW3mtUvZHR+Y1ij5DruwTL98K42t4=; b=r2CzHC2CWqbk/zBLGmkVn0/jfh9PdDHRkG+l2x6hQQ/XoK3D/aGPyAs1ZQJXCtfosW qUy22LFEh60oTGumWaRuP0m+DsLY9W5buln50Tqn09AnqXG7PxC4M0ZsjG7tXVQB0/ie 6jt9p7N6k6nQPtRvNA2+0Z/aWZW1ME1532N2lvLBYVErGPF9Q0cXAYEyWN9MfJJJ9Glf 3XDCcBgnTVw+7o5wHqqYGESdXhs5qkMIG1tlgB3sDjlgnOe7k6iRZpTrzXcs/0exI/vV n2Ovz3q/1YIyWYPPCVcVdmx1vls2ZSEJWkdqnFfZITtrEoK8a2MaOTgXgx+AphdD0J4e Au3g== X-Forwarded-Encrypted: i=1; AHgh+RpNsvCCzCjTuO+iz2MrNr9vAr+UtISfHCRJohiu7jCQfrnJ5w0RfIdexBKxsAcl40pIEJjHvsHhquaoflo=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9mqQVPj80GbUcsD5+lyVT35DuxTFt8Zu0sl49ODQgAYAwt/EC D6FXfs5gVXWf8tDNhg0Fs0vbWJ3J0pNe3fbwaxqwp/aAk6p76yooDQxKjkPgHq6C X-Gm-Gg: AfdE7cknYmohJCxQOnGS+1yeeyMDl99/YjuS0uB80PDksW+9kTQ72ILA20D+FLU7Rcm GGht7w9KFlmjEpQBgHMLQ9CRRrxNuX7/E5KhSyrOzhYSaup1fDJT7EU3GDLP2fOozpDEp4CgEhb NecfGcxkovzo8YGPE44e/FQabUc/+Ttk9+VvfndIH5ZC3yPR3z0Y+L2mp6ocMjsy4DxO30D0X61 +cgZPZPWIni4HBLTyUJSb+r1h5wAKWZ1x7AsIX/WphVgSWj+jkIHNBAMQFjUCNTpxC75cmDXvaQ SdGPAL4bO1HqR0tBly8Ry1lsWZ4qzCpgxz+ERQpBJoboLKgIIBuG7hAodz9w5hGc8Z26rVFDHFu R8HuCzcytRh0u7WOqLz5DV+T4XbfJ4ZMoQPLWgNLzcc99UoTPCEYUvrc2Och/fWLQwTQcFVkrjA nwue19LcRZs8vcqlh951Zi9zM7w+aq0w2c8C2Xb2YVfPbzPrA= X-Received: by 2002:ac2:57c6:0:b0:5b0:17e7:67d0 with SMTP id 2adb3069b0e04-5b0236c860amr2422594e87.62.1784058947539; Tue, 14 Jul 2026 12:55:47 -0700 (PDT) Received: from MSI-LINUX.kielce.vectranet.pl ([2a02:2a40:27ec:2900:822e:374d:22e8:16cf]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b01ca501bfsm3693490e87.26.2026.07.14.12.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 12:55:47 -0700 (PDT) From: Jakub Szczudlo To: linux-iio@vger.kernel.org Cc: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, marcelo.schmitt@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mike.looijmans@topic.nl, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, jorge.marques@analog.com, antoniu.miclaus@analog.com, mazziesaccount@gmail.com, jishnu.prakash@oss.qualcomm.com, duje@dujemihanovic.xyz, wens@kernel.org, sakari.ailus@linux.intel.com, linusw@kernel.org, Jakub Szczudlo Subject: [PATCH v7 3/3] iio: adc: ti-ads1100: Add ti-ads1110 support to ti-ads1100 driver Date: Tue, 14 Jul 2026 21:55:28 +0200 Message-ID: <20260714195528.597753-4-jakubszczudlo40@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260714195528.597753-1-jakubszczudlo40@gmail.com> References: <20260714195528.597753-1-jakubszczudlo40@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add ADS1110 support that have faster datarate than ADS1100, it also uses internal voltage reference of 2.048V for measurement. Signed-off-by: Jakub Szczudlo Reviewed-by: Andy Shevchenko Reviewed-by: David Lechner --- drivers/iio/adc/Kconfig | 9 ++-- drivers/iio/adc/ti-ads1100.c | 87 +++++++++++++++++++++++++++--------- 2 files changed, 71 insertions(+), 25 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 3755a81c1efd..49a9ac3bf43d 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1768,11 +1768,14 @@ config TI_ADS1018 called ti-ads1018. =20 config TI_ADS1100 - tristate "Texas Instruments ADS1100 and ADS1000 ADC" + tristate "Texas Instruments ADS1100 and similar single channel I2C ADC" depends on I2C help - If you say yes here you get support for Texas Instruments ADS1100 and - ADS1000 ADC chips. + If you say yes here you get support for TI single channel I2C Analog + Devices. + * ADS1000 12-Bit, 128 SPS Analog-to-Digital Converter + * ADS1100 16-Bit, 128 SPS Analog-to-Digital Converter + * ADS1110 16-Bit, 240 SPS Analog-to-Digital Converter =20 This driver can also be built as a module. If so, the module will be called ti-ads1100. diff --git a/drivers/iio/adc/ti-ads1100.c b/drivers/iio/adc/ti-ads1100.c index f0a30ae139af..5d798bfcc74e 100644 --- a/drivers/iio/adc/ti-ads1100.c +++ b/drivers/iio/adc/ti-ads1100.c @@ -5,7 +5,7 @@ * Copyright (c) 2023, Topic Embedded Products * * Datasheet: https://www.ti.com/lit/gpn/ads1100 - * IIO driver for ADS1100 and ADS1000 ADC 16-bit I2C + * IIO driver for ADS1100 and similar single channel ADC 16-bit I2C */ =20 #include @@ -41,20 +41,44 @@ #define ADS1100_SINGLESHOT ADS1100_CFG_SC =20 #define ADS1100_SLEEP_DELAY_MS 2000 +#define ADS1110_INTERNAL_REF_mV 2048 =20 static const int ads1100_data_rate[] =3D { 128, 32, 16, 8 }; +static const int ads1110_data_rate[] =3D { 240, 60, 30, 15 }; static const int ads1100_data_rate_bits[] =3D { 12, 14, 15, 16 }; =20 /* Timeout based on the minimum sample rate of 8 SPS (7500ms) */ #define ADS1100_MAX_DRDY_TIMEOUT_US (7500 * USEC_PER_MSEC) =20 +struct ads1100_config { + const char *name; + const int *available_data_rate_hz; + const int data_rate_count; + bool has_internal_vref_only; +}; + +static const struct ads1100_config ads1100_config =3D { + .name =3D "ads1100", + .available_data_rate_hz =3D ads1100_data_rate, + .data_rate_count =3D ARRAY_SIZE(ads1100_data_rate), + .has_internal_vref_only =3D false, +}; + +static const struct ads1100_config ads1110_config =3D { + .name =3D "ads1110", + .available_data_rate_hz =3D ads1110_data_rate, + .data_rate_count =3D ARRAY_SIZE(ads1110_data_rate), + .has_internal_vref_only =3D true, +}; + struct ads1100_data { struct i2c_client *client; struct regulator *reg_vdd; struct mutex lock; int scale_avail[2 * 4]; /* 4 gain settings */ + const struct ads1100_config *ads_config; u8 config; - bool supports_data_rate; /* Only the ADS1100 can select the rate */ + bool supports_data_rate; }; =20 static const struct iio_chan_spec ads1100_channel =3D { @@ -90,6 +114,20 @@ static int ads1100_set_config_bits(struct ads1100_data = *data, u8 mask, u8 value) return 0; }; =20 +static int ads1100_get_vref_millivolts(struct ads1100_data *data) +{ + int voltage_uV; + + if (data->ads_config->has_internal_vref_only) + return ADS1110_INTERNAL_REF_mV; + + voltage_uV =3D regulator_get_voltage(data->reg_vdd); + if (voltage_uV < 0) + return voltage_uV; + + return voltage_uV / (MICRO / MILLI); +} + static int ads1100_data_bits(struct ads1100_data *data) { return ads1100_data_rate_bits[FIELD_GET(ADS1100_DR_MASK, data->config)]; @@ -144,7 +182,8 @@ static int ads1100_new_data_is_ready(struct ads1100_dat= a *data) =20 static int ads1100_poll_data_ready(struct ads1100_data *data) { - int data_rate_Hz =3D ads1100_data_rate[FIELD_GET(ADS1100_DR_MASK, data->c= onfig)]; + int data_rate_index =3D FIELD_GET(ADS1100_DR_MASK, data->config); + int data_rate_Hz =3D data->ads_config->available_data_rate_hz[data_rate_i= ndex]; /* To be sure we wait 5 times more than data rate */ unsigned long wait_time_us =3D DIV_ROUND_CLOSEST(USEC_PER_SEC, 5 * data_r= ate_Hz); int data_ready; @@ -185,7 +224,7 @@ static int ads1100_set_scale(struct ads1100_data *data,= int val, int val2) if (ret) return ret; =20 - microvolts =3D regulator_get_voltage(data->reg_vdd); + microvolts =3D ads1100_get_vref_millivolts(data) * (MICRO / MILLI); /* * val2 is in 'micro' units, n =3D val2 / 1000000 * result must be millivolts, d =3D microvolts / 1000 @@ -208,9 +247,9 @@ static int ads1100_set_data_rate(struct ads1100_data *d= ata, int chan, int rate) unsigned int size; int ret; =20 - size =3D data->supports_data_rate ? ARRAY_SIZE(ads1100_data_rate) : 1; + size =3D data->supports_data_rate ? data->ads_config->data_rate_count : 1; for (i =3D 0; i < size; i++) { - if (ads1100_data_rate[i] =3D=3D rate) + if (data->ads_config->available_data_rate_hz[i] =3D=3D rate) break; } =20 @@ -230,14 +269,9 @@ static int ads1100_set_data_rate(struct ads1100_data *= data, int chan, int rate) return ads1100_poll_data_ready(data); } =20 -static int ads1100_get_vdd_millivolts(struct ads1100_data *data) -{ - return regulator_get_voltage(data->reg_vdd) / (MICRO / MILLI); -} - static void ads1100_calc_scale_avail(struct ads1100_data *data) { - int millivolts =3D ads1100_get_vdd_millivolts(data); + int millivolts =3D ads1100_get_vref_millivolts(data); unsigned int i; =20 for (i =3D 0; i < ARRAY_SIZE(data->scale_avail) / 2; i++) { @@ -259,9 +293,9 @@ static int ads1100_read_avail(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_SAMP_FREQ: *type =3D IIO_VAL_INT; - *vals =3D ads1100_data_rate; + *vals =3D data->ads_config->available_data_rate_hz; if (data->supports_data_rate) - *length =3D ARRAY_SIZE(ads1100_data_rate); + *length =3D data->ads_config->data_rate_count; else *length =3D 1; return IIO_AVAIL_LIST; @@ -280,6 +314,7 @@ static int ads1100_read_raw(struct iio_dev *indio_dev, int *val2, long mask) { int ret; + int data_rate_index; struct ads1100_data *data =3D iio_priv(indio_dev); =20 guard(mutex)(&data->lock); @@ -296,12 +331,12 @@ static int ads1100_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: /* full-scale is the supply voltage in millivolts */ - *val =3D ads1100_get_vdd_millivolts(data); + *val =3D ads1100_get_vref_millivolts(data); *val2 =3D 15 + FIELD_GET(ADS1100_PGA_MASK, data->config); return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_SAMP_FREQ: - *val =3D ads1100_data_rate[FIELD_GET(ADS1100_DR_MASK, - data->config)]; + data_rate_index =3D FIELD_GET(ADS1100_DR_MASK, data->config); + *val =3D data->ads_config->available_data_rate_hz[data_rate_index]; return IIO_VAL_INT; default: return -EINVAL; @@ -381,7 +416,6 @@ static int ads1100_probe(struct i2c_client *client) data->client =3D client; mutex_init(&data->lock); =20 - indio_dev->name =3D "ads1100"; indio_dev->modes =3D INDIO_DIRECT_MODE; indio_dev->channels =3D &ads1100_channel; indio_dev->num_channels =3D 1; @@ -401,6 +435,13 @@ static int ads1100_probe(struct i2c_client *client) if (ret) return ret; =20 + data->ads_config =3D i2c_get_match_data(client); + if (!data->ads_config) + return dev_err_probe(dev, -EINVAL, + "Can't get device data from firmware\n"); + + indio_dev->name =3D data->ads_config->name; + ret =3D ads1100_setup(data); if (ret) return dev_err_probe(dev, ret, @@ -463,16 +504,18 @@ static DEFINE_RUNTIME_DEV_PM_OPS(ads1100_pm_ops, NULL); =20 static const struct i2c_device_id ads1100_id[] =3D { - { .name =3D "ads1100" }, - { .name =3D "ads1000" }, + { .name =3D "ads1000", .driver_data =3D (kernel_ulong_t)&ads1100_config }, + { .name =3D "ads1100", .driver_data =3D (kernel_ulong_t)&ads1100_config }, + { .name =3D "ads1110", .driver_data =3D (kernel_ulong_t)&ads1110_config }, { } }; =20 MODULE_DEVICE_TABLE(i2c, ads1100_id); =20 static const struct of_device_id ads1100_of_match[] =3D { - {.compatible =3D "ti,ads1100" }, - {.compatible =3D "ti,ads1000" }, + { .compatible =3D "ti,ads1000", .data =3D &ads1100_config }, + { .compatible =3D "ti,ads1100", .data =3D &ads1100_config }, + { .compatible =3D "ti,ads1110", .data =3D &ads1110_config }, { } }; =20 --=20 2.47.3