public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] updated IDE patch for __LITTLE_ENDIAN CPUs
@ 2003-08-14 18:59 Marc Singer
  2003-08-14 19:56 ` Wolfgang Denk
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Singer @ 2003-08-14 18:59 UTC (permalink / raw)
  To: u-boot

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;
 }
 
 /* ------------------------------------------------------------------------- */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot-Users] [PATCH] updated IDE patch for __LITTLE_ENDIAN CPUs
  2003-08-14 18:59 [U-Boot-Users] [PATCH] updated IDE patch for __LITTLE_ENDIAN CPUs Marc Singer
@ 2003-08-14 19:56 ` Wolfgang Denk
  2003-08-14 20:09   ` Marc Singer
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Denk @ 2003-08-14 19:56 UTC (permalink / raw)
  To: u-boot

In message <20030814185918.GA5740@buici.com> you wrote:
> 
> Now using the existing byteorder macros.

Arrrrrgghhh...


Can you please sort this out BEFORE posting this stuff to the mailing
list?

You are just wasting my time.

>  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.

This is obviously wrong. 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
Tactical? TACTICAL!?!? Hey, buddy, we went from kilotons to  megatons
several  minutes  ago.  We don't need no stinkin' tactical nukes. (By
the way, do you have change for 10 million people?)           - lwall

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot-Users] [PATCH] updated IDE patch for __LITTLE_ENDIAN CPUs
  2003-08-14 19:56 ` Wolfgang Denk
@ 2003-08-14 20:09   ` Marc Singer
  0 siblings, 0 replies; 3+ messages in thread
From: Marc Singer @ 2003-08-14 20:09 UTC (permalink / raw)
  To: u-boot

The comment is CHANGELOG is corrected and the C++ comment removed.
-------------- 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 13:02:49.000000000 -0700
@@ -2,6 +2,9 @@
 Changes for U-Boot 0.4.5:
 ======================================================================
 
+* Patch by Marc Singer, 14 Aug 2003
+  - 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;
 }
 
 /* ------------------------------------------------------------------------- */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-08-14 20:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-14 18:59 [U-Boot-Users] [PATCH] updated IDE patch for __LITTLE_ENDIAN CPUs Marc Singer
2003-08-14 19:56 ` Wolfgang Denk
2003-08-14 20:09   ` Marc Singer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox