Moving Axi emac to DM
Subsystems (2)
v2 cover Moving Axi emac to DM
Hi,
This patch series depends on microblaze cleanup series. All these patches will be available ingit://git.denx.de/u-boot-microblaze.git
also with patches which I am going to send now.
Thanks,
Michal
Changes in v2:
- Change commit message - Joe
- Remove additional blank line - Joe
- Remove one comment - Joe
- new patch is this series
Michal Simek (11):
net: axi_emac: Fix parentheses around operand !
net: axi_emac: Show phy address instead of register content
net: axi_emac: Pass directly pointer to register space
net: axi_emac: Put iobase to private structure
net: axi_emac: Pass private structure to phyread/phywrite
net: axi_emac: Pass private structure where possible
net: axi_emac: Move driver to DM
net: axi_emac: Enable access to MDIO in probe
net: axi_emac: Split recv from free_pkt
net: axi_emac: Rename start, stop, write_hwaddr functions
net: Add axi emac to Kconfig
.../xilinx/microblaze-generic/microblaze-generic.c | 5 - board/xilinx/zynq/board.c | 4 - drivers/net/Kconfig | 8 + drivers/net/xilinx_axi_emac.c | 280 +++++++++++++-------- include/netdev.h | 2 - 5 files changed, 183 insertions(+), 116 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/11 net: axi_emac: Fix parentheses around operand !
Fix these compilation warning by proper grouping:
In function 'axi_dma_init': drivers/net/xilinx_axi_emac.c:391:7:
warning: suggest parentheses around operand of '!' or change '&' to '&&' or '!' to '~' [-Wparentheses]
if (!(in_be32(&priv->dmatx->control) |
^In function 'axiemac_send': drivers/net/xilinx_axi_emac.c:501:21:
warning: suggest parentheses around operand of '!' or change '&' to '&&' or '!' to '~' [-Wparentheses]
while (timeout && (!in_be32(&priv->dmatx->status) &
---
Changes in v2: None
drivers/net/xilinx_axi_emac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/xilinx_axi_emac.c +4 -4
@@ -388,9 +388,9 @@ static void axi_dma_init(struct eth_device *dev)while (timeout--) {/* Check transmit/receive channel */ /* Reset is done when the reset bit is low */ -if (!(in_be32 (&priv->dmatx->control) | +if (!((in_be32 (&priv->dmatx->control) |in_be32 (&priv->dmarx->control)) - &XAXIDMA_CR_RESET_MASK ) { + &XAXIDMA_CR_RESET_MASK )) {break ; } }
@@ -498,8 +498,8 @@ static int axiemac_send(struct eth_device *dev, void *ptr, int len)/* Wait for transmission to complete */ debug ("axiemac: Waiting for tx to be done\n" ); timeout =200 ; -while (timeout && (!in_be32 (&priv->dmatx->status) & - (XAXIDMA_IRQ_DELAY_MASK |XAXIDMA_IRQ_IOC_MASK ))) { +while (timeout && (!(in_be32 (&priv->dmatx->status) & + (XAXIDMA_IRQ_DELAY_MASK |XAXIDMA_IRQ_IOC_MASK )))) { timeout--;udelay (1 ); }
Signature · 1 line
1.9.1
PATCH v2 2/11 net: axi_emac: Show phy address instead of register content
In reply to Michal SimekFix debug message.
---
Changes in v2: None
drivers/net/xilinx_axi_emac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/xilinx_axi_emac.c +1 -1
@@ -243,7 +243,7 @@ static int setup_phy(struct eth_device *dev)/* Found a valid PHY address */ priv->phyaddr = i;debug ("axiemac: Found valid phy address, %x\n" , - phyreg); + i);break ; } }
Signature · 1 line
1.9.1
PATCH v2 3/11 net: axi_emac: Pass directly pointer to register space
In reply to Michal SimekSimplify mdio_wait function by passing regs directly.
---
Changes in v2: None
drivers/net/xilinx_axi_emac.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/xilinx_axi_emac.c +5 -6
@@ -147,9 +147,8 @@ struct axi_regs {*/ #define PHY_DETECT_MASK 0x1808 -static inline int mdio_wait (struct eth_device *dev) +static inline int mdio_wait (struct axi_regs *regs) { -struct axi_regs *regs = (struct axi_regs *)dev->iobase;u32 timeout =200 ;/* Wait till MDIO interface is ready to accept a new transaction. */
@@ -171,7 +170,7 @@ static u32 phyread(struct eth_device *dev, u32 phyaddress, u32 registernum,struct axi_regs *regs = (struct axi_regs *)dev->iobase;u32 mdioctrlreg =0 ; -if (mdio_wait (dev)) +if (mdio_wait (regs))return 1 ; mdioctrlreg = ((phyaddress << XAE_MDIO_MCR_PHYAD_SHIFT) &
@@ -183,7 +182,7 @@ static u32 phyread(struct eth_device *dev, u32 phyaddress, u32 registernum,out_be32 (®s->mdio_mcr, mdioctrlreg); -if (mdio_wait (dev)) +if (mdio_wait (regs))return 1 ;/* Read data */
@@ -197,7 +196,7 @@ static u32 phywrite(struct eth_device *dev, u32 phyaddress, u32 registernum,struct axi_regs *regs = (struct axi_regs *)dev->iobase;u32 mdioctrlreg =0 ; -if (mdio_wait (dev)) +if (mdio_wait (regs))return 1 ; mdioctrlreg = ((phyaddress << XAE_MDIO_MCR_PHYAD_SHIFT) &
@@ -212,7 +211,7 @@ static u32 phywrite(struct eth_device *dev, u32 phyaddress, u32 registernum,out_be32 (®s->mdio_mcr, mdioctrlreg); -if (mdio_wait (dev)) +if (mdio_wait (regs))return 1 ;return 0 ;
Signature · 1 line
1.9.1
PATCH v2 4/11 net: axi_emac: Put iobase to private structure
In reply to Michal SimekSaving iobase directly to private structure helps with moving to DM. There is an option to load iobase from pdata but it is additional load. Pointer to private structure is available all the time.
---
Changes in v2: None
drivers/net/xilinx_axi_emac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/xilinx_axi_emac.c +3 -2
@@ -86,7 +86,7 @@ struct axidma_priv {struct axidma_reg *dmatx;struct axidma_reg *dmarx;int phyaddr; - +struct axi_regs *iobase;struct phy_device *phydev;struct mii_dev *bus; };
@@ -223,7 +223,7 @@ static int setup_phy(struct eth_device *dev)u16 phyreg;u32 i, speed, emmc_reg, ret;struct axidma_priv *priv = dev->priv; -struct axi_regs *regs = (struct axi_regs *)dev->iobase; +struct axi_regs *regs = priv->iobase;struct phy_device *phydev; u32 supported = SUPPORTED_10baseT_Half |
@@ -629,6 +629,7 @@ int xilinx_axiemac_initialize(bd_t *bis, unsigned long base_addr,sprintf (dev->name,"aximac.%lx" , base_addr); dev->iobase = base_addr; + priv->iobase = (struct axi_regs *)base_addr; priv->dmatx = (struct axidma_reg *)dma_addr;/* RX channel offset is 0x30 */ priv->dmarx = (struct axidma_reg *)(dma_addr +0x30 );
Signature · 1 line
1.9.1
PATCH v2 5/11 net: axi_emac: Pass private structure to phyread/phywrite
In reply to Michal SimekPrepare for move to DM.
---
Changes in v2: None
drivers/net/xilinx_axi_emac.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/xilinx_axi_emac.c +9 -9
@@ -164,10 +164,10 @@ static inline int mdio_wait(struct axi_regs *regs)return 0 ; } -static u32 phyread (struct eth_device *dev,u32 phyaddress,u32 registernum, -u16 *val) +static u32 phyread (struct axidma_priv *priv,u32 phyaddress,u32 registernum, +u16 *val) { -struct axi_regs *regs = (struct axi_regs *)dev->iobase; +struct axi_regs *regs = priv->iobase;u32 mdioctrlreg =0 ;if (mdio_wait (regs))
@@ -190,10 +190,10 @@ static u32 phyread(struct eth_device *dev, u32 phyaddress, u32 registernum,return 0 ; } -static u32 phywrite (struct eth_device *dev,u32 phyaddress,u32 registernum, -u32 data) +static u32 phywrite (struct axidma_priv *priv,u32 phyaddress,u32 registernum, +u32 data) { -struct axi_regs *regs = (struct axi_regs *)dev->iobase; +struct axi_regs *regs = priv->iobase;u32 mdioctrlreg =0 ;if (mdio_wait (regs))
@@ -236,7 +236,7 @@ static int setup_phy(struct eth_device *dev)if (priv->phyaddr ==-1 ) {/* Detect the PHY address */ for (i =31 ; i >=0 ; i--) { - ret =phyread (dev, i,PHY_DETECT_REG , &phyreg); + ret =phyread (priv, i,PHY_DETECT_REG , &phyreg);if (!ret && (phyreg !=0xFFFF ) && ((phyreg &PHY_DETECT_MASK ) ==PHY_DETECT_MASK )) {/* Found a valid PHY address */
@@ -589,7 +589,7 @@ static int axiemac_miiphy_read(const char *devname, uchar addr,struct eth_device *dev =eth_get_dev ();u32 ret; - ret =phyread (dev, addr, reg, val); + ret =phyread (dev->priv, addr, reg, val);debug ("axiemac: Read MII 0x%x, 0x%x, 0x%x\n" , addr, reg, *val);return ret; }
@@ -600,7 +600,7 @@ static int axiemac_miiphy_write(const char *devname, uchar addr,struct eth_device *dev =eth_get_dev ();debug ("axiemac: Write MII 0x%x, 0x%x, 0x%x\n" , addr, reg, val); -return phywrite (dev, addr, reg, val); +return phywrite (dev->priv, addr, reg, val); }static int axiemac_bus_reset (struct mii_dev *bus)
Signature · 1 line
1.9.1
PATCH v2 6/11 net: axi_emac: Pass private structure where possible
In reply to Michal SimekUse axidma_priv instead of ethdevice in preparation of the DM move.
---
Changes in v2:
- Change commit message - Joe
drivers/net/xilinx_axi_emac.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/net/xilinx_axi_emac.c +7 -9
@@ -315,9 +315,9 @@ static void axiemac_halt(struct eth_device *dev)debug ("axiemac: Halted\n" ); } -static int axi_ethernet_init (struct eth_device *dev) +static int axi_ethernet_init (struct axidma_priv *priv) { -struct axi_regs *regs = (struct axi_regs *)dev->iobase; +struct axi_regs *regs = priv->iobase;u32 timeout =200 ;/*
@@ -374,9 +374,8 @@ static int axiemac_setup_mac(struct eth_device *dev) }/* Reset DMA engine */ -static void axi_dma_init (struct eth_device *dev) +static void axi_dma_init (struct axidma_priv *priv) { -struct axidma_priv *priv = dev->priv;u32 timeout =500 ;/* Reset the engine so the hardware starts from a known state */
@@ -410,10 +409,10 @@ static int axiemac_init(struct eth_device *dev, bd_t * bis)* reset, and since AXIDMA reset line is connected to AxiEthernet, this * would ensure a reset of AxiEthernet. */ -axi_dma_init (dev); +axi_dma_init (priv);/* Initialize AxiEthernet hardware. */ -if (axi_ethernet_init (dev)) +if (axi_ethernet_init (priv))return -1 ;/* Disable all RX interrupts before RxBD space setup */
@@ -511,10 +510,9 @@ static int axiemac_send(struct eth_device *dev, void *ptr, int len)return 0 ; } -static int isrxready (struct eth_device *dev) +static int isrxready (struct axidma_priv *priv) {u32 status; -struct axidma_priv *priv = dev->priv;/* Read pending interrupts */ status =in_be32 (&priv->dmarx->status);
@@ -539,7 +537,7 @@ static int axiemac_recv(struct eth_device *dev)u32 temp;/* Wait for an incoming packet */ -if (!isrxready (dev)) +if (!isrxready (priv))return 0 ;debug ("axiemac: RX data ready\n" );
Signature · 1 line
1.9.1
PATCH v2 7/11 net: axi_emac: Move driver to DM
In reply to Michal SimekMove driver to DM.
---
Changes in v2: None
.../xilinx/microblaze-generic/microblaze-generic.c | 5 - board/xilinx/zynq/board.c | 4 - drivers/net/xilinx_axi_emac.c | 190 +++++++++++++-------- include/netdev.h | 2 - 4 files changed, 122 insertions(+), 79 deletions(-)
board/xilinx/microblaze-generic/microblaze-generic.c +0 -5
@@ -105,11 +105,6 @@ int board_eth_init(bd_t *bis) {int ret =0 ; -#ifdef CONFIG_XILINX_AXIEMAC - ret |=xilinx_axiemac_initialize (bis,XILINX_AXIEMAC_BASEADDR , -XILINX_AXIDMA_BASEADDR ); -#endif -#if defined(CONFIG_XILINX_EMACLITE ) && defined(XILINX_EMACLITE_BASEADDR )u32 txpp =0 ;u32 rxpp =0 ;
board/xilinx/zynq/board.c +0 -4
@@ -103,10 +103,6 @@ int board_eth_init(bd_t *bis) {u32 ret =0 ; -#ifdef CONFIG_XILINX_AXIEMAC - ret |=xilinx_axiemac_initialize (bis,XILINX_AXIEMAC_BASEADDR , -XILINX_AXIDMA_BASEADDR ); -#endif #ifdef CONFIG_XILINX_EMACLITE u32 txpp =0 ;u32 rxpp =0 ;
drivers/net/xilinx_axi_emac.c +122 -68
287 lines not on this page · raw message
include/netdev.h +0 -2
@@ -80,8 +80,6 @@ int tsi108_eth_initialize(bd_t *bis);int uec_standard_init (bd_t *bis);int uli526x_initialize (bd_t *bis);int armada100_fec_register (unsigned long base_addr); -int xilinx_axiemac_initialize (bd_t *bis,unsigned long base_addr, -unsigned long dma_addr);int xilinx_emaclite_of_init (const void *blob);int xilinx_emaclite_initialize (bd_t *bis,unsigned long base_addr,int txpp,int rxpp);
Signature · 1 line
1.9.1
PATCH v2 8/11 net: axi_emac: Enable access to MDIO in probe
In reply to Michal SimekDetect phy when driver probes.
---
Changes in v2:
- Remove additional blank line - Joe
- Remove one comment - Joe
drivers/net/xilinx_axi_emac.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/net/xilinx_axi_emac.c +19 -3
@@ -221,11 +221,10 @@ static u32 phywrite(struct axidma_priv *priv, u32 phyaddress, u32 registernum,return 0 ; } -/* Setting axi emac and phy to proper setting */ -static int setup_phy (struct udevice *dev) +static int axiemac_phy_init (struct udevice *dev) {u16 phyreg; -u32 i, speed, emmc_reg, ret; +u32 i, ret;struct axidma_priv *priv =dev_get_priv (dev);struct axi_regs *regs = priv->iobase;struct phy_device *phydev;
@@ -237,6 +236,9 @@ static int setup_phy(struct udevice *dev) SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full; +/* Set default MDIO divisor */ +out_be32 (®s->mdio_mc,XAE_MDIO_DIV_DFT |XAE_MDIO_MC_MDIOEN_MASK ); +if (priv->phyaddr ==-1 ) {/* Detect the PHY address */ for (i =31 ; i >=0 ; i--) {
@@ -259,6 +261,18 @@ static int setup_phy(struct udevice *dev) phydev->advertising = phydev->supported; priv->phydev = phydev;phy_config (phydev); + +return 0 ; +} + +/* Setting axi emac and phy to proper setting */ +static int setup_phy (struct udevice *dev) +{ +u32 speed, emmc_reg; +struct axidma_priv *priv =dev_get_priv (dev); +struct axi_regs *regs = priv->iobase; +struct phy_device *phydev = priv->phydev; +if (phy_startup (phydev)) {printf ("axiemac: could not initialize PHY %s\n" , phydev->dev->name);
@@ -621,6 +635,8 @@ static int axi_emac_probe(struct udevice *dev)if (ret)return ret; +axiemac_phy_init (dev); +return 0 ; }
Signature · 1 line
1.9.1
PATCH v2 9/11 net: axi_emac: Split recv from free_pkt
In reply to Michal SimekCall net_process_received_packet() by core.
---
Changes in v2: None
drivers/net/xilinx_axi_emac.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/xilinx_axi_emac.c +9 -3
@@ -571,9 +571,14 @@ static int axiemac_recv(struct udevice *dev, int flags, uchar **packetp)#ifdef DEBUG print_buffer (&rxframe, &rxframe[0 ],1 , length,16 );#endif -/* Pass the received frame up for processing */ -if (length) -net_process_received_packet (rxframe, length); + + *packetp = rxframe; +return length; +} + +static int axiemac_free_pkt (struct udevice *dev,uchar *packet,int length) +{ +struct axidma_priv *priv =dev_get_priv (dev);#ifdef DEBUG /* It is useful to clear buffer to be sure that it is consistent */
@@ -655,6 +660,7 @@ static const struct eth_ops axi_emac_ops = { .start = axiemac_init, .send = axiemac_send, .recv = axiemac_recv, + .free_pkt = axiemac_free_pkt, .stop = axiemac_halt, .write_hwaddr = axiemac_setup_mac, };
Signature · 1 line
1.9.1
PATCH v2 10/11 net: axi_emac: Rename start, stop, write_hwaddr functions
In reply to Michal SimekRename few functions to fit to the new name convention used by DM.
---
Changes in v2:
- new patch is this series
drivers/net/xilinx_axi_emac.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/xilinx_axi_emac.c +7 -7
@@ -316,7 +316,7 @@ static int setup_phy(struct udevice *dev) }/* STOP DMA transfers */ -static void axiemac_halt (struct udevice *dev) +static void axiemac_stop (struct udevice *dev) {struct axidma_priv *priv =dev_get_priv (dev);u32 temp;
@@ -376,7 +376,7 @@ static int axi_ethernet_init(struct axidma_priv *priv)return 0 ; } -static int axiemac_setup_mac (struct udevice *dev) +static int axiemac_write_hwaddr (struct udevice *dev) {struct eth_pdata *pdata =dev_get_platdata (dev);struct axidma_priv *priv =dev_get_priv (dev);
@@ -416,7 +416,7 @@ static void axi_dma_init(struct axidma_priv *priv)printf ("%s: Timeout\n" , __func__); } -static int axiemac_init (struct udevice *dev) +static int axiemac_start (struct udevice *dev) {struct axidma_priv *priv =dev_get_priv (dev);struct axi_regs *regs = priv->iobase;
@@ -470,7 +470,7 @@ static int axiemac_init(struct udevice *dev)/* PHY setup */ if (!setup_phy (dev)) { -axiemac_halt (dev); +axiemac_stop (dev);return -1 ; }
@@ -657,12 +657,12 @@ static int axi_emac_remove(struct udevice *dev) }static const struct eth_ops axi_emac_ops = { - .start = axiemac_init, + .start = axiemac_start, .send = axiemac_send, .recv = axiemac_recv, .free_pkt = axiemac_free_pkt, - .stop = axiemac_halt, - .write_hwaddr = axiemac_setup_mac, + .stop = axiemac_stop, + .write_hwaddr = axiemac_write_hwaddr, };static int axi_emac_ofdata_to_platdata (struct udevice *dev)
Signature · 1 line
1.9.1
PATCH v2 11/11 net: Add axi emac to Kconfig
In reply to Michal SimekAlso add dependency on PHYLIB and MII which is required. Clean PHYLIB dependency from the driver too.
---
Changes in v2: None
drivers/net/Kconfig | 8 ++++++++ drivers/net/xilinx_axi_emac.c | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/net/Kconfig +8 -0
@@ -101,6 +101,14 @@ config PCH_GBE This MAC is present in Intel Platform Controller Hub EG20T. It supports 10/100/1000 Mbps operation. +config XILINX_AXIEMAC + depends on DM_ETH && (MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP) + select PHYLIB + select MII + bool "Xilinx AXI Ethernet" + help + This MAC is present in Xilinx Microblaze, Zynq and ZynqMP SoCs. + config ZYNQ_GEM depends on DM_ETH && (ARCH_ZYNQ || ARCH_ZYNQMP) select PHYLIB
drivers/net/xilinx_axi_emac.c +0 -4
@@ -17,10 +17,6 @@DECLARE_GLOBAL_DATA_PTR ; -#if !defined(CONFIG_PHYLIB ) -# error AXI_ETHERNET requires PHYLIB -#endif -/* Link setup */ #define XAE_EMMC_LINKSPEED_MASK 0xC0000000/* Link speed */ #define XAE_EMMC_LINKSPD_10 0x00000000/* Link Speed mask for 10 Mbit */
Signature · 1 line
1.9.1