X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=examples%2Feepro100_eeprom.c;h=2b15d05adbb287c988899bc2ad09a3e0cbbc935b;hb=ee1d2001ea7fbabb2b9256026dc5468f057337f8;hp=656b2382b8e82b6f6921fd245adbc03a769a2225;hpb=affae2bff825c1a8d2cfeaf7b270188d251d39d2;p=oweals%2Fu-boot.git diff --git a/examples/eepro100_eeprom.c b/examples/eepro100_eeprom.c index 656b2382b8..2b15d05adb 100644 --- a/examples/eepro100_eeprom.c +++ b/examples/eepro100_eeprom.c @@ -17,21 +17,24 @@ * and release the resulting code under the GPL. */ -#define _PPC_STRING_H_ /* avoid unnecessary str/mem functions */ -#define _LINUX_STRING_H_ /* avoid unnecessary str/mem functions */ +/* avoid unnecessary memcpy function */ +#define __HAVE_ARCH_MEMCPY +#define _PPC_STRING_H_ #include -#include +#include 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 +79,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 +125,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 +135,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 +146,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 +172,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 +185,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,11 +206,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; } -