Fix alignment error on ARM for modules
[oweals/u-boot.git] / examples / eepro100_eeprom.c
index 23020037d3cfdc6c87353e3cd8e06c0f4d4b7bf2..a52e68d4e719c22440f342713dfe6d192291358a 100644 (file)
 #define _LINUX_STRING_H_       /* avoid unnecessary str/mem functions */
 
 #include <common.h>
-#include <syscall.h>
+#include <exports.h>
 
 static int reset_eeprom(unsigned long ioaddr, unsigned char *hwaddr);
 
-int eepro100_eeprom(void)
+int eepro100_eeprom(int argc, char *argv[])
 {
        int ret = 0;
 
        unsigned char hwaddr1[6] = { 0x00, 0x00, 0x02, 0x03, 0x04, 0x05 };
        unsigned char hwaddr2[6] = { 0x00, 0x00, 0x02, 0x03, 0x04, 0x06 };
 
+       app_startup(argv);
+
 #if defined(CONFIG_OXC)
        ret |= reset_eeprom(0x80000000, hwaddr1);
        ret |= reset_eeprom(0x81000000, hwaddr2);
@@ -76,9 +78,12 @@ static inline short inw(long addr)
 
 static inline void *memcpy(void *dst, const void *src, unsigned int len)
 {
-       void * ret = dst;
-       while (len-- > 0) *((char *)dst)++ = *((char *)src)++;
-       return ret;
+       char *ret = dst;
+       while (len-- > 0) {
+               *ret++ = *((char *)src);
+               src++;
+       }
+       return (void *)ret;
 }
 
 /* The EEPROM commands include the alway-set leading bit. */
@@ -119,7 +124,7 @@ static int do_eeprom_cmd(long ioaddr, int cmd, int cmd_len)
        long ee_addr = ioaddr + EE_OFFSET;
 
        if (debug > 1)
-               mon_printf(" EEPROM op 0x%x: ", cmd);
+               printf(" EEPROM op 0x%x: ", cmd);
 
        outw(EE_ENB | EE_SHIFT_CLK, ee_addr);
 
@@ -129,7 +134,7 @@ static int do_eeprom_cmd(long ioaddr, int cmd, int cmd_len)
                outw(dataval, ee_addr);
                eeprom_delay(ee_addr);
                if (debug > 2)
-                       mon_printf("%X", inw(ee_addr) & 15);
+                       printf("%X", inw(ee_addr) & 15);
                outw(dataval | EE_SHIFT_CLK, ee_addr);
                eeprom_delay(ee_addr);
                retval = (retval << 1) | ((inw(ee_addr) & EE_DATA_READ) ? 1 : 0);
@@ -140,7 +145,7 @@ static int do_eeprom_cmd(long ioaddr, int cmd, int cmd_len)
        /* Terminate the EEPROM access. */
        outw(EE_ENB & ~EE_CS, ee_addr);
        if (debug > 1)
-               mon_printf(" EEPROM result is 0x%5.5x.\n", retval);
+               printf(" EEPROM result is 0x%5.5x.\n", retval);
        return retval;
 }
 
@@ -166,7 +171,7 @@ static void write_eeprom(long ioaddr, int index, int value, int addr_len)
        /* Poll for write finished. */
        i = eeprom_busy_poll(ee_ioaddr);                        /* Typical 2000 ticks */
        if (debug)
-               mon_printf(" Write finished after %d ticks.\n", i);
+               printf(" Write finished after %d ticks.\n", i);
        /* Disable programming. This command is not instantaneous, so we check
           for busy before the next op. */
        do_eeprom_cmd(ioaddr, (0x40 << (addr_len-4)), 3 + addr_len);
@@ -179,7 +184,7 @@ static int reset_eeprom(unsigned long ioaddr, unsigned char *hwaddr)
        int size_test;
        int i;
 
-       mon_printf("Resetting i82559 EEPROM @ 0x%08x ... ", ioaddr);
+       printf("Resetting i82559 EEPROM @ 0x%08lX ... ", ioaddr);
 
        size_test = do_eeprom_cmd(ioaddr, (EE_READ_CMD << 8) << 16, 27);
        eeprom_addr_size = (size_test & 0xffe0000) == 0xffe0000 ? 8 : 6;
@@ -200,10 +205,10 @@ static int reset_eeprom(unsigned long ioaddr, unsigned char *hwaddr)
 
        for (i = 0; i < eeprom_size; i++)
                if (read_eeprom(ioaddr, i, eeprom_addr_size) != eeprom[i]) {
-                       mon_printf("failed\n");
+                       printf("failed\n");
                        return 1;
                }
 
-       mon_printf("done\n");
+       printf("done\n");
        return 0;
 }