blob: 1c58efc55ac04adc261aad8520f05f17e74de08d [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00002/*
Wolfgang Denk2bc10cf2011-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 Aribaud45027552010-08-08 05:17:06 +053010
wdenkc6097192002-11-03 00:24:07 +000011#include <common.h>
Simon Glass2ee8ada2016-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 Schocher2559e0f2007-08-28 17:39:14 +020018#include <asm/io.h>
Grant Likelyffc2dd72007-02-20 09:04:34 +010019
Heiko Schocher65d94db2017-06-07 17:33:09 +020020#if defined(CONFIG_IDE_PCMCIA)
wdenkc6097192002-11-03 00:24:07 +000021# include <pcmcia.h>
22#endif
Grant Likelyffc2dd72007-02-20 09:04:34 +010023
wdenkc6097192002-11-03 00:24:07 +000024#include <ide.h>
25#include <ata.h>
Grant Likelyffc2dd72007-02-20 09:04:34 +010026
Uri Mashiach4892d392017-01-19 10:51:45 +020027#ifdef CONFIG_LED_STATUS
wdenkc6097192002-11-03 00:24:07 +000028# include <status_led.h>
29#endif
Grant Likelyffc2dd72007-02-20 09:04:34 +010030
wdenkc6097192002-11-03 00:24:07 +000031/* Current I/O Device */
Bin Meng1946db22017-09-10 05:12:53 -070032static int curr_device;
wdenkc6097192002-11-03 00:24:07 +000033
Simon Glass43a464a2016-05-01 11:36:00 -060034int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
35{
Simon Glass8a8b7682017-07-29 11:34:57 -060036 if (argc == 2) {
Simon Glass43a464a2016-05-01 11:36:00 -060037 if (strncmp(argv[1], "res", 3) == 0) {
Heiko Schocher65d94db2017-06-07 17:33:09 +020038 puts("\nReset IDE: ");
Simon Glass43a464a2016-05-01 11:36:00 -060039 ide_init();
40 return 0;
Simon Glass43a464a2016-05-01 11:36:00 -060041 }
Simon Glass43a464a2016-05-01 11:36:00 -060042 }
Simon Glass8a8b7682017-07-29 11:34:57 -060043
44 return blk_common_cmd(argc, argv, IF_TYPE_IDE, &curr_device);
Simon Glass43a464a2016-05-01 11:36:00 -060045}
wdenkf602aa02004-03-13 23:29:43 +000046
Simon Glass43a464a2016-05-01 11:36:00 -060047int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
48{
49 return common_diskboot(cmdtp, "ide", argc, argv);
50}
wdenkc6097192002-11-03 00:24:07 +000051
Wolfgang Denk2bc10cf2011-10-29 09:41:40 +000052U_BOOT_CMD(ide, 5, 1, do_ide,
53 "IDE sub-system",
54 "reset - reset IDE controller\n"
55 "ide info - show available IDE devices\n"
56 "ide device [dev] - show or set current device\n"
57 "ide part [dev] - print partition table of one or all IDE devices\n"
58 "ide read addr blk# cnt\n"
59 "ide write addr blk# cnt - read/write `cnt'"
60 " blocks starting at block `blk#'\n"
61 " to/from memory address `addr'");
wdenk57b2d802003-06-27 21:31:46 +000062
Wolfgang Denk2bc10cf2011-10-29 09:41:40 +000063U_BOOT_CMD(diskboot, 3, 1, do_diskboot,
64 "boot from IDE device", "loadAddr dev:part");