summaryrefslogtreecommitdiff
path: root/board/hymod
diff options
context:
space:
mode:
authorwdenk <wdenk>2003-06-21 00:17:24 +0000
committerwdenk <wdenk>2003-06-21 00:17:24 +0000
commit592c5cabe78fe1cef4eb733904c81a9555d59a7e (patch)
tree7655563542f63358451ed964d0f49d2f803846d4 /board/hymod
parent72755c7137396fdd8230dfc498294760fa2aaeb4 (diff)
downloadu-boot-imx-592c5cabe78fe1cef4eb733904c81a9555d59a7e.zip
u-boot-imx-592c5cabe78fe1cef4eb733904c81a9555d59a7e.tar.gz
u-boot-imx-592c5cabe78fe1cef4eb733904c81a9555d59a7e.tar.bz2
Patch by Murray Jensen, 20 Jun 2003:
- hymod update - cleanup (especially for gcc-3.x compilers)
Diffstat (limited to 'board/hymod')
-rw-r--r--board/hymod/config.mk2
-rw-r--r--board/hymod/eeprom.c171
-rw-r--r--board/hymod/flash.c24
-rw-r--r--board/hymod/flash.h2
-rw-r--r--board/hymod/global_env21
5 files changed, 118 insertions, 102 deletions
diff --git a/board/hymod/config.mk b/board/hymod/config.mk
index ccc7f38..0a9985f 100644
--- a/board/hymod/config.mk
+++ b/board/hymod/config.mk
@@ -27,6 +27,6 @@
TEXT_BASE = 0x40000000
-PLATFORM_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) -I$(TOPDIR)
+PLATFORM_CPPFLAGS += -I$(TOPDIR)
OBJCFLAGS = --remove-section=.ppcenv
diff --git a/board/hymod/eeprom.c b/board/hymod/eeprom.c
index 01e1453..15eb48e 100644
--- a/board/hymod/eeprom.c
+++ b/board/hymod/eeprom.c
@@ -39,62 +39,61 @@ hymod_eeprom_load (int which, hymod_eeprom_t *ep)
unsigned dev_addr = CFG_I2C_EEPROM_ADDR | \
(which ? HYMOD_EEOFF_MEZZ : HYMOD_EEOFF_MAIN);
unsigned offset = 0;
- uchar data[HYMOD_EEPROM_SIZE], *dp, *edp;
- hymod_eehdr_t *hp;
+ uchar data[HYMOD_EEPROM_MAXLEN], *dp, *edp;
+ hymod_eehdr_t hdr;
ulong len, crc;
memset (ep, 0, sizeof *ep);
- memset (data, 0, HYMOD_EEPROM_SIZE);
- crc = 0;
- hp = (hymod_eehdr_t *)data;
- eeprom_read (dev_addr, offset, (uchar *)hp, sizeof (*hp));
- offset += sizeof (*hp);
+ eeprom_read (dev_addr, offset, (uchar *)&hdr, sizeof (hdr));
+ offset += sizeof (hdr);
- if (hp->id != HYMOD_EEPROM_ID || hp->ver > HYMOD_EEPROM_VER ||
- (len = hp->len) > HYMOD_EEPROM_MAXLEN)
+ if (hdr.id != HYMOD_EEPROM_ID || hdr.ver > HYMOD_EEPROM_VER ||
+ (len = hdr.len) > HYMOD_EEPROM_MAXLEN)
return (0);
- dp = (uchar *)(hp + 1); edp = dp + len;
- eeprom_read (dev_addr, offset, dp, len);
+ eeprom_read (dev_addr, offset, data, len);
offset += len;
eeprom_read (dev_addr, offset, (uchar *)&crc, sizeof (ulong));
+ offset += sizeof (ulong);
- if (crc32 (0, data, edp - data) != crc)
+ if (crc32 (crc32 (0, (char *)&hdr, sizeof hdr), data, len) != crc)
return (0);
- ep->ver = hp->ver;
+ ep->ver = hdr.ver;
+ dp = data; edp = dp + len;
for (;;) {
- hymod_eerec_t *rp = (hymod_eerec_t *)dp;
ulong rtyp;
uchar rlen, *rdat;
- uint rsiz;
- if (rp->small.topbit == 0) {
- rtyp = rp->small.type;
- rlen = rp->small.len;
- rdat = rp->small.data;
- rsiz = offsetof (hymod_eerec_t, small.data) + rlen;
- }
- else if (rp->medium.nxtbit == 0) {
- rtyp = rp->medium.type;
- rlen = rp->medium.len;
- rdat = rp->medium.data;
- rsiz = offsetof (hymod_eerec_t, medium.data) + rlen;
- }
+ rtyp = *dp++;
+ if ((rtyp & 0x80) == 0)
+ rlen = *dp++;
else {
- rtyp = rp->large.type;
- rlen = rp->large.len;
- rdat = rp->large.data;
- rsiz = offsetof (hymod_eerec_t, large.data) + rlen;
+ uchar islarge = rtyp & 0x40;
+
+ rtyp = ((rtyp & 0x3f) << 8) | *dp++;
+ if (islarge) {
+ rtyp = (rtyp << 8) | *dp++;
+ rtyp = (rtyp << 8) | *dp++;
+ }
+
+ rlen = *dp++;
+ rlen = (rlen << 8) | *dp++;
+ if (islarge) {
+ rlen = (rlen << 8) | *dp++;
+ rlen = (rlen << 8) | *dp++;
+ }
}
if (rtyp == 0)
break;
- dp += rsiz;
+ rdat = dp;
+ dp += rlen;
+
if (dp > edp) /* error? */
break;
@@ -102,12 +101,20 @@ hymod_eeprom_load (int which, hymod_eeprom_t *ep)
case HYMOD_EEREC_SERNO: /* serial number */
if (rlen == sizeof (ulong))
- memcpy (&ep->serno, rdat, sizeof (ulong));
+ ep->serno = \
+ ((ulong)rdat[0] << 24) | \
+ ((ulong)rdat[1] << 16) | \
+ ((ulong)rdat[2] << 8) | \
+ (ulong)rdat[3];
break;
case HYMOD_EEREC_DATE: /* date */
- if (rlen == sizeof (hymod_date_t))
- memcpy (&ep->date, rdat, sizeof (hymod_date_t));
+ if (rlen == sizeof (hymod_date_t)) {
+ ep->date.year = ((ushort)rdat[0] << 8) | \
+ (ushort)rdat[1];
+ ep->date.month = rdat[2];
+ ep->date.day = rdat[3];
+ }
break;
case HYMOD_EEREC_BATCH: /* batch */
@@ -250,18 +257,13 @@ eerec_map_t;
static uchar *
uint_handler (eerec_map_t *rp, uchar *val, uchar *dp, uchar *edp)
{
- uchar *eval;
- union {
- uchar cval[4];
- ushort sval[2];
- ulong lval;
- } rdata;
+ char *eval;
+ ulong lval;
- rdata.lval = simple_strtol (val, (char **)&eval, 10);
+ lval = simple_strtol (val, &eval, 10);
- if (eval == val || *eval != '\0') {
- printf ("%s rec (%s) is not a valid uint\n",
- rp->name, val);
+ if ((uchar *)eval == val || *eval != '\0') {
+ printf ("%s rec (%s) is not a valid uint\n", rp->name, val);
return (NULL);
}
@@ -276,27 +278,29 @@ uint_handler (eerec_map_t *rp, uchar *val, uchar *dp, uchar *edp)
switch (rp->length) {
case 1:
- if (rdata.lval >= 256) {
+ if (lval >= 256) {
printf ("%s rec value (%lu) out of range (0-255)\n",
- rp->name, rdata.lval);
+ rp->name, lval);
return (NULL);
}
- *dp++ = rdata.cval[3];
+ *dp++ = lval;
break;
case 2:
- if (rdata.lval >= 65536) {
+ if (lval >= 65536) {
printf ("%s rec value (%lu) out of range (0-65535)\n",
- rp->name, rdata.lval);
+ rp->name, lval);
return (NULL);
}
- memcpy (dp, &rdata.sval[1], 2);
- dp += 2;
+ *dp++ = lval >> 8;
+ *dp++ = lval;
break;
case 4:
- memcpy (dp, &rdata.lval, 4);
- dp += 4;
+ *dp++ = lval >> 24;
+ *dp++ = lval >> 16;
+ *dp++ = lval >> 8;
+ *dp++ = lval;
break;
default:
@@ -311,32 +315,41 @@ static uchar *
date_handler (eerec_map_t *rp, uchar *val, uchar *dp, uchar *edp)
{
hymod_date_t date;
- uchar *p = val, *ep;
+ uchar *p = val;
+ char *ep;
+ ulong lval;
- date.year = simple_strtol (p, (char **)&ep, 10);
- if (ep == p || *ep++ != '-') {
+ lval = simple_strtol (p, &ep, 10);
+ if ((uchar *)ep == p || *ep++ != '-') {
bad_date:
printf ("%s rec (%s) is not a valid date\n", rp->name, val);
return (NULL);
}
+ if (lval >= 65536)
+ goto bad_date;
+ date.year = lval;
- date.month = simple_strtol (p = ep, (char **)&ep, 10);
- if (ep == p || *ep++ != '-' || date.month == 0 || date.month > 12)
+ lval = simple_strtol (p = ep, &ep, 10);
+ if ((uchar *)ep == p || *ep++ != '-' || lval == 0 || lval > 12)
goto bad_date;
+ date.month = lval;
- date.day = simple_strtol (p = ep, (char **)&ep, 10);
- if (ep == p || *ep != '\0' || date.day == 0 || date.day > 31)
+ lval = simple_strtol (p = ep, &ep, 10);
+ if ((uchar *)ep == p || *ep != '\0' || lval == 0 || lval > 31)
goto bad_date;
+ date.day = lval;
- if (dp + 2 + sizeof (hymod_date_t) > edp) {
+ if (dp + 2 + rp->length > edp) {
printf ("can't fit %s rec into eeprom\n", rp->name);
return (NULL);
}
*dp++ = rp->type;
- *dp++ = sizeof (hymod_date_t);
- memcpy (dp, &date, sizeof (hymod_date_t));
- dp += sizeof (hymod_date_t);
+ *dp++ = rp->length;
+ *dp++ = date.year >> 8;
+ *dp++ = date.year;
+ *dp++ = date.month;
+ *dp++ = date.day;
return (dp);
}
@@ -368,29 +381,28 @@ string_handler (eerec_map_t *rp, uchar *val, uchar *dp, uchar *edp)
static uchar *
bytes_handler (eerec_map_t *rp, uchar *val, uchar *dp, uchar *edp)
{
- uchar bytes[HYMOD_MAX_BYTES], nbytes = 0;
- uchar *p = val, *ep;
+ uchar bytes[HYMOD_MAX_BYTES], nbytes, *p;
+ char *ep;
- for (;;) {
+ for (nbytes = 0, p = val; *p != '\0'; p = (uchar *)ep) {
+ ulong lval;
- if (nbytes >= HYMOD_MAX_BYTES) {
- printf ("%s rec (%s) byte array too long\n",
+ lval = simple_strtol (p, &ep, 10);
+ if ((uchar *)ep == p || (*ep != '\0' && *ep != ',') || \
+ lval >= 256) {
+ printf ("%s rec (%s) byte array has invalid uint\n",
rp->name, val);
return (NULL);
}
-
- bytes[nbytes++] = simple_strtol (p, (char **)&ep, 10);
-
- if (ep == p || (*ep != '\0' && *ep != ',')) {
- printf ("%s rec (%s) byte array has invalid uint\n",
+ if (nbytes >= HYMOD_MAX_BYTES) {
+ printf ("%s rec (%s) byte array too long\n",
rp->name, val);
return (NULL);
}
+ bytes[nbytes++] = lval;
- if (*ep++ == '\0')
- break;
-
- p = ep;
+ if (*ep != '\0')
+ ep++;
}
if (dp + 2 + nbytes > edp) {
@@ -459,6 +471,7 @@ hymod_eeprom_fetch(int which, char *filename, ulong addr)
hymod_eehdr_t *hp = (hymod_eehdr_t *)&data[0];
ulong crc;
+ memset (hp, 0, sizeof *hp);
hp->id = HYMOD_EEPROM_ID;
hp->ver = HYMOD_EEPROM_VER;
diff --git a/board/hymod/flash.c b/board/hymod/flash.c
index 7d1ae30..ad0a229 100644
--- a/board/hymod/flash.c
+++ b/board/hymod/flash.c
@@ -43,29 +43,26 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
* in the flash_info entry "fip". Fatal error if nothing there.
*/
static void
-bank_probe (flash_info_t *fip, bank_addr_t base)
+bank_probe (flash_info_t *fip, volatile bank_addr_t base)
{
- bank_addr_t addr;
+ volatile bank_addr_t addr;
bank_word_t word;
int i;
/* reset the flash */
*base = BANK_CMD_RST;
- /* check the manufacturer id - must be intel */
+ /* put flash into read id mode */
*base = BANK_CMD_RD_ID;
- word = *BANK_REG_MAN_CODE (base);
- *base = BANK_CMD_RST;
+ /* check the manufacturer id - must be intel */
+ word = *BANK_REG_MAN_CODE (base);
if (word != BANK_FILL_WORD (INTEL_MANUFACT&0xff))
panic ("\nbad manufacturer's code (0x%08lx) at addr 0x%08lx",
(unsigned long)word, (unsigned long)base);
/* check the device id */
- *base = BANK_CMD_RD_ID;
word = *BANK_REG_DEV_CODE (base);
- *base = BANK_CMD_RST;
-
switch (word) {
case BANK_FILL_WORD (INTEL_ID_28F320J5&0xff):
@@ -110,12 +107,15 @@ bank_probe (flash_info_t *fip, bank_addr_t base)
}
fip->size = (bank_size_t)addr - (bank_size_t)base;
+
+ /* reset the flash */
+ *base = BANK_CMD_RST;
}
static void
bank_reset (flash_info_t *info, int sect)
{
- bank_addr_t addr = (bank_addr_t)info->start[sect];
+ volatile bank_addr_t addr = (bank_addr_t)info->start[sect];
#ifdef FLASH_DEBUG
printf ("writing reset cmd to addr 0x%08lx\n", (unsigned long)addr);
@@ -127,7 +127,7 @@ bank_reset (flash_info_t *info, int sect)
static void
bank_erase_init (flash_info_t *info, int sect)
{
- bank_addr_t addr = (bank_addr_t)info->start[sect];
+ volatile bank_addr_t addr = (bank_addr_t)info->start[sect];
int flag;
#ifdef FLASH_DEBUG
@@ -152,7 +152,7 @@ bank_erase_init (flash_info_t *info, int sect)
static int
bank_erase_poll (flash_info_t *info, int sect)
{
- bank_addr_t addr = (bank_addr_t)info->start[sect];
+ volatile bank_addr_t addr = (bank_addr_t)info->start[sect];
bank_word_t stat = *addr;
#ifdef FLASH_DEBUG
@@ -176,7 +176,7 @@ bank_erase_poll (flash_info_t *info, int sect)
}
static int
-bank_write_word (bank_addr_t addr, bank_word_t value)
+bank_write_word (volatile bank_addr_t addr, bank_word_t value)
{
bank_word_t stat;
ulong start;
diff --git a/board/hymod/flash.h b/board/hymod/flash.h
index 10db7fc..ee047fe 100644
--- a/board/hymod/flash.h
+++ b/board/hymod/flash.h
@@ -92,7 +92,7 @@ typedef bank_word_t bank_blk_t[32 * 1024];
#endif /* EXAMPLE */
/* the sizes of these two types should probably be the same */
-typedef volatile bank_word_t *bank_addr_t;
+typedef bank_word_t *bank_addr_t;
typedef unsigned long bank_size_t;
/* align bank addresses and sizes to bank word boundaries */
diff --git a/board/hymod/global_env b/board/hymod/global_env
index 16def24..43cab1d 100644
--- a/board/hymod/global_env
+++ b/board/hymod/global_env
@@ -58,7 +58,7 @@
# MISCELLANEOUS PARAMETERS
# version must always come first
-version=3
+version=4
# set the ip address based on the main board serial number
ipaddr=192.168.1.%S
@@ -74,7 +74,7 @@ always_check_env=no
# BOOTING COMMANDS AND PARAMETERS
# command to run when "auto-booting"
-bootcmd=bootm 40080000 40200000
+bootcmd=bootm 40080000
# how long the "countdown" to automatically running "bootcmd" is
bootdelay=2
@@ -88,9 +88,9 @@ bootretry=5
# r4 - address of initial ramdisk image (0 means no initrd)
# r5 - size of initial ramdisk image
# r6 - address of command line string
--bootargs=root=/dev/ram rw
+-bootargs=root=/dev/mtdblock5 rootfstype=squashfs ro
-# these four are for hymod linux intergrated into our Sun network
+# these four are for hymod linux integrated into our Sun network
bootargs+=serialno=%S
bootargs+=nisclient nisdomain=mlb.dmt.csiro.au nissrvadr=138.194.112.4
bootargs+=nfsclient
@@ -145,14 +145,17 @@ copyaltlinux=cp.b 100000 40140000 $(filesize)
cmpaltlinux=cmp.b 100000 40140000 $(filesize)
newaltlinux=run fetchaltlinux erasealtlinux copyaltlinux cmpaltlinux
-fetchird=tftp 100000 /hymod/initrd.bin
-eraseird=erase 1:8-47
-copyird=cp.b 100000 40200000 $(filesize)
-cmpird=cmp.b 100000 40200000 $(filesize)
-newinitrd=run fetchird eraseird copyird cmpird
+fetchroot=tftp 100000 /hymod/root.bin
+eraseroot=erase 1:8-47
+copyroot=cp.b 100000 40200000 $(filesize)
+cmproot=cmp.b 100000 40200000 $(filesize)
+newroot=run fetchroot eraseroot copyroot cmproot
fetchard=tftp 100000 /hymod/apprd.bin
eraseard=erase 1:48-63
copyard=cp.b 100000 40c00000 $(filesize)
cmpard=cmp.b 100000 40c00000 $(filesize)
newapprd=run fetchard eraseard copyard cmpard
+
+# pass above map to linux mtd driver
+bootargs+=mtdparts=phys:256k(u-boot),256k(u-boot-env),768k(linux),768k(altlinux),10m(root),4m(hymod)