summaryrefslogtreecommitdiff
path: root/arch/arm/mach-rockchip/boot_mode.c
diff options
context:
space:
mode:
authorHugh Cole-Baker <sigmaris@gmail.com>2020-01-25 16:19:36 +0000
committerKever Yang <kever.yang@rock-chips.com>2020-02-19 16:45:38 +0800
commit80b9882a6e666fe7edd7fe3e821ae6e8188fb126 (patch)
treefb61438e799915c4efe4e27baf19b6e0dacbd15f /arch/arm/mach-rockchip/boot_mode.c
parenta30c68945cadc6aada3f05a6864627f3ca9d6bde (diff)
rockchip: boot_mode: find the saradc device name
adc_channel_single_shot() requires the full device name e.g. "saradc@ff100000", which differs between Rockchip SoC's, but they all share the prefix "saradc"; find the ADC device with this name prefix and use its full name. Signed-off-by: Hugh Cole-Baker <sigmaris@gmail.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Diffstat (limited to 'arch/arm/mach-rockchip/boot_mode.c')
-rw-r--r--arch/arm/mach-rockchip/boot_mode.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/arch/arm/mach-rockchip/boot_mode.c b/arch/arm/mach-rockchip/boot_mode.c
index 08f80bd91a..7598fe4c43 100644
--- a/arch/arm/mach-rockchip/boot_mode.c
+++ b/arch/arm/mach-rockchip/boot_mode.c
@@ -7,6 +7,8 @@
#include <adc.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 +37,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;
}