* [U-Boot-Users] [PATCH] changes to IDE driver for LSB machines
@ 2003-08-14 18:31 Marc Singer
2003-08-14 19:54 ` Wolfgang Denk
0 siblings, 1 reply; 2+ messages in thread
From: Marc Singer @ 2003-08-14 18:31 UTC (permalink / raw)
To: u-boot
Aside from the ARM additions, there are changes to allow the IDE code
to run on other little endian machines IA32, mips.
BTW, the macro names, WORDS_BIGENDIAN and BYTES_BIGENDIAN come from
autoconf.
Also, the endianness of mips isn't clear. Like PPC, it can do either
and as far as I can tell both are supported by Debian.
Cheers.
-------------- 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:14:28.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 (WORDS_BIGENDIAN)
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 (BYTES_BIGENDIAN) || 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;
}
/* ------------------------------------------------------------------------- */
diff -ruN --exclude '*.o' --exclude='*.map' --exclude '*~' --exclude '*-orig' --exclude=.depend --exclude=configx.mk --exclude='*.srec' --exclude='*.a' u-boot-0.4.5/ppc_config.mk u-boot/ppc_config.mk
--- u-boot-0.4.5/ppc_config.mk 2002-11-10 14:06:23.000000000 -0800
+++ u-boot/ppc_config.mk 2003-08-14 10:40:08.000000000 -0700
@@ -23,3 +23,4 @@
PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
PLATFORM_LDFLAGS += -n
+PLATFORM_CPPFLAGS += -DWORDS_BIGENDIAN -DBYTES_BIGENDIAN
^ permalink raw reply [flat|nested] 2+ messages in thread
* [U-Boot-Users] [PATCH] changes to IDE driver for LSB machines
2003-08-14 18:31 [U-Boot-Users] [PATCH] changes to IDE driver for LSB machines Marc Singer
@ 2003-08-14 19:54 ` Wolfgang Denk
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2003-08-14 19:54 UTC (permalink / raw)
To: u-boot
In message <20030814183104.GA23820@buici.com> you wrote:
>
> Aside from the ARM additions, there are changes to allow the IDE code
> to run on other little endian machines IA32, mips.
>
> BTW, the macro names, WORDS_BIGENDIAN and BYTES_BIGENDIAN come from
> autoconf.
Maybe. But we don't use autoconf in U-Boot. I don;t like to invent
new macro names if there is a working mechanism in place already.
Please use <include/asm/byteorder.h>".
> Also, the endianness of mips isn't clear. Like PPC, it can do either
> and as far as I can tell both are supported by Debian.
This is why I do not want to base such stuff on the name of the
architecture. There is a generic way to solve this issue, so please
let's use this.
> +* 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.
Please separate the new board support from the changes to the IDE
driver.
BTW: I don't see any new board support stuff in this patch???
> +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);
Please don't use C++ comments.
> {
> - int start,end;
> +#if !defined (BYTES_BIGENDIAN) || defined (__PPC__)
...
I quote yourself::
"Also, the endianness of mips isn't clear. Like PPC, it can
do either..."
And here you base an assumption on the architecture name? Please
decide what you want.
And below you add BYTES_BIGENDIAN for PPC systems, so this makes
really little sense to me.
> PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
> PLATFORM_LDFLAGS += -n
> +PLATFORM_CPPFLAGS += -DWORDS_BIGENDIAN -DBYTES_BIGENDIAN
This just pollutes the namespace and is 100% redundand. Please use
the existent macros.
Patch rejected.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de
By the way, ALL software projects are done by iterative prototyping.
Some companies call their prototypes "releases", that's all.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-08-14 19:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-14 18:31 [U-Boot-Users] [PATCH] changes to IDE driver for LSB machines Marc Singer
2003-08-14 19:54 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox