hw23: add shutdown on power-up when ignition is down.
BugzID: 73163 Signed-off-by: Lucien Mueller <lucien.mueller@netmodule.com>
This commit is contained in:
parent
5cdce0ed93
commit
68ad3ed097
|
|
@ -559,6 +559,51 @@ int board_mmc_get_env_dev(int devno)
|
|||
return devno;
|
||||
}
|
||||
|
||||
static void powerdown(void)
|
||||
{
|
||||
/* Final call, will not return */
|
||||
(void)da9063_set_reg(PMIC_REG_CONTROL_A, 0x00);
|
||||
|
||||
puts("ERROR: PMIC power down failed\n");
|
||||
for (;;) {}
|
||||
}
|
||||
|
||||
static void stop_if_ignition_is_off(void)
|
||||
{
|
||||
uint8_t state = 0x00;
|
||||
int ret;
|
||||
|
||||
ret = da9063_get_reg(PMIC_REG_STATUS_A, &state);
|
||||
if (ret == 0) {
|
||||
if ((state & PMIC_REG_STATUS_A_COMP1V2_MASK) == PMIC_REG_STATUS_A_COMP1V2_MASK) {
|
||||
puts("Ignition : On\n");
|
||||
}
|
||||
else {
|
||||
puts("Ignition : Off\n");
|
||||
/*
|
||||
* Ignition is off, if this is a power-on start, power down
|
||||
* as this is considered an unwanted system start.
|
||||
*/
|
||||
|
||||
/*
|
||||
* There is a chance for a race condition, when ignition is enabled
|
||||
* between the check above and here. In this case we should just reset
|
||||
* not power down.
|
||||
* Although the risk is minimal here due to the very short time interval
|
||||
* we do the check. The same logic will have to be added in other
|
||||
* components.
|
||||
*/
|
||||
ret = da9063_get_reg(PMIC_REG_EVENT_B, &state);
|
||||
if ((ret == 0) && ((state & PMIC_REG_EVENT_COMP1V2_MASK) == 0)) {
|
||||
powerdown();
|
||||
}
|
||||
else {
|
||||
reset_cpu(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void check_reset_reason(uint64_t reset_reason_shm_location)
|
||||
{
|
||||
volatile struct reset_registers* reset_regs = (struct reset_registers*)reset_reason_shm_location;
|
||||
|
|
@ -695,6 +740,10 @@ static void check_reset_reason(uint64_t reset_reason_shm_location)
|
|||
|
||||
rr_start_reason_to_str(reset_regs->sr_events, strbuf, sizeof(strbuf));
|
||||
printf("\nStart Events: %s\n", strbuf);
|
||||
|
||||
if (sys_start_event & SR_POR) {
|
||||
stop_if_ignition_is_off();
|
||||
}
|
||||
}
|
||||
|
||||
static int _bd_init(void)
|
||||
|
|
|
|||
Loading…
Reference in New Issue