]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
c609719b | 2 | /* |
34c202c7 | 3 | * (C) Copyright 2000-2011 |
c609719b | 4 | * Wolfgang Denk, DENX Software Engineering, [email protected]. |
c609719b WD |
5 | */ |
6 | ||
7 | /* | |
8 | * IDE support | |
9 | */ | |
113bfe48 | 10 | |
2a981dc2 | 11 | #include <blk.h> |
80778f50 | 12 | #include <dm.h> |
c609719b WD |
13 | #include <config.h> |
14 | #include <watchdog.h> | |
15 | #include <command.h> | |
16 | #include <image.h> | |
17 | #include <asm/byteorder.h> | |
f98984cb | 18 | #include <asm/io.h> |
80778f50 SG |
19 | #include <dm/device-internal.h> |
20 | #include <dm/uclass-internal.h> | |
735dd97b | 21 | |
c609719b WD |
22 | #include <ide.h> |
23 | #include <ata.h> | |
735dd97b | 24 | |
2d8d190c | 25 | #ifdef CONFIG_LED_STATUS |
c609719b WD |
26 | # include <status_led.h> |
27 | #endif | |
735dd97b | 28 | |
c609719b | 29 | /* Current I/O Device */ |
584f316f | 30 | static int curr_device; |
c609719b | 31 | |
09140113 | 32 | int do_ide(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
ed73508d | 33 | { |
09ed0d61 | 34 | if (argc == 2) { |
ed73508d | 35 | if (strncmp(argv[1], "res", 3) == 0) { |
80778f50 SG |
36 | struct udevice *dev; |
37 | int ret; | |
38 | ||
5b8e76c3 | 39 | puts("\nReset IDE: "); |
80778f50 SG |
40 | ret = uclass_find_first_device(UCLASS_IDE, &dev); |
41 | ret = device_remove(dev, DM_REMOVE_NORMAL); | |
42 | if (!ret) | |
43 | ret = device_chld_unbind(dev, NULL); | |
44 | if (ret) { | |
45 | printf("Cannot remove IDE (err=%dE)\n", ret); | |
46 | return CMD_RET_FAILURE; | |
47 | } | |
48 | ||
49 | ret = uclass_first_device_err(UCLASS_IDE, &dev); | |
50 | if (ret) { | |
51 | printf("Init failed (err=%dE)\n", ret); | |
52 | return CMD_RET_FAILURE; | |
53 | } | |
54 | ||
ed73508d | 55 | return 0; |
ed73508d | 56 | } |
ed73508d | 57 | } |
09ed0d61 | 58 | |
e33a5c6b | 59 | return blk_common_cmd(argc, argv, UCLASS_IDE, &curr_device); |
ed73508d | 60 | } |
c40b2956 | 61 | |
09140113 | 62 | int do_diskboot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
ed73508d SG |
63 | { |
64 | return common_diskboot(cmdtp, "ide", argc, argv); | |
65 | } | |
c609719b | 66 | |
34c202c7 WD |
67 | U_BOOT_CMD(ide, 5, 1, do_ide, |
68 | "IDE sub-system", | |
69 | "reset - reset IDE controller\n" | |
70 | "ide info - show available IDE devices\n" | |
71 | "ide device [dev] - show or set current device\n" | |
72 | "ide part [dev] - print partition table of one or all IDE devices\n" | |
73 | "ide read addr blk# cnt\n" | |
74 | "ide write addr blk# cnt - read/write `cnt'" | |
75 | " blocks starting at block `blk#'\n" | |
76 | " to/from memory address `addr'"); | |
77 | ||
78 | U_BOOT_CMD(diskboot, 3, 1, do_diskboot, | |
79 | "boot from IDE device", "loadAddr dev:part"); |