nmhw21: add factory reset/recovery boot

- check reset button at startup
- short press (2s) invokes factory reset.
   - adds factory-reset to bootline
- long press (12s) invokes recovery boot in the following order:
   1. pxe boot
   2. tftp recovery boot

BugzID: 55039
This commit is contained in:
Rene Straub 2019-01-04 18:23:07 +01:00
parent 36d526cc87
commit 84189ee455
1 changed files with 25 additions and 18 deletions

View File

@ -814,27 +814,36 @@ static void check_fct(void)
i2c_set_bus_num(old_bus);
}
#if 0
static bool get_button_state(void)
{
u8 state = 0x00;
uint8_t state = 0x00;
bool pressed = false;
int bus;
int rc;
/* TODO: Claim Bus */
(void)da9063_get_reg(PMIC_REG_STATUS_A, &state);
bus = da9063_claim_i2c_bus();
rc = da9063_get_reg(PMIC_REG_STATUS_A, &state);
da9063_release_i2c_bus(bus);
return (state & 0x01) == 0x01;
if (!rc) {
pressed = (state & 0x01) == 0x01;
}
return pressed;
}
static void blink_led(void)
{
const int pulse_width = 400*1000; /* 400ms */
/* Assumes green status LED is on */
/* Assumes status LED is orange */
udelay(pulse_width);
set_status_led(0, 0);
set_status_led(0, 0); /* Off */
ui_set_top_led(0, 0);
udelay(pulse_width);
set_status_led(0, 1);
set_status_led(1, 1); /* Orange */
ui_set_top_led(1, 1);
}
static void check_reset_button(void)
@ -869,9 +878,9 @@ static void check_reset_button(void)
char new_bootargs[512];
char *bootargs = getenv("bootargs");
if (bootargs == 0) bootargs="";
if (bootargs == 0) bootargs = "";
printf("Do factory reset during boot...\n");
puts("Do factory reset during boot...\n");
strncpy(new_bootargs, bootargs, sizeof(new_bootargs));
strncat(new_bootargs, " factory-reset", sizeof(new_bootargs));
@ -881,17 +890,12 @@ static void check_reset_button(void)
else
{
/* Boot into recovery for duration > 12s */
printf("Booting recovery image...\n");
puts("Booting recovery image...\n");
/* Set bootcmd to run recovery */
setenv("bootcmd", "run recovery");
/* set consoledev to external port */
/* setenv("consoledev", "ttyS1"); */
}
}
#endif
#endif /* !defined(CONFIG_SPL_BUILD) */
@ -961,8 +965,11 @@ int board_late_init(void)
init_gnss();
/*
* Check if a user action is requested
* - Short press: factory reset
* - Long press: recovery boot
*/
check_reset_button();
*/
set_status_led(1, 1); /* Orange */
set_indicator_led(0, 0); /* Off */