Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp388001lqo; Thu, 16 May 2024 09:03:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmujHcyGvcC2rtWi0sQ+0puLJ5RcWxQo302KYb9fGan5zaRj4KAw0Pjo6yQqRohx1SV/5mBmtvH1PxCljjSmxOhp0UBhZEyHdGkWopEA== X-Google-Smtp-Source: AGHT+IEg8Bkw6ACWQ546iN7zyqnW6FkBkroL8ko8Bk8DO60qj1w1XzKAf22NtEml6Pr39lEU1vxd X-Received: by 2002:a17:906:5291:b0:a59:9f88:f1f1 with SMTP id a640c23a62f3a-a5a2d1de7b1mr1794906466b.19.1715875414254; Thu, 16 May 2024 09:03:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715875414; cv=pass; d=google.com; s=arc-20160816; b=lzE+kNwVDOvFsJ3pL2+xCoEe49ljvIZcIgoBF2n+Zvw3QqrOV18XG3yJncOm9QCLDI UgOP0mXjACMmLt6nQq1BfK/haBSTP3jQRajIzqKBekAVBfcWOySIygNEOnvX7kO0lbyf MnTcR6Cu9/ofGeCqPvjf3eBc6nOE9OLOJ6vTLv1ccsV/9iIZQ2VLfcWsHyq6+yGj2yI6 KJ0dJfnW/StAhHA3cFrlNZU2Snx7v+FdAwCg73AHzcbp8CcaJ1S+Bh0nEyjtsa0FpfmI mSS31cDh6JJFZoW25dN85tHjKsomfrhX9DdL8QfGR9GQOfKSfWwno4xBRSkAdWXItuKg 1BzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=quQEENvi+8m2W7cBE5Cl749lOV0EoC/dR++hJ/4pzdI=; fh=/Oqn+MMwn80lnQvwSs4j80J/abZ9Kb5z4DtBlJxirYc=; b=H6bfLRjN9YKValfqgE08ier5hyRnZUVRVP3Caj5xr4QGGvwEY2NTcVhlqu1Ooeb2CY rNCZKPNQSi+GqEhmwS9NwUHvyvm0/eKM/NAyuPKIRNce43lOrhrubAYsLxVrhD/zeogA jC6Ub5IHuNwmbDbvWnN9/4rK1ym88iOk7GqZ/vYigMRpUhmQwxiIKqCAp4AHUeDgov6U hm0Uyi2WgkZx9W4HLvK1L3wM7VwNS1KwvyjSBylMcaKyW8eNAyVTJnLU2iGpMSpifIH4 KcJc3Ti+HHMmQko2CzjLqcMfLnILiKwLcE+0z/u1oT1p5Np6b+YkGt4M5ofzjScm92o6 KKqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hyGTErEQ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-181286-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a179460d6si813882566b.12.2024.05.16.09.03.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 09:03:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181286-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hyGTErEQ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-181286-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D06301F2217C for ; Thu, 16 May 2024 16:03:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1747E14D712; Thu, 16 May 2024 16:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hyGTErEQ" Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (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 6FF8F14D2AE; Thu, 16 May 2024 16:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715875395; cv=none; b=MTeCdTfaxCFkxGV6XzP7gBovj81T+pwGgdCqxCdCo6S2iwv6ZzJFHqSRPqv/FbxYCxV4owY7K5CWIcr8BppxgLXrFjCEtBAF8TTMfor4lmQyIKCvX0fRmNvPuV8AYpIFSceop8DlpC5Y+N01tACDoDxPBjvwFzz98+b0e5NSjG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715875395; c=relaxed/simple; bh=XfbK26HHwTXb9D6hf85Wv5JSchZA7ZbGTeN/kOh0rRw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dGULdCkYYkWKO3bRe3v7Vs1XhB80f9tTp00REYe5D9nDB7LtArgPjeWHBD7obd3DkhIl/dxONJ/hiAJXlVfcBG6wgMJ5giDc3w8RwwcjGjY7RB1F3ZPYCZBqLpZz4cV5AKEvQzjC9HMB4KphSU5KCr6PIApQ+00ngO8MLOJTACs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hyGTErEQ; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-43df44ef3e3so33174691cf.2; Thu, 16 May 2024 09:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715875392; x=1716480192; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=quQEENvi+8m2W7cBE5Cl749lOV0EoC/dR++hJ/4pzdI=; b=hyGTErEQFmXvFTZKsDMCaA5I3ANYEZweCWknpV9mi5taZz0bkBwO+f8Tlf3pKpP8AT xYr7pTCAKJOcJM3w05M/je0jq7ffozvkXNr8jB+5MFUJNMcz1FWdrOM4HCbF/4iyWinz Gqt3YVyPSijQtraH3ZmNqxZI9pKQeQAVlZNu910S6eTIoVp87xPeOq9/uY0CuDWWv/7u 9h433goprZqKl2d93BGOJpgSMaoUAeOdtjt0HjoXemMwW05fl4kIOGx/ZNiJSU75xIqv 9woM0/W0XooQ6i6F9mzJUamuZgw8t6NT6/ZPntVR9cm/8NdfMbBPQpnd7aIeicyXO3UV 2H8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715875392; x=1716480192; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=quQEENvi+8m2W7cBE5Cl749lOV0EoC/dR++hJ/4pzdI=; b=wSvjOSO2LM0/WMrgu8LaHgmapz9+i5x0n67GAm2LzhHIzsfS58IoyiarWmdMOu3oHZ fkbQnTwbm4rH1LPDBhLjx5L23LcrYEWksgF+CbfKaw1QB1B9cOGBt9TW4SyAy6vgh6UH QVAv3YqJu4Zqc4+NpY9LAEAas4PNB527L5VVV7xvggIxXrIwZ1L98Hq+3rqAxAsjJx1D 1UFLtZmuuVS85YAo+Y+GLV+WZ0umR3pkBHqo3FEGk0B9AHonWpMgLtHh9kX6G9c7xrWa WiCDXdXCamWWli2op8LRyoZl+gMaUtgCAsCvZs8gYszErzR6WqydBgRJDGCEqGVqukn/ 1MHQ== X-Forwarded-Encrypted: i=1; AJvYcCWmyfZ6A8xgVz4N99qjR/A8dDYhOtp1bmaVOFMkDvlT/uNA27FkY2NzXi4Wtlh8fgdJM0+C9dec70LTVeVXMVhIsXnCdEA04wZXdifS3Xi4p5zp7hhixHEnFtAygzHAuepVWiA8s3cnOMYkn/LBbRewLH1IUYlAV1okky2/shyfKQA/rg== X-Gm-Message-State: AOJu0Yzz3REoeEpRzAgGKkjWMYRl/vN1QVyche4T37TqfofAPHNWpShW TrNo8R+YM7+gfdcedgLjNcSoagq+hyDxrzxxsaax1YOFWij2ZawT X-Received: by 2002:ac8:5a8c:0:b0:439:f51a:2c1 with SMTP id d75a77b69052e-43dfda9664bmr233981201cf.1.1715875392075; Thu, 16 May 2024 09:03:12 -0700 (PDT) Received: from [192.168.0.137] ([188.24.105.36]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43df54f216esm99899601cf.31.2024.05.16.09.03.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 May 2024 09:03:11 -0700 (PDT) Message-ID: <9c58e5d3-d31c-4dd2-b89d-3acf744b3a28@gmail.com> Date: Thu, 16 May 2024 19:03:07 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 5/9] iio: adc: ad7173: add support for special inputs To: David Lechner , 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 References: <20240514-ad4111-v2-0-29be6a55efb5@analog.com> <20240514-ad4111-v2-5-29be6a55efb5@analog.com> Content-Language: en-US From: "Ceclan, Dumitru" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 16/05/2024 02:27, David Lechner wrote: > On Tue, May 14, 2024 at 2:23 AM 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 − 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 − 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[] = { >> .has_temp = true, >> .has_input_buf = true, >> .has_int_ref = true, >> + .has_common_input = true, >> .clock = 2 * HZ_PER_MHZ, >> .sinc5_data_rates = ad7173_sinc5_data_rates, >> .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), >> @@ -228,6 +235,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { >> .has_temp = false, >> .has_input_buf = true, >> .has_ref2 = true, >> + .has_common_input = true, >> .clock = 2 * HZ_PER_MHZ, >> .sinc5_data_rates = ad7173_sinc5_data_rates, >> .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), >> @@ -243,6 +251,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { >> .has_input_buf = true, >> .has_int_ref = true, >> .has_ref2 = true, >> + .has_common_input = false, >> .clock = 2 * HZ_PER_MHZ, >> .sinc5_data_rates = ad7173_sinc5_data_rates, >> .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), >> @@ -257,6 +266,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { >> .has_temp = true, >> .has_input_buf = true, >> .has_int_ref = true, >> + .has_common_input = true, >> .clock = 16 * HZ_PER_MHZ, >> .sinc5_data_rates = ad7175_sinc5_data_rates, >> .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), >> @@ -271,6 +281,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { >> .has_input_buf = true, >> .has_int_ref = true, >> .has_ref2 = true, >> + .has_common_input = true, >> .clock = 16 * HZ_PER_MHZ, >> .sinc5_data_rates = ad7175_sinc5_data_rates, >> .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), >> @@ -285,6 +296,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { >> .has_temp = false, >> .has_input_buf = false, >> .has_int_ref = true, >> + .has_common_input = false, >> .clock = 16 * HZ_PER_MHZ, >> .sinc5_data_rates = ad7175_sinc5_data_rates, >> .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), >> @@ -298,6 +310,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { >> .has_temp = true, >> .has_input_buf = true, >> .has_int_ref = true, >> + .has_common_input = true, >> .clock = 16 * HZ_PER_MHZ, >> .odr_start_value = AD7177_ODR_START_VALUE, >> .sinc5_data_rates = 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] == AD7173_AIN_REF_POS || ain[i] == AD7173_AIN_REF_NEG) >> + continue; >> + >> + if ((ain[i] == AD7173_AIN_COM_IN_POS || >> + ain[i] == 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. > As I've said, I do not agree with forcing one channel slot to be used. I could add a property that spawns this channel. Although as I see under, I think I'll permit these inputs to be mixed and matched. > 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. > This is imposed artificially, AD411x has the same cross-point mux that can mix and match all the inputs. > 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? > I think it is 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 >> >>