net: davinci_emac: convert to using the driver model
Subsystems (5)
PATCH v2 1/1 net: davinci_emac: convert to using the driver model
From: Bartosz Golaszewski <[email protected]>
Now that we removed all legacy boards selecting TI_EMAC we can completely convert the driver code to using the driver model. This patch also updates all remaining users of davinci_emac.
---
v1 -> v2:
- moved the packetp assignment to the top of the recv() callback which fixes a crash on am3517_evm
- dropped a redundant call to net_process_received_packet(): this is already called from eth core
Thanks goes to Adam Ford for much appreciated testing and help.
Tested on da850-lcdk and da850-evm.
arch/arm/mach-davinci/cpu.c | 13 ----- arch/arm/mach-omap2/omap3/emac.c | 3 +- board/davinci/da8xxevm/da850evm.c | 6 -- board/davinci/da8xxevm/omapl138_lcdk.c | 14 ----- board/logicpd/am3517evm/am3517evm.c | 1 - board/ti/ti816x/evm.c | 3 +- configs/am3517_evm_defconfig | 1 + configs/da850evm_defconfig | 1 + configs/da850evm_direct_nor_defconfig | 1 + configs/da850evm_nand_defconfig | 1 + configs/omapl138_lcdk_defconfig | 1 + configs/ti816x_evm_defconfig | 1 + drivers/net/ti/davinci_emac.c | 77 ++++++++++++++------------ include/netdev.h | 1 - 14 files changed, 50 insertions(+), 74 deletions(-)
arch/arm/mach-davinci/cpu.c +0 -13
@@ -5,7 +5,6 @@*/ #include <common.h> -#include <netdev.h> #include <asm/arch/hardware.h> #include <asm/io.h>
@@ -90,15 +89,3 @@ int set_cpu_clk_info(void) gd->bd->bi_dsp_freq =0 ;return 0 ; } - -/* -* Initializes on-chip ethernet controllers. -* to override, implement board_eth_init() -*/ -int cpu_eth_init (bd_t *bis) -{ -#if defined(CONFIG_DRIVER_TI_EMAC ) -davinci_emac_initialize (); -#endif -return 0 ; -}
arch/arm/mach-omap2/omap3/emac.c +1 -2
@@ -7,7 +7,6 @@*/ #include <common.h> -#include <netdev.h> #include <asm/io.h> #include <asm/arch/am35x_def.h>
@@ -24,5 +23,5 @@ int cpu_eth_init(bd_t *bis) reset &= ~CPGMACSS_SW_RST ;writel (reset, &am35x_scm_general_regs->ip_sw_reset); -return davinci_emac_initialize (); +return 0 ; }
board/davinci/da8xxevm/da850evm.c +0 -6
@@ -13,7 +13,6 @@#include <environment.h> #include <i2c.h> #include <net.h> -#include <netdev.h> #include <spi.h> #include <spi_flash.h> #include <asm/arch/hardware.h>
@@ -472,11 +471,6 @@ int board_eth_init(bd_t *bis)if (rmii_hw_init ())printf ("RMII hardware init failed!!!\n" );#endif -if (!davinci_emac_initialize ()) { -printf ("Error: Ethernet init failed!\n" ); -return -1 ; - } - return 0; }#endif /* CONFIG_DRIVER_TI_EMAC */
board/davinci/da8xxevm/omapl138_lcdk.c +0 -14
@@ -11,7 +11,6 @@#include <common.h> #include <i2c.h> #include <net.h> -#include <netdev.h> #include <spi.h> #include <spi_flash.h> #include <asm/arch/hardware.h>
@@ -229,19 +228,6 @@ int board_init(void)#ifdef CONFIG_DRIVER_TI_EMAC -/* -* Initializes on-board ethernet controllers. -*/ -int board_eth_init (bd_t *bis) -{ -if (!davinci_emac_initialize ()) { -printf ("Error: Ethernet init failed!\n" ); -return -1 ; - } - -return 0 ; -} -#endif /* CONFIG_DRIVER_TI_EMAC */ #define CFG_MAC_ADDR_SPI_BUS 0
board/logicpd/am3517evm/am3517evm.c +0 -1
@@ -28,7 +28,6 @@#include <linux/usb/gadget.h> #include <linux/usb/musb.h> #include <i2c.h> -#include <netdev.h> #include "am3517evm.h" DECLARE_GLOBAL_DATA_PTR ;
board/ti/ti816x/evm.c +1 -2
@@ -9,7 +9,6 @@#include <common.h> #include <environment.h> #include <spl.h> -#include <netdev.h> #include <asm/cache.h> #include <asm/io.h> #include <asm/arch/clock.h>
@@ -56,7 +55,7 @@ int board_eth_init(bd_t *bis)printf ("Unable to read MAC address. Set <ethaddr>\n" ); } -return davinci_emac_initialize (); +return 0 ; }#ifdef CONFIG_SPL_BUILD
configs/am3517_evm_defconfig +1 -0
@@ -44,6 +44,7 @@ CONFIG_SYS_NAND_BUSWIDTH_16BIT=y CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y CONFIG_SYS_NAND_U_BOOT_OFFS=0x80000 CONFIG_SPL_NAND_SIMPLE=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PINCTRL=y
configs/da850evm_defconfig +1 -0
@@ -59,6 +59,7 @@ CONFIG_SF_DEFAULT_SPEED=30000000 CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SPI_FLASH_MTD=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PINCTRL=y
configs/da850evm_direct_nor_defconfig +1 -0
@@ -50,6 +50,7 @@ CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PINCTRL=y
configs/da850evm_nand_defconfig +1 -0
@@ -59,6 +59,7 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SPI_FLASH_MTD=y +CONFIG_DM_ETH=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y CONFIG_DM_SERIAL=y
configs/omapl138_lcdk_defconfig +1 -0
@@ -49,6 +49,7 @@ CONFIG_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_DM_SERIAL=y
configs/ti816x_evm_defconfig +1 -0
@@ -45,6 +45,7 @@ CONFIG_SYS_I2C_OMAP24XX=y CONFIG_MMC_OMAP_HS=y CONFIG_NAND=y CONFIG_SYS_NAND_BUSWIDTH_16BIT=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_SYS_NS16550=y
drivers/net/ti/davinci_emac.c +42 -35
159 lines not on this page · raw message
include/netdev.h +0 -1
@@ -30,7 +30,6 @@ int bcm_sf2_eth_register(bd_t *bis, u8 dev_num);int bfin_EMAC_initialize (bd_t *bis);int calxedaxgmac_initialize (u32 id,ulong base_addr);int cs8900_initialize (u8 dev_num,int base_addr); -int davinci_emac_initialize (void );int dc21x4x_initialize (bd_t *bis);int designware_initialize (ulong base_addr,u32 interface);int dm9000_initialize (bd_t *bis);
Signature · 1 line
2.21.0
PATCH v2 1/1 net: davinci_emac: convert to using the driver model
Quoted 8 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Now that we removed all legacy boards selecting
TI_EMACwe can completely convert the driver code to using the driver model. This patch also updates all remaining users ofdavinci_emac.Signed-off-by Bartosz Golaszewski <[email protected]>
Quoted 426 lines
---
v1 -> v2:
- moved the packetp assignment to the top of therecv()callback which fixes a crash onam3517_evm
- dropped a redundant call tonet_process_received_packet(): this is already called from eth coreThanks goes to Adam Ford for much appreciated testing and help.
Tested on da850-lcdk and da850-evm.
arch/arm/mach-davinci/cpu.c | 13 ----- arch/arm/mach-omap2/omap3/emac.c | 3 +- board/davinci/da8xxevm/da850evm.c | 6 -- board/davinci/da8xxevm/omapl138_lcdk.c | 14 ----- board/logicpd/am3517evm/am3517evm.c | 1 - board/ti/ti816x/evm.c | 3 +- configs/am3517_evm_defconfig | 1 + configs/da850evm_defconfig | 1 + configs/da850evm_direct_nor_defconfig | 1 + configs/da850evm_nand_defconfig | 1 + configs/omapl138_lcdk_defconfig | 1 + configs/ti816x_evm_defconfig | 1 + drivers/net/ti/davinci_emac.c | 77 ++++++++++++++------------ include/netdev.h | 1 - 14 files changed, 50 insertions(+), 74 deletions(-)arch/arm/mach-davinci/cpu.c +0
-13@@ -5,7 +5,6 @@*/ #include <common.h> -#include <netdev.h> #include <asm/arch/hardware.h> #include <asm/io.h> @@ -90,15 +89,3 @@ int set_cpu_clk_info(void) gd->bd->bi_dsp_freq =0 ;return 0 ; } - -/* -* Initializes on-chip ethernet controllers. -* to override, implement board_eth_init() -*/ -int cpu_eth_init (bd_t *bis) -{ -#if defined(CONFIG_DRIVER_TI_EMAC ) -davinci_emac_initialize (); -#endif -return 0 ; -}arch/arm/mach-omap2/omap3/emac.c +1
-2@@ -7,7 +7,6 @@*/ #include <common.h> -#include <netdev.h> #include <asm/io.h> #include <asm/arch/am35x_def.h> @@ -24,5 +23,5 @@ int cpu_eth_init(bd_t *bis) reset &= ~CPGMACSS_SW_RST ;writel (reset, &am35x_scm_general_regs->ip_sw_reset); -return davinci_emac_initialize (); +return 0 ; }board/davinci/da8xxevm/da850evm.c +0
-6@@ -13,7 +13,6 @@#include <environment.h> #include <i2c.h> #include <net.h> -#include <netdev.h> #include <spi.h> #include <spi_flash.h> #include <asm/arch/hardware.h> @@ -472,11 +471,6 @@ int board_eth_init(bd_t *bis)if (rmii_hw_init ())printf ("RMII hardware init failed!!!\n" );#endif -if (!davinci_emac_initialize ()) { -printf ("Error: Ethernet init failed!\n" ); -return -1 ; - } - return 0; }#endif /* CONFIG_DRIVER_TI_EMAC */ board/davinci/da8xxevm/omapl138_lcdk.c +0
-14@@ -11,7 +11,6 @@#include <common.h> #include <i2c.h> #include <net.h> -#include <netdev.h> #include <spi.h> #include <spi_flash.h> #include <asm/arch/hardware.h> @@ -229,19 +228,6 @@ int board_init(void)#ifdef CONFIG_DRIVER_TI_EMAC -/* -* Initializes on-board ethernet controllers. -*/ -int board_eth_init (bd_t *bis) -{ -if (!davinci_emac_initialize ()) { -printf ("Error: Ethernet init failed!\n" ); -return -1 ; - } - -return 0 ; -} -#endif /* CONFIG_DRIVER_TI_EMAC */ #define CFG_MAC_ADDR_SPI_BUS 0board/logicpd/am3517evm/am3517evm.c +0
-1@@ -28,7 +28,6 @@#include <linux/usb/gadget.h> #include <linux/usb/musb.h> #include <i2c.h> -#include <netdev.h> #include "am3517evm.h" DECLARE_GLOBAL_DATA_PTR ;board/ti/ti816x/evm.c +1
-2@@ -9,7 +9,6 @@#include <common.h> #include <environment.h> #include <spl.h> -#include <netdev.h> #include <asm/cache.h> #include <asm/io.h> #include <asm/arch/clock.h> @@ -56,7 +55,7 @@ int board_eth_init(bd_t *bis)printf ("Unable to read MAC address. Set <ethaddr>\n" ); } -return davinci_emac_initialize (); +return 0 ; }#ifdef CONFIG_SPL_BUILD configs/am3517_evm_defconfig +1
-0@@ -44,6 +44,7 @@ CONFIG_SYS_NAND_BUSWIDTH_16BIT=y CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y CONFIG_SYS_NAND_U_BOOT_OFFS=0x80000 CONFIG_SPL_NAND_SIMPLE=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PINCTRL=yconfigs/da850evm_defconfig +1
-0@@ -59,6 +59,7 @@ CONFIG_SF_DEFAULT_SPEED=30000000 CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SPI_FLASH_MTD=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PINCTRL=yconfigs/da850evm_direct_nor_defconfig +1
-0@@ -50,6 +50,7 @@ CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PINCTRL=yconfigs/da850evm_nand_defconfig +1
-0@@ -59,6 +59,7 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SPI_FLASH_MTD=y +CONFIG_DM_ETH=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y CONFIG_DM_SERIAL=yconfigs/omapl138_lcdk_defconfig +1
-0@@ -49,6 +49,7 @@ CONFIG_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_DM_SERIAL=yconfigs/ti816x_evm_defconfig +1
-0@@ -45,6 +45,7 @@ CONFIG_SYS_I2C_OMAP24XX=y CONFIG_MMC_OMAP_HS=y CONFIG_NAND=y CONFIG_SYS_NAND_BUSWIDTH_16BIT=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_SYS_NS16550=ydrivers/net/ti/davinci_emac.c +42
-35@@ -26,7 +26,6 @@#include <net.h> #include <miiphy.h> #include <malloc.h> -#include <netdev.h> #include <linux/compiler.h> #include <asm/arch/emac_defs.h> #include <asm/io.h> @@ -107,8 +106,9 @@ static u_int8_t num_phy;phy_t phy[CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT ]; -static int davinci_eth_set_mac_addr (struct eth_device *dev) +static int davinci_emac_write_hwaddr (struct udevice *dev) { +struct eth_pdata *pdata =dev_get_platdata (dev);unsigned long mac_hi;unsigned long mac_lo;@@ -118,12 +118,12 @@ static int davinci_eth_set_mac_addr(struct eth_device *dev)* Using channel 0 only - other channels are disabled * */ writel (0 , &adap_emac->MACINDEX); - mac_hi = (dev->enetaddr[3 ] <<24 ) | - (dev->enetaddr[2 ] <<16 ) | - (dev->enetaddr[1 ] <<8 ) | - (dev->enetaddr[0 ]); - mac_lo = (dev->enetaddr[5 ] <<8 ) | - (dev->enetaddr[4 ]); + mac_hi = (pdata->enetaddr[3 ] <<24 ) | + (pdata->enetaddr[2 ] <<16 ) | + (pdata->enetaddr[1 ] <<8 ) | + (pdata->enetaddr[0 ]); + mac_lo = (pdata->enetaddr[5 ] <<8 ) | + (pdata->enetaddr[4 ]);writel (mac_hi, &adap_emac->MACADDRHI);#if defined(DAVINCI_EMAC_VERSION2 )@@ -411,7 +411,7 @@ static void __attribute__((unused)) davinci_eth_gigabit_enable(int phy_addr) }/* Eth device open */ -static int davinci_eth_open (struct eth_device *dev,bd_t *bis) +static int davinci_emac_start (struct udevice *dev) {dv_reg_p addr;u_int32_t clkdiv, cnt, mac_control;@@ -447,7 +447,7 @@ static int davinci_eth_open(struct eth_device *dev, bd_t *bis)writel (1 , &adap_emac->TXCONTROL);writel (1 , &adap_emac->RXCONTROL); -davinci_eth_set_mac_addr (dev); +davinci_emac_write_hwaddr (dev);/* Set DMA 8 TX / 8 RX Head pointers to 0 */ addr = &adap_emac->TX0HDP;@@ -588,7 +588,7 @@ static void davinci_eth_ch_teardown(int ch) }/* Eth device close */ -static void davinci_eth_close (struct eth_device *dev) +static void davinci_emac_stop (struct udevice *dev) {debug_emac ("+ emac_close\n" );@@ -619,8 +619,8 @@ static int tx_send_loop = 0;* This function sends a single packet on the network and returns * positive number (number of bytes transmitted) or negative for error */ -static int davinci_eth_send_packet (struct eth_device *dev, -void *packet,int length) +static int davinci_emac_send (struct udevice *dev, +void *packet,int length) {int ret_status =-1 ;int index;@@ -672,7 +672,7 @@ static int davinci_eth_send_packet (struct eth_device *dev,/* * This function handles receipt of a packet from the network */ -static int davinci_eth_rcv_packet (struct eth_device *dev) +static int davinci_emac_recv (struct udevice *dev,int flags,uchar **packetp) {volatile emac_desc *rx_curr_desc;volatile emac_desc *curr_desc;@@ -682,6 +682,7 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) rx_curr_desc = emac_rx_active_head;if (!rx_curr_desc)return 0 ; + *packetp = rx_curr_desc->buffer; status = rx_curr_desc->pkt_flag_len;if ((status &EMAC_CPPI_OWNERSHIP_BIT ) ==0 ) {if (status &EMAC_CPPI_RX_ERROR_FRAME ) {@@ -693,7 +694,6 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) rx_curr_desc->buff_off_len &0xffff ;invalidate_dcache_range (tmp, tmp +ALIGN (len,PKTALIGN )); -net_process_received_packet (rx_curr_desc->buffer, len); ret = len; }@@ -742,6 +742,7 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) }return (ret); } +return (0 ); }@@ -750,30 +751,12 @@ static int davinci_eth_rcv_packet (struct eth_device *dev)* EMAC modules power or pin multiplexors, that is done by board_init() * much earlier in bootup process. Returns 1 on success, 0 otherwise. */ -int davinci_emac_initialize (void ) +static int davinci_emac_probe (struct udevice *dev) {u_int32_t phy_id;u_int16_t tmp;int i;int ret; -struct eth_device *dev; - - dev =malloc (sizeof *dev); - -if (dev ==NULL ) -return -1 ; - -memset (dev,0 ,sizeof *dev); -strcpy (dev->name,"DaVinci-EMAC" ); - - dev->iobase =0 ; - dev->init = davinci_eth_open; - dev->halt = davinci_eth_close; - dev->send = davinci_eth_send_packet; - dev->recv = davinci_eth_rcv_packet; - dev->write_hwaddr = davinci_eth_set_mac_addr; - -eth_register (dev);davinci_eth_mdio_enable ();@@ -854,5 +837,29 @@ int davinci_emac_initialize(void) phy[i].auto_negotiate(i); }#endif -return (1 ); +return 0 ; } + +static const struct eth_ops davinci_emac_ops = { + .start = davinci_emac_start, + .send = davinci_emac_send, + .recv = davinci_emac_recv, + .stop = davinci_emac_stop, + .write_hwaddr = davinci_emac_write_hwaddr, +}; + +static const struct udevice_id davinci_emac_ids[] = { + { .compatible ="ti,davinci-dm6467-emac" }, + { .compatible ="ti,am3517-emac" , }, + { .compatible ="ti,dm816-emac" , }, + { } +}; + +U_BOOT_DRIVER (davinci_emac) = { + .name ="davinci_emac" , + .id =UCLASS_ETH , + .of_match = davinci_emac_ids, + .probe = davinci_emac_probe, + .ops = &davinci_emac_ops, + .platdata_auto_alloc_size =sizeof (struct eth_pdata ), +};include/netdev.h +0
-2@@ -30,7 +30,6 @@ int bcm_sf2_eth_register(bd_t *bis, u8 dev_num);int bfin_EMAC_initialize (bd_t *bis);int calxedaxgmac_initialize (u32 id,ulong base_addr);int cs8900_initialize (u8 dev_num,int base_addr); -int davinci_emac_initialize (void );int dc21x4x_initialize (bd_t *bis);int designware_initialize (ulong base_addr,u32 interface);int dm9000_initialize (bd_t *bis); --2.21.0
PATCH v2 1/1 net: davinci_emac: convert to using the driver model
In reply to Bartosz GolaszewskiQuoted 423 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Now that we removed all legacy boards selecting
TI_EMACwe can completely convert the driver code to using the driver model. This patch also updates all remaining users ofdavinci_emac.Signed-off-by Bartosz Golaszewski <[email protected]>---
v1 -> v2:
- moved the packetp assignment to the top of therecv()callback which fixes a crash onam3517_evm
- dropped a redundant call tonet_process_received_packet(): this is already called from eth coreThanks goes to Adam Ford for much appreciated testing and help.
Tested on da850-lcdk and da850-evm.
arch/arm/mach-davinci/cpu.c | 13 ----- arch/arm/mach-omap2/omap3/emac.c | 3 +- board/davinci/da8xxevm/da850evm.c | 6 -- board/davinci/da8xxevm/omapl138_lcdk.c | 14 ----- board/logicpd/am3517evm/am3517evm.c | 1 - board/ti/ti816x/evm.c | 3 +- configs/am3517_evm_defconfig | 1 + configs/da850evm_defconfig | 1 + configs/da850evm_direct_nor_defconfig | 1 + configs/da850evm_nand_defconfig | 1 + configs/omapl138_lcdk_defconfig | 1 + configs/ti816x_evm_defconfig | 1 + drivers/net/ti/davinci_emac.c | 77 ++++++++++++++------------ include/netdev.h | 1 - 14 files changed, 50 insertions(+), 74 deletions(-)arch/arm/mach-davinci/cpu.c +0
-13@@ -5,7 +5,6 @@*/ #include <common.h> -#include <netdev.h> #include <asm/arch/hardware.h> #include <asm/io.h> @@ -90,15 +89,3 @@ int set_cpu_clk_info(void) gd->bd->bi_dsp_freq =0 ;return 0 ; } - -/* -* Initializes on-chip ethernet controllers. -* to override, implement board_eth_init() -*/ -int cpu_eth_init (bd_t *bis) -{ -#if defined(CONFIG_DRIVER_TI_EMAC ) -davinci_emac_initialize (); -#endif -return 0 ; -}arch/arm/mach-omap2/omap3/emac.c +1
-2@@ -7,7 +7,6 @@*/ #include <common.h> -#include <netdev.h> #include <asm/io.h> #include <asm/arch/am35x_def.h> @@ -24,5 +23,5 @@ int cpu_eth_init(bd_t *bis) reset &= ~CPGMACSS_SW_RST ;writel (reset, &am35x_scm_general_regs->ip_sw_reset); -return davinci_emac_initialize (); +return 0 ; }board/davinci/da8xxevm/da850evm.c +0
-6@@ -13,7 +13,6 @@#include <environment.h> #include <i2c.h> #include <net.h> -#include <netdev.h> #include <spi.h> #include <spi_flash.h> #include <asm/arch/hardware.h> @@ -472,11 +471,6 @@ int board_eth_init(bd_t *bis)if (rmii_hw_init ())printf ("RMII hardware init failed!!!\n" );#endif -if (!davinci_emac_initialize ()) { -printf ("Error: Ethernet init failed!\n" ); -return -1 ; - } - return 0; }#endif /* CONFIG_DRIVER_TI_EMAC */ board/davinci/da8xxevm/omapl138_lcdk.c +0
-14@@ -11,7 +11,6 @@#include <common.h> #include <i2c.h> #include <net.h> -#include <netdev.h> #include <spi.h> #include <spi_flash.h> #include <asm/arch/hardware.h> @@ -229,19 +228,6 @@ int board_init(void)#ifdef CONFIG_DRIVER_TI_EMAC -/* -* Initializes on-board ethernet controllers. -*/ -int board_eth_init (bd_t *bis) -{ -if (!davinci_emac_initialize ()) { -printf ("Error: Ethernet init failed!\n" ); -return -1 ; - } - -return 0 ; -} -#endif /* CONFIG_DRIVER_TI_EMAC */ #define CFG_MAC_ADDR_SPI_BUS 0board/logicpd/am3517evm/am3517evm.c +0
-1@@ -28,7 +28,6 @@#include <linux/usb/gadget.h> #include <linux/usb/musb.h> #include <i2c.h> -#include <netdev.h> #include "am3517evm.h" DECLARE_GLOBAL_DATA_PTR ;board/ti/ti816x/evm.c +1
-2@@ -9,7 +9,6 @@#include <common.h> #include <environment.h> #include <spl.h> -#include <netdev.h> #include <asm/cache.h> #include <asm/io.h> #include <asm/arch/clock.h> @@ -56,7 +55,7 @@ int board_eth_init(bd_t *bis)printf ("Unable to read MAC address. Set <ethaddr>\n" ); } -return davinci_emac_initialize (); +return 0 ; }#ifdef CONFIG_SPL_BUILD configs/am3517_evm_defconfig +1
-0@@ -44,6 +44,7 @@ CONFIG_SYS_NAND_BUSWIDTH_16BIT=y CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y CONFIG_SYS_NAND_U_BOOT_OFFS=0x80000 CONFIG_SPL_NAND_SIMPLE=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PINCTRL=yconfigs/da850evm_defconfig +1
-0@@ -59,6 +59,7 @@ CONFIG_SF_DEFAULT_SPEED=30000000 CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SPI_FLASH_MTD=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PINCTRL=yconfigs/da850evm_direct_nor_defconfig +1
-0@@ -50,6 +50,7 @@ CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PINCTRL=yconfigs/da850evm_nand_defconfig +1
-0@@ -59,6 +59,7 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SPI_FLASH_MTD=y +CONFIG_DM_ETH=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y CONFIG_DM_SERIAL=yconfigs/omapl138_lcdk_defconfig +1
-0@@ -49,6 +49,7 @@ CONFIG_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_DM_SERIAL=yconfigs/ti816x_evm_defconfig +1
-0@@ -45,6 +45,7 @@ CONFIG_SYS_I2C_OMAP24XX=y CONFIG_MMC_OMAP_HS=y CONFIG_NAND=y CONFIG_SYS_NAND_BUSWIDTH_16BIT=y +CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_SYS_NS16550=ydrivers/net/ti/davinci_emac.c +42
-35@@ -26,7 +26,6 @@#include <net.h> #include <miiphy.h> #include <malloc.h> -#include <netdev.h> #include <linux/compiler.h> #include <asm/arch/emac_defs.h> #include <asm/io.h> @@ -107,8 +106,9 @@ static u_int8_t num_phy;phy_t phy[CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT ]; -static int davinci_eth_set_mac_addr (struct eth_device *dev) +static int davinci_emac_write_hwaddr (struct udevice *dev) { +struct eth_pdata *pdata =dev_get_platdata (dev);unsigned long mac_hi;unsigned long mac_lo;@@ -118,12 +118,12 @@ static int davinci_eth_set_mac_addr(struct eth_device *dev)* Using channel 0 only - other channels are disabled * */ writel (0 , &adap_emac->MACINDEX); - mac_hi = (dev->enetaddr[3 ] <<24 ) | - (dev->enetaddr[2 ] <<16 ) | - (dev->enetaddr[1 ] <<8 ) | - (dev->enetaddr[0 ]); - mac_lo = (dev->enetaddr[5 ] <<8 ) | - (dev->enetaddr[4 ]); + mac_hi = (pdata->enetaddr[3 ] <<24 ) | + (pdata->enetaddr[2 ] <<16 ) | + (pdata->enetaddr[1 ] <<8 ) | + (pdata->enetaddr[0 ]); + mac_lo = (pdata->enetaddr[5 ] <<8 ) | + (pdata->enetaddr[4 ]);writel (mac_hi, &adap_emac->MACADDRHI);#if defined(DAVINCI_EMAC_VERSION2 )@@ -411,7 +411,7 @@ static void __attribute__((unused)) davinci_eth_gigabit_enable(int phy_addr) }/* Eth device open */ -static int davinci_eth_open (struct eth_device *dev,bd_t *bis) +static int davinci_emac_start (struct udevice *dev) {dv_reg_p addr;u_int32_t clkdiv, cnt, mac_control;@@ -447,7 +447,7 @@ static int davinci_eth_open(struct eth_device *dev, bd_t *bis)writel (1 , &adap_emac->TXCONTROL);writel (1 , &adap_emac->RXCONTROL); -davinci_eth_set_mac_addr (dev); +davinci_emac_write_hwaddr (dev);/* Set DMA 8 TX / 8 RX Head pointers to 0 */ addr = &adap_emac->TX0HDP;@@ -588,7 +588,7 @@ static void davinci_eth_ch_teardown(int ch) }/* Eth device close */ -static void davinci_eth_close (struct eth_device *dev) +static void davinci_emac_stop (struct udevice *dev) {debug_emac ("+ emac_close\n" );@@ -619,8 +619,8 @@ static int tx_send_loop = 0;* This function sends a single packet on the network and returns * positive number (number of bytes transmitted) or negative for error */ -static int davinci_eth_send_packet (struct eth_device *dev, -void *packet,int length) +static int davinci_emac_send (struct udevice *dev, +void *packet,int length) {int ret_status =-1 ;int index;@@ -672,7 +672,7 @@ static int davinci_eth_send_packet (struct eth_device *dev,/* * This function handles receipt of a packet from the network */ -static int davinci_eth_rcv_packet (struct eth_device *dev) +static int davinci_emac_recv (struct udevice *dev,int flags,uchar **packetp) {volatile emac_desc *rx_curr_desc;volatile emac_desc *curr_desc;@@ -682,6 +682,7 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) rx_curr_desc = emac_rx_active_head;if (!rx_curr_desc)return 0 ; + *packetp = rx_curr_desc->buffer; status = rx_curr_desc->pkt_flag_len;if ((status &EMAC_CPPI_OWNERSHIP_BIT ) ==0 ) {if (status &EMAC_CPPI_RX_ERROR_FRAME ) {@@ -693,7 +694,6 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) rx_curr_desc->buff_off_len &0xffff ;invalidate_dcache_range (tmp, tmp +ALIGN (len,PKTALIGN )); -net_process_received_packet (rx_curr_desc->buffer, len); ret = len; }@@ -742,6 +742,7 @@ static int davinci_eth_rcv_packet (struct eth_device *dev) }return (ret); } +return (0 ); }@@ -750,30 +751,12 @@ static int davinci_eth_rcv_packet (struct eth_device *dev)* EMAC modules power or pin multiplexors, that is done by board_init() * much earlier in bootup process. Returns 1 on success, 0 otherwise. */ -int davinci_emac_initialize (void ) +static int davinci_emac_probe (struct udevice *dev) {u_int32_t phy_id;u_int16_t tmp;int i;int ret; -struct eth_device *dev; - - dev =malloc (sizeof *dev); - -if (dev ==NULL ) -return -1 ; - -memset (dev,0 ,sizeof *dev); -strcpy (dev->name,"DaVinci-EMAC" ); - - dev->iobase =0 ; - dev->init = davinci_eth_open; - dev->halt = davinci_eth_close; - dev->send = davinci_eth_send_packet; - dev->recv = davinci_eth_rcv_packet; - dev->write_hwaddr = davinci_eth_set_mac_addr; - -eth_register (dev);davinci_eth_mdio_enable ();@@ -854,5 +837,29 @@ int davinci_emac_initialize(void) phy[i].auto_negotiate(i); }#endif -return (1 ); +return 0 ; } + +static const struct eth_ops davinci_emac_ops = { + .start = davinci_emac_start, + .send = davinci_emac_send, + .recv = davinci_emac_recv, + .stop = davinci_emac_stop, + .write_hwaddr = davinci_emac_write_hwaddr, +}; + +static const struct udevice_id davinci_emac_ids[] = { + { .compatible ="ti,davinci-dm6467-emac" }, + { .compatible ="ti,am3517-emac" , }, + { .compatible ="ti,dm816-emac" , }, + { } +}; + +U_BOOT_DRIVER (davinci_emac) = { + .name ="davinci_emac" , + .id =UCLASS_ETH , + .of_match = davinci_emac_ids, + .probe = davinci_emac_probe, + .ops = &davinci_emac_ops, + .platdata_auto_alloc_size =sizeof (struct eth_pdata ), +};include/netdev.h +0
-0
include/netdev.h int bcm_sf2_eth_register(bd_t *bis, u8 dev_num); · line 35
Quoted 7 lines
include/netdev.h +0
-1@@ -30,7 +30,6 @@ int bcm_sf2_eth_register(bd_t *bis, u8 dev_num);int bfin_EMAC_initialize (bd_t *bis);int calxedaxgmac_initialize (u32 id,ulong base_addr);int cs8900_initialize (u8 dev_num,int base_addr); -int davinci_emac_initialize (void );int dc21x4x_initialize (bd_t *bis);int designware_initialize (ulong base_addr,u32 interface);int dm9000_initialize (bd_t *bis);
PATCH v2 1/1 net: davinci_emac: convert to using the driver model
In reply to Bartosz GolaszewskiQuoted 8 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Now that we removed all legacy boards selecting
TI_EMACwe can completely convert the driver code to using the driver model. This patch also updates all remaining users ofdavinci_emac.Signed-off-by Bartosz Golaszewski <[email protected]>
PATCH v2 1/1 net: davinci_emac: convert to using the driver model
In reply to Bartosz GolaszewskiQuoted 15 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Now that we removed all legacy boards selecting
TI_EMACwe can completely convert the driver code to using the driver model. This patch also updates all remaining users ofdavinci_emac.Signed-off-by Bartosz Golaszewski <[email protected]>---
v1 -> v2:
- moved the packetp assignment to the top of therecv()callback which fixes a crash onam3517_evm
- dropped a redundant call tonet_process_received_packet(): this is already called from eth core
Quoted 3 lines
Thanks goes to Adam Ford for much appreciated testing and help.
Tested on da850-lcdk and da850-evm.
Looks like a build failure on this patch...
https://travis-ci.org/jhershbe/u-boot/jobs/562799958
Can you have a look?
Thanks,
-Joe
PATCH v2 1/1 net: davinci_emac: convert to using the driver model
śr., 24 lip 2019 o 01:22 Joe Hershberger <[email protected]> napisał(a):
Quoted 21 lines · Bartosz Golaszewski
Quoted 15 lines
From: Bartosz Golaszewski <[email protected]>
Now that we removed all legacy boards selecting
TI_EMACwe can completely convert the driver code to using the driver model. This patch also updates all remaining users ofdavinci_emac.Signed-off-by Bartosz Golaszewski <[email protected]>---
v1 -> v2:
- moved the packetp assignment to the top of therecv()callback which fixes a crash onam3517_evm
- dropped a redundant call tonet_process_received_packet(): this is already called from eth coreQuoted 3 lines
Thanks goes to Adam Ford for much appreciated testing and help.
Tested on da850-lcdk and da850-evm.
Quoted 8 lines
Looks like a build failure on this patch...
https://travis-ci.org/jhershbe/u-boot/jobs/562799958
Can you have a look?
Thanks,
-Joe
This board was missing CONFIG_DM_ETH=y in my patch. I fixed it and v2 of the integration series is on the way.
Bart