mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
arm: mvebu: turris_omnia: add RESET button handling
There is a Factory RESET button on the back side of the Turris Omnia router. When user presses this button before powering the device up and keeps it pressed, the microcontroller prevents the main CPU from booting and counts how long the RESET button is being pressed (and indicates this by lighting up front LEDs). The idea behind this is that the user can boot the device into several Factory RESET modes. This patch adds support for U-Boot to read into which Factory RESET mode the user booted the device. The value is an integer stored into the omnia_reset environment variable. It is 0 if the button was not pressed at all during power up, otherwise it is the number identifying the Factory RESET mode. This patch also changes bootcmd to a special hardcoded value if Factory RESET button was pressed during device powerup. This special bootcmd value sets the colors of all the LEDs on the front panel to green and then tries to load the rescue image from the SPI flash memory and boot it. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Signed-off-by: Stefan Roese <sr@denx.de>
This commit is contained in:
parent
2151926b08
commit
539f0242f3
2 changed files with 39 additions and 0 deletions
|
@ -116,6 +116,7 @@ config TARGET_DB_88F6820_AMC
|
|||
config TARGET_TURRIS_OMNIA
|
||||
bool "Support Turris Omnia"
|
||||
select 88F6820
|
||||
select BOARD_LATE_INIT
|
||||
select DM_I2C
|
||||
select I2C_MUX
|
||||
select I2C_MUX_PCA954x
|
||||
|
|
|
@ -328,6 +328,43 @@ static int set_regdomain(void)
|
|||
printf("Regdomain set to %s\n", rd);
|
||||
return env_set("regdomain", rd);
|
||||
}
|
||||
|
||||
/*
|
||||
* default factory reset bootcommand on Omnia first sets all the front LEDs
|
||||
* to green and then tries to load the rescue image from SPI flash memory and
|
||||
* boot it
|
||||
*/
|
||||
#define OMNIA_FACTORY_RESET_BOOTCMD \
|
||||
"i2c dev 2; " \
|
||||
"i2c mw 0x2a.1 0x3 0x1c 1; " \
|
||||
"i2c mw 0x2a.1 0x4 0x1c 1; " \
|
||||
"mw.l 0x01000000 0x00ff000c; " \
|
||||
"i2c write 0x01000000 0x2a.1 0x5 4 -s; " \
|
||||
"setenv bootargs \"$bootargs omniarescue=$omnia_reset\"; " \
|
||||
"sf probe; " \
|
||||
"sf read 0x1000000 0x100000 0x700000; " \
|
||||
"bootm 0x1000000; " \
|
||||
"bootz 0x1000000"
|
||||
|
||||
static void handle_reset_button(void)
|
||||
{
|
||||
int ret;
|
||||
u8 reset_status;
|
||||
|
||||
ret = omnia_mcu_read(CMD_GET_RESET, &reset_status, 1);
|
||||
if (ret) {
|
||||
printf("omnia_mcu_read failed: %i, reset status unknown!\n",
|
||||
ret);
|
||||
return;
|
||||
}
|
||||
|
||||
env_set_ulong("omnia_reset", reset_status);
|
||||
|
||||
if (reset_status) {
|
||||
printf("RESET button was pressed, overwriting bootcmd!\n");
|
||||
env_set("bootcmd", OMNIA_FACTORY_RESET_BOOTCMD);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int board_early_init_f(void)
|
||||
|
@ -373,6 +410,7 @@ int board_late_init(void)
|
|||
{
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
set_regdomain();
|
||||
handle_reset_button();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue