blob: 6739f0b12d1a5f335253277511280242adf0bd2b [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00002/*
Wolfgang Denk34c202c2011-10-29 09:41:40 +00003 * (C) Copyright 2000-2011
wdenkc6097192002-11-03 00:24:07 +00004 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenkc6097192002-11-03 00:24:07 +00005 */
6
7/*
8 * IDE support
9 */
Albert Aribaud113bfe42010-08-08 05:17:06 +053010
wdenkc6097192002-11-03 00:24:07 +000011#include <common.h>
Simon Glass2a981dc2016-02-29 15:25:52 -070012#include <blk.h>
wdenkc6097192002-11-03 00:24:07 +000013#include <config.h>
14#include <watchdog.h>
15#include <command.h>
16#include <image.h>
17#include <asm/byteorder.h>
Heiko Schocherf98984c2007-08-28 17:39:14 +020018#include <asm/io.h>
Grant Likely735dd972007-02-20 09:04:34 +010019
wdenkc6097192002-11-03 00:24:07 +000020#include <ide.h>
21#include <ata.h>
Grant Likely735dd972007-02-20 09:04:34 +010022
Uri Mashiach2d8d1902017-01-19 10:51:45 +020023#ifdef CONFIG_LED_STATUS
wdenkc6097192002-11-03 00:24:07 +000024# include <status_led.h>
25#endif
Grant Likely735dd972007-02-20 09:04:34 +010026
wdenkc6097192002-11-03 00:24:07 +000027/* Current I/O Device */
Bin Meng584f3162017-09-10 05:12:53 -070028static int curr_device;
wdenkc6097192002-11-03 00:24:07 +000029
Simon Glass09140112020-05-10 11:40:03 -060030int do_ide(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
wdenkc6097192002-11-03 00:24:07 +000031{
Simon Glass09ed0d62017-07-29 11:34:57 -060032 if (argc == 2) {
Wolfgang Denk34c202c2011-10-29 09:41:40 +000033 if (strncmp(argv[1], "res", 3) == 0) {
Heiko Schocher5b8e76c2017-06-07 17:33:09 +020034 puts("\nReset IDE: ");
Wolfgang Denk34c202c2011-10-29 09:41:40 +000035 ide_init();
36 return 0;
Wolfgang Denk34c202c2011-10-29 09:41:40 +000037 }
Wolfgang Denk34c202c2011-10-29 09:41:40 +000038 }
Simon Glass09ed0d62017-07-29 11:34:57 -060039
Simon Glasse33a5c62022-08-11 19:34:59 -060040 return blk_common_cmd(argc, argv, UCLASS_IDE, &curr_device);
wdenkc6097192002-11-03 00:24:07 +000041}
42
Simon Glass09140112020-05-10 11:40:03 -060043int do_diskboot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
wdenkc6097192002-11-03 00:24:07 +000044{
Rob Herring7405a132012-09-21 04:02:30 +000045 return common_diskboot(cmdtp, "ide", argc, argv);
wdenkc6097192002-11-03 00:24:07 +000046}
47
Wolfgang Denk34c202c2011-10-29 09:41:40 +000048U_BOOT_CMD(ide, 5, 1, do_ide,
49 "IDE sub-system",
50 "reset - reset IDE controller\n"
51 "ide info - show available IDE devices\n"
52 "ide device [dev] - show or set current device\n"
53 "ide part [dev] - print partition table of one or all IDE devices\n"
54 "ide read addr blk# cnt\n"
55 "ide write addr blk# cnt - read/write `cnt'"
56 " blocks starting at block `blk#'\n"
57 " to/from memory address `addr'");
wdenk8bde7f72003-06-27 21:31:46 +000058
Wolfgang Denk34c202c2011-10-29 09:41:40 +000059U_BOOT_CMD(diskboot, 3, 1, do_diskboot,
60 "boot from IDE device", "loadAddr dev:part");