Skip to content
Snippets Groups Projects
Commit d957c28a authored by Nikita Kiryanov's avatar Nikita Kiryanov Committed by Stefano Babic
Browse files

cmd_sata: implement sata stop command


Implement sata stop command.
This introduces the __sata_stop() weak function, which mirrors
the weak __sata_initialize() function, giving users the option of
undoing the custom steps performed in overrides of sata_initialize().

Signed-off-by: default avatarNikita Kiryanov <nikita@compulab.co.il>
Cc: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@ti.com>
parent 10ee8eca
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,20 @@ int __sata_initialize(void) ...@@ -48,6 +48,20 @@ int __sata_initialize(void)
} }
int sata_initialize(void) __attribute__((weak,alias("__sata_initialize"))); int sata_initialize(void) __attribute__((weak,alias("__sata_initialize")));
__weak int __sata_stop(void)
{
int i, err = 0;
for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++)
err |= reset_sata(i);
if (err)
printf("Could not reset some SATA devices\n");
return err;
}
int sata_stop(void) __attribute__((weak, alias("__sata_stop")));
#ifdef CONFIG_PARTITIONS #ifdef CONFIG_PARTITIONS
block_dev_desc_t *sata_get_dev(int dev) block_dev_desc_t *sata_get_dev(int dev)
{ {
...@@ -59,8 +73,15 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ...@@ -59,8 +73,15 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{ {
int rc = 0; int rc = 0;
if (argc == 2 && strcmp(argv[1], "init") == 0) if (argc == 2 && strcmp(argv[1], "stop") == 0)
return sata_stop();
if (argc == 2 && strcmp(argv[1], "init") == 0) {
if (sata_curr_device != -1)
sata_stop();
return sata_initialize(); return sata_initialize();
}
/* If the user has not yet run `sata init`, do it now */ /* If the user has not yet run `sata init`, do it now */
if (sata_curr_device == -1) if (sata_curr_device == -1)
...@@ -185,6 +206,7 @@ U_BOOT_CMD( ...@@ -185,6 +206,7 @@ U_BOOT_CMD(
sata, 5, 1, do_sata, sata, 5, 1, do_sata,
"SATA sub system", "SATA sub system",
"init - init SATA sub system\n" "init - init SATA sub system\n"
"sata stop - disable SATA sub system\n"
"sata info - show available SATA devices\n" "sata info - show available SATA devices\n"
"sata device [dev] - show or set current device\n" "sata device [dev] - show or set current device\n"
"sata part [dev] - print partition table\n" "sata part [dev] - print partition table\n"
......
...@@ -10,6 +10,8 @@ ulong sata_write(int dev, ulong blknr, lbaint_t blkcnt, const void *buffer); ...@@ -10,6 +10,8 @@ ulong sata_write(int dev, ulong blknr, lbaint_t blkcnt, const void *buffer);
int sata_initialize(void); int sata_initialize(void);
int __sata_initialize(void); int __sata_initialize(void);
int sata_stop(void);
int __sata_stop(void);
int sata_port_status(int dev, int port); int sata_port_status(int dev, int port);
extern block_dev_desc_t sata_dev_desc[]; extern block_dev_desc_t sata_dev_desc[];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment