DM_MDIO for fsl_tsec driver
Subsystems (2)
cover DM_MDIO for fsl_tsec driver
From: Vladimir Oltean <[email protected]>
This series converts the MDIO handling portion of the DM_ETH variant of the tsec driver (currently in use only on LS1021A-TSN and LS1021A-TWR) to use DM_MDIO. The other (non-DM_ETH) users of tsec are left alone.
Posted as RFC since it depends on Zhiqiang's series
"[PATCHv2,0/3] net: tsec: Fix issues of DM driver":
https://patchwork.ozlabs.org/project/uboot/cover/20200503144843.36949-1-Zhiqiang.Hou at nxp.com/
Vladimir Oltean (3):
phy: make phy_connect_fixed work with a null mdio bus
configs: enable DM_MDIO for LS1021A-TWR and LS1021A-TSN
net: tsec: convert fsl_pq_mdio to DM_MDIO
configs/ls1021atsn_qspi_defconfig | 1 + configs/ls1021atsn_sdcard_defconfig | 1 + configs/ls1021atwr_nor_SECURE_BOOT_defconfig | 1 + configs/ls1021atwr_nor_defconfig | 1 + configs/ls1021atwr_nor_lpuart_defconfig | 1 + configs/ls1021atwr_qspi_defconfig | 1 + ...s1021atwr_sdcard_ifc_SECURE_BOOT_defconfig | 1 + configs/ls1021atwr_sdcard_ifc_defconfig | 1 + configs/ls1021atwr_sdcard_qspi_defconfig | 1 + drivers/net/fsl_mdio.c | 66 +++++++++++++++++-- drivers/net/phy/phy.c | 4 +- drivers/net/tsec.c | 50 +++++--------- include/fsl_mdio.h | 4 +- 13 files changed, 89 insertions(+), 44 deletions(-)
Signature · 1 line
2.17.1
RFC PATCH 1/3 phy: make phy_connect_fixed work with a null mdio bus
From: Vladimir Oltean <[email protected]>
It is utterly pointless to require an MDIO bus pointer for a fixed PHY device. The fixed.c implementation does not require it, only phy_device_create. Fix that.
--- drivers/net/phy/phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/phy.c +2 -2
@@ -651,7 +651,7 @@ static struct phy_device *phy_device_create(struct mii_dev *bus, int addr, dev =malloc (sizeof (*dev));if (!dev) {printf ("Failed to allocate PHY device for %s:%d\n" , - bus->name, addr); + bus ? bus->name :"(null bus)" , addr);return NULL ; }
@@ -679,7 +679,7 @@ static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,return NULL ; } -if (addr >=0 && addr <PHY_MAX_ADDR ) +if (addr >=0 && addr <PHY_MAX_ADDR && phy_id !=PHY_FIXED_ID ) bus->phymap[addr] = dev;return dev;
Signature · 1 line
2.17.1
RFC PATCH 1/3 phy: make phy_connect_fixed work with a null mdio bus
Quoted 47 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: 2020?5?4? 2:52
To: u-boot at lists.denx.de; joe.hershberger at ni.com; Priyanka Jain <[email protected]>
Cc: Z.q. Hou <[email protected]>; bmeng.cn at gmail.com; Claudiu Manoil <[email protected]>; Alexandru Marginean <[email protected]>
Subject: [RFC PATCH 1/3] phy: makephy_connect_fixedwork with a null mdio busFrom: Vladimir Oltean <[email protected]>
It is utterly pointless to require an MDIO bus pointer for a fixed PHY device. The
fixed.cimplementation does not require it, onlyphy_device_create. Fix that.Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/phy/phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/phy/phy.c index renamed from drivers/net/phy/phy.c +0
-0
9a66e62e8974..dcef1aaf2026100644drivers/net/phy/phy.c +2
-2@@ -651,7 +651,7 @@ static struct phy_device *phy_device_create(struct mii_dev *bus, int addr, dev =malloc (sizeof (*dev));if (!dev) {printf ("Failed to allocate PHY device for %s:%d\n" , - bus->name, addr); + bus ? bus->name :"(null bus)" , addr);return NULL ; }@@ -679,7 +679,7 @@ static struct phy_device *phy_device_create(struct mii_dev *bus, int addr, return NULL; } -if (addr >=0 && addr <PHY_MAX_ADDR ) +if (addr >=0 && addr <PHY_MAX_ADDR && phy_id !=PHY_FIXED_ID ) bus->phymap[addr] = dev;
Quoted 3 lines
return dev;
--
2.17.1
RFC PATCH 2/3 configs: enable DM_MDIO for LS1021A-TWR and LS1021A-TSN
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The tsec driver now requires DM_MDIO when DM_ETH is enabled. To avoid build errors, enable DM_MDIO in these boards' configs before we actually add DM_MDIO support to tsec.
--- configs/ls1021atsn_qspi_defconfig | 1 + configs/ls1021atsn_sdcard_defconfig | 1 + configs/ls1021atwr_nor_SECURE_BOOT_defconfig | 1 + configs/ls1021atwr_nor_defconfig | 1 + configs/ls1021atwr_nor_lpuart_defconfig | 1 + configs/ls1021atwr_qspi_defconfig | 1 + configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig | 1 + configs/ls1021atwr_sdcard_ifc_defconfig | 1 + configs/ls1021atwr_sdcard_qspi_defconfig | 1 + 9 files changed, 9 insertions(+)
configs/ls1021atsn_qspi_defconfig +1 -0
@@ -38,6 +38,7 @@ CONFIG_PHY_ATHEROS=y CONFIG_PHY_BROADCOM=y CONFIG_PHY_FIXED=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_MII=y CONFIG_TSEC_ENET=y
configs/ls1021atsn_sdcard_defconfig +1 -0
@@ -50,6 +50,7 @@ CONFIG_PHY_ATHEROS=y CONFIG_PHY_BROADCOM=y CONFIG_PHY_FIXED=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_MII=y CONFIG_TSEC_ENET=y
configs/ls1021atwr_nor_SECURE_BOOT_defconfig +1 -0
@@ -39,6 +39,7 @@ CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y CONFIG_SYS_FLASH_CFI=y CONFIG_PHY_ATHEROS=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_MII=y
configs/ls1021atwr_nor_defconfig +1 -0
@@ -39,6 +39,7 @@ CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y CONFIG_SYS_FLASH_CFI=y CONFIG_PHY_ATHEROS=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_MII=y
configs/ls1021atwr_nor_lpuart_defconfig +1 -0
@@ -41,6 +41,7 @@ CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y CONFIG_SYS_FLASH_CFI=y CONFIG_PHY_ATHEROS=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_MII=y
configs/ls1021atwr_qspi_defconfig +1 -0
@@ -41,6 +41,7 @@ CONFIG_SPI_FLASH_ATMEL=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_PHY_ATHEROS=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_MII=y
configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig +1 -0
@@ -53,6 +53,7 @@ CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y CONFIG_SYS_FLASH_CFI=y CONFIG_PHY_ATHEROS=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_MII=y
configs/ls1021atwr_sdcard_ifc_defconfig +1 -0
@@ -54,6 +54,7 @@ CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y CONFIG_SYS_FLASH_CFI=y CONFIG_PHY_ATHEROS=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_MII=y
configs/ls1021atwr_sdcard_qspi_defconfig +1 -0
@@ -53,6 +53,7 @@ CONFIG_SPI_FLASH_ATMEL=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_PHY_ATHEROS=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_MII=y
Signature · 1 line
2.17.1
RFC PATCH 3/3 net: tsec: convert fsl_pq_mdio to DM_MDIO
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
For the platforms on which the eTSEC driver uses DM_ETH, convert its MDIO controller code to also use DM_MDIO.
Note that for handling the TBI PHY (the MAC PCS for SGMII), we still don't register a udevice for it, since we can drive it locally and there is no point in doing otherwise.
--- drivers/net/fsl_mdio.c | 66 ++++++++++++++++++++++++++++++++++++++---- drivers/net/tsec.c | 50 ++++++++++---------------------- include/fsl_mdio.h | 4 +-- 3 files changed, 78 insertions(+), 42 deletions(-)
drivers/net/fsl_mdio.c +61 -5
@@ -8,9 +8,11 @@#include <common.h> #include <miiphy.h> #include <phy.h> +#include <miiphy.h> #include <fsl_mdio.h> #include <asm/io.h> #include <linux/errno.h> +#include <tsec.h> void tsec_local_mdio_write (struct tsec_mii_mng __iomem *phyregs,int port_addr,int dev_addr,int regnum,int value)
@@ -56,11 +58,8 @@ int tsec_local_mdio_read(struct tsec_mii_mng __iomem *phyregs, int port_addr,return value; } -static int fsl_pq_mdio_reset (struct mii_dev *bus) +int fsl_pq_mdio_reset (struct tsec_mii_mng __iomem *regs) { -struct tsec_mii_mng __iomem *regs = - (struct tsec_mii_mng __iomem *)bus->priv; -/* Reset MII (due to new addresses) */ out_be32 (®s->miimcfg,MIIMCFG_RESET_MGMT );
@@ -72,6 +71,7 @@ static int fsl_pq_mdio_reset(struct mii_dev *bus)return 0 ; } +#ifndef CONFIG_DM_MDIO int tsec_phy_read (struct mii_dev *bus,int addr,int dev_addr,int regnum) { struct tsec_mii_mng __iomem *phyregs =
@@ -91,6 +91,11 @@ int tsec_phy_write(struct mii_dev *bus, int addr, int dev_addr, int regnum,return 0 ; } +static int tsec_mdio_reset (struct mii_dev *bus) +{ +return fsl_pq_mdio_reset (bus->priv); +} +int fsl_pq_mdio_init (bd_t *bis,struct fsl_pq_mdio_info *info) {struct mii_dev *bus =mdio_alloc ();
@@ -102,10 +107,61 @@ int fsl_pq_mdio_init(bd_t *bis, struct fsl_pq_mdio_info *info) bus->read = tsec_phy_read; bus->write = tsec_phy_write; - bus->reset = fsl_pq_mdio_reset; + bus->reset = tsec_mdio_reset;strcpy (bus->name, info->name); bus->priv = (void *)info->regs;return mdio_register (bus); } +#endif + +#ifdef CONFIG_DM_MDIO +static int dm_fsl_pq_mdio_read (struct udevice *dev,int addr,int devad, +int reg) +{ +struct fsl_pq_mdio_info *info =dev_get_priv (dev); + +return tsec_local_mdio_read (info->regs, addr, devad, reg); +} + +static int dm_fsl_pq_mdio_write (struct udevice *dev,int addr,int devad, +int reg,u16 val) +{ +struct fsl_pq_mdio_info *info =dev_get_priv (dev); + +tsec_local_mdio_write (info->regs, addr, devad, reg, val); + +return 0 ; +} + +static int fsl_pq_mdio_probe (struct udevice *dev) +{ +struct fsl_pq_mdio_info *info =dev_get_priv (dev); +fdt_addr_t reg; + + reg =devfdt_get_addr (dev); + info->regs =map_physmem (reg +TSEC_MDIO_REGS_OFFSET ,0 ,MAP_NOCACHE ); + +return fsl_pq_mdio_reset (info->regs); +} + +static const struct mdio_ops fsl_pq_mdio_ops = { + .read = dm_fsl_pq_mdio_read, + .write = dm_fsl_pq_mdio_write, +}; + +static const struct udevice_id fsl_pq_mdio_ids[] = { + { .compatible ="fsl,etsec2-mdio" }, + { } +}; + +U_BOOT_DRIVER (fsl_pq_mdio) = { + .name ="fsl_pq_mdio" , + .id =UCLASS_MDIO , + .of_match = fsl_pq_mdio_ids, + .probe = fsl_pq_mdio_probe, + .ops = &fsl_pq_mdio_ops, + .priv_auto_alloc_size =sizeof (struct fsl_pq_mdio_info ), +}; +#endif
drivers/net/tsec.c +16 -34
89 lines not on this page · raw message
include/fsl_mdio.h +1 -3
@@ -46,9 +46,7 @@ void tsec_local_mdio_write(struct tsec_mii_mng __iomem *phyregs, int port_addr, int dev_addr, int reg, int value);int tsec_local_mdio_read (struct tsec_mii_mng __iomem *phyregs,int port_addr,int dev_addr,int regnum); -int tsec_phy_read (struct mii_dev *bus,int addr,int dev_addr,int regnum); -int tsec_phy_write (struct mii_dev *bus,int addr,int dev_addr,int regnum, -u16 value); +int fsl_pq_mdio_reset (struct tsec_mii_mng __iomem *regs);int memac_mdio_write (struct mii_dev *bus,int port_addr,int dev_addr,int regnum,u16 value); int memac_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr,
Signature · 1 line
2.17.1
RFC PATCH 3/3 net: tsec: convert fsl_pq_mdio to DM_MDIO
Quoted 153 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: 2020?5?4? 2:52
To: u-boot at lists.denx.de; joe.hershberger at ni.com; Priyanka Jain <[email protected]>
Cc: Z.q. Hou <[email protected]>; bmeng.cn at gmail.com; Claudiu Manoil <[email protected]>; Alexandru Marginean <[email protected]>
Subject: [RFC PATCH 3/3] net: tsec: convertfsl_pq_mdiotoDM_MDIOFrom: Vladimir Oltean <[email protected]>
For the platforms on which the eTSEC driver uses
DM_ETH, convert its MDIO controller code to also useDM_MDIO.Note that for handling the TBI PHY (the MAC PCS for SGMII), we still don't register a udevice for it, since we can drive it locally and there is no point in doing otherwise.
Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/fsl_mdio.c | 66 ++++++++++++++++++++++++++++++++++++++---- drivers/net/tsec.c | 50 ++++++++++---------------------- include/fsl_mdio.h | 4 +-- 3 files changed, 78 insertions(+), 42 deletions(-)drivers/net/fsl_mdio.c index renamed from drivers/net/fsl_mdio.c +0
-0
894b52ee66f4..284508062c8e100644drivers/net/fsl_mdio.c +2
-0@@ -8,9 +8,11 @@#include <common.h> #include <miiphy.h> #include <phy.h> +#include <miiphy.h> #include <fsl_mdio.h> #include <asm/io.h> #include <linux/errno.h> +#include <tsec.h> void tsec_local_mdio_write(struct tsec_mii_mng __iomem *phyregs, int port_addr,drivers/net/fsl_mdio.c +2
-4int dev_addr, int regnum, int value)@@ -56,11 +58,8 @@ int tsec_local_mdio_read(struct tsec_mii_mng __iomem *phyregs, int port_addr, return value; } -static int fsl_pq_mdio_reset (struct mii_dev *bus) +int fsl_pq_mdio_reset (struct tsec_mii_mng __iomem *regs) { -struct tsec_mii_mng __iomem *regs = - (struct tsec_mii_mng __iomem *)bus->priv; -/* Reset MII (due to new addresses) */ out_be32 (®s->miimcfg,MIIMCFG_RESET_MGMT );@@ -72,6 +71,7 @@ static int fsl_pq_mdio_reset(struct mii_dev *bus)return 0 ; } +#ifndef CONFIG_DM_MDIO int tsec_phy_read (struct mii_dev *bus,int addr,int dev_addr,int regnum) { struct tsec_mii_mng __iomem *phyregs = @@ -91,6 +91,11 @@ int tsec_phy_write(struct mii_dev *bus, int addr, int dev_addr, int regnum,drivers/net/fsl_mdio.c +31
-1return 0 ; } +static int tsec_mdio_reset (struct mii_dev *bus) { +return fsl_pq_mdio_reset (bus->priv); +} +int fsl_pq_mdio_init (bd_t *bis,struct fsl_pq_mdio_info *info) {struct mii_dev *bus =mdio_alloc ();@@ -102,10 +107,61 @@ int fsl_pq_mdio_init(bd_t *bis, struct fsl_pq_mdio_info *info) bus->read = tsec_phy_read; bus->write = tsec_phy_write; - bus->reset = fsl_pq_mdio_reset; + bus->reset = tsec_mdio_reset;strcpy (bus->name, info->name); bus->priv = (void *)info->regs;return mdio_register (bus); } +#endif + +#ifdef CONFIG_DM_MDIO +static int dm_fsl_pq_mdio_read (struct udevice *dev,int addr,int devad, +int reg) +{ +struct fsl_pq_mdio_info *info =dev_get_priv (dev); + +return tsec_local_mdio_read (info->regs, addr, devad, reg); } + +static int dm_fsl_pq_mdio_write (struct udevice *dev,int addr,int devad, +int reg,u16 val) +{ +struct fsl_pq_mdio_info *info =dev_get_priv (dev); + +tsec_local_mdio_write (info->regs, addr, devad, reg, val); + +return 0 ; +} + +static int fsl_pq_mdio_probe (struct udevice *dev) { +struct fsl_pq_mdio_info *info =dev_get_priv (dev); +fdt_addr_t reg; + + reg =devfdt_get_addr (dev); + info->regs = map_physmem(reg + TSEC_MDIO_REGS_OFFSET, 0,
MAP_NOCACHE);drivers/net/fsl_mdio.c +23
-0+ + return fsl_pq_mdio_reset(info->regs); +} + +static const struct mdio_ops fsl_pq_mdio_ops = { + .read = dm_fsl_pq_mdio_read, + .write = dm_fsl_pq_mdio_write, +}; + +static const struct udevice_id fsl_pq_mdio_ids[] = { + { .compatible ="fsl,etsec2-mdio" }, + { } +}; + +U_BOOT_DRIVER (fsl_pq_mdio) = { + .name ="fsl_pq_mdio" , + .id =UCLASS_MDIO , + .of_match = fsl_pq_mdio_ids, + .probe = fsl_pq_mdio_probe, + .ops = &fsl_pq_mdio_ops, + .priv_auto_alloc_size =sizeof (struct fsl_pq_mdio_info ), +}; +#endif drivers/net/tsec.c index renamed from drivers/net/tsec.c +0
-0
842cddf2297a..93f151a8a6db100644drivers/net/tsec.c +1
-0@@ -15,6 +15,7 @@#include <command.h> #include <tsec.h> #include <fsl_mdio.h> +#include <miiphy.h> #include <linux/errno.h> #include <asm/processor.h> #include <asm/io.h>
drivers/net/tsec.c static int init_phy(struct tsec_private *priv) · line 685
Quoted 6 lines
drivers/net/tsec.c +3
-0@@ -679,8 +680,15 @@ static int init_phy(struct tsec_private *priv)if (priv->interface ==PHY_INTERFACE_MODE_SGMII )tsec_configure_serdes (priv); +#ifdef CONFIG_DM_ETH +if (ofnode_valid (ofnode_find_subnode (priv->dev->node,"fixed-link" ))) + phydev =phy_connect (NULL ,0 , priv->dev, priv->interface);
Thanks for adding the "fixed PHY" support, I have a non-DM_MDIO version to supporting this, while this patch is better, I will drop mine.
I think it's better to split this into a separate patch, since it's a new feature for the current driver.
Thanks,
Zhiqiang
Quoted 96 lines
drivers/net/tsec.c +3
-0+ else + phydev =dm_eth_phy_connect (priv->dev);#else phydev =phy_connect (priv->bus, priv->phyaddr, priv->dev, priv->interface); +#endif if (!phydev)return 0 ;@@ -785,14 +793,17 @@ int tsec_standard_init(bd_t *bis)return tsec_eth_init (bis, tsec_info,ARRAY_SIZE (tsec_info)); }#else /*
CONFIG_DM_ETH*/drivers/net/tsec.c +8
-34+ +#ifndef CONFIG_DM_MDIO +#error "TSEC with DM_ETH also requires DM_MDIO" +#endif +int tsec_probe (struct udevice *dev) {struct eth_pdata *pdata =dev_get_platdata (dev);struct tsec_private *priv =dev_get_priv (dev); -struct tsec_mii_mng __iomem *ext_phyregs_mii;struct ofnode_phandle_args phandle_args;u32 tbiaddr =CONFIG_SYS_TBIPA_VALUE ; -struct fsl_pq_mdio_info mdio_info;const char *phy_mode;fdt_addr_t reg;ofnode parent;@@ -801,31 +812,6 @@ int tsec_probe(struct udevice *dev) pdata->iobase = (phys_addr_t )dev_read_addr (dev); priv->regs =dev_remap_addr (dev); -if (dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , - &phandle_args)) { -printf ("phy-handle does not exist under tsec %s\n" , dev->name); -return -ENOENT ; - }else { -int reg =ofnode_read_u32_default (phandle_args.node,"reg" ,0 ); - - priv->phyaddr = reg; - } - - parent =ofnode_get_parent (phandle_args.node); -if (!ofnode_valid (parent)) { -printf ("No parent node for PHY?\n" ); -return -ENOENT ; - } - - reg =ofnode_get_addr_index (parent,0 ); -if (reg ==FDT_ADDR_T_NONE ) { -printf ("No 'reg' property of MII for external PHY\n" ); -return -ENOENT ; - } - - ext_phyregs_mii =map_physmem (reg +TSEC_MDIO_REGS_OFFSET ,0 , -MAP_NOCACHE ); - ret =dev_read_phandle_with_args (dev,"tbi-handle" ,NULL ,0 ,0 , &phandle_args);if (ret ==0 ) {@@ -860,14 +846,10 @@ int tsec_probe(struct udevice *dev)/* Initialize flags */ priv->flags =TSEC_GIGABIT ; -if (priv->interface ==PHY_INTERFACE_MODE_SGMII ) +if (priv->interface ==PHY_INTERFACE_MODE_SGMII ) { priv->flags |=TSEC_SGMII ; - - mdio_info.regs = ext_phyregs_mii; - mdio_info.name = (char *)dev->name; - ret =fsl_pq_mdio_init (NULL , &mdio_info); -if (ret) -return ret; +fsl_pq_mdio_reset (priv->phyregs_sgmii); + }/* Reset the MAC */ setbits_be32(&priv->regs->maccfg1, MACCFG1_SOFT_RESET); diff --git
a/include/fsl_mdio.hb/include/fsl_mdio.hindexb87346ce7ca1..11a6d588aff3100644include/fsl_mdio.h +1
-3@@ -46,9 +46,7 @@ void tsec_local_mdio_write(struct tsec_mii_mng __iomem *phyregs, int port_addr, int dev_addr, int reg, int value);int tsec_local_mdio_read (struct tsec_mii_mng __iomem *phyregs,int port_addr,int dev_addr,int regnum); -int tsec_phy_read (struct mii_dev *bus,int addr,int dev_addr,int regnum); -int tsec_phy_write (struct mii_dev *bus,int addr,int dev_addr,int regnum, -u16 value); +int fsl_pq_mdio_reset (struct tsec_mii_mng __iomem *regs); int memac_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr,int regnum, u16 value);
int memac_mdio_read(structmii_dev*bus, intport_addr, intdev_addr,
--
2.17.1
RFC PATCH 3/3 net: tsec: convert fsl_pq_mdio to DM_MDIO
Quoted 166 lines · Z.q. Hou
Quoted 154 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: 2020?5?4? 2:52
To: u-boot at lists.denx.de; joe.hershberger at ni.com; Priyanka Jain <[email protected]>
Cc: Z.q. Hou <[email protected]>; bmeng.cn at gmail.com; Claudiu Manoil <[email protected]>; Alexandru Marginean <[email protected]>
Subject: [RFC PATCH 3/3] net: tsec: convertfsl_pq_mdiotoDM_MDIOFrom: Vladimir Oltean <[email protected]>
For the platforms on which the eTSEC driver uses
DM_ETH, convert its MDIO controller code to also useDM_MDIO.Note that for handling the TBI PHY (the MAC PCS for SGMII), we still don't register a udevice for it, since we can drive it locally and there is no point in doing otherwise.
Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/fsl_mdio.c | 66 ++++++++++++++++++++++++++++++++++++++---- drivers/net/tsec.c | 50 ++++++++++---------------------- include/fsl_mdio.h | 4 +-- 3 files changed, 78 insertions(+), 42 deletions(-)drivers/net/fsl_mdio.c index renamed from drivers/net/fsl_mdio.c +0
-0
894b52ee66f4..284508062c8e100644drivers/net/fsl_mdio.c +2
-0@@ -8,9 +8,11 @@#include <common.h> #include <miiphy.h> #include <phy.h> +#include <miiphy.h> #include <fsl_mdio.h> #include <asm/io.h> #include <linux/errno.h> +#include <tsec.h> void tsec_local_mdio_write(struct tsec_mii_mng __iomem *phyregs, int port_addr,int
dev_addr, int regnum, int value)drivers/net/fsl_mdio.c +2
-4@@ -56,11 +58,8 @@ int tsec_local_mdio_read(struct tsec_mii_mng __iomem *phyregs, int port_addr, return value; } -static int fsl_pq_mdio_reset (struct mii_dev *bus) +int fsl_pq_mdio_reset (struct tsec_mii_mng __iomem *regs) { -struct tsec_mii_mng __iomem *regs = - (struct tsec_mii_mng __iomem *)bus->priv; -/* Reset MII (due to new addresses) */ out_be32 (®s->miimcfg,MIIMCFG_RESET_MGMT );@@ -72,6 +71,7 @@ static int fsl_pq_mdio_reset(struct mii_dev *bus)return 0 ; } +#ifndef CONFIG_DM_MDIO int tsec_phy_read (struct mii_dev *bus,int addr,int dev_addr,int regnum) { struct tsec_mii_mng __iomem *phyregs = @@ -91,6 +91,11 @@ int tsec_phy_write(struct mii_dev *bus, int addr, int dev_addr, int regnum,return 0;}
drivers/net/fsl_mdio.c +31
-1+static int tsec_mdio_reset (struct mii_dev *bus) { +return fsl_pq_mdio_reset (bus->priv); +} +int fsl_pq_mdio_init (bd_t *bis,struct fsl_pq_mdio_info *info) {struct mii_dev *bus =mdio_alloc ();@@ -102,10 +107,61 @@ int fsl_pq_mdio_init(bd_t *bis, struct fsl_pq_mdio_info *info) bus->read = tsec_phy_read; bus->write = tsec_phy_write; - bus->reset = fsl_pq_mdio_reset; + bus->reset = tsec_mdio_reset;strcpy (bus->name, info->name); bus->priv = (void *)info->regs;return mdio_register (bus); } +#endif + +#ifdef CONFIG_DM_MDIO +static int dm_fsl_pq_mdio_read (struct udevice *dev,int addr,int devad, +int reg) +{ +struct fsl_pq_mdio_info *info =dev_get_priv (dev); + +return tsec_local_mdio_read (info->regs, addr, devad, reg); } + +static int dm_fsl_pq_mdio_write (struct udevice *dev,int addr,int devad, +int reg,u16 val) +{ +struct fsl_pq_mdio_info *info =dev_get_priv (dev); + +tsec_local_mdio_write (info->regs, addr, devad, reg, val); + +return 0 ; +} + +static int fsl_pq_mdio_probe (struct udevice *dev) { +struct fsl_pq_mdio_info *info =dev_get_priv (dev); +fdt_addr_t reg; + + reg =devfdt_get_addr (dev); + info->regs = map_physmem(reg + TSEC_MDIO_REGS_OFFSET, 0,
MAP_NOCACHE);drivers/net/fsl_mdio.c +23
-0+ + return fsl_pq_mdio_reset(info->regs); +} + +static const struct mdio_ops fsl_pq_mdio_ops = { + .read = dm_fsl_pq_mdio_read, + .write = dm_fsl_pq_mdio_write, +}; + +static const struct udevice_id fsl_pq_mdio_ids[] = { + { .compatible ="fsl,etsec2-mdio" }, + { } +}; + +U_BOOT_DRIVER (fsl_pq_mdio) = { + .name ="fsl_pq_mdio" , + .id =UCLASS_MDIO , + .of_match = fsl_pq_mdio_ids, + .probe = fsl_pq_mdio_probe, + .ops = &fsl_pq_mdio_ops, + .priv_auto_alloc_size =sizeof (struct fsl_pq_mdio_info ), +}; +#endif drivers/net/tsec.c index renamed from drivers/net/tsec.c +0
-0
842cddf2297a..93f151a8a6db100644drivers/net/tsec.c +1
-0@@ -15,6 +15,7 @@#include <command.h> #include <tsec.h> #include <fsl_mdio.h> +#include <miiphy.h> #include <linux/errno.h> #include <asm/processor.h> #include <asm/io.h> drivers/net/tsec.c static int init_phy(struct tsec_private *priv) · line 685
Quoted 6 lines
drivers/net/tsec.c +3
-0@@ -679,8 +680,15 @@ static int init_phy(struct tsec_private *priv)if (priv->interface ==PHY_INTERFACE_MODE_SGMII )tsec_configure_serdes (priv); +#ifdef CONFIG_DM_ETH +if (ofnode_valid (ofnode_find_subnode (priv->dev->node,"fixed-link" ))) + phydev =phy_connect (NULL ,0 , priv->dev, priv->interface);Thanks for adding the "fixed PHY" support, I have a non-DM_MDIO version to supporting this, while this patch is better, I will drop mine.
I think it's better to split this into a separate patch, since it's a new feature for the current driver.
Quoted 3 lines
Thanks,
Zhiqiang
Thanks for the review. I'll split it apart when submitting it (after your patches get merged).
Quoted 88 lines
Quoted 88 lines
drivers/net/tsec.c +3
-0+ else + phydev =dm_eth_phy_connect (priv->dev);#else phydev =phy_connect (priv->bus, priv->phyaddr, priv->dev, priv->interface); +#endif if (!phydev)return 0 ;@@ -785,14 +793,17 @@ int tsec_standard_init(bd_t *bis)return tsec_eth_init (bis, tsec_info,ARRAY_SIZE (tsec_info)); }#else /*
CONFIG_DM_ETH*/drivers/net/tsec.c +8
-34+ +#ifndef CONFIG_DM_MDIO +#error "TSEC with DM_ETH also requires DM_MDIO" +#endif +int tsec_probe (struct udevice *dev) {struct eth_pdata *pdata =dev_get_platdata (dev);struct tsec_private *priv =dev_get_priv (dev); -struct tsec_mii_mng __iomem *ext_phyregs_mii;struct ofnode_phandle_args phandle_args;u32 tbiaddr =CONFIG_SYS_TBIPA_VALUE ; -struct fsl_pq_mdio_info mdio_info;const char *phy_mode;fdt_addr_t reg;ofnode parent;@@ -801,31 +812,6 @@ int tsec_probe(struct udevice *dev) pdata->iobase = (phys_addr_t )dev_read_addr (dev); priv->regs =dev_remap_addr (dev); -if (dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , - &phandle_args)) { -printf ("phy-handle does not exist under tsec %s\n" , dev->name); -return -ENOENT ; - }else { -int reg =ofnode_read_u32_default (phandle_args.node,"reg" ,0 ); - - priv->phyaddr = reg; - } - - parent =ofnode_get_parent (phandle_args.node); -if (!ofnode_valid (parent)) { -printf ("No parent node for PHY?\n" ); -return -ENOENT ; - } - - reg =ofnode_get_addr_index (parent,0 ); -if (reg ==FDT_ADDR_T_NONE ) { -printf ("No 'reg' property of MII for external PHY\n" ); -return -ENOENT ; - } - - ext_phyregs_mii =map_physmem (reg +TSEC_MDIO_REGS_OFFSET ,0 , -MAP_NOCACHE ); - ret =dev_read_phandle_with_args (dev,"tbi-handle" ,NULL ,0 ,0 , &phandle_args);if (ret ==0 ) {@@ -860,14 +846,10 @@ int tsec_probe(struct udevice *dev)/* Initialize flags */ priv->flags =TSEC_GIGABIT ; -if (priv->interface ==PHY_INTERFACE_MODE_SGMII ) +if (priv->interface ==PHY_INTERFACE_MODE_SGMII ) { priv->flags |=TSEC_SGMII ; - - mdio_info.regs = ext_phyregs_mii; - mdio_info.name = (char *)dev->name; - ret =fsl_pq_mdio_init (NULL , &mdio_info); -if (ret) -return ret; +fsl_pq_mdio_reset (priv->phyregs_sgmii); + }/* Reset the MAC */ setbits_be32(&priv->regs->maccfg1, MACCFG1_SOFT_RESET); diff --git
a/include/fsl_mdio.hb/include/fsl_mdio.hindexb87346ce7ca1..11a6d588aff3100644include/fsl_mdio.h +0
-1@@ -46,9 +46,7 @@ void tsec_local_mdio_write(struct tsec_mii_mng __iomem *phyregs, int port_addr, int dev_addr, int reg, int value);int tsec_local_mdio_read (struct tsec_mii_mng __iomem *phyregs,int port_addr,int dev_addr,int regnum); -int tsec_phy_read (struct mii_dev *bus,int addr,int dev_addr,int regnum);
Quoted 9 lines
Quoted 8 lines
include/fsl_mdio.h +1
-2-int tsec_phy_write (struct mii_dev *bus,int addr,int dev_addr,int regnum, -u16 value); +int fsl_pq_mdio_reset (struct tsec_mii_mng __iomem *regs); int memac_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr,int regnum, u16 value);int memac_mdio_read(struct
mii_dev*bus, intport_addr, intdev_addr,
--
2.17.1
Regards,
-Vladimir
RFC PATCH 3/3 net: tsec: convert fsl_pq_mdio to DM_MDIO
In reply to Vladimir OlteanHi Vladimir,
a patch for tsec migration to DM_MDIO has already been submitted, part of the DPAA 1 PowerPC patch set:
https://patchwork.ozlabs.org/project/uboot/patch/1588251616-14976-3-git-send-email-madalin.bucur at oss.nxp.com/
Madalin
Quoted 20 lines
-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Vladimir Oltean
Sent: Sunday, May 3, 2020 9:52 PM
To: u-boot at lists.denx.de; joe.hershberger at ni.com; Priyanka Jain <[email protected]>
Cc: Z.q. Hou <[email protected]>; bmeng.cn at gmail.com; Claudiu Manoil <[email protected]>; Alexandru Marginean <[email protected]>
Subject: [RFC PATCH 3/3] net: tsec: convertfsl_pq_mdiotoDM_MDIOFrom: Vladimir Oltean <[email protected]>
For the platforms on which the eTSEC driver uses
DM_ETH, convert its MDIO controller code to also useDM_MDIO.Note that for handling the TBI PHY (the MAC PCS for SGMII), we still don't register a udevice for it, since we can drive it locally and there is no point in doing otherwise.
Signed-off-by Vladimir Oltean <[email protected]>
RFC PATCH 3/3 net: tsec: convert fsl_pq_mdio to DM_MDIO
Quoted 15 lines
-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Madalin Bucur (OSS)
Sent: Tuesday, May 5, 2020 3:04 PM
To: Vladimir Oltean <[email protected]>; u-boot at lists.denx.de; joe.hershberger at ni.com; Priyanka Jain <[email protected]>
Cc: Z.q. Hou <[email protected]>; bmeng.cn at gmail.com; Claudiu Manoil <[email protected]>; Alexandru Marginean <[email protected]>
Subject: RE: [RFC PATCH 3/3] net: tsec: convertfsl_pq_mdiotoDM_MDIOHi Vladimir,
Quoted 8 lines
a patch for tsec migration to
DM_MDIOhas already been submitted, part of the DPAA 1 PowerPC patch set:https://patchwork.ozlabs.org/project/uboot/patch/1588251616-14976-3-git-
send-email-madalin.bucur at oss.nxp.com/Madalin
Vladimir,
As Madalin patches are now merged, kindly rebase the series and resend.
Thanks
Priyanka
<snip>