summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoy Cho <joy.cho@hardkernel.com>2020-09-24 09:14:12 +0300
committerJoy Cho <joy.cho@hardkernel.com>2020-12-02 10:31:09 +0300
commiteb994d3c167307247967c61c6c317cd20a65dd14 (patch)
tree86c4d19808a6ad2a7825a7dbcae10ddfa61ef4c7
parentddc53eb50c4c755f176dfb75fce49feaa3ba7480 (diff)
downloadu-boot-eb994d3c167307247967c61c6c317cd20a65dd14.tar.xz
ODROID-GO3: Support OGA Auto Test
Change-Id: I1b800545bc63e4aec548fe863c7b7c0a8865f63e
-rw-r--r--arch/arm/dts/odroidgo3-kernel.dts16
-rw-r--r--board/rockchip/odroidgo3/odroidgo3.c13
-rw-r--r--cmd/odroidtest.c538
-rw-r--r--cmd/odroidtest.h45
-rw-r--r--configs/odroidgo3-spi_defconfig2
-rw-r--r--configs/odroidgo3_defconfig2
6 files changed, 563 insertions, 53 deletions
diff --git a/arch/arm/dts/odroidgo3-kernel.dts b/arch/arm/dts/odroidgo3-kernel.dts
index bc4998a34e..3d9d57d65d 100644
--- a/arch/arm/dts/odroidgo3-kernel.dts
+++ b/arch/arm/dts/odroidgo3-kernel.dts
@@ -34,6 +34,22 @@
status = "okay";
};
+ /*
+ *** ODROIDGO3-Advance Switch layoout ***
+ |------------------------------------------------|
+ | sw15 sw21 sw10 sw9 sw20 sw16 |
+ |------------------------------------------------|
+ | sw19 sw22 |
+ | |-------------------| |
+ | sw1 | | sw8 |
+ | sw3 sw4 | | sw7 sw5 |
+ | sw2 | LCD Display | sw6 |
+ | | | |
+ | | | |
+ | |-------------------| |
+ | sw11 sw12 | sd-slot | sw13 sw14 |
+ |-------------------| |------------------|
+ */
keys: gpio-keys {
compatible = "gpio-keys";
status = "okay";
diff --git a/board/rockchip/odroidgo3/odroidgo3.c b/board/rockchip/odroidgo3/odroidgo3.c
index 696bed93c3..5df3caeea3 100644
--- a/board/rockchip/odroidgo3/odroidgo3.c
+++ b/board/rockchip/odroidgo3/odroidgo3.c
@@ -52,6 +52,12 @@ int board_check_autotest(void)
return 0;
}
+void board_run_autotest(void)
+{
+ run_command("odroidtest all", 0);
+ odroid_wait_pwrkey();
+}
+
#define GRF_BASE 0xff140000
void board_debug_uart2m1(void)
{
@@ -102,7 +108,7 @@ void board_init_switch_gpio(void)
rk_clrsetreg(&grf->gpio1b_p, 0xff00, 0x5500);
rk_clrsetreg(&grf->gpio1a_p, 0xfcc0, 0x5440);
rk_clrsetreg(&grf->gpio2a_p, 0xffff, 0x5555);
- rk_clrsetreg(&grf->gpio3b_p, 0xC030, 0x4010);
+ rk_clrsetreg(&grf->gpio3b_p, 0xC33C, 0x4114);
}
void board_check_mandatory_files(void)
@@ -160,6 +166,11 @@ int rk_board_late_init(void)
lcd_printf(0, 27, 1, " %s", U_BOOT_VERSION);
lcd_printf(0, 28, 1, " %s %s", U_BOOT_DATE, U_BOOT_TIME);
+ if (!board_check_autotest()) {
+ board_run_autotest();
+ return 0;
+ }
+
/* check sd card and es launcher */
board_check_mandatory_files();
diff --git a/cmd/odroidtest.c b/cmd/odroidtest.c
index cab6fcd693..581756ecd0 100644
--- a/cmd/odroidtest.c
+++ b/cmd/odroidtest.c
@@ -6,14 +6,21 @@
#include "odroidtest.h"
+#ifdef CONFIG_TARGET_ODROIDGO3
+static int yoffs = 4;
+#else
+static int yoffs = 0;
+#endif
+
static int do_odroidtest_all(cmd_tbl_t * cmdtp, int flag,
int argc, char * const argv[]);
-int wait_key_event(void)
+int wait_key_event(bool timeout)
{
struct udevice *dev;
struct dm_key_uclass_platdata *key;
int evt;
+ unsigned int cnt = 15;
while (!ctrlc()) {
for (uclass_first_device(UCLASS_KEY, &dev);
@@ -21,7 +28,6 @@ int wait_key_event(void)
uclass_next_device(&dev)) {
key = dev_get_uclass_platdata(dev);
evt = key_read(key->code);
-
if (evt == KEY_PRESS_DOWN) {
printf("'%s [%d]' key pressed...\n",
key->name, key->code);
@@ -32,16 +38,355 @@ int wait_key_event(void)
lcd_setbg_color("black");
lcd_clear();
lcd_setfg_color("white");
- lcd_printf(0, 10, 1, "Power key pressed... system will shut down.");
+ lcd_printf(0, 10 + yoffs, 1, "Power key pressed... system will shut down.");
mdelay(500);
run_command("poweroff", 0);
}
+
+ if (timeout == true && cnt == 0)
+ return -1;
+
+ cnt--;
}
}
return 0;
}
+#ifdef CONFIG_TARGET_ODROIDGO3
+/* adc mux controls */
+#define GPIO_ADCMUX_EN 109 /* GPIO3_B5 */
+#define GPIO_ADCMUX_SEL_A 107 /* GPIO3_B3 */
+#define GPIO_ADCMUX_SEL_B 104 /* GPIO3_B0 */
+
+#define NUM_ADC_CH 4
+#define ADC_RIGHT_Y 0
+#define ADC_RIGHT_X 1
+#define ADC_LEFT_Y 2
+#define ADC_LEFT_X 3
+
+struct key_adc {
+ unsigned int center;
+ unsigned int value;
+};
+
+void adc_draw_key_arrays(struct key_adc *adcs, int key_idx)
+{
+ int i;
+ char cmd[16];
+
+ lcd_setfg_color("yellow");
+
+ /* center */
+ sprintf(cmd, "X %d", adcs[ADC_RIGHT_X].center);
+ lcd_printf(599, 10, 0, cmd);
+ sprintf(cmd, "Y %d", adcs[ADC_RIGHT_Y].center);
+ lcd_printf(599, 12, 0, cmd);
+
+ sprintf(cmd, "X %d", adcs[ADC_LEFT_X].center);
+ lcd_printf(184, 10, 0, cmd);
+ sprintf(cmd, "Y %d", adcs[ADC_LEFT_Y].center);
+ lcd_printf(184, 12, 0, cmd);
+
+ /* value */
+ sprintf(cmd, "X %d ",
+ (int)adcs[ADC_RIGHT_X].value - adcs[ADC_RIGHT_X].center);
+ lcd_printf(599, 18, 0, cmd);
+ sprintf(cmd, "Y %d ",
+ (int)adcs[ADC_RIGHT_Y].value - adcs[ADC_RIGHT_Y].center);
+ lcd_printf(599, 20, 0, cmd);
+
+ sprintf(cmd, "X %d ",
+ (int)adcs[ADC_LEFT_X].value - adcs[ADC_LEFT_X].center);
+ lcd_printf(184, 18, 0, cmd);
+ sprintf(cmd, "Y %d ",
+ (int)adcs[ADC_LEFT_Y].value - adcs[ADC_LEFT_Y].center);
+ lcd_printf(184, 20, 0, cmd);
+
+ for (i = 0; i < 8; i++) {
+ if (adckeys[i].chk) {
+ if (i != key_idx)
+ lcd_setfg_color("green");
+ else
+ lcd_setfg_color("blue");
+ }
+ else
+ lcd_setfg_color("red");
+
+ lcd_printf(adckeys[i].x, adckeys[i].y,
+ 0, adckeys[i].name);
+ }
+
+ mdelay(200);
+ lcd_setfg_color("green");
+ lcd_printf(adckeys[key_idx].x, adckeys[key_idx].y,
+ 0, adckeys[key_idx].name);
+}
+
+int adc_amux_select(int channel)
+{
+ /* enable mux */
+ gpio_set_value(GPIO_ADCMUX_EN, 0);
+
+ switch(channel) {
+ case ADC_RIGHT_Y: /* Right Y */
+ gpio_set_value(GPIO_ADCMUX_SEL_A, 0);
+ gpio_set_value(GPIO_ADCMUX_SEL_B, 0);
+ break;
+ case ADC_RIGHT_X: /* Right X */
+ gpio_set_value(GPIO_ADCMUX_SEL_A, 0);
+ gpio_set_value(GPIO_ADCMUX_SEL_B, 1);
+ break;
+ case ADC_LEFT_Y: /* Left Y */
+ gpio_set_value(GPIO_ADCMUX_SEL_A, 1);
+ gpio_set_value(GPIO_ADCMUX_SEL_B, 0);
+ break;
+ case ADC_LEFT_X: /* Left X */
+ gpio_set_value(GPIO_ADCMUX_SEL_A, 1);
+ gpio_set_value(GPIO_ADCMUX_SEL_B, 1);
+ break;
+ default:
+ /* disable adcmux */
+ gpio_set_value(GPIO_ADCMUX_EN, 1);
+ return -1;
+ }
+
+ mdelay(50);
+
+ return 0;
+}
+
+#define ADC_CENTER_CHECK_COUNT 5
+int adc_get_center(struct key_adc *adc, int adc_ch)
+{
+ int i = 0;
+ unsigned int val;
+
+ adc->center = 0;
+
+ adc_amux_select(adc_ch);
+
+ while (i < ADC_CENTER_CHECK_COUNT) {
+ if (adc_channel_single_shot("saradc", 1, &val)) {
+ printf("adc_channel_single_shot fail!\n");
+ return CMD_RET_FAILURE;
+ }
+
+ adc->center += val;
+
+ mdelay(50);
+ i++;
+ }
+
+ adc->center /= ADC_CENTER_CHECK_COUNT;
+
+ return CMD_RET_SUCCESS;
+}
+
+int adc_read_value(struct key_adc *adc, int adc_ch)
+{
+ adc_amux_select(adc_ch);
+
+ if (adc_channel_single_shot("saradc", 1, &adc->value)) {
+ printf("adc_channel_single_shot fail!\n");
+ return CMD_RET_FAILURE;
+ }
+
+ return CMD_RET_SUCCESS;
+}
+
+#define ADC_CHECK_OFFSET 100
+static int do_odroidtest_adc(cmd_tbl_t * cmdtp, int flag,
+ int argc, char * const argv[])
+{
+ struct udevice *dev;
+ struct key_adc adcs[NUM_ADC_CH];
+
+ int i;
+ int center_x, center_y;
+ int val_x, val_y;
+ int key;
+ int key_idx = -1;
+
+ if (uclass_get_device(UCLASS_ADC, 0, &dev))
+ return CMD_RET_FAILURE;
+
+ /* init adcs arrays */
+ memset(adcs, 0, sizeof(adcs));
+
+ /* draw background */
+ lcd_setbg_color("black");
+ lcd_clear();
+ lcd_setfg_color("white");
+ lcd_printf(0, 1, 1, "[ ADC KEY TEST ]");
+
+ /* calibration preparation */
+ lcd_printf(0, 8, 1, "For the Accuracy of Analog Joysticks Test,");
+ lcd_printf(0, 10, 1, "Calibration will be Run First.");
+ mdelay(1000);
+ lcd_setfg_color("red");
+ lcd_printf(0, 14, 1, "DO NOT Control Analog Joysticks During Calibration.");
+ mdelay(1000);
+ lcd_setfg_color("white");
+ lcd_printf(0, 18, 1, "Now, Press Any Button to Start.");
+ lcd_printf(0, 20, 1, "Then, Calibration will Start in 2 Seconds.");
+ mdelay(500);
+
+ key = wait_key_event(false);
+
+ lcd_printf(0, 22, 1, "... ");
+ mdelay(400);
+ lcd_printf(0, 22, 1, "...... ");
+ mdelay(400);
+ lcd_printf(0, 22, 1, "......... ");
+ mdelay(400);
+ lcd_printf(0, 22, 1, ".............");
+ mdelay(400);
+
+ /* start calibration */
+ lcd_clear();
+ lcd_setfg_color("white");
+ lcd_printf(0, 1, 1, "[ ADC KEY TEST ]");
+ lcd_printf(0, 14, 1, "Calibration Starts...");
+ lcd_printf(0, 16, 1, "It may take 1 or 2 seconds.");
+
+ gpio_request(GPIO_ADCMUX_EN, "adcmux_en");
+ gpio_direction_output(GPIO_ADCMUX_EN, 1); /* default disable */
+ gpio_request(GPIO_ADCMUX_SEL_A, "adcmux_sel_a");
+ gpio_direction_output(GPIO_ADCMUX_SEL_A, 0);
+ gpio_request(GPIO_ADCMUX_SEL_B, "adcmux_sel_b");
+ gpio_direction_output(GPIO_ADCMUX_SEL_B, 0);
+
+ for (i = 0; i < NUM_ADC_CH; i++) {
+ if (adc_get_center(&adcs[i], i))
+ return CMD_RET_FAILURE;
+ }
+
+ mdelay(500);
+ lcd_printf(0, 14, 1, " Calibration Done ! ");
+ lcd_printf(0, 16, 1, "Press Any Button to Start Analog Joysticks Test.");
+ mdelay(500);
+
+ key = wait_key_event(false);
+ mdelay(1000);
+
+ /* clear background */
+ lcd_clear();
+ lcd_setfg_color("white");
+ lcd_printf(0, 1, 1, "[ ADC KEY TEST ]");
+ lcd_setfg_color("grey");
+ lcd_printf(0, 26, 1, "F3+F6 press to exit ADC KEY test");
+ lcd_printf(0, 28, 1, "Long press on PWR key to turn off power");
+
+ adc_draw_key_arrays(adcs, key_idx);
+
+ while (1) {
+ /* LEFT ADC */
+ for (i = 2; i < 4; i++) {
+ if (adc_read_value(&adcs[i], i))
+ return CMD_RET_FAILURE;
+ }
+
+ center_x = adcs[ADC_LEFT_X].center;
+ center_y = adcs[ADC_LEFT_Y].center;
+ val_x = adcs[ADC_LEFT_X].value;
+ val_y = adcs[ADC_LEFT_Y].value;
+
+ debug("[LEFT]center x %d y %d / value x %d, y %d ",
+ center_x, center_y,
+ val_x, val_y);
+
+ /* WEST */
+ if (val_x < center_x - ADC_CHECK_OFFSET) {
+ if (!adckeys[0].chk)
+ adckeys[0].chk = 1;
+ key_idx = 0;
+ /* EAST */
+ } else if (val_x > center_x + ADC_CHECK_OFFSET) {
+ if (!adckeys[1].chk)
+ adckeys[1].chk = 1;
+ key_idx = 1;
+ /* NORTH */
+ } else if (val_y < center_y - ADC_CHECK_OFFSET) {
+ if (!adckeys[2].chk)
+ adckeys[2].chk = 1;
+ key_idx = 2;
+ /* SOUTH */
+ } else if (val_y > center_y + ADC_CHECK_OFFSET) {
+ if (!adckeys[3].chk)
+ adckeys[3].chk = 1;
+ key_idx = 3;
+ }
+
+ for (i = 0; i < 3; i++) {
+ if (adc_read_value(&adcs[i], i))
+ return CMD_RET_FAILURE;
+ }
+
+ /* RIGHT ADC */
+ center_x = adcs[ADC_RIGHT_X].center;
+ center_y = adcs[ADC_RIGHT_Y].center;
+ val_x = adcs[ADC_RIGHT_X].value;
+ val_y = adcs[ADC_RIGHT_Y].value;
+
+ debug("[RIGHT]center x %d y %d / value x %d, y %d\n",
+ center_x, center_y,
+ val_x, val_y);
+
+ /* WEST */
+ if (val_x < center_x - ADC_CHECK_OFFSET) {
+ if (!adckeys[4].chk)
+ adckeys[4].chk = 1;
+ key_idx = 4;
+ /* EAST */
+ } else if (val_x > center_x + ADC_CHECK_OFFSET) {
+ if (!adckeys[5].chk)
+ adckeys[5].chk = 1;
+ key_idx = 5;
+ /* NORTH */
+ } else if (val_y < center_y - ADC_CHECK_OFFSET) {
+ if (!adckeys[6].chk)
+ adckeys[6].chk = 1;
+ key_idx = 6;
+ /* SOUTH */
+ } else if (val_y > center_y + ADC_CHECK_OFFSET) {
+ if (!adckeys[7].chk)
+ adckeys[7].chk = 1;
+ key_idx = 7;
+ }
+
+ adc_draw_key_arrays(adcs, key_idx);
+ key_idx = -1;
+ mdelay(200);
+
+ /* termination using F3+F6 */
+ key = wait_key_event(true);
+ if ((key == BTN_TRIGGER_HAPPY3) || (key == BTN_TRIGGER_HAPPY6)) {
+ if(!run_command("gpio input C2", 0)
+ && !run_command("gpio input C5", 0)) {
+ printf("Got termination key!\n");
+ break;
+ }
+ }
+ }
+
+ lcd_setfg_color("white");
+ lcd_printf(0, 22, 1, "ADC KEY TEST TERMINATED!");
+
+ for (i = 0; i < 8; i++)
+ adckeys[i].chk = 0;
+
+ mdelay(1000);
+
+ gpio_free(GPIO_ADCMUX_EN);
+ gpio_free(GPIO_ADCMUX_SEL_A);
+ gpio_free(GPIO_ADCMUX_SEL_B);
+
+ return CMD_RET_SUCCESS;
+}
+
+#else /* CONFIG_TARGET_ODROIDGO3 */
+
void adc_draw_key_arrays(void)
{
int i;
@@ -164,7 +509,7 @@ static int do_odroidtest_adc(cmd_tbl_t * cmdtp, int flag,
}
lcd_setfg_color("white");
- lcd_printf(0, 18, 1, "ADC KEY TEST PASS!");
+ lcd_printf(0, 18 + yoffs, 1, "ADC KEY TEST PASS!");
for (i = 0; i < 4; i++)
adckeys[i].chk = 0;
@@ -173,11 +518,13 @@ static int do_odroidtest_adc(cmd_tbl_t * cmdtp, int flag,
return CMD_RET_SUCCESS;
}
+#endif /* CONFIG_TARGET_ODROIDGO3 */
static int do_odroidtest_backlight(cmd_tbl_t * cmdtp, int flag,
int argc, char * const argv[])
{
int loop;
+ int key;
uint period_ns, duty_ns;
u8 active[4] = {10, 30, 80, 100};
@@ -190,26 +537,58 @@ static int do_odroidtest_backlight(cmd_tbl_t * cmdtp, int flag,
lcd_clear();
lcd_setfg_color("black");
lcd_printf(0, 3, 1, "[ BACKLIGHT TEST ]");
+ lcd_printf(0, 12 + yoffs, 1, "Press any key to go on next step");
+
+ lcd_setfg_color("grey");
+ lcd_printf(0, 22 + yoffs, 1, "F3+F6 press to exit BACKLIGHT test");
+ lcd_printf(0, 24 + yoffs, 1,
+ "Long press on PWR key to turn off power");
loop = 0;
- while (loop < 4) {
+
+ lcd_setfg_color("black");
+ while (1) {
period_ns = 25000;
duty_ns = period_ns * active[loop] / 100;
printf("active percentage %d, duty_ns %d\n", active[loop], duty_ns);
-
- lcd_printf(0, 8, 1, "PERCENTAGE : %d %", active[loop]);
- lcd_printf(0, 12, 1, "Press any key to go on next step");
+ lcd_printf(0, 8 + yoffs, 1, "PERCENTAGE : %d %", active[loop]);
if(pwm_set_config(dev, 1, period_ns, duty_ns))
return CMD_RET_FAILURE;
- wait_key_event();
+ if (loop < 3)
+ loop++;
+ else
+ loop = 0;
+
+ key = wait_key_event(false);
+#ifdef CONFIG_TARGET_ODROIDGO3
+ /* termination using F3+F6 */
+ if ((key == BTN_TRIGGER_HAPPY3) || (key == BTN_TRIGGER_HAPPY6)) {
+ if(!run_command("gpio input C2", 0)
+ && !run_command("gpio input C5", 0)) {
+ printf("Got termination key!\n");
+ break;
+ }
+ }
+#else
+ /* termination using F1+F6 */
+ if ((key == BTN_TRIGGER_HAPPY1) || (key == BTN_TRIGGER_HAPPY6)) {
+ if(!run_command("gpio input C0", 0)
+ && !run_command("gpio input C5", 0)) {
+ printf("Got termination key!\n");
+ break;
+ }
+ }
+#endif
mdelay(500);
- loop++;
}
+ /* set backlight as max */
+ pwm_set_config(dev, 1, period_ns, period_ns);
+
lcd_setfg_color("black");
- lcd_printf(0, 16, 1, "BACKLIGHT TEST DONE!");
+ lcd_printf(0, 18 + yoffs, 1, "BACKLIGHT TEST TERMINATED!");
mdelay(1000);
@@ -221,15 +600,21 @@ static int do_odroidtest_lcd(cmd_tbl_t * cmdtp, int flag,
{
int loop = 0;
int ret = 0;
+ int key;
char cmd[128];
char *colors[] =
{"red", "blue", "green", "white", "black"};
- while (loop < 5) {
+ while (1) {
sprintf(cmd, "lcd setbg %s", colors[loop]);
run_command(cmd, 0);
run_command("lcd clear", 0);
+ lcd_setfg_color("grey");
+ lcd_printf(0, 22 + yoffs, 1, "F3+F6 press to exit LCD test");
+ lcd_printf(0, 24 + yoffs, 1,
+ "Long press on PWR key to turn off power");
+
if (!strcmp(colors[loop], "red"))
lcd_setfg_color("black");
else
@@ -237,18 +622,38 @@ static int do_odroidtest_lcd(cmd_tbl_t * cmdtp, int flag,
sprintf(cmd, "%s", colors[loop]);
lcd_printf(0, 4, 1, "[ LCD TEST ]");
- lcd_printf(0, 8, 1, cmd);
- lcd_printf(0, 12, 1, "Press any key to go on next step");
-
- printf("%s\n", colors[loop]);
-
- wait_key_event();
+ lcd_printf(0, 8 + yoffs, 1, cmd);
+ sprintf(cmd, "%d / 5", (loop + 1));
+ lcd_printf(0, 10 + yoffs, 1, cmd);
+ lcd_printf(0, 12 + yoffs, 1, "Press any key to go on next step");
+
+ if (loop < 4) loop++;
+ else loop = 0;
+
+ key = wait_key_event(false);
+#ifdef CONFIG_TARGET_ODROIDGO3
+ /* termination using F3+F6 */
+ if ((key == BTN_TRIGGER_HAPPY3) || (key == BTN_TRIGGER_HAPPY6)) {
+ if(!run_command("gpio input C2", 0)
+ && !run_command("gpio input C5", 0)) {
+ printf("Got termination key!\n");
+ break;
+ }
+ }
+#else
+ /* termination using F1+F6 */
+ if ((key == BTN_TRIGGER_HAPPY1) || (key == BTN_TRIGGER_HAPPY6)) {
+ if(!run_command("gpio input C0", 0)
+ && !run_command("gpio input C5", 0)) {
+ printf("Got termination key!\n");
+ break;
+ }
+ }
+#endif
mdelay(500);
- loop++;
}
- lcd_setfg_color("yellow");
- lcd_printf(0, 14, 1, "LCD TEST DONE!");
+ lcd_printf(0, 18 + yoffs, 1, "LCD TEST TERMINATED!");
mdelay(1000);
@@ -259,17 +664,15 @@ void btn_draw_key_arrays(int numkeys, int key_idx)
{
int i;
- lcd_setbg_color("black");
- lcd_clear();
-
- lcd_setfg_color("white");
- lcd_printf(0, 1, 1, "[ GPIO KEY TEST ]");
-
for (i = 0; i < numkeys; i++) {
- if ((gpiokeys[i].chk) && (i != key_idx))
- lcd_setfg_color("blue");
- else
+ if (gpiokeys[i].chk) {
+ if (i != key_idx)
+ lcd_setfg_color("green");
+ else
+ lcd_setfg_color("blue");
+ } else {
lcd_setfg_color("red");
+ }
lcd_printf(gpiokeys[i].x, gpiokeys[i].y,
0, gpiokeys[i].name);
@@ -277,17 +680,17 @@ void btn_draw_key_arrays(int numkeys, int key_idx)
mdelay(200);
- lcd_setfg_color("blue");
+ lcd_setfg_color("green");
lcd_printf(gpiokeys[key_idx].x, gpiokeys[key_idx].y,
0, gpiokeys[key_idx].name);
}
static int btn_passed;
-int btn_update_key_status(int key)
+int btn_update_key_status(int key, int numkeys)
{
int i = 0;
- while (i < NUMGPIOKEYS) {
+ while (i < numkeys) {
if (gpiokeys[i].code == key) {
if(!(gpiokeys[i].chk)) {
gpiokeys[i].chk = 1;
@@ -301,12 +704,12 @@ int btn_update_key_status(int key)
return -1;
}
-void btn_set_default(void)
+void btn_set_default(int numkeys)
{
int i;
btn_passed = 0;
- for (i = 0; i < NUMGPIOKEYS; i++)
+ for (i = 0; i < numkeys; i++)
gpiokeys[i].chk = 0;
}
@@ -316,22 +719,49 @@ static int do_odroidtest_btn(cmd_tbl_t * cmdtp, int flag,
int key, numkeys, key_idx;
const char *hwrev = env_get("hwrev");
- if (hwrev && !strcmp(hwrev, "v11"))
- numkeys = NUMGPIOKEYS;
- else
+ if (hwrev && !strcmp(hwrev, "v10"))
numkeys = NUMGPIOKEYS - 2;
+ else
+ numkeys = NUMGPIOKEYS;
+
+ /* draw background */
+ lcd_setbg_color("black");
+ lcd_clear();
+ lcd_setfg_color("white");
+ lcd_printf(0, 1, 1, "[ GPIO KEY TEST ]");
+
+ lcd_setfg_color("grey");
+ lcd_printf(0, 22 + yoffs, 1, "F3+F6 press to exit BUTTON test");
+ lcd_printf(0, 24 + yoffs, 1,
+ "Long press on PWR key to turn off power");
+
+ /* key initialization */
key_idx = -1;
btn_draw_key_arrays(numkeys, key_idx);
mdelay(2000);
while (1) {
- key = wait_key_event();
- key_idx = btn_update_key_status(key);
+ key = wait_key_event(false);
+ key_idx = btn_update_key_status(key, numkeys);
+
+ /* update display */
btn_draw_key_arrays(numkeys, key_idx);
printf("key 0x%x, passed %d\n", key, btn_passed);
- /* termination using F1+F6 */
+#ifdef CONFIG_TARGET_ODROIDGO3
+ /* check termination using F3+F6 */
+ if ((key == BTN_TRIGGER_HAPPY3) || (key == BTN_TRIGGER_HAPPY6)) {
+ printf("check termination keys, key_idx %d\n", key_idx);
+
+ if(!run_command("gpio input C2", 0)
+ && !run_command("gpio input C5", 0)) {
+ printf("Got termination key!\n");
+ break;
+ }
+ }
+#else
+ /* check termination using F1+F6 */
if ((key == BTN_TRIGGER_HAPPY1) || (key == BTN_TRIGGER_HAPPY6)) {
printf("check termination keys, key_idx %d\n", key_idx);
@@ -341,15 +771,13 @@ static int do_odroidtest_btn(cmd_tbl_t * cmdtp, int flag,
break;
}
}
+#endif
}
lcd_setfg_color("white");
- if (btn_passed == numkeys)
- lcd_printf(0, 18, 1, "GPIO KEY TEST PASS!");
- else
- lcd_printf(0, 18, 1, "GPIO KEY TEST TERMINATED!");
+ lcd_printf(0, 18 + yoffs, 1, "GPIO KEY TEST TERMINATED!");
- btn_set_default();
+ btn_set_default(numkeys);
mdelay(1000);
@@ -368,6 +796,8 @@ static int do_odroidtest_all(cmd_tbl_t * cmdtp, int flag,
int argc, char * const argv[])
{
int i, ret = 0;
+ unsigned int state;
+ unsigned int delay = 5000;
for (i = 1; i < ARRAY_SIZE(cmd_sub_odroidtest); i++) {
printf("----- [ %s ] -----\n",
@@ -379,6 +809,22 @@ static int do_odroidtest_all(cmd_tbl_t * cmdtp, int flag,
lcd_clear();
lcd_setfg_color("yellow");
lcd_printf(0, 9, 1, "AUTO TEST DONE!");
+ lcd_printf(0, 16 + yoffs, 1, "wait power key...");
+
+ /* check power key */
+ while (delay) {
+ state = key_read(KEY_POWER);
+ if (state == KEY_PRESS_DOWN)
+ break;
+
+ mdelay(25);
+ delay -= 25;
+ }
+
+ printf("power key long pressed...\n");
+ lcd_printf(0, 18 + yoffs, 1, "%s", "power off...");
+ mdelay(500);
+ run_command("poweroff", 0);
return ret;
}
diff --git a/cmd/odroidtest.h b/cmd/odroidtest.h
index 8f60188904..733d7b2e48 100644
--- a/cmd/odroidtest.h
+++ b/cmd/odroidtest.h
@@ -15,8 +15,6 @@
#include <odroidgo2_status.h>
#include <rockchip_display_cmds.h>
-#define NUMGPIOKEYS 18
-
struct key_arrays {
const char * name;
u32 code;
@@ -25,7 +23,46 @@ struct key_arrays {
u32 chk; /* 0:red, 1:blue */
};
-struct key_arrays gpiokeys[NUMGPIOKEYS] = {
+#ifdef CONFIG_TARGET_ODROIDGO3
+#define NUMGPIOKEYS 20
+static struct key_arrays gpiokeys[NUMGPIOKEYS] = {
+ {"[sw1]", BTN_DPAD_UP, 170, 13, 0},
+ {"[sw2]", BTN_DPAD_DOWN, 170, 17, 0},
+ {"[sw3]", BTN_DPAD_LEFT, 85, 15, 0},
+ {"[sw4]", BTN_DPAD_RIGHT, 255, 15, 0},
+ {"[sw5]", BTN_EAST, 702, 15, 0},
+ {"[sw6]", BTN_SOUTH, 617, 17, 0},
+ {"[sw7]", BTN_WEST, 532, 15, 0},
+ {"[sw8]", BTN_NORTH, 617, 13, 0},
+ {"[sw9]", KEY_VOLUMEUP, 457, 5, 0},
+ {"[sw10]", KEY_VOLUMEDOWN, 350, 5, 0},
+ {"[sw11]", BTN_TRIGGER_HAPPY3, 85, 25, 0},
+ {"[sw12]", BTN_TRIGGER_HAPPY4, 170, 25, 0},
+ {"[sw13]", BTN_TRIGGER_HAPPY5, 617, 25, 0},
+ {"[sw14]", BTN_TRIGGER_HAPPY6, 702, 25, 0},
+ {"[sw15]", BTN_TL, 85, 5, 0},
+ {"[sw16]", BTN_TR, 702, 5, 0},
+ {"[sw20]", BTN_TR2, 617, 5, 0},
+ {"[sw21]", BTN_TL2, 170, 5, 0},
+ {"[sw19]", BTN_TRIGGER_HAPPY1, 260, 9, 0},
+ {"[sw22]", BTN_TRIGGER_HAPPY2, 532, 9, 0},
+};
+
+struct key_arrays adckeys[8] = {
+ /* LEFT */
+ {"[WEST]", 0, 85, 11, 0},
+ {"[EAST]", 0, 275, 11, 0},
+ {"[NORTH]", 0, 180, 6, 0},
+ {"[SOUTH]", 0, 180, 16, 0},
+ /* RIGHT */
+ {"[WEST]", 0, 500, 11, 0},
+ {"[EAST]", 0, 690, 11, 0},
+ {"[NORTH]", 0, 595, 6, 0},
+ {"[SOUTH]", 0, 595, 16, 0},
+};
+#else
+#define NUMGPIOKEYS 18
+static struct key_arrays gpiokeys[NUMGPIOKEYS] = {
{"[sw1]", BTN_DPAD_UP, 96, 7, 0},
{"[sw2]", BTN_DPAD_DOWN, 96, 11, 0},
{"[sw3]", BTN_DPAD_LEFT, 48, 9, 0},
@@ -52,5 +89,5 @@ struct key_arrays adckeys[4] = {
{"[UP]", 0, 220, 4, 0},
{"[DOWN]", 0, 218, 14, 0},
};
-
+#endif
#endif /* _CMD_ODROIDTEST_ */
diff --git a/configs/odroidgo3-spi_defconfig b/configs/odroidgo3-spi_defconfig
index cd12fec482..48ffd94ec5 100644
--- a/configs/odroidgo3-spi_defconfig
+++ b/configs/odroidgo3-spi_defconfig
@@ -644,7 +644,7 @@ CONFIG_CMD_FS_GENERIC=y
CONFIG_CMD_ODROID_ADC=y
CONFIG_CMD_ODROID_CFGLOAD=y
CONFIG_CMD_ODROID_BATTERY=y
-# CONFIG_CMD_ODROID_TEST is not set
+CONFIG_CMD_ODROID_TEST=y
CONFIG_CMD_ODROID_HWREV=y
#
diff --git a/configs/odroidgo3_defconfig b/configs/odroidgo3_defconfig
index 64fe8fd868..2b0fb34b44 100644
--- a/configs/odroidgo3_defconfig
+++ b/configs/odroidgo3_defconfig
@@ -644,7 +644,7 @@ CONFIG_CMD_FS_GENERIC=y
CONFIG_CMD_ODROID_ADC=y
CONFIG_CMD_ODROID_CFGLOAD=y
CONFIG_CMD_ODROID_BATTERY=y
-# CONFIG_CMD_ODROID_TEST is not set
+CONFIG_CMD_ODROID_TEST=y
CONFIG_CMD_ODROID_HWREV=y
#