[U-Boot-Users] [PATCH] updated IDE patch for __LITTLE_ENDIAN CPUs
Marc Singer
elf at buici.com
Thu Aug 14 20:59:18 CEST 2003
Now using the existing byteorder macros.
-------------- next part --------------
diff -ruN --exclude '*.o' --exclude='*.map' --exclude '*~' --exclude '*-orig' --exclude=.depend --exclude=configx.mk --exclude='*.srec' --exclude='*.a' u-boot-0.4.5/CHANGELOG u-boot/CHANGELOG
--- u-boot-0.4.5/CHANGELOG 2003-08-07 15:18:11.000000000 -0700
+++ u-boot/CHANGELOG 2003-08-14 11:29:34.000000000 -0700
@@ -2,6 +2,11 @@
Changes for U-Boot 0.4.5:
======================================================================
+* Patch by Marc Singer, 14 Aug 2003
+ - New target, Sharp KEV7A400
+ - New configuration method using mkconfigx script
+ - IDE drivers changes to support little endian CPUs.
+
* Update for TQM board defaults:
disable clocks_in_mhz, enable boot count limit
diff -ruN --exclude '*.o' --exclude='*.map' --exclude '*~' --exclude '*-orig' --exclude=.depend --exclude=configx.mk --exclude='*.srec' --exclude='*.a' u-boot-0.4.5/common/cmd_ide.c u-boot/common/cmd_ide.c
--- u-boot-0.4.5/common/cmd_ide.c 2003-07-01 14:07:07.000000000 -0700
+++ u-boot/common/cmd_ide.c 2003-08-14 11:55:12.000000000 -0700
@@ -42,7 +42,10 @@
#ifdef CONFIG_STATUS_LED
# include <status_led.h>
#endif
-#ifdef __I386__
+#if defined (__I386__)
+#include <asm/io.h>
+#endif
+#if defined (__ARM__)
#include <asm/io.h>
#endif
@@ -120,6 +123,10 @@
#define ATA_CURR_BASE(dev) (CFG_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
#endif
+#if defined (__ARM__)
+#define ATA_CURR_BASE(dev) (CFG_ATA_BASE_ADDR)
+#endif
+
#ifndef CONFIG_AMIGAONEG3SE
static int ide_bus_ok[CFG_IDE_MAXBUS];
#else
@@ -559,7 +566,7 @@
continue;
}
#endif
- printf ("Bus %d: ", bus);
+ printf ("Bus %d (dev %x):", bus, dev);
ide_bus_ok[bus] = 0;
@@ -759,6 +766,16 @@
printf ("ide_outb: 0x%08lx <== 0x%02x\n", ATA_CURR_BASE(dev)+port, val);
#endif
}
+#elif defined (__ARM__)
+static void __inline__
+ide_outb(int dev, int port, unsigned char val)
+{
+ volatile u32* p = (void*) ATA_CURR_BASE(dev)+(port << 2);
+ *p = val;
+#if 0
+ printf ("ide_outb: 0x%08x <== 0x%02x\n", (u32) p, val);
+#endif
+}
#else /* ! __PPC__ */
static void __inline__
ide_outb(int dev, int port, unsigned char val)
@@ -781,11 +798,23 @@
#endif
return (val);
}
+#elif defined (__ARM__)
+static unsigned char __inline__
+ide_inb(int dev, int port)
+{
+ volatile u32* p = (volatile void*)(ATA_CURR_BASE (dev) + (port << 2));
+ u16 val = *p;
+
+#if 0
+ printf ("ide_inb_arm: 0x%08x ==> 0x%02x\n", (u32) p, val);
+#endif
+ return ((uchar)val);
+}
#else /* ! __PPC__ */
static unsigned char __inline__
ide_inb(int dev, int port)
{
- return inb(port);
+ return inb (port);
}
#endif /* __PPC__ */
@@ -866,7 +895,18 @@
*dbuf++ = *pbuf;
}
}
-#else /* ! __PPC__ */
+#elif defined (__ARM__)
+static void
+input_data(int dev, ulong *sect_buf, int words)
+{
+ volatile u32* p = (volatile void*)(ATA_CURR_BASE (dev));
+ u16* rg = (void*) sect_buf;
+ while (words--)
+ *rg++ = (*p)&0xffff;
+
+ // insw(ATA_DATA_REG, sect_buf, words << 1);
+}
+#else
static void
input_data(int dev, ulong *sect_buf, int words)
{
@@ -1055,8 +1095,15 @@
}
#endif /* CONFIG_ATAPI */
- /* swap shorts */
+ /* Oddly, the IDE interface stores the capacity datum in LSB
+ * order even though the identification strings are stored in MSB
+ * order. [Compact Flash spec 2.0, section 6.2.1.6,
+ * Identify Drive Command] */
+#if defined (__BIG_ENDIAN)
dev_desc->lba = (iop->lba_capacity << 16) | (iop->lba_capacity >> 16);
+#else
+ dev_desc->lba = iop->lba_capacity;
+#endif
/* assuming HD */
dev_desc->type=DEV_TYPE_HARDDISK;
dev_desc->blksz=ATA_BLOCKSIZE;
@@ -1230,24 +1277,32 @@
*/
static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len)
{
- int start,end;
+#if defined (__LITTLE_ENDIAN) || defined (__PPC__)
+ /* Identity strings are stored in MSB order. Swap them on LSB
+ machines to make them look right.
+
+ We also have to do this on PPC because it uses the function
+ input_swap_data to reorder all input data. In the case of
+ the identity strings, it is reversing the byte order. */
- start=0;
- while (start<len) {
- if (src[start]!=' ')
- break;
- start++;
- }
- end=len-1;
- while (end>start) {
- if (src[end]!=' ')
- break;
- end--;
+ {
+ int i = len/2;
+ while (i--)
+ ((u16*) src)[i] = (((u16*) src)[i] >> 8) | (((u16*) src)[i] << 8);
}
- for ( ; start<=end; start++) {
- *dest++=src[start];
+#endif
+
+ while (*src == ' ' || *src == 0) {
+ ++src;
+ --len;
}
- *dest='\0';
+
+ while ((len && src[len - 1] == ' ') || src[len - 1] == 0)
+ --len;
+
+ while (len--)
+ *dest++ = *src++;
+ *dest = 0;
}
/* ------------------------------------------------------------------------- */
More information about the U-Boot
mailing list