All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rockchip: boot_mode: find the saradc device name
@ 2020-01-25 16:19 Hugh Cole-Baker
  2020-01-30  3:53 ` Kever Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Hugh Cole-Baker @ 2020-01-25 16:19 UTC (permalink / raw)
  To: u-boot

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 <sigmaris@gmail.com>
---
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 <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;
 	}
-- 
2.17.2 (Apple Git-113)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] rockchip: boot_mode: find the saradc device name
  2020-01-25 16:19 [PATCH] rockchip: boot_mode: find the saradc device name Hugh Cole-Baker
@ 2020-01-30  3:53 ` Kever Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Kever Yang @ 2020-01-30  3:53 UTC (permalink / raw)
  To: u-boot


On 2020/1/26 上午12:19, Hugh Cole-Baker wrote:
> 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 <sigmaris@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
> 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 <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;
>   	}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-30  3:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-25 16:19 [PATCH] rockchip: boot_mode: find the saradc device name Hugh Cole-Baker
2020-01-30  3:53 ` Kever Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.