From nobody Sat Nov 30 02:29:39 2024 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B2DE1DCB31 for ; Fri, 13 Sep 2024 13:57:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726235875; cv=none; b=TMV9mzVP5kC8z97V1q3QM7elHa220dJwpMYPdat/3xfmYgNTo+LAM/6cm0L01Q0uyFD+WZIwp8sIq917wBMA2c33IBcI3X1i4jMy94Hvj96oH23SI2gDPKplUB591SfOTmsxA23vYBuruwmbOfAChFiOnG44GwEP8UrLuvc9KN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726235875; c=relaxed/simple; bh=7jeDEErQ+xBSjvZ9RT/TEcexKXO8icQCIcZ4pRA2dbs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZON5gPp9Goj5Ecgf/JfP1nHG2IMgQZYvMIcF34TgAWcO5J7YL30BXmiqGlZuMnwbNspTa45HZ8exvqMAG2hxSQP74Lp2JH0Ka3l2EVEV8lCu+6lgTAPN4IJ9QjZTGD4k79R6nuIxtbLGiyBTDAZwiWaoE553Id/+NEPqpRXunXE= 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=f7vffjNL; arc=none smtp.client-ip=209.85.221.49 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="f7vffjNL" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-371ba7e46easo1659420f8f.0 for ; Fri, 13 Sep 2024 06:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1726235872; x=1726840672; 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=f7vffjNLa2Uo8BHFJIkEb2c7KUVA3dEVwf4KVDYJRFkYNMJUGaeiZnUREap003S08A uA2Wmmec3HhQuQtEdOZbmwJmUrmMQbM7XFKlxfAjBiJnKusGgqc/IjYB0H68HrMZyTd5 sMUIzdApqXaQwtsiPxW+zFKpQJ14SmmsJaVGYOmO9UDPaIn7N4vhPpkEgUVRrBEkbsS1 G0XVbW373kX/v/FASKlRqa2+kE9CxG13mBqwNEWZb9Z2SuvmHF69rjsCJY+kete7O6d2 bdWNLab+cAAW8SU4H4Gmux/i0EnmxRmqqNlJ2xuKeiirEs8Y67lC9plBp3HEg1DfXgsU F6mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726235872; x=1726840672; 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=YqcrYo/8BiRiqGW8PzO1OilNCVWaf4VpBwrp5WafK83Vz2l6G9AQ55qpK7LLNWFmgX MyA6/tE6lt0M2rLY49p/3DN+vUqb7ZhPXONX7+OFSwz0j+VvREk7IUhuZyW932bwrXqd YOfP5S6gXJEjgBUpFhOb9KoNQpgjvlayScCdiq+gS+Ertknk029BeKE2NFgDddFgao5g Spl+Ri3NleVxZZEyCPv8ZBNulBWOKXjE4ubWYggcNlL2TtE1ypQ/Q+3qSzxd3ayikBB0 H/0TMX2v9iKS8lFpZnNc2I+pEIx3Hz6xLv1J4hUPd3S6Iswl3RaCac5tLQ6vvUXLUvmp VtNQ== X-Forwarded-Encrypted: i=1; AJvYcCX2Ep/0Kl1tFauNHWrv8atjczFOLAfEM7HsITu9Joh2wtNBTar0uIorsSR9yKn14xlQKJHitXpnAWOebo8=@vger.kernel.org X-Gm-Message-State: AOJu0YwJpq14JeFvENeo3WrkWeik9wa2ChuPIXuP78jiSJKgPgor++Jr Eo/2eL8wkhdm/PlieI2JQ+B+MQ6AYfVEOkt0vMy0gT1WarJggfOOYVWmF/rRcJA= X-Google-Smtp-Source: AGHT+IG+OkIQ2PfAitpwrJHTaZB7u3SC6rFQQVsxZbK+lEsxaD5mTd98pNcYiRYKHuMBt7oR57Iznw== X-Received: by 2002:adf:a3d0:0:b0:368:64e:a7dd with SMTP id ffacd0b85a97d-378c2d55661mr3394962f8f.53.1726235870736; Fri, 13 Sep 2024 06:57:50 -0700 (PDT) Received: from neptune.lan ([188.27.129.88]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956d3941sm17104749f8f.84.2024.09.13.06.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 06:57: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 v6 1/8] iio: adc: ad7606: add 'bits' parameter to channels macros Date: Fri, 13 Sep 2024 16:57:36 +0300 Message-ID: <20240913135744.152669-2-aardelean@baylibre.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240913135744.152669-1-aardelean@baylibre.com> References: <20240913135744.152669-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 --- 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