* [PATCH v2] adc: rockchip-saradc: add support for getting reference voltage value
@ 2022-02-04 20:16 Peter Cai
2022-02-07 20:22 ` Simon Glass
2022-03-14 8:07 ` Kever Yang
0 siblings, 2 replies; 3+ messages in thread
From: Peter Cai @ 2022-02-04 20:16 UTC (permalink / raw)
To: u-boot; +Cc: Peter Cai, John Keeping, Simon Glass, Philipp Tomsich, Kever Yang
Mirroring commit 97ab802aa36f ("adc: meson-saradc: add support for
getting reference voltage value") for meson-saradc, this adds support
for getting the "vref-supply" regulator and register it as the ADC's
reference voltage regulator, so clients can translate sampled ADC values
to voltage.
Signed-off-by: Peter Cai <peter@typeblog.net>
Reviewed-by: John Keeping <john@metanate.com>
Tested-by: John Keeping <john@metanate.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Kever Yang <kever.yang@rock-chips.com>
---
Changes in v2:
- Reordered local variables in `rockchip_saradc_probe`.
---
drivers/adc/rockchip-saradc.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c
index e464d33f2267..4007188133c8 100644
--- a/drivers/adc/rockchip-saradc.c
+++ b/drivers/adc/rockchip-saradc.c
@@ -13,6 +13,7 @@
#include <asm/io.h>
#include <linux/bitops.h>
#include <linux/err.h>
+#include <power/regulator.h>
#define SARADC_CTRL_CHN_MASK GENMASK(2, 0)
#define SARADC_CTRL_POWER_CTRL BIT(3)
@@ -100,8 +101,11 @@ int rockchip_saradc_stop(struct udevice *dev)
int rockchip_saradc_probe(struct udevice *dev)
{
+ struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev);
struct rockchip_saradc_priv *priv = dev_get_priv(dev);
+ struct udevice *vref;
struct clk clk;
+ int vref_uv;
int ret;
ret = clk_get_by_index(dev, 0, &clk);
@@ -114,6 +118,23 @@ int rockchip_saradc_probe(struct udevice *dev)
priv->active_channel = -1;
+ ret = device_get_supply_regulator(dev, "vref-supply", &vref);
+ if (ret) {
+ printf("can't get vref-supply: %d\n", ret);
+ return ret;
+ }
+
+ vref_uv = regulator_get_value(vref);
+ if (vref_uv < 0) {
+ printf("can't get vref-supply value: %d\n", vref_uv);
+ return vref_uv;
+ }
+
+ /* VDD supplied by common vref pin */
+ uc_pdata->vdd_supply = vref;
+ uc_pdata->vdd_microvolts = vref_uv;
+ uc_pdata->vss_microvolts = 0;
+
return 0;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] adc: rockchip-saradc: add support for getting reference voltage value
2022-02-04 20:16 [PATCH v2] adc: rockchip-saradc: add support for getting reference voltage value Peter Cai
@ 2022-02-07 20:22 ` Simon Glass
2022-03-14 8:07 ` Kever Yang
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2022-02-07 20:22 UTC (permalink / raw)
To: Peter Cai; +Cc: U-Boot Mailing List, John Keeping, Philipp Tomsich, Kever Yang
On Fri, 4 Feb 2022 at 13:16, Peter Cai <peter@typeblog.net> wrote:
>
> Mirroring commit 97ab802aa36f ("adc: meson-saradc: add support for
> getting reference voltage value") for meson-saradc, this adds support
> for getting the "vref-supply" regulator and register it as the ADC's
> reference voltage regulator, so clients can translate sampled ADC values
> to voltage.
>
> Signed-off-by: Peter Cai <peter@typeblog.net>
> Reviewed-by: John Keeping <john@metanate.com>
> Tested-by: John Keeping <john@metanate.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> ---
> Changes in v2:
> - Reordered local variables in `rockchip_saradc_probe`.
> ---
> drivers/adc/rockchip-saradc.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] adc: rockchip-saradc: add support for getting reference voltage value
2022-02-04 20:16 [PATCH v2] adc: rockchip-saradc: add support for getting reference voltage value Peter Cai
2022-02-07 20:22 ` Simon Glass
@ 2022-03-14 8:07 ` Kever Yang
1 sibling, 0 replies; 3+ messages in thread
From: Kever Yang @ 2022-03-14 8:07 UTC (permalink / raw)
To: Peter Cai
Cc: U-Boot-Denx, John Keeping, Simon Glass, Philipp Tomsich, Kever Yang
Hi Peter,
Peter Cai <peter@typeblog.net> 于2022年2月5日周六 21:49写道:
>
> Mirroring commit 97ab802aa36f ("adc: meson-saradc: add support for
> getting reference voltage value") for meson-saradc, this adds support
> for getting the "vref-supply" regulator and register it as the ADC's
> reference voltage regulator, so clients can translate sampled ADC values
> to voltage.
>
> Signed-off-by: Peter Cai <peter@typeblog.net>
> Reviewed-by: John Keeping <john@metanate.com>
> Tested-by: John Keeping <john@metanate.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Thanks,
- Kever
> ---
> Changes in v2:
> - Reordered local variables in `rockchip_saradc_probe`.
> ---
> drivers/adc/rockchip-saradc.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c
> index e464d33f2267..4007188133c8 100644
> --- a/drivers/adc/rockchip-saradc.c
> +++ b/drivers/adc/rockchip-saradc.c
> @@ -13,6 +13,7 @@
> #include <asm/io.h>
> #include <linux/bitops.h>
> #include <linux/err.h>
> +#include <power/regulator.h>
>
> #define SARADC_CTRL_CHN_MASK GENMASK(2, 0)
> #define SARADC_CTRL_POWER_CTRL BIT(3)
> @@ -100,8 +101,11 @@ int rockchip_saradc_stop(struct udevice *dev)
>
> int rockchip_saradc_probe(struct udevice *dev)
> {
> + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev);
> struct rockchip_saradc_priv *priv = dev_get_priv(dev);
> + struct udevice *vref;
> struct clk clk;
> + int vref_uv;
> int ret;
>
> ret = clk_get_by_index(dev, 0, &clk);
> @@ -114,6 +118,23 @@ int rockchip_saradc_probe(struct udevice *dev)
>
> priv->active_channel = -1;
>
> + ret = device_get_supply_regulator(dev, "vref-supply", &vref);
> + if (ret) {
> + printf("can't get vref-supply: %d\n", ret);
> + return ret;
> + }
> +
> + vref_uv = regulator_get_value(vref);
> + if (vref_uv < 0) {
> + printf("can't get vref-supply value: %d\n", vref_uv);
> + return vref_uv;
> + }
> +
> + /* VDD supplied by common vref pin */
> + uc_pdata->vdd_supply = vref;
> + uc_pdata->vdd_microvolts = vref_uv;
> + uc_pdata->vss_microvolts = 0;
> +
> return 0;
> }
>
> --
> 2.35.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-14 8:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 20:16 [PATCH v2] adc: rockchip-saradc: add support for getting reference voltage value Peter Cai
2022-02-07 20:22 ` Simon Glass
2022-03-14 8:07 ` Kever Yang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.