]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - examples/eepro100_eeprom.c
* Patches by Pantelis Antoniou, 30 Mar 2004:
[karo-tx-uboot.git] / examples / eepro100_eeprom.c
index 23020037d3cfdc6c87353e3cd8e06c0f4d4b7bf2..60b937ef8de5092c7a6cc98d25af96d8d4bc8988 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);
@@ -119,7 +121,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 +131,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 +142,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 +168,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 +181,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 +202,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;
 }