From nobody Tue Nov 26 05:49:02 2024 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 F22BC1E0DD4 for ; Mon, 21 Oct 2024 10:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504818; cv=none; b=ERynRc8JeQVGz/RQf/70ti/OuyjkdofMM/unRCqbKxSXijwyiq4o9334Rt7dYU7C7NI3s9EvKgLz7v/65yYjwbrsjSGSKiFPVpRB6u08CLeOC+wXLdE9scMhgFKRVwZSN4lU4otvBa86lGkGSpyM6eE33pumNsE4lmQSFgsGo3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504818; c=relaxed/simple; bh=lSphsV781DEEO5eZXZe+5WCVeSRk48zEv06wI90qIyM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jO8exUsxgFS9Z1TE+TvM8LXSdakTDAMX5ZYK4PMeov7OCMvPddZD1Xjnk8VY7mcEWnc8U68M5sTXjJTfiCulAJeJcdZsRQy+goR6jiEivle3BLe34OzQQnSgwmrUgRX4u5zzRJbMPXLow3iJ/0NYYWeQOnrzwK8htqiVHzRQnCo= 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=uG4HMIYH; arc=none smtp.client-ip=209.85.128.46 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="uG4HMIYH" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4315abed18aso39105605e9.2 for ; Mon, 21 Oct 2024 03:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729504813; x=1730109613; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fKrQZwpLn/eCRDsZpuyk3NH+ActJifA9aPIUH7Z4gH0=; b=uG4HMIYHnTaU2/0N85QSfn20l2Kbb8LfTtb+VONpXzJR5YIZwjD/AbNEKhloEtZGui gBYhAhVtXqw2dqxs/P5ll9lMGi2DtRgQGG6oZsmvENBHMbef3PWeuM8QyYJ6eUfGAf50 E+TvQDHFz3I1IFKloHPTc1CyGIx4QbrWXB7eo44NTuCTi6YU7c2luYRF05FcmVpdvvQf 6BydyInKuX9/1bLNjcjCfW/YJ3t1pJZ/0R8n30ddbQ5KPbNR0l8VjCRALKdY556TajSE Fcplm9HSL+dggg+IueBHuFG0UaWf5S+9POMB7XyaJxLKmer1fzGBlxRNJUcayLYZg7b9 qB6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729504813; x=1730109613; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fKrQZwpLn/eCRDsZpuyk3NH+ActJifA9aPIUH7Z4gH0=; b=E/uTisrGG8Px4k0J0sNWLg32O9xKpHvvpnGWFpPlGDYaTiq8rneKOKk0klHopI/fhI RdWDjfk4BW2Q7nS6SnYKCUfPQoh1tl/hK+/EicG6g1/xFyeH8OZ6G7iEawCk6dSEDg/7 patpXMOdHI0AYWObsMg8fVONhWIAQcgx72D8CwIDUio6kN2ty2k8H/UQLaiUrp97XGUm gb07nN5W9bYCyM6j7KCXQeSxupjZsiByZpIVIQwKyQyqHtxWVPVXr/S69GHt48tWrp5b NiHy3Sf8cCGqvqDCKuHxcoqCpVdmaYo/zi3n9EiQCYgg6h1ryWqSFETPUUJoxbZ8wvv1 BgTw== X-Forwarded-Encrypted: i=1; AJvYcCWoiruSqMABlrwciDlgE09efDvc3MOoe9cVvnx9E/9zdvIm4TIxFa1WAffpTRJG2kKO08n8Cca6AL6Qfkg=@vger.kernel.org X-Gm-Message-State: AOJu0YxYEErpVuLEP8sTIsAt+Ap2sd4+0nsOfrH2aZ9/bXsWDjRsbOXf I6QW0+mgptDPSRohnE+9epKwwtKhBUpU+UqIn42ww59c+ZEAiz973z870KVO7N0= X-Google-Smtp-Source: AGHT+IH1e5STM6w/t/+OThujXJlwLR1a0UQlVFBhiPO3a/AoXIdCcxa112WnOGMIDZef+UCO5tSY2g== X-Received: by 2002:a05:600c:1c0d:b0:42f:7ed4:4c25 with SMTP id 5b1f17b1804b1-4316164d809mr90175855e9.14.1729504813198; Mon, 21 Oct 2024 03:00:13 -0700 (PDT) Received: from [192.168.1.64] (2a02-842a-d52e-6101-6fd0-06c4-5d68-f0a5.rev.sfr.net. [2a02:842a:d52e:6101:6fd0:6c4:5d68:f0a5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58bbaasm52375995e9.23.2024.10.21.03.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 03:00:12 -0700 (PDT) From: Julien Stephan Date: Mon, 21 Oct 2024 12:00:09 +0200 Subject: [PATCH v2 1/5] dt-bindings: iio: adc: ad7380: fix ad7380-4 reference supply Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241021-ad7380-fix-supplies-v2-1-2ca551b3352a@baylibre.com> References: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> In-Reply-To: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , David Lechner , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , Jonathan Corbet Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Conor Dooley , Jonathan Cameron , linux-doc@vger.kernel.org, Julien Stephan X-Mailer: b4 0.14.2 ad7380-4 is the only device from ad738x family that doesn't have an internal reference. Moreover its external reference is called REFIN in the datasheet while all other use REFIO as an optional external reference. If refio-supply is omitted the internal reference is used. Fix the binding by adding refin-supply and makes it required for ad7380-4 only. Fixes: 1a291cc8ee17 ("dt-bindings: iio: adc: ad7380: add support for ad738x= -4 4 channels variants") Signed-off-by: Julien Stephan Acked-by: Conor Dooley Reviewed-by: David Lechner --- .../devicetree/bindings/iio/adc/adi,ad7380.yaml | 21 +++++++++++++++++= ++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml b/Do= cumentation/devicetree/bindings/iio/adc/adi,ad7380.yaml index bd19abb867d98d46bdd1c9e0c197e10f06979204..0065d650882489e21b952bb9fb2= 5f1e3a070ee68 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml @@ -67,6 +67,10 @@ properties: A 2.5V to 3.3V supply for the external reference voltage. When omitt= ed, the internal 2.5V reference is used. =20 + refin-supply: + description: + A 2.5V to 3.3V supply for external reference voltage, for ad7380-4 o= nly. + aina-supply: description: The common mode voltage supply for the AINA- pin on pseudo-different= ial @@ -135,6 +139,23 @@ allOf: ainc-supply: false aind-supply: false =20 + # ad7380-4 uses refin-supply as external reference. + # All other chips from ad738x family use refio as optional external refe= rence. + # When refio-supply is omitted, internal reference is used. + - if: + properties: + compatible: + enum: + - adi,ad7380-4 + then: + properties: + refio-supply: false + required: + - refin-supply + else: + properties: + refin-supply: false + examples: - | #include --=20 2.47.0 From nobody Tue Nov 26 05:49:02 2024 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 0FE8C1E3DF0 for ; Mon, 21 Oct 2024 10:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504819; cv=none; b=MFQIDxdiFoUxc6MfLGySKQ6f8pKZ3GO9QjO90exz4JjIDWzD1jN9u9k0dKGK/pL0JaQfQpdOayQHNr4veUIDV6cJ85khHmP9sIdI2Vd2MIJrkX75sV2+Bj6PjNyvjKOWgXNw1USBKRYLTtK7tifRS/RAseHNUS4aiQFmq9tCHqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504819; c=relaxed/simple; bh=pYKC/ozJRXt9qviKAsjryDj3zz5bmMLUYM6HFMi7wgo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nSp6rJ61wMEtEi5if2SJ9vikPIWfYqQ9olU3IB/ap9gO7OdGBQKIeZ+EYzhI41H8OikxunRojJD8oDzjrHpg+QNQl0mqLW4HJ5E4XpEj+axncO4SDz7yY3gS3kacq2CUj/qfTNaRbWO0kAzyMzh9m7zDxExCYKS/e7zEqGf0jY4= 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=yfZTi2vg; arc=none smtp.client-ip=209.85.128.44 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="yfZTi2vg" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4315e62afe0so40235525e9.1 for ; Mon, 21 Oct 2024 03:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729504814; x=1730109614; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=W+XglmH5KouUUXSHvhgqKk4QMj3dNVGqrGai6OpWZdk=; b=yfZTi2vgGqwBnL66haofJ6552JOLp4dddX2tJ/nsswjUecpwdtWtx3M+CxQI9iKE+D 2UZy/Fcb2anQiYt/LX+sKbOJW2+EtlfIgOnDiSXH5MeA5swUKn5jNc8gkCdvBwmxD9O/ +gEVP/kZH3YOGMvTcl49OyfIJgzLq1FRnF2BeGWgjc9X3v/XSoTQUqMLBzAwoJTTNFca oSJd7770rqqBXNQXMrjdp3ra/9rLjEAL416qoNDwy4osDhyzm9tnv08G3AKp9zWrS+Uo wFa8RuG0m4r/fEc+nFq5Xzn6yJEb3rWhGv+YQxdfg7/UI+7wVqNnfRgJ+Mku37NFvcBJ Eb3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729504814; x=1730109614; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W+XglmH5KouUUXSHvhgqKk4QMj3dNVGqrGai6OpWZdk=; b=HFLk5ubtcu/YghODC/VCX8OKkHU6gGVEXGrFTRJll9qx4MhE2AP24SdqEAvpfpu92x N9IjOhnRoPdlvDblmqGOwNdXZScurMPV4YlQbj+Nbw9VmB00VvctOJLD/4JVWSfSI4xz bpPuWAC/xupItrD70KtvQKAZ/c2VPQVxuUPyB4pd8tD5XyC9+VUPjVg4/Cst2gla9zaJ KJu6S4rH6QvCrzbOzNLMfN0GfI2/VnyH194dnWjQ9TNMwzlvsdLZB1stXCPnBrKE4mN+ oPO9Mk6NIFN2iJZMmo91KaEW5MCd9HTCZayld587HRjxGRScStAgQjQZaQCdEc09s4A7 By/g== X-Forwarded-Encrypted: i=1; AJvYcCXboxWebIlxSyVrSd969j1iOqtkethY8inmK1oDhqtR72axxs5i/x8/55eY9vpFxM9rCZ0FkR1K8mEX4FE=@vger.kernel.org X-Gm-Message-State: AOJu0YwpWGp860UjBeg+hidL0G/0mvrSoMXmn3qbHBKp9A0CVGdQN/vD kU/eGUp16KbfbEoo9mhhTwqiI33LHdEi7W+Wbjfj93T05a7yA9TExaCOd/y0Eao= X-Google-Smtp-Source: AGHT+IFaxOJUQtTdaIO9at2lQQ/ZakRe9JJUO3BStAxciPjCyTaiExJ2MiGvvhZ2SyDu1aqK8ba/Ew== X-Received: by 2002:a05:600c:3151:b0:42c:b55f:f7c with SMTP id 5b1f17b1804b1-4316165c311mr89344365e9.15.1729504814071; Mon, 21 Oct 2024 03:00:14 -0700 (PDT) Received: from [192.168.1.64] (2a02-842a-d52e-6101-6fd0-06c4-5d68-f0a5.rev.sfr.net. [2a02:842a:d52e:6101:6fd0:6c4:5d68:f0a5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58bbaasm52375995e9.23.2024.10.21.03.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 03:00:13 -0700 (PDT) From: Julien Stephan Date: Mon, 21 Oct 2024 12:00:10 +0200 Subject: [PATCH v2 2/5] iio: adc: ad7380: use devm_regulator_get_enable_read_voltage() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241021-ad7380-fix-supplies-v2-2-2ca551b3352a@baylibre.com> References: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> In-Reply-To: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , David Lechner , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , Jonathan Corbet Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Conor Dooley , Jonathan Cameron , linux-doc@vger.kernel.org, Julien Stephan X-Mailer: b4 0.14.2 Use devm_regulator_get_enable_read_voltage() to simplify the code. Signed-off-by: Julien Stephan Reviewed-by: David Lechner Reviewed-by: Nuno Sa --- drivers/iio/adc/ad7380.c | 81 +++++++++++++-------------------------------= ---- 1 file changed, 21 insertions(+), 60 deletions(-) diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c index e8bddfb0d07dbcf3e2a43344a4e0516f4d617548..e033c734191143a25a490b09c73= 0dbf95f796737 100644 --- a/drivers/iio/adc/ad7380.c +++ b/drivers/iio/adc/ad7380.c @@ -956,7 +956,7 @@ static const struct iio_info ad7380_info =3D { .debugfs_reg_access =3D &ad7380_debugfs_reg_access, }; =20 -static int ad7380_init(struct ad7380_state *st, struct regulator *vref) +static int ad7380_init(struct ad7380_state *st, bool external_ref_en) { int ret; =20 @@ -968,13 +968,13 @@ static int ad7380_init(struct ad7380_state *st, struc= t regulator *vref) if (ret < 0) return ret; =20 - /* select internal or external reference voltage */ - ret =3D regmap_update_bits(st->regmap, AD7380_REG_ADDR_CONFIG1, - AD7380_CONFIG1_REFSEL, - FIELD_PREP(AD7380_CONFIG1_REFSEL, - vref ? 1 : 0)); - if (ret < 0) - return ret; + if (external_ref_en) { + /* select external reference voltage */ + ret =3D regmap_set_bits(st->regmap, AD7380_REG_ADDR_CONFIG1, + AD7380_CONFIG1_REFSEL); + if (ret < 0) + return ret; + } =20 /* This is the default value after reset. */ st->oversampling_ratio =3D 1; @@ -987,16 +987,11 @@ static int ad7380_init(struct ad7380_state *st, struc= t regulator *vref) FIELD_PREP(AD7380_CONFIG2_SDO, 1)); } =20 -static void ad7380_regulator_disable(void *p) -{ - regulator_disable(p); -} - static int ad7380_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct ad7380_state *st; - struct regulator *vref; + bool external_ref_en; int ret, i; =20 indio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); @@ -1009,37 +1004,17 @@ static int ad7380_probe(struct spi_device *spi) if (!st->chip_info) return dev_err_probe(&spi->dev, -EINVAL, "missing match data\n"); =20 - vref =3D devm_regulator_get_optional(&spi->dev, "refio"); - if (IS_ERR(vref)) { - if (PTR_ERR(vref) !=3D -ENODEV) - return dev_err_probe(&spi->dev, PTR_ERR(vref), - "Failed to get refio regulator\n"); - - vref =3D NULL; - } - /* * If there is no REFIO supply, then it means that we are using * the internal 2.5V reference, otherwise REFIO is reference voltage. */ - if (vref) { - ret =3D regulator_enable(vref); - if (ret) - return ret; + ret =3D devm_regulator_get_enable_read_voltage(&spi->dev, "refio"); + if (ret < 0 && ret !=3D -ENODEV) + return dev_err_probe(&spi->dev, ret, + "Failed to get refio regulator\n"); =20 - ret =3D devm_add_action_or_reset(&spi->dev, - ad7380_regulator_disable, vref); - if (ret) - return ret; - - ret =3D regulator_get_voltage(vref); - if (ret < 0) - return ret; - - st->vref_mv =3D ret / 1000; - } else { - st->vref_mv =3D AD7380_INTERNAL_REF_MV; - } + external_ref_en =3D ret !=3D -ENODEV; + st->vref_mv =3D external_ref_en ? ret / 1000 : AD7380_INTERNAL_REF_MV; =20 if (st->chip_info->num_vcm_supplies > ARRAY_SIZE(st->vcm_mv)) return dev_err_probe(&spi->dev, -EINVAL, @@ -1050,27 +1025,13 @@ static int ad7380_probe(struct spi_device *spi) * input pin. */ for (i =3D 0; i < st->chip_info->num_vcm_supplies; i++) { - struct regulator *vcm; - - vcm =3D devm_regulator_get(&spi->dev, - st->chip_info->vcm_supplies[i]); - if (IS_ERR(vcm)) - return dev_err_probe(&spi->dev, PTR_ERR(vcm), - "Failed to get %s regulator\n", - st->chip_info->vcm_supplies[i]); + const char *vcm =3D st->chip_info->vcm_supplies[i]; =20 - ret =3D regulator_enable(vcm); - if (ret) - return ret; - - ret =3D devm_add_action_or_reset(&spi->dev, - ad7380_regulator_disable, vcm); - if (ret) - return ret; - - ret =3D regulator_get_voltage(vcm); + ret =3D devm_regulator_get_enable_read_voltage(&spi->dev, vcm); if (ret < 0) - return ret; + return dev_err_probe(&spi->dev, ret, + "Failed to get %s regulator\n", + vcm); =20 st->vcm_mv[i] =3D ret / 1000; } @@ -1135,7 +1096,7 @@ static int ad7380_probe(struct spi_device *spi) if (ret) return ret; =20 - ret =3D ad7380_init(st, vref); + ret =3D ad7380_init(st, external_ref_en); if (ret) return ret; =20 --=20 2.47.0 From nobody Tue Nov 26 05:49:02 2024 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.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 E08321E47B8 for ; Mon, 21 Oct 2024 10:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504819; cv=none; b=p+ny6sJrR7T1BaRJiPETYBSJM+E+5gZXwJKbo9a7BLWSvfnlNqDVjyxHF6Xegucsqh9dfU+WpfGAZtQu8+9xRmNjPfA03d/m1QxmWthNk6JW/TJrivaoHU2WHHStxrJ6ZZ9uC2MlAbY4qaA92zzzBJAzXXj2ulZp8PUFIycSngk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504819; c=relaxed/simple; bh=CLWgS17xU2QNj818aWqPE/gqen+525xGgHzoq/mwX6s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DofcUbUbw17CUAhrk4suRxrhYIEXT98ua/lnoz5M6iVWd9UaVefe+84LOroiwT74+AhM9ttTXuIgiLSyOyrZENy/SE8GpDEbFp/H0j8g2ZGbvdknbU/qTvjxB/VyqyDAT60c3Ap1oad7MDduy8bpYdv857XdVOEbN5D4ROlj7zs= 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=kATdHh58; arc=none smtp.client-ip=209.85.128.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="kATdHh58" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4314c4cb752so45126695e9.2 for ; Mon, 21 Oct 2024 03:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729504815; x=1730109615; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OSAuKhPnRKrQtznNZ2b2Xb8z5UtqTMbdPxuKnBZE3RU=; b=kATdHh58n/tHc0+DDk056Fc4+TbSwnN/u2Of7MTyd/acjEIa04vXzU+9bwrTCPaYWS 0eyzmdmk+fjb5WUo6OFhU13vR8b18PTF+2P4hvj5iMMPg16Pe/5TCz7xaohy2MMuSQ52 Mk4Hc6NTU+MqyzLBGZpDoifV2izGcgdIBozFRoPXIunFPheblL38EysDN8/niGzNo9bP 2ZUCCWqkrvFEvGhU7ZEiayuFLmmrk2j696JGJW6WzCxfDcB6IE/8gfpp8amr7JM4EPkY Z4qA37XkVb8X2AZkKB+xb/wT2ckkLfrnspiPmbC/LMzcbenfsOmki1gLZ3jO+MyLNFut qoNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729504815; x=1730109615; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OSAuKhPnRKrQtznNZ2b2Xb8z5UtqTMbdPxuKnBZE3RU=; b=dRA6w1Ty2nnnPVD5xkNiAMt9Wus3B80NA0ec8LllmbXW0PkHiVUftUcA4c4LQUYDTF sAX16M9IExePdyYjqwM1w05z6TNpAjpl72SWRKjYNpgaTDQFvRHwYjEFoTj9+Fs3z3XR MFQbyhoVupywkubOR93UdRcYaJdQ0SywcWtUGzOLDHQAlJnOCkU5nCT0IWqJxGjgYCWS RDcAN+DUIqoR8W5i8mj/fOn6zGkdc9QRGivxpCrvwzz7WdlFJNLvGWRF83xslp+S/w7g R+kqIj9lyAvcHAwpkE0PkMTzcP513jvzTa5K6KVVpxnvT8CvHe1njbACFMLt9Gq8HZIu NCVA== X-Forwarded-Encrypted: i=1; AJvYcCVxAEa6Bq3PqkOkwHjl1Tyx/MuAxrZCf9D6Fl5NF81PDB/JQa6hKt9tGK+BUv6VFxc2sKJmhAnEUS6Yhx4=@vger.kernel.org X-Gm-Message-State: AOJu0YxJEd+bIwBYrfr+PwDU6u74TgfJevbHSCZmmt43kkzo0kMAs0uA 96SJbE1wJ/lkHOdTOvR2hGO67+NWYDcGfet4wjp0pBbDVIszkPLYijAHARAjaRk= X-Google-Smtp-Source: AGHT+IHfwxl2M2jZBLMcvDu4oqoDJ3/yF2Audoq/iqQ+uv2BSUteZWTzxhvukc+D1YDNPQlWSQfcwQ== X-Received: by 2002:a05:600c:6747:b0:42c:acb0:dda5 with SMTP id 5b1f17b1804b1-4316161f2fcmr91828815e9.1.1729504815144; Mon, 21 Oct 2024 03:00:15 -0700 (PDT) Received: from [192.168.1.64] (2a02-842a-d52e-6101-6fd0-06c4-5d68-f0a5.rev.sfr.net. [2a02:842a:d52e:6101:6fd0:6c4:5d68:f0a5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58bbaasm52375995e9.23.2024.10.21.03.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 03:00:14 -0700 (PDT) From: Julien Stephan Date: Mon, 21 Oct 2024 12:00:11 +0200 Subject: [PATCH v2 3/5] iio: adc: ad7380: add missing supplies Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241021-ad7380-fix-supplies-v2-3-2ca551b3352a@baylibre.com> References: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> In-Reply-To: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , David Lechner , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , Jonathan Corbet Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Conor Dooley , Jonathan Cameron , linux-doc@vger.kernel.org, Julien Stephan X-Mailer: b4 0.14.2 vcc and vlogic are required but are not retrieved and enabled in the probe. Add them. In order to prepare support for additional parts requiring different supplies, add vcc and vlogic to the platform specific structures Signed-off-by: Julien Stephan Reviewed-by: David Lechner Reviewed-by: Nuno Sa --- drivers/iio/adc/ad7380.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c index e033c734191143a25a490b09c730dbf95f796737..e257f78d63edd7910fcb936ec53= 44922f8e70b99 100644 --- a/drivers/iio/adc/ad7380.c +++ b/drivers/iio/adc/ad7380.c @@ -75,6 +75,7 @@ #define T_CONVERT_NS 190 /* conversion time */ #define T_CONVERT_0_NS 10 /* 1st conversion start time (oversampling) */ #define T_CONVERT_X_NS 500 /* xth conversion start time (oversampling) */ +#define T_POWERUP_MS 5 /* Power up */ =20 struct ad7380_timing_specs { const unsigned int t_csh_ns; /* CS minimum high time */ @@ -86,6 +87,8 @@ struct ad7380_chip_info { unsigned int num_channels; unsigned int num_simult_channels; bool has_mux; + const char * const *supplies; + unsigned int num_supplies; const char * const *vcm_supplies; unsigned int num_vcm_supplies; const unsigned long *available_scan_masks; @@ -243,6 +246,10 @@ DEFINE_AD7380_8_CHANNEL(ad7386_4_channels, 16, 0, u); DEFINE_AD7380_8_CHANNEL(ad7387_4_channels, 14, 0, u); DEFINE_AD7380_8_CHANNEL(ad7388_4_channels, 12, 0, u); =20 +static const char * const ad7380_supplies[] =3D { + "vcc", "vlogic", +}; + static const char * const ad7380_2_channel_vcm_supplies[] =3D { "aina", "ainb", }; @@ -338,6 +345,8 @@ static const struct ad7380_chip_info ad7380_chip_info = =3D { .channels =3D ad7380_channels, .num_channels =3D ARRAY_SIZE(ad7380_channels), .num_simult_channels =3D 2, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .available_scan_masks =3D ad7380_2_channel_scan_masks, .timing_specs =3D &ad7380_timing, }; @@ -347,6 +356,8 @@ static const struct ad7380_chip_info ad7381_chip_info = =3D { .channels =3D ad7381_channels, .num_channels =3D ARRAY_SIZE(ad7381_channels), .num_simult_channels =3D 2, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .available_scan_masks =3D ad7380_2_channel_scan_masks, .timing_specs =3D &ad7380_timing, }; @@ -356,6 +367,8 @@ static const struct ad7380_chip_info ad7383_chip_info = =3D { .channels =3D ad7383_channels, .num_channels =3D ARRAY_SIZE(ad7383_channels), .num_simult_channels =3D 2, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .vcm_supplies =3D ad7380_2_channel_vcm_supplies, .num_vcm_supplies =3D ARRAY_SIZE(ad7380_2_channel_vcm_supplies), .available_scan_masks =3D ad7380_2_channel_scan_masks, @@ -367,6 +380,8 @@ static const struct ad7380_chip_info ad7384_chip_info = =3D { .channels =3D ad7384_channels, .num_channels =3D ARRAY_SIZE(ad7384_channels), .num_simult_channels =3D 2, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .vcm_supplies =3D ad7380_2_channel_vcm_supplies, .num_vcm_supplies =3D ARRAY_SIZE(ad7380_2_channel_vcm_supplies), .available_scan_masks =3D ad7380_2_channel_scan_masks, @@ -378,6 +393,8 @@ static const struct ad7380_chip_info ad7386_chip_info = =3D { .channels =3D ad7386_channels, .num_channels =3D ARRAY_SIZE(ad7386_channels), .num_simult_channels =3D 2, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .has_mux =3D true, .available_scan_masks =3D ad7380_2x2_channel_scan_masks, .timing_specs =3D &ad7380_timing, @@ -388,6 +405,8 @@ static const struct ad7380_chip_info ad7387_chip_info = =3D { .channels =3D ad7387_channels, .num_channels =3D ARRAY_SIZE(ad7387_channels), .num_simult_channels =3D 2, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .has_mux =3D true, .available_scan_masks =3D ad7380_2x2_channel_scan_masks, .timing_specs =3D &ad7380_timing, @@ -398,6 +417,8 @@ static const struct ad7380_chip_info ad7388_chip_info = =3D { .channels =3D ad7388_channels, .num_channels =3D ARRAY_SIZE(ad7388_channels), .num_simult_channels =3D 2, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .has_mux =3D true, .available_scan_masks =3D ad7380_2x2_channel_scan_masks, .timing_specs =3D &ad7380_timing, @@ -408,6 +429,8 @@ static const struct ad7380_chip_info ad7380_4_chip_info= =3D { .channels =3D ad7380_4_channels, .num_channels =3D ARRAY_SIZE(ad7380_4_channels), .num_simult_channels =3D 4, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .available_scan_masks =3D ad7380_4_channel_scan_masks, .timing_specs =3D &ad7380_4_timing, }; @@ -417,6 +440,8 @@ static const struct ad7380_chip_info ad7381_4_chip_info= =3D { .channels =3D ad7381_4_channels, .num_channels =3D ARRAY_SIZE(ad7381_4_channels), .num_simult_channels =3D 4, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .available_scan_masks =3D ad7380_4_channel_scan_masks, .timing_specs =3D &ad7380_4_timing, }; @@ -426,6 +451,8 @@ static const struct ad7380_chip_info ad7383_4_chip_info= =3D { .channels =3D ad7383_4_channels, .num_channels =3D ARRAY_SIZE(ad7383_4_channels), .num_simult_channels =3D 4, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .vcm_supplies =3D ad7380_4_channel_vcm_supplies, .num_vcm_supplies =3D ARRAY_SIZE(ad7380_4_channel_vcm_supplies), .available_scan_masks =3D ad7380_4_channel_scan_masks, @@ -437,6 +464,8 @@ static const struct ad7380_chip_info ad7384_4_chip_info= =3D { .channels =3D ad7384_4_channels, .num_channels =3D ARRAY_SIZE(ad7384_4_channels), .num_simult_channels =3D 4, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .vcm_supplies =3D ad7380_4_channel_vcm_supplies, .num_vcm_supplies =3D ARRAY_SIZE(ad7380_4_channel_vcm_supplies), .available_scan_masks =3D ad7380_4_channel_scan_masks, @@ -448,6 +477,8 @@ static const struct ad7380_chip_info ad7386_4_chip_info= =3D { .channels =3D ad7386_4_channels, .num_channels =3D ARRAY_SIZE(ad7386_4_channels), .num_simult_channels =3D 4, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .has_mux =3D true, .available_scan_masks =3D ad7380_2x4_channel_scan_masks, .timing_specs =3D &ad7380_4_timing, @@ -458,6 +489,8 @@ static const struct ad7380_chip_info ad7387_4_chip_info= =3D { .channels =3D ad7387_4_channels, .num_channels =3D ARRAY_SIZE(ad7387_4_channels), .num_simult_channels =3D 4, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .has_mux =3D true, .available_scan_masks =3D ad7380_2x4_channel_scan_masks, .timing_specs =3D &ad7380_4_timing, @@ -468,6 +501,8 @@ static const struct ad7380_chip_info ad7388_4_chip_info= =3D { .channels =3D ad7388_4_channels, .num_channels =3D ARRAY_SIZE(ad7388_4_channels), .num_simult_channels =3D 4, + .supplies =3D ad7380_supplies, + .num_supplies =3D ARRAY_SIZE(ad7380_supplies), .has_mux =3D true, .available_scan_masks =3D ad7380_2x4_channel_scan_masks, .timing_specs =3D &ad7380_4_timing, @@ -1004,6 +1039,14 @@ static int ad7380_probe(struct spi_device *spi) if (!st->chip_info) return dev_err_probe(&spi->dev, -EINVAL, "missing match data\n"); =20 + ret =3D devm_regulator_bulk_get_enable(&spi->dev, st->chip_info->num_supp= lies, + st->chip_info->supplies); + + if (ret) + return dev_err_probe(&spi->dev, ret, + "Failed to enable power supplies\n"); + msleep(T_POWERUP_MS); + /* * If there is no REFIO supply, then it means that we are using * the internal 2.5V reference, otherwise REFIO is reference voltage. --=20 2.47.0 From nobody Tue Nov 26 05:49:02 2024 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 D5CDA1E47C5 for ; Mon, 21 Oct 2024 10:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504820; cv=none; b=EZ0elgC6OsBSISWaV0+RMNyQV/0mp7Q9Tq4TIya9fSQvmfcXstl8amsEp2pgPcd7vMtFxV+b8v3HWgvmKcxYIr/jIRf4KnAY05lw2sD3h1SizQjoLVsvdjtQq5ezGxMbymgAaqyDx7IT13Xk9KGnY3kdA75+Xb3wKyN7NyV4GNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504820; c=relaxed/simple; bh=g5cZOk2TBRdNqBRRxIPoU5chsYH4Ym3JbGrRyU4zj2o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AifMrjjYyTdcu4FRUGNuXlakNXIH+NNZ4Q9JFloGbfmet1bwlxj8D3bFpWwe9WOqYLXs2LN3DXwQUBAr03r59zqMV/1CGuj6La9gOKX2NVM8rH69eiKYPnuWZMyNHsTBla9tt/QRjrdsmgoaCSzzVFskNBPmr6/v4yGzrV4a7j0= 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=zqrxBMTa; arc=none smtp.client-ip=209.85.128.42 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="zqrxBMTa" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4314fa33a35so43626975e9.1 for ; Mon, 21 Oct 2024 03:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729504816; x=1730109616; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GPOrVtTUtrTNGw1M2sJsQdVYLeAplWcJ5G6hfZza2f8=; b=zqrxBMTaza9gmCIugvDKA28+0PPQqa8RJYzO9CaShDxAzZAYNfvKMDw/9toJwXJNN9 WcaQoDzWq6Y1nVadAHiTjovp+6o2zKKsJAlIi1ZuoeLMB14uJJrlbyhL6i2VxSJYFPHY tZniExwR0F6/6sKmPM1AUpXLrO0e4TTT0m2mljRAxFX2m4K82jl+eyEo2sPa/yd/CLNi ECQwFvgwRfBTlcqIC83PrQOl1bmT8sxfGVlrdF3A4Oq5PTCUNk6Jcz4atX/HgzwJTN+W 1wV/5vpYlY7SXLzehG0lWwP//eEvK1OWDQCgRZooF8sN1KpWRp+XH/Xg11/O/gNJjmCP aPaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729504816; x=1730109616; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GPOrVtTUtrTNGw1M2sJsQdVYLeAplWcJ5G6hfZza2f8=; b=aWXtwA3IxDo3ujQUeN/JW9mSkkGH8WWxNdG17ze2BqxwGNIKYTQpzoz2KSpUVgsmU+ FcUvFsW+pSKt4uYxpJ4ckDyvn0hiJHcO4ZJzNK8x6kNwkdTxRHIcQ9SyLrvIOT6cl+rY FIYcQ7HUm+t/dS2GuGL47EZJZrqJAe3ru/CxHWKFYyG81+ndwNFDJniEdXHoMads4sWQ yHtJCtBAZ/KThVnGzALqNjYnnb7lcPTC2hMW2OVEds+jbPQCgdhvuWKY7OVFufNXvasr BCIMBcAcdiWsBf1nMHO4zmzysUt6pt9Rts6ilimSNk2wQe1ODUvuQW9vjTKEMyXbymgp VrSQ== X-Forwarded-Encrypted: i=1; AJvYcCW3HWokbtW8YD5C69spw8drJjt6sAdIblHzqwk44HIxyJVsxLN2OreJ32GdzU0W3oVLNdUmp8+ABHKX+2g=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9riKw8qzvOAY4+I1Vmm8p2FgXtFY9DR/6eOKe2cBc32yF0T8k TFWyzipKDSdWlRPvZPHiTVw6gAX9mluBl3a9bDPSVZL/MVQw8N/PgDtoyipy4+0= X-Google-Smtp-Source: AGHT+IF07HOumQy50gBkQaWj0y5iUsQm/oWvfTD2vdo86U7e3YHPzzmO2E6zfR2esGYs7FlPdkcG0A== X-Received: by 2002:a05:600c:4fc4:b0:42f:8287:c24d with SMTP id 5b1f17b1804b1-43161667fdfmr89174005e9.21.1729504816134; Mon, 21 Oct 2024 03:00:16 -0700 (PDT) Received: from [192.168.1.64] (2a02-842a-d52e-6101-6fd0-06c4-5d68-f0a5.rev.sfr.net. [2a02:842a:d52e:6101:6fd0:6c4:5d68:f0a5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58bbaasm52375995e9.23.2024.10.21.03.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 03:00:15 -0700 (PDT) From: Julien Stephan Date: Mon, 21 Oct 2024 12:00:12 +0200 Subject: [PATCH v2 4/5] iio: adc: ad7380: fix supplies for ad7380-4 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241021-ad7380-fix-supplies-v2-4-2ca551b3352a@baylibre.com> References: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> In-Reply-To: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , David Lechner , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , Jonathan Corbet Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Conor Dooley , Jonathan Cameron , linux-doc@vger.kernel.org, Julien Stephan X-Mailer: b4 0.14.2 ad7380-4 is the only device in the family that does not have an internal reference. It uses "refin" as a required external reference. All other devices in the family use "refio"" as an optional external reference. Fixes: 737413da8704 ("iio: adc: ad7380: add support for ad738x-4 4 channels= variants") Signed-off-by: Julien Stephan Reviewed-by: David Lechner Reviewed-by: Nuno Sa --- drivers/iio/adc/ad7380.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c index e257f78d63edd7910fcb936ec5344922f8e70b99..65096717f0dd3ea6a4ff7020bc5= 44d62b84cb8fd 100644 --- a/drivers/iio/adc/ad7380.c +++ b/drivers/iio/adc/ad7380.c @@ -89,6 +89,7 @@ struct ad7380_chip_info { bool has_mux; const char * const *supplies; unsigned int num_supplies; + bool external_ref_only; const char * const *vcm_supplies; unsigned int num_vcm_supplies; const unsigned long *available_scan_masks; @@ -431,6 +432,7 @@ static const struct ad7380_chip_info ad7380_4_chip_info= =3D { .num_simult_channels =3D 4, .supplies =3D ad7380_supplies, .num_supplies =3D ARRAY_SIZE(ad7380_supplies), + .external_ref_only =3D true, .available_scan_masks =3D ad7380_4_channel_scan_masks, .timing_specs =3D &ad7380_4_timing, }; @@ -1047,17 +1049,31 @@ static int ad7380_probe(struct spi_device *spi) "Failed to enable power supplies\n"); msleep(T_POWERUP_MS); =20 - /* - * If there is no REFIO supply, then it means that we are using - * the internal 2.5V reference, otherwise REFIO is reference voltage. - */ - ret =3D devm_regulator_get_enable_read_voltage(&spi->dev, "refio"); - if (ret < 0 && ret !=3D -ENODEV) - return dev_err_probe(&spi->dev, ret, - "Failed to get refio regulator\n"); + if (st->chip_info->external_ref_only) { + ret =3D devm_regulator_get_enable_read_voltage(&spi->dev, + "refin"); + if (ret < 0) + return dev_err_probe(&spi->dev, ret, + "Failed to get refin regulator\n"); + + st->vref_mv =3D ret / 1000; =20 - external_ref_en =3D ret !=3D -ENODEV; - st->vref_mv =3D external_ref_en ? ret / 1000 : AD7380_INTERNAL_REF_MV; + /* these chips don't have a register bit for this */ + external_ref_en =3D false; + } else { + /* + * If there is no REFIO supply, then it means that we are using + * the internal reference, otherwise REFIO is reference voltage. + */ + ret =3D devm_regulator_get_enable_read_voltage(&spi->dev, + "refio"); + if (ret < 0 && ret !=3D -ENODEV) + return dev_err_probe(&spi->dev, ret, + "Failed to get refio regulator\n"); + + external_ref_en =3D ret !=3D -ENODEV; + st->vref_mv =3D external_ref_en ? ret / 1000 : AD7380_INTERNAL_REF_MV; + } =20 if (st->chip_info->num_vcm_supplies > ARRAY_SIZE(st->vcm_mv)) return dev_err_probe(&spi->dev, -EINVAL, --=20 2.47.0 From nobody Tue Nov 26 05:49:02 2024 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.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 3FDD41E5703 for ; Mon, 21 Oct 2024 10:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504822; cv=none; b=fsCLW1vQWb5zpbKWH9EE6oQ8SopGN834pk3FchuGgHVmAME1ZOMc2/Fd6fAoje5pw4UvNyXqs+ivLuacmiv8AOMHu1hQ9t5NBFISPkGZxeYJGJp0HFrxy9I7pMK0af8w5SANB3hmn6mA9B5M/S1fLuk/IpFGtbwVpwBn3KAaPow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729504822; c=relaxed/simple; bh=JVqTtX2R5tgI5AgbA4RUFWdiRHGbpSlYbypt0KFdYVI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hojnaoW4gS9T+6zLysuOohDewH8oXffeGaYMbXNVbaAp73nSvyhsmWuiwXZ/1HXEcTWddsG5prCTCh3kA/8CiEtyFA/kZBjPFSZvO/IG57m2FJhniQlEmzd4P7hCBmRqr2oTXM5rvsYAHlfL7pOpUvP8sbzN54Y+sCUKyW5XhOE= 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=eYp4iOoV; arc=none smtp.client-ip=209.85.221.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="eYp4iOoV" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-37d4a5ecc44so3197119f8f.2 for ; Mon, 21 Oct 2024 03:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729504818; x=1730109618; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=y2t5+GdX8LkCEmUcnfMgk3trAyT7R5nzR/wNUS1TNBk=; b=eYp4iOoVIUlQdZubB9EHihRjM89bOqrYWf3HP2erVXi02iFeDUFkiF7NWHGXXkB7mk gRi94g0Y1ZKHUL62if5mkalzcZ8UpTc9qeKXhOiLcpZVEEFArV3FZN/Q6LJLAQNHB6mp eGub/aYantxYDSxn1ou9RrP42nVFSDd50EwzYGzWhdGWQl4af1O9pIBJESLAQbrxmew4 GjjJARhJDrCMe5N3s7M2NJ7t+BNatG2eBT4ZnHKyxsUK5ukV4HKUXQ6gRkn1M/9J8tl9 P6kVVixjP4RvYv0RX5/OIDSeya+Ch/NE4rEUzIpZnF6mY/123u1oNzSX+aFhirLA6PTD Z3rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729504818; x=1730109618; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y2t5+GdX8LkCEmUcnfMgk3trAyT7R5nzR/wNUS1TNBk=; b=fKPFv8r9urF0EluRDvAeX1RWwGI15amo3G1flxcaY2VnG6em0QZTzp/X+Pyp0rvh04 ES0wJfs1r8BXTER7NfyCpJKlRgz47ZoVEOI1e3dVoamOlBTuI3pWYdps3h+GHHt7V2S4 Sg65GOIZteWUW0TxCled9jTjvvB+/jFEPZQaT4YUh9e7m+pRpkrJ7eVg3jRmMzWC3yxa DaRSsP9JUDYjEgWNWGJ8H/i+tG52/r+IPQTVQKoGLKWNic7/VykkFpb9X5tBlJEBJg0E y+F+kE9ta9NcupXy+KjtlwgHGuQWdqlCvbpdk/hbw3H0TMwe4Q19Rxjtd+BU4yV1BYD4 Jd7w== X-Forwarded-Encrypted: i=1; AJvYcCUrSar20w65oRwtOhztWB3ofv1evlSPZTWnhlzsTW4j6BSIVe+MWeGI/cZj/xgmFJf5YjaSqE9HI2LQI6o=@vger.kernel.org X-Gm-Message-State: AOJu0YzCBDyyRr04e4gDEcX42ardR9hg68mPrX3Jfxno+Lg2L8Nnqjw5 /I/W3wKCelikd0Uvy8D4lPhqCHbc73cyBkY74bUtpHu5YYVckPA3TFgueLXry5Q= X-Google-Smtp-Source: AGHT+IHvplc2wMXT1OorBIg0HcGCuXTDErHL+CnzciKozIpFOxqNccmTzrhFCLXXNzwzzh3RuSgWHA== X-Received: by 2002:adf:ed11:0:b0:37d:45c3:3459 with SMTP id ffacd0b85a97d-37eab75b5cbmr7425151f8f.21.1729504817015; Mon, 21 Oct 2024 03:00:17 -0700 (PDT) Received: from [192.168.1.64] (2a02-842a-d52e-6101-6fd0-06c4-5d68-f0a5.rev.sfr.net. [2a02:842a:d52e:6101:6fd0:6c4:5d68:f0a5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58bbaasm52375995e9.23.2024.10.21.03.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 03:00:16 -0700 (PDT) From: Julien Stephan Date: Mon, 21 Oct 2024 12:00:13 +0200 Subject: [PATCH v2 5/5] docs: iio: ad7380: fix supply for ad7380-4 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241021-ad7380-fix-supplies-v2-5-2ca551b3352a@baylibre.com> References: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> In-Reply-To: <20241021-ad7380-fix-supplies-v2-0-2ca551b3352a@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , David Lechner , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , Jonathan Corbet Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Conor Dooley , Jonathan Cameron , linux-doc@vger.kernel.org, Julien Stephan X-Mailer: b4 0.14.2 ad7380-4 is the only device from ad738x family that doesn't have an internal reference. Moreover it's external reference is called REFIN in the datasheet while all other use REFIO as an optional external reference. Update documentation to highlight this. Fixes: 3e82dfc82f38 ("docs: iio: new docs for ad7380 driver") Signed-off-by: Julien Stephan Reviewed-by: David Lechner --- Documentation/iio/ad7380.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Documentation/iio/ad7380.rst b/Documentation/iio/ad7380.rst index 9c784c1e652e9afc116fd206a6cdb70fa6e2adf0..6f70b49b9ef27c1ac32acaefecd= 1146e5c8bd6cc 100644 --- a/Documentation/iio/ad7380.rst +++ b/Documentation/iio/ad7380.rst @@ -41,13 +41,22 @@ supports only 1 SDO line. Reference voltage ----------------- =20 -2 possible reference voltage sources are supported: +ad7380-4 +~~~~~~~~ + +ad7380-4 supports only an external reference voltage (2.5V to 3.3V). It mu= st be +declared in the device tree as ``refin-supply``. + +All other devices from ad738x family +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +All other devices from ad738x support 2 possible reference voltage sources: =20 - Internal reference (2.5V) - External reference (2.5V to 3.3V) =20 The source is determined by the device tree. If ``refio-supply`` is presen= t, -then the external reference is used, else the internal reference is used. +then it is used as external reference, else the internal reference is used. =20 Oversampling and resolution boost --------------------------------- --=20 2.47.0