blob: bdb598050c13e0335743c1ca40f26ce16ace3b9b [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
Wolfgang Denk34c202c2011-10-29 09:41:40 +00002 * (C) Copyright 2000-2011
wdenkc6097192002-11-03 00:24:07 +00003 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00006 */
7
8/*
9 * IDE support
10 */
Albert Aribaud113bfe42010-08-08 05:17:06 +053011
wdenkc6097192002-11-03 00:24:07 +000012#include <common.h>
Simon Glass2a981dc2016-02-29 15:25:52 -070013#include <blk.h>
wdenkc6097192002-11-03 00:24:07 +000014#include <config.h>
15#include <watchdog.h>
16#include <command.h>
17#include <image.h>
18#include <asm/byteorder.h>
Heiko Schocherf98984c2007-08-28 17:39:14 +020019#include <asm/io.h>
Grant Likely735dd972007-02-20 09:04:34 +010020
Heiko Schocher5b8e76c2017-06-07 17:33:09 +020021#if defined(CONFIG_IDE_PCMCIA)
wdenkc6097192002-11-03 00:24:07 +000022# include <pcmcia.h>
23#endif
Grant Likely735dd972007-02-20 09:04:34 +010024
wdenkc6097192002-11-03 00:24:07 +000025#include <ide.h>
26#include <ata.h>
Grant Likely735dd972007-02-20 09:04:34 +010027
Uri Mashiach2d8d1902017-01-19 10:51:45 +020028#ifdef CONFIG_LED_STATUS
wdenkc6097192002-11-03 00:24:07 +000029# include <status_led.h>
30#endif
Grant Likely735dd972007-02-20 09:04:34 +010031
wdenkc6097192002-11-03 00:24:07 +000032/* Current I/O Device */
Bin Meng584f3162017-09-10 05:12:53 -070033static int curr_device;
wdenkc6097192002-11-03 00:24:07 +000034
Wolfgang Denk34c202c2011-10-29 09:41:40 +000035int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
wdenkc6097192002-11-03 00:24:07 +000036{
Simon Glass09ed0d62017-07-29 11:34:57 -060037 if (argc == 2) {
Wolfgang Denk34c202c2011-10-29 09:41:40 +000038 if (strncmp(argv[1], "res", 3) == 0) {
Heiko Schocher5b8e76c2017-06-07 17:33:09 +020039 puts("\nReset IDE: ");
Wolfgang Denk34c202c2011-10-29 09:41:40 +000040 ide_init();
41 return 0;
Wolfgang Denk34c202c2011-10-29 09:41:40 +000042 }
Wolfgang Denk34c202c2011-10-29 09:41:40 +000043 }
Simon Glass09ed0d62017-07-29 11:34:57 -060044
45 return blk_common_cmd(argc, argv, IF_TYPE_IDE, &curr_device);
wdenkc6097192002-11-03 00:24:07 +000046}
47
Wolfgang Denk34c202c2011-10-29 09:41:40 +000048int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
wdenkc6097192002-11-03 00:24:07 +000049{
Rob Herring7405a132012-09-21 04:02:30 +000050 return common_diskboot(cmdtp, "ide", argc, argv);
wdenkc6097192002-11-03 00:24:07 +000051}
52
Wolfgang Denk34c202c2011-10-29 09:41:40 +000053U_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'");
wdenk8bde7f72003-06-27 21:31:46 +000063
Wolfgang Denk34c202c2011-10-29 09:41:40 +000064U_BOOT_CMD(diskboot, 3, 1, do_diskboot,
65 "boot from IDE device", "loadAddr dev:part");