Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / mach-rockchip / boot_mode.c
index 08f80bd91aae0bb39d6588acea312bc9f3349f6a..2158934159a5b997a102d2b3649352b635927a98 100644 (file)
@@ -5,8 +5,13 @@
 
 #include <common.h>
 #include <adc.h>
+#include <command.h>
+#include <env.h>
+#include <log.h>
 #include <asm/io.h>
 #include <asm/arch-rockchip/boot_mode.h>
+#include <dm/device.h>
+#include <dm/uclass.h>
 
 #if (CONFIG_ROCKCHIP_BOOT_MODE_REG == 0)
 
@@ -35,8 +40,26 @@ void set_back_to_bootrom_dnl_flag(void)
 __weak int rockchip_dnl_key_pressed(void)
 {
        unsigned int val;
+       struct udevice *dev;
+       struct uclass *uc;
+       int ret;
 
-       if (adc_channel_single_shot("saradc", 1, &val)) {
+       ret = uclass_get(UCLASS_ADC, &uc);
+       if (ret)
+               return false;
+
+       ret = -ENODEV;
+       uclass_foreach_dev(dev, uc) {
+               if (!strncmp(dev->name, "saradc", 6)) {
+                       ret = adc_channel_single_shot(dev->name, 1, &val);
+                       break;
+               }
+       }
+
+       if (ret == -ENODEV) {
+               pr_warn("%s: no saradc device found\n", __func__);
+               return false;
+       } else if (ret) {
                pr_err("%s: adc_channel_single_shot fail!\n", __func__);
                return false;
        }