Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp327495lqo; Wed, 15 May 2024 16:27:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3XIz/Ww5lDzW+/bZdQXe6WTsfpCFelK+K9+zILQuWIsKULPxftcuZStehYvK/rTulFCRKEu1HPVsuE3zmAaWyBVOeSoPFNti4r9mDpw== X-Google-Smtp-Source: AGHT+IH4tK7JTCS0jz8k5F1UGkKoRgVkVpawI2eYNO3xCe96gFVQvBOOCeEAm0pI5xlJaOhRUtrX X-Received: by 2002:a05:6214:5d8d:b0:6a1:19c6:2591 with SMTP id 6a1803df08f44-6a168140c87mr213246436d6.4.1715815677646; Wed, 15 May 2024 16:27:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715815677; cv=pass; d=google.com; s=arc-20160816; b=u134cVbGdgj9B80Qs38LGwn2sp2LaUyUl98cbkET7Q4X53OSRnUlMlq9m08hrAi5L+ wUHlAOtplzctN77Ww6vq52HfD95WyUHfhPd2uGDUxdLLjd/OEEIJao6144qe3OFaX4EA uPeZ+2j/3CI8ylegT0SOQ0bRnp+9Vxtyseh68I5IGdHdMNAg/W9M4kXMeS0toSoTy0v2 JSJbka60RJe1+FryBePdBfa1LDSaGzyzaDbewmFNMD3Vw2Njc2HlDe6UOBHVM2YbptjO jCKlWT/mRomWih44PzoLBVptDlSpPG+5TDWqxYpkBGw/pQ/kqEJjhwmBdbS8HXuZe2En D2sg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=iRsDSovNQ6qr5UiueXhcNuD8AQiDxUzPcRjU5GwfeDI=; fh=4v3JPy9oKXJSfl7/8+2/6nL1GjYgvnWEJ0NROGF7y9g=; b=v4nXFcB6sLtI4fB7nQgqaDJ4GGt7Do2Rnjye8wA0MloB55zTdletPGh6uyNuY3G33V uDzO1005UKblJzZ3FL4JikvcDtIuJWNbc3a4FQ/Gyx44FUkuc2Yo0PSCQS4Gb3y6zVeA QrBOUcsF+lmaFPOBYv0vpbmp1phPKaswJ14Nd6nTqZdxc3rlaIg9mY2GB0bkMTyTEOJi L2zp0+EAMQSWXJSIt+B7QIXe2P9gdrvLiOHaatzwe3+AHbmJml3GhV/tVRZBz6q1imrN ZHmrzRFi2HNOilPGrSBWCRp7AzlObgAUTJEk3yIyEaxB+tpavJRu7XAvQ3LdHHIRK485 xlmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ijm3BpHA; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-180486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180486-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f2b749dsi154643756d6.406.2024.05.15.16.27.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 16:27:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ijm3BpHA; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-180486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180486-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 53E7D1C213A0 for ; Wed, 15 May 2024 23:27:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 236CF5025A; Wed, 15 May 2024 23:27:50 +0000 (UTC) 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="ijm3BpHA" Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 E03C439FEC for ; Wed, 15 May 2024 23:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715815669; cv=none; b=gBQ7EKCaFgOqJstIsIYyRkyOwV7nomP1qPsM32GUfHptdtwm0uhudiobe5c5DxIStgTY9nfReRKOc+cSTBex1vJsZ5oXhThaiTzitrZNTDlQhsU1tEAeVX772pd93WF1iwD5Gqmm7ZOmk2a5pfOHAeTbVFvxKiebRymWIPli6VI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715815669; c=relaxed/simple; bh=jMCf65n6mZ9Lh1wcVdqz3IcOWbhY/JMPATbvY5TnZNg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=aPX08TNQR9kaoBxbmfpgm4XeDgm+fLq9mwVsYQ5g6G6XjC1AQnoMt+iRCc/LuX432tp5IuQVTWKAHzRab2m6H80NeTIhZoLQMXQdeGZ13PauKjfCVU47qDCvO9oUYYL+r1pYgEL7FbDym97w7mnBd+dP4a0Vkeb+fm5+MDNVmkQ= 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=ijm3BpHA; arc=none smtp.client-ip=209.85.208.173 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 Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2e3efa18e6aso1177281fa.0 for ; Wed, 15 May 2024 16:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715815664; x=1716420464; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iRsDSovNQ6qr5UiueXhcNuD8AQiDxUzPcRjU5GwfeDI=; b=ijm3BpHAjO5ZRm8qK936yBfaORsehiXAqIXb2P0ev4jPI+ixOpffPwqdUL0aMNbPHG p8ft2whMHgKbbJveSWTcrIgyxIhNdTNk9HIM3gXk1EAZOi0WEdoijrHuVH6Jw4GAKDYB TTaaTZahOTQ3pfTiB+BNiyut1SUeNPed0JYWTY7KHEQ5CLRtQ6OykERGgA9OSMKBT7MM fgFx8nYAKp746BkpImgIk3i3Euxa9koYkAA5Ap64ra0K1aOeM6Zbcu6+53ZHIPFBbfFE ZH8yFpgbjIIL14Pao4Jg2uGBWdMGgPb7M95RaCZVWc5gedYh6DsFWpYPK9wa2b1YYcNl 1HXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715815664; x=1716420464; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iRsDSovNQ6qr5UiueXhcNuD8AQiDxUzPcRjU5GwfeDI=; b=quX6zmeBpSJkmJ18fT/3GFr4ILd64MoCTz15xgVd4H4HIYk1sYfWiifMkqRTJxYRDj OoXmxjQ8LECpswFoHHoASqkaO5wYqdSTPZTNZEo8PWUYe3NWTW3WmalhfXB439rLVlLr mm25o61RtJYS1a8SyaAsKu/3B9IpnquUpd/Pq/6S9BK7x7MofAgi8jRkDaOF+cV9ZTb0 6NnIWTHj5QOtTsMvyRRgY53D6OghGSSPIjAKbwZ2Nob3Kg+97O4wnM6ndppRUr7wc4JI FyHr2f1YkhStIUd0CgQ7e5PnHCtYfmRXRblaAme86rPsIENQiwMNZLyvs3SrcR227kqZ nSLg== X-Forwarded-Encrypted: i=1; AJvYcCULxLoG3Ul5Tt76cBYIJe3JymKbZR73DeUNZcAeQnBYyBzN6KMOitJGL2uXRMxaHnthFJv57IRCTVdfLF2wJrK2DDs3YHiH5XVRNbRA X-Gm-Message-State: AOJu0Yy4J/TFQqQ92buGo7n/ys43w1S+mri+zj5P+jldu4AUKjs6m6E8 i8PePalYFHYYr9xrR1ltA3ykk8pWjCB15yndw8zPQZSXqoNbwqDG3qhVsxXJt38Vcn1cykmcEzw QRtItdV83Gqjie1d3QLKAPoRU/12V8OUuuW35w0QoWrwahQlcumovTw== X-Received: by 2002:a2e:1319:0:b0:2d8:4892:bee2 with SMTP id 38308e7fff4ca-2e51b17f931mr63457721fa.20.1715815664025; Wed, 15 May 2024 16:27:44 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240514-ad4111-v2-0-29be6a55efb5@analog.com> <20240514-ad4111-v2-5-29be6a55efb5@analog.com> In-Reply-To: <20240514-ad4111-v2-5-29be6a55efb5@analog.com> From: David Lechner Date: Wed, 15 May 2024 18:27:32 -0500 Message-ID: Subject: Re: [PATCH v2 5/9] iio: adc: ad7173: add support for special inputs To: dumitru.ceclan@analog.com Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Dumitru Ceclan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 14, 2024 at 2:23=E2=80=AFAM Dumitru Ceclan via B4 Relay wrote: > > From: Dumitru Ceclan > > Add support for selecting REF+ and REF- inputs on all models. > Add support for selecting ((AVDD1 =E2=88=92 AVSS)/5) inputs > on supported models. > > Signed-off-by: Dumitru Ceclan > --- > drivers/iio/adc/ad7173.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c > index fb33534d63a9..1e9ba3070770 100644 > --- a/drivers/iio/adc/ad7173.c > +++ b/drivers/iio/adc/ad7173.c > @@ -65,6 +65,10 @@ > FIELD_PREP(AD7173_CH_SETUP_AINNEG_MASK, neg)) > #define AD7173_AIN_TEMP_POS 17 > #define AD7173_AIN_TEMP_NEG 18 > +#define AD7173_AIN_COM_IN_POS 19 > +#define AD7173_AIN_COM_IN_NEG 20 > +#define AD7173_AIN_REF_POS 21 > +#define AD7173_AIN_REF_NEG 22 > > #define AD7172_2_ID 0x00d0 > #define AD7175_ID 0x0cd0 > @@ -145,6 +149,8 @@ struct ad7173_device_info { > unsigned int id; > char *name; > bool has_temp; > + /* ((AVDD1 =E2=88=92 AVSS)/5) */ > + bool has_common_input; > bool has_input_buf; > bool has_int_ref; > bool has_ref2; > @@ -215,6 +221,7 @@ static const struct ad7173_device_info ad7173_device_= info[] =3D { > .has_temp =3D true, > .has_input_buf =3D true, > .has_int_ref =3D true, > + .has_common_input =3D true, > .clock =3D 2 * HZ_PER_MHZ, > .sinc5_data_rates =3D ad7173_sinc5_data_rates, > .num_sinc5_data_rates =3D ARRAY_SIZE(ad7173_sinc5_data_ra= tes), > @@ -228,6 +235,7 @@ static const struct ad7173_device_info ad7173_device_= info[] =3D { > .has_temp =3D false, > .has_input_buf =3D true, > .has_ref2 =3D true, > + .has_common_input =3D true, > .clock =3D 2 * HZ_PER_MHZ, > .sinc5_data_rates =3D ad7173_sinc5_data_rates, > .num_sinc5_data_rates =3D ARRAY_SIZE(ad7173_sinc5_data_ra= tes), > @@ -243,6 +251,7 @@ static const struct ad7173_device_info ad7173_device_= info[] =3D { > .has_input_buf =3D true, > .has_int_ref =3D true, > .has_ref2 =3D true, > + .has_common_input =3D false, > .clock =3D 2 * HZ_PER_MHZ, > .sinc5_data_rates =3D ad7173_sinc5_data_rates, > .num_sinc5_data_rates =3D ARRAY_SIZE(ad7173_sinc5_data_ra= tes), > @@ -257,6 +266,7 @@ static const struct ad7173_device_info ad7173_device_= info[] =3D { > .has_temp =3D true, > .has_input_buf =3D true, > .has_int_ref =3D true, > + .has_common_input =3D true, > .clock =3D 16 * HZ_PER_MHZ, > .sinc5_data_rates =3D ad7175_sinc5_data_rates, > .num_sinc5_data_rates =3D ARRAY_SIZE(ad7175_sinc5_data_ra= tes), > @@ -271,6 +281,7 @@ static const struct ad7173_device_info ad7173_device_= info[] =3D { > .has_input_buf =3D true, > .has_int_ref =3D true, > .has_ref2 =3D true, > + .has_common_input =3D true, > .clock =3D 16 * HZ_PER_MHZ, > .sinc5_data_rates =3D ad7175_sinc5_data_rates, > .num_sinc5_data_rates =3D ARRAY_SIZE(ad7175_sinc5_data_ra= tes), > @@ -285,6 +296,7 @@ static const struct ad7173_device_info ad7173_device_= info[] =3D { > .has_temp =3D false, > .has_input_buf =3D false, > .has_int_ref =3D true, > + .has_common_input =3D false, > .clock =3D 16 * HZ_PER_MHZ, > .sinc5_data_rates =3D ad7175_sinc5_data_rates, > .num_sinc5_data_rates =3D ARRAY_SIZE(ad7175_sinc5_data_ra= tes), > @@ -298,6 +310,7 @@ static const struct ad7173_device_info ad7173_device_= info[] =3D { > .has_temp =3D true, > .has_input_buf =3D true, > .has_int_ref =3D true, > + .has_common_input =3D true, > .clock =3D 16 * HZ_PER_MHZ, > .odr_start_value =3D AD7177_ODR_START_VALUE, > .sinc5_data_rates =3D ad7175_sinc5_data_rates, > @@ -920,6 +933,14 @@ static int ad7173_validate_voltage_ain_inputs(struct= ad7173_state *st, > if (ain[i] < st->info->num_inputs) > continue; > > + if (ain[i] =3D=3D AD7173_AIN_REF_POS || ain[i] =3D=3D AD7= 173_AIN_REF_NEG) > + continue; > + > + if ((ain[i] =3D=3D AD7173_AIN_COM_IN_POS || > + ain[i] =3D=3D AD7173_AIN_COM_IN_NEG) && > + st->info->has_common_input) > + continue; > + If there is only one valid combination, it seems like these should be fixed channels like the temperature input rather than something coming from the device tree. It looks like on AD411x, it is the case that there is only one valid option for the reference input in the channel configuration. But in the case of AD717x since both REF+ and REF- are listed as possible inputs for both AINPOS0 and AINNEG0, it seems like they could be mixed and matched with other channels. The datasheet doesn't seem very clear on this though. If it is valid to combine, say AIN0 with REF+ though, then the validation would need to be relaxed. But I'm guessing that is not actually the case? > return dev_err_probe(dev, -EINVAL, > "Input pin number out of range for pair (%d %d).\= n", > ain[0], ain[1]); > > -- > 2.43.0 > >