ipq9574: power cycle SDX during IPQ crash

This patch adds support to power cycle the SDX device during
the IPQ crash scenario by toggling the full_power_on and reset
gpios.

Change-Id: Ifac2db5480c13456ef50b6d779691c5bf41f21b2
Signed-off-by: Nitheesh Sekar <quic_nsekar@quicinc.com>
This commit is contained in:
Nitheesh Sekar 2023-02-03 21:04:47 +05:30 committed by Gerrit - the friendly Code Review server
parent 236b230dda
commit e520f6cd3a
4 changed files with 46 additions and 2 deletions

View file

@ -248,4 +248,9 @@
};
};
};
sdx-gpio {
power_on = <40>;
reset = <47>;
};
};

View file

@ -38,4 +38,9 @@
};
/delete-node/ pci@18000000;
sdx-gpio {
power_on = <40>;
reset = <47>;
};
};

View file

@ -1191,6 +1191,35 @@ void reset_cpu(unsigned long a)
while (1);
}
void power_cycle_sdx(void)
{
int node, power_on_gpio = -1, reset_gpio = -1;
unsigned int *power_on_gpio_base, *reset_gpio_base;
unsigned int machid = gd->bd->bi_arch_number;
if (machid != 0x8050201 && machid != 0x8051201)
return;
node = fdt_path_offset(gd->fdt_blob, "/sdx-gpio");
if (node >= 0)
power_on_gpio = fdtdec_get_uint(gd->fdt_blob, node, "power_on", -1);
node = fdt_path_offset(gd->fdt_blob, "/sdx-gpio");
if (node >= 0)
reset_gpio = fdtdec_get_uint(gd->fdt_blob, node, "reset", -1);
if (power_on_gpio >= 0 && reset_gpio >= 0) {
power_on_gpio_base = (unsigned int *)GPIO_CONFIG_ADDR(power_on_gpio);
reset_gpio_base = (unsigned int *)GPIO_CONFIG_ADDR(reset_gpio);
writel(0x2c1, power_on_gpio_base);
writel(0x2c1, reset_gpio_base);
gpio_set_value(power_on_gpio, 0x1);
gpio_set_value(reset_gpio, 0x1);
gpio_set_value(power_on_gpio, 0x0);
gpio_set_value(reset_gpio, 0x0);
}
}
void reset_board(void)
{
run_command("reset", 0);
@ -1259,8 +1288,10 @@ int apps_iscrashed_crashdump_disabled(void)
{
u32 dmagic = ipq_read_tcsr_boot_misc();
if (dmagic & DLOAD_DISABLED)
if (dmagic & DLOAD_DISABLED) {
power_cycle_sdx();
return 1;
}
return 0;
}
@ -1269,8 +1300,10 @@ int apps_iscrashed(void)
{
u32 dmagic = ipq_read_tcsr_boot_misc();
if (dmagic & DLOAD_MAGIC_COOKIE)
if (dmagic & DLOAD_MAGIC_COOKIE) {
power_cycle_sdx();
return 1;
}
return 0;
}

View file

@ -387,4 +387,5 @@ extern const add_node_t add_fdt_node[];
int ipq_get_tz_version(char *version_name, int buf_size);
void ipq_fdt_fixup_socinfo(void *blob);
int ipq_board_usb_init(void);
void power_cycle_sdx(void);
#endif /* _IPQ9574_CDP_H_ */