2 * (C) Copyright 2000-2011
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 #include <asm/byteorder.h>
37 #if defined(CONFIG_IDE_8xx_DIRECT) || defined(CONFIG_IDE_PCMCIA)
52 #ifdef CONFIG_STATUS_LED
53 # include <status_led.h>
57 # define EIEIO __asm__ volatile ("eieio")
58 # define SYNC __asm__ volatile ("sync")
60 # define EIEIO /* nothing */
61 # define SYNC /* nothing */
64 /* ------------------------------------------------------------------------- */
66 /* Current I/O Device */
67 static int curr_device = -1;
69 /* Current offset for IDE0 / IDE1 bus access */
70 ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS] = {
71 #if defined(CONFIG_SYS_ATA_IDE0_OFFSET)
72 CONFIG_SYS_ATA_IDE0_OFFSET,
74 #if defined(CONFIG_SYS_ATA_IDE1_OFFSET) && (CONFIG_SYS_IDE_MAXBUS > 1)
75 CONFIG_SYS_ATA_IDE1_OFFSET,
79 static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS];
81 block_dev_desc_t ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE];
82 /* ------------------------------------------------------------------------- */
85 # if !defined(CONFIG_BMS2003) && \
86 !defined(CONFIG_CPC45) && \
87 !defined(CONFIG_KUP4K) && \
88 !defined(CONFIG_KUP4X)
89 static void ide_led (uchar led, uchar status);
91 extern void ide_led (uchar led, uchar status);
94 #define ide_led(a,b) /* dummy */
97 #ifdef CONFIG_IDE_RESET
98 static void ide_reset (void);
100 #define ide_reset() /* dummy */
103 static void ide_ident (block_dev_desc_t *dev_desc);
104 static uchar ide_wait (int dev, ulong t);
106 #define IDE_TIME_OUT 2000 /* 2 sec timeout */
108 #define ATAPI_TIME_OUT 7000 /* 7 sec timeout (5 sec seems to work...) */
110 #define IDE_SPIN_UP_TIME_OUT 5000 /* 5 sec spin-up timeout */
112 static void input_data(int dev, ulong *sect_buf, int words);
113 static void output_data(int dev, const ulong *sect_buf, int words);
114 static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
116 #ifndef CONFIG_SYS_ATA_PORT_ADDR
117 #define CONFIG_SYS_ATA_PORT_ADDR(port) (port)
121 static void atapi_inquiry(block_dev_desc_t *dev_desc);
122 ulong atapi_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer);
126 /* ------------------------------------------------------------------------- */
128 int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
135 return CMD_RET_USAGE;
137 if (strncmp(argv[1], "res", 3) == 0) {
139 #ifdef CONFIG_IDE_8xx_DIRECT
140 " on PCMCIA " PCMCIA_SLOT_MSG
146 } else if (strncmp(argv[1], "inf", 3) == 0) {
151 for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
152 if (ide_dev_desc[i].type == DEV_TYPE_UNKNOWN)
153 continue; /* list only known devices */
154 printf("IDE device %d: ", i);
155 dev_print(&ide_dev_desc[i]);
159 } else if (strncmp(argv[1], "dev", 3) == 0) {
160 if ((curr_device < 0)
161 || (curr_device >= CONFIG_SYS_IDE_MAXDEVICE)) {
162 puts("\nno IDE devices available\n");
165 printf("\nIDE device %d: ", curr_device);
166 dev_print(&ide_dev_desc[curr_device]);
168 } else if (strncmp(argv[1], "part", 4) == 0) {
171 for (ok = 0, dev = 0;
172 dev < CONFIG_SYS_IDE_MAXDEVICE;
174 if (ide_dev_desc[dev].part_type !=
179 print_part(&ide_dev_desc[dev]);
183 puts("\nno IDE devices available\n");
188 return CMD_RET_USAGE;
190 if (strncmp(argv[1], "dev", 3) == 0) {
191 int dev = (int) simple_strtoul(argv[2], NULL, 10);
193 printf("\nIDE device %d: ", dev);
194 if (dev >= CONFIG_SYS_IDE_MAXDEVICE) {
195 puts("unknown device\n");
198 dev_print(&ide_dev_desc[dev]);
199 /*ide_print (dev); */
201 if (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN)
206 puts("... is now current device\n");
209 } else if (strncmp(argv[1], "part", 4) == 0) {
210 int dev = (int) simple_strtoul(argv[2], NULL, 10);
212 if (ide_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) {
213 print_part(&ide_dev_desc[dev]);
215 printf("\nIDE device %d not available\n",
222 return CMD_RET_USAGE;
224 /* at least 4 args */
226 if (strcmp(argv[1], "read") == 0) {
227 ulong addr = simple_strtoul(argv[2], NULL, 16);
228 ulong cnt = simple_strtoul(argv[4], NULL, 16);
231 #ifdef CONFIG_SYS_64BIT_LBA
232 lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
234 printf("\nIDE read: device %d block # %lld, count %ld ... ",
235 curr_device, blk, cnt);
237 lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
239 printf("\nIDE read: device %d block # %ld, count %ld ... ",
240 curr_device, blk, cnt);
243 n = ide_dev_desc[curr_device].block_read(curr_device,
246 /* flush cache after read */
248 cnt * ide_dev_desc[curr_device].blksz);
250 printf("%ld blocks read: %s\n",
251 n, (n == cnt) ? "OK" : "ERROR");
256 } else if (strcmp(argv[1], "write") == 0) {
257 ulong addr = simple_strtoul(argv[2], NULL, 16);
258 ulong cnt = simple_strtoul(argv[4], NULL, 16);
261 #ifdef CONFIG_SYS_64BIT_LBA
262 lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
264 printf("\nIDE write: device %d block # %lld, count %ld ... ",
265 curr_device, blk, cnt);
267 lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
269 printf("\nIDE write: device %d block # %ld, count %ld ... ",
270 curr_device, blk, cnt);
272 n = ide_write(curr_device, blk, cnt, (ulong *) addr);
274 printf("%ld blocks written: %s\n",
275 n, (n == cnt) ? "OK" : "ERROR");
281 return CMD_RET_USAGE;
288 int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
290 return common_diskboot(cmdtp, "ide", argc, argv);
293 /* ------------------------------------------------------------------------- */
295 inline void __ide_outb(int dev, int port, unsigned char val)
297 debug("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
299 (ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)));
301 #if defined(CONFIG_IDE_AHB)
304 ide_write_register(dev, port, val);
307 outb(val, (ATA_CURR_BASE(dev)));
310 outb(val, (ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)));
314 void ide_outb(int dev, int port, unsigned char val)
315 __attribute__ ((weak, alias("__ide_outb")));
317 inline unsigned char __ide_inb(int dev, int port)
321 #if defined(CONFIG_IDE_AHB)
322 val = ide_read_register(dev, port);
324 val = inb((ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)));
327 debug("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
329 (ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)), val);
333 unsigned char ide_inb(int dev, int port)
334 __attribute__ ((weak, alias("__ide_inb")));
336 #ifdef CONFIG_TUNE_PIO
337 inline int __ide_set_piomode(int pio_mode)
342 inline int ide_set_piomode(int pio_mode)
343 __attribute__ ((weak, alias("__ide_set_piomode")));
351 #ifdef CONFIG_IDE_8xx_PCCARD
352 extern int ide_devices_found; /* Initialized in check_ide_device() */
353 #endif /* CONFIG_IDE_8xx_PCCARD */
355 #ifdef CONFIG_IDE_PREINIT
359 puts("ide_preinit failed\n");
362 #endif /* CONFIG_IDE_PREINIT */
367 * Reset the IDE just to be sure.
368 * Light LED's to show
370 ide_led((LED_IDE1 | LED_IDE2), 1); /* LED's on */
372 /* ATAPI Drives seems to need a proper IDE Reset */
375 #ifdef CONFIG_IDE_INIT_POSTRESET
378 if (ide_init_postreset()) {
379 puts("ide_preinit_postreset failed\n");
382 #endif /* CONFIG_IDE_INIT_POSTRESET */
385 * Wait for IDE to get ready.
386 * According to spec, this can take up to 31 seconds!
388 for (bus = 0; bus < CONFIG_SYS_IDE_MAXBUS; ++bus) {
390 bus * (CONFIG_SYS_IDE_MAXDEVICE /
391 CONFIG_SYS_IDE_MAXBUS);
393 #ifdef CONFIG_IDE_8xx_PCCARD
394 /* Skip non-ide devices from probing */
395 if ((ide_devices_found & (1 << bus)) == 0) {
396 ide_led((LED_IDE1 | LED_IDE2), 0); /* LED's off */
400 printf("Bus %d: ", bus);
406 udelay(100000); /* 100 ms */
407 ide_outb(dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev));
408 udelay(100000); /* 100 ms */
411 udelay(10000); /* 10 ms */
413 c = ide_inb(dev, ATA_STATUS);
415 if (i > (ATA_RESET_TIME * 100)) {
416 puts("** Timeout **\n");
418 ide_led((LED_IDE1 | LED_IDE2), 0);
421 if ((i >= 100) && ((i % 100) == 0))
424 } while (c & ATA_STAT_BUSY);
426 if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) {
427 puts("not available ");
428 debug("Status = 0x%02X ", c);
429 #ifndef CONFIG_ATAPI /* ATAPI Devices do not set DRDY */
430 } else if ((c & ATA_STAT_READY) == 0) {
431 puts("not available ");
432 debug("Status = 0x%02X ", c);
443 ide_led((LED_IDE1 | LED_IDE2), 0); /* LED's off */
446 for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
447 #ifdef CONFIG_IDE_LED
448 int led = (IDE_BUS(i) == 0) ? LED_IDE1 : LED_IDE2;
450 ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
451 ide_dev_desc[i].if_type = IF_TYPE_IDE;
452 ide_dev_desc[i].dev = i;
453 ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
454 ide_dev_desc[i].blksz = 0;
455 ide_dev_desc[i].lba = 0;
456 ide_dev_desc[i].block_read = ide_read;
457 ide_dev_desc[i].block_write = ide_write;
458 if (!ide_bus_ok[IDE_BUS(i)])
460 ide_led(led, 1); /* LED on */
461 ide_ident(&ide_dev_desc[i]);
462 ide_led(led, 0); /* LED off */
463 dev_print(&ide_dev_desc[i]);
465 if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) {
466 /* initialize partition type */
467 init_part(&ide_dev_desc[i]);
475 /* ------------------------------------------------------------------------- */
477 #ifdef CONFIG_PARTITIONS
478 block_dev_desc_t *ide_get_dev(int dev)
480 return (dev < CONFIG_SYS_IDE_MAXDEVICE) ? &ide_dev_desc[dev] : NULL;
484 /* ------------------------------------------------------------------------- */
486 /* We only need to swap data if we are running on a big endian cpu. */
487 /* But Au1x00 cpu:s already swaps data in big endian mode! */
488 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SOC_AU1X00)
489 #define input_swap_data(x,y,z) input_data(x,y,z)
491 static void input_swap_data(int dev, ulong *sect_buf, int words)
493 #if defined(CONFIG_CPC45)
495 volatile uchar *pbuf_even =
496 (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
497 volatile uchar *pbuf_odd =
498 (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
499 ushort *dbuf = (ushort *) sect_buf;
502 for (i = 0; i < 2; i++) {
503 *(((uchar *) (dbuf)) + 1) = *pbuf_even;
504 *(uchar *) dbuf = *pbuf_odd;
509 volatile ushort *pbuf =
510 (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
511 ushort *dbuf = (ushort *) sect_buf;
513 debug("in input swap data base for read is %lx\n",
514 (unsigned long) pbuf);
518 *dbuf++ = swab16p((u16 *) pbuf);
519 *dbuf++ = swab16p((u16 *) pbuf);
520 #elif defined(CONFIG_PCS440EP)
524 *dbuf++ = ld_le16(pbuf);
525 *dbuf++ = ld_le16(pbuf);
530 #endif /* __LITTLE_ENDIAN || CONFIG_AU1X00 */
533 #if defined(CONFIG_IDE_SWAP_IO)
534 static void output_data(int dev, const ulong *sect_buf, int words)
536 #if defined(CONFIG_CPC45)
538 volatile uchar *pbuf_even;
539 volatile uchar *pbuf_odd;
541 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
542 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
543 dbuf = (uchar *) sect_buf;
546 *pbuf_even = *dbuf++;
550 *pbuf_even = *dbuf++;
556 volatile ushort *pbuf;
558 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
559 dbuf = (ushort *) sect_buf;
561 #if defined(CONFIG_PCS440EP)
562 /* not tested, because CF was write protected */
564 *pbuf = ld_le16(dbuf++);
566 *pbuf = ld_le16(dbuf++);
576 #else /* ! CONFIG_IDE_SWAP_IO */
577 static void output_data(int dev, const ulong *sect_buf, int words)
579 #if defined(CONFIG_IDE_AHB)
580 ide_write_data(dev, sect_buf, words);
582 outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, words << 1);
585 #endif /* CONFIG_IDE_SWAP_IO */
587 #if defined(CONFIG_IDE_SWAP_IO)
588 static void input_data(int dev, ulong *sect_buf, int words)
590 #if defined(CONFIG_CPC45)
592 volatile uchar *pbuf_even;
593 volatile uchar *pbuf_odd;
595 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
596 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
597 dbuf = (uchar *) sect_buf;
599 *dbuf++ = *pbuf_even;
605 *dbuf++ = *pbuf_even;
614 volatile ushort *pbuf;
616 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
617 dbuf = (ushort *) sect_buf;
619 debug("in input data base for read is %lx\n", (unsigned long) pbuf);
622 #if defined(CONFIG_PCS440EP)
624 *dbuf++ = ld_le16(pbuf);
626 *dbuf++ = ld_le16(pbuf);
636 #else /* ! CONFIG_IDE_SWAP_IO */
637 static void input_data(int dev, ulong *sect_buf, int words)
639 #if defined(CONFIG_IDE_AHB)
640 ide_read_data(dev, sect_buf, words);
642 insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, words << 1);
646 #endif /* CONFIG_IDE_SWAP_IO */
648 /* -------------------------------------------------------------------------
650 static void ide_ident(block_dev_desc_t *dev_desc)
659 #ifdef CONFIG_TUNE_PIO
664 int mode, cycle_time;
668 device = dev_desc->dev;
669 printf(" Device %d: ", device);
671 ide_led(DEVICE_LED(device), 1); /* LED on */
674 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
675 dev_desc->if_type = IF_TYPE_IDE;
680 /* Warning: This will be tricky to read */
681 while (retries <= 1) {
682 /* check signature */
683 if ((ide_inb(device, ATA_SECT_CNT) == 0x01) &&
684 (ide_inb(device, ATA_SECT_NUM) == 0x01) &&
685 (ide_inb(device, ATA_CYL_LOW) == 0x14) &&
686 (ide_inb(device, ATA_CYL_HIGH) == 0xEB)) {
687 /* ATAPI Signature found */
688 dev_desc->if_type = IF_TYPE_ATAPI;
690 * Start Ident Command
692 ide_outb(device, ATA_COMMAND, ATAPI_CMD_IDENT);
694 * Wait for completion - ATAPI devices need more time
697 c = ide_wait(device, ATAPI_TIME_OUT);
702 * Start Ident Command
704 ide_outb(device, ATA_COMMAND, ATA_CMD_IDENT);
707 * Wait for completion
709 c = ide_wait(device, IDE_TIME_OUT);
711 ide_led(DEVICE_LED(device), 0); /* LED off */
713 if (((c & ATA_STAT_DRQ) == 0) ||
714 ((c & (ATA_STAT_FAULT | ATA_STAT_ERR)) != 0)) {
718 * Need to soft reset the device
719 * in case it's an ATAPI...
721 debug("Retrying...\n");
722 ide_outb(device, ATA_DEV_HD,
723 ATA_LBA | ATA_DEVICE(device));
725 ide_outb(device, ATA_COMMAND, 0x08);
726 udelay(500000); /* 500 ms */
731 ide_outb(device, ATA_DEV_HD,
732 ATA_LBA | ATA_DEVICE(device));
741 } /* see above - ugly to read */
743 if (retries == 2) /* Not found */
747 input_swap_data(device, (ulong *)&iop, ATA_SECTORWORDS);
749 ident_cpy((unsigned char *) dev_desc->revision, iop.fw_rev,
750 sizeof(dev_desc->revision));
751 ident_cpy((unsigned char *) dev_desc->vendor, iop.model,
752 sizeof(dev_desc->vendor));
753 ident_cpy((unsigned char *) dev_desc->product, iop.serial_no,
754 sizeof(dev_desc->product));
755 #ifdef __LITTLE_ENDIAN
757 * firmware revision, model, and serial number have Big Endian Byte
758 * order in Word. Convert all three to little endian.
760 * See CF+ and CompactFlash Specification Revision 2.0:
761 * 6.2.1.6: Identify Drive, Table 39 for more details
764 strswab(dev_desc->revision);
765 strswab(dev_desc->vendor);
766 strswab(dev_desc->product);
767 #endif /* __LITTLE_ENDIAN */
769 if ((iop.config & 0x0080) == 0x0080)
770 dev_desc->removable = 1;
772 dev_desc->removable = 0;
774 #ifdef CONFIG_TUNE_PIO
775 /* Mode 0 - 2 only, are directly determined by word 51. */
778 printf("WARNING: Invalid PIO (word 51 = %d).\n", pio_mode);
779 /* Force it to dead slow, and hope for the best... */
783 /* Any CompactFlash Storage Card that supports PIO mode 3 or above
784 * shall set bit 1 of word 53 to one and support the fields contained
785 * in words 64 through 70.
787 if (iop.field_valid & 0x02) {
789 * Mode 3 and above are possible. Check in order from slow
790 * to fast, so we wind up with the highest mode allowed.
792 if (iop.eide_pio_modes & 0x01)
794 if (iop.eide_pio_modes & 0x02)
796 if (ata_id_is_cfa((u16 *)&iop)) {
797 if ((iop.cf_advanced_caps & 0x07) == 0x01)
799 if ((iop.cf_advanced_caps & 0x07) == 0x02)
804 /* System-specific, depends on bus speeds, etc. */
805 ide_set_piomode(pio_mode);
806 #endif /* CONFIG_TUNE_PIO */
810 * Drive PIO mode autoselection
814 printf("tPIO = 0x%02x = %d\n", mode, mode);
815 if (mode > 2) { /* 2 is maximum allowed tPIO value */
817 debug("Override tPIO -> 2\n");
819 if (iop.field_valid & 2) { /* drive implements ATA2? */
820 debug("Drive implements ATA2\n");
821 if (iop.capability & 8) { /* drive supports use_iordy? */
822 cycle_time = iop.eide_pio_iordy;
824 cycle_time = iop.eide_pio;
826 debug("cycle time = %d\n", cycle_time);
828 if (cycle_time > 120)
829 mode = 3; /* 120 ns for PIO mode 4 */
830 if (cycle_time > 180)
831 mode = 2; /* 180 ns for PIO mode 3 */
832 if (cycle_time > 240)
833 mode = 1; /* 240 ns for PIO mode 4 */
834 if (cycle_time > 383)
835 mode = 0; /* 383 ns for PIO mode 4 */
837 printf("PIO mode to use: PIO %d\n", mode);
841 if (dev_desc->if_type == IF_TYPE_ATAPI) {
842 atapi_inquiry(dev_desc);
845 #endif /* CONFIG_ATAPI */
849 dev_desc->lba = (iop.lba_capacity << 16) | (iop.lba_capacity >> 16);
850 #else /* ! __BIG_ENDIAN */
852 * do not swap shorts on little endian
854 * See CF+ and CompactFlash Specification Revision 2.0:
855 * 6.2.1.6: Identfy Drive, Table 39, Word Address 57-58 for details.
857 dev_desc->lba = iop.lba_capacity;
858 #endif /* __BIG_ENDIAN */
861 if (iop.command_set_2 & 0x0400) { /* LBA 48 support */
863 dev_desc->lba = (unsigned long long) iop.lba48_capacity[0] |
864 ((unsigned long long) iop.lba48_capacity[1] << 16) |
865 ((unsigned long long) iop.lba48_capacity[2] << 32) |
866 ((unsigned long long) iop.lba48_capacity[3] << 48);
870 #endif /* CONFIG_LBA48 */
872 dev_desc->type = DEV_TYPE_HARDDISK;
873 dev_desc->blksz = ATA_BLOCKSIZE;
874 dev_desc->lun = 0; /* just to fill something in... */
876 #if 0 /* only used to test the powersaving mode,
877 * if enabled, the drive goes after 5 sec
879 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
880 c = ide_wait(device, IDE_TIME_OUT);
881 ide_outb(device, ATA_SECT_CNT, 1);
882 ide_outb(device, ATA_LBA_LOW, 0);
883 ide_outb(device, ATA_LBA_MID, 0);
884 ide_outb(device, ATA_LBA_HIGH, 0);
885 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
886 ide_outb(device, ATA_COMMAND, 0xe3);
888 c = ide_wait(device, IDE_TIME_OUT); /* can't take over 500 ms */
893 /* ------------------------------------------------------------------------- */
895 ulong ide_read(int device, lbaint_t blknr, ulong blkcnt, void *buffer)
899 unsigned char pwrsave = 0; /* power save */
902 unsigned char lba48 = 0;
904 if (blknr & 0x0000fffff0000000ULL) {
905 /* more than 28 bits used, use 48bit mode */
909 debug("ide_read dev %d start %lX, blocks %lX buffer at %lX\n",
910 device, blknr, blkcnt, (ulong) buffer);
912 ide_led(DEVICE_LED(device), 1); /* LED on */
916 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
917 c = ide_wait(device, IDE_TIME_OUT);
919 if (c & ATA_STAT_BUSY) {
920 printf("IDE read: device %d not ready\n", device);
924 /* first check if the drive is in Powersaving mode, if yes,
925 * increase the timeout value */
926 ide_outb(device, ATA_COMMAND, ATA_CMD_CHK_PWR);
929 c = ide_wait(device, IDE_TIME_OUT); /* can't take over 500 ms */
931 if (c & ATA_STAT_BUSY) {
932 printf("IDE read: device %d not ready\n", device);
935 if ((c & ATA_STAT_ERR) == ATA_STAT_ERR) {
936 printf("No Powersaving mode %X\n", c);
938 c = ide_inb(device, ATA_SECT_CNT);
939 debug("Powersaving %02X\n", c);
945 while (blkcnt-- > 0) {
947 c = ide_wait(device, IDE_TIME_OUT);
949 if (c & ATA_STAT_BUSY) {
950 printf("IDE read: device %d not ready\n", device);
955 /* write high bits */
956 ide_outb(device, ATA_SECT_CNT, 0);
957 ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF);
958 #ifdef CONFIG_SYS_64BIT_LBA
959 ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xFF);
960 ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
962 ide_outb(device, ATA_LBA_MID, 0);
963 ide_outb(device, ATA_LBA_HIGH, 0);
967 ide_outb(device, ATA_SECT_CNT, 1);
968 ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
969 ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
970 ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
974 ide_outb(device, ATA_DEV_HD,
975 ATA_LBA | ATA_DEVICE(device));
976 ide_outb(device, ATA_COMMAND, ATA_CMD_READ_EXT);
981 ide_outb(device, ATA_DEV_HD, ATA_LBA |
982 ATA_DEVICE(device) | ((blknr >> 24) & 0xF));
983 ide_outb(device, ATA_COMMAND, ATA_CMD_READ);
989 /* may take up to 4 sec */
990 c = ide_wait(device, IDE_SPIN_UP_TIME_OUT);
993 /* can't take over 500 ms */
994 c = ide_wait(device, IDE_TIME_OUT);
997 if ((c & (ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR)) !=
999 #if defined(CONFIG_SYS_64BIT_LBA)
1000 printf("Error (no IRQ) dev %d blk %lld: status 0x%02x\n",
1003 printf("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
1004 device, (ulong) blknr, c);
1009 input_data(device, buffer, ATA_SECTORWORDS);
1010 (void) ide_inb(device, ATA_STATUS); /* clear IRQ */
1014 buffer += ATA_BLOCKSIZE;
1017 ide_led(DEVICE_LED(device), 0); /* LED off */
1021 /* ------------------------------------------------------------------------- */
1024 ulong ide_write(int device, lbaint_t blknr, ulong blkcnt, const void *buffer)
1030 unsigned char lba48 = 0;
1032 if (blknr & 0x0000fffff0000000ULL) {
1033 /* more than 28 bits used, use 48bit mode */
1038 ide_led(DEVICE_LED(device), 1); /* LED on */
1042 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1044 while (blkcnt-- > 0) {
1046 c = ide_wait(device, IDE_TIME_OUT);
1048 if (c & ATA_STAT_BUSY) {
1049 printf("IDE read: device %d not ready\n", device);
1054 /* write high bits */
1055 ide_outb(device, ATA_SECT_CNT, 0);
1056 ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF);
1057 #ifdef CONFIG_SYS_64BIT_LBA
1058 ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xFF);
1059 ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
1061 ide_outb(device, ATA_LBA_MID, 0);
1062 ide_outb(device, ATA_LBA_HIGH, 0);
1066 ide_outb(device, ATA_SECT_CNT, 1);
1067 ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
1068 ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
1069 ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
1073 ide_outb(device, ATA_DEV_HD,
1074 ATA_LBA | ATA_DEVICE(device));
1075 ide_outb(device, ATA_COMMAND, ATA_CMD_WRITE_EXT);
1080 ide_outb(device, ATA_DEV_HD, ATA_LBA |
1081 ATA_DEVICE(device) | ((blknr >> 24) & 0xF));
1082 ide_outb(device, ATA_COMMAND, ATA_CMD_WRITE);
1087 /* can't take over 500 ms */
1088 c = ide_wait(device, IDE_TIME_OUT);
1090 if ((c & (ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR)) !=
1092 #if defined(CONFIG_SYS_64BIT_LBA)
1093 printf("Error (no IRQ) dev %d blk %lld: status 0x%02x\n",
1096 printf("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
1097 device, (ulong) blknr, c);
1102 output_data(device, buffer, ATA_SECTORWORDS);
1103 c = ide_inb(device, ATA_STATUS); /* clear IRQ */
1106 buffer += ATA_BLOCKSIZE;
1109 ide_led(DEVICE_LED(device), 0); /* LED off */
1113 /* ------------------------------------------------------------------------- */
1116 * copy src to dest, skipping leading and trailing blanks and null
1117 * terminate the string
1118 * "len" is the size of available memory including the terminating '\0'
1120 static void ident_cpy(unsigned char *dst, unsigned char *src,
1123 unsigned char *end, *last;
1126 end = src + len - 1;
1128 /* reserve space for '\0' */
1132 /* skip leading white space */
1133 while ((*src) && (src < end) && (*src == ' '))
1136 /* copy string, omitting trailing white space */
1137 while ((*src) && (src < end)) {
1146 /* ------------------------------------------------------------------------- */
1149 * Wait until Busy bit is off, or timeout (in ms)
1150 * Return last status
1152 static uchar ide_wait(int dev, ulong t)
1154 ulong delay = 10 * t; /* poll every 100 us */
1157 while ((c = ide_inb(dev, ATA_STATUS)) & ATA_STAT_BUSY) {
1165 /* ------------------------------------------------------------------------- */
1167 #ifdef CONFIG_IDE_RESET
1168 extern void ide_set_reset(int idereset);
1170 static void ide_reset(void)
1175 for (i = 0; i < CONFIG_SYS_IDE_MAXBUS; ++i)
1177 for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i)
1178 ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
1180 ide_set_reset(1); /* assert reset */
1182 /* the reset signal shall be asserted for et least 25 us */
1187 /* de-assert RESET signal */
1191 for (i = 0; i < 250; ++i)
1195 #endif /* CONFIG_IDE_RESET */
1197 /* ------------------------------------------------------------------------- */
1199 #if defined(CONFIG_IDE_LED) && \
1200 !defined(CONFIG_CPC45) && \
1201 !defined(CONFIG_KUP4K) && \
1202 !defined(CONFIG_KUP4X)
1204 static uchar led_buffer; /* Buffer for current LED status */
1206 static void ide_led(uchar led, uchar status)
1208 uchar *led_port = LED_PORT;
1210 if (status) /* switch LED on */
1212 else /* switch LED off */
1215 *led_port = led_buffer;
1218 #endif /* CONFIG_IDE_LED */
1220 #if defined(CONFIG_OF_IDE_FIXUP)
1221 int ide_device_present(int dev)
1223 if (dev >= CONFIG_SYS_IDE_MAXBUS)
1225 return (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN ? 0 : 1);
1228 /* ------------------------------------------------------------------------- */
1231 /****************************************************************************
1235 #if defined(CONFIG_IDE_SWAP_IO)
1236 /* since ATAPI may use commands with not 4 bytes alligned length
1237 * we have our own transfer functions, 2 bytes alligned */
1238 static void output_data_shorts(int dev, ushort *sect_buf, int shorts)
1240 #if defined(CONFIG_CPC45)
1242 volatile uchar *pbuf_even;
1243 volatile uchar *pbuf_odd;
1245 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
1246 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
1249 *pbuf_even = *dbuf++;
1251 *pbuf_odd = *dbuf++;
1255 volatile ushort *pbuf;
1257 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
1258 dbuf = (ushort *) sect_buf;
1260 debug("in output data shorts base for read is %lx\n",
1261 (unsigned long) pbuf);
1270 static void input_data_shorts(int dev, ushort *sect_buf, int shorts)
1272 #if defined(CONFIG_CPC45)
1274 volatile uchar *pbuf_even;
1275 volatile uchar *pbuf_odd;
1277 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
1278 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
1281 *dbuf++ = *pbuf_even;
1283 *dbuf++ = *pbuf_odd;
1287 volatile ushort *pbuf;
1289 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
1290 dbuf = (ushort *) sect_buf;
1292 debug("in input data shorts base for read is %lx\n",
1293 (unsigned long) pbuf);
1302 #else /* ! CONFIG_IDE_SWAP_IO */
1303 static void output_data_shorts(int dev, ushort *sect_buf, int shorts)
1305 outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
1308 static void input_data_shorts(int dev, ushort *sect_buf, int shorts)
1310 insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
1313 #endif /* CONFIG_IDE_SWAP_IO */
1316 * Wait until (Status & mask) == res, or timeout (in ms)
1317 * Return last status
1318 * This is used since some ATAPI CD ROMs clears their Busy Bit first
1319 * and then they set their DRQ Bit
1321 static uchar atapi_wait_mask(int dev, ulong t, uchar mask, uchar res)
1323 ulong delay = 10 * t; /* poll every 100 us */
1326 /* prevents to read the status before valid */
1327 c = ide_inb(dev, ATA_DEV_CTL);
1329 while (((c = ide_inb(dev, ATA_STATUS)) & mask) != res) {
1330 /* break if error occurs (doesn't make sense to wait more) */
1331 if ((c & ATA_STAT_ERR) == ATA_STAT_ERR)
1341 * issue an atapi command
1343 unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen,
1344 unsigned char *buffer, int buflen)
1346 unsigned char c, err, mask, res;
1349 ide_led(DEVICE_LED(device), 1); /* LED on */
1353 mask = ATA_STAT_BUSY | ATA_STAT_DRQ;
1355 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1356 c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1357 if ((c & mask) != res) {
1358 printf("ATAPI_ISSUE: device %d not ready status %X\n", device,
1363 /* write taskfile */
1364 ide_outb(device, ATA_ERROR_REG, 0); /* no DMA, no overlaped */
1365 ide_outb(device, ATA_SECT_CNT, 0);
1366 ide_outb(device, ATA_SECT_NUM, 0);
1367 ide_outb(device, ATA_CYL_LOW, (unsigned char) (buflen & 0xFF));
1368 ide_outb(device, ATA_CYL_HIGH,
1369 (unsigned char) ((buflen >> 8) & 0xFF));
1370 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1372 ide_outb(device, ATA_COMMAND, ATAPI_CMD_PACKET);
1375 mask = ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR;
1377 c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1379 if ((c & mask) != res) { /* DRQ must be 1, BSY 0 */
1380 printf("ATAPI_ISSUE: Error (no IRQ) before sending ccb dev %d status 0x%02x\n",
1386 /* write command block */
1387 output_data_shorts(device, (unsigned short *) ccb, ccblen / 2);
1389 /* ATAPI Command written wait for completition */
1390 udelay(5000); /* device must set bsy */
1392 mask = ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR;
1394 * if no data wait for DRQ = 0 BSY = 0
1395 * if data wait for DRQ = 1 BSY = 0
1400 c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1401 if ((c & mask) != res) {
1402 if (c & ATA_STAT_ERR) {
1403 err = (ide_inb(device, ATA_ERROR_REG)) >> 4;
1404 debug("atapi_issue 1 returned sense key %X status %02X\n",
1407 printf("ATAPI_ISSUE: (no DRQ) after sending ccb (%x) status 0x%02x\n",
1413 n = ide_inb(device, ATA_CYL_HIGH);
1415 n += ide_inb(device, ATA_CYL_LOW);
1417 printf("ERROR, transfer bytes %d requested only %d\n", n,
1422 if ((n == 0) && (buflen < 0)) {
1423 printf("ERROR, transfer bytes %d requested %d\n", n, buflen);
1428 debug("WARNING, transfer bytes %d not equal with requested %d\n",
1431 if (n != 0) { /* data transfer */
1432 debug("ATAPI_ISSUE: %d Bytes to transfer\n", n);
1433 /* we transfer shorts */
1435 /* ok now decide if it is an in or output */
1436 if ((ide_inb(device, ATA_SECT_CNT) & 0x02) == 0) {
1437 debug("Write to device\n");
1438 output_data_shorts(device, (unsigned short *) buffer,
1441 debug("Read from device @ %p shorts %d\n", buffer, n);
1442 input_data_shorts(device, (unsigned short *) buffer,
1446 udelay(5000); /* seems that some CD ROMs need this... */
1447 mask = ATA_STAT_BUSY | ATA_STAT_ERR;
1449 c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1450 if ((c & ATA_STAT_ERR) == ATA_STAT_ERR) {
1451 err = (ide_inb(device, ATA_ERROR_REG) >> 4);
1452 debug("atapi_issue 2 returned sense key %X status %X\n", err,
1458 ide_led(DEVICE_LED(device), 0); /* LED off */
1463 * sending the command to atapi_issue. If an status other than good
1464 * returns, an request_sense will be issued
1467 #define ATAPI_DRIVE_NOT_READY 100
1468 #define ATAPI_UNIT_ATTN 10
1470 unsigned char atapi_issue_autoreq(int device,
1473 unsigned char *buffer, int buflen)
1475 unsigned char sense_data[18], sense_ccb[12];
1476 unsigned char res, key, asc, ascq;
1477 int notready, unitattn;
1479 unitattn = ATAPI_UNIT_ATTN;
1480 notready = ATAPI_DRIVE_NOT_READY;
1483 res = atapi_issue(device, ccb, ccblen, buffer, buflen);
1488 return 0xFF; /* error */
1490 debug("(auto_req)atapi_issue returned sense key %X\n", res);
1492 memset(sense_ccb, 0, sizeof(sense_ccb));
1493 memset(sense_data, 0, sizeof(sense_data));
1494 sense_ccb[0] = ATAPI_CMD_REQ_SENSE;
1495 sense_ccb[4] = 18; /* allocation Length */
1497 res = atapi_issue(device, sense_ccb, 12, sense_data, 18);
1498 key = (sense_data[2] & 0xF);
1499 asc = (sense_data[12]);
1500 ascq = (sense_data[13]);
1502 debug("ATAPI_CMD_REQ_SENSE returned %x\n", res);
1503 debug(" Sense page: %02X key %02X ASC %02X ASCQ %02X\n",
1504 sense_data[0], key, asc, ascq);
1507 return 0; /* ok device ready */
1509 if ((key == 6) || (asc == 0x29) || (asc == 0x28)) { /* Unit Attention */
1510 if (unitattn-- > 0) {
1514 printf("Unit Attention, tried %d\n", ATAPI_UNIT_ATTN);
1517 if ((asc == 0x4) && (ascq == 0x1)) {
1518 /* not ready, but will be ready soon */
1519 if (notready-- > 0) {
1523 printf("Drive not ready, tried %d times\n",
1524 ATAPI_DRIVE_NOT_READY);
1528 debug("Media not present\n");
1532 printf("ERROR: Unknown Sense key %02X ASC %02X ASCQ %02X\n", key, asc,
1535 debug("ERROR Sense key %02X ASC %02X ASCQ %02X\n", key, asc, ascq);
1540 static void atapi_inquiry(block_dev_desc_t *dev_desc)
1542 unsigned char ccb[12]; /* Command descriptor block */
1543 unsigned char iobuf[64]; /* temp buf */
1547 device = dev_desc->dev;
1548 dev_desc->type = DEV_TYPE_UNKNOWN; /* not yet valid */
1549 dev_desc->block_read = atapi_read;
1551 memset(ccb, 0, sizeof(ccb));
1552 memset(iobuf, 0, sizeof(iobuf));
1554 ccb[0] = ATAPI_CMD_INQUIRY;
1555 ccb[4] = 40; /* allocation Legnth */
1556 c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 40);
1558 debug("ATAPI_CMD_INQUIRY returned %x\n", c);
1562 /* copy device ident strings */
1563 ident_cpy((unsigned char *) dev_desc->vendor, &iobuf[8], 8);
1564 ident_cpy((unsigned char *) dev_desc->product, &iobuf[16], 16);
1565 ident_cpy((unsigned char *) dev_desc->revision, &iobuf[32], 5);
1569 dev_desc->blksz = 0;
1570 dev_desc->type = iobuf[0] & 0x1f;
1572 if ((iobuf[1] & 0x80) == 0x80)
1573 dev_desc->removable = 1;
1575 dev_desc->removable = 0;
1577 memset(ccb, 0, sizeof(ccb));
1578 memset(iobuf, 0, sizeof(iobuf));
1579 ccb[0] = ATAPI_CMD_START_STOP;
1580 ccb[4] = 0x03; /* start */
1582 c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 0);
1584 debug("ATAPI_CMD_START_STOP returned %x\n", c);
1588 memset(ccb, 0, sizeof(ccb));
1589 memset(iobuf, 0, sizeof(iobuf));
1590 c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 0);
1592 debug("ATAPI_CMD_UNIT_TEST_READY returned %x\n", c);
1596 memset(ccb, 0, sizeof(ccb));
1597 memset(iobuf, 0, sizeof(iobuf));
1598 ccb[0] = ATAPI_CMD_READ_CAP;
1599 c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 8);
1600 debug("ATAPI_CMD_READ_CAP returned %x\n", c);
1604 debug("Read Cap: LBA %02X%02X%02X%02X blksize %02X%02X%02X%02X\n",
1605 iobuf[0], iobuf[1], iobuf[2], iobuf[3],
1606 iobuf[4], iobuf[5], iobuf[6], iobuf[7]);
1608 dev_desc->lba = ((unsigned long) iobuf[0] << 24) +
1609 ((unsigned long) iobuf[1] << 16) +
1610 ((unsigned long) iobuf[2] << 8) + ((unsigned long) iobuf[3]);
1611 dev_desc->blksz = ((unsigned long) iobuf[4] << 24) +
1612 ((unsigned long) iobuf[5] << 16) +
1613 ((unsigned long) iobuf[6] << 8) + ((unsigned long) iobuf[7]);
1615 /* ATAPI devices cannot use 48bit addressing (ATA/ATAPI v7) */
1616 dev_desc->lba48 = 0;
1624 * we transfer only one block per command, since the multiple DRQ per
1625 * command is not yet implemented
1627 #define ATAPI_READ_MAX_BYTES 2048 /* we read max 2kbytes */
1628 #define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */
1629 #define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE)
1631 ulong atapi_read(int device, lbaint_t blknr, ulong blkcnt, void *buffer)
1634 unsigned char ccb[12]; /* Command descriptor block */
1637 debug("atapi_read dev %d start %lX, blocks %lX buffer at %lX\n",
1638 device, blknr, blkcnt, (ulong) buffer);
1641 if (blkcnt > ATAPI_READ_MAX_BLOCK)
1642 cnt = ATAPI_READ_MAX_BLOCK;
1646 ccb[0] = ATAPI_CMD_READ_12;
1647 ccb[1] = 0; /* reserved */
1648 ccb[2] = (unsigned char) (blknr >> 24) & 0xFF; /* MSB Block */
1649 ccb[3] = (unsigned char) (blknr >> 16) & 0xFF; /* */
1650 ccb[4] = (unsigned char) (blknr >> 8) & 0xFF;
1651 ccb[5] = (unsigned char) blknr & 0xFF; /* LSB Block */
1652 ccb[6] = (unsigned char) (cnt >> 24) & 0xFF; /* MSB Block cnt */
1653 ccb[7] = (unsigned char) (cnt >> 16) & 0xFF;
1654 ccb[8] = (unsigned char) (cnt >> 8) & 0xFF;
1655 ccb[9] = (unsigned char) cnt & 0xFF; /* LSB Block */
1656 ccb[10] = 0; /* reserved */
1657 ccb[11] = 0; /* reserved */
1659 if (atapi_issue_autoreq(device, ccb, 12,
1660 (unsigned char *) buffer,
1661 cnt * ATAPI_READ_BLOCK_SIZE)
1668 buffer += (cnt * ATAPI_READ_BLOCK_SIZE);
1669 } while (blkcnt > 0);
1673 /* ------------------------------------------------------------------------- */
1675 #endif /* CONFIG_ATAPI */
1677 U_BOOT_CMD(ide, 5, 1, do_ide,
1679 "reset - reset IDE controller\n"
1680 "ide info - show available IDE devices\n"
1681 "ide device [dev] - show or set current device\n"
1682 "ide part [dev] - print partition table of one or all IDE devices\n"
1683 "ide read addr blk# cnt\n"
1684 "ide write addr blk# cnt - read/write `cnt'"
1685 " blocks starting at block `blk#'\n"
1686 " to/from memory address `addr'");
1688 U_BOOT_CMD(diskboot, 3, 1, do_diskboot,
1689 "boot from IDE device", "loadAddr dev:part");