From nobody Fri Nov 29 12:31:39 2024 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 14DEE19D892 for ; Thu, 19 Sep 2024 13:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751094; cv=none; b=s0P6r6B5X0D2ctnWaaIz+eBJRghWeRrl8SH2CSEJa8z82gaWIMuBkV710iChpP2HVQxwAhNW5EP/AnLJii9ZrPLsvsbcX28Q30+s1BRmpFp6sB8ek/I1BVSgTnY+5SPqXYGSYO1VbWhqImXkSTr5ffBMKJEJZio8cnVJmdd0Q8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751094; c=relaxed/simple; bh=7jeDEErQ+xBSjvZ9RT/TEcexKXO8icQCIcZ4pRA2dbs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SikD552V5m7ea71DnivB1ktPk02s0XiCkqpjtu2XWsa/RsK+wI/vUjnEBbLROMEwQuwwNmApQFrNyZtdY41YhwZlcnTiJJY6YaCdS332jvlb1OdhV9rUANiKa6aVsK0qX6BBwL0dETK+O3FD9++ofz8bJTFT5VTQIqxXK/9fB0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=MFTY8Fke; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="MFTY8Fke" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5c25f01879fso1049496a12.1 for ; Thu, 19 Sep 2024 06:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726751091; x=1727355891; 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; bh=ZWLUgthTvXLTW08JjjEElu7+ziFuVs/iQEkeWDpV0KA=; b=MFTY8FkeCfksuk8FcdznELF/uzWI1EQ0g0jCBshhzvxxjfc76NX1sZa/30ktKkVSbl lwXRylojqzL6FKXmIQuXU155l6540IeuY2G42UUhBzpSxeHru+SIf3MKuE9OGYmaPAGd 98guD3o4qS/7r20hczXakVTBYAwd6JUDN634gV1lFV2sordzV/4TPjhEkXqvWt7kcJlk JlEzaBxFy4cPK2RPydTPk+OK1tfUKhgcE86JhrNvq+kc30qgVlU8LPCDx4X6Sr1dSXOh MS/EhiCDDzR615pen7ImTG/fN2ljWNUKcLuHDOk6ym2wVuJcYnJMJLby1btrBEgJ+bvt ojBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726751091; x=1727355891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZWLUgthTvXLTW08JjjEElu7+ziFuVs/iQEkeWDpV0KA=; b=PHcqGUFBDqtO2d6WuDGmLHl5QmhgoPW5Im/gqz4NK1JWNVylo62zHckR572VbBk16q ybJMvsYQovCTMTk7KT/pgWDrzP1awI3llCuVoXsl6F+ix1JaTZKX44ghCAv1F72hawug tyFUWqSKz0pt+HMGxgUkSN80Y/FVBxFX9Nj5VwjOMfgLUAhmfNTLVgVLwfw5ZGtdiPwR Loe5reL7SpLfID6OhpJ6Nu7ovTh+gNaoYfOy4PvOwnPChRZ0ORIL8arh00+wYmHXHQ/8 RCT81usn0Yv7PV6aOCIPKKXjlX4o0+APsnKBpgmAfPduLvTIfuYQewHV72P/ZHQVdT47 skBQ== X-Forwarded-Encrypted: i=1; AJvYcCW+/sTL2dZ4pdH+KGHPdbbYA60jzwN6jPymtjmzbwD2TcFwCxFK0pL+3nnRN0iaVCWTQPo1yQK3rgf8O/M=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5LdYrXSRgQLcquTxVhqm1CFquW2TBf0fqHSxceP06LpxzKzCH JcDkZshhHNLYd0uCkle+a+vfWVAOPSu0e9xKAN7ZnunEl1n1wXfGWRdnnR+YoiQ= X-Google-Smtp-Source: AGHT+IFCzw8baFkNf0BgCzVZQgQ3gbw6b+bcEnMmiDQX9iGDzFn09M+1ygpCg5C6XyrB59wxuSzCTw== X-Received: by 2002:a17:906:794b:b0:a86:a4b1:d2b8 with SMTP id a640c23a62f3a-a90293b1860mr2515563166b.4.1726751090966; Thu, 19 Sep 2024 06:04:50 -0700 (PDT) Received: from localhost.localdomain ([188.27.132.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90cbc7122esm53213166b.124.2024.09.19.06.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 06:04:50 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: jic23@kernel.org, krzk+dt@kernel.org, robh@kernel.org, lars@metafoo.de, michael.hennerich@analog.com, gstols@baylibre.com, dlechner@baylibre.com, Alexandru Ardelean Subject: [PATCH v7 1/8] iio: adc: ad7606: add 'bits' parameter to channels macros Date: Thu, 19 Sep 2024 16:04:36 +0300 Message-ID: <20240919130444.2100447-2-aardelean@baylibre.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919130444.2100447-1-aardelean@baylibre.com> References: <20240919130444.2100447-1-aardelean@baylibre.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" There are some newer additions to the AD7606 family, which support 18 bit precision. Up until now, all chips were 16 bit. This change adds a 'bits' parameter to the AD760X_CHANNEL macro and renames 'ad7606_channels' -> 'ad7606_channels_16bit' for the current devices. The AD7606_SW_CHANNEL() macro is also introduced, as a short-hand for IIO channels in SW mode. Signed-off-by: Alexandru Ardelean Reviewed-by: David Lechner --- drivers/iio/adc/ad7606.c | 58 ++++++++++++++++++------------------ drivers/iio/adc/ad7606.h | 18 ++++++----- drivers/iio/adc/ad7606_spi.c | 16 +++++----- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 9b457472d49c..8ebfe8abc3f4 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -309,16 +309,16 @@ static const struct iio_chan_spec ad7605_channels[] = =3D { AD7605_CHANNEL(3), }; =20 -static const struct iio_chan_spec ad7606_channels[] =3D { +static const struct iio_chan_spec ad7606_channels_16bit[] =3D { IIO_CHAN_SOFT_TIMESTAMP(8), - AD7606_CHANNEL(0), - AD7606_CHANNEL(1), - AD7606_CHANNEL(2), - AD7606_CHANNEL(3), - AD7606_CHANNEL(4), - AD7606_CHANNEL(5), - AD7606_CHANNEL(6), - AD7606_CHANNEL(7), + AD7606_CHANNEL(0, 16), + AD7606_CHANNEL(1, 16), + AD7606_CHANNEL(2, 16), + AD7606_CHANNEL(3, 16), + AD7606_CHANNEL(4, 16), + AD7606_CHANNEL(5, 16), + AD7606_CHANNEL(6, 16), + AD7606_CHANNEL(7, 16), }; =20 /* @@ -333,22 +333,22 @@ static const struct iio_chan_spec ad7606_channels[] = =3D { */ static const struct iio_chan_spec ad7616_channels[] =3D { IIO_CHAN_SOFT_TIMESTAMP(16), - AD7606_CHANNEL(0), - AD7606_CHANNEL(1), - AD7606_CHANNEL(2), - AD7606_CHANNEL(3), - AD7606_CHANNEL(4), - AD7606_CHANNEL(5), - AD7606_CHANNEL(6), - AD7606_CHANNEL(7), - AD7606_CHANNEL(8), - AD7606_CHANNEL(9), - AD7606_CHANNEL(10), - AD7606_CHANNEL(11), - AD7606_CHANNEL(12), - AD7606_CHANNEL(13), - AD7606_CHANNEL(14), - AD7606_CHANNEL(15), + AD7606_CHANNEL(0, 16), + AD7606_CHANNEL(1, 16), + AD7606_CHANNEL(2, 16), + AD7606_CHANNEL(3, 16), + AD7606_CHANNEL(4, 16), + AD7606_CHANNEL(5, 16), + AD7606_CHANNEL(6, 16), + AD7606_CHANNEL(7, 16), + AD7606_CHANNEL(8, 16), + AD7606_CHANNEL(9, 16), + AD7606_CHANNEL(10, 16), + AD7606_CHANNEL(11, 16), + AD7606_CHANNEL(12, 16), + AD7606_CHANNEL(13, 16), + AD7606_CHANNEL(14, 16), + AD7606_CHANNEL(15, 16), }; =20 static const struct ad7606_chip_info ad7606_chip_info_tbl[] =3D { @@ -358,25 +358,25 @@ static const struct ad7606_chip_info ad7606_chip_info= _tbl[] =3D { .num_channels =3D 5, }, [ID_AD7606_8] =3D { - .channels =3D ad7606_channels, + .channels =3D ad7606_channels_16bit, .num_channels =3D 9, .oversampling_avail =3D ad7606_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), }, [ID_AD7606_6] =3D { - .channels =3D ad7606_channels, + .channels =3D ad7606_channels_16bit, .num_channels =3D 7, .oversampling_avail =3D ad7606_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), }, [ID_AD7606_4] =3D { - .channels =3D ad7606_channels, + .channels =3D ad7606_channels_16bit, .num_channels =3D 5, .oversampling_avail =3D ad7606_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), }, [ID_AD7606B] =3D { - .channels =3D ad7606_channels, + .channels =3D ad7606_channels_16bit, .num_channels =3D 9, .oversampling_avail =3D ad7606_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index 6649e84d25de..204a343067e5 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -8,7 +8,7 @@ #ifndef IIO_ADC_AD7606_H_ #define IIO_ADC_AD7606_H_ =20 -#define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all) { \ +#define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all, bits) { \ .type =3D IIO_VOLTAGE, \ .indexed =3D 1, \ .channel =3D num, \ @@ -19,24 +19,26 @@ .scan_index =3D num, \ .scan_type =3D { \ .sign =3D 's', \ - .realbits =3D 16, \ - .storagebits =3D 16, \ + .realbits =3D (bits), \ + .storagebits =3D (bits) > 16 ? 32 : 16, \ .endianness =3D IIO_CPU, \ }, \ } =20 #define AD7605_CHANNEL(num) \ AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW), \ - BIT(IIO_CHAN_INFO_SCALE), 0) + BIT(IIO_CHAN_INFO_SCALE), 0, 16) =20 -#define AD7606_CHANNEL(num) \ +#define AD7606_CHANNEL(num, bits) \ AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW), \ BIT(IIO_CHAN_INFO_SCALE), \ - BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO)) + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), bits) =20 -#define AD7616_CHANNEL(num) \ +#define AD7606_SW_CHANNEL(num, bits) \ AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),\ - 0, BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO)) + 0, BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), bits) + +#define AD7616_CHANNEL(num) AD7606_SW_CHANNEL(num, 16) =20 /** * struct ad7606_chip_info - chip specific information diff --git a/drivers/iio/adc/ad7606_spi.c b/drivers/iio/adc/ad7606_spi.c index 62ec12195307..e00f58a6a0e9 100644 --- a/drivers/iio/adc/ad7606_spi.c +++ b/drivers/iio/adc/ad7606_spi.c @@ -67,14 +67,14 @@ static const struct iio_chan_spec ad7616_sw_channels[] = =3D { =20 static const struct iio_chan_spec ad7606b_sw_channels[] =3D { IIO_CHAN_SOFT_TIMESTAMP(8), - AD7616_CHANNEL(0), - AD7616_CHANNEL(1), - AD7616_CHANNEL(2), - AD7616_CHANNEL(3), - AD7616_CHANNEL(4), - AD7616_CHANNEL(5), - AD7616_CHANNEL(6), - AD7616_CHANNEL(7), + AD7606_SW_CHANNEL(0, 16), + AD7606_SW_CHANNEL(1, 16), + AD7606_SW_CHANNEL(2, 16), + AD7606_SW_CHANNEL(3, 16), + AD7606_SW_CHANNEL(4, 16), + AD7606_SW_CHANNEL(5, 16), + AD7606_SW_CHANNEL(6, 16), + AD7606_SW_CHANNEL(7, 16), }; =20 static const unsigned int ad7606B_oversampling_avail[9] =3D { --=20 2.46.0 From nobody Fri Nov 29 12:31:39 2024 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 83C9619DFB3 for ; Thu, 19 Sep 2024 13:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751096; cv=none; b=ogLIPTDqDXf48vjGBX2bSztlB8yvp+hOlb3I8cypQKx4UmL6r87CgMz+dEEWJAwSGghYvytgojgNX0LpANHf7AcI3rR58viFqWU4sIZ3574D1Swvn0BEopd8KwEw8daAu/7SheD5yR6fx53E9WiS0Jypfi54fWpMSnGfnfNFAVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751096; c=relaxed/simple; bh=ykUyvmQc/5wbFyrFRMV34ty22I9dWMk9TBb47ILEe4U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WzxAhJpLibKHEq9GWLk0xEbmneiSnKWOe5V9YDNzklsLOeuGPZl6Y7AlDUqo+D/9aYYKpYrzvfecrpmoMEqS5597Fwcq3NS51aPK38I8ApIVhPB7S47iHX+DByb7IqhAYSt2AFNYQ8I5DOBVOfQkHJ9/wlvn/ylBKUGnZl3hGBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=cKfegPfP; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="cKfegPfP" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a8d0d0aea3cso105362466b.3 for ; Thu, 19 Sep 2024 06:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726751093; x=1727355893; 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; bh=B4rgjfNfx6m5HjjB8s+u7qEdTS2g8HjBiOKrDc5NZNs=; b=cKfegPfP/sE5xKmpH95RN0knadHFGAIqJ1L7BjwxYbm48JemgrUDxkC/vZJzQfnedl lNAec90WioSVK88Vz1xVLtKEa2u9UWyN0oN4NU+h/o0wt9ggvWCl1dpAKREKVeMG2fE+ Xe8AbkpzZ+mMe3n5CMnT3qGUnh5U/u66QSGxcEElijuNXDcELEaajpuHHsuNBkZd439R TUm1SwqrScgCskfT7YM1DFGNpYatg59nV6ulMYLjh0Aj+P85/4vUTmpiZpSaskLHfcnG ILNfz3eLsCP+oqFmirlQTpIpgtgWt28A+s1EwWUtYi5x0qDsnHPBOY1bweNPFueI8jlP 6N5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726751093; x=1727355893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B4rgjfNfx6m5HjjB8s+u7qEdTS2g8HjBiOKrDc5NZNs=; b=wtnY7qUKzxpkFK2GiZrsPBGCUVMfT4XAfQMS7gcsJflVh2SU8tFR9P76po/rPK2zNr QZOrRiqQAMeXgWa5UkEJWlnJQXADXD7E3pOU2LV7BNaloCt41lUNMsXeuNTj/S+JpqH9 Lazp+yR7NEI3D5a8F209ZJoc1mA3MLiQDk+4qnZwi2eTr/L0E0V02IfhY5ybEjo4MKRP 9eEe1qyxVWbeb9xMGvCc/obp/rZeKc+u7tS4JskRd9TPpjfBeMKGomLUeNwOOGPgqP6x AMp6ccZH/JGzn42mHr+WtvZJe/icwoIELxPMdwkoWZK+cnjb4SnCxbuQ6Azs/QDksbv3 TKBg== X-Forwarded-Encrypted: i=1; AJvYcCX04UttTCGvMbxe1cV3lTSAqw+QZ2tcykX99GAUjw1MR7PracA8qu5o6sr9Vdx1itWhIi4hdmtsctlsvXY=@vger.kernel.org X-Gm-Message-State: AOJu0YzevTCN23Yy96En87n+uSlKKTfpMpa2eCnf/kh/RKddfIKAJdgg KIwX+XIw22wMR9StbcGVO0XEnmgM+DwvA/SMnAUcLPnRttwpE5/RvVE/OQROPkk= X-Google-Smtp-Source: AGHT+IEl9n2aGivKm8Nn1OjphaunB6AciwjLNzCRmh6NUeWAsMtAyCaWK5ZAg7pYg6y6TwSpV+kunA== X-Received: by 2002:a17:906:f5a9:b0:a86:7924:11bd with SMTP id a640c23a62f3a-a90296178c9mr2762405466b.41.1726751092813; Thu, 19 Sep 2024 06:04:52 -0700 (PDT) Received: from localhost.localdomain ([188.27.132.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90cbc7122esm53213166b.124.2024.09.19.06.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 06:04:52 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: jic23@kernel.org, krzk+dt@kernel.org, robh@kernel.org, lars@metafoo.de, michael.hennerich@analog.com, gstols@baylibre.com, dlechner@baylibre.com, Alexandru Ardelean Subject: [PATCH v7 2/8] iio: adc: ad7606: move 'val' pointer to ad7606_scan_direct() Date: Thu, 19 Sep 2024 16:04:37 +0300 Message-ID: <20240919130444.2100447-3-aardelean@baylibre.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919130444.2100447-1-aardelean@baylibre.com> References: <20240919130444.2100447-1-aardelean@baylibre.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" The ad7606_scan_direct() function returns 'int', which is fine for 16-bit samples. But when going to 18-bit samples, these need to be implemented as 32-bit (or int) type. In that case when getting samples (which can be negative), we'd get random error codes. So, the easiest thing is to just move the 'val' pointer to 'ad7606_scan_direct()'. This doesn't qualify as a fix, it's just a preparation for 18-bit ADCs (of the AD7606 family). Reviewed-by: David Lechner Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/ad7606.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 8ebfe8abc3f4..032a8135c912 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -114,7 +114,8 @@ static irqreturn_t ad7606_trigger_handler(int irq, void= *p) return IRQ_HANDLED; } =20 -static int ad7606_scan_direct(struct iio_dev *indio_dev, unsigned int ch) +static int ad7606_scan_direct(struct iio_dev *indio_dev, unsigned int ch, + int *val) { struct ad7606_state *st =3D iio_priv(indio_dev); int ret; @@ -128,8 +129,10 @@ static int ad7606_scan_direct(struct iio_dev *indio_de= v, unsigned int ch) } =20 ret =3D ad7606_read_samples(st); - if (ret =3D=3D 0) - ret =3D st->data[ch]; + if (ret) + goto error_ret; + + *val =3D sign_extend32(st->data[ch], 15); =20 error_ret: gpiod_set_value(st->gpio_convst, 0); @@ -149,10 +152,9 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: iio_device_claim_direct_scoped(return -EBUSY, indio_dev) { - ret =3D ad7606_scan_direct(indio_dev, chan->address); + ret =3D ad7606_scan_direct(indio_dev, chan->address, val); if (ret < 0) return ret; - *val =3D (short) ret; return IIO_VAL_INT; } unreachable(); --=20 2.46.0 From nobody Fri Nov 29 12:31:39 2024 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.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 C0F3D19EEDF for ; Thu, 19 Sep 2024 13:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751098; cv=none; b=fPMkmQIrQLPAKFhcgG9jPqKQplsMLKnCrflLH55pSj/tEyuOrmWNFUFgkTuJVRvZZaBlb7haEmlBKYQ+cNYdo5Vr2w2obJV6WhAqTTRBfF95BEpx/g5oouwbBMzNb9lUpapr1j4lf2UrauJTllKLXA7YAKQ3DYwRfh1yBNDzZPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751098; c=relaxed/simple; bh=63E+67ut4upizdiuiIAIWX+zYFAZeVjPavEhQ9/iZhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G5adiP341iVIPHh9xR7jjglaaD1IsgvAZwltWC5SgHBKQ6oCdZhXR1yAXfONN/TnG+i2qIhxPpFJEqznlcSv5saDGmSPKuS228CK/TgZqvln7b36m3K6RAcfCaERfXC5+/1xX39/rrZf/oCG/FPhygaABkA59nLhW1N87SROuYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=Jphyq+eb; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Jphyq+eb" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a86e9db75b9so116568366b.1 for ; Thu, 19 Sep 2024 06:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726751095; x=1727355895; 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; bh=SGwDN6q9n1jJb2Ms/M/RGF868EKCCN0sUCPfjspQZyM=; b=Jphyq+ebQ5dbjIF3DV+eGxHNivpr+MNJ2gi+3RGIctrshwoKrvznwTbbh2Bvp02zEB 1cxGmGISe1JDxRQMJZ0AnsNBwkflbrnWSinsOwH+0t+y2jonUCVga24mM+yBNZkqQhR7 81+MsnnPbxslpngsOHdFGgIben8B2pbOovAwWKZLqeJuPfwLfWF9Rtn6YjwuGmpo2PbS itk9Bw2VRectG3bxozJMaDRFmAF3yQ2stV+iygCKs3pyp6p0E0OhteYRhcclEKSPsETx dr6L37f7jn4we0ODa6IoWZu8/JLPEeq4H24zOryDJh4PmIIkJHrpyBpeARiQCuBwtVso aCcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726751095; x=1727355895; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SGwDN6q9n1jJb2Ms/M/RGF868EKCCN0sUCPfjspQZyM=; b=uiaHgG6qMvDxz5zfjOCUtSno0Gy1MVzouOVZcyoXczI0SAQtiLK4zHL6KGdGHxWBGY TzwYGbHRUGZpgtes7IQSOudeHlB51XUnuwaTjxvlEyvIYLbcf4IF7AWM+pDPBq7tkJAx X/j2qWVjYe+SzzuNsYxGY1ceff54sRTM3DUfkD24qyj3uFR2XpTxbJO0TA1Z+pRok6ll bZyPgoK+ygZHQVeu2YmIeodTITd1JkFBJvzjJHHPdKIOfE9Bf/Vsy+rQwFM8wRyn2d5D ZhmEtbnRwxK4wmc2GCTq1eMJOdkx4LTvFHQRU0bsNQrWbi1tXFy9g+NrwTMhuWDIX57p gIMg== X-Forwarded-Encrypted: i=1; AJvYcCUBUGmK5l5iZwAsbpvgAC1Z6qAfAJh3aRDXScWI2QspoKJ6KSBKxO4agbTuuKAAgjVXTrTsXp8eHKV9dSo=@vger.kernel.org X-Gm-Message-State: AOJu0Yze95IYRcvqkWS3/wou//5nMUUJMhCDimeVZ0jExQ5R6MjDeRat hwYtn0tSp4RZg+tDIc34jZLZVLwoCkLG7etIVhmVtawJoJCLVD4cjwoz7d8IWtNpbOQVwO/OftB xDb8= X-Google-Smtp-Source: AGHT+IFNvdUG7g3Pl8zwTlSq7TzYdKM+DB1NKm/09lPUq9vW6DyC1KsLbh0Fw1ONi7W35QsGLikqSw== X-Received: by 2002:a17:907:7d87:b0:a90:3492:9ad8 with SMTP id a640c23a62f3a-a9034936970mr2788278566b.65.1726751094742; Thu, 19 Sep 2024 06:04:54 -0700 (PDT) Received: from localhost.localdomain ([188.27.132.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90cbc7122esm53213166b.124.2024.09.19.06.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 06:04:54 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: jic23@kernel.org, krzk+dt@kernel.org, robh@kernel.org, lars@metafoo.de, michael.hennerich@analog.com, gstols@baylibre.com, dlechner@baylibre.com, Alexandru Ardelean Subject: [PATCH v7 3/8] iio: adc: ad7606: move scale_setup as function pointer on chip-info Date: Thu, 19 Sep 2024 16:04:38 +0300 Message-ID: <20240919130444.2100447-4-aardelean@baylibre.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919130444.2100447-1-aardelean@baylibre.com> References: <20240919130444.2100447-1-aardelean@baylibre.com> 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 Up until now, all ADCs were 16-bit precision. With the addition of the AD7606C some things will change. For one thing, we'll need to setup available-scales for each channel. Also for the 18-bit precision variants, the scales will be different. This change adds a function-pointer to the chip-info struct to be able to set this up (differently) for the new parts. For the current parts, the scales are the same (for all parts) between HW and SW modes. Also creating a 'ad7606_sw_mode_setup()' function that must be called before the scale_setup callback. This is needed in case SW mode is enabled for some ADCs. Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/ad7606.c | 84 +++++++++++++++++++++++++++++----------- drivers/iio/adc/ad7606.h | 6 +++ 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 032a8135c912..7dc299aeee15 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -32,12 +32,12 @@ * Scales are computed as 5000/32768 and 10000/32768 respectively, * so that when applied to the raw values they provide mV values */ -static const unsigned int ad7606_scale_avail[2] =3D { +static const unsigned int ad7606_16bit_hw_scale_avail[2] =3D { 152588, 305176 }; =20 =20 -static const unsigned int ad7616_sw_scale_avail[3] =3D { +static const unsigned int ad7606_16bit_sw_scale_avail[3] =3D { 76293, 152588, 305176 }; =20 @@ -62,6 +62,25 @@ int ad7606_reset(struct ad7606_state *st) } EXPORT_SYMBOL_NS_GPL(ad7606_reset, IIO_AD7606); =20 +static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st, int ch) +{ + if (!st->sw_mode_en) { + /* tied to logic low, analog input range is +/- 5V */ + st->range[ch] =3D 0; + st->scale_avail =3D ad7606_16bit_hw_scale_avail; + st->num_scales =3D ARRAY_SIZE(ad7606_16bit_hw_scale_avail); + return 0; + } + + /* Scale of 0.076293 is only available in sw mode */ + /* After reset, in software mode, =C2=B110 V is set by default */ + st->range[ch] =3D 2; + st->scale_avail =3D ad7606_16bit_sw_scale_avail; + st->num_scales =3D ARRAY_SIZE(ad7606_16bit_sw_scale_avail); + + return 0; +} + static int ad7606_reg_access(struct iio_dev *indio_dev, unsigned int reg, unsigned int writeval, @@ -358,34 +377,40 @@ static const struct ad7606_chip_info ad7606_chip_info= _tbl[] =3D { [ID_AD7605_4] =3D { .channels =3D ad7605_channels, .num_channels =3D 5, + .scale_setup_cb =3D ad7606_16bit_chan_scale_setup, }, [ID_AD7606_8] =3D { .channels =3D ad7606_channels_16bit, .num_channels =3D 9, + .scale_setup_cb =3D ad7606_16bit_chan_scale_setup, .oversampling_avail =3D ad7606_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), }, [ID_AD7606_6] =3D { .channels =3D ad7606_channels_16bit, .num_channels =3D 7, + .scale_setup_cb =3D ad7606_16bit_chan_scale_setup, .oversampling_avail =3D ad7606_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), }, [ID_AD7606_4] =3D { .channels =3D ad7606_channels_16bit, .num_channels =3D 5, + .scale_setup_cb =3D ad7606_16bit_chan_scale_setup, .oversampling_avail =3D ad7606_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), }, [ID_AD7606B] =3D { .channels =3D ad7606_channels_16bit, .num_channels =3D 9, + .scale_setup_cb =3D ad7606_16bit_chan_scale_setup, .oversampling_avail =3D ad7606_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), }, [ID_AD7616] =3D { .channels =3D ad7616_channels, .num_channels =3D 17, + .scale_setup_cb =3D ad7606_16bit_chan_scale_setup, .oversampling_avail =3D ad7616_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7616_oversampling_avail), .os_req_reset =3D true, @@ -523,6 +548,35 @@ static const struct iio_trigger_ops ad7606_trigger_ops= =3D { .validate_device =3D iio_trigger_validate_own_device, }; =20 +static int ad7606_sw_mode_setup(struct iio_dev *indio_dev) +{ + struct ad7606_state *st =3D iio_priv(indio_dev); + + st->sw_mode_en =3D st->bops->sw_mode_config && + device_property_present(st->dev, "adi,sw-mode"); + if (!st->sw_mode_en) + return 0; + + indio_dev->info =3D &ad7606_info_os_range_and_debug; + + return st->bops->sw_mode_config(indio_dev); +} + +static int ad7606_chan_scales_setup(struct iio_dev *indio_dev) +{ + unsigned int num_channels =3D indio_dev->num_channels - 1; + struct ad7606_state *st =3D iio_priv(indio_dev); + int ch, ret; + + for (ch =3D 0; ch < num_channels; ch++) { + ret =3D st->chip_info->scale_setup_cb(st, ch); + if (ret) + return ret; + } + + return 0; +} + int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, const char *name, unsigned int id, const struct ad7606_bus_ops *bops) @@ -542,11 +596,7 @@ int ad7606_probe(struct device *dev, int irq, void __i= omem *base_address, mutex_init(&st->lock); st->bops =3D bops; st->base_address =3D base_address; - /* tied to logic low, analog input range is +/- 5V */ - st->range[0] =3D 0; st->oversampling =3D 1; - st->scale_avail =3D ad7606_scale_avail; - st->num_scales =3D ARRAY_SIZE(ad7606_scale_avail); =20 ret =3D devm_regulator_get_enable(dev, "avcc"); if (ret) @@ -595,23 +645,13 @@ int ad7606_probe(struct device *dev, int irq, void __= iomem *base_address, st->write_scale =3D ad7606_write_scale_hw; st->write_os =3D ad7606_write_os_hw; =20 - if (st->bops->sw_mode_config) - st->sw_mode_en =3D device_property_present(st->dev, - "adi,sw-mode"); - - if (st->sw_mode_en) { - /* Scale of 0.076293 is only available in sw mode */ - st->scale_avail =3D ad7616_sw_scale_avail; - st->num_scales =3D ARRAY_SIZE(ad7616_sw_scale_avail); - - /* After reset, in software mode, =C2=B110 V is set by default */ - memset32(st->range, 2, ARRAY_SIZE(st->range)); - indio_dev->info =3D &ad7606_info_os_range_and_debug; + ret =3D ad7606_sw_mode_setup(indio_dev); + if (ret) + return ret; =20 - ret =3D st->bops->sw_mode_config(indio_dev); - if (ret < 0) - return ret; - } + ret =3D ad7606_chan_scales_setup(indio_dev); + if (ret) + return ret; =20 st->trig =3D devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index 204a343067e5..95f3b3cb0be3 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -40,10 +40,15 @@ =20 #define AD7616_CHANNEL(num) AD7606_SW_CHANNEL(num, 16) =20 +struct ad7606_state; + +typedef int (*ad7606_scale_setup_cb_t)(struct ad7606_state *st, int ch); + /** * struct ad7606_chip_info - chip specific information * @channels: channel specification * @num_channels: number of channels + * @scale_setup_cb: callback to setup the scales for each channel * @oversampling_avail pointer to the array which stores the available * oversampling ratios. * @oversampling_num number of elements stored in oversampling_avail array @@ -54,6 +59,7 @@ struct ad7606_chip_info { const struct iio_chan_spec *channels; unsigned int num_channels; + ad7606_scale_setup_cb_t scale_setup_cb; const unsigned int *oversampling_avail; unsigned int oversampling_num; bool os_req_reset; --=20 2.46.0 From nobody Fri Nov 29 12:31:39 2024 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 55C6C19F479 for ; Thu, 19 Sep 2024 13:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751100; cv=none; b=mzXRTMK91YU0ZJTKjj82aWvhPdEO13eqHkXeO6NdgLTAAuX5ejbren34AiaJeKDeRNVGi141ZFAoUHJEJuZ9XKuIYX/6dJHOuZP0WK1zythQ42yx49PJrXmL97FsXjVefJGp7yvsdEm4NsiXEDo3TUHtV+e5XghSJcWJW9b1A5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751100; c=relaxed/simple; bh=AiPTW+eC15hy8WCQnEhvb/1uaDdvGFA0NbdJznajRXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SEQy9i0TOLQ+p7vZG0czd7tkvNQThvRlPEdqGmCAZ7rxfvSEGADYI8CDcGnObA37NnaIYsvWiMxyoHqjKAennKc7IodoSiWtkCf7m433UIpRW/cp+Ruh62wZiynScVg68IQwpQfZHTrXtA54qgFJJX9XtPhqj5CLYX5tQIro0MQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=VGqwEDeA; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="VGqwEDeA" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5c26a52cf82so497178a12.2 for ; Thu, 19 Sep 2024 06:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726751096; x=1727355896; 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; bh=WyNNlkM7L3gokB2vnij6JW+A3TweMpCxgtAx8xE2ujg=; b=VGqwEDeAT+gNBV8F/r8eqUvUl6XAaqX1Sh1lI/1Npgf8lG/Abn8wvcFFW+k6oeLJ69 q8hqv15ozIyJ163TvigRVicJowbXSiGibQieOjEWMb/Z9aMPwif1sivl+D5u58mjO9vz P+XduiQN/v9eXGgEv5x3RITi25UazvjUy6P/+4jb3AvnfbKlzSoMuzXhpeUQVEwug4s2 cKYHOp6KZKm0Uqz/NLRLm85NtIWEwHuTmxqMlcw6F+g7ZrNHGic6fUoiOj3tnJOlfCPk bBrvXbuf/KHLNC9mVV5OHwoGKbp3BQkndb34uw6WMauvAGZnjfrWtFrwjQy7jwW5LVXa a7+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726751096; x=1727355896; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WyNNlkM7L3gokB2vnij6JW+A3TweMpCxgtAx8xE2ujg=; b=vW43s1WgM4Tsl4f0wxE9Q6V13W0t3xAngBpRK3vsc66X1IiTO0ATM1UbeDxF34B1Cn sa6rY37toomefXHbr7ZYpGl7+SFEENw2WTXpGusFmMejyM95z6lUAqmZJE8URLewJ/C0 GnKBkGDqrD9WkuIZMaENXaQr2F7pzaNRXnGfnMnutr7KjNYRPWcaQRqQ+WYEgqdfVwzO Gok+TX2+Q5rk2+MZqZc/Jf5k9NOR2PvhMmkXx7UT1r5CG6uQn1AybbQHKsIbWQsd3TMD l5cgsQReeNT4cPSMyd+2fvofyLfjY2J62/kfGqXKmAO21kZNyYEw5tHz9dlE6RyNYxuq 6gCg== X-Forwarded-Encrypted: i=1; AJvYcCXols85jyqpru6PgycNDm3tLZnSWoxAFJmiTCpzU/DDRXaJQOUMrQxPNth9u08o9RTDHypxBy1ok16zHsM=@vger.kernel.org X-Gm-Message-State: AOJu0YwkS5fXAiu/cUzEFI7X6L0f9yzP9qUuBhWwAyZr+f5dJuRfQNeW rhkQ7kKHAY+H/sFbsBg4bv5st5QQOyX77W0+viiepLx3DN+y26m0LYRH7PTHtkuaRqcUhg17Xom tidg= X-Google-Smtp-Source: AGHT+IFsIEnS+1xTSYTHdSp6hiXffA07P4l0229m/9LQuDVZfBMaMTJic2JjSwIY7FZYrQG6iyNeTA== X-Received: by 2002:a05:6402:530b:b0:5c0:8eb1:2800 with SMTP id 4fb4d7f45d1cf-5c41e0969bdmr28971931a12.11.1726751096528; Thu, 19 Sep 2024 06:04:56 -0700 (PDT) Received: from localhost.localdomain ([188.27.132.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90cbc7122esm53213166b.124.2024.09.19.06.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 06:04:56 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: jic23@kernel.org, krzk+dt@kernel.org, robh@kernel.org, lars@metafoo.de, michael.hennerich@analog.com, gstols@baylibre.com, dlechner@baylibre.com, Alexandru Ardelean Subject: [PATCH v7 4/8] iio: adc: ad7606: wrap channel ranges & scales into struct Date: Thu, 19 Sep 2024 16:04:39 +0300 Message-ID: <20240919130444.2100447-5-aardelean@baylibre.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919130444.2100447-1-aardelean@baylibre.com> References: <20240919130444.2100447-1-aardelean@baylibre.com> 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 With the addition of AD7606C-16,18 which have differential & bipolar channels (and ranges), which can vary from channel to channel, we'll need to keep more information about each channel range. To do that, we'll add a 'struct ad7606_chan_scale' type to hold just configuration for each channel. This includes the scales per channel (which can be different with AD7606C-16,18), as well as the range for each channel. This driver was already keeping the range value for each channel before, and since this is couple with the scales, it also makes sense to put them in the same struct. Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/ad7606.c | 29 ++++++++++++++++++----------- drivers/iio/adc/ad7606.h | 22 ++++++++++++++++------ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 7dc299aeee15..94a254c0725e 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -64,19 +64,21 @@ EXPORT_SYMBOL_NS_GPL(ad7606_reset, IIO_AD7606); =20 static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st, int ch) { + struct ad7606_chan_scale *cs =3D &st->chan_scales[ch]; + if (!st->sw_mode_en) { /* tied to logic low, analog input range is +/- 5V */ - st->range[ch] =3D 0; - st->scale_avail =3D ad7606_16bit_hw_scale_avail; - st->num_scales =3D ARRAY_SIZE(ad7606_16bit_hw_scale_avail); + cs->range =3D 0; + cs->scale_avail =3D ad7606_16bit_hw_scale_avail; + cs->num_scales =3D ARRAY_SIZE(ad7606_16bit_hw_scale_avail); return 0; } =20 /* Scale of 0.076293 is only available in sw mode */ /* After reset, in software mode, =C2=B110 V is set by default */ - st->range[ch] =3D 2; - st->scale_avail =3D ad7606_16bit_sw_scale_avail; - st->num_scales =3D ARRAY_SIZE(ad7606_16bit_sw_scale_avail); + cs->range =3D 2; + cs->scale_avail =3D ad7606_16bit_sw_scale_avail; + cs->num_scales =3D ARRAY_SIZE(ad7606_16bit_sw_scale_avail); =20 return 0; } @@ -167,6 +169,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, { int ret, ch =3D 0; struct ad7606_state *st =3D iio_priv(indio_dev); + struct ad7606_chan_scale *cs; =20 switch (m) { case IIO_CHAN_INFO_RAW: @@ -180,8 +183,9 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: if (st->sw_mode_en) ch =3D chan->address; + cs =3D &st->chan_scales[ch]; *val =3D 0; - *val2 =3D st->scale_avail[st->range[ch]]; + *val2 =3D cs->scale_avail[cs->range]; return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_OVERSAMPLING_RATIO: *val =3D st->oversampling; @@ -211,8 +215,9 @@ static ssize_t in_voltage_scale_available_show(struct d= evice *dev, { struct iio_dev *indio_dev =3D dev_to_iio_dev(dev); struct ad7606_state *st =3D iio_priv(indio_dev); + struct ad7606_chan_scale *cs =3D &st->chan_scales[0]; =20 - return ad7606_show_avail(buf, st->scale_avail, st->num_scales, true); + return ad7606_show_avail(buf, cs->scale_avail, cs->num_scales, true); } =20 static IIO_DEVICE_ATTR_RO(in_voltage_scale_available, 0); @@ -250,19 +255,21 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, long mask) { struct ad7606_state *st =3D iio_priv(indio_dev); + struct ad7606_chan_scale *cs; int i, ret, ch =3D 0; =20 guard(mutex)(&st->lock); =20 switch (mask) { case IIO_CHAN_INFO_SCALE: - i =3D find_closest(val2, st->scale_avail, st->num_scales); if (st->sw_mode_en) ch =3D chan->address; + cs =3D &st->chan_scales[ch]; + i =3D find_closest(val2, cs->scale_avail, cs->num_scales); ret =3D st->write_scale(indio_dev, ch, i); if (ret < 0) return ret; - st->range[ch] =3D i; + cs->range =3D i; =20 return 0; case IIO_CHAN_INFO_OVERSAMPLING_RATIO: @@ -707,7 +714,7 @@ static int ad7606_resume(struct device *dev) struct ad7606_state *st =3D iio_priv(indio_dev); =20 if (st->gpio_standby) { - gpiod_set_value(st->gpio_range, st->range[0]); + gpiod_set_value(st->gpio_range, st->chan_scales[0].range); gpiod_set_value(st->gpio_standby, 1); ad7606_reset(st); } diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index 95f3b3cb0be3..2b90f52affba 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -8,6 +8,8 @@ #ifndef IIO_ADC_AD7606_H_ #define IIO_ADC_AD7606_H_ =20 +#define AD760X_MAX_CHANNELS 16 + #define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all, bits) { \ .type =3D IIO_VOLTAGE, \ .indexed =3D 1, \ @@ -66,17 +68,27 @@ struct ad7606_chip_info { unsigned long init_delay_ms; }; =20 +/** + * struct ad7606_chan_scale - channel scale configuration + * @scale_avail pointer to the array which stores the available scales + * @num_scales number of elements stored in the scale_avail array + * @range voltage range selection, selects which scale to apply + */ +struct ad7606_chan_scale { + const unsigned int *scale_avail; + unsigned int num_scales; + unsigned int range; +}; + /** * struct ad7606_state - driver instance specific data * @dev pointer to kernel device * @chip_info entry in the table of chips that describes this device * @bops bus operations (SPI or parallel) - * @range voltage range selection, selects which scale to apply + * @chan_scales scale configuration for channels * @oversampling oversampling selection * @base_address address from where to read data in parallel operation * @sw_mode_en software mode enabled - * @scale_avail pointer to the array which stores the available scales - * @num_scales number of elements stored in the scale_avail array * @oversampling_avail pointer to the array which stores the available * oversampling ratios. * @num_os_ratios number of elements stored in oversampling_avail array @@ -100,12 +112,10 @@ struct ad7606_state { struct device *dev; const struct ad7606_chip_info *chip_info; const struct ad7606_bus_ops *bops; - unsigned int range[16]; + struct ad7606_chan_scale chan_scales[AD760X_MAX_CHANNELS]; unsigned int oversampling; void __iomem *base_address; bool sw_mode_en; - const unsigned int *scale_avail; - unsigned int num_scales; const unsigned int *oversampling_avail; unsigned int num_os_ratios; int (*write_scale)(struct iio_dev *indio_dev, int ch, int val); --=20 2.46.0 From nobody Fri Nov 29 12:31:39 2024 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 646B319FA8F for ; Thu, 19 Sep 2024 13:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751102; cv=none; b=KoswfGdlbAD4uj1dK/mwV6spxpAkuWTp2KMPBFcSkGY2L15rKhrDmPxzn2ofjnKMrH83OboRLYjzfhWQFCul1fVt3oZH7KTvaS6R7bDO0Uls7sLa/D3c3cDoo+w9InB0BWuOkOioQkcpmbTNRXAQFT7TFiE4hwWnIOF+JPXUF5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751102; c=relaxed/simple; bh=RzKqVRTlU4lc2tQgU6jZrPJ/xkgEk5frw6b90nEo2eQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GiI7oWoj4Kd2VdwcDFeH4uy2OIAAvwNI75zy74QvwwGWa0aSWEPW3ytCZLAaOqsR8d4ar/eQ7Rm2dYtsIOaNRqnVFtWzX6wko53N8n+QnXTb/CvLDzE3vRv2Dci7nJdAquWOIoyIwyMKt6FYhY7eMPmxY2kn/u+JASw/p69FEx4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=UeG+KI3m; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="UeG+KI3m" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5356aa9a0afso1372807e87.2 for ; Thu, 19 Sep 2024 06:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726751098; x=1727355898; 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; bh=d3L8FUnehujX20iEAFhi39bqT6dZ8dbQps0T02oejwI=; b=UeG+KI3m6QzdfBgiqyjaL+/wGIiCTWI37JIsEOk1YCxm/6iZABHaoEw9yAvoXqVbFS uVz60xBSLg2/Ey3M0+Gx5WBarnPeiijtIltRTZluseBsaRe0QL2SaTNWPpVYelCCaEV2 acVmZBqvUgCN3uaaT8C4Z2zgWRC/SoC9Rs34/sWJforzrkKK/W21A5D8ihfOiT2sMAdC 5R6XOUXG/kUb/D6ynZN0lbGO/5b2OsOIcpcLEzBx8hxrh5uKWFcR5L69OU1q4xIUg+OA TBdRZkUt88QEkThUBiEUQoHhTg/PVH0lnrHCPs098MJzU5Rrgsp1Nozjxk95d4L+j2jh vKvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726751098; x=1727355898; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d3L8FUnehujX20iEAFhi39bqT6dZ8dbQps0T02oejwI=; b=IDZHJnB8PXDswMmw/XjOLNbEEtHs70mjpKyqe3HWHln32kqHEiwdYndqcCXm7AR0wI 2HsD+U4Hkfy91dK2+lNG96SdIuGsCFhNE11QTPLbErxwSfTp5tYPz8hVF/0sG+b/33gN Ydc6Hq719wESCMttlLreKjK+yLvE3tAuBafj2LhnLwzo1PWWNNeN4eYmWrPuSlN2Y7UH jT/XDXgF0XagkXRtatEZvoCP8AGSdKU4g15bbU7F4HQljeqX8Fp+igZyHDX2XUUWuRdE FmnAEJscY0MutxGgBEl2bIoVStYXrvvgy6ZggAiSlHGejqDkBUyAPXHSbFDezpGEZNYg aL8w== X-Forwarded-Encrypted: i=1; AJvYcCUSYxRy3RRb8lMBHUCw2RzEnezRyWPj4mGyUPPYkhUzV2qBPMjBBORPcX12Glf1pFk7VJX++3ZQw8riUO8=@vger.kernel.org X-Gm-Message-State: AOJu0YygbbRn5e5KgojSbOT+KF6RDQMapRIPdnPrnWKTq7r45WepfyDg Wf3+iQ1uE1Rc5f78/PhbVDRUtaO0zc4O/IHatPgKzTzg764eZuKN/rUkiOSWPC8= X-Google-Smtp-Source: AGHT+IEVJORrtAqmlG0amMhbhQuH8cetI9n/WAL/CzoUUx25CRGGiDOQzMnwnN+YuIKIM2r8hrUTNg== X-Received: by 2002:a05:6512:32c7:b0:533:4620:ebec with SMTP id 2adb3069b0e04-5367feb9639mr18350294e87.3.1726751098462; Thu, 19 Sep 2024 06:04:58 -0700 (PDT) Received: from localhost.localdomain ([188.27.132.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90cbc7122esm53213166b.124.2024.09.19.06.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 06:04:58 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: jic23@kernel.org, krzk+dt@kernel.org, robh@kernel.org, lars@metafoo.de, michael.hennerich@analog.com, gstols@baylibre.com, dlechner@baylibre.com, Alexandru Ardelean Subject: [PATCH v7 5/8] iio: adc: ad7606: rework available attributes for SW channels Date: Thu, 19 Sep 2024 16:04:40 +0300 Message-ID: <20240919130444.2100447-6-aardelean@baylibre.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919130444.2100447-1-aardelean@baylibre.com> References: <20240919130444.2100447-1-aardelean@baylibre.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" For SW mode, the oversampling and scales attributes are always present. So, they can be implemented via a 'read_avail' hook in iio_info. For HW mode, it's a bit tricky, as these attributes get assigned based on GPIO definitions. So, for SW mode, we define a separate AD7606_SW_CHANNEL() macro, and use that for the SW channels. And 'ad7606_info_os_range_and_debug' can be renamed to 'ad7606_info_sw_mode' as it is only used for SW mode. For the 'read_avail' hook, we'll need to allocate the SW scales, so that they are just returned userspace without any extra processing. The allocation will happen when then ad7606_state struct is allocated. The oversampling available parameters don't need any extra processing; they can just be passed back to userspace (as they are). Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/ad7606.c | 52 ++++++++++++++++++++++++++++++++++--- drivers/iio/adc/ad7606.h | 32 ++++++++++++++++++++--- drivers/iio/adc/ad7606_spi. | 0 3 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 drivers/iio/adc/ad7606_spi. diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 94a254c0725e..b909ee14fd81 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -512,6 +512,37 @@ static int ad7606_buffer_predisable(struct iio_dev *in= dio_dev) return 0; } =20 +static int ad7606_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long info) +{ + struct ad7606_state *st =3D iio_priv(indio_dev); + struct ad7606_chan_scale *cs; + unsigned int ch =3D 0; + + switch (info) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + *vals =3D st->oversampling_avail; + *length =3D st->num_os_ratios; + *type =3D IIO_VAL_INT; + + return IIO_AVAIL_LIST; + + case IIO_CHAN_INFO_SCALE: + if (st->sw_mode_en) + ch =3D chan->address; + + cs =3D &st->chan_scales[ch]; + *vals =3D cs->scale_avail_show; + *length =3D cs->num_scales * 2; + *type =3D IIO_VAL_INT_PLUS_MICRO; + + return IIO_AVAIL_LIST; + } + return -EINVAL; +} + static const struct iio_buffer_setup_ops ad7606_buffer_ops =3D { .postenable =3D &ad7606_buffer_postenable, .predisable =3D &ad7606_buffer_predisable, @@ -529,11 +560,11 @@ static const struct iio_info ad7606_info_os_and_range= =3D { .validate_trigger =3D &ad7606_validate_trigger, }; =20 -static const struct iio_info ad7606_info_os_range_and_debug =3D { +static const struct iio_info ad7606_info_sw_mode =3D { .read_raw =3D &ad7606_read_raw, .write_raw =3D &ad7606_write_raw, + .read_avail =3D &ad7606_read_avail, .debugfs_reg_access =3D &ad7606_reg_access, - .attrs =3D &ad7606_attribute_group_os_and_range, .validate_trigger =3D &ad7606_validate_trigger, }; =20 @@ -564,7 +595,7 @@ static int ad7606_sw_mode_setup(struct iio_dev *indio_d= ev) if (!st->sw_mode_en) return 0; =20 - indio_dev->info =3D &ad7606_info_os_range_and_debug; + indio_dev->info =3D &ad7606_info_sw_mode; =20 return st->bops->sw_mode_config(indio_dev); } @@ -576,9 +607,24 @@ static int ad7606_chan_scales_setup(struct iio_dev *in= dio_dev) int ch, ret; =20 for (ch =3D 0; ch < num_channels; ch++) { + struct ad7606_chan_scale *cs; + int i; + ret =3D st->chip_info->scale_setup_cb(st, ch); if (ret) return ret; + + cs =3D &st->chan_scales[ch]; + + if (cs->num_scales * 2 > AD760X_MAX_SCALE_SHOW) + return dev_err_probe(st->dev, -ERANGE, + "Driver error: scale range too big"); + + /* Generate a scale_avail list for showing to userspace */ + for (i =3D 0; i < cs->num_scales; i++) { + cs->scale_avail_show[i * 2] =3D 0; + cs->scale_avail_show[i * 2 + 1] =3D cs->scale_avail[i]; + } } =20 return 0; diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index 2b90f52affba..25e84efd15c3 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -27,6 +27,29 @@ }, \ } =20 +#define AD7606_SW_CHANNEL(num, bits) { \ + .type =3D IIO_VOLTAGE, \ + .indexed =3D 1, \ + .channel =3D num, \ + .address =3D num, \ + .info_mask_separate =3D \ + BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_separate_available =3D \ + BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all =3D \ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ + .info_mask_shared_by_all_available =3D \ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ + .scan_index =3D num, \ + .scan_type =3D { \ + .sign =3D 's', \ + .realbits =3D (bits), \ + .storagebits =3D (bits) > 16 ? 32 : 16, \ + .endianness =3D IIO_CPU, \ + }, \ +} + #define AD7605_CHANNEL(num) \ AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW), \ BIT(IIO_CHAN_INFO_SCALE), 0, 16) @@ -36,10 +59,6 @@ BIT(IIO_CHAN_INFO_SCALE), \ BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), bits) =20 -#define AD7606_SW_CHANNEL(num, bits) \ - AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),\ - 0, BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), bits) - #define AD7616_CHANNEL(num) AD7606_SW_CHANNEL(num, 16) =20 struct ad7606_state; @@ -71,11 +90,16 @@ struct ad7606_chip_info { /** * struct ad7606_chan_scale - channel scale configuration * @scale_avail pointer to the array which stores the available scales + * @scale_avail_show a duplicate of 'scale_avail' which is readily formatt= ed + * such that it can be read via the 'read_avail' hook * @num_scales number of elements stored in the scale_avail array * @range voltage range selection, selects which scale to apply */ struct ad7606_chan_scale { +#define AD760X_MAX_SCALES 16 +#define AD760X_MAX_SCALE_SHOW (AD760X_MAX_SCALES * 2) const unsigned int *scale_avail; + int scale_avail_show[AD760X_MAX_SCALE_SHOW]; unsigned int num_scales; unsigned int range; }; diff --git a/drivers/iio/adc/ad7606_spi. b/drivers/iio/adc/ad7606_spi. new file mode 100644 index 000000000000..e69de29bb2d1 --=20 2.46.0 From nobody Fri Nov 29 12:31:39 2024 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.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 34B441A00E3 for ; Thu, 19 Sep 2024 13:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751104; cv=none; b=nUdJLFD0/wbvInZrwyBRaljB9iEjToq5998zyPockL9OmoV9g9Uj3ZIehS1r37uPVvVzGZsllXd/Pn2um7VZrdJSDfzsf/Yvd/0rh20Lv/JrmzLwwgzGrn7l4uAMfvhehRiEXeK02PXnIuTfpNA9dVCGj9IUKuUpoKNB/q2Ju64= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751104; c=relaxed/simple; bh=/ovmFlVD/7j+ipJY0VPXyzdNP1zhe/wqKiyGk4ajqgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N9UWEBqUwTSIvC0oTcHf1zVE+PbSpwyS3lGXnpnphp4bHys5eG/5scF1oHMYrn0LY7bibgk42ogfhqUXLlWQtkV/57bsRZvYgc0bmnekUjp26HrLMX++e7lTgVORu+1tEDxoFd+sxL8tVQ5WU25ckDKUqifScAC7JzBRUF0ELdU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=E9QTYpu3; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="E9QTYpu3" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5c42e7adbe0so989269a12.2 for ; Thu, 19 Sep 2024 06:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726751100; x=1727355900; 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; bh=g46xgvcRuzluvD9uFfVgOC6tB6SvIHIhrOwQLDjP3Ko=; b=E9QTYpu3jQaal8H9mZ6HwShBozQbTwcCvO11gFMo/QU6oV99UzwaBNHxo7jaOZSogf 43Ws6pO6eBbOk9ZQAJihVCeIbVlCTsTuoGtpWF9T4AGEgAGP9PwYoI/7Txfn0lMLYYQz cUJ/xEWZ0/OlZJazxqj6P48Swen/eNP9We9jZCuhrFqGGB/vX/Y8R0vqpCQeXEP8uIYt hJJIiLaC5ISBZOLs9xjxvK0+s9BV+kE+xC4rsoH0y0kBF4rtxasVvbj6tcpIxkXujOS/ huq4j34KwHlLlANPfKZd3BMoMYCUDF/5kGB7e4PXyFRnXv703+4ldzWHcOggMT5p0gWo w6Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726751100; x=1727355900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g46xgvcRuzluvD9uFfVgOC6tB6SvIHIhrOwQLDjP3Ko=; b=dJP8Daft+4Oz2wV82WtorHEo17J/LYQ3fJrGCg5ZSJ6EIvMszg5xV+RzfTkypYCYYD hXdx/ZozofpZ1F42AKNNkQx2gNef73Et7v5V1H/f5xR87Ku1YW479KpmMzp7N2GabFhY k4FsRIdnvh8hC9sbK0LMwB7045TQdoEciv16potvcyupyZFIEQLizhuU8CvGX3Hl6yFQ NGRiTwHX+K3B3kY+CmEOHX/9wjgAwvvvy81YTOEVfp+45bc5lfMxkBmEAp31a1LhpWw0 Z4C6Ka3FGOoOY1WaXVKAYdg2bOF9coBAaDPZS+pMn7WM9AVlfskgzPDRG8Y1E/L1vWAF Zqhw== X-Forwarded-Encrypted: i=1; AJvYcCUn3oMqkUOAfJXN3sZAl0GRURYkWd7QLLfQGL5dsT3Bc7M4X4tCp7erPTQaqrjNogGZeDLIrKi0rvW58Ig=@vger.kernel.org X-Gm-Message-State: AOJu0YxcipTYXaotqLxnsqjH2dSYOR+tCfGhUeGS6htvZDqDuwwKEq3u 0Lo6/sbH8s+57t//YSJbsmMkYPuFc45wHxysshYFEFK8BjReA17jqMFPIP2/sJI= X-Google-Smtp-Source: AGHT+IGZWvWVarAWxHdzLKTJNnQgxlemGlabJF9ZbqtOnxayKzR9Y2NE1y4XM7BEumvgC0ymjc1kfg== X-Received: by 2002:a17:906:bc26:b0:a8d:2ec3:94f4 with SMTP id a640c23a62f3a-a902964d007mr2208929966b.54.1726751100495; Thu, 19 Sep 2024 06:05:00 -0700 (PDT) Received: from localhost.localdomain ([188.27.132.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90cbc7122esm53213166b.124.2024.09.19.06.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 06:05:00 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: jic23@kernel.org, krzk+dt@kernel.org, robh@kernel.org, lars@metafoo.de, michael.hennerich@analog.com, gstols@baylibre.com, dlechner@baylibre.com, Alexandru Ardelean , Krzysztof Kozlowski Subject: [PATCH v7 6/8] dt-bindings: iio: adc: document diff-channels corner case for some ADCs Date: Thu, 19 Sep 2024 16:04:41 +0300 Message-ID: <20240919130444.2100447-7-aardelean@baylibre.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919130444.2100447-1-aardelean@baylibre.com> References: <20240919130444.2100447-1-aardelean@baylibre.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" Some ADCs have channels with negative and positive inputs, which can be used to measure differential voltage levels. These inputs/pins are dedicated (to the given channel) and cannot be muxed as with other ADCs. For those types of setups, the 'diff-channels' property can be specified to be used with the channel number (or reg property) for both negative and positive inputs/pins. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Alexandru Ardelean --- Documentation/devicetree/bindings/iio/adc/adc.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adc.yaml b/Documenta= tion/devicetree/bindings/iio/adc/adc.yaml index 8e7835cf36fd..b9bc02b5b07a 100644 --- a/Documentation/devicetree/bindings/iio/adc/adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adc.yaml @@ -37,6 +37,10 @@ properties: to both the positive and negative inputs of a differential ADC. The first value specifies the positive input pin, the second specifies the negative input pin. + There are also some ADCs, where the differential channel has dedicat= ed + positive and negative inputs which can be used to measure differenti= al + voltage levels. For those setups, this property can be configured wi= th + the 'reg' property for both inputs (i.e. diff-channels =3D = ). =20 single-channel: $ref: /schemas/types.yaml#/definitions/uint32 --=20 2.46.0 From nobody Fri Nov 29 12:31:39 2024 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 48FAC1A01C5 for ; Thu, 19 Sep 2024 13:05:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751106; cv=none; b=BUMob9RFNEEy7o7NCfupSD1QTHoqqF1A+HCrTdhswLpDsusnRzUgv1u2XfHRPngBTT31hjjEJPDWLeYtKu7R6LapWdnMQnlvHe4yig30kRnR2uDqZGbJcVOMUAI07yvte26N7gKSeaLuyFN2azCcFAeGKohuo8D1cH2glpZmGRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751106; c=relaxed/simple; bh=GQdyZWqzfnQT3hAZa3L+fZIM4t+AoyLa8IiB5e8peIs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V3YI80hBVSxoJwVvOz/PwAWZZcTJaT38w3MKf2W2oZ+n3FODYm+kiPvZHgRns+LMUcfXG+0nwdprb7iM+AlQS5Ljr5dY9B/HKW0AbjlCl2PR+R1nTZQOiXa9WAx6fyEZg0jp3sL06UzM3OGdzFneHeVwFqMjXbnJ4qYc2MzXkF8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=h+jCse6I; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="h+jCse6I" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a7aa086b077so112675066b.0 for ; Thu, 19 Sep 2024 06:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726751103; x=1727355903; 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; bh=G7id2uNYW2O+D+9KmRKjfLk5jRelw+ydc8eaTsKnZHc=; b=h+jCse6IKqg2yWvu2L50mVw/DU264NerkzbzJcT+mFPcBcOjx/8Mpcw8l7yJCb5M/X oO27CC5UvoP8dRMEv/xs1RbNBaCxZcFHYo9CzbMyIrI0vpflwUMWjJu5mJyV8Xz7j/f4 iBK93+XByp105yTfMYjMmMXSe3BbybxzV+1O/1Umic/jh0nn5ZfC45RIEHhqV0wK7UPr wD54Trc+apY3h7xRPGfMVPK0VvY8hv5vA7igdrUQ8//QErcJDMa9KlZQcIVbKmPLIm5f IEKiGr1aGNQqAdXIhrKvBTFynjfLaT8OXcXou1Atbs1ZwwgYxwfnfuO/vNLwN5PL0F+e P2hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726751103; x=1727355903; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G7id2uNYW2O+D+9KmRKjfLk5jRelw+ydc8eaTsKnZHc=; b=Ls9bH95b5B852C8W06PTf+QnQbmqLwHlx5ocN36PMZ0/01pKJDmPxSWHIzukFRdpoz 1sTO0EWyuAwaSndSs0c2UMgLbKROZDvkyBHqUEgkER6oFrQXBDK3vOmT70T9K3GWO3lj gh342aekFLYfMLfVS/upUlymAN/4zAy/T+YnYbDiCRqX3nAD+pK94xrHi8kxT3YYxOam 7XmSyUbQWcRCY+RaTR3xdI2KvQLRGakxhGrMV3WKje4xp880qoN9lw/ytLPmVh2c1w4K m2gqmMRjLOwYdkZOcfhsYHGQFOzT+9ieU+tqpGs34tuGXXUpVH008A8lW1cWvrJt76fy fRnw== X-Forwarded-Encrypted: i=1; AJvYcCV+gbccoEjNXTkcOc9nYH2eRAulaJO5g5+1EGSDP5rG67jAz+Jn0Sh0ky+0FWlAVT6xamXKnv346pK35o0=@vger.kernel.org X-Gm-Message-State: AOJu0YzPIn3EvvWY5EJcGFgn71R/RY7IfqwKk3WnAzT6hs5hC55KcHhO eOSaszA+SKRNAjD1bXdSUICZLHm9kNeZGVvex68sko56/cLYBot5DsVm7Vz3RTs= X-Google-Smtp-Source: AGHT+IGNlJottmDzPzx0Gu7cX0jZi+pY3crUMD5i6Wzg/5buXQlriDxASBEnczvo+IbUWDCdACJVyA== X-Received: by 2002:a17:907:d5a2:b0:a86:96d1:d1f with SMTP id a640c23a62f3a-a902943a557mr2472309566b.26.1726751102601; Thu, 19 Sep 2024 06:05:02 -0700 (PDT) Received: from localhost.localdomain ([188.27.132.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90cbc7122esm53213166b.124.2024.09.19.06.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 06:05:02 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: jic23@kernel.org, krzk+dt@kernel.org, robh@kernel.org, lars@metafoo.de, michael.hennerich@analog.com, gstols@baylibre.com, dlechner@baylibre.com, Alexandru Ardelean , Krzysztof Kozlowski Subject: [PATCH v7 7/8] dt-bindings: iio: adc: add docs for AD7606C-{16,18} parts Date: Thu, 19 Sep 2024 16:04:42 +0300 Message-ID: <20240919130444.2100447-8-aardelean@baylibre.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919130444.2100447-1-aardelean@baylibre.com> References: <20240919130444.2100447-1-aardelean@baylibre.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" The driver will support the AD7606C-16 and AD7606C-18. This change adds the compatible strings for these devices. The AD7606C-16,18 channels also support these (individually configurable) types of channels: - bipolar single-ended - unipolar single-ended - bipolar differential Reviewed-by: Krzysztof Kozlowski Signed-off-by: Alexandru Ardelean --- .../bindings/iio/adc/adi,ad7606.yaml | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml b/Do= cumentation/devicetree/bindings/iio/adc/adi,ad7606.yaml index 69408cae3db9..bec7cfba52a7 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml @@ -14,6 +14,8 @@ description: | https://www.analog.com/media/en/technical-documentation/data-sheets/AD76= 05-4.pdf https://www.analog.com/media/en/technical-documentation/data-sheets/ad76= 06_7606-6_7606-4.pdf https://www.analog.com/media/en/technical-documentation/data-sheets/AD76= 06B.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad76= 06c-16.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad76= 06c-18.pdf https://www.analog.com/media/en/technical-documentation/data-sheets/AD76= 16.pdf =20 properties: @@ -24,11 +26,19 @@ properties: - adi,ad7606-6 - adi,ad7606-8 # Referred to as AD7606 (without -8) in the datasheet - adi,ad7606b + - adi,ad7606c-16 + - adi,ad7606c-18 - adi,ad7616 =20 reg: maxItems: 1 =20 + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + spi-cpha: true =20 spi-cpol: true @@ -114,6 +124,47 @@ properties: assumed that the pins are hardwired to VDD. type: boolean =20 +patternProperties: + "^channel@[1-8]$": + type: object + $ref: adc.yaml + unevaluatedProperties: false + + properties: + reg: + description: + The channel number, as specified in the datasheet (from 1 to 8). + minimum: 1 + maximum: 8 + + diff-channels: + description: + Each channel can be configured as a bipolar differential channel. + The ADC uses the same positive and negative inputs for this. + This property must be specified as 'reg' (or the channel number)= for + both positive and negative inputs (i.e. diff-channels =3D ). + Since the configuration is bipolar differential, the 'bipolar' + property is required. + items: + minimum: 1 + maximum: 8 + + bipolar: + description: + The ADC channels can be configured as + * Bipolar single-ended + * Unipolar single-ended + * Bipolar differential + Therefore in the DT, if no channel node is specified, it is cons= idered + 'unipolar single-ended'. So for the other configurations the 'bi= polar' + property must be specified. If 'diff-channels' is specified, it = is + considered a bipolar differential channel. Otherwise it is bipol= ar + single-ended. + + required: + - reg + - bipolar + required: - compatible - reg @@ -170,6 +221,25 @@ allOf: adi,conversion-start-gpios: maxItems: 1 =20 + - if: + not: + required: + - adi,sw-mode + then: + patternProperties: + "^channel@[1-8]$": false + + - if: + not: + properties: + compatible: + enum: + - adi,ad7606c-16 + - adi,ad7606c-18 + then: + patternProperties: + "^channel@[1-8]$": false + unevaluatedProperties: false =20 examples: @@ -202,4 +272,54 @@ examples: standby-gpios =3D <&gpio 24 GPIO_ACTIVE_LOW>; }; }; + - | + #include + #include + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + adc@0 { + compatible =3D "adi,ad7606c-18"; + reg =3D <0>; + + #address-cells =3D <1>; + #size-cells =3D <0>; + + spi-max-frequency =3D <1000000>; + spi-cpol; + spi-cpha; + + avcc-supply =3D <&adc_vref>; + vdrive-supply =3D <&vdd_supply>; + + interrupts =3D <25 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent =3D <&gpio>; + + adi,conversion-start-gpios =3D <&gpio 17 GPIO_ACTIVE_HIGH>; + reset-gpios =3D <&gpio 27 GPIO_ACTIVE_HIGH>; + adi,first-data-gpios =3D <&gpio 22 GPIO_ACTIVE_HIGH>; + standby-gpios =3D <&gpio 24 GPIO_ACTIVE_LOW>; + + adi,sw-mode; + + channel@1 { + reg =3D <1>; + diff-channels =3D <1 1>; + bipolar; + }; + + channel@3 { + reg =3D <3>; + bipolar; + }; + + channel@8 { + reg =3D <8>; + diff-channels =3D <8 8>; + bipolar; + }; + + }; + }; ... --=20 2.46.0 From nobody Fri Nov 29 12:31:39 2024 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.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 63B3E1A0719 for ; Thu, 19 Sep 2024 13:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751108; cv=none; b=nITVQG8XraBTomp37SifBCkCmWKQRDvWJqCsMAAYrddpuUBmKmkC6/QQ6+AreyRauWBz6XvWAqANmE/FLnYpRuskxRqHC70Iwb/tLFjm6y8xpow0FjsBQ/t6wj3gyTqwOq3OebzpbaYOilIPwPh7MoA05U/k4lEJbOCkgPuZs9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726751108; c=relaxed/simple; bh=CiOMCexFCZSEd7owZvk3bwFRUxrfGS/QQ0aD+UzetPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=THwY8SyZXsg0NXoNVA9+LJ5dAHiRoOetMFhvRbZg0Z4iAHvbWMAIRHCltUAruFIZNQFjsmSboaBEjiwlfjZfQpOnMKsY6VFJGdktO6jy0h2rqK2g03HYMPLMcXnm5BYAhu1kWxlRbgqRx/Ri5pnY30iQASGZBSi+I8UN0P0/qIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=YOavxOSd; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="YOavxOSd" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a90349aa7e5so114360466b.0 for ; Thu, 19 Sep 2024 06:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726751105; x=1727355905; 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; bh=yzXjJttaQou+NiC+dCEGRBo2GWgoI4V/6wH3BP5H0TY=; b=YOavxOSdmb2FK7d7NyVgDGwW1DcnHMQW+RxuptpWWPYF7YVFdxK4KFi4xZY+Nb44Lc zcNvPVi1DOnfWlIns/8GElKSDUyL7kNAF8gyQgOhVQn/0JgfA03GKDMg1Ey/YOTnh3sh CO+82i7rjbgn/j2R82MLDntwE8X03Np0ysRNJrSCpfaWZXiv6/R1rYK7pXx1duocnY20 HuspUKV8hEIc7V4aM7vRz0AYgUJ0I6e+S7tvp2noLcZy+qFbd31TGg7NJ5L0dq9goeLI 1u3e6sB0S6bGe3SlfynVvMpnvzSpYGlphhRUo6dZBSYlAgT7ywFfVI7q2f4kl4hEEkoJ okag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726751105; x=1727355905; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yzXjJttaQou+NiC+dCEGRBo2GWgoI4V/6wH3BP5H0TY=; b=pB5urGvXmn7biJpQxUmpHQ06uQyAbJDBQBBYrkWxMsgbCcKSZpWu9w7Os9eqAkirT+ eOqLN705l8I2h3t3PfHmMFjzmnsUxU5LxoWDc62EIbdiBWnR3r/kVggv8o8WslwYnWjY rWxuwYC1vLDK4X+mpJiS1wSi7D6oSQdER6sPAn5MtmEEpWxcXubGlm64II2QrWFIS0sg PwIVZVY34VaUbfOB89NkkNKfj1QwY2aEEz35DNJ7acKht54xoLWThGryn9yGL0M6BxVy FlZVFXpMJ3kA0JLgIfZckHqlBIPB/iGVE54UQI7MWO5/xCdRX7ezI5gMT2SYoq2hu3CN M7QA== X-Forwarded-Encrypted: i=1; AJvYcCWLQR13ZSjOkh0WeOkiFHwlLGzuEwOgLB0gqWXhWlA1cZ6Q9EBS+db1Eou3AIOVlGUHjU6kRNYbnkrpQLU=@vger.kernel.org X-Gm-Message-State: AOJu0YzkY/hz3O2Dy4+JvQY0t1qTXXC/evWEsdrffCEcSiehJFOlBl5x aTblT1qVoB0fF9a+1u9bAsyrUwgcinBcSsDCdYLm45F5TeDh6THM/yhe12wJXas= X-Google-Smtp-Source: AGHT+IEOHJWbr4sYmBS3OLvdYCOBsnXHukwMDvko9GGwxhx1ScYJzU9mWVIb+ZQ08hwSi0U63OuX1g== X-Received: by 2002:a17:907:f7a4:b0:a8d:2359:3160 with SMTP id a640c23a62f3a-a90294b60ffmr2146813566b.38.1726751104535; Thu, 19 Sep 2024 06:05:04 -0700 (PDT) Received: from localhost.localdomain ([188.27.132.130]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90cbc7122esm53213166b.124.2024.09.19.06.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 06:05:04 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: jic23@kernel.org, krzk+dt@kernel.org, robh@kernel.org, lars@metafoo.de, michael.hennerich@analog.com, gstols@baylibre.com, dlechner@baylibre.com, Alexandru Ardelean Subject: [PATCH v7 8/8] iio: adc: ad7606: add support for AD7606C-{16,18} parts Date: Thu, 19 Sep 2024 16:04:43 +0300 Message-ID: <20240919130444.2100447-9-aardelean@baylibre.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919130444.2100447-1-aardelean@baylibre.com> References: <20240919130444.2100447-1-aardelean@baylibre.com> 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 The AD7606C-16 and AD7606C-18 are pretty similar with the AD7606B. The main difference between AD7606C-16 & AD7606C-18 is the precision in bits (16 vs 18). Because of that, some scales need to be defined for the 18-bit variants, as they need to be computed against 2**18 (vs 2**16 for the 16 bit-variants). Because the AD7606C-16,18 also supports bipolar & differential channels, for SW-mode, the default range of 10 V or =C2=B110V should be set at probe. On reset, the default range (in the registers) is set to value 0x3 which corresponds to '=C2=B110 V single-ended range', regardless of bipolar or differential configuration. Aside from the scale/ranges, the AD7606C-16 is similar to the AD7606B. The AD7606C-18 variant offers 18-bit precision. Because of this, the requirement to use this chip is that the SPI controller supports padding of 18-bit sequences to 32-bit arrays. Datasheet: https://www.analog.com/media/en/technical-documentation/data-she= ets/ad7606c-16.pdf Datasheet: https://www.analog.com/media/en/technical-documentation/data-she= ets/ad7606c-18.pdf Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/ad7606.c | 263 +++++++++++++++++++++++++++++++++-- drivers/iio/adc/ad7606.h | 16 ++- drivers/iio/adc/ad7606_spi.c | 55 ++++++++ 3 files changed, 322 insertions(+), 12 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index b909ee14fd81..f04e5660d2f8 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -36,6 +36,33 @@ static const unsigned int ad7606_16bit_hw_scale_avail[2]= =3D { 152588, 305176 }; =20 +static const unsigned int ad7606_18bit_hw_scale_avail[2] =3D { + 38147, 76294 +}; + +static const unsigned int ad7606c_16bit_single_ended_unipolar_scale_avail[= 3] =3D { + 76294, 152588, 190735, +}; + +static const unsigned int ad7606c_16bit_single_ended_bipolar_scale_avail[5= ] =3D { + 76294, 152588, 190735, 305176, 381470 +}; + +static const unsigned int ad7606c_16bit_differential_bipolar_scale_avail[4= ] =3D { + 152588, 305176, 381470, 610352 +}; + +static const unsigned int ad7606c_18bit_single_ended_unipolar_scale_avail[= 3] =3D { + 19073, 38147, 47684 +}; + +static const unsigned int ad7606c_18bit_single_ended_bipolar_scale_avail[5= ] =3D { + 19073, 38147, 47684, 76294, 95367 +}; + +static const unsigned int ad7606c_18bit_differential_bipolar_scale_avail[4= ] =3D { + 38147, 76294, 95367, 152588 +}; =20 static const unsigned int ad7606_16bit_sw_scale_avail[3] =3D { 76293, 152588, 305176 @@ -62,7 +89,8 @@ int ad7606_reset(struct ad7606_state *st) } EXPORT_SYMBOL_NS_GPL(ad7606_reset, IIO_AD7606); =20 -static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st, int ch) +static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st, + struct iio_chan_spec *chan, int ch) { struct ad7606_chan_scale *cs =3D &st->chan_scales[ch]; =20 @@ -83,6 +111,173 @@ static int ad7606_16bit_chan_scale_setup(struct ad7606= _state *st, int ch) return 0; } =20 +static int ad7606_get_chan_config(struct ad7606_state *st, int ch, + bool *bipolar, bool *differential) +{ + unsigned int num_channels =3D st->chip_info->num_channels - 1; + struct device *dev =3D st->dev; + int ret; + + *bipolar =3D false; + *differential =3D false; + + device_for_each_child_node_scoped(dev, child) { + u32 pins[2]; + int reg; + + ret =3D fwnode_property_read_u32(child, "reg", ®); + if (ret) + continue; + + /* channel number (here) is from 1 to num_channels */ + if (reg =3D=3D 0 || reg > num_channels) { + dev_warn(dev, + "Invalid channel number (ignoring): %d\n", reg); + continue; + } + + if (reg !=3D (ch + 1)) + continue; + + *bipolar =3D fwnode_property_read_bool(child, "bipolar"); + + ret =3D fwnode_property_read_u32_array(child, "diff-channels", + pins, ARRAY_SIZE(pins)); + /* Channel is differential, if pins are the same as 'reg' */ + if (ret =3D=3D 0 && (pins[0] !=3D reg || pins[1] !=3D reg)) { + dev_err(dev, + "Differential pins must be the same as 'reg'"); + return -EINVAL; + } + + *differential =3D (ret =3D=3D 0); + + if (*differential && !*bipolar) { + dev_err(dev, + "'bipolar' must be added for diff channel %d\n", + reg); + return -EINVAL; + } + + return 0; + } + + return 0; +} + +static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st, + struct iio_chan_spec *chan, int ch) +{ + struct ad7606_chan_scale *cs =3D &st->chan_scales[ch]; + bool bipolar, differential; + int ret; + + if (!st->sw_mode_en) { + cs->range =3D 0; + cs->scale_avail =3D ad7606_18bit_hw_scale_avail; + cs->num_scales =3D ARRAY_SIZE(ad7606_18bit_hw_scale_avail); + return 0; + } + + ret =3D ad7606_get_chan_config(st, ch, &bipolar, &differential); + if (ret) + return ret; + + if (differential) { + cs->scale_avail =3D ad7606c_18bit_differential_bipolar_scale_avail; + cs->num_scales =3D + ARRAY_SIZE(ad7606c_18bit_differential_bipolar_scale_avail); + /* Bipolar differential ranges start at 8 (b1000) */ + cs->reg_offset =3D 8; + cs->range =3D 1; + chan->differential =3D 1; + chan->channel2 =3D chan->channel; + + return 0; + } + + chan->differential =3D 0; + + if (bipolar) { + cs->scale_avail =3D ad7606c_18bit_single_ended_bipolar_scale_avail; + cs->num_scales =3D + ARRAY_SIZE(ad7606c_18bit_single_ended_bipolar_scale_avail); + /* Bipolar single-ended ranges start at 0 (b0000) */ + cs->reg_offset =3D 0; + cs->range =3D 3; + chan->scan_type.sign =3D 's'; + + return 0; + } + + cs->scale_avail =3D ad7606c_18bit_single_ended_unipolar_scale_avail; + cs->num_scales =3D + ARRAY_SIZE(ad7606c_18bit_single_ended_unipolar_scale_avail); + /* Unipolar single-ended ranges start at 5 (b0101) */ + cs->reg_offset =3D 5; + cs->range =3D 1; + chan->scan_type.sign =3D 'u'; + + return 0; +} + +static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st, + struct iio_chan_spec *chan, int ch) +{ + struct ad7606_chan_scale *cs =3D &st->chan_scales[ch]; + bool bipolar, differential; + int ret; + + if (!st->sw_mode_en) { + cs->range =3D 0; + cs->scale_avail =3D ad7606_16bit_hw_scale_avail; + cs->num_scales =3D ARRAY_SIZE(ad7606_16bit_hw_scale_avail); + return 0; + } + + ret =3D ad7606_get_chan_config(st, ch, &bipolar, &differential); + if (ret) + return ret; + + if (differential) { + cs->scale_avail =3D ad7606c_16bit_differential_bipolar_scale_avail; + cs->num_scales =3D + ARRAY_SIZE(ad7606c_16bit_differential_bipolar_scale_avail); + /* Bipolar differential ranges start at 8 (b1000) */ + cs->reg_offset =3D 8; + cs->range =3D 1; + chan->differential =3D 1; + chan->channel2 =3D chan->channel; + chan->scan_type.sign =3D 's'; + + return 0; + } + + chan->differential =3D 0; + + if (bipolar) { + cs->scale_avail =3D ad7606c_16bit_single_ended_bipolar_scale_avail; + cs->num_scales =3D + ARRAY_SIZE(ad7606c_16bit_single_ended_bipolar_scale_avail); + /* Bipolar single-ended ranges start at 0 (b0000) */ + cs->reg_offset =3D 0; + cs->range =3D 3; + chan->scan_type.sign =3D 's'; + + return 0; + } + + cs->scale_avail =3D ad7606c_16bit_single_ended_unipolar_scale_avail; + cs->num_scales =3D + ARRAY_SIZE(ad7606c_16bit_single_ended_unipolar_scale_avail); + /* Unipolar single-ended ranges start at 5 (b0101) */ + cs->reg_offset =3D 5; + cs->range =3D 1; + chan->scan_type.sign =3D 'u'; + + return 0; +} + static int ad7606_reg_access(struct iio_dev *indio_dev, unsigned int reg, unsigned int writeval, @@ -107,9 +302,8 @@ static int ad7606_reg_access(struct iio_dev *indio_dev, static int ad7606_read_samples(struct ad7606_state *st) { unsigned int num =3D st->chip_info->num_channels - 1; - u16 *data =3D st->data; =20 - return st->bops->read_block(st->dev, num, data); + return st->bops->read_block(st->dev, num, &st->data); } =20 static irqreturn_t ad7606_trigger_handler(int irq, void *p) @@ -125,7 +319,7 @@ static irqreturn_t ad7606_trigger_handler(int irq, void= *p) if (ret) goto error_ret; =20 - iio_push_to_buffers_with_timestamp(indio_dev, st->data, + iio_push_to_buffers_with_timestamp(indio_dev, &st->data, iio_get_time_ns(indio_dev)); error_ret: iio_trigger_notify_done(indio_dev->trig); @@ -139,6 +333,8 @@ static int ad7606_scan_direct(struct iio_dev *indio_dev= , unsigned int ch, int *val) { struct ad7606_state *st =3D iio_priv(indio_dev); + unsigned int storagebits =3D st->chip_info->channels[1].scan_type.storage= bits; + const struct iio_chan_spec *chan; int ret; =20 gpiod_set_value(st->gpio_convst, 1); @@ -153,7 +349,19 @@ static int ad7606_scan_direct(struct iio_dev *indio_de= v, unsigned int ch, if (ret) goto error_ret; =20 - *val =3D sign_extend32(st->data[ch], 15); + chan =3D &indio_dev->channels[ch + 1]; + if (chan->scan_type.sign =3D=3D 'u') { + if (storagebits > 16) + *val =3D st->data.buf32[ch]; + else + *val =3D st->data.buf16[ch]; + return 0; + } + + if (storagebits > 16) + *val =3D sign_extend32(st->data.buf32[ch], 17); + else + *val =3D sign_extend32(st->data.buf16[ch], 15); =20 error_ret: gpiod_set_value(st->gpio_convst, 0); @@ -266,7 +474,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, ch =3D chan->address; cs =3D &st->chan_scales[ch]; i =3D find_closest(val2, cs->scale_avail, cs->num_scales); - ret =3D st->write_scale(indio_dev, ch, i); + ret =3D st->write_scale(indio_dev, ch, i + cs->reg_offset); if (ret < 0) return ret; cs->range =3D i; @@ -349,6 +557,18 @@ static const struct iio_chan_spec ad7606_channels_16bi= t[] =3D { AD7606_CHANNEL(7, 16), }; =20 +static const struct iio_chan_spec ad7606_channels_18bit[] =3D { + IIO_CHAN_SOFT_TIMESTAMP(8), + AD7606_CHANNEL(0, 18), + AD7606_CHANNEL(1, 18), + AD7606_CHANNEL(2, 18), + AD7606_CHANNEL(3, 18), + AD7606_CHANNEL(4, 18), + AD7606_CHANNEL(5, 18), + AD7606_CHANNEL(6, 18), + AD7606_CHANNEL(7, 18), +}; + /* * The current assumption that this driver makes for AD7616, is that it's * working in Hardware Mode with Serial, Burst and Sequencer modes activat= ed. @@ -414,6 +634,20 @@ static const struct ad7606_chip_info ad7606_chip_info_= tbl[] =3D { .oversampling_avail =3D ad7606_oversampling_avail, .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), }, + [ID_AD7606C_16] =3D { + .channels =3D ad7606_channels_16bit, + .num_channels =3D 9, + .scale_setup_cb =3D ad7606c_16bit_chan_scale_setup, + .oversampling_avail =3D ad7606_oversampling_avail, + .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), + }, + [ID_AD7606C_18] =3D { + .channels =3D ad7606_channels_18bit, + .num_channels =3D 9, + .scale_setup_cb =3D ad7606c_18bit_chan_scale_setup, + .oversampling_avail =3D ad7606_oversampling_avail, + .oversampling_num =3D ARRAY_SIZE(ad7606_oversampling_avail), + }, [ID_AD7616] =3D { .channels =3D ad7616_channels, .num_channels =3D 17, @@ -586,7 +820,7 @@ static const struct iio_trigger_ops ad7606_trigger_ops = =3D { .validate_device =3D iio_trigger_validate_own_device, }; =20 -static int ad7606_sw_mode_setup(struct iio_dev *indio_dev) +static int ad7606_sw_mode_setup(struct iio_dev *indio_dev, unsigned int id) { struct ad7606_state *st =3D iio_priv(indio_dev); =20 @@ -604,13 +838,24 @@ static int ad7606_chan_scales_setup(struct iio_dev *i= ndio_dev) { unsigned int num_channels =3D indio_dev->num_channels - 1; struct ad7606_state *st =3D iio_priv(indio_dev); + struct iio_chan_spec *chans; + size_t size; int ch, ret; =20 + /* Clone IIO channels, since some may be differential */ + size =3D indio_dev->num_channels * sizeof(*indio_dev->channels); + chans =3D devm_kzalloc(st->dev, size, GFP_KERNEL); + if (!chans) + return -ENOMEM; + + memcpy(chans, indio_dev->channels, size); + indio_dev->channels =3D chans; + for (ch =3D 0; ch < num_channels; ch++) { struct ad7606_chan_scale *cs; int i; =20 - ret =3D st->chip_info->scale_setup_cb(st, ch); + ret =3D st->chip_info->scale_setup_cb(st, &chans[ch + 1], ch); if (ret) return ret; =20 @@ -698,7 +943,7 @@ int ad7606_probe(struct device *dev, int irq, void __io= mem *base_address, st->write_scale =3D ad7606_write_scale_hw; st->write_os =3D ad7606_write_os_hw; =20 - ret =3D ad7606_sw_mode_setup(indio_dev); + ret =3D ad7606_sw_mode_setup(indio_dev, id); if (ret) return ret; =20 diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index 25e84efd15c3..14ee75aa225b 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -63,7 +63,8 @@ =20 struct ad7606_state; =20 -typedef int (*ad7606_scale_setup_cb_t)(struct ad7606_state *st, int ch); +typedef int (*ad7606_scale_setup_cb_t)(struct ad7606_state *st, + struct iio_chan_spec *chan, int ch); =20 /** * struct ad7606_chip_info - chip specific information @@ -94,6 +95,8 @@ struct ad7606_chip_info { * such that it can be read via the 'read_avail' hook * @num_scales number of elements stored in the scale_avail array * @range voltage range selection, selects which scale to apply + * @reg_offset offset for the register value, to be applied when + * writing the value of 'range' to the register value */ struct ad7606_chan_scale { #define AD760X_MAX_SCALES 16 @@ -102,6 +105,7 @@ struct ad7606_chan_scale { int scale_avail_show[AD760X_MAX_SCALE_SHOW]; unsigned int num_scales; unsigned int range; + unsigned int reg_offset; }; =20 /** @@ -158,9 +162,13 @@ struct ad7606_state { /* * DMA (thus cache coherency maintenance) may require the * transfer buffers to live in their own cache lines. - * 16 * 16-bit samples + 64-bit timestamp + * 16 * 16-bit samples + 64-bit timestamp - for AD7616 + * 8 * 32-bit samples + 64-bit timestamp - for AD7616C-18 (and similar) */ - unsigned short data[20] __aligned(IIO_DMA_MINALIGN); + union { + u16 buf16[20]; + u32 buf32[10]; + } data __aligned(IIO_DMA_MINALIGN); __be16 d16[2]; }; =20 @@ -201,6 +209,8 @@ enum ad7606_supported_device_ids { ID_AD7606_6, ID_AD7606_4, ID_AD7606B, + ID_AD7606C_16, + ID_AD7606C_18, ID_AD7616, }; =20 diff --git a/drivers/iio/adc/ad7606_spi.c b/drivers/iio/adc/ad7606_spi.c index e00f58a6a0e9..143440e73aab 100644 --- a/drivers/iio/adc/ad7606_spi.c +++ b/drivers/iio/adc/ad7606_spi.c @@ -77,6 +77,18 @@ static const struct iio_chan_spec ad7606b_sw_channels[] = =3D { AD7606_SW_CHANNEL(7, 16), }; =20 +static const struct iio_chan_spec ad7606c_18_sw_channels[] =3D { + IIO_CHAN_SOFT_TIMESTAMP(8), + AD7606_SW_CHANNEL(0, 18), + AD7606_SW_CHANNEL(1, 18), + AD7606_SW_CHANNEL(2, 18), + AD7606_SW_CHANNEL(3, 18), + AD7606_SW_CHANNEL(4, 18), + AD7606_SW_CHANNEL(5, 18), + AD7606_SW_CHANNEL(6, 18), + AD7606_SW_CHANNEL(7, 18), +}; + static const unsigned int ad7606B_oversampling_avail[9] =3D { 1, 2, 4, 8, 16, 32, 64, 128, 256 }; @@ -120,6 +132,19 @@ static int ad7606_spi_read_block(struct device *dev, return 0; } =20 +static int ad7606_spi_read_block18to32(struct device *dev, + int count, void *buf) +{ + struct spi_device *spi =3D to_spi_device(dev); + struct spi_transfer xfer =3D { + .bits_per_word =3D 18, + .len =3D count * sizeof(u32), + .rx_buf =3D buf, + }; + + return spi_sync_transfer(spi, &xfer, 1); +} + static int ad7606_spi_reg_read(struct ad7606_state *st, unsigned int addr) { struct spi_device *spi =3D to_spi_device(st->dev); @@ -283,6 +308,19 @@ static int ad7606B_sw_mode_config(struct iio_dev *indi= o_dev) return 0; } =20 +static int ad7606c_18_sw_mode_config(struct iio_dev *indio_dev) +{ + int ret; + + ret =3D ad7606B_sw_mode_config(indio_dev); + if (ret) + return ret; + + indio_dev->channels =3D ad7606c_18_sw_channels; + + return 0; +} + static const struct ad7606_bus_ops ad7606_spi_bops =3D { .read_block =3D ad7606_spi_read_block, }; @@ -305,6 +343,15 @@ static const struct ad7606_bus_ops ad7606B_spi_bops = =3D { .sw_mode_config =3D ad7606B_sw_mode_config, }; =20 +static const struct ad7606_bus_ops ad7606c_18_spi_bops =3D { + .read_block =3D ad7606_spi_read_block18to32, + .reg_read =3D ad7606_spi_reg_read, + .reg_write =3D ad7606_spi_reg_write, + .write_mask =3D ad7606_spi_write_mask, + .rd_wr_cmd =3D ad7606B_spi_rd_wr_cmd, + .sw_mode_config =3D ad7606c_18_sw_mode_config, +}; + static int ad7606_spi_probe(struct spi_device *spi) { const struct spi_device_id *id =3D spi_get_device_id(spi); @@ -315,8 +362,12 @@ static int ad7606_spi_probe(struct spi_device *spi) bops =3D &ad7616_spi_bops; break; case ID_AD7606B: + case ID_AD7606C_16: bops =3D &ad7606B_spi_bops; break; + case ID_AD7606C_18: + bops =3D &ad7606c_18_spi_bops; + break; default: bops =3D &ad7606_spi_bops; break; @@ -333,6 +384,8 @@ static const struct spi_device_id ad7606_id_table[] =3D= { { "ad7606-6", ID_AD7606_6 }, { "ad7606-8", ID_AD7606_8 }, { "ad7606b", ID_AD7606B }, + { "ad7606c-16", ID_AD7606C_16 }, + { "ad7606c-18", ID_AD7606C_18 }, { "ad7616", ID_AD7616 }, { } }; @@ -344,6 +397,8 @@ static const struct of_device_id ad7606_of_match[] =3D { { .compatible =3D "adi,ad7606-6" }, { .compatible =3D "adi,ad7606-8" }, { .compatible =3D "adi,ad7606b" }, + { .compatible =3D "adi,ad7606c-16" }, + { .compatible =3D "adi,ad7606c-18" }, { .compatible =3D "adi,ad7616" }, { } }; --=20 2.46.0