From nobody Sat Jul 25 18:54:01 2026 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 BAE1C3EF66D for ; Tue, 14 Jul 2026 19:47:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058460; cv=none; b=Br24eZYi9WiAxLsdq/PlpoxHR/1o/VyR+aITYAHVezRYnU5gnUDg1KmivODJLGmaCcCUdGw2S7xL5Elcl9Cav3tqjBTldJCgoYQ1Pf4RSCTySJhoQd7dcvPxfM89nIR7Fw2bDHDVXfzLjPsZOxhe2YW0/117lFKCIqlFAPwyw8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058460; c=relaxed/simple; bh=L5cKDZ3oZuREEsG/FL4nnHJOHClGwu35C6UP+h/6c9s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F94y7MLwGozCBuBCFisgHKNE/9IkhW2HjySuDYOo6FoD4KVAa2q4TT8hcgB6X8iAJbvXuDPTgEDy3JWe37HXYCYt1XjQ3fp23oWbd/25fl/38dQcVX5g5p1gazTj1tOGeJvVbF5nC6/vj1HY/BO84hMw+214n1x87fv0yy+sqiQ= 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=gjPZq8Cu; arc=none smtp.client-ip=209.85.208.170 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="gjPZq8Cu" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-39c95395230so11730751fa.2 for ; Tue, 14 Jul 2026 12:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784058457; x=1784663257; 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=7F0XFPsWY8E1IJTSA8IwnIWALBfCdqYZnCek7z6Ufx4=; b=gjPZq8CuPlLCIa3fzC+IHNZ7nHmi9rMToMCcFQ5fBoJJhjaFB61tbUl6jDrld5x3PR qm148FrGD7PXyWsP3x6C+Qw2Xb13H6YXUdeKiuwFfs4HdOS/SkN5vbt1277Y+R8uw/uh I8S38kOjvkbMaDsiHqp1EXnYB52Wq4o49A9P7aTzhkmuWyrz59CF/rgjFu2ubUifHu3Q EJfKyaZoidtLvPU9bBS6UVoXJ1sgRoMLoJG9ES2DIDadEABdcxe6Wt1rT+1NCkFFrtMd 6k0+orTgNaEbO4KzKYNWRWh3RNoo81ItheQ1ANiEEmU1MChwLSQ//n+73n2QrNwbst92 SjEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784058457; x=1784663257; 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=7F0XFPsWY8E1IJTSA8IwnIWALBfCdqYZnCek7z6Ufx4=; b=eDLRdw2Zu1x0CvTtB5wmeEMKC6FrG9LVGAysRypxukWfM6WFjXGytiFT+56i2mmI7O Y+pWch0GoLyxdrVPEVqJ0ORj04v3mOsHYYLzlbBWgpLgpUuUksFaoZ3nD+p4RLPUgvxb Mf2TUaKSecYjxNJbaQijCXHTX89u/DIapSFyh9M+l4NUOL2ZJGbwJ7cvbupLRFJj8TXU aa6/3ahmVPfM9L2r/ZhWxQ0h34uwNMc8IrFo3K4cE7O4LmAtLtetwaimoMXR+/BZ6dJQ 5zgfV8EIq1UNlvY0LZ/ajl7jkJx4jgXKjj03DluebcsoTmdZgkne+TQjz5ugYUP+vXr0 uWug== X-Forwarded-Encrypted: i=1; AHgh+RpgA1pN642fiwP/SLyFN/y4dgY+bQIWOhHLyqzbSnCL2WjgVmQXwE6uLM9kOH4/+K1djmT5YttMDDOnpUk=@vger.kernel.org X-Gm-Message-State: AOJu0YyXvjyhWla10un4zgsefU9HS/b/7BvXEu+kEj1rG4rMbmEjFF4R bdducguadJ6bQM5xxiCT//xU0LH2wErmWD2FSpYaOw2Qxa73gZemwKT/ X-Gm-Gg: AfdE7ckdzeUgtI/yQjktGIriuS7h28AKCJvyoSwA9aHeIunTCPXuoJ/Sn2x6H3fkYqq Ot7ao6scR7F9/aFINI2pZp1+OnQbMQhNTk5u8DiV8a2iD1iTpQAgURdyhitCjWQ4BaDfHR4dSzo F2dD8n2GKVMjuasWBe2U7RmwwueiT7jJUBmxTYHqpPlQwNP9JPE3ykkPUxC2MTe2FAbUNn6WGT0 BJSOz6D8AIJILvImD4967PyN48UNiWb0zPRzmgM5FvRNbjNXGP9L03xebld3aVDjq62kcKvHREG nVrURDHmMnp0mvAYOa34wJwlMBOJWVTfjp/L4tbPCBKayzRUpFHuj/e/QLqcRnzuNRztIqQMgH8 l68L99xM8WPCFD6oW286NQvSiNzjF1/37EYUY1f6fZCwRll6b5gGmsDWihOFZNtenwbvEtPjiTO 5Ankru+NPE9dcFBtqU3yF76jqeK6LMthYxC6H9+GS7G4so3vdKz7qCrpGynw== X-Received: by 2002:a05:6512:3345:b0:5b0:1959:d877 with SMTP id 2adb3069b0e04-5b023698daemr3222763e87.41.1784058456644; Tue, 14 Jul 2026 12:47:36 -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-5b01ca50a8esm3780287e87.28.2026.07.14.12.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 12:47:36 -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:47:15 +0200 Message-ID: <20260714194717.596193-2-jakubszczudlo40@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260714194717.596193-1-jakubszczudlo40@gmail.com> References: <20260714194717.596193-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 a new measurement, so to be sure that read after change is correct functions that changes datarate and gain will wait for new data. Fixes: 541880542f2b ("iio: adc: Add TI ADS1100 and ADS1000") Signed-off-by: Jakub Szczudlo --- 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:54:01 2026 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 97A98435511 for ; Tue, 14 Jul 2026 19:47:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058464; cv=none; b=iO9PIIZ6fxQXmJJefsScLoGjkQrGg/tHAaNejXqCELJyr5RbOp7RAfr9M5Aqd3iUSfd/c7EyeicdWAMxLJQ2+KnQRDkAPjetX2iQzN03FCn4MUclnb7r+jFwaokaW55xdIsSbSYLalroW/yl8vpEHW8fIo2PCw3g1vtNSzVNdn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058464; c=relaxed/simple; bh=U2YoNQx/hGloZRC8McPJss1WdTnU2vgI7Fy7zmdhFok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IvwoQPx+ZbpWdQZoloHw3+rcu7E6efd/T+pwWEfFuFXphpY5k7eJGLFXg5ynrZkZoKS7b7yIG60z63UOO0LTGoy2cwdOTXPi6bsJQVaBvxVU7nWBe7IIdiqKtGlm5pcKkmkq//yTXgc9rxIWEeDiDlWE2P9pfUeb4S1AWjxQVrc= 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=pyZHSMzQ; arc=none smtp.client-ip=209.85.167.49 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="pyZHSMzQ" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5aeb5e85378so4954227e87.1 for ; Tue, 14 Jul 2026 12:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784058460; x=1784663260; 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=pyZHSMzQyFI5idb/CwmpcPkmdtQ38fAmiCyxUHczWKhNCd4+iNoYFT+60lXFzBJejB QrB7GSJGcEC/Dwsi9rtTzbVG16ZxcvRIND4NcCxLyBcjYljpwTDYh8N15nOE3kp1JSem vqEBAXw7+k0gbFde1OmmoqyzarLycEJ/ViqgZvV2OjzGG5UUJExB5K2XQXD73l6GKY2/ 0xd5rRdxbmHnBRj1zZivmvuK2wAAaphwxghJGSeRfJpnyr5V6ZRR0DQSd42KeY+DIYP8 I9D8HC1LEOkYigGQuk92cEQPJeILebkR5JwjqZVoGdsNnRcvgq9S1UEjxHaXw/eOw4Jw 8hfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784058460; x=1784663260; 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=VocZcbleOeYhZVuMY1gwhqPBA5fUOUlgNZuwc1fMbxVO1gl4jECs+Y6vs4zJKSts2y JonLmvTWJfaTOCepiV/YPJJJIIMG+eByN0oiFq9Q4RqmwGBQ7uuQzUivOJzNh8/Hvqqo Rv4e9YwyuEZxzbW6vpM82R52NqRLyyYdo3tJ2h8yS1h5J+ipYJPW+8NgEtwaakNLttGr kQf5AmO/YGSFxf0LU8JpEjnfor0nxSfF/o0lEVkJIV+S3sm/LrK252SbkghtT5JXtcrh Ingk+w3QC6a/x8LQMSQtZjeiUjcw5/cyYun1/NcYkWYHWQiC528cx8x9lvKDLQk0wZtV NUWg== X-Forwarded-Encrypted: i=1; AHgh+RpFwfs+WZo6CtB1tanyR28ebU0LLOhmiquhb7DejwoSTWGe1136vmfS98YDp2uw8LLXvWLJSIgMiygi+4g=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4a+2jj479lqXD/TN1fg5m0Sp2dchq2LM2aNVkMWOLAI+PNgjO Ko+M0ADP2IzdkljH8sOGCX+9xXuam7vTg7dEvJHNE6EtiQbBBll+nPzz X-Gm-Gg: AfdE7ck7RIN4r5Y4EB850ykeKUj+KeOgB3k4g1rpVhtg0Lv9odqlRMnWflhAv54Em19 gAG6IWNh/dRqUNYI8piF95wZYjQMIP+Lsi0Xe8bNILmqdmMiENktONWQX00IlRyegnmkNviYwrg 4iQl+xwmBPqqmC0TuIZb1ndFI4bBs4CBnobUTOgc9YdammCnNVUz2iItfazdozfXsPNRdmJNtHq 248oSLnd0j3ZVZw+dJQYOt+Mh5rPr4NEk1AaIbPJyg1J5ImIfasqPBUNVeh3uUtkFyHGfZkusYA MXjz8e5OoR4FBcuB+dRyu329V/zKh3qbxaaFZwQORr/6bqH9E3vdJQ7TA9nFNK2z08GIMmGPlRA U0uHzfeu0XGJS6FiMQNpEI8vjD4Udf5t71Jm0QifQzrzcbQP9Bd8clMymV0aGA+HHhi02+ILT/R bTIlk7ajw/BjUA6nsR3bczTOD4mrzRclxQ6sFWHWfT4VwUKPw= X-Received: by 2002:a05:6512:6185:b0:5b1:4fab:fbd4 with SMTP id 2adb3069b0e04-5b159b8bbf7mr716449e87.59.1784058460358; Tue, 14 Jul 2026 12:47:40 -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-5b01ca50a8esm3780287e87.28.2026.07.14.12.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 12:47:39 -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:47:16 +0200 Message-ID: <20260714194717.596193-3-jakubszczudlo40@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260714194717.596193-1-jakubszczudlo40@gmail.com> References: <20260714194717.596193-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 --- .../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:54:01 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 4D42A43552B for ; Tue, 14 Jul 2026 19:47:46 +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=1784058468; cv=none; b=ZUr+F5yBYqmrof1NEwAyGj4fqLe06NosPWoarJHWw7CV0bxITpWR+groH7/vmveDR1uEGIUtn/P/4lWdvzTazNk9OtmctFHXmcHa/6MNHsSkHtEipwmoTyORirOEc4+toGLCGSd+vvP09FHIBNd0HFl5nfUiZ52dHB+IC3sQgF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058468; c=relaxed/simple; bh=x5xeEm5V2RUVbJPpiW7WO6S+OyLmpUCyxUEr4Fp4/mM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rl5y77+cUbY9SpEg7FiRVqCBGaxWFXnHHTiyxm3VLT4ZXLnXmBKFQf/o+OnrQq65StadnuGmyZTmBDjy5zQUa8owVRNtTJbiiLd0eeqCbVC9EVPABpUFuE72dHe6Uxl0xl67jD3KRQBYdUuzIOzsfo4u4NQ9pHshqbhgAegNook= 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=Moft9qN/; 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="Moft9qN/" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5b0148201fbso1085215e87.3 for ; Tue, 14 Jul 2026 12:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784058464; x=1784663264; 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=C5ekcSFTL4/hgcBZvhEGy/Z9aZabj+fJ0ywhsDg/4Uw=; b=Moft9qN/guihsKiXKCcSdZM/eL2KokMUN9bfIRrRfYDi92aULNWF2uPFB3TMjQ+4Tu BWtyVKZ1jYSymu2ZQkl4oSYhvjZrlh1tScS9hBkLvFC4dU4ij/h/JgW5/OBLwgReHjUe qqaHzmd+b05VJqeUQm27mTeBNK+EvWe7Ka0LDTXx47HgsgpR6U/xdWbkufb6hEcDfaBx gkTQS+pNYzu/xh5m0ZFmHoPEy69vX4yMB8Jf9jUsA4yoQlL2Eh5mhy2h4/lva+BCAzgY /QXCYtjayBB0tUTx+qzIQnEQyB038apjri8CVbdjbEWLax/GYkLHfdN4tpD7MtGJsKQY puHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784058464; x=1784663264; 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=C5ekcSFTL4/hgcBZvhEGy/Z9aZabj+fJ0ywhsDg/4Uw=; b=LPVoW7/tykBpOtjkyDwEC45sup2gLUWtWKSQvu+Gex6MtSSp8I6Eqy9UgAoBE9sLN+ ytkwNdgJt+pxaJnBvcS+dj2/FNeY83p83IdpSIWrHIUDwvpPr933+9dXh5ujZ384vVuu 6PCiIgUwDHVehSwKer4Mu7acMaql8HMVNF1pDI14TL9BfrnYx6TMFVN37/GpF9RvsTk0 zQELRBjsHLt10D+nXfI3xYtdLwNkl7MOT1NF80uTe949b6Ntd1D7/Z+bFdthVRvkQtvN hTvmhAOKkR0iCS8ZKEJbQOofnwsdCr6xKKQIuSE1gIHGtiHDwzTom70uIR0AEI/IVyHy p8Zg== X-Forwarded-Encrypted: i=1; AHgh+RoXp9Kox6+dkoqWSUm8VN0ZnVtzu0lYK2GOT/ubLkzpLBPh/t7mxPD9AO4CBHSCtVVejAh0FBqAtOEf9FM=@vger.kernel.org X-Gm-Message-State: AOJu0YzUEYKxgQXFQUXJXgKIxQS6xYYZUwwH1U3RVEbiQmzvzC0N+ODN L+ZHSBdc2KIjrvxtc4nWGQr/ew/dI+hLBxvxMNkbite6LrDHkK+OVgTEMRVK2IGU X-Gm-Gg: AfdE7clqq2Dq8jsGWW7JHFkpYLmPv303kbS7sbszgFu7IPmqjRvQq3slkrvbQiKD7yn Ur04LX2BopyNKusYR0ADw+PEQlCTC3j/aKYIeO1wyeRmlqb0119fysHhRM/KImddqKLCujz8wzq mpI6fJe3NgfoIvOUVVhVQPK7725E4CqgDneVmx41a5JaFN3tH/tLT+xMNvgeFUgbpu7VqMa/tim WCvxc9EZxlGCXp4iSdAIFFkVXrioSJ7QDb9lwX2GOLhLxY0jYva4ZQ1zrzOUHjBDvKJFw3Hdcmu e++JNimUaeo47HRf0Q25tmiufxbiQw2DW6p53R5XJ1xT01DNL2Q0xb7pmkWcHVosxSVms/2Ev0y 294mkyy1XbsRmvnEwpek0DN1SYuhM/E17tu2V12kp2bjrgQYEpOhwUuiU3jyC37wLP5jmKvGJYE 7DxZKV0i+r65AT8Ax+ZyafXaGbVEbxrxVV3xIlh5kYIfTO2vM= X-Received: by 2002:ac2:508c:0:b0:5b0:e70:c6e8 with SMTP id 2adb3069b0e04-5b0236c0babmr2541636e87.59.1784058463983; Tue, 14 Jul 2026 12:47: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-5b01ca50a8esm3780287e87.28.2026.07.14.12.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 12:47: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 3/3] iio: adc: ti-ads1100: Add ti-ads1110 support to ti-ads1100 driver Date: Tue, 14 Jul 2026 21:47:17 +0200 Message-ID: <20260714194717.596193-4-jakubszczudlo40@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260714194717.596193-1-jakubszczudlo40@gmail.com> References: <20260714194717.596193-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 --- drivers/iio/adc/Kconfig | 9 ++-- drivers/iio/adc/ti-ads1100.c | 84 +++++++++++++++++++++++++++--------- 2 files changed, 69 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 3755a81c1efd..9de2f4eb72fa 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 MSPS Analog-to-Digital Converter + * ADS1100 16-Bit, 128 MSPS Analog-to-Digital Converter + * ADS1110 16-Bit, 240 MSPS 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..ad9099aaf19c 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_milivolts(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_milivolts(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_milivolts(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_milivolts(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; @@ -401,6 +436,11 @@ 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"); + ret =3D ads1100_setup(data); if (ret) return dev_err_probe(dev, ret, @@ -463,16 +503,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