[U-Boot] [PATCH 1/3] net/eth_device: keep index inside each device

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- include/net.h | 1 + net/eth.c | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/include/net.h b/include/net.h index 4a03717..2a8a12d 100644 --- a/include/net.h +++ b/include/net.h @@ -93,6 +93,7 @@ enum eth_state_t { };
struct eth_device { + int index; char name[NAMESIZE]; unsigned char enetaddr[6]; int iobase; diff --git a/net/eth.c b/net/eth.c index 42f74da..2316a22 100644 --- a/net/eth.c +++ b/net/eth.c @@ -83,6 +83,7 @@ static unsigned int eth_rcv_current = 0, eth_rcv_last = 0; #endif
static struct eth_device *eth_devices, *eth_current; +static int nb_eth_devices = 0;
struct eth_device *eth_get_dev(void) { @@ -133,22 +134,12 @@ struct eth_device *eth_get_dev_by_index(int index)
int eth_get_dev_index (void) { - struct eth_device *dev; - int num = 0; - if (!eth_devices) { return (-1); }
- for (dev = eth_devices; dev; dev = dev->next) { - if (dev == eth_current) - break; - ++num; - } - - if (dev) { - return (num); - } + if (eth_current) + return eth_current->index;
return (0); } @@ -172,6 +163,8 @@ int eth_register(struct eth_device* dev) d->next = dev; }
+ dev->index = nb_eth_devices; + nb_eth_devices++; dev->state = ETH_STATE_INIT; dev->next = eth_devices;

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- include/net.h | 2 ++ net/eth.c | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/include/net.h b/include/net.h index 2a8a12d..dc4ae41 100644 --- a/include/net.h +++ b/include/net.h @@ -124,6 +124,8 @@ extern void eth_set_enetaddr(int num, char* a); /* Set new MAC address */ extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr); extern int eth_getenv_enetaddr(char *name, uchar *enetaddr); extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr); +extern int eth_getenv_num_enetaddr(int num, uchar *enetaddr); +extern int eth_setenv_num_enetaddr(int num, const uchar *enetaddr);
extern int eth_init(bd_t *bis); /* Initialize the device */ extern int eth_send(volatile void *packet, int length); /* Send a packet */ diff --git a/net/eth.c b/net/eth.c index 2316a22..9bdf961 100644 --- a/net/eth.c +++ b/net/eth.c @@ -27,6 +27,12 @@ #include <miidev.h>
#ifdef CONFIG_CMD_NET + +static void get_enetvar(int num, char *enetvar) +{ + sprintf(enetvar, num ? "eth%daddr" : "ethaddr", num); +} + void eth_parse_enetaddr(const char *addr, uchar *enetaddr) { char *end; @@ -53,6 +59,24 @@ int eth_setenv_enetaddr(char *name, const uchar *enetaddr)
return setenv(name, buf); } + +int eth_getenv_num_enetaddr(int num, uchar *enetaddr) +{ + char enetvar[32]; + + get_enetvar(num, enetvar); + + return eth_getenv_enetaddr(enetvar, enetaddr); +} + +int eth_setenv_num_enetaddr(int num, const uchar *enetaddr) +{ + char enetvar[32]; + + get_enetvar(num, enetvar); + + return eth_setenv_enetaddr(enetvar, enetaddr); +} #endif
#if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI) @@ -173,7 +197,6 @@ int eth_register(struct eth_device* dev)
int eth_initialize(bd_t *bis) { - char enetvar[32]; unsigned char env_enetaddr[6]; int eth_number = 0;
@@ -214,8 +237,7 @@ int eth_initialize(bd_t *bis) puts (" [PRIME]"); }
- sprintf(enetvar, eth_number ? "eth%daddr" : "ethaddr", eth_number); - eth_getenv_enetaddr(enetvar, env_enetaddr); + eth_getenv_num_enetaddr(eth_number, env_enetaddr);
if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) { if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- board/netstar/eeprom.c | 3 +- board/voiceblue/eeprom.c | 3 +- drivers/net/smc91111.c | 420 +++++++++++++++++++------------------ drivers/net/smc91111.h | 8 +- include/configs/ADNPESC1.h | 1 + include/configs/DK1C20.h | 1 + include/configs/DK1S10.h | 1 + include/configs/EP1C20.h | 1 + include/configs/EP1S10.h | 1 + include/configs/EP1S40.h | 1 + include/configs/MigoR.h | 1 + include/configs/PK1C20.h | 1 + include/configs/bf533-ezkit.h | 1 + include/configs/bf533-stamp.h | 1 + include/configs/bf538f-ezkit.h | 1 + include/configs/bf561-ezkit.h | 1 + include/configs/blackstamp.h | 1 + include/configs/cerf250.h | 1 + include/configs/cm-bf533.h | 1 + include/configs/cm-bf561.h | 1 + include/configs/cradle.h | 1 + include/configs/delta.h | 1 + include/configs/dnp1110.h | 1 + include/configs/gr_cpci_ax2000.h | 1 + include/configs/gr_ep2s60.h | 1 + include/configs/innokom.h | 1 + include/configs/integratorcp.h | 1 + include/configs/logodl.h | 1 + include/configs/lpd7a400-10.h | 1 + include/configs/lpd7a404-10.h | 1 + include/configs/ms7722se.h | 1 + include/configs/netstar.h | 1 + include/configs/nhk8815.h | 1 + include/configs/pxa255_idp.h | 1 + include/configs/versatile.h | 1 + include/configs/voiceblue.h | 1 + include/configs/xaeniax.h | 1 + include/configs/xm250.h | 1 + include/configs/xsengine.h | 1 + include/configs/zylonite.h | 1 + include/netdev.h | 1 + 41 files changed, 259 insertions(+), 212 deletions(-)
diff --git a/board/netstar/eeprom.c b/board/netstar/eeprom.c index 5806128..05c6768 100644 --- a/board/netstar/eeprom.c +++ b/board/netstar/eeprom.c @@ -27,9 +27,8 @@ #include <common.h> #include <exports.h> #include <timestamp.h> -#include "../drivers/net/smc91111.h" - #define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE +#include "../drivers/net/smc91111.h"
static u16 read_eeprom_reg(u16 reg) { diff --git a/board/voiceblue/eeprom.c b/board/voiceblue/eeprom.c index f01597a..8b3fbed 100644 --- a/board/voiceblue/eeprom.c +++ b/board/voiceblue/eeprom.c @@ -27,9 +27,8 @@ #include <common.h> #include <exports.h> #include <timestamp.h> -#include "../drivers/net/smc91111.h" - #define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE +#include "../drivers/net/smc91111.h"
static u16 read_eeprom_reg(u16 reg) { diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c index b41e4d2..1c0c20f 100644 --- a/drivers/net/smc91111.c +++ b/drivers/net/smc91111.c @@ -61,9 +61,10 @@
#include <common.h> #include <command.h> -#include <config.h> +#include <malloc.h> #include "smc91111.h" #include <net.h> +#include <netdev.h>
/* Use power-down feature of the chip */ #define POWER_DOWN 0 @@ -114,7 +115,6 @@ static const char version[] = #define PRINTK(args...) #endif
- /*------------------------------------------------------------------------ . . The internal workings of the driver. If you are changing anything @@ -127,14 +127,7 @@ static const char version[] = /* Memory sizing constant */ #define LAN91C111_MEMORY_MULTIPLIER (1024*2)
-#ifndef CONFIG_SMC91111_BASE -#define CONFIG_SMC91111_BASE 0x20000300 -#endif - -#define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE - #define SMC_DEV_NAME "SMC91111" -#define SMC_PHY_ADDR 0x0000 #define SMC_ALLOC_MAX_TRY 5 #define SMC_TX_TIMEOUT 30
@@ -143,75 +136,51 @@ static const char version[] = #define ETH_ZLEN 60
#ifdef CONFIG_SMC_USE_32_BIT -#define USE_32_BIT 1 +#define is_use_32bit(x) (x->use_32bit) #else -#undef USE_32_BIT +#define is_use_32bit(x) (0) #endif + +struct smc91111_device { + int id; + void *regs; + + int use_32bit; + + struct eth_device netdev; + unsigned short phy_addr; +}; +#define to_smc91111(_nd) container_of(_nd, struct smc91111_device, netdev) + /*----------------------------------------------------------------- . . The driver can be entered at any of the following entry points. . .------------------------------------------------------------------ */
-extern int eth_init(bd_t *bd); -extern void eth_halt(void); -extern int eth_rx(void); -extern int eth_send(volatile void *packet, int length); - #ifdef SHARED_RESOURCES extern void swap_to(int device_id); #endif
/* - . This is called by register_netdev(). It is responsible for - . checking the portlist for the SMC9000 series chipset. If it finds - . one, then it will initialize the device, find the hardware information, - . and sets up the appropriate device parameters. - . NOTE: Interrupts are *OFF* when this procedure is called. - . - . NB:This shouldn't be static since it is referred to externally. -*/ -int smc_init(void); - -/* . This is called by unregister_netdev(). It is responsible for . cleaning up before the driver is finally unregistered and discarded. */ void smc_destructor(void);
/* - . The kernel calls this function when someone wants to use the device, - . typically 'ifconfig ethX up'. -*/ -static int smc_open(bd_t *bd); - - -/* - . This is called by the kernel in response to 'ifconfig ethX down'. It - . is responsible for cleaning up everything that the open routine - . does, and maybe putting the card into a powerdown state. -*/ -static int smc_close(void); - -/* . Configures the PHY through the MII Management interface */ #ifndef CONFIG_SMC91111_EXT_PHY -static void smc_phy_configure(void); +static void smc_phy_configure(struct smc91111_device *smc); #endif /* !CONFIG_SMC91111_EXT_PHY */
-/* - . This is a separate procedure to handle the receipt of a packet, to - . leave the interrupt code looking slightly cleaner -*/ -static int smc_rcv(void); - /* See if a MAC address is defined in the current environment. If so use it. If not . print a warning and set the environment and other globals with the default. . If an EEPROM is present it really should be consulted. */ -int smc_get_ethaddr(bd_t *bd); -int get_rom_mac(uchar *v_rom_mac); +int smc_get_ethaddr(struct smc91111_device *smc, bd_t *bd); +int get_rom_mac(struct smc91111_device *smc, uchar *v_rom_mac);
/* ------------------------------------------------------------ @@ -233,30 +202,31 @@ int get_rom_mac(uchar *v_rom_mac); * packets being corrupt (shifted) on the wire, etc. Switching to the * inx,outx functions fixed this problem. */ -static inline word SMC_inw(dword offset); -static inline void SMC_outw(word value, dword offset); -static inline byte SMC_inb(dword offset); -static inline void SMC_outb(byte value, dword offset); -static inline void SMC_insw(dword offset, volatile uchar* buf, dword len); -static inline void SMC_outsw(dword offset, uchar* buf, dword len); +#define SMC_inw(offset) SMC_io_inw(smc, offset) +#define SMC_outw(value, offset) SMC_io_outw(smc, value, offset) +#define SMC_inb(offset) SMC_io_inb(smc, offset) +#define SMC_outb(value, offset) SMC_io_outb(smc, value, offset) +#define SMC_insw(offset, buf, len) SMC_io_insw(smc, offset, buf, len) +#define SMC_outsw(offset, buf, len) SMC_io_outsw(smc, offset, buf, len)
#define barrier() __asm__ __volatile__("": : :"memory")
-static inline word SMC_inw(dword offset) +static inline word SMC_io_inw(struct smc91111_device *smc, dword offset) { word v; - v = *((volatile word*)(SMC_BASE_ADDRESS+offset)); + v = *((volatile word*)(smc->regs+offset)); barrier(); *(volatile u32*)(0xc0000000); return v; }
-static inline void SMC_outw(word value, dword offset) +static inline void SMC_io_outw(struct smc91111_device *smc, word value, + dword offset) { - *((volatile word*)(SMC_BASE_ADDRESS+offset)) = value; + *((volatile word*)(smc->regs+offset)) = value; barrier(); *(volatile u32*)(0xc0000000); }
-static inline byte SMC_inb(dword offset) +static inline byte SMC_io_inb(struct smc91111_device *smc, dword offset) { word _w;
@@ -264,18 +234,22 @@ static inline byte SMC_inb(dword offset) return (offset & 1) ? (byte)(_w >> 8) : (byte)(_w); }
-static inline void SMC_outb(byte value, dword offset) +static inline void SMC_io_outb(struct smc91111_device *smc, byte value, + dword offset) { word _w;
_w = SMC_inw(offset & ~((dword)1)); if (offset & 1) - *((volatile word*)(SMC_BASE_ADDRESS+(offset & ~((dword)1)))) = (value<<8) | (_w & 0x00ff); + *((volatile word*)(smc->regs+(offset & ~((dword)1)))) = + (value<<8) | (_w & 0x00ff); else - *((volatile word*)(SMC_BASE_ADDRESS+offset)) = value | (_w & 0xff00); + *((volatile word*)(smc->regs+offset)) = + value | (_w & 0xff00); }
-static inline void SMC_insw(dword offset, volatile uchar* buf, dword len) +static inline void SMC_io_insw(struct smc91111_device *smc, dword offset, + volatile uchar* buf, dword len) { volatile word *p = (volatile word *)buf;
@@ -286,7 +260,8 @@ static inline void SMC_insw(dword offset, volatile uchar* buf, dword len) } }
-static inline void SMC_outsw(dword offset, uchar* buf, dword len) +static inline void SMC_io_outsw(struct smc91111_device *smc, dword offset, + uchar* buf, dword len) { volatile word *p = (volatile word *)buf;
@@ -339,7 +314,7 @@ void smc_get_macaddr( byte *addr ) { /*********************************************** * Show available memory * ***********************************************/ -void dump_memory_info(void) +void dump_memory_info(struct smc91111_device *smc) { word mem_info; word old_bank; @@ -363,25 +338,26 @@ static void print_packet( byte *, int );
/* this does a soft reset on the device */ -static void smc_reset( void ); +static void smc_reset(struct smc91111_device *smc);
/* Enable Interrupts, Receive, and Transmit */ -static void smc_enable( void ); +static void smc_enable(struct smc91111_device *smc);
/* this puts the device in an inactive state */ -static void smc_shutdown( void ); +static void smc_shutdown(struct smc91111_device *smc);
/* Routines to Read and Write the PHY Registers across the MII Management Interface */
#ifndef CONFIG_SMC91111_EXT_PHY -static word smc_read_phy_register(byte phyreg); -static void smc_write_phy_register(byte phyreg, word phydata); +static word smc_read_phy_register(struct smc91111_device *smc, byte phyreg); +static void smc_write_phy_register(struct smc91111_device *smc, byte phyreg, + word phydata); #endif /* !CONFIG_SMC91111_EXT_PHY */
-static int poll4int (byte mask, int timeout) +static int poll4int (struct smc91111_device *smc, byte mask, int timeout) { int tmo = get_timer (0) + timeout * CONFIG_SYS_HZ; int is_timeout = 0; @@ -406,7 +382,7 @@ static int poll4int (byte mask, int timeout) }
/* Only one release command at a time, please */ -static inline void smc_wait_mmu_release_complete (void) +static inline void smc_wait_mmu_release_complete (struct smc91111_device *smc) { int count = 0;
@@ -435,7 +411,7 @@ static inline void smc_wait_mmu_release_complete (void) . 5. clear all interrupts . */ -static void smc_reset (void) +static void smc_reset (struct smc91111_device *smc) { PRINTK2 ("%s: smc_reset\n", SMC_DEV_NAME);
@@ -475,7 +451,7 @@ static void smc_reset (void)
/* Reset the MMU */ SMC_SELECT_BANK (2); - smc_wait_mmu_release_complete (); + smc_wait_mmu_release_complete (smc); SMC_outw (MC_RESET, MMU_CMD_REG); while (SMC_inw (MMU_CMD_REG) & MC_BUSY) udelay (1); /* Wait until not busy */ @@ -496,7 +472,7 @@ static void smc_reset (void) . 2. Enable the receiver . 3. Enable interrupts */ -static void smc_enable() +static void smc_enable(struct smc91111_device *smc) { PRINTK2("%s: smc_enable\n", SMC_DEV_NAME); SMC_SELECT_BANK( 0 ); @@ -522,7 +498,7 @@ static void smc_enable() . the manual says that it will wake up in response to any I/O requests . in the register space. Empirical results do not show this working. */ -static void smc_shutdown() +static void smc_shutdown(struct smc91111_device *smc) { PRINTK2(CARDNAME ": smc_shutdown\n");
@@ -558,8 +534,10 @@ static void smc_shutdown() . Enable the transmit interrupt, so I know if it failed . Free the kernel data if I actually sent it. */ -static int smc_send_packet (volatile void *packet, int packet_length) +static int smc_send(struct eth_device *netdev, volatile void *packet, + int packet_length) { + struct smc91111_device *smc = to_smc91111(netdev); byte packet_no; unsigned long ioaddr; byte *buf; @@ -637,7 +615,7 @@ again:
/* I can send the packet now.. */
- ioaddr = SMC_BASE_ADDRESS; + ioaddr = (ulong)smc->regs;
buf = (byte *) packet;
@@ -676,13 +654,13 @@ again:
/* send the packet length ( +6 for status, length and ctl byte ) and the status word ( set to zeros ) */ -#ifdef USE_32_BIT - SMC_outl ((length + 6) << 16, SMC91111_DATA_REG); -#else - SMC_outw (0, SMC91111_DATA_REG); - /* send the packet length ( +6 for status words, length, and ctl */ - SMC_outw ((length + 6), SMC91111_DATA_REG); -#endif + if (is_use_32bit(smc)) { + SMC_outl ((length + 6) << 16, SMC91111_DATA_REG); + } else { + SMC_outw (0, SMC91111_DATA_REG); + /* send the packet length ( +6 for status words, length, and ctl */ + SMC_outw ((length + 6), SMC91111_DATA_REG); + }
/* send the actual data . I _think_ it's faster to send the longs first, and then @@ -691,32 +669,32 @@ again: . a good idea to check which is optimal? But that could take . almost as much time as is saved? */ -#ifdef USE_32_BIT - SMC_outsl (SMC91111_DATA_REG, buf, length >> 2); + if (is_use_32bit(smc)) { + SMC_outsl (SMC91111_DATA_REG, buf, length >> 2); #ifndef CONFIG_XAENIAX - if (length & 0x2) - SMC_outw (*((word *) (buf + (length & 0xFFFFFFFC))), - SMC91111_DATA_REG); + if (length & 0x2) + SMC_outw (*((word *) (buf + (length & 0xFFFFFFFC))), + SMC91111_DATA_REG); #else - /* On XANEIAX, we can only use 32-bit writes, so we need to handle - * unaligned tail part specially. The standard code doesn't work. - */ - if ((length & 3) == 3) { - u16 * ptr = (u16*) &buf[length-3]; - SMC_outl((*ptr) | ((0x2000 | buf[length-1]) << 16), - SMC91111_DATA_REG); - } else if ((length & 2) == 2) { - u16 * ptr = (u16*) &buf[length-2]; - SMC_outl(*ptr, SMC91111_DATA_REG); - } else if (length & 1) { - SMC_outl((0x2000 | buf[length-1]), SMC91111_DATA_REG); + /* On XANEIAX, we can only use 32-bit writes, so we need to handle + * unaligned tail part specially. The standard code doesn't work. + */ + if ((length & 3) == 3) { + u16 * ptr = (u16*) &buf[length-3]; + SMC_outl((*ptr) | ((0x2000 | buf[length-1]) << 16), + SMC91111_DATA_REG); + } else if ((length & 2) == 2) { + u16 * ptr = (u16*) &buf[length-2]; + SMC_outl(*ptr, SMC91111_DATA_REG); + } else if (length & 1) { + SMC_outl((0x2000 | buf[length-1]), SMC91111_DATA_REG); + } else { + SMC_outl(0, SMC91111_DATA_REG); + } +#endif } else { - SMC_outl(0, SMC91111_DATA_REG); + SMC_outsw (SMC91111_DATA_REG, buf, (length) >> 1); } -#endif -#else - SMC_outsw (SMC91111_DATA_REG, buf, (length) >> 1); -#endif /* USE_32_BIT */
#ifndef CONFIG_XAENIAX /* Send the last byte, if there is one. */ @@ -733,7 +711,7 @@ again: /* poll for TX INT */ /* if (poll4int (IM_TX_INT, SMC_TX_TIMEOUT)) { */ /* poll for TX_EMPTY INT - autorelease enabled */ - if (poll4int(IM_TX_EMPTY_INT, SMC_TX_TIMEOUT)) { + if (poll4int(smc, IM_TX_EMPTY_INT, SMC_TX_TIMEOUT)) { /* sending failed */ PRINTK2 ("%s: TX timeout, sending failed...\n", SMC_DEV_NAME);
@@ -813,19 +791,24 @@ void smc_destructor() * Set up everything, reset the card, etc .. * */ -static int smc_open (bd_t * bd) +static int smc_init(struct eth_device *netdev, bd_t * bd) { + struct smc91111_device *smc = to_smc91111(netdev); int i, err;
+#ifdef SHARED_RESOURCES + swap_to(ETHERNET); +#endif + PRINTK2 ("%s: smc_open\n", SMC_DEV_NAME);
/* reset the hardware */ - smc_reset (); - smc_enable (); + smc_reset (smc); + smc_enable (smc);
/* Configure the PHY */ #ifndef CONFIG_SMC91111_EXT_PHY - smc_phy_configure (); + smc_phy_configure (smc); #endif
/* conservative setting (10Mbps, HalfDuplex, no AutoNeg.) */ @@ -833,21 +816,22 @@ static int smc_open (bd_t * bd) /* SMC_outw(0, RPC_REG); */ SMC_SELECT_BANK (1);
- err = smc_get_ethaddr (bd); /* set smc_mac_addr, and sync it with u-boot globals */ + /* set smc_mac_addr, and sync it with u-boot globals */ + err = smc_get_ethaddr (smc, bd); if (err < 0) return -1; -#ifdef USE_32_BIT - for (i = 0; i < 6; i += 2) { - word address; + if (is_use_32bit(smc)) { + for (i = 0; i < 6; i += 2) { + word address;
- address = smc_mac_addr[i + 1] << 8; - address |= smc_mac_addr[i]; - SMC_outw (address, (ADDR0_REG + i)); + address = smc_mac_addr[i + 1] << 8; + address |= smc_mac_addr[i]; + SMC_outw (address, (ADDR0_REG + i)); + } + } else { + for (i = 0; i < 6; i++) + SMC_outb (smc_mac_addr[i], (ADDR0_REG + i)); } -#else - for (i = 0; i < 6; i++) - SMC_outb (smc_mac_addr[i], (ADDR0_REG + i)); -#endif
return 0; } @@ -864,15 +848,14 @@ static int smc_open (bd_t * bd) . o otherwise, read in the packet -------------------------------------------------------------- */ -static int smc_rcv() +static int smc_recv(struct eth_device *netdev) { + struct smc91111_device *smc = to_smc91111(netdev); int packet_number; word status; word packet_length; int is_error = 0; -#ifdef USE_32_BIT dword stat_len; -#endif byte saved_pnr; word saved_ptr;
@@ -893,14 +876,14 @@ static int smc_rcv() SMC_outw( PTR_READ | PTR_RCV | PTR_AUTOINC, PTR_REG );
/* First two words are status and packet_length */ -#ifdef USE_32_BIT - stat_len = SMC_inl(SMC91111_DATA_REG); - status = stat_len & 0xffff; - packet_length = stat_len >> 16; -#else - status = SMC_inw( SMC91111_DATA_REG ); - packet_length = SMC_inw( SMC91111_DATA_REG ); -#endif + if (is_use_32bit(smc)) { + stat_len = SMC_inl(SMC91111_DATA_REG); + status = stat_len & 0xffff; + packet_length = stat_len >> 16; + } else { + status = SMC_inw( SMC91111_DATA_REG ); + packet_length = SMC_inw( SMC91111_DATA_REG ); + }
packet_length &= 0x07ff; /* mask off top bits */
@@ -916,29 +899,31 @@ static int smc_rcv() /* TODO ? */
-#ifdef USE_32_BIT - PRINTK3(" Reading %d dwords (and %d bytes) \n", - packet_length >> 2, packet_length & 3 ); - /* QUESTION: Like in the TX routine, do I want - to send the DWORDs or the bytes first, or some - mixture. A mixture might improve already slow PIO - performance */ - SMC_insl( SMC91111_DATA_REG , NetRxPackets[0], packet_length >> 2 ); - /* read the left over bytes */ - if (packet_length & 3) { - int i; - - byte *tail = (byte *)(NetRxPackets[0] + (packet_length & ~3)); - dword leftover = SMC_inl(SMC91111_DATA_REG); - for (i=0; i<(packet_length & 3); i++) - *tail++ = (byte) (leftover >> (8*i)) & 0xff; + if (is_use_32bit(smc)) { + PRINTK3(" Reading %d dwords (and %d bytes) \n", + packet_length >> 2, packet_length & 3 ); + /* QUESTION: Like in the TX routine, do I want + to send the DWORDs or the bytes first, or some + mixture. A mixture might improve already slow PIO + performance */ + SMC_insl( SMC91111_DATA_REG , NetRxPackets[0], + packet_length >> 2 ); + /* read the left over bytes */ + if (packet_length & 3) { + int i; + + byte *tail = (byte *)(NetRxPackets[0] + + (packet_length & ~3)); + dword leftover = SMC_inl(SMC91111_DATA_REG); + for (i=0; i<(packet_length & 3); i++) + *tail++ = (byte)(leftover >> (8*i)) & 0xff; + } + } else { + PRINTK3(" Reading %d words and %d byte(s) \n", + (packet_length >> 1 ), packet_length & 1 ); + SMC_insw(SMC91111_DATA_REG , NetRxPackets[0], + packet_length >> 1); } -#else - PRINTK3(" Reading %d words and %d byte(s) \n", - (packet_length >> 1 ), packet_length & 1 ); - SMC_insw(SMC91111_DATA_REG , NetRxPackets[0], packet_length >> 1); - -#endif /* USE_32_BIT */
#if SMC_DEBUG > 2 printf("Receiving Packet\n"); @@ -990,14 +975,13 @@ static int smc_rcv() . an 'ifconfig ethX down' . -----------------------------------------------------*/ -static int smc_close() +static void smc_halt(struct eth_device *netdev) { + struct smc91111_device *smc = to_smc91111(netdev); PRINTK2("%s: smc_close\n", SMC_DEV_NAME);
/* clear everything */ - smc_shutdown(); - - return 0; + smc_shutdown(smc); }
@@ -1105,7 +1089,7 @@ static void smc_dump_mii_stream (byte * bits, int size) . Reads a register from the MII Management serial interface .-------------------------------------------------------------*/ #ifndef CONFIG_SMC91111_EXT_PHY -static word smc_read_phy_register (byte phyreg) +static word smc_read_phy_register (struct smc91111_device *smc, byte phyreg) { int oldBank; int i; @@ -1115,7 +1099,7 @@ static word smc_read_phy_register (byte phyreg) int clk_idx = 0; int input_idx; word phydata; - byte phyaddr = SMC_PHY_ADDR; + byte phyaddr = smc->phy_addr;
/* 32 consecutive ones on MDO to establish sync */ for (i = 0; i < 32; ++i) @@ -1222,7 +1206,8 @@ static word smc_read_phy_register (byte phyreg) /*------------------------------------------------------------ . Writes a register to the MII Management serial interface .-------------------------------------------------------------*/ -static void smc_write_phy_register (byte phyreg, word phydata) +static void smc_write_phy_register (struct smc91111_device *smc, byte phyreg, + word phydata) { int oldBank; int i; @@ -1230,7 +1215,7 @@ static void smc_write_phy_register (byte phyreg, word phydata) word mii_reg; byte bits[65]; int clk_idx = 0; - byte phyaddr = SMC_PHY_ADDR; + byte phyaddr = smc->phy_addr;
/* 32 consecutive ones on MDO to establish sync */ for (i = 0; i < 32; ++i) @@ -1345,7 +1330,7 @@ static void smc_wait_ms(unsigned int ms) . smc_phy_fixed() if the user has requested a certain config. .-------------------------------------------------------------*/ #ifndef CONFIG_SMC91111_EXT_PHY -static void smc_phy_configure () +static void smc_phy_configure (struct smc91111_device *smc) { int timeout; byte phyaddr; @@ -1358,15 +1343,15 @@ static void smc_phy_configure ()
/* Get the detected phy address */ - phyaddr = SMC_PHY_ADDR; + phyaddr = smc->phy_addr;
/* Reset the PHY, setting all other bits to zero */ - smc_write_phy_register (PHY_CNTL_REG, PHY_CNTL_RST); + smc_write_phy_register (smc, PHY_CNTL_REG, PHY_CNTL_RST);
/* Wait for the reset to complete, or time out */ timeout = 6; /* Wait up to 3 seconds */ while (timeout--) { - if (!(smc_read_phy_register (PHY_CNTL_REG) + if (!(smc_read_phy_register (smc, PHY_CNTL_REG) & PHY_CNTL_RST)) { /* reset complete */ break; @@ -1385,14 +1370,14 @@ static void smc_phy_configure ()
/* Enable PHY Interrupts (for register 18) */ /* Interrupts listed here are disabled */ - smc_write_phy_register (PHY_MASK_REG, 0xffff); + smc_write_phy_register (smc, PHY_MASK_REG, 0xffff);
/* Configure the Receive/Phy Control register */ SMC_SELECT_BANK (0); SMC_outw (RPC_DEFAULT, RPC_REG);
/* Copy our capabilities from PHY_STAT_REG to PHY_AD_REG */ - my_phy_caps = smc_read_phy_register (PHY_STAT_REG); + my_phy_caps = smc_read_phy_register (smc, PHY_STAT_REG); my_ad_caps = PHY_AD_CSMA; /* I am CSMA capable */
if (my_phy_caps & PHY_STAT_CAP_T4) @@ -1411,18 +1396,18 @@ static void smc_phy_configure () my_ad_caps |= PHY_AD_10_HDX;
/* Update our Auto-Neg Advertisement Register */ - smc_write_phy_register (PHY_AD_REG, my_ad_caps); + smc_write_phy_register (smc, PHY_AD_REG, my_ad_caps);
/* Read the register back. Without this, it appears that when */ /* auto-negotiation is restarted, sometimes it isn't ready and */ /* the link does not come up. */ - smc_read_phy_register(PHY_AD_REG); + smc_read_phy_register(smc, PHY_AD_REG);
PRINTK2 ("%s: phy caps=%x\n", SMC_DEV_NAME, my_phy_caps); PRINTK2 ("%s: phy advertised caps=%x\n", SMC_DEV_NAME, my_ad_caps);
/* Restart auto-negotiation process in order to advertise my caps */ - smc_write_phy_register (PHY_CNTL_REG, + smc_write_phy_register (smc, PHY_CNTL_REG, PHY_CNTL_ANEG_EN | PHY_CNTL_ANEG_RST);
/* Wait for the auto-negotiation to complete. This may take from */ @@ -1431,7 +1416,7 @@ static void smc_phy_configure () timeout = CONFIG_SMC_AUTONEG_TIMEOUT * 2; while (timeout--) {
- status = smc_read_phy_register (PHY_STAT_REG); + status = smc_read_phy_register (smc, PHY_STAT_REG); if (status & PHY_STAT_ANEG_ACK) { /* auto-negotiate complete */ break; @@ -1447,7 +1432,8 @@ static void smc_phy_configure () /* Restart auto-negotiation */ printf ("%s: PHY restarting auto-negotiation\n", SMC_DEV_NAME); - smc_write_phy_register (PHY_CNTL_REG, + smc_write_phy_register (smc, + PHY_CNTL_REG, PHY_CNTL_ANEG_EN | PHY_CNTL_ANEG_RST | PHY_CNTL_SPEED | @@ -1512,44 +1498,26 @@ static void print_packet( byte * buf, int length ) } #endif
-int eth_init(bd_t *bd) { -#ifdef SHARED_RESOURCES - swap_to(ETHERNET); -#endif - return (smc_open(bd)); -} - -void eth_halt() { - smc_close(); -} - -int eth_rx() { - return smc_rcv(); -} - -int eth_send(volatile void *packet, int length) { - return smc_send_packet(packet, length); -} - -int smc_get_ethaddr (bd_t * bd) +int smc_get_ethaddr (struct smc91111_device *smc, bd_t * bd) { - uchar v_mac[6]; + struct eth_device *netdev = &smc->netdev;
- if (!eth_getenv_enetaddr("ethaddr", v_mac)) { + if (!eth_getenv_num_enetaddr(netdev->index, netdev->enetaddr)) { /* get ROM mac value if any */ - if (!get_rom_mac(v_mac)) { + if (!get_rom_mac(smc, netdev->enetaddr)) { printf("\n*** ERROR: ethaddr is NOT set !!\n"); return -1; } - eth_setenv_enetaddr("ethaddr", v_mac); + eth_setenv_num_enetaddr(netdev->index, netdev->enetaddr); }
- smc_set_mac_addr(v_mac); /* use old function to update smc default */ - PRINTK("Using MAC Address %pM\n", v_mac); + /* use old function to update smc default */ + smc_set_mac_addr(netdev->enetaddr); + PRINTK("Using MAC Address %pM\n", netdev->enetaddr); return 0; }
-int get_rom_mac (uchar *v_rom_mac) +int get_rom_mac (struct smc91111_device *smc, uchar *v_rom_mac) { #ifdef HARDCODE_MAC /* used for testing or to supress run time warnings */ char hw_mac_addr[] = { 0x02, 0x80, 0xad, 0x20, 0x31, 0xb8 }; @@ -1570,3 +1538,47 @@ int get_rom_mac (uchar *v_rom_mac) return (valid_mac ? 1 : 0); #endif } + +int smc91111_initialize(int id, void *regs, int use_32bit) +{ + struct smc91111_device *smc; + struct eth_device *netdev; + + smc = calloc(1, sizeof(struct smc91111_device)); + if (!smc) { + printf("Error: Failed to allocate memory for smc91111_%d\n", id); + return -1; + } + + netdev = &smc->netdev; + + smc->regs = regs; + smc->phy_addr = 0; + smc->id = id; + smc->use_32bit = use_32bit; + + sprintf(netdev->name, "smc91111_%d", id); + netdev->init = smc_init; + netdev->halt = smc_halt; + netdev->send = smc_send; + netdev->recv = smc_recv; + + eth_register(netdev); + + return 0; +} + +#ifdef CONFIG_SMC_USE_32_BIT +#define USE_32BIT 1 +#else +#define USE_32BIT 0 +#endif + +int cpu_eth_init(bd_t *bis) +{ + int rc = 0; + + rc = smc91111_initialize(0, (void *)CONFIG_SMC91111_BASE, USE_32BIT); + + return rc; +} diff --git a/drivers/net/smc91111.h b/drivers/net/smc91111.h index 967addd..b2ed6a5 100644 --- a/drivers/net/smc91111.h +++ b/drivers/net/smc91111.h @@ -72,6 +72,10 @@ typedef unsigned long int dword;
/* Because of bank switching, the LAN91xxx uses only 16 I/O ports */
+#ifndef SMC_BASE_ADDRESS +#define SMC_BASE_ADDRESS smc->regs +#endif + #define SMC_IO_EXTENT 16
#ifdef CONFIG_PXA250 @@ -301,8 +305,6 @@ typedef unsigned long int dword;
#endif /* CONFIG_SMC_USE_IOFUNCS */
-#if defined(CONFIG_SMC_USE_32_BIT) - #ifdef CONFIG_XSENGINE #define SMC_inl(r) (*((volatile dword *)(SMC_BASE_ADDRESS+(r<<1)))) #else @@ -331,8 +333,6 @@ typedef unsigned long int dword; } \ })
-#endif /* CONFIG_SMC_USE_32_BIT */ - #endif
/*--------------------------------------------------------------- diff --git a/include/configs/ADNPESC1.h b/include/configs/ADNPESC1.h index b8afc17..664a073 100644 --- a/include/configs/ADNPESC1.h +++ b/include/configs/ADNPESC1.h @@ -412,6 +412,7 @@ #if (CONFIG_SYS_NIOS_CPU_LAN0_TYPE == 0) /* LAN91C111 */
#define CONFIG_DRIVER_SMC91111 /* Using SMC91c111 */ +#define CONFIG_NET_MULTI #undef CONFIG_SMC91111_EXT_PHY /* Internal PHY */ #define CONFIG_SMC91111_BASE (CONFIG_SYS_NIOS_CPU_LAN0_BASE + CONFIG_SYS_NIOS_CPU_LAN0_OFFS)
diff --git a/include/configs/DK1C20.h b/include/configs/DK1C20.h index 45ff2f7..36e7aa0 100644 --- a/include/configs/DK1C20.h +++ b/include/configs/DK1C20.h @@ -218,6 +218,7 @@ #if (CONFIG_SYS_NIOS_CPU_LAN0_TYPE == 0) /* LAN91C111 */
#define CONFIG_DRIVER_SMC91111 /* Using SMC91c111 */ +#define CONFIG_NET_MULTI #undef CONFIG_SMC91111_EXT_PHY /* Internal PHY */ #define CONFIG_SMC91111_BASE (CONFIG_SYS_NIOS_CPU_LAN0_BASE + CONFIG_SYS_NIOS_CPU_LAN0_OFFS)
diff --git a/include/configs/DK1S10.h b/include/configs/DK1S10.h index ae567a3..6f74b20 100644 --- a/include/configs/DK1S10.h +++ b/include/configs/DK1S10.h @@ -235,6 +235,7 @@ #if (CONFIG_SYS_NIOS_CPU_LAN0_TYPE == 0) /* LAN91C111 */
#define CONFIG_DRIVER_SMC91111 /* Using SMC91c111 */ +#define CONFIG_NET_MULTI #undef CONFIG_SMC91111_EXT_PHY /* Internal PHY */ #define CONFIG_SMC91111_BASE (CONFIG_SYS_NIOS_CPU_LAN0_BASE + CONFIG_SYS_NIOS_CPU_LAN0_OFFS)
diff --git a/include/configs/EP1C20.h b/include/configs/EP1C20.h index 8941e4d..fc6cf20 100644 --- a/include/configs/EP1C20.h +++ b/include/configs/EP1C20.h @@ -151,6 +151,7 @@ * cache bypass so there's no need to monkey with inx/outx macros. *----------------------------------------------------------------------*/ #define CONFIG_SMC91111_BASE 0x82110300 /* Base addr (bypass) */ +#define CONFIG_NET_MULTI #define CONFIG_DRIVER_SMC91111 /* Using SMC91c111 */ #undef CONFIG_SMC91111_EXT_PHY /* Internal PHY */ #define CONFIG_SMC_USE_32_BIT /* 32-bit interface */ diff --git a/include/configs/EP1S10.h b/include/configs/EP1S10.h index 53bd0d8..21176b1 100644 --- a/include/configs/EP1S10.h +++ b/include/configs/EP1S10.h @@ -145,6 +145,7 @@ * cache bypass so there's no need to monkey with inx/outx macros. *----------------------------------------------------------------------*/ #define CONFIG_SMC91111_BASE 0x82110300 /* Base addr (bypass) */ +#define CONFIG_NET_MULTI #define CONFIG_DRIVER_SMC91111 /* Using SMC91c111 */ #undef CONFIG_SMC91111_EXT_PHY /* Internal PHY */ #define CONFIG_SMC_USE_32_BIT /* 32-bit interface */ diff --git a/include/configs/EP1S40.h b/include/configs/EP1S40.h index 9e9a8a4..cbf150a 100644 --- a/include/configs/EP1S40.h +++ b/include/configs/EP1S40.h @@ -145,6 +145,7 @@ * cache bypass so there's no need to monkey with inx/outx macros. *----------------------------------------------------------------------*/ #define CONFIG_SMC91111_BASE 0x82110300 /* Base addr (bypass) */ +#define CONFIG_NET_MULTI #define CONFIG_DRIVER_SMC91111 /* Using SMC91c111 */ #undef CONFIG_SMC91111_EXT_PHY /* Internal PHY */ #define CONFIG_SMC_USE_32_BIT /* 32-bit interface */ diff --git a/include/configs/MigoR.h b/include/configs/MigoR.h index 3853574..3324a8c 100644 --- a/include/configs/MigoR.h +++ b/include/configs/MigoR.h @@ -51,6 +51,7 @@
/* SMC9111 */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE (0xB0000000)
/* MEMORY */ diff --git a/include/configs/PK1C20.h b/include/configs/PK1C20.h index 522349f..75843a7 100644 --- a/include/configs/PK1C20.h +++ b/include/configs/PK1C20.h @@ -151,6 +151,7 @@ * cache bypass so there's no need to monkey with inx/outx macros. *----------------------------------------------------------------------*/ #define CONFIG_SMC91111_BASE 0x82110300 /* Base addr (bypass) */ +#define CONFIG_NET_MULTI #define CONFIG_DRIVER_SMC91111 /* Using SMC91c111 */ #undef CONFIG_SMC91111_EXT_PHY /* Internal PHY */ #define CONFIG_SMC_USE_32_BIT /* 32-bit interface */ diff --git a/include/configs/bf533-ezkit.h b/include/configs/bf533-ezkit.h index f896cb0..532bc77 100644 --- a/include/configs/bf533-ezkit.h +++ b/include/configs/bf533-ezkit.h @@ -66,6 +66,7 @@ */ #define ADI_CMDS_NETWORK 1 #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x20310300 #define SMC91111_EEPROM_INIT() \ do { \ diff --git a/include/configs/bf533-stamp.h b/include/configs/bf533-stamp.h index 4be2a5c..ac2093c 100644 --- a/include/configs/bf533-stamp.h +++ b/include/configs/bf533-stamp.h @@ -61,6 +61,7 @@ */ #define ADI_CMDS_NETWORK 1 #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x20300300 #define SMC91111_EEPROM_INIT() \ do { \ diff --git a/include/configs/bf538f-ezkit.h b/include/configs/bf538f-ezkit.h index 535687f..309c8b8 100644 --- a/include/configs/bf538f-ezkit.h +++ b/include/configs/bf538f-ezkit.h @@ -61,6 +61,7 @@ */ #define ADI_CMDS_NETWORK 1 #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x20310300 #define CONFIG_HOSTNAME bf538f-ezkit /* Uncomment next line to use fixed MAC address */ diff --git a/include/configs/bf561-ezkit.h b/include/configs/bf561-ezkit.h index 4779a97..9b40d02 100644 --- a/include/configs/bf561-ezkit.h +++ b/include/configs/bf561-ezkit.h @@ -61,6 +61,7 @@ */ #define ADI_CMDS_NETWORK 1 #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x2C010300 #define CONFIG_SMC_USE_32_BIT 1 #define CONFIG_HOSTNAME bf561-ezkit diff --git a/include/configs/blackstamp.h b/include/configs/blackstamp.h index 887f3fb..789e922 100644 --- a/include/configs/blackstamp.h +++ b/include/configs/blackstamp.h @@ -31,6 +31,7 @@ * Board settings */ #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x20300300
/* FLASH/ETHERNET uses the same address range diff --git a/include/configs/cerf250.h b/include/configs/cerf250.h index b924758..6e00679 100644 --- a/include/configs/cerf250.h +++ b/include/configs/cerf250.h @@ -54,6 +54,7 @@ * Hardware drivers */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x04000300 #define CONFIG_SMC_USE_32_BIT
diff --git a/include/configs/cm-bf533.h b/include/configs/cm-bf533.h index ea548e9..3c670e0 100644 --- a/include/configs/cm-bf533.h +++ b/include/configs/cm-bf533.h @@ -61,6 +61,7 @@ */ #define ADI_CMDS_NETWORK 1 #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x20200300 #define CONFIG_HOSTNAME cm-bf533 /* Uncomment next line to use fixed MAC address */ diff --git a/include/configs/cm-bf561.h b/include/configs/cm-bf561.h index 59dc8d2..8ea7de5 100644 --- a/include/configs/cm-bf561.h +++ b/include/configs/cm-bf561.h @@ -62,6 +62,7 @@ #define ADI_CMDS_NETWORK 1 /* The next 2 lines are for use with DEV-BF5xx */ #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x28000300 /* The next 3 lines are for use with EXT-BF5xx-USB-ETH2 */ /* #define CONFIG_DRIVER_SMC911X 1 */ diff --git a/include/configs/cradle.h b/include/configs/cradle.h index b150c22..11db360 100644 --- a/include/configs/cradle.h +++ b/include/configs/cradle.h @@ -50,6 +50,7 @@ * Hardware drivers */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x10000300 #define CONFIG_SMC91111_EXT_PHY #define CONFIG_SMC_USE_32_BIT diff --git a/include/configs/delta.h b/include/configs/delta.h index 95e04f9..3c69a4d 100644 --- a/include/configs/delta.h +++ b/include/configs/delta.h @@ -54,6 +54,7 @@ #undef TURN_ON_ETHERNET #ifdef TURN_ON_ETHERNET # define CONFIG_DRIVER_SMC91111 1 +# define CONFIG_NET_MULTI # define CONFIG_SMC91111_BASE 0x14000300 # define CONFIG_SMC91111_EXT_PHY # define CONFIG_SMC_USE_32_BIT diff --git a/include/configs/dnp1110.h b/include/configs/dnp1110.h index b6cfc67..a6af22d 100644 --- a/include/configs/dnp1110.h +++ b/include/configs/dnp1110.h @@ -55,6 +55,7 @@ * Hardware drivers */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x20000300
diff --git a/include/configs/gr_cpci_ax2000.h b/include/configs/gr_cpci_ax2000.h index bbe635b..79043b9 100644 --- a/include/configs/gr_cpci_ax2000.h +++ b/include/configs/gr_cpci_ax2000.h @@ -293,6 +293,7 @@ * Ethernet configuration uses on board SMC91C111 */ #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x20000300 /* chip select 3 */ #define CONFIG_SMC_USE_32_BIT 1 /* 32 bit bus */ #undef CONFIG_SMC_91111_EXT_PHY /* we use internal phy */ diff --git a/include/configs/gr_ep2s60.h b/include/configs/gr_ep2s60.h index 7b0a08f..aa5edc8 100644 --- a/include/configs/gr_ep2s60.h +++ b/include/configs/gr_ep2s60.h @@ -268,6 +268,7 @@
/* USE SMC91C111 MAC */ #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x20000300 /* chip select 3 */ #define CONFIG_SMC_USE_32_BIT 1 /* 32 bit bus */ #undef CONFIG_SMC_91111_EXT_PHY /* we use internal phy */ diff --git a/include/configs/innokom.h b/include/configs/innokom.h index ed03ad3..307a6d8 100644 --- a/include/configs/innokom.h +++ b/include/configs/innokom.h @@ -158,6 +158,7 @@ * SMSC91C111 Network Card */ #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x14000000 /* chip select 5 */ #undef CONFIG_SMC_USE_32_BIT /* 16 bit bus access */ #undef CONFIG_SMC_91111_EXT_PHY /* we use internal phy */ diff --git a/include/configs/integratorcp.h b/include/configs/integratorcp.h index e38d569..70bf5de 100644 --- a/include/configs/integratorcp.h +++ b/include/configs/integratorcp.h @@ -54,6 +54,7 @@ * Hardware drivers */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC_USE_32_BIT #define CONFIG_SMC91111_BASE 0xC8000000 #undef CONFIG_SMC91111_EXT_PHY diff --git a/include/configs/logodl.h b/include/configs/logodl.h index 5b903f0..6407757 100644 --- a/include/configs/logodl.h +++ b/include/configs/logodl.h @@ -134,6 +134,7 @@ */ #if 0 #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x10000000 /* chip select 4 */ #undef CONFIG_SMC_USE_32_BIT /* 16 bit bus access */ #undef CONFIG_SMC_91111_EXT_PHY /* we use internal phy */ diff --git a/include/configs/lpd7a400-10.h b/include/configs/lpd7a400-10.h index 6145c37..28b6976 100644 --- a/include/configs/lpd7a400-10.h +++ b/include/configs/lpd7a400-10.h @@ -73,6 +73,7 @@ * (LAN chip) tied to Vcc, so we just care about the chip select */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE (0x70000000) #undef CONFIG_SMC_USE_32_BIT #define CONFIG_SMC_USE_IOFUNCS diff --git a/include/configs/lpd7a404-10.h b/include/configs/lpd7a404-10.h index ce23f3d..33069f6 100644 --- a/include/configs/lpd7a404-10.h +++ b/include/configs/lpd7a404-10.h @@ -73,6 +73,7 @@ * (LAN chip) tied to Vcc, so we just care about the chip select */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE (0x70000000) #undef CONFIG_SMC_USE_32_BIT #define CONFIG_SMC_USE_IOFUNCS diff --git a/include/configs/ms7722se.h b/include/configs/ms7722se.h index 6755af3..f949cb1 100644 --- a/include/configs/ms7722se.h +++ b/include/configs/ms7722se.h @@ -49,6 +49,7 @@
/* SMC9111 */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE (0xB8000000)
/* MEMORY */ diff --git a/include/configs/netstar.h b/include/configs/netstar.h index f0b4207..df0c5b1 100644 --- a/include/configs/netstar.h +++ b/include/configs/netstar.h @@ -94,6 +94,7 @@ #define CONFIG_SYS_NS16550_COM1 OMAP1510_UART1_BASE /* uart1 */
#define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x04000300
#define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1 diff --git a/include/configs/nhk8815.h b/include/configs/nhk8815.h index 8a83d92..3309fb7 100644 --- a/include/configs/nhk8815.h +++ b/include/configs/nhk8815.h @@ -133,6 +133,7 @@ #define __mem_isa(a) ((a) + PCI_MEMORY_VADDR)
#define CONFIG_DRIVER_SMC91111 /* Using SMC91c111*/ +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x34000300 #undef CONFIG_SMC91111_EXT_PHY /* Internal PHY */ #define CONFIG_SMC_USE_32_BIT diff --git a/include/configs/pxa255_idp.h b/include/configs/pxa255_idp.h index 2cae8ca..1087dd7 100644 --- a/include/configs/pxa255_idp.h +++ b/include/configs/pxa255_idp.h @@ -88,6 +88,7 @@ * Hardware drivers */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE (PXA_CS5_PHYS + IDP_CS5_ETH_OFFSET + 0x300) #define CONFIG_SMC_USE_32_BIT 1 /* #define CONFIG_SMC_USE_IOFUNCS */ diff --git a/include/configs/versatile.h b/include/configs/versatile.h index a9b70cc..09c38e6 100644 --- a/include/configs/versatile.h +++ b/include/configs/versatile.h @@ -83,6 +83,7 @@ */
#define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC_USE_32_BIT #define CONFIG_SMC91111_BASE 0x10010000 #undef CONFIG_SMC91111_EXT_PHY diff --git a/include/configs/voiceblue.h b/include/configs/voiceblue.h index c9c3132..fd2f1c9 100644 --- a/include/configs/voiceblue.h +++ b/include/configs/voiceblue.h @@ -95,6 +95,7 @@ * Hardware drivers */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x08000300
#define CONFIG_HARD_I2C diff --git a/include/configs/xaeniax.h b/include/configs/xaeniax.h index 83883f6..22ea650 100644 --- a/include/configs/xaeniax.h +++ b/include/configs/xaeniax.h @@ -197,6 +197,7 @@ * SMSC91C111 Network Card */ #define CONFIG_DRIVER_SMC91111 1 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x10000300 /* chip select 3 */ #define CONFIG_SMC_USE_32_BIT 1 /* 32 bit bus */ #undef CONFIG_SMC_91111_EXT_PHY /* we use internal phy */ diff --git a/include/configs/xm250.h b/include/configs/xm250.h index f18701a..36e6c82 100644 --- a/include/configs/xm250.h +++ b/include/configs/xm250.h @@ -51,6 +51,7 @@ * Hardware drivers */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x04000300 #undef CONFIG_SMC91111_EXT_PHY #define CONFIG_SMC_USE_32_BIT diff --git a/include/configs/xsengine.h b/include/configs/xsengine.h index 2697cca..330f6c3 100644 --- a/include/configs/xsengine.h +++ b/include/configs/xsengine.h @@ -95,6 +95,7 @@
/* Hardware drivers */ #define CONFIG_DRIVER_SMC91111 +#define CONFIG_NET_MULTI #define CONFIG_SMC91111_BASE 0x04000300 #define CONFIG_SMC_USE_32_BIT 1
diff --git a/include/configs/zylonite.h b/include/configs/zylonite.h index 86b6ea1..40478bf 100644 --- a/include/configs/zylonite.h +++ b/include/configs/zylonite.h @@ -63,6 +63,7 @@ #undef TURN_ON_ETHERNET #ifdef TURN_ON_ETHERNET # define CONFIG_DRIVER_SMC91111 1 +# define CONFIG_NET_MULTI # define CONFIG_SMC91111_BASE 0x14000300 # define CONFIG_SMC91111_EXT_PHY # define CONFIG_SMC_USE_32_BIT diff --git a/include/netdev.h b/include/netdev.h index 3e66586..834d3c0 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -73,6 +73,7 @@ int rtl8169_initialize(bd_t *bis); int scc_initialize(bd_t *bis); int skge_initialize(bd_t *bis); int smc911x_initialize(u8 dev_num, int base_addr); +int smc91111_initialize(int id, void *regs, int use_32bit); int tsi108_eth_initialize(bd_t *bis); int uec_initialize(int index); int uec_standard_init(bd_t *bis);

Jean-Christophe, Jean-Christophe PLAGNIOL-VILLARD wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
I already posted a patch that does this and asked for help testing. It is available in the net/next repo. If you find it to be inadequate, please provide patches to make it work.
regards, Ben

On 08:54 Wed 12 Aug , Ben Warren wrote:
Jean-Christophe, Jean-Christophe PLAGNIOL-VILLARD wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
I already posted a patch that does this and asked for help testing. It is available in the net/next repo. If you find it to be inadequate, please provide patches to make it work.
I've also update the mac support and allow multi chip support does you pacth do the same?
as I do need multi chip support
and the one I send work fine
Best Regards, J.

Jean-Christophe PLAGNIOL-VILLARD wrote:
On 08:54 Wed 12 Aug , Ben Warren wrote:
Jean-Christophe, Jean-Christophe PLAGNIOL-VILLARD wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
I already posted a patch that does this and asked for help testing. It is available in the net/next repo. If you find it to be inadequate, please provide patches to make it work.
I've also update the mac support and allow multi chip support does you pacth do the same?
Of course it does. I don't know why you'd just ignore it and implement your own.
Ben

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1250023747-20224-3-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
...
#ifdef CONFIG_SMC_USE_32_BIT -#define USE_32_BIT 1 +#define is_use_32bit(x) (x->use_32bit)
Does switching from a compile time check to a run time check not cause an avoidable growth of the memory footprint?
How much bigger is the new code?
-#undef USE_32_BIT +#define is_use_32bit(x) (0) #endif
...
-static inline word SMC_inw(dword offset) +static inline word SMC_io_inw(struct smc91111_device *smc, dword offset) { word v;
- v = *((volatile word*)(SMC_BASE_ADDRESS+offset));
- v = *((volatile word*)(smc->regs+offset)); barrier(); *(volatile u32*)(0xc0000000); return v;
}
-static inline void SMC_outw(word value, dword offset) +static inline void SMC_io_outw(struct smc91111_device *smc, word value,
dword offset)
{
- *((volatile word*)(SMC_BASE_ADDRESS+offset)) = value;
- *((volatile word*)(smc->regs+offset)) = value; barrier(); *(volatile u32*)(0xc0000000);
}
Please use proper I/O accessor functions here.
-static inline byte SMC_inb(dword offset) +static inline byte SMC_io_inb(struct smc91111_device *smc, dword offset) { word _w;
...and here.
@@ -264,18 +234,22 @@ static inline byte SMC_inb(dword offset) return (offset & 1) ? (byte)(_w >> 8) : (byte)(_w); }
-static inline void SMC_outb(byte value, dword offset) +static inline void SMC_io_outb(struct smc91111_device *smc, byte value,
dword offset)
{ word _w;
_w = SMC_inw(offset & ~((dword)1)); if (offset & 1)
*((volatile word*)(SMC_BASE_ADDRESS+(offset & ~((dword)1)))) = (value<<8) | (_w & 0x00ff);
*((volatile word*)(smc->regs+(offset & ~((dword)1)))) =
else(value<<8) | (_w & 0x00ff);
*((volatile word*)(SMC_BASE_ADDRESS+offset)) = value | (_w & 0xff00);
*((volatile word*)(smc->regs+offset)) =
value | (_w & 0xff00);
}
...and here.
-static inline void SMC_insw(dword offset, volatile uchar* buf, dword len) +static inline void SMC_io_insw(struct smc91111_device *smc, dword offset,
volatile uchar* buf, dword len)
{ volatile word *p = (volatile word *)buf;
...and here.
@@ -286,7 +260,8 @@ static inline void SMC_insw(dword offset, volatile uchar* buf, dword len) } }
-static inline void SMC_outsw(dword offset, uchar* buf, dword len) +static inline void SMC_io_outsw(struct smc91111_device *smc, dword offset,
uchar* buf, dword len)
{ volatile word *p = (volatile word *)buf;
...and here.
-static int smc_close() +static void smc_halt(struct eth_device *netdev) {
- struct smc91111_device *smc = to_smc91111(netdev); PRINTK2("%s: smc_close\n", SMC_DEV_NAME);
You should also adapt the debug messages to the changed function names.
+#ifdef CONFIG_SMC_USE_32_BIT +#define USE_32BIT 1 +#else +#define USE_32BIT 0 +#endif
Above you get rid of the USE_32BIT stuff; here you re-introduce it. Why?
diff --git a/drivers/net/smc91111.h b/drivers/net/smc91111.h index 967addd..b2ed6a5 100644 --- a/drivers/net/smc91111.h +++ b/drivers/net/smc91111.h @@ -72,6 +72,10 @@ typedef unsigned long int dword;
/* Because of bank switching, the LAN91xxx uses only 16 I/O ports */
+#ifndef SMC_BASE_ADDRESS +#define SMC_BASE_ADDRESS smc->regs +#endif
#define SMC_IO_EXTENT 16
#ifdef CONFIG_PXA250 @@ -301,8 +305,6 @@ typedef unsigned long int dword;
#endif /* CONFIG_SMC_USE_IOFUNCS */
-#if defined(CONFIG_SMC_USE_32_BIT)
#ifdef CONFIG_XSENGINE #define SMC_inl(r) (*((volatile dword *)(SMC_BASE_ADDRESS+(r<<1))))
This should be fixed to use I/O accessors, too.
include/configs/ADNPESC1.h | 1 + include/configs/DK1C20.h | 1 + include/configs/DK1S10.h | 1 + include/configs/EP1C20.h | 1 + include/configs/EP1S10.h | 1 + include/configs/EP1S40.h | 1 + include/configs/MigoR.h | 1 + include/configs/PK1C20.h | 1 + include/configs/bf533-ezkit.h | 1 + include/configs/bf533-stamp.h | 1 + include/configs/bf538f-ezkit.h | 1 + include/configs/bf561-ezkit.h | 1 + include/configs/blackstamp.h | 1 + include/configs/cerf250.h | 1 + include/configs/cm-bf533.h | 1 + include/configs/cm-bf561.h | 1 + include/configs/cradle.h | 1 + include/configs/delta.h | 1 + include/configs/dnp1110.h | 1 + include/configs/gr_cpci_ax2000.h | 1 + include/configs/gr_ep2s60.h | 1 + include/configs/innokom.h | 1 + include/configs/integratorcp.h | 1 + include/configs/logodl.h | 1 + include/configs/lpd7a400-10.h | 1 + include/configs/lpd7a404-10.h | 1 + include/configs/ms7722se.h | 1 + include/configs/netstar.h | 1 + include/configs/nhk8815.h | 1 + include/configs/pxa255_idp.h | 1 + include/configs/versatile.h | 1 + include/configs/voiceblue.h | 1 + include/configs/xaeniax.h | 1 + include/configs/xm250.h | 1 + include/configs/xsengine.h | 1 + include/configs/zylonite.h | 1 +
This is a pretty long list of boards which is affected. How many of these have actuaaly been tested with this patch, and which ones, and to what extent?
Best regards,
Wolfgang Denk

On 21:12 Wed 12 Aug , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1250023747-20224-3-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
...
#ifdef CONFIG_SMC_USE_32_BIT -#define USE_32_BIT 1 +#define is_use_32bit(x) (x->use_32bit)
Does switching from a compile time check to a run time check not cause an avoidable growth of the memory footprint?
How much bigger is the new code?
none for the non 32 bit support it will only impact you if you do enable the 32bits support but the impact depend on the arch you use I've seen different impact on arm and sh but on the board I've test less than 300 bytes for dual support
with dual support ... configured to boot from Nand Flash Configuring for nhk8815 board... text data bss dec hex filename 189330 8132 24984 222446 364ee u-boot
with 32bit only ... configured to boot from Nand Flash Configuring for nhk8815 board... text data bss dec hex filename 189082 8132 24984 222198 363f6 u-boot
with non 32bit ... configured to boot from Nand Flash Configuring for nhk8815 board... text data bss dec hex filename 189050 8132 24984 222166 363d6 u-boot
-#undef USE_32_BIT +#define is_use_32bit(x) (0) #endif
...
-static inline word SMC_inw(dword offset) +static inline word SMC_io_inw(struct smc91111_device *smc, dword offset) { word v;
- v = *((volatile word*)(SMC_BASE_ADDRESS+offset));
- v = *((volatile word*)(smc->regs+offset)); barrier(); *(volatile u32*)(0xc0000000); return v;
}
-static inline void SMC_outw(word value, dword offset) +static inline void SMC_io_outw(struct smc91111_device *smc, word value,
dword offset)
{
- *((volatile word*)(SMC_BASE_ADDRESS+offset)) = value;
- *((volatile word*)(smc->regs+offset)) = value; barrier(); *(volatile u32*)(0xc0000000);
}
Please use proper I/O accessor functions here.
this will be for an other patch I do not want to mix Net multi api update and I/O cleanup
-static int smc_close() +static void smc_halt(struct eth_device *netdev) {
- struct smc91111_device *smc = to_smc91111(netdev); PRINTK2("%s: smc_close\n", SMC_DEV_NAME);
You should also adapt the debug messages to the changed function names.
+#ifdef CONFIG_SMC_USE_32_BIT +#define USE_32BIT 1 +#else +#define USE_32BIT 0 +#endif
Above you get rid of the USE_32BIT stuff; here you re-introduce it. Why?
yes it's different here it's to declare that you want to activate the 32bit for the default driver init
include/configs/ADNPESC1.h | 1 + include/configs/DK1C20.h | 1 + include/configs/DK1S10.h | 1 + include/configs/EP1C20.h | 1 + include/configs/EP1S10.h | 1 + include/configs/EP1S40.h | 1 + include/configs/MigoR.h | 1 + include/configs/PK1C20.h | 1 + include/configs/bf533-ezkit.h | 1 + include/configs/bf533-stamp.h | 1 + include/configs/bf538f-ezkit.h | 1 + include/configs/bf561-ezkit.h | 1 + include/configs/blackstamp.h | 1 + include/configs/cerf250.h | 1 + include/configs/cm-bf533.h | 1 + include/configs/cm-bf561.h | 1 + include/configs/cradle.h | 1 + include/configs/delta.h | 1 + include/configs/dnp1110.h | 1 + include/configs/gr_cpci_ax2000.h | 1 + include/configs/gr_ep2s60.h | 1 + include/configs/innokom.h | 1 + include/configs/integratorcp.h | 1 + include/configs/logodl.h | 1 + include/configs/lpd7a400-10.h | 1 + include/configs/lpd7a404-10.h | 1 + include/configs/ms7722se.h | 1 + include/configs/netstar.h | 1 + include/configs/nhk8815.h | 1 + include/configs/pxa255_idp.h | 1 + include/configs/versatile.h | 1 + include/configs/voiceblue.h | 1 + include/configs/xaeniax.h | 1 + include/configs/xm250.h | 1 + include/configs/xsengine.h | 1 + include/configs/zylonite.h | 1 +
This is a pretty long list of boards which is affected. How many of these have actuaaly been tested with this patch, and which ones, and to what extent?
none will be impact as the share the same init and I've not modify any config just active the multi support and the code is tested on custom boards (4 differents) + nhk8815
and compile on arm & sh
Best Regards, J.

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090812203659.GB21725@game.jcrosoft.org you wrote:
+#ifdef CONFIG_SMC_USE_32_BIT +#define USE_32BIT 1 +#else +#define USE_32BIT 0 +#endif
Above you get rid of the USE_32BIT stuff; here you re-introduce it. Why?
yes it's different here it's to declare that you want to activate the 32bit for the default driver init
Why not use the same method as above?
This is a pretty long list of boards which is affected. How many of these have actuaaly been tested with this patch, and which ones, and to what extent?
none will be impact as the share the same init and I've not modify any config just active the multi support
Come on. You make heavy changes to the driver ans claim that none of the boards would be affected? This is... very naïve at best.
and the code is tested on custom boards (4 differents) + nhk8815
I see. You should ask board maintainers for feedback, then.
Best regards,
Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1250023747-20224-2-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
include/net.h | 2 ++ net/eth.c | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-)
NAK.
First, there are formal issues:
- The subject line is way too long.
- There is no commit message and no description what this patch is supposed to do or to fix. Why should we add it?
index 2a8a12d..dc4ae41 100644 --- a/include/net.h +++ b/include/net.h @@ -124,6 +124,8 @@ extern void eth_set_enetaddr(int num, char* a); /* Set new MAC address */ extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr); extern int eth_getenv_enetaddr(char *name, uchar *enetaddr); extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr); +extern int eth_getenv_num_enetaddr(int num, uchar *enetaddr); +extern int eth_setenv_num_enetaddr(int num, const uchar *enetaddr);
What are these functions god for? Are they by any chance duplicationg existing code, got example eth_getenv_enetaddr_by_index() ?
extern int eth_init(bd_t *bis); /* Initialize the device */ extern int eth_send(volatile void *packet, int length); /* Send a packet */ diff --git a/net/eth.c b/net/eth.c index 2316a22..9bdf961 100644 --- a/net/eth.c +++ b/net/eth.c @@ -27,6 +27,12 @@ #include <miidev.h>
#ifdef CONFIG_CMD_NET
+static void get_enetvar(int num, char *enetvar)
Should this not be "uchar *", to stay consistent with the other code?
+{
- sprintf(enetvar, num ? "eth%daddr" : "ethaddr", num);
+}
void eth_parse_enetaddr(const char *addr, uchar *enetaddr) { char *end; @@ -53,6 +59,24 @@ int eth_setenv_enetaddr(char *name, const uchar *enetaddr)
return setenv(name, buf); }
+int eth_getenv_num_enetaddr(int num, uchar *enetaddr) +{
- char enetvar[32];
- get_enetvar(num, enetvar);
- return eth_getenv_enetaddr(enetvar, enetaddr);
+}
Looks very much like eth_getenv_enetaddr_by_index() to me. What do you need this for?
Please elucidate...
Best regards,
Wolfgang Denk

On 20:58 Wed 12 Aug , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1250023747-20224-2-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
include/net.h | 2 ++ net/eth.c | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-)
NAK.
First, there are formal issues:
- The subject line is way too long.
why it's only 67 chars
- There is no commit message and no description what this patch is supposed to do or to fix. Why should we add it?
just to stop to duplicate this in every driver
index 2a8a12d..dc4ae41 100644 --- a/include/net.h +++ b/include/net.h @@ -124,6 +124,8 @@ extern void eth_set_enetaddr(int num, char* a); /* Set new MAC address */ extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr); extern int eth_getenv_enetaddr(char *name, uchar *enetaddr); extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr); +extern int eth_getenv_num_enetaddr(int num, uchar *enetaddr); +extern int eth_setenv_num_enetaddr(int num, const uchar *enetaddr);
What are these functions god for? Are they by any chance duplicationg existing code, got example eth_getenv_enetaddr_by_index() ?
the get yes but not there is no set
Best Regards, J.

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090812205833.GD21725@game.jcrosoft.org you wrote:
- There is no commit message and no description what this patch is supposed to do or to fix. Why should we add it?
just to stop to duplicate this in every driver
I would expect then that you remove such duplicated code from "every driver", but I do not see any such removal?
index 2a8a12d..dc4ae41 100644 --- a/include/net.h +++ b/include/net.h @@ -124,6 +124,8 @@ extern void eth_set_enetaddr(int num, char* a); /* Set new MAC address */ extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr); extern int eth_getenv_enetaddr(char *name, uchar *enetaddr); extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr); +extern int eth_getenv_num_enetaddr(int num, uchar *enetaddr); +extern int eth_setenv_num_enetaddr(int num, const uchar *enetaddr);
What are these functions god for? Are they by any chance duplicationg existing code, got example eth_getenv_enetaddr_by_index() ?
the get yes but not there is no set
Makes no sense to me. Above you claim you want to avoid code duplication, and here you duplicate existing functions? Please use the existing code instead, and add only what might be missing.
Best regards,
Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1250023747-20224-1-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
include/net.h | 1 + net/eth.c | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-)
What exactly is the problem you are addressing with this patch?
Please provide a commit message that explains what is going on, and what is being changed or fixed.
Thanks.
Best regards,
Wolfgang Denk

On 20:50 Wed 12 Aug , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1250023747-20224-1-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
include/net.h | 1 + net/eth.c | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-)
What exactly is the problem you are addressing with this patch?
Please provide a commit message that explains what is going on, and what is being changed or fixed.
simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are which allow us the avoid to read the eeprom every time we want to use the eth
Best Regards, J.

Jean-Christophe PLAGNIOL-VILLARD wrote:
On 20:50 Wed 12 Aug , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1250023747-20224-1-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
include/net.h | 1 + net/eth.c | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-)
What exactly is the problem you are addressing with this patch?
Please provide a commit message that explains what is going on, and what is being changed or fixed.
simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are which allow us the avoid to read the eeprom every time we want to use the eth
While I'm not completely opposed to the idea of tracking indices, it's simply not true that you don't know the indices of the controllers on your board. They're all instantiated in board_eth_init(), so the first will be 0 and the second will be 1 etc. If you had a mix of devices and they were found by probing as in Linux, it would be different. Here in U-boot, ordering is deterministic and dictated by the developer.
BTW - this is hardly the first driver that can have multiple instances. Others, such as TSEC, seem to be managing just fine.
regards, Ben

On 14:15 Wed 12 Aug , Ben Warren wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 20:50 Wed 12 Aug , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1250023747-20224-1-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
include/net.h | 1 + net/eth.c | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-)
What exactly is the problem you are addressing with this patch?
Please provide a commit message that explains what is going on, and what is being changed or fixed.
simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are which allow us the avoid to read the eeprom every time we want to use the eth
While I'm not completely opposed to the idea of tracking indices, it's simply not true that you don't know the indices of the controllers on your board. They're all instantiated in board_eth_init(), so the first will be 0 and the second will be 1 etc. If you had a mix of devices and they were found by probing as in Linux, it would be different. Here in U-boot, ordering is deterministic and dictated by the developer.
but you can not known it in the driver specially if you have multi different MAC chip 2 SMC91111 + 1 SOC MAC
and you will add it in the order of preferance to use for the board to let u-boot try to connect in the order of your preference
as example this order SOC_M_0 SMC9111_0 SMC9111_1
so you can do this board_eth_init() { call cpu_eth_init register smc91111_0 register smc91111_1 }
in an other board I can prefer board_eth_init() { call cpu_eth_init register smc91111_0 register smc91111_1 }
so instead of duplicate the info and the code you just allow the driver to known is index
BTW - this is hardly the first driver that can have multiple instances. Others, such as TSEC, seem to be managing just fine.
each drivers do his own way
this one is generic
Best Regards, J.

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090812212651.GA11003@game.jcrosoft.org you wrote:
While I'm not completely opposed to the idea of tracking indices, it's simply not true that you don't know the indices of the controllers on your board. They're all instantiated in board_eth_init(), so the first will be 0 and the second will be 1 etc. If you had a mix of devices and they were found by probing as in Linux, it would be different. Here in U-boot, ordering is deterministic and dictated by the developer.
but you can not known it in the driver specially if you have multi different MAC chip 2 SMC91111
- 1 SOC MAC
and you will add it in the order of preferance to use for the board to let u-boot try to connect in the order of your preference
Like Ben I don't really understand where your problem is. We have many boards with multiple Ethernet Interfaces; for example, we see boards with up to 4 x TSEC and up to 2 x EEPRO100 controllers. And there is never more than a single "active" device.
We don't need any such code there. Why would you need it?
Best regards,
Wolfgang Denk

Jean-Christophe PLAGNIOL-VILLARD wrote:
On 14:15 Wed 12 Aug , Ben Warren wrote:
Jean-Christophe PLAGNIOL-VILLARD wrote:
On 20:50 Wed 12 Aug , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1250023747-20224-1-git-send-email-plagnioj@jcrosoft.com you wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
include/net.h | 1 + net/eth.c | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-)
What exactly is the problem you are addressing with this patch?
Please provide a commit message that explains what is going on, and what is being changed or fixed.
simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are which allow us the avoid to read the eeprom every time we want to use the eth
While I'm not completely opposed to the idea of tracking indices, it's simply not true that you don't know the indices of the controllers on your board. They're all instantiated in board_eth_init(), so the first will be 0 and the second will be 1 etc. If you had a mix of devices and they were found by probing as in Linux, it would be different. Here in U-boot, ordering is deterministic and dictated by the developer.
but you can not known it in the driver specially if you have multi different MAC chip 2 SMC91111
- 1 SOC MAC
and you will add it in the order of preferance to use for the board to let u-boot try to connect in the order of your preference
as example this order SOC_M_0 SMC9111_0 SMC9111_1
so you can do this board_eth_init() { call cpu_eth_init register smc91111_0 register smc91111_1 }
in an other board I can prefer board_eth_init() { call cpu_eth_init register smc91111_0 register smc91111_1 }
so instead of duplicate the info and the code you just allow the driver to known is index
I find it convenient to get a driver handle via eth_get_dev_by_name() and then access its elements (MAC address etc.) through the handle. Not exactly the most efficient way, but it's certainly convenient. This is how I modified all the eeprom-accessing standalone apps with SMC911X and SMC91111 (which, BTW, your SMC91111 patch didn't fix) to work with CONFIG_NET_MULTI.
BTW - this is hardly the first driver that can have multiple instances. Others, such as TSEC, seem to be managing just fine.
each drivers do his own way
Not a good direction to take if possible.
this one is generic
Best Regards, J.
Ben

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090812210339.GE21725@game.jcrosoft.org you wrote:
What exactly is the problem you are addressing with this patch?
Please provide a commit message that explains what is going on, and what is being changed or fixed.
simple it impossible to known what will be your device index in the driver specially when you have 2 or more drivers instance once or more
Sorry, but we don't have driver instances in U-Boot. Even if you have several Ethernet interfaces of the same type, there will be only a single device driver instance.
so you can not update the mac addres in the env if you want to do it as we do on smc91111 as we can not known eth%daddr you are which allow us the avoid to read the eeprom every time we want to use the eth
At any time, there is (at most) a single active interface.
Best regards,
Wolfgang Denk
participants (3)
-
Ben Warren
-
Jean-Christophe PLAGNIOL-VILLARD
-
Wolfgang Denk