Blame view
cmd/sata.c
2.78 KB
83d290c56 SPDX: Convert all... |
1 |
// SPDX-License-Identifier: GPL-2.0+ |
c7057b529 ata: add the supp... |
2 3 4 5 6 7 8 9 |
/* * Copyright (C) 2000-2005, DENX Software Engineering * Wolfgang Denk <wd@denx.de> * Copyright (C) Procsys. All rights reserved. * Mushtaq Khan <mushtaq_k@procsys.com> * <mushtaqk_921@yahoo.co.in> * Copyright (C) 2008 Freescale Semiconductor, Inc. * Dave Liu <daveliu@freescale.com> |
c7057b529 ata: add the supp... |
10 11 12 |
*/ #include <common.h> |
f19f1ecb6 dm: sata: Support... |
13 14 |
#include <ahci.h> #include <dm.h> |
c7057b529 ata: add the supp... |
15 16 17 |
#include <command.h> #include <part.h> #include <sata.h> |
f19f1ecb6 dm: sata: Support... |
18 19 |
#include <dm/device-internal.h> #include <dm/uclass-internal.h> |
c7057b529 ata: add the supp... |
20 |
|
088f1b199 common/cmd_*.c: s... |
21 |
static int sata_curr_device = -1; |
c7057b529 ata: add the supp... |
22 |
|
f19f1ecb6 dm: sata: Support... |
23 24 25 26 27 |
int sata_remove(int devnum) { #ifdef CONFIG_AHCI struct udevice *dev; int rc; |
2d7818d04 cmd: sata: Add bl... |
28 |
blk_unbind_all(IF_TYPE_SATA); |
f19f1ecb6 dm: sata: Support... |
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
rc = uclass_find_device(UCLASS_AHCI, devnum, &dev); if (!rc && !dev) rc = uclass_find_first_device(UCLASS_AHCI, &dev); if (rc || !dev) { printf("Cannot find SATA device %d (err=%d) ", devnum, rc); return CMD_RET_FAILURE; } rc = device_remove(dev, DM_REMOVE_NORMAL); if (rc) { printf("Cannot remove SATA device '%s' (err=%d) ", dev->name, rc); return CMD_RET_FAILURE; } return 0; #else return sata_stop(); #endif } int sata_probe(int devnum) { #ifdef CONFIG_AHCI struct udevice *dev; |
f19f1ecb6 dm: sata: Support... |
56 57 58 59 60 61 62 63 64 65 |
int rc; rc = uclass_get_device(UCLASS_AHCI, devnum, &dev); if (rc) rc = uclass_find_first_device(UCLASS_AHCI, &dev); if (rc) { printf("Cannot probe SATA device %d (err=%d) ", devnum, rc); return CMD_RET_FAILURE; } |
b3860bfe7 cmd: sata: add nu... |
66 67 68 69 70 |
if (!dev) { printf("No SATA device found! "); return CMD_RET_FAILURE; } |
f19f1ecb6 dm: sata: Support... |
71 72 73 74 75 76 |
rc = sata_scan(dev); if (rc) { printf("Cannot scan SATA device %d (err=%d) ", devnum, rc); return CMD_RET_FAILURE; } |
f19f1ecb6 dm: sata: Support... |
77 78 79 80 81 |
return 0; #else return sata_initialize() < 0 ? CMD_RET_FAILURE : CMD_RET_SUCCESS; #endif } |
088f1b199 common/cmd_*.c: s... |
82 |
static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
c7057b529 ata: add the supp... |
83 84 |
{ int rc = 0; |
f19f1ecb6 dm: sata: Support... |
85 86 87 88 89 |
if (argc >= 2) { int devnum = 0; if (argc == 3) devnum = (int)simple_strtoul(argv[2], NULL, 10); |
aefaf1b93 MLK-14930-1 cmd: ... |
90 91 |
if (!strcmp(argv[1], "stop")) { sata_curr_device = -1; |
f19f1ecb6 dm: sata: Support... |
92 |
return sata_remove(devnum); |
aefaf1b93 MLK-14930-1 cmd: ... |
93 |
} |
d957c28a7 cmd_sata: impleme... |
94 |
|
f19f1ecb6 dm: sata: Support... |
95 96 97 98 99 100 |
if (!strcmp(argv[1], "init")) { if (sata_curr_device != -1) { rc = sata_remove(devnum); if (rc) return rc; } |
d957c28a7 cmd_sata: impleme... |
101 |
|
aefaf1b93 MLK-14930-1 cmd: ... |
102 103 104 105 106 |
rc = sata_probe(devnum); if (rc < 0) return CMD_RET_FAILURE; sata_curr_device = rc; return CMD_RET_SUCCESS; |
f19f1ecb6 dm: sata: Support... |
107 |
} |
d957c28a7 cmd_sata: impleme... |
108 |
} |
cf7e399fb SATA: do not auto... |
109 110 |
/* If the user has not yet run `sata init`, do it now */ |
aa6ab905b sata: fix sata co... |
111 |
if (sata_curr_device == -1) { |
f19f1ecb6 dm: sata: Support... |
112 |
rc = sata_probe(0); |
7e83f1d5e sata: fix sata_Pr... |
113 114 |
if (rc) return rc; |
f19f1ecb6 dm: sata: Support... |
115 |
sata_curr_device = 0; |
aa6ab905b sata: fix sata co... |
116 |
} |
cf7e399fb SATA: do not auto... |
117 |
|
e29e71e93 dm: sata: Adjust ... |
118 |
return blk_common_cmd(argc, argv, IF_TYPE_SATA, &sata_curr_device); |
c7057b529 ata: add the supp... |
119 120 121 122 |
} U_BOOT_CMD( sata, 5, 1, do_sata, |
2fb2604d5 Command usage cle... |
123 |
"SATA sub system", |
85dafbb8b common: cmd_sata:... |
124 125 |
"init - init SATA sub system " |
f19f1ecb6 dm: sata: Support... |
126 127 |
"sata stop [dev] - disable SATA sub system or device " |
c7057b529 ata: add the supp... |
128 129 130 131 132 133 134 135 |
"sata info - show available SATA devices " "sata device [dev] - show or set current device " "sata part [dev] - print partition table " "sata read addr blk# cnt " |
a89c33db9 General help mess... |
136 137 |
"sata write addr blk# cnt" ); |