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 ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
114 #ifndef CONFIG_SYS_ATA_PORT_ADDR
115 #define CONFIG_SYS_ATA_PORT_ADDR(port) (port)
119 static void atapi_inquiry(block_dev_desc_t *dev_desc);
120 ulong atapi_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer);
124 /* ------------------------------------------------------------------------- */
126 int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
133 return CMD_RET_USAGE;
135 if (strncmp(argv[1], "res", 3) == 0) {
137 #ifdef CONFIG_IDE_8xx_DIRECT
138 " on PCMCIA " PCMCIA_SLOT_MSG
144 } else if (strncmp(argv[1], "inf", 3) == 0) {
149 for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
150 if (ide_dev_desc[i].type == DEV_TYPE_UNKNOWN)
151 continue; /* list only known devices */
152 printf("IDE device %d: ", i);
153 dev_print(&ide_dev_desc[i]);
157 } else if (strncmp(argv[1], "dev", 3) == 0) {
158 if ((curr_device < 0)
159 || (curr_device >= CONFIG_SYS_IDE_MAXDEVICE)) {
160 puts("\nno IDE devices available\n");
163 printf("\nIDE device %d: ", curr_device);
164 dev_print(&ide_dev_desc[curr_device]);
166 } else if (strncmp(argv[1], "part", 4) == 0) {
169 for (ok = 0, dev = 0;
170 dev < CONFIG_SYS_IDE_MAXDEVICE;
172 if (ide_dev_desc[dev].part_type !=
177 print_part(&ide_dev_desc[dev]);
181 puts("\nno IDE devices available\n");
186 return CMD_RET_USAGE;
188 if (strncmp(argv[1], "dev", 3) == 0) {
189 int dev = (int) simple_strtoul(argv[2], NULL, 10);
191 printf("\nIDE device %d: ", dev);
192 if (dev >= CONFIG_SYS_IDE_MAXDEVICE) {
193 puts("unknown device\n");
196 dev_print(&ide_dev_desc[dev]);
197 /*ide_print (dev); */
199 if (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN)
204 puts("... is now current device\n");
207 } else if (strncmp(argv[1], "part", 4) == 0) {
208 int dev = (int) simple_strtoul(argv[2], NULL, 10);
210 if (ide_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) {
211 print_part(&ide_dev_desc[dev]);
213 printf("\nIDE device %d not available\n",
220 return CMD_RET_USAGE;
222 /* at least 4 args */
224 if (strcmp(argv[1], "read") == 0) {
225 ulong addr = simple_strtoul(argv[2], NULL, 16);
226 ulong cnt = simple_strtoul(argv[4], NULL, 16);
229 #ifdef CONFIG_SYS_64BIT_LBA
230 lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
232 printf("\nIDE read: device %d block # %lld, count %ld ... ",
233 curr_device, blk, cnt);
235 lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
237 printf("\nIDE read: device %d block # %ld, count %ld ... ",
238 curr_device, blk, cnt);
241 n = ide_dev_desc[curr_device].block_read(curr_device,
244 /* flush cache after read */
246 cnt * ide_dev_desc[curr_device].blksz);
248 printf("%ld blocks read: %s\n",
249 n, (n == cnt) ? "OK" : "ERROR");
254 } else if (strcmp(argv[1], "write") == 0) {
255 ulong addr = simple_strtoul(argv[2], NULL, 16);
256 ulong cnt = simple_strtoul(argv[4], NULL, 16);
259 #ifdef CONFIG_SYS_64BIT_LBA
260 lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
262 printf("\nIDE write: device %d block # %lld, count %ld ... ",
263 curr_device, blk, cnt);
265 lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
267 printf("\nIDE write: device %d block # %ld, count %ld ... ",
268 curr_device, blk, cnt);
270 n = ide_write(curr_device, blk, cnt, (ulong *) addr);
272 printf("%ld blocks written: %s\n",
273 n, (n == cnt) ? "OK" : "ERROR");
279 return CMD_RET_USAGE;
286 int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
288 return common_diskboot(cmdtp, "ide", argc, argv);
291 /* ------------------------------------------------------------------------- */
293 inline void __ide_outb(int dev, int port, unsigned char val)
295 debug("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
297 (ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)));
299 #if defined(CONFIG_IDE_AHB)
302 ide_write_register(dev, port, val);
305 outb(val, (ATA_CURR_BASE(dev)));
308 outb(val, (ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)));
312 void ide_outb(int dev, int port, unsigned char val)
313 __attribute__ ((weak, alias("__ide_outb")));
315 inline unsigned char __ide_inb(int dev, int port)
319 #if defined(CONFIG_IDE_AHB)
320 val = ide_read_register(dev, port);
322 val = inb((ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)));
325 debug("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
327 (ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)), val);
331 unsigned char ide_inb(int dev, int port)
332 __attribute__ ((weak, alias("__ide_inb")));
334 #ifdef CONFIG_TUNE_PIO
335 inline int __ide_set_piomode(int pio_mode)
340 inline int ide_set_piomode(int pio_mode)
341 __attribute__ ((weak, alias("__ide_set_piomode")));
349 #ifdef CONFIG_IDE_8xx_PCCARD
350 extern int ide_devices_found; /* Initialized in check_ide_device() */
351 #endif /* CONFIG_IDE_8xx_PCCARD */
353 #ifdef CONFIG_IDE_PREINIT
357 puts("ide_preinit failed\n");
360 #endif /* CONFIG_IDE_PREINIT */
365 * Reset the IDE just to be sure.
366 * Light LED's to show
368 ide_led((LED_IDE1 | LED_IDE2), 1); /* LED's on */
370 /* ATAPI Drives seems to need a proper IDE Reset */
373 #ifdef CONFIG_IDE_INIT_POSTRESET
376 if (ide_init_postreset()) {
377 puts("ide_preinit_postreset failed\n");
380 #endif /* CONFIG_IDE_INIT_POSTRESET */
383 * Wait for IDE to get ready.
384 * According to spec, this can take up to 31 seconds!
386 for (bus = 0; bus < CONFIG_SYS_IDE_MAXBUS; ++bus) {
388 bus * (CONFIG_SYS_IDE_MAXDEVICE /
389 CONFIG_SYS_IDE_MAXBUS);
391 #ifdef CONFIG_IDE_8xx_PCCARD
392 /* Skip non-ide devices from probing */
393 if ((ide_devices_found & (1 << bus)) == 0) {
394 ide_led((LED_IDE1 | LED_IDE2), 0); /* LED's off */
398 printf("Bus %d: ", bus);
404 udelay(100000); /* 100 ms */
405 ide_outb(dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev));
406 udelay(100000); /* 100 ms */
409 udelay(10000); /* 10 ms */
411 c = ide_inb(dev, ATA_STATUS);
413 if (i > (ATA_RESET_TIME * 100)) {
414 puts("** Timeout **\n");
416 ide_led((LED_IDE1 | LED_IDE2), 0);
419 if ((i >= 100) && ((i % 100) == 0))
422 } while (c & ATA_STAT_BUSY);
424 if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) {
425 puts("not available ");
426 debug("Status = 0x%02X ", c);
427 #ifndef CONFIG_ATAPI /* ATAPI Devices do not set DRDY */
428 } else if ((c & ATA_STAT_READY) == 0) {
429 puts("not available ");
430 debug("Status = 0x%02X ", c);
441 ide_led((LED_IDE1 | LED_IDE2), 0); /* LED's off */
444 for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
445 #ifdef CONFIG_IDE_LED
446 int led = (IDE_BUS(i) == 0) ? LED_IDE1 : LED_IDE2;
448 ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
449 ide_dev_desc[i].if_type = IF_TYPE_IDE;
450 ide_dev_desc[i].dev = i;
451 ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
452 ide_dev_desc[i].blksz = 0;
453 ide_dev_desc[i].lba = 0;
454 ide_dev_desc[i].block_read = ide_read;
455 ide_dev_desc[i].block_write = ide_write;
456 if (!ide_bus_ok[IDE_BUS(i)])
458 ide_led(led, 1); /* LED on */
459 ide_ident(&ide_dev_desc[i]);
460 ide_led(led, 0); /* LED off */
461 dev_print(&ide_dev_desc[i]);
463 if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) {
464 /* initialize partition type */
465 init_part(&ide_dev_desc[i]);
473 /* ------------------------------------------------------------------------- */
475 #ifdef CONFIG_PARTITIONS
476 block_dev_desc_t *ide_get_dev(int dev)
478 return (dev < CONFIG_SYS_IDE_MAXDEVICE) ? &ide_dev_desc[dev] : NULL;
482 /* ------------------------------------------------------------------------- */
484 void ide_input_swap_data(int dev, ulong *sect_buf, int words)
485 __attribute__ ((weak, alias("__ide_input_swap_data")));
487 void ide_input_data(int dev, ulong *sect_buf, int words)
488 __attribute__ ((weak, alias("__ide_input_data")));
490 void ide_output_data(int dev, const ulong *sect_buf, int words)
491 __attribute__ ((weak, alias("__ide_output_data")));
493 /* We only need to swap data if we are running on a big endian cpu. */
494 /* But Au1x00 cpu:s already swaps data in big endian mode! */
495 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SOC_AU1X00)
496 void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
498 ide_input_data(dev, sect_buf, words);
501 void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
503 #if defined(CONFIG_CPC45)
505 volatile uchar *pbuf_even =
506 (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
507 volatile uchar *pbuf_odd =
508 (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
509 ushort *dbuf = (ushort *) sect_buf;
512 for (i = 0; i < 2; i++) {
513 *(((uchar *) (dbuf)) + 1) = *pbuf_even;
514 *(uchar *) dbuf = *pbuf_odd;
519 volatile ushort *pbuf =
520 (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
521 ushort *dbuf = (ushort *) sect_buf;
523 debug("in input swap data base for read is %lx\n",
524 (unsigned long) pbuf);
528 *dbuf++ = swab16p((u16 *) pbuf);
529 *dbuf++ = swab16p((u16 *) pbuf);
530 #elif defined(CONFIG_PCS440EP)
534 *dbuf++ = ld_le16(pbuf);
535 *dbuf++ = ld_le16(pbuf);
540 #endif /* __LITTLE_ENDIAN || CONFIG_AU1X00 */
543 #if defined(CONFIG_IDE_SWAP_IO)
544 void __ide_output_data(int dev, const ulong *sect_buf, int words)
546 #if defined(CONFIG_CPC45)
548 volatile uchar *pbuf_even;
549 volatile uchar *pbuf_odd;
551 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
552 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
553 dbuf = (uchar *) sect_buf;
556 *pbuf_even = *dbuf++;
560 *pbuf_even = *dbuf++;
566 volatile ushort *pbuf;
568 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
569 dbuf = (ushort *) sect_buf;
571 #if defined(CONFIG_PCS440EP)
572 /* not tested, because CF was write protected */
574 *pbuf = ld_le16(dbuf++);
576 *pbuf = ld_le16(dbuf++);
586 #else /* ! CONFIG_IDE_SWAP_IO */
587 void __ide_output_data(int dev, const ulong *sect_buf, int words)
589 #if defined(CONFIG_IDE_AHB)
590 ide_write_data(dev, sect_buf, words);
592 outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, words << 1);
595 #endif /* CONFIG_IDE_SWAP_IO */
597 #if defined(CONFIG_IDE_SWAP_IO)
598 void __ide_input_data(int dev, ulong *sect_buf, int words)
600 #if defined(CONFIG_CPC45)
602 volatile uchar *pbuf_even;
603 volatile uchar *pbuf_odd;
605 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
606 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
607 dbuf = (uchar *) sect_buf;
609 *dbuf++ = *pbuf_even;
615 *dbuf++ = *pbuf_even;
624 volatile ushort *pbuf;
626 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
627 dbuf = (ushort *) sect_buf;
629 debug("in input data base for read is %lx\n", (unsigned long) pbuf);
632 #if defined(CONFIG_PCS440EP)
634 *dbuf++ = ld_le16(pbuf);
636 *dbuf++ = ld_le16(pbuf);
646 #else /* ! CONFIG_IDE_SWAP_IO */
647 void __ide_input_data(int dev, ulong *sect_buf, int words)
649 #if defined(CONFIG_IDE_AHB)
650 ide_read_data(dev, sect_buf, words);
652 insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, words << 1);
656 #endif /* CONFIG_IDE_SWAP_IO */
658 /* -------------------------------------------------------------------------
660 static void ide_ident(block_dev_desc_t *dev_desc)
669 #ifdef CONFIG_TUNE_PIO
674 int mode, cycle_time;
678 device = dev_desc->dev;
679 printf(" Device %d: ", device);
681 ide_led(DEVICE_LED(device), 1); /* LED on */
684 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
685 dev_desc->if_type = IF_TYPE_IDE;
690 /* Warning: This will be tricky to read */
691 while (retries <= 1) {
692 /* check signature */
693 if ((ide_inb(device, ATA_SECT_CNT) == 0x01) &&
694 (ide_inb(device, ATA_SECT_NUM) == 0x01) &&
695 (ide_inb(device, ATA_CYL_LOW) == 0x14) &&
696 (ide_inb(device, ATA_CYL_HIGH) == 0xEB)) {
697 /* ATAPI Signature found */
698 dev_desc->if_type = IF_TYPE_ATAPI;
700 * Start Ident Command
702 ide_outb(device, ATA_COMMAND, ATAPI_CMD_IDENT);
704 * Wait for completion - ATAPI devices need more time
707 c = ide_wait(device, ATAPI_TIME_OUT);
712 * Start Ident Command
714 ide_outb(device, ATA_COMMAND, ATA_CMD_IDENT);
717 * Wait for completion
719 c = ide_wait(device, IDE_TIME_OUT);
721 ide_led(DEVICE_LED(device), 0); /* LED off */
723 if (((c & ATA_STAT_DRQ) == 0) ||
724 ((c & (ATA_STAT_FAULT | ATA_STAT_ERR)) != 0)) {
728 * Need to soft reset the device
729 * in case it's an ATAPI...
731 debug("Retrying...\n");
732 ide_outb(device, ATA_DEV_HD,
733 ATA_LBA | ATA_DEVICE(device));
735 ide_outb(device, ATA_COMMAND, 0x08);
736 udelay(500000); /* 500 ms */
741 ide_outb(device, ATA_DEV_HD,
742 ATA_LBA | ATA_DEVICE(device));
751 } /* see above - ugly to read */
753 if (retries == 2) /* Not found */
757 ide_input_swap_data(device, (ulong *)&iop, ATA_SECTORWORDS);
759 ident_cpy((unsigned char *) dev_desc->revision, iop.fw_rev,
760 sizeof(dev_desc->revision));
761 ident_cpy((unsigned char *) dev_desc->vendor, iop.model,
762 sizeof(dev_desc->vendor));
763 ident_cpy((unsigned char *) dev_desc->product, iop.serial_no,
764 sizeof(dev_desc->product));
765 #ifdef __LITTLE_ENDIAN
767 * firmware revision, model, and serial number have Big Endian Byte
768 * order in Word. Convert all three to little endian.
770 * See CF+ and CompactFlash Specification Revision 2.0:
771 * 6.2.1.6: Identify Drive, Table 39 for more details
774 strswab(dev_desc->revision);
775 strswab(dev_desc->vendor);
776 strswab(dev_desc->product);
777 #endif /* __LITTLE_ENDIAN */
779 if ((iop.config & 0x0080) == 0x0080)
780 dev_desc->removable = 1;
782 dev_desc->removable = 0;
784 #ifdef CONFIG_TUNE_PIO
785 /* Mode 0 - 2 only, are directly determined by word 51. */
788 printf("WARNING: Invalid PIO (word 51 = %d).\n", pio_mode);
789 /* Force it to dead slow, and hope for the best... */
793 /* Any CompactFlash Storage Card that supports PIO mode 3 or above
794 * shall set bit 1 of word 53 to one and support the fields contained
795 * in words 64 through 70.
797 if (iop.field_valid & 0x02) {
799 * Mode 3 and above are possible. Check in order from slow
800 * to fast, so we wind up with the highest mode allowed.
802 if (iop.eide_pio_modes & 0x01)
804 if (iop.eide_pio_modes & 0x02)
806 if (ata_id_is_cfa((u16 *)&iop)) {
807 if ((iop.cf_advanced_caps & 0x07) == 0x01)
809 if ((iop.cf_advanced_caps & 0x07) == 0x02)
814 /* System-specific, depends on bus speeds, etc. */
815 ide_set_piomode(pio_mode);
816 #endif /* CONFIG_TUNE_PIO */
820 * Drive PIO mode autoselection
824 printf("tPIO = 0x%02x = %d\n", mode, mode);
825 if (mode > 2) { /* 2 is maximum allowed tPIO value */
827 debug("Override tPIO -> 2\n");
829 if (iop.field_valid & 2) { /* drive implements ATA2? */
830 debug("Drive implements ATA2\n");
831 if (iop.capability & 8) { /* drive supports use_iordy? */
832 cycle_time = iop.eide_pio_iordy;
834 cycle_time = iop.eide_pio;
836 debug("cycle time = %d\n", cycle_time);
838 if (cycle_time > 120)
839 mode = 3; /* 120 ns for PIO mode 4 */
840 if (cycle_time > 180)
841 mode = 2; /* 180 ns for PIO mode 3 */
842 if (cycle_time > 240)
843 mode = 1; /* 240 ns for PIO mode 4 */
844 if (cycle_time > 383)
845 mode = 0; /* 383 ns for PIO mode 4 */
847 printf("PIO mode to use: PIO %d\n", mode);
851 if (dev_desc->if_type == IF_TYPE_ATAPI) {
852 atapi_inquiry(dev_desc);
855 #endif /* CONFIG_ATAPI */
859 dev_desc->lba = (iop.lba_capacity << 16) | (iop.lba_capacity >> 16);
860 #else /* ! __BIG_ENDIAN */
862 * do not swap shorts on little endian
864 * See CF+ and CompactFlash Specification Revision 2.0:
865 * 6.2.1.6: Identfy Drive, Table 39, Word Address 57-58 for details.
867 dev_desc->lba = iop.lba_capacity;
868 #endif /* __BIG_ENDIAN */
871 if (iop.command_set_2 & 0x0400) { /* LBA 48 support */
873 dev_desc->lba = (unsigned long long) iop.lba48_capacity[0] |
874 ((unsigned long long) iop.lba48_capacity[1] << 16) |
875 ((unsigned long long) iop.lba48_capacity[2] << 32) |
876 ((unsigned long long) iop.lba48_capacity[3] << 48);
880 #endif /* CONFIG_LBA48 */
882 dev_desc->type = DEV_TYPE_HARDDISK;
883 dev_desc->blksz = ATA_BLOCKSIZE;
884 dev_desc->lun = 0; /* just to fill something in... */
886 #if 0 /* only used to test the powersaving mode,
887 * if enabled, the drive goes after 5 sec
889 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
890 c = ide_wait(device, IDE_TIME_OUT);
891 ide_outb(device, ATA_SECT_CNT, 1);
892 ide_outb(device, ATA_LBA_LOW, 0);
893 ide_outb(device, ATA_LBA_MID, 0);
894 ide_outb(device, ATA_LBA_HIGH, 0);
895 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
896 ide_outb(device, ATA_COMMAND, 0xe3);
898 c = ide_wait(device, IDE_TIME_OUT); /* can't take over 500 ms */
903 /* ------------------------------------------------------------------------- */
905 ulong ide_read(int device, lbaint_t blknr, ulong blkcnt, void *buffer)
909 unsigned char pwrsave = 0; /* power save */
912 unsigned char lba48 = 0;
914 if (blknr & 0x0000fffff0000000ULL) {
915 /* more than 28 bits used, use 48bit mode */
919 debug("ide_read dev %d start %lX, blocks %lX buffer at %lX\n",
920 device, blknr, blkcnt, (ulong) buffer);
922 ide_led(DEVICE_LED(device), 1); /* LED on */
926 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
927 c = ide_wait(device, IDE_TIME_OUT);
929 if (c & ATA_STAT_BUSY) {
930 printf("IDE read: device %d not ready\n", device);
934 /* first check if the drive is in Powersaving mode, if yes,
935 * increase the timeout value */
936 ide_outb(device, ATA_COMMAND, ATA_CMD_CHK_PWR);
939 c = ide_wait(device, IDE_TIME_OUT); /* can't take over 500 ms */
941 if (c & ATA_STAT_BUSY) {
942 printf("IDE read: device %d not ready\n", device);
945 if ((c & ATA_STAT_ERR) == ATA_STAT_ERR) {
946 printf("No Powersaving mode %X\n", c);
948 c = ide_inb(device, ATA_SECT_CNT);
949 debug("Powersaving %02X\n", c);
955 while (blkcnt-- > 0) {
957 c = ide_wait(device, IDE_TIME_OUT);
959 if (c & ATA_STAT_BUSY) {
960 printf("IDE read: device %d not ready\n", device);
965 /* write high bits */
966 ide_outb(device, ATA_SECT_CNT, 0);
967 ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF);
968 #ifdef CONFIG_SYS_64BIT_LBA
969 ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xFF);
970 ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
972 ide_outb(device, ATA_LBA_MID, 0);
973 ide_outb(device, ATA_LBA_HIGH, 0);
977 ide_outb(device, ATA_SECT_CNT, 1);
978 ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
979 ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
980 ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
984 ide_outb(device, ATA_DEV_HD,
985 ATA_LBA | ATA_DEVICE(device));
986 ide_outb(device, ATA_COMMAND, ATA_CMD_READ_EXT);
991 ide_outb(device, ATA_DEV_HD, ATA_LBA |
992 ATA_DEVICE(device) | ((blknr >> 24) & 0xF));
993 ide_outb(device, ATA_COMMAND, ATA_CMD_READ);
999 /* may take up to 4 sec */
1000 c = ide_wait(device, IDE_SPIN_UP_TIME_OUT);
1003 /* can't take over 500 ms */
1004 c = ide_wait(device, IDE_TIME_OUT);
1007 if ((c & (ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR)) !=
1009 #if defined(CONFIG_SYS_64BIT_LBA)
1010 printf("Error (no IRQ) dev %d blk %lld: status 0x%02x\n",
1013 printf("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
1014 device, (ulong) blknr, c);
1019 ide_input_data(device, buffer, ATA_SECTORWORDS);
1020 (void) ide_inb(device, ATA_STATUS); /* clear IRQ */
1024 buffer += ATA_BLOCKSIZE;
1027 ide_led(DEVICE_LED(device), 0); /* LED off */
1031 /* ------------------------------------------------------------------------- */
1034 ulong ide_write(int device, lbaint_t blknr, ulong blkcnt, const void *buffer)
1040 unsigned char lba48 = 0;
1042 if (blknr & 0x0000fffff0000000ULL) {
1043 /* more than 28 bits used, use 48bit mode */
1048 ide_led(DEVICE_LED(device), 1); /* LED on */
1052 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1054 while (blkcnt-- > 0) {
1056 c = ide_wait(device, IDE_TIME_OUT);
1058 if (c & ATA_STAT_BUSY) {
1059 printf("IDE read: device %d not ready\n", device);
1064 /* write high bits */
1065 ide_outb(device, ATA_SECT_CNT, 0);
1066 ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF);
1067 #ifdef CONFIG_SYS_64BIT_LBA
1068 ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xFF);
1069 ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
1071 ide_outb(device, ATA_LBA_MID, 0);
1072 ide_outb(device, ATA_LBA_HIGH, 0);
1076 ide_outb(device, ATA_SECT_CNT, 1);
1077 ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
1078 ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
1079 ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
1083 ide_outb(device, ATA_DEV_HD,
1084 ATA_LBA | ATA_DEVICE(device));
1085 ide_outb(device, ATA_COMMAND, ATA_CMD_WRITE_EXT);
1090 ide_outb(device, ATA_DEV_HD, ATA_LBA |
1091 ATA_DEVICE(device) | ((blknr >> 24) & 0xF));
1092 ide_outb(device, ATA_COMMAND, ATA_CMD_WRITE);
1097 /* can't take over 500 ms */
1098 c = ide_wait(device, IDE_TIME_OUT);
1100 if ((c & (ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR)) !=
1102 #if defined(CONFIG_SYS_64BIT_LBA)
1103 printf("Error (no IRQ) dev %d blk %lld: status 0x%02x\n",
1106 printf("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
1107 device, (ulong) blknr, c);
1112 ide_output_data(device, buffer, ATA_SECTORWORDS);
1113 c = ide_inb(device, ATA_STATUS); /* clear IRQ */
1116 buffer += ATA_BLOCKSIZE;
1119 ide_led(DEVICE_LED(device), 0); /* LED off */
1123 /* ------------------------------------------------------------------------- */
1126 * copy src to dest, skipping leading and trailing blanks and null
1127 * terminate the string
1128 * "len" is the size of available memory including the terminating '\0'
1130 static void ident_cpy(unsigned char *dst, unsigned char *src,
1133 unsigned char *end, *last;
1136 end = src + len - 1;
1138 /* reserve space for '\0' */
1142 /* skip leading white space */
1143 while ((*src) && (src < end) && (*src == ' '))
1146 /* copy string, omitting trailing white space */
1147 while ((*src) && (src < end)) {
1156 /* ------------------------------------------------------------------------- */
1159 * Wait until Busy bit is off, or timeout (in ms)
1160 * Return last status
1162 static uchar ide_wait(int dev, ulong t)
1164 ulong delay = 10 * t; /* poll every 100 us */
1167 while ((c = ide_inb(dev, ATA_STATUS)) & ATA_STAT_BUSY) {
1175 /* ------------------------------------------------------------------------- */
1177 #ifdef CONFIG_IDE_RESET
1178 extern void ide_set_reset(int idereset);
1180 static void ide_reset(void)
1185 for (i = 0; i < CONFIG_SYS_IDE_MAXBUS; ++i)
1187 for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i)
1188 ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
1190 ide_set_reset(1); /* assert reset */
1192 /* the reset signal shall be asserted for et least 25 us */
1197 /* de-assert RESET signal */
1201 for (i = 0; i < 250; ++i)
1205 #endif /* CONFIG_IDE_RESET */
1207 /* ------------------------------------------------------------------------- */
1209 #if defined(CONFIG_IDE_LED) && \
1210 !defined(CONFIG_CPC45) && \
1211 !defined(CONFIG_KUP4K) && \
1212 !defined(CONFIG_KUP4X)
1214 static uchar led_buffer; /* Buffer for current LED status */
1216 static void ide_led(uchar led, uchar status)
1218 uchar *led_port = LED_PORT;
1220 if (status) /* switch LED on */
1222 else /* switch LED off */
1225 *led_port = led_buffer;
1228 #endif /* CONFIG_IDE_LED */
1230 #if defined(CONFIG_OF_IDE_FIXUP)
1231 int ide_device_present(int dev)
1233 if (dev >= CONFIG_SYS_IDE_MAXBUS)
1235 return (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN ? 0 : 1);
1238 /* ------------------------------------------------------------------------- */
1241 /****************************************************************************
1245 void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
1246 __attribute__ ((weak, alias("__ide_input_data_shorts")));
1248 void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
1249 __attribute__ ((weak, alias("__ide_output_data_shorts")));
1252 #if defined(CONFIG_IDE_SWAP_IO)
1253 /* since ATAPI may use commands with not 4 bytes alligned length
1254 * we have our own transfer functions, 2 bytes alligned */
1255 void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
1257 #if defined(CONFIG_CPC45)
1259 volatile uchar *pbuf_even;
1260 volatile uchar *pbuf_odd;
1262 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
1263 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
1266 *pbuf_even = *dbuf++;
1268 *pbuf_odd = *dbuf++;
1272 volatile ushort *pbuf;
1274 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
1275 dbuf = (ushort *) sect_buf;
1277 debug("in output data shorts base for read is %lx\n",
1278 (unsigned long) pbuf);
1287 void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
1289 #if defined(CONFIG_CPC45)
1291 volatile uchar *pbuf_even;
1292 volatile uchar *pbuf_odd;
1294 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
1295 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
1298 *dbuf++ = *pbuf_even;
1300 *dbuf++ = *pbuf_odd;
1304 volatile ushort *pbuf;
1306 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
1307 dbuf = (ushort *) sect_buf;
1309 debug("in input data shorts base for read is %lx\n",
1310 (unsigned long) pbuf);
1319 #else /* ! CONFIG_IDE_SWAP_IO */
1320 void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
1322 outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
1325 void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
1327 insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
1330 #endif /* CONFIG_IDE_SWAP_IO */
1333 * Wait until (Status & mask) == res, or timeout (in ms)
1334 * Return last status
1335 * This is used since some ATAPI CD ROMs clears their Busy Bit first
1336 * and then they set their DRQ Bit
1338 static uchar atapi_wait_mask(int dev, ulong t, uchar mask, uchar res)
1340 ulong delay = 10 * t; /* poll every 100 us */
1343 /* prevents to read the status before valid */
1344 c = ide_inb(dev, ATA_DEV_CTL);
1346 while (((c = ide_inb(dev, ATA_STATUS)) & mask) != res) {
1347 /* break if error occurs (doesn't make sense to wait more) */
1348 if ((c & ATA_STAT_ERR) == ATA_STAT_ERR)
1358 * issue an atapi command
1360 unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen,
1361 unsigned char *buffer, int buflen)
1363 unsigned char c, err, mask, res;
1366 ide_led(DEVICE_LED(device), 1); /* LED on */
1370 mask = ATA_STAT_BUSY | ATA_STAT_DRQ;
1372 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1373 c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1374 if ((c & mask) != res) {
1375 printf("ATAPI_ISSUE: device %d not ready status %X\n", device,
1380 /* write taskfile */
1381 ide_outb(device, ATA_ERROR_REG, 0); /* no DMA, no overlaped */
1382 ide_outb(device, ATA_SECT_CNT, 0);
1383 ide_outb(device, ATA_SECT_NUM, 0);
1384 ide_outb(device, ATA_CYL_LOW, (unsigned char) (buflen & 0xFF));
1385 ide_outb(device, ATA_CYL_HIGH,
1386 (unsigned char) ((buflen >> 8) & 0xFF));
1387 ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1389 ide_outb(device, ATA_COMMAND, ATAPI_CMD_PACKET);
1392 mask = ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR;
1394 c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1396 if ((c & mask) != res) { /* DRQ must be 1, BSY 0 */
1397 printf("ATAPI_ISSUE: Error (no IRQ) before sending ccb dev %d status 0x%02x\n",
1403 /* write command block */
1404 ide_output_data_shorts(device, (unsigned short *) ccb, ccblen / 2);
1406 /* ATAPI Command written wait for completition */
1407 udelay(5000); /* device must set bsy */
1409 mask = ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR;
1411 * if no data wait for DRQ = 0 BSY = 0
1412 * if data wait for DRQ = 1 BSY = 0
1417 c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1418 if ((c & mask) != res) {
1419 if (c & ATA_STAT_ERR) {
1420 err = (ide_inb(device, ATA_ERROR_REG)) >> 4;
1421 debug("atapi_issue 1 returned sense key %X status %02X\n",
1424 printf("ATAPI_ISSUE: (no DRQ) after sending ccb (%x) status 0x%02x\n",
1430 n = ide_inb(device, ATA_CYL_HIGH);
1432 n += ide_inb(device, ATA_CYL_LOW);
1434 printf("ERROR, transfer bytes %d requested only %d\n", n,
1439 if ((n == 0) && (buflen < 0)) {
1440 printf("ERROR, transfer bytes %d requested %d\n", n, buflen);
1445 debug("WARNING, transfer bytes %d not equal with requested %d\n",
1448 if (n != 0) { /* data transfer */
1449 debug("ATAPI_ISSUE: %d Bytes to transfer\n", n);
1450 /* we transfer shorts */
1452 /* ok now decide if it is an in or output */
1453 if ((ide_inb(device, ATA_SECT_CNT) & 0x02) == 0) {
1454 debug("Write to device\n");
1455 ide_output_data_shorts(device,
1456 (unsigned short *) buffer, n);
1458 debug("Read from device @ %p shorts %d\n", buffer, n);
1459 ide_input_data_shorts(device,
1460 (unsigned short *) buffer, n);
1463 udelay(5000); /* seems that some CD ROMs need this... */
1464 mask = ATA_STAT_BUSY | ATA_STAT_ERR;
1466 c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1467 if ((c & ATA_STAT_ERR) == ATA_STAT_ERR) {
1468 err = (ide_inb(device, ATA_ERROR_REG) >> 4);
1469 debug("atapi_issue 2 returned sense key %X status %X\n", err,
1475 ide_led(DEVICE_LED(device), 0); /* LED off */
1480 * sending the command to atapi_issue. If an status other than good
1481 * returns, an request_sense will be issued
1484 #define ATAPI_DRIVE_NOT_READY 100
1485 #define ATAPI_UNIT_ATTN 10
1487 unsigned char atapi_issue_autoreq(int device,
1490 unsigned char *buffer, int buflen)
1492 unsigned char sense_data[18], sense_ccb[12];
1493 unsigned char res, key, asc, ascq;
1494 int notready, unitattn;
1496 unitattn = ATAPI_UNIT_ATTN;
1497 notready = ATAPI_DRIVE_NOT_READY;
1500 res = atapi_issue(device, ccb, ccblen, buffer, buflen);
1505 return 0xFF; /* error */
1507 debug("(auto_req)atapi_issue returned sense key %X\n", res);
1509 memset(sense_ccb, 0, sizeof(sense_ccb));
1510 memset(sense_data, 0, sizeof(sense_data));
1511 sense_ccb[0] = ATAPI_CMD_REQ_SENSE;
1512 sense_ccb[4] = 18; /* allocation Length */
1514 res = atapi_issue(device, sense_ccb, 12, sense_data, 18);
1515 key = (sense_data[2] & 0xF);
1516 asc = (sense_data[12]);
1517 ascq = (sense_data[13]);
1519 debug("ATAPI_CMD_REQ_SENSE returned %x\n", res);
1520 debug(" Sense page: %02X key %02X ASC %02X ASCQ %02X\n",
1521 sense_data[0], key, asc, ascq);
1524 return 0; /* ok device ready */
1526 if ((key == 6) || (asc == 0x29) || (asc == 0x28)) { /* Unit Attention */
1527 if (unitattn-- > 0) {
1531 printf("Unit Attention, tried %d\n", ATAPI_UNIT_ATTN);
1534 if ((asc == 0x4) && (ascq == 0x1)) {
1535 /* not ready, but will be ready soon */
1536 if (notready-- > 0) {
1540 printf("Drive not ready, tried %d times\n",
1541 ATAPI_DRIVE_NOT_READY);
1545 debug("Media not present\n");
1549 printf("ERROR: Unknown Sense key %02X ASC %02X ASCQ %02X\n", key, asc,
1552 debug("ERROR Sense key %02X ASC %02X ASCQ %02X\n", key, asc, ascq);
1557 static void atapi_inquiry(block_dev_desc_t *dev_desc)
1559 unsigned char ccb[12]; /* Command descriptor block */
1560 unsigned char iobuf[64]; /* temp buf */
1564 device = dev_desc->dev;
1565 dev_desc->type = DEV_TYPE_UNKNOWN; /* not yet valid */
1566 dev_desc->block_read = atapi_read;
1568 memset(ccb, 0, sizeof(ccb));
1569 memset(iobuf, 0, sizeof(iobuf));
1571 ccb[0] = ATAPI_CMD_INQUIRY;
1572 ccb[4] = 40; /* allocation Legnth */
1573 c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 40);
1575 debug("ATAPI_CMD_INQUIRY returned %x\n", c);
1579 /* copy device ident strings */
1580 ident_cpy((unsigned char *) dev_desc->vendor, &iobuf[8], 8);
1581 ident_cpy((unsigned char *) dev_desc->product, &iobuf[16], 16);
1582 ident_cpy((unsigned char *) dev_desc->revision, &iobuf[32], 5);
1586 dev_desc->blksz = 0;
1587 dev_desc->type = iobuf[0] & 0x1f;
1589 if ((iobuf[1] & 0x80) == 0x80)
1590 dev_desc->removable = 1;
1592 dev_desc->removable = 0;
1594 memset(ccb, 0, sizeof(ccb));
1595 memset(iobuf, 0, sizeof(iobuf));
1596 ccb[0] = ATAPI_CMD_START_STOP;
1597 ccb[4] = 0x03; /* start */
1599 c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 0);
1601 debug("ATAPI_CMD_START_STOP returned %x\n", c);
1605 memset(ccb, 0, sizeof(ccb));
1606 memset(iobuf, 0, sizeof(iobuf));
1607 c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 0);
1609 debug("ATAPI_CMD_UNIT_TEST_READY returned %x\n", c);
1613 memset(ccb, 0, sizeof(ccb));
1614 memset(iobuf, 0, sizeof(iobuf));
1615 ccb[0] = ATAPI_CMD_READ_CAP;
1616 c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 8);
1617 debug("ATAPI_CMD_READ_CAP returned %x\n", c);
1621 debug("Read Cap: LBA %02X%02X%02X%02X blksize %02X%02X%02X%02X\n",
1622 iobuf[0], iobuf[1], iobuf[2], iobuf[3],
1623 iobuf[4], iobuf[5], iobuf[6], iobuf[7]);
1625 dev_desc->lba = ((unsigned long) iobuf[0] << 24) +
1626 ((unsigned long) iobuf[1] << 16) +
1627 ((unsigned long) iobuf[2] << 8) + ((unsigned long) iobuf[3]);
1628 dev_desc->blksz = ((unsigned long) iobuf[4] << 24) +
1629 ((unsigned long) iobuf[5] << 16) +
1630 ((unsigned long) iobuf[6] << 8) + ((unsigned long) iobuf[7]);
1632 /* ATAPI devices cannot use 48bit addressing (ATA/ATAPI v7) */
1633 dev_desc->lba48 = 0;
1641 * we transfer only one block per command, since the multiple DRQ per
1642 * command is not yet implemented
1644 #define ATAPI_READ_MAX_BYTES 2048 /* we read max 2kbytes */
1645 #define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */
1646 #define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE)
1648 ulong atapi_read(int device, lbaint_t blknr, ulong blkcnt, void *buffer)
1651 unsigned char ccb[12]; /* Command descriptor block */
1654 debug("atapi_read dev %d start %lX, blocks %lX buffer at %lX\n",
1655 device, blknr, blkcnt, (ulong) buffer);
1658 if (blkcnt > ATAPI_READ_MAX_BLOCK)
1659 cnt = ATAPI_READ_MAX_BLOCK;
1663 ccb[0] = ATAPI_CMD_READ_12;
1664 ccb[1] = 0; /* reserved */
1665 ccb[2] = (unsigned char) (blknr >> 24) & 0xFF; /* MSB Block */
1666 ccb[3] = (unsigned char) (blknr >> 16) & 0xFF; /* */
1667 ccb[4] = (unsigned char) (blknr >> 8) & 0xFF;
1668 ccb[5] = (unsigned char) blknr & 0xFF; /* LSB Block */
1669 ccb[6] = (unsigned char) (cnt >> 24) & 0xFF; /* MSB Block cnt */
1670 ccb[7] = (unsigned char) (cnt >> 16) & 0xFF;
1671 ccb[8] = (unsigned char) (cnt >> 8) & 0xFF;
1672 ccb[9] = (unsigned char) cnt & 0xFF; /* LSB Block */
1673 ccb[10] = 0; /* reserved */
1674 ccb[11] = 0; /* reserved */
1676 if (atapi_issue_autoreq(device, ccb, 12,
1677 (unsigned char *) buffer,
1678 cnt * ATAPI_READ_BLOCK_SIZE)
1685 buffer += (cnt * ATAPI_READ_BLOCK_SIZE);
1686 } while (blkcnt > 0);
1690 /* ------------------------------------------------------------------------- */
1692 #endif /* CONFIG_ATAPI */
1694 U_BOOT_CMD(ide, 5, 1, do_ide,
1696 "reset - reset IDE controller\n"
1697 "ide info - show available IDE devices\n"
1698 "ide device [dev] - show or set current device\n"
1699 "ide part [dev] - print partition table of one or all IDE devices\n"
1700 "ide read addr blk# cnt\n"
1701 "ide write addr blk# cnt - read/write `cnt'"
1702 " blocks starting at block `blk#'\n"
1703 " to/from memory address `addr'");
1705 U_BOOT_CMD(diskboot, 3, 1, do_diskboot,
1706 "boot from IDE device", "loadAddr dev:part");