]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
adc: rockchip-saradc: Use vdd-microvolts prop as fallback
authorJonas Karlman <jonas@kwiboo.se>
Thu, 17 Oct 2024 20:00:26 +0000 (20:00 +0000)
committerKever Yang <kever.yang@rock-chips.com>
Sat, 26 Oct 2024 02:46:48 +0000 (10:46 +0800)
Change to use vdd-microvolts prop value as voltage reference when the
supply regulator is missing or when DM_REGULATOR=n is used.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/adc/rockchip-saradc.c

index f6832ab30731463546917204863b791c54136a92..7cf9735f60d087a8ee350dfd5163b98aa8922db8 100644 (file)
@@ -241,7 +241,7 @@ 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 udevice *vref = NULL;
        struct clk clk;
        int vref_uv;
        int ret;
@@ -259,7 +259,7 @@ int rockchip_saradc_probe(struct udevice *dev)
        priv->active_channel = -1;
 
        ret = device_get_supply_regulator(dev, "vref-supply", &vref);
-       if (ret) {
+       if (ret && uc_pdata->vdd_microvolts <= 0) {
                printf("can't get vref-supply: %d\n", ret);
                return ret;
        }
@@ -267,7 +267,10 @@ int rockchip_saradc_probe(struct udevice *dev)
        if (priv->reset)
                rockchip_saradc_reset_controller(priv->reset);
 
-       vref_uv = regulator_get_value(vref);
+       if (vref)
+               vref_uv = regulator_get_value(vref);
+       else
+               vref_uv = uc_pdata->vdd_microvolts;
        if (vref_uv < 0) {
                printf("can't get vref-supply value: %d\n", vref_uv);
                return vref_uv;