Skip to contentSkip to conversation

rockchip: boot_mode: find the saradc device name

PATCH New Hugh Cole-Baker 2 participants 2 messages Jan 25, 2020 – Jan 30, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rockchip: boot_mode: find the saradc device name

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.

---
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(-)
arch/arm/mach-rockchip/boot_mode.c +21 -1
index 08f80bd91a..7598fe4c43 100644
@@ -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;
 	}
Signature · 1 line
2.17.2 (Apple Git-113)
#1 lore raw

PATCH 1/1 rockchip: boot_mode: find the saradc device name

Quoted 6 lines · Hugh Cole-Baker

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.

Thanks,
- Kever

Quoted 49 lines

---
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(-)
arch/arm/mach-rockchip/boot_mode.c +21 -1
index 08f80bd91a..7598fe4c43 100644
@@ -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;
  	}