From nobody Fri Apr 3 04:33:24 2026 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (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 D88D9282F39 for ; Wed, 25 Mar 2026 02:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774405469; cv=none; b=nRh902tTrk7pzo9r++y2QA8bZaUVXtauiodxRfl8ZVWluRkuxJp5do+QVGCKBJ+p/DhAe5dQwmVG3Cv0mzaMCG0Al2zgwRrctPnrRfTCTYIAMLZ2NdPC0wtl+cF8iQ40lNfSwFRJDTvSZNJWgBz9Lv5neBqZ1txMCnZh+7A5yDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774405469; c=relaxed/simple; bh=ypN7V548x4EKOmq5vAbetbJ4K584gqDCxFws7qAK/iA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Na2AwOiZAy5/FHVDfhqz0HojeNnAjOE3VSdr+kXXlFY+MJ66m7Sxsi24XbPP8JUkbkJDU4ZqGON7cBsBZ9PiRjJ6OxyP6XZsZYKEYUGP7YUQUrN1k3fqENLRjnZEzquHZRSGs29xZPGGi8wUH0mOB0JML3JBKVJtrPXqW1oFGII= 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=Z8GEQSQk; arc=none smtp.client-ip=209.85.215.177 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="Z8GEQSQk" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-c73c990a96dso1953802a12.0 for ; Tue, 24 Mar 2026 19:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774405467; x=1775010267; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=VMpmsaiWG89XF5HzNW61uXjH9rISZDARf2EnPrRV2mU=; b=Z8GEQSQkt6fR4TXL1Kj6EGPArX91TjMcw50a2L5SkHLJbNSsQM4Z63PqXXqfM0hMfG UQcGdoA7n665QgEYRO80/mo5KnTOl5QdGb18t7Sdd/mBrBv7v1V1xe6laxjzN4M5VQWw 1/Kb/BBEoPZ6/fRQJDmUlfDD8TWgk5wCRxGgNWYxfVVxP6qCfU37dPDxRXzvQ7WvkfgU 9UwIoRaSPAuC88lRfyTbdy4rXjNFo+9Qnv8g2/d7gDGYmJ4XX94qsS1kZw6daPkZpIo7 +WxFepUiIfEbn9Dkr+qhWEnVueV/izqCg0Iy+5cccHkLqfTQg1Ot+dV84kimDk2M/gS0 d/Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774405467; x=1775010267; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=VMpmsaiWG89XF5HzNW61uXjH9rISZDARf2EnPrRV2mU=; b=PrrHHrOJFjma8L0RSt/+2bjZZpygrSvAfecACndNTWk81iNeZC1ok+QNnP4YB51GDT 5Utl14tRrYglWU6ZGlhp66IxgfgdTEMKD9TiIK2byVhCFQwRI72p+FH3Pq/MueFkTlRE qidhKAs67K5i/Qk/y8Bp3+0oanVQODahy6TkbnnGyIbSsD7qwbT3KhxPY9tPVKQnt7am yg3ey+t14ihhvmKJJ5ACK/oZvn5Nlypos2+aQpESKubzGL9xkvvVgQF5+E/vYp5aj1kW Sc89DYypubtdk49cu4iuwLAUVw4xEKYjY680N6ncl3wZpQ9XxDv601Naws1RWCEg9A1J wRng== X-Forwarded-Encrypted: i=1; AJvYcCX6i4xAhO0dVcIDhdAWqSyAuKUQS7ZYIL97GVGKoQej5NdHHPX7Y3nGnsjGCWT1PC0EvMhktvgr8W+mLa0=@vger.kernel.org X-Gm-Message-State: AOJu0YwWzwpun1I33YPC4keCndUnP/tRzQqipzH/SEpayxCuPBrYBM4T b/vYVXCl1JcxK0z2QhYBM1FKMftg1dc60I9kU6a99mP0/a3Cy8pUTSzZ X-Gm-Gg: ATEYQzwwtKBkO5VBY5s+wHg+lWuqlCCdSYiY2jTUlWVC4p71lAJo0ccmmZqm0V6Xus8 oWAMzuO0mNQU0Ox0y7sYWydLfqofupnWfD4Pupct4EcuSaZENqQ3xiy8JhMzCHO/6CxN9g7CTSh YMij64N67rQzT2HSCc12NnTVM0iyz80JmbNah70V+n0unUYo8uCZgufsH9wft6MpOAP8IKhduvP IoS4FrySRIF/JLbe7kXti172AO6lQWLthIaFVjA9qpUxt20YcNFuRTV1Fl4z2GzKVyI/k9xPefg YZbAKvqrOonzoVoMgcBN+XlpfVWBfIWnoKVvnVD7+ha1tOzlrfIFoob+ceLuqAeJWnP00opgeCA nIlKXDfde35X4m20/lHJLd90+3iHkiQ33VrBy7PlNf/zOYhalxcYFpzH8HuUWqA6xnruhcIH9XA Gphx2XRiRMJg2zFWqzMQ4vLu9a1zKVFVNV8T4Rmz9FxaVR2TumguiXE9gtKCur7w3dbDtdaLrgx w== X-Received: by 2002:a17:903:19cb:b0:2b0:68d1:2537 with SMTP id d9443c01a7336-2b0b0b106a1mr19748055ad.42.1774405467322; Tue, 24 Mar 2026 19:24:27 -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-2b08352ae70sm170348635ad.23.2026.03.24.19.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 19:24:27 -0700 (PDT) From: Kyle Hsieh Date: Wed, 25 Mar 2026 10:24:22 +0800 Subject: [PATCH v5 3/3] iio: adc: ltc2309: add support for ltc2305 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: <20260325-add_ltc2305_driver-v5-3-e0d29daa54f9@gmail.com> References: <20260325-add_ltc2305_driver-v5-0-e0d29daa54f9@gmail.com> In-Reply-To: <20260325-add_ltc2305_driver-v5-0-e0d29daa54f9@gmail.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Beguin Cc: Michael Hennerich , 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=4420; i=kylehsieh1995@gmail.com; h=from:subject:message-id; bh=ypN7V548x4EKOmq5vAbetbJ4K584gqDCxFws7qAK/iA=; b=owEBbQGS/pANAwAKAaWDQrcJVsSBAcsmYgBpw0df63jGHRr6Rb3yLa1VHFGG9IAXwD7kyho9E a8vf44CZI6JATMEAAEKAB0WIQTJHsaNZOdY+THGqJelg0K3CVbEgQUCacNHXwAKCRClg0K3CVbE gXAVB/97I2caN1oSKbHVQHDhnvsk053+AmckELCjiueujhlHB+JuB4yfBv7iaq8nC9OvERCjABV T/8u9+yC7vdBQw/yhFFLd6xcHp+HXYtRCg1s2sQh19u2v9sRmSwy/MR6+wIdmQ0vjHhBLKGIdNL 1YpWm/2ufYSzXdH1L4XK2LQuZTLN4XVg6DdJbKFRPGxLmjW5TFGLB/63Wk1Ru5KA9agi+vwnhx7 JtSPeEU9BhScNVTp2WrEEvcjXZjMBf4U8FqpSLGKIDkpRZBj2+UZlA+X5r9qFMCpajRy/Y38GtJ v/tKexQF5WBZtlSb7Eqce9L7AUFE4V7sIYAhQYnL6TRCmVdO X-Developer-Key: i=kylehsieh1995@gmail.com; a=openpgp; fpr=C91EC68D64E758F931C6A897A58342B70956C481 Add support for the LTC2305 ADC to the LTC2309 driver. The LTC2305 is a 2-channel, 12-bit SAR ADC that is register-compatible with the LTC2309 but has a different channel selection mapping and count. To support multiple chips in this family, introduce ltc2309_chip_info struct to store chip-specific channel specifications and names. The probe function now uses i2c_get_match_data() to retrieve the correct configuration for the detected device. Specific channel addresses for LTC2305 (CH0, CH1, and differential pairs) are added based on the datasheet. Signed-off-by: Kyle Hsieh --- drivers/iio/adc/ltc2309.c | 49 ++++++++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c index 3f27ffc66668..316256edf150 100644 --- a/drivers/iio/adc/ltc2309.c +++ b/drivers/iio/adc/ltc2309.c @@ -1,8 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 /* + * The LTC2305 is a 2-Channel, 12-Bit SAR ADC with an I2C Interface. * The LTC2309 is an 8-Channel, 12-Bit SAR ADC with an I2C Interface. * * Datasheet: + * https://www.analog.com/media/en/technical-documentation/data-sheets/230= 15fb.pdf * https://www.analog.com/media/en/technical-documentation/data-sheets/230= 9fd.pdf * * Copyright (c) 2023, Liam Beguin @@ -41,6 +43,13 @@ struct ltc2309 { }; =20 /* Order matches expected channel address, See datasheet Table 1. */ +enum ltc2305_channels { + LTC2305_CH0_CH1 =3D 0x0, + LTC2305_CH1_CH0 =3D 0x4, + LTC2305_CH0 =3D 0x8, + LTC2305_CH1 =3D 0xc, +}; + enum ltc2309_channels { LTC2309_CH0_CH1 =3D 0x0, LTC2309_CH2_CH3 =3D 0x1, @@ -80,6 +89,13 @@ enum ltc2309_channels { .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE), \ } =20 +static const struct iio_chan_spec ltc2305_channels[] =3D { + LTC2309_CHAN(0, LTC2305_CH0), + LTC2309_CHAN(1, LTC2305_CH1), + LTC2309_DIFF_CHAN(0, 1, LTC2305_CH0_CH1), + LTC2309_DIFF_CHAN(1, 0, LTC2305_CH1_CH0), +}; + static const struct iio_chan_spec ltc2309_channels[] =3D { LTC2309_CHAN(0, LTC2309_CH0), LTC2309_CHAN(1, LTC2309_CH1), @@ -99,6 +115,24 @@ static const struct iio_chan_spec ltc2309_channels[] = =3D { LTC2309_DIFF_CHAN(7, 6, LTC2309_CH7_CH6), }; =20 +struct ltc2309_chip_info { + const char *name; + const struct iio_chan_spec *channels; + int num_channels; +}; + +static const struct ltc2309_chip_info ltc2305_chip_info =3D { + .name =3D "ltc2305", + .channels =3D ltc2305_channels, + .num_channels =3D ARRAY_SIZE(ltc2305_channels), +}; + +static const struct ltc2309_chip_info ltc2309_chip_info =3D { + .name =3D "ltc2309", + .channels =3D ltc2309_channels, + .num_channels =3D ARRAY_SIZE(ltc2309_channels), +}; + static int ltc2309_read_raw_channel(struct ltc2309 *ltc2309, unsigned long address, int *val) { @@ -158,6 +192,7 @@ static const struct iio_info ltc2309_info =3D { =20 static int ltc2309_probe(struct i2c_client *client) { + const struct ltc2309_chip_info *chip_info; struct iio_dev *indio_dev; struct ltc2309 *ltc2309; int ret; @@ -167,13 +202,15 @@ static int ltc2309_probe(struct i2c_client *client) return -ENOMEM; =20 ltc2309 =3D iio_priv(indio_dev); + chip_info =3D i2c_get_match_data(client); + ltc2309->dev =3D &indio_dev->dev; ltc2309->client =3D client; =20 - indio_dev->name =3D "ltc2309"; + indio_dev->name =3D chip_info->name; indio_dev->modes =3D INDIO_DIRECT_MODE; - indio_dev->channels =3D ltc2309_channels; - indio_dev->num_channels =3D ARRAY_SIZE(ltc2309_channels); + indio_dev->channels =3D chip_info->channels; + indio_dev->num_channels =3D chip_info->num_channels; indio_dev->info =3D <c2309_info; =20 ret =3D devm_regulator_get_enable_read_voltage(&client->dev, "vref"); @@ -189,13 +226,15 @@ static int ltc2309_probe(struct i2c_client *client) } =20 static const struct of_device_id ltc2309_of_match[] =3D { - { .compatible =3D "lltc,ltc2309" }, + { .compatible =3D "lltc,ltc2305", .data =3D <c2305_chip_info }, + { .compatible =3D "lltc,ltc2309", .data =3D <c2309_chip_info }, { } }; MODULE_DEVICE_TABLE(of, ltc2309_of_match); =20 static const struct i2c_device_id ltc2309_id[] =3D { - { "ltc2309" }, + { "ltc2305", (kernel_ulong_t)<c2305_chip_info }, + { "ltc2309", (kernel_ulong_t)<c2309_chip_info }, { } }; MODULE_DEVICE_TABLE(i2c, ltc2309_id); --=20 2.34.1