]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_ide.c
Fix IDE stability problems on CPC45 board.
[u-boot] / common / cmd_ide.c
index 0c9927be744e04622ff467d6658751ae36662d92..b8e0bef574289e6fd112fff5ba1e27519bb6f618 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000-2002
+ * (C) Copyright 2000-2004
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
@@ -140,11 +140,11 @@ static int            ide_bus_ok[CFG_IDE_MAXBUS];
 static int         ide_bus_ok[CFG_IDE_MAXBUS] = {0,};
 #endif
 
-static  block_dev_desc_t ide_dev_desc[CFG_IDE_MAXDEVICE];
+block_dev_desc_t ide_dev_desc[CFG_IDE_MAXDEVICE];
 /* ------------------------------------------------------------------------- */
 
 #ifdef CONFIG_IDE_LED
-#if !defined(CONFIG_KUP4K) &&  !defined(CONFIG_KUP4X) &&!defined(CONFIG_BMS2003)
+#if !defined(CONFIG_KUP4K) &&  !defined(CONFIG_KUP4X) &&!defined(CONFIG_BMS2003) &&!defined(CONFIG_CPC45)
 static void  ide_led   (uchar led, uchar status);
 #else
 extern void  ide_led   (uchar led, uchar status);
@@ -957,13 +957,17 @@ input_data(int dev, ulong *sect_buf, int words)
        pbuf_odd  = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
        dbuf = (uchar *)sect_buf;
        while (words--) {
+               EIEIO;
                EIEIO;
                *dbuf++ = *pbuf_even;
                EIEIO;
+               EIEIO;
                *dbuf++ = *pbuf_odd;
                EIEIO;
+               EIEIO;
                *dbuf++ = *pbuf_even;
                EIEIO;
+               EIEIO;
                *dbuf++ = *pbuf_odd;
        }
 #endif /* CONFIG_HMI10 */
@@ -1009,8 +1013,10 @@ static void ide_ident (block_dev_desc_t *dev_desc)
 
 #ifdef CONFIG_AMIGAONEG3SE
        int max_bus_scan;
-       int retries = 0;
        char *s;
+#endif
+#ifdef CONFIG_ATAPI
+       int retries = 0;
        int do_retry = 0;
 #endif
 
@@ -1041,14 +1047,11 @@ static void ide_ident (block_dev_desc_t *dev_desc)
        dev_desc->if_type=IF_TYPE_IDE;
 #ifdef CONFIG_ATAPI
 
-#ifdef CONFIG_AMIGAONEG3SE
     do_retry = 0;
     retries = 0;
 
     /* Warning: This will be tricky to read */
     while (retries <= 1) {
-#endif /* CONFIG_AMIGAONEG3SE */
-
        /* check signature */
        if ((ide_inb(device,ATA_SECT_CNT) == 0x01) &&
                 (ide_inb(device,ATA_SECT_NUM) == 0x01) &&
@@ -1079,32 +1082,35 @@ static void ide_ident (block_dev_desc_t *dev_desc)
 
        if (((c & ATA_STAT_DRQ) == 0) ||
            ((c & (ATA_STAT_FAULT|ATA_STAT_ERR)) != 0) ) {
+#ifdef CONFIG_ATAPI
 #ifdef CONFIG_AMIGAONEG3SE
-               if (retries == 0) {
-                       do_retry = 1;
-               } else {
-                       return;
-               }
-#else
-               return;
-#endif /* CONFIG_AMIGAONEG3SE */
-       }
-
-#ifdef CONFIG_AMIGAONEG3SE
-       s = getenv("ide_doreset");
-       if (s && strcmp(s, "on") == 0 && 1 == do_retry) {
-               /* Need to soft reset the device in case it's an ATAPI...  */
-               PRINTF("Retrying...\n");
+               s = getenv("ide_doreset");
+               if (s && strcmp(s, "on") == 0)
+#endif
+                       {
+                               /* Need to soft reset the device in case it's an ATAPI...  */
+                               PRINTF("Retrying...\n");
+                               ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
+                               udelay(100000);
+                               ide_outb (device, ATA_COMMAND, 0x08);
+                               udelay (500000);        /* 500 ms */
+                       }
+               /* Select device
+                */
                ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
-               udelay(100000);
-               ide_outb (device, ATA_COMMAND, 0x08);
-               udelay (100000);        /* 100 ms */
                retries++;
-       } else {
-               retries = 100;
+#else
+               return;
+#endif
        }
+#ifdef CONFIG_ATAPI
+       else
+               break;
     }  /* see above - ugly to read */
-#endif /* CONFIG_AMIGAONEG3SE */
+
+       if (retries == 2) /* Not found */
+               return;
+#endif
 
        input_swap_data (device, iobuf, ATA_SECTORWORDS);
 
@@ -1546,11 +1552,12 @@ static void ide_reset (void)
 
 /* ------------------------------------------------------------------------- */
 
-#if defined(CONFIG_IDE_LED) && \
-   !defined(CONFIG_AMIGAONEG3SE) && \
-   !defined(CONFIG_KUP4K) && \
-   !defined(CONFIG_KUP4X) && \
-   !defined(CONFIG_HMI10)
+#if defined(CONFIG_IDE_LED)    && \
+   !defined(CONFIG_AMIGAONEG3SE)&& \
+   !defined(CONFIG_CPC45)      && \
+   !defined(CONFIG_HMI10)      && \
+   !defined(CONFIG_KUP4K)      && \
+   !defined(CONFIG_KUP4X)
 
 static uchar   led_buffer = 0;         /* Buffer for current LED status        */
 
@@ -1576,7 +1583,6 @@ static void ide_led (uchar led, uchar status)
  * ATAPI Support
  */
 
-
 #undef ATAPI_DEBUG
 
 #ifdef ATAPI_DEBUG
@@ -1659,7 +1665,6 @@ output_data_shorts(int dev, ushort *sect_buf, int shorts)
        outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, shorts);
 }
 
-
 static void
 input_data_shorts(int dev, ushort *sect_buf, int shorts)
 {