From patchwork Sat Jan 25 16:19:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Cole-Baker X-Patchwork-Id: 240106 List-Id: U-Boot discussion From: sigmaris at gmail.com (Hugh Cole-Baker) Date: Sat, 25 Jan 2020 16:19:36 +0000 Subject: [PATCH] rockchip: boot_mode: find the saradc device name Message-ID: <20200125161936.53550-1-sigmaris@gmail.com> adc_channel_single_shot() requires the full device name e.g. "saradc at 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 Reviewed-by: Kever Yang --- I previously sent this on Jan. 11 as an RFC patch, since there were no comments on it previously I guess it can just be submitted as a patch as-is. arch/arm/mach-rockchip/boot_mode.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 #include #include +#include +#include #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; }