[U-Boot] [U-Boot, 1/3] rockchip: boot mode: parse adc channel from dts

Philipp Tomsich philipp.tomsich at theobroma-systems.com
Tue Nov 28 13:59:49 UTC 2017


+sjg

On Tue, 28 Nov 2017, Andy Yan wrote:

> Most the current rockchip based boards use adc channel
> 1 detect the download key, but there are also some
> boards like rv1108 based plaform use adc channel 0.
> So we parse the adc channel from dts if we can get
> it, otherwise we use the channel 1 as default.
>
> Signed-off-by: Andy Yan <andy.yan at rock-chips.com>
> Acked-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
> ---
>
> arch/arm/mach-rockchip/boot_mode.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-rockchip/boot_mode.c b/arch/arm/mach-rockchip/boot_mode.c
> index 942849f..49dfd39 100644
> --- a/arch/arm/mach-rockchip/boot_mode.c
> +++ b/arch/arm/mach-rockchip/boot_mode.c
> @@ -8,6 +8,9 @@
> #include <adc.h>
> #include <asm/io.h>
> #include <asm/arch/boot_mode.h>
> +#include <fdtdec.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
>
> void set_back_to_bootrom_dnl_flag(void)
> {
> @@ -26,9 +29,19 @@ void set_back_to_bootrom_dnl_flag(void)
>
> __weak int rockchip_dnl_key_pressed(void)
> {
> +	const void *blob = gd->fdt_blob;
> 	unsigned int val;
> +	int channel = 1;
> +	int node;
> +	u32 chns[2];
> +
> +	node = fdt_node_offset_by_compatible(blob, 0, "adc-keys");
> +	if (node >= 0) {
> +		if (!fdtdec_get_int_array(blob, node, "io-channels", chns, 2))
> +			channel = chns[1];
> +	}

The driver for 'adc-keys' should be a driver in drivers/input that can 
then be retrieved via DM and queried using keyboard_getc().

>
> -	if (adc_channel_single_shot("saradc", 1, &val)) {
> +	if (adc_channel_single_shot("saradc", channel, &val)) {
> 		pr_err("%s: adc_channel_single_shot fail!\n", __func__);
> 		return false;
> 	}
>


More information about the U-Boot mailing list