summaryrefslogtreecommitdiff
path: root/board/voiceblue
diff options
context:
space:
mode:
Diffstat (limited to 'board/voiceblue')
-rw-r--r--board/voiceblue/Makefile8
-rw-r--r--board/voiceblue/eeprom.c143
-rw-r--r--board/voiceblue/eeprom.lds51
-rw-r--r--board/voiceblue/eeprom_start.S11
-rw-r--r--board/voiceblue/voiceblue.c80
5 files changed, 174 insertions, 119 deletions
diff --git a/board/voiceblue/Makefile b/board/voiceblue/Makefile
index 44be6ca89..6302fa854 100644
--- a/board/voiceblue/Makefile
+++ b/board/voiceblue/Makefile
@@ -32,21 +32,23 @@ SOBJS := setup.o
gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
LOAD_ADDR = 0x10400000
+LDSCRIPT = $(TOPDIR)/board/$(BOARDDIR)/eeprom.lds
all: $(LIB) eeprom.srec eeprom.bin
$(LIB): $(OBJS) $(SOBJS)
$(AR) crv $@ $(OBJS) $(SOBJS)
-eeprom.srec: eeprom.o
- $(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e $(<:.o=) $^ \
+eeprom.srec: eeprom.o eeprom_start.o
+ $(LD) -T $(LDSCRIPT) -g -Ttext $(LOAD_ADDR) \
+ -o $(<:.o=) -e $(<:.o=) $^ \
-L../../examples -lstubs \
-L../../lib_generic -lgeneric \
-L$(gcclibdir) -lgcc
$(OBJCOPY) -O srec $(<:.o=) $@
eeprom.bin: eeprom.srec
- $(OBJCOPY) -O binary $< $@ 2>/dev/null
+ $(OBJCOPY) -I srec -O binary $< $@ 2>/dev/null
clean:
rm -f $(SOBJS) $(OBJS) eeprom eeprom.srec eeprom.bin
diff --git a/board/voiceblue/eeprom.c b/board/voiceblue/eeprom.c
index 6383a0203..0ad1b666b 100644
--- a/board/voiceblue/eeprom.c
+++ b/board/voiceblue/eeprom.c
@@ -30,40 +30,6 @@
#define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE
-static int verify_macaddr(char *);
-static int set_mac(char *);
-
-int eeprom(int argc, char *argv[])
-{
- app_startup(argv);
- if (get_version() != XF_VERSION) {
- printf("Wrong XF_VERSION.\n");
- printf("Application expects ABI version %d\n", XF_VERSION);
- printf("Actual U-Boot ABI version %d\n", (int)get_version());
- return 1;
- }
-
- if ((SMC_inw (BANK_SELECT) & 0xFF00) != 0x3300) {
- printf("SMSC91111 not found.\n");
- return 2;
- }
-
- if (argc != 2) {
- printf("VoiceBlue EEPROM writer\n");
- printf("Built: %s at %s\n", __DATE__ , __TIME__ );
- printf("Usage:\n\t<mac_address>");
- return 3;
- }
-
- set_mac(argv[1]);
- if (verify_macaddr(argv[1])) {
- printf("*** ERROR ***\n");
- return 4;
- }
-
- return 0;
-}
-
static u16 read_eeprom_reg(u16 reg)
{
int timeout;
@@ -106,17 +72,28 @@ static int write_eeprom_reg(u16 value, u16 reg)
return 1;
}
+static int write_data(u16 *buf, int len)
+{
+ u16 reg = 0x23;
+
+ while (len--)
+ write_eeprom_reg(*buf++, reg++);
+
+ return 0;
+}
+
static int verify_macaddr(char *s)
{
u16 reg;
int i, err = 0;
- printf("Verifying MAC Address: ");
+ printf("MAC Address: ");
err = i = 0;
for (i = 0; i < 3; i++) {
reg = read_eeprom_reg(0x20 + i);
printf("%02x:%02x%c", reg & 0xff, reg >> 8, i != 2 ? ':' : '\n');
- err |= reg != ((u16 *)s)[i];
+ if (s)
+ err |= reg != ((u16 *)s)[i];
}
return err ? 0 : 1;
@@ -138,3 +115,97 @@ static int set_mac(char *s)
return 0;
}
+
+static int parse_element(char *s, unsigned char *buf, int len)
+{
+ int cnt;
+ char *p, num[3];
+ unsigned char id;
+
+ id = simple_strtoul(s, &p, 16);
+ if (*p++ != ':')
+ return -1;
+ cnt = 2;
+ num[2] = 0;
+ for (; *p; p += 2) {
+ if (p[1] == 0)
+ return -2;
+ if (cnt + 3 > len)
+ return -3;
+ num[0] = p[0];
+ num[1] = p[1];
+ buf[cnt++] = simple_strtoul(num, NULL, 16);
+ }
+ buf[0] = id;
+ buf[1] = cnt - 2;
+
+ return cnt;
+}
+
+int eeprom(int argc, char *argv[])
+{
+ int i, len, ret;
+ unsigned char buf[58], *p;
+
+ app_startup(argv);
+ if (get_version() != XF_VERSION) {
+ printf("Wrong XF_VERSION.\n");
+ printf("Application expects ABI version %d\n", XF_VERSION);
+ printf("Actual U-Boot ABI version %d\n", (int)get_version());
+ return 1;
+ }
+
+ if ((SMC_inw (BANK_SELECT) & 0xFF00) != 0x3300) {
+ printf("SMSC91111 not found.\n");
+ return 2;
+ }
+
+ /* Called without parameters - print MAC address */
+ if (argc < 2) {
+ verify_macaddr(NULL);
+ return 0;
+ }
+
+ /* Print help message */
+ if (argv[1][1] == 'h') {
+ printf("VoiceBlue EEPROM writer\n");
+ printf("Built: %s at %s\n", __DATE__ , __TIME__ );
+ printf("Usage:\n\t<mac_address> [<element_1>] [<...>]\n");
+ return 0;
+ }
+
+ /* Try to parse information elements */
+ len = sizeof(buf);
+ p = buf;
+ for (i = 2; i < argc; i++) {
+ ret = parse_element(argv[i], p, len);
+ switch (ret) {
+ case -1:
+ printf("Element %d: malformed\n", i - 1);
+ return 3;
+ case -2:
+ printf("Element %d: odd character count\n", i - 1);
+ return 3;
+ case -3:
+ printf("Out of EEPROM memory\n");
+ return 3;
+ default:
+ p += ret;
+ len -= ret;
+ }
+ }
+
+ /* First argument (MAC) is mandatory */
+ set_mac(argv[1]);
+ if (verify_macaddr(argv[1])) {
+ printf("*** MAC address does not match! ***\n");
+ return 4;
+ }
+
+ while (len--)
+ *p++ = 0;
+
+ write_data((u16 *)buf, sizeof(buf) >> 1);
+
+ return 0;
+}
diff --git a/board/voiceblue/eeprom.lds b/board/voiceblue/eeprom.lds
new file mode 100644
index 000000000..317550dba
--- /dev/null
+++ b/board/voiceblue/eeprom.lds
@@ -0,0 +1,51 @@
+/*
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
+ * (C) Copyright 2005
+ * Ladislav Michl, 2N Telekomunikace, <michl@2n.cz>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+ . = ALIGN(4);
+ .text :
+ {
+ eeprom_start.o (.text)
+ *(.text)
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(.rodata) }
+
+ . = ALIGN(4);
+ .data : { *(.data) }
+
+ . = ALIGN(4);
+ .got : { *(.got) }
+
+ . = ALIGN(4);
+ __bss_start = .;
+ .bss : { *(.bss) }
+ _end = .;
+}
diff --git a/board/voiceblue/eeprom_start.S b/board/voiceblue/eeprom_start.S
new file mode 100644
index 000000000..8f88de5c3
--- /dev/null
+++ b/board/voiceblue/eeprom_start.S
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2005 2N Telekomunikace
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ */
+
+.globl _start
+_start: b eeprom
diff --git a/board/voiceblue/voiceblue.c b/board/voiceblue/voiceblue.c
index 969110658..7a2d243ef 100644
--- a/board/voiceblue/voiceblue.c
+++ b/board/voiceblue/voiceblue.c
@@ -56,90 +56,10 @@ int dram_init(void)
return 0;
}
-#ifndef VOICEBLUE_SMALL_FLASH
-
-#include <jffs2/jffs2.h>
-
-extern flash_info_t flash_info[];
-static struct part_info partinfo;
-static int current_part = -1;
-
-/* Partition table (Linux MTD see it this way)
- *
- * 0 - U-Boot
- * 1 - env
- * 2 - redundant env
- * 3 - data1 (jffs2)
- * 4 - data2 (jffs2)
- */
-
-static struct {
- ulong offset;
- ulong size;
-} part[5];
-
-static void partition_flash(flash_info_t *info)
-{
- char mtdparts[128];
- int i, n, size, psize;
- const ulong plen[3] = { CFG_MONITOR_LEN, CFG_ENV_SIZE, CFG_ENV_SIZE };
-
- size = n = 0;
- for (i = 0; i < 4; i++) {
- part[i].offset = info->start[n];
- psize = i < 3 ? plen[i] : (info->size - size) / 2;
- while (part[i].size < psize) {
- if (++n > info->sector_count) {
- printf("Partitioning error. System halted.\n");
- while (1) ;
- }
- part[i].size += info->start[n] - info->start[n - 1];
- }
- size += part[i].size;
- }
- part[4].offset = info->start[n];
- part[4].size = info->start[info->sector_count - 1] - info->start[n];
-
- sprintf(mtdparts, "omapflash.0:"
- "%dk(U-Boot)ro,%dk(env),%dk(r_env),%dk(data1),-(data2)",
- part[0].size >> 10, part[1].size >> 10,
- part[2].size >> 10, part[3].size >> 10);
- setenv ("mtdparts", mtdparts);
-}
-
-struct part_info* jffs2_part_info(int part_num)
-{
- void *jffs2_priv_saved = partinfo.jffs2_priv;
-
- if (part_num != 3 && part_num != 4)
- return NULL;
-
- if (current_part != part_num) {
- memset(&partinfo, 0, sizeof(partinfo));
- current_part = part_num;
- partinfo.offset = (char*) part[part_num].offset;
- partinfo.size = part[part_num].size;
- partinfo.usr_priv = &current_part;
- partinfo.jffs2_priv = jffs2_priv_saved;
- }
-
- return &partinfo;
-}
-
-#endif
-
int misc_init_r(void)
{
*((volatile unsigned short *) VOICEBLUE_LED_REG) = 0x55;
-#ifndef VOICEBLUE_SMALL_FLASH
- if (flash_info[0].flash_id == FLASH_UNKNOWN) {
- printf("Unknown flash. System halted.\n");
- while (1) ;
- }
- partition_flash(&flash_info[0]);
-#endif
-
return 0;
}