rk添加uboot按键功能

rk平台默认支持adc音量键进入loader模式,对于使用gpio按键的设备,需要添加自定义按键功能

不hack源码,直接在板级实现

u-boot/board/rockchip/evb_rk3562/evb_rk3562.c

添加实现

#include <asm/gpio.h> #define LOADER_KEY_GPIO 4 /* GPIO0_A4 */ static int loader_key_pressed(void) { int ret; int value; ret = gpio_request(LOADER_KEY_GPIO, "loader_key"); if (ret) return 0; ret = gpio_direction_input(LOADER_KEY_GPIO); if (ret) { gpio_free(LOADER_KEY_GPIO); return 0; } value = gpio_get_value(LOADER_KEY_GPIO); gpio_free(LOADER_KEY_GPIO); return value == 0; } int rk_board_late_init(void) { if (loader_key_pressed()) { printf("enter loader!\n"); env_set("preboot", "setenv preboot; download"); } return 0; }