ipq: Indicate SDx when host resets

Change-Id: I202725bffe1ecbdf69aeac4d99a6b6a010f6cbce
Signed-off-by: Karthick Shanmugham <kartshan@codeaurora.org>
This commit is contained in:
Karthick Shanmugham 2021-09-21 13:38:02 +05:30 committed by Gerrit - the friendly Code Review server
parent 3a663227a3
commit 63c2c3a2c5
5 changed files with 85 additions and 0 deletions

View file

@ -157,4 +157,9 @@
};
sdx-gpio {
ap2mdm = <25>;
};
};

View file

@ -31,6 +31,10 @@
aquantia_port = <5>;
aquantia_gpio = <44>;
};
sdx-gpio {
x55-ap2mdm = <26>;
x65-ap2mdm = <45>;
};
};

View file

@ -160,6 +160,40 @@ void uart1_set_rate_mnd(unsigned int m,
writel(two_d, GCC_BLSP1_UART1_APPS_D);
}
int get_ap2mdm_gpio(void)
{
int ap2mdm_gpio = -1, node;
node = fdt_path_offset(gd->fdt_blob, "/sdx-gpio");
if (node >= 0) {
ap2mdm_gpio = fdtdec_get_uint(gd->fdt_blob, node, "ap2mdm", -1);
} else
return node;
return ap2mdm_gpio;
}
void indicate_sdx_device(void)
{
int ap2mdm_gpio;
unsigned int *ap2mdm_gpio_base;
unsigned int machid = gd->bd->bi_arch_number;
if (machid != 0x8040003)
return;
ap2mdm_gpio = get_ap2mdm_gpio();
if(ap2mdm_gpio >= 0) {
/* Enabling OE in gpio cfg reg */
ap2mdm_gpio_base = (unsigned int *)GPIO_CONFIG_ADDR(ap2mdm_gpio);
writel(0x2c0, ap2mdm_gpio_base);
/* Indicate SDx by writing low to ap2mdm */
gpio_set_value(ap2mdm_gpio, 0x1);
gpio_set_value(ap2mdm_gpio, 0x0);
}
}
void reset_board(void)
{
run_command("reset", 0);

View file

@ -430,6 +430,45 @@ void reset_cpu(unsigned long a)
while(1);
}
int sdx65_attached(void);
int get_ap2mdm_gpio(void)
{
int ap2mdm_gpio = -1, node;
node = fdt_path_offset(gd->fdt_blob, "/sdx-gpio");
if (node >= 0) {
if(sdx65_attached())
ap2mdm_gpio = fdtdec_get_uint(gd->fdt_blob, node, "x65-ap2mdm", -1);
else
ap2mdm_gpio = fdtdec_get_uint(gd->fdt_blob, node, "x55-ap2mdm", -1);
} else
return node;
return ap2mdm_gpio;
}
void indicate_sdx_device(void)
{
int ap2mdm_gpio;
unsigned int *ap2mdm_gpio_base;
unsigned int machid = gd->bd->bi_arch_number;
if (machid != 0x08010400)
return;
ap2mdm_gpio = get_ap2mdm_gpio();
if(ap2mdm_gpio >= 0) {
/* Enabling OE in gpio cfg reg */
ap2mdm_gpio_base = (unsigned int *)GPIO_CONFIG_ADDR(ap2mdm_gpio);
writel(0x2c0, ap2mdm_gpio_base);
/* Indicate SDx by writing low to ap2mdm */
gpio_set_value(ap2mdm_gpio, 0x0);
}
}
void reset_board(void)
{
run_command("reset", 0);

View file

@ -366,6 +366,8 @@ __weak int apps_iscrashed_crashdump_disabled(void)
return 0;
}
__weak void indicate_sdx_device(void) {}
void autoboot_command(const char *s)
{
debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
@ -377,6 +379,7 @@ void autoboot_command(const char *s)
*/
if (apps_iscrashed()) {
printf("Crashdump magic found, initializing dump activity..\n");
indicate_sdx_device();
s = getenv("dump_to_flash");
if (!s) {
s = getenv("dump_minimal");