net/fsl: introduce Freescale 10G MDIO driver
Subsystems (2)
PATCH 1/1 net/fsl: introduce Freescale 10G MDIO driver
Similar to fsl_pq_mdio.c, this driver is for the 10G MDIO controller on Freescale Frame Manager Ethernet controllers.
--- drivers/net/ethernet/freescale/Kconfig | 7 + drivers/net/ethernet/freescale/Makefile | 1 + drivers/net/ethernet/freescale/xgmac_mdio.c | 257 +++++++++++++++++++++++++++ 3 files changed, 265 insertions(+), 0 deletions(-) create mode 100644 drivers/net/ethernet/freescale/xgmac_mdio.c
drivers/net/ethernet/freescale/Kconfig +7 -0
@@ -62,6 +62,13 @@ config FSL_PQ_MDIO ---help--- This driver supports the MDIO bus used by the gianfar and UCC drivers. +config FSL_XGMAC_MDIO + tristate "Freescale XGMAC MDIO" + depends on FSL_SOC + select PHYLIB + ---help--- + This driver supports the MDIO bus on the Fman 10G Ethernet MACs. + config UCC_GETH tristate "Freescale QE Gigabit Ethernet" depends on QUICC_ENGINE
drivers/net/ethernet/freescale/Makefile +1 -0
@@ -9,6 +9,7 @@ ifeq ($(CONFIG_FEC_MPC52xx_MDIO),y) endif obj-$(CONFIG_FS_ENET) += fs_enet/ obj-$(CONFIG_FSL_PQ_MDIO) += fsl_pq_mdio.o +obj-$(CONFIG_FSL_XGMAC_MDIO) += xgmac_mdio.o obj-$(CONFIG_GIANFAR) += gianfar_driver.o obj-$(CONFIG_PTP_1588_CLOCK_GIANFAR) += gianfar_ptp.o gianfar_driver-objs := gianfar.o \
drivers/net/ethernet/freescale/xgmac_mdio.c new file +257 -0
257 lines not on this page · raw message
Signature · 1 line
1.7.3.4
Timur Tabi <[email protected]> :
Quoted 5 lines
Similar to
fsl_pq_mdio.c, this driver is for the 10G MDIO controller on Freescale Frame Manager Ethernet controllers.Signed-off-by Timur Tabi <[email protected]>---
[...]
Quoted 5 lines
drivers/net/ethernet/freescale/xgmac_mdio.c new file +0
-0
[...]
Quoted 6 lines
drivers/net/ethernet/freescale/xgmac_mdio.c new file +6
-0+static int xgmac_mdio_write (struct mii_bus *bus,int phy_id,int regnum,u16 value) +{ +struct tgec_mdio_controller __iomem *regs = bus->priv; +uint16_t dev_addr = regnum >>16 ; +uint32_t status; +
drivers/net/ethernet/freescale/xgmac_mdio.c line 67
Quoted 10 lines
drivers/net/ethernet/freescale/xgmac_mdio.c new file +10
-0+/* Setup the MII Mgmt clock speed */ +out_be32 (®s->mdio_stat,MDIO_STAT_CLKDIV (100 )); + +/* Wait till the bus is free */ + status =spin_event_timeout ( + !((in_be32 (®s->mdio_stat)) &MDIO_STAT_BSY ),TIMEOUT ,0 ); +if (!status) { +dev_dbg (&bus->dev,"%s: timeout waiting for stat\n" , __func__); +return -ETIMEDOUT ; + }
This code - comment included - is repeated several times. You may consider factoring it out in some xgmac_mdio_free_bus_wait function.
Signature · 1 line
Ueimor
Quoted 9 lines · Francois Romieu
Quoted 7 lines
drivers/net/ethernet/freescale/xgmac_mdio.c line 67
Quoted 7 lines
drivers/net/ethernet/freescale/xgmac_mdio.c new file +7
-0+/* Wait till the bus is free */ + status =spin_event_timeout ( + !((in_be32 (®s->mdio_stat)) &MDIO_STAT_BSY ),TIMEOUT ,0 ); +if (!status) { +dev_dbg (&bus->dev,"%s: timeout waiting for stat\n" , __func__); +return -ETIMEDOUT ; + }This code - comment included - is repeated several times. You may consider factoring it out in some
xgmac_mdio_free_bus_waitfunction.
But it's just one line and a test. The function would look like this:
bool xgmac_mdio_free_bus_wait(struct tgec_mdio_controller __iomem *regs)
{
uint32_t status;
status = spin_event_timeout(
!((in_be32(®s->mdio_stat)) & MDIO_STAT_BSY), TIMEOUT, 0);
return status != 0;
}and then
if (!xgmac_mdio_free_bus_wait(regs)) {
dev_dbg(&bus->dev, "%s: timeout waiting for stat\n", __func__);
return -ETIMEDOUT;
}I don't see any real savings here.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Tabi Timur-B04825 <[email protected]> :
[...]
Quoted 1 line
I don't see any real savings here.
xgmac_mdio_free_bus_wait could return -ETIMEDOUT and include the debug message.
Signature · 1 line
Ueimor
Quoted 6 lines · Francois Romieu
Tabi Timur-B04825 <[email protected]> :
[...]Quoted 1 line
I don't see any real savings here.
xgmac_mdio_free_bus_waitcould return-ETIMEDOUTand include the debug message.
Ok.
Quoted 4 lines
Signature · 2 lines
-- Ueimor