xref: /openbmc/u-boot/cmd/ide.c (revision cb0060e8)
1 /*
2  * (C) Copyright 2000-2011
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 /*
9  * IDE support
10  */
11 
12 #include <common.h>
13 #include <blk.h>
14 #include <config.h>
15 #include <watchdog.h>
16 #include <command.h>
17 #include <image.h>
18 #include <asm/byteorder.h>
19 #include <asm/io.h>
20 
21 #if defined(CONFIG_IDE_PCMCIA)
22 # include <pcmcia.h>
23 #endif
24 
25 #include <ide.h>
26 #include <ata.h>
27 
28 #ifdef CONFIG_LED_STATUS
29 # include <status_led.h>
30 #endif
31 
32 /* Current I/O Device	*/
33 static int curr_device;
34 
35 int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
36 {
37 	if (argc == 2) {
38 		if (strncmp(argv[1], "res", 3) == 0) {
39 			puts("\nReset IDE: ");
40 			ide_init();
41 			return 0;
42 		}
43 	}
44 
45 	return blk_common_cmd(argc, argv, IF_TYPE_IDE, &curr_device);
46 }
47 
48 int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
49 {
50 	return common_diskboot(cmdtp, "ide", argc, argv);
51 }
52 
53 U_BOOT_CMD(ide, 5, 1, do_ide,
54 	   "IDE sub-system",
55 	   "reset - reset IDE controller\n"
56 	   "ide info  - show available IDE devices\n"
57 	   "ide device [dev] - show or set current device\n"
58 	   "ide part [dev] - print partition table of one or all IDE devices\n"
59 	   "ide read  addr blk# cnt\n"
60 	   "ide write addr blk# cnt - read/write `cnt'"
61 	   " blocks starting at block `blk#'\n"
62 	   "    to/from memory address `addr'");
63 
64 U_BOOT_CMD(diskboot, 3, 1, do_diskboot,
65 	   "boot from IDE device", "loadAddr dev:part");
66