Convert SMC911X Ethernet driver to CONFIG_NET_MULTI API
Subsystems (2)
PATCH 1/1 Convert SMC911X Ethernet driver to CONFIG_NET_MULTI API
All in-tree boards that use this controller have CONFIG_NET_MULTI added Also:
- changed CONFIG_DRIVER_SMC911X* to CONFIG_SMC911X*
- cleaned up line lengths
- modified all boards that override weak function in this driver
--- board/bf548-ezkit/bf548-ezkit.c | 11 ++ board/cm-bf548/cm-bf548.c | 10 ++ board/freescale/mx31pdk/mx31pdk.c | 10 ++ board/imx31_litekit/imx31_litekit.c | 10 ++ board/imx31_phycore/imx31_phycore.c | 10 ++ board/micronas/vct/ebi_smc911x.c | 22 ++++- board/micronas/vct/vct.c | 10 ++ board/omap3/evm/evm.c | 10 ++ board/renesas/ap325rxa/ap325rxa.c | 10 ++ board/renesas/rsk7203/rsk7203.c | 17 +++- drivers/net/Makefile | 2 +- drivers/net/smc911x.c | 151 +++++++++++++++++++----------- drivers/net/smc911x.h | 173 +++++++++++++++++++---------------- include/configs/ap325rxa.h | 7 +- include/configs/bf548-ezkit.h | 7 +- include/configs/cm-bf548.h | 7 +- include/configs/imx31_litekit.h | 7 +- include/configs/imx31_phycore.h | 7 +- include/configs/mx31pdk.h | 7 +- include/configs/omap3_evm.h | 7 +- include/configs/rsk7203.h | 7 +- include/configs/vct.h | 9 +- include/netdev.h | 1 + 23 files changed, 341 insertions(+), 171 deletions(-)
board/bf548-ezkit/bf548-ezkit.c +11 -0
@@ -7,6 +7,7 @@*/ #include <common.h> +#include <netdev.h> #include <config.h> #include <command.h> #include <asm/blackfin.h>
@@ -77,3 +78,13 @@ int board_early_init_f(void)return 0 ; } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +#endif +return rc; +} +
board/cm-bf548/cm-bf548.c +10 -0
@@ -9,6 +9,7 @@#include <common.h> #include <config.h> #include <command.h> +#include <netdev.h> #include <asm/blackfin.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -77,3 +78,12 @@ int board_early_init_f(void)return 0 ; } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +#endif +return rc; +}
board/freescale/mx31pdk/mx31pdk.c +10 -0
@@ -25,6 +25,7 @@#include <common.h> +#include <netdev.h> #include <asm/arch/mx31.h> #include <asm/arch/mx31-regs.h>
@@ -61,3 +62,12 @@ int checkboard(void)printf ("Board: i.MX31 MAX PDK (3DS)\n" );return 0 ; } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +#endif +return rc; +}
board/imx31_litekit/imx31_litekit.c +10 -0
@@ -23,6 +23,7 @@#include <common.h> +#include <netdev.h> #include <asm/arch/mx31.h> #include <asm/arch/mx31-regs.h>
@@ -75,3 +76,12 @@ int checkboard (void)printf ("Board: i.MX31 Litekit\n" );return 0 ; } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +#endif +return rc; +}
board/imx31_phycore/imx31_phycore.c +10 -0
@@ -24,6 +24,7 @@#include <common.h> #include <s6e63d6.h> +#include <netdev.h> #include <asm/arch/mx31.h> #include <asm/arch/mx31-regs.h>
@@ -128,3 +129,12 @@ int checkboard (void)printf ("Board: Phytec phyCore i.MX31\n" );return 0 ; } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +#endif +return rc; +}
board/micronas/vct/ebi_smc911x.c +18 -4
@@ -18,6 +18,7 @@*/ #include <common.h> +#include <netdev.h> #include <asm/io.h> #include "vct.h"
@@ -45,10 +46,11 @@ int ebi_init_smc911x(void)* Accessor functions replacing the "weak" functions in * drivers/net/smc911x.c */ -u32 smc911x_reg_read (u32 addr) +u32 smc911x_reg_read (struct eth_device *dev,u32 addr) {volatile u32 data; + addr += dev->iobase;reg_write (EBI_DEV1_CONFIG2 (EBI_BASE ),0x0000004F );ebi_wait ();reg_write (EBI_CPU_IO_ACCS (EBI_BASE ), (EXT_DEVICE_CHANNEL_1 | addr));
@@ -58,8 +60,9 @@ u32 smc911x_reg_read(u32 addr)return (data); } -void smc911x_reg_write (u32 addr,u32 data) +void smc911x_reg_write (struct eth_device *dev,u32 addr,u32 data) { + addr += dev->iobase;reg_write (EBI_DEV1_CONFIG2 (EBI_BASE ),0x0000004F );ebi_wait ();reg_write (EBI_IO_ACCS_DATA (EBI_BASE ), data);
@@ -68,8 +71,9 @@ void smc911x_reg_write(u32 addr, u32 data)ebi_wait (); } -void pkt_data_push (u32 addr,u32 data) +void pkt_data_push (struct eth_device *dev,u32 addr,u32 data) { + addr += dev->iobase;reg_write (EBI_DEV1_CONFIG2 (EBI_BASE ),0x0000004A );ebi_wait ();reg_write (EBI_IO_ACCS_DATA (EBI_BASE ), data);
@@ -80,10 +84,11 @@ void pkt_data_push(u32 addr, u32 data)return ; } -u32 pkt_data_pull (u32 addr) +u32 pkt_data_pull (struct eth_device *dev,u32 addr) {volatile u32 data; + addr += dev->iobase;reg_write (EBI_DEV1_CONFIG2 (EBI_BASE ),0x0000004A );ebi_wait ();reg_write (EBI_CPU_IO_ACCS (EBI_BASE ), (EXT_DEVICE_CHANNEL_1 | addr));
@@ -92,3 +97,12 @@ u32 pkt_data_pull(u32 addr)return data; } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_DRIVER_SMC911X_BASE ); +#endif +return rc; +}
board/micronas/vct/vct.c +10 -0
@@ -21,6 +21,7 @@#include <common.h> #include <command.h> +#include <netdev.h> #include <asm/mipsregs.h> #include "vct.h"
@@ -115,3 +116,12 @@ int checkboard(void)return 0 ; } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +#endif +return rc; +}
board/omap3/evm/evm.c +10 -0
@@ -28,6 +28,7 @@* MA 02111-1307 USA */ #include <common.h> +#include <netdev.h> #include <asm/io.h> #include <asm/arch/mem.h> #include <asm/arch/mux.h>
@@ -122,3 +123,12 @@ static void setup_net_chip(void)udelay (1 );writel (GPIO0 , &gpio3_base->setdataout); } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +#endif +return rc; +}
board/renesas/ap325rxa/ap325rxa.c +10 -0
@@ -19,6 +19,7 @@*/ #include <common.h> +#include <netdev.h> #include <asm/io.h> #include <asm/processor.h>
@@ -160,3 +161,12 @@ void ide_set_reset(int idereset)udelay (FPGA_NAND_RST_WAIT );outw (FPGA_NAND_INIT ,FPGA_NAND_CTL ); } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +#endif +return rc; +}
board/renesas/rsk7203/rsk7203.c +14 -3
@@ -21,6 +21,7 @@*/ #include <common.h> +#include <netdev.h> #include <asm/io.h> #include <asm/processor.h>
@@ -57,15 +58,25 @@ void led_set_state(unsigned short value)* And this has problem by FIFO access only. pkt_data_pull/pkt_data_push * functions necessary to solve this problem. */ -u32 pkt_data_pull (u32 addr) +u32 pkt_data_pull (struct eth_device *dev,u32 addr) { -volatile u16 *addr_16 = (u16 *)addr; +volatile u16 *addr_16 = (u16 *)(dev->iobase + addr);return (u32)((swab16 (*addr_16) <<16 ) &0xFFFF0000 )\ |swab16 (*(addr_16 +1 )); } -void pkt_data_push (u32 addr,u32 val) +void pkt_data_push (struct eth_device *dev,u32 addr,u32 val) { + addr += dev->iobase; *(volatile u16 *)(addr +2 ) =swab16 ((u16 )val); *(volatile u16 *)(addr) =swab16 ((u16)(val >>16 )); } + +int board_eth_init (bd_t *bis) +{ +int rc =0 ; +#ifdef CONFIG_SMC911X + rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +#endif +return rc; +}
drivers/net/Makefile +1 -1
@@ -63,7 +63,7 @@ COBJS-$(CONFIG_RTL8169) += rtl8169.o COBJS-$(CONFIG_DRIVER_S3C4510_ETH) += s3c4510b_eth.o COBJS-$(CONFIG_SH_ETHER) += sh_eth.o COBJS-$(CONFIG_DRIVER_SMC91111) += smc91111.o -COBJS-$(CONFIG_DRIVER_SMC911X) += smc911x.o +COBJS-$(CONFIG_SMC911X) += smc911x.o COBJS-$(CONFIG_TIGON3) += tigon3.o bcm570x_autoneg.o 5701rls.o COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o COBJS-$(CONFIG_TSEC_ENET) += tsec.o
drivers/net/smc911x.c +95 -56
303 lines not on this page · raw message
drivers/net/smc911x.h +94 -79
365 lines not on this page · raw message
include/configs/ap325rxa.h +4 -3
@@ -53,9 +53,10 @@#undef CONFIG_SHOW_BOOT_PROGRESS/* SMC9118 */ -#define CONFIG_DRIVER_SMC911X 1 -#define CONFIG_DRIVER_SMC911X_32_BIT 1 -#define CONFIG_DRIVER_SMC911X_BASE 0xB6080000 +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X 1 +#define CONFIG_SMC911X_32_BIT 1 +#define CONFIG_SMC911X_BASE 0xB6080000/* MEMORY */ #define AP325RXA_SDRAM_BASE (0x88000000)
include/configs/bf548-ezkit.h +4 -3
@@ -69,9 +69,10 @@* Network Settings */ #define ADI_CMDS_NETWORK 1 -#define CONFIG_DRIVER_SMC911X 1 -#define CONFIG_DRIVER_SMC911X_BASE 0x24000000 -#define CONFIG_DRIVER_SMC911X_16_BIT +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X 1 +#define CONFIG_SMC911X_BASE 0x24000000 +#define CONFIG_SMC911X_16_BIT #define CONFIG_HOSTNAME bf548-ezkit/* Uncomment next line to use fixed MAC address */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
include/configs/cm-bf548.h +4 -3
@@ -69,9 +69,10 @@* Network Settings */ #define ADI_CMDS_NETWORK 1 -#define CONFIG_DRIVER_SMC911X 1 -#define CONFIG_DRIVER_SMC911X_BASE 0x24000000 -#define CONFIG_DRIVER_SMC911X_16_BIT +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X 1 +#define CONFIG_SMC911X_BASE 0x24000000 +#define CONFIG_SMC911X_16_BIT #define CONFIG_HOSTNAME cm-bf548/* Uncomment next line to use fixed MAC address */ /* #define CONFIG_ETHADDR 02:80:ad:24:31:91 */
include/configs/imx31_litekit.h +4 -3
@@ -104,9 +104,10 @@ "prg_uboot=tftpboot 0x80000000 u-boot-imx31_litekit.bin; protect off all; erase 0xa00d0000 0xa01effff; cp.b 0x80000000 0xa00d0000 $(filesize)\0" -#define CONFIG_DRIVER_SMC911X 1 -#define CONFIG_DRIVER_SMC911X_BASE (CS4_BASE + 0x00020000) -#define CONFIG_DRIVER_SMC911X_32_BIT 1 +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X 1 +#define CONFIG_SMC911X_BASE (CS4_BASE + 0x00020000) +#define CONFIG_SMC911X_32_BIT 1/* * Miscellaneous configurable options
include/configs/imx31_phycore.h +4 -3
@@ -106,9 +106,10 @@ "prg_jffs2=tftpboot 0x80000000 $(jffs2); erase 0xa01c0000 0xa1ffffff; cp.b 0x80000000 0xa01c0000 $(filesize)\0" -#define CONFIG_DRIVER_SMC911X 1 -#define CONFIG_DRIVER_SMC911X_BASE 0xa8000000 -#define CONFIG_DRIVER_SMC911X_32_BIT 1 +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X 1 +#define CONFIG_SMC911X_BASE 0xa8000000 +#define CONFIG_SMC911X_32_BIT 1/* * Miscellaneous configurable options
include/configs/mx31pdk.h +4 -3
@@ -106,9 +106,10 @@"bootcmd_net=run bootargs_base bootargs_mtd bootargs_nfs; " \ "tftpboot 0x81000000 uImage-mx31; bootm\0" -#define CONFIG_DRIVER_SMC911X 1 -#define CONFIG_DRIVER_SMC911X_BASE 0xB6000000 -#define CONFIG_DRIVER_SMC911X_32_BIT 1 +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X 1 +#define CONFIG_SMC911X_BASE 0xB6000000 +#define CONFIG_SMC911X_32_BIT 1/* * Miscellaneous configurable options
include/configs/omap3_evm.h +4 -3
@@ -301,9 +301,10 @@ extern unsigned int boot_flash_type;*/ #if defined(CONFIG_CMD_NET ) -#define CONFIG_DRIVER_SMC911X -#define CONFIG_DRIVER_SMC911X_32_BIT -#define CONFIG_DRIVER_SMC911X_BASE 0x2C000000 +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X +#define CONFIG_SMC911X_32_BIT +#define CONFIG_SMC911X_BASE 0x2C000000#endif /* (CONFIG_CMD_NET) */
include/configs/rsk7203.h +4 -3
@@ -105,8 +105,9 @@#define CONFIG_SYS_HZ (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)/* Network interface */ -#define CONFIG_DRIVER_SMC911X -#define CONFIG_DRIVER_SMC911X_16_BIT -#define CONFIG_DRIVER_SMC911X_BASE (0x24000000) +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X +#define CONFIG_SMC911X_16_BIT +#define CONFIG_SMC911X_BASE (0x24000000)#endif /* __RSK7203_H */
include/configs/vct.h +5 -4
@@ -89,10 +89,11 @@/* * SMSC91C11x Network Card */ -#define CONFIG_DRIVER_SMC911X -#define CONFIG_DRIVER_SMC911X_BASE 0x00000000 -#define CONFIG_DRIVER_SMC911X_32_BIT +#define CONFIG_SMC911X +#define CONFIG_SMC911X_BASE 0x00000000 +#define CONFIG_SMC911X_32_BIT #define CONFIG_NET_RETRY_COUNT 20 +#define CONFIG_NET_MULTI #endif /*
@@ -342,7 +343,7 @@ int vct_gpio_get(int pin);#undef CONFIG_CMD_TERMINAL#undef CONFIG_CMD_USB -#undef CONFIG_DRIVER_SMC911X +#undef CONFIG_SMC911X#undef CONFIG_SOFT_I2C#undef CONFIG_SOURCE#undef CONFIG_SYS_LONGHELP
include/netdev.h +1 -0
@@ -71,6 +71,7 @@ int rtl8139_initialize(bd_t *bis);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 tsi108_eth_initialize (bd_t *bis);int uec_initialize (int index);int uli526x_initialize (bd_t *bis);
Signature · 1 line
1.5.6.3
PATCH 1/1 Convert SMC911X Ethernet driver to CONFIG_NET_MULTI API
Quoted 8 lines · Ben Warren
All in-tree boards that use this controller have
CONFIG_NET_MULTIadded Also:
- changed CONFIG_DRIVER_SMC911X* to CONFIG_SMC911X*
- cleaned up line lengths
- modified all boards that override weak function in this driverSigned-off-by Ben Warren <[email protected]>---
Note: I haven't actually *tested* this code, only verified that it compiles cleanly on an ARM platform and that the appropriate weak functions are overridden (looked in System.map). Although the changes are mainly cosmetic, there's a very good chance that bugs were introduced, so if anybody can try it please do!
thanks,
Ben
PATCH 1/1 Convert SMC911X Ethernet driver to CONFIG_NET_MULTI API
In reply to Ben Warrencouple changes to squash into this:
- fix build error for systems using in 16bit
- tweak bf548-ezkit update
- do not leak priv malloc() if dev malloc() failed
- make sure we clear eth_device (we really need a zalloc())
- initialize dev->enetaddr in the driver register func
- initialize the driver mac with dev->enetaddr
seems to work on my bf548-ezkit:
....
Net: smc911x-0 Hit any key to stop autoboot: 0
bfin> t 0 u-boot.bin
smc911x: initializing
smc911x: detected LAN9218 controller
smc911x: phy initialized
smc911x: MAC 00:e0:22:fe:bd:04
Using smc911x-0 device
TFTP from server 192.168.0.2; our IP address is 192.168.0.15 Filename 'u-boot.bin'.
Load address: 0x0
Loading: ##################
done
Bytes transferred = 258112 (3f040 hex)
bfin>
-mike
board/bf548-ezkit/bf548-ezkit.c +3 -6
@@ -79,12 +79,9 @@ int board_early_init_f(void)return 0 ; } +#ifdef CONFIG_SMC911X int board_eth_init (bd_t *bis) { -int rc =0 ; -#ifdef CONFIG_SMC911X - rc =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); -#endif -return rc; +return smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); } - +#endif
drivers/net/smc911x.c +29 -44
102 lines not on this page · raw message
drivers/net/smc911x.h +2 -2
@@ -64,8 +64,8 @@ static inline u32 smc911x_reg_read(struct eth_device *dev, u32 offset)static inline void smc911x_reg_write (struct eth_device *dev,u32 offset,u32 val) { - *(volatile u16 *)(dev->iobase + addr) = (u16 )val; - *(volatile u16 *)(dev->iobase + addr +2 ) = (u16)(val >>16 ); + *(volatile u16 *)(dev->iobase + offset) = (u16 )val; + *(volatile u16 *)(dev->iobase + offset +2 ) = (u16)(val >>16 ); }#else #error "SMC911X: undefined bus width"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090716/27a929bb/attachment.pgp
PATCH 1/1 Convert SMC911X Ethernet driver to CONFIG_NET_MULTI API
Quoted 9 lines · Mike Frysinger
couple changes to squash into this:
- fix build error for systems using in 16bit
- tweak bf548-ezkit update
- do not leak privmalloc()if devmalloc()failed
- make sure we cleareth_device(we really need azalloc())
- initializedev->enetaddrin the driver register func
- initialize the driver mac withdev->enetaddrseems to work on my bf548-ezkit:
<snip>
Wow, that was quick! Thanks!
Ben