From: Marc Singer <elf@buici.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] updated IDE patch for __LITTLE_ENDIAN CPUs
Date: Thu, 14 Aug 2003 11:59:18 -0700 [thread overview]
Message-ID: <20030814185918.GA5740@buici.com> (raw)
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;
}
/* ------------------------------------------------------------------------- */
next reply other threads:[~2003-08-14 18:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-14 18:59 Marc Singer [this message]
2003-08-14 19:56 ` [U-Boot-Users] [PATCH] updated IDE patch for __LITTLE_ENDIAN CPUs Wolfgang Denk
2003-08-14 20:09 ` Marc Singer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030814185918.GA5740@buici.com \
--to=elf@buici.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.