All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] DM_MDIO for fsl_tsec driver
@ 2020-05-03 18:52 Vladimir Oltean
  2020-05-03 18:52 ` [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio bus Vladimir Oltean
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Vladimir Oltean @ 2020-05-03 18:52 UTC (permalink / raw)
  To: u-boot

From: Vladimir Oltean <vladimir.oltean@nxp.com>

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(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio bus
  2020-05-03 18:52 [RFC PATCH 0/3] DM_MDIO for fsl_tsec driver Vladimir Oltean
@ 2020-05-03 18:52 ` Vladimir Oltean
  2020-05-04  6:08   ` Z.q. Hou
  2020-05-03 18:52 ` [RFC PATCH 2/3] configs: enable DM_MDIO for LS1021A-TWR and LS1021A-TSN Vladimir Oltean
  2020-05-03 18:52 ` [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO Vladimir Oltean
  2 siblings, 1 reply; 9+ messages in thread
From: Vladimir Oltean @ 2020-05-03 18:52 UTC (permalink / raw)
  To: u-boot

From: Vladimir Oltean <vladimir.oltean@nxp.com>

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.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/phy/phy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 9a66e62e8974..dcef1aaf2026 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -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;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 2/3] configs: enable DM_MDIO for LS1021A-TWR and LS1021A-TSN
  2020-05-03 18:52 [RFC PATCH 0/3] DM_MDIO for fsl_tsec driver Vladimir Oltean
  2020-05-03 18:52 ` [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio bus Vladimir Oltean
@ 2020-05-03 18:52 ` Vladimir Oltean
  2020-05-03 18:52 ` [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO Vladimir Oltean
  2 siblings, 0 replies; 9+ messages in thread
From: Vladimir Oltean @ 2020-05-03 18:52 UTC (permalink / raw)
  To: u-boot

From: Vladimir Oltean <vladimir.oltean@nxp.com>

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.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 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(+)

diff --git a/configs/ls1021atsn_qspi_defconfig b/configs/ls1021atsn_qspi_defconfig
index f1c010b5e916..debd52f2b236 100644
--- a/configs/ls1021atsn_qspi_defconfig
+++ b/configs/ls1021atsn_qspi_defconfig
@@ -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
diff --git a/configs/ls1021atsn_sdcard_defconfig b/configs/ls1021atsn_sdcard_defconfig
index 3550d16af8d6..de66c84314f4 100644
--- a/configs/ls1021atsn_sdcard_defconfig
+++ b/configs/ls1021atsn_sdcard_defconfig
@@ -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
diff --git a/configs/ls1021atwr_nor_SECURE_BOOT_defconfig b/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
index 85c19a66cda0..0e80182d7bee 100644
--- a/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
+++ b/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
@@ -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
diff --git a/configs/ls1021atwr_nor_defconfig b/configs/ls1021atwr_nor_defconfig
index 88462493a553..a71e036b4a49 100644
--- a/configs/ls1021atwr_nor_defconfig
+++ b/configs/ls1021atwr_nor_defconfig
@@ -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
diff --git a/configs/ls1021atwr_nor_lpuart_defconfig b/configs/ls1021atwr_nor_lpuart_defconfig
index 5ec13aaafd67..60daf3ef2b2d 100644
--- a/configs/ls1021atwr_nor_lpuart_defconfig
+++ b/configs/ls1021atwr_nor_lpuart_defconfig
@@ -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
diff --git a/configs/ls1021atwr_qspi_defconfig b/configs/ls1021atwr_qspi_defconfig
index 82339c98cf38..09a6a2918c39 100644
--- a/configs/ls1021atwr_qspi_defconfig
+++ b/configs/ls1021atwr_qspi_defconfig
@@ -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
diff --git a/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig b/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig
index a18b192176b3..4298b57aead9 100644
--- a/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig
+++ b/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig
@@ -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
diff --git a/configs/ls1021atwr_sdcard_ifc_defconfig b/configs/ls1021atwr_sdcard_ifc_defconfig
index fac41154456a..571fde20edac 100644
--- a/configs/ls1021atwr_sdcard_ifc_defconfig
+++ b/configs/ls1021atwr_sdcard_ifc_defconfig
@@ -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
diff --git a/configs/ls1021atwr_sdcard_qspi_defconfig b/configs/ls1021atwr_sdcard_qspi_defconfig
index 80a0e9171739..6af5289e38bb 100644
--- a/configs/ls1021atwr_sdcard_qspi_defconfig
+++ b/configs/ls1021atwr_sdcard_qspi_defconfig
@@ -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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO
  2020-05-03 18:52 [RFC PATCH 0/3] DM_MDIO for fsl_tsec driver Vladimir Oltean
  2020-05-03 18:52 ` [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio bus Vladimir Oltean
  2020-05-03 18:52 ` [RFC PATCH 2/3] configs: enable DM_MDIO for LS1021A-TWR and LS1021A-TSN Vladimir Oltean
@ 2020-05-03 18:52 ` Vladimir Oltean
  2020-05-04  6:22   ` Z.q. Hou
  2020-05-05  9:34   ` Madalin Bucur
  2 siblings, 2 replies; 9+ messages in thread
From: Vladimir Oltean @ 2020-05-03 18:52 UTC (permalink / raw)
  To: u-boot

From: Vladimir Oltean <vladimir.oltean@nxp.com>

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.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/fsl_mdio.c | 66 ++++++++++++++++++++++++++++++++++++++----
 drivers/net/tsec.c     | 50 ++++++++++----------------------
 include/fsl_mdio.h     |  4 +--
 3 files changed, 78 insertions(+), 42 deletions(-)

diff --git a/drivers/net/fsl_mdio.c b/drivers/net/fsl_mdio.c
index 894b52ee66f4..284508062c8e 100644
--- a/drivers/net/fsl_mdio.c
+++ b/drivers/net/fsl_mdio.c
@@ -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(&regs->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
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 842cddf2297a..93f151a8a6db 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -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>
@@ -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);
+	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 */
+
+#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.h b/include/fsl_mdio.h
index b87346ce7ca1..11a6d588aff3 100644
--- a/include/fsl_mdio.h
+++ b/include/fsl_mdio.h
@@ -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,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio bus
  2020-05-03 18:52 ` [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio bus Vladimir Oltean
@ 2020-05-04  6:08   ` Z.q. Hou
  0 siblings, 0 replies; 9+ messages in thread
From: Z.q. Hou @ 2020-05-04  6:08 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Vladimir Oltean <olteanv@gmail.com>
> Sent: 2020?5?4? 2:52
> To: u-boot at lists.denx.de; joe.hershberger at ni.com; Priyanka Jain
> <priyanka.jain@nxp.com>
> Cc: Z.q. Hou <zhiqiang.hou@nxp.com>; bmeng.cn at gmail.com; Claudiu
> Manoil <claudiu.manoil@nxp.com>; Alexandru Marginean
> <alexandru.marginean@nxp.com>
> Subject: [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio
> bus
> 
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> 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.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  drivers/net/phy/phy.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index
> 9a66e62e8974..dcef1aaf2026 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -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;
> --
> 2.17.1

Reviewed-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO
  2020-05-03 18:52 ` [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO Vladimir Oltean
@ 2020-05-04  6:22   ` Z.q. Hou
  2020-05-04  8:06     ` Vladimir Oltean
  2020-05-05  9:34   ` Madalin Bucur
  1 sibling, 1 reply; 9+ messages in thread
From: Z.q. Hou @ 2020-05-04  6:22 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Vladimir Oltean <olteanv@gmail.com>
> Sent: 2020?5?4? 2:52
> To: u-boot at lists.denx.de; joe.hershberger at ni.com; Priyanka Jain
> <priyanka.jain@nxp.com>
> Cc: Z.q. Hou <zhiqiang.hou@nxp.com>; bmeng.cn at gmail.com; Claudiu
> Manoil <claudiu.manoil@nxp.com>; Alexandru Marginean
> <alexandru.marginean@nxp.com>
> Subject: [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO
> 
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> 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.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  drivers/net/fsl_mdio.c | 66
> ++++++++++++++++++++++++++++++++++++++----
>  drivers/net/tsec.c     | 50 ++++++++++----------------------
>  include/fsl_mdio.h     |  4 +--
>  3 files changed, 78 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/net/fsl_mdio.c b/drivers/net/fsl_mdio.c index
> 894b52ee66f4..284508062c8e 100644
> --- a/drivers/net/fsl_mdio.c
> +++ b/drivers/net/fsl_mdio.c
> @@ -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(&regs->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
> diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index
> 842cddf2297a..93f151a8a6db 100644
> --- a/drivers/net/tsec.c
> +++ b/drivers/net/tsec.c
> @@ -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>
> @@ -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

> +	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 */
> +
> +#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.h b/include/fsl_mdio.h index
> b87346ce7ca1..11a6d588aff3 100644
> --- a/include/fsl_mdio.h
> +++ b/include/fsl_mdio.h
> @@ -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,
> --
> 2.17.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO
  2020-05-04  6:22   ` Z.q. Hou
@ 2020-05-04  8:06     ` Vladimir Oltean
  0 siblings, 0 replies; 9+ messages in thread
From: Vladimir Oltean @ 2020-05-04  8:06 UTC (permalink / raw)
  To: u-boot

On Mon, 4 May 2020 at 09:22, Z.q. Hou <zhiqiang.hou@nxp.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Vladimir Oltean <olteanv@gmail.com>
> > Sent: 2020?5?4? 2:52
> > To: u-boot at lists.denx.de; joe.hershberger at ni.com; Priyanka Jain
> > <priyanka.jain@nxp.com>
> > Cc: Z.q. Hou <zhiqiang.hou@nxp.com>; bmeng.cn at gmail.com; Claudiu
> > Manoil <claudiu.manoil@nxp.com>; Alexandru Marginean
> > <alexandru.marginean@nxp.com>
> > Subject: [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO
> >
> > From: Vladimir Oltean <vladimir.oltean@nxp.com>
> >
> > 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.
> >
> > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > ---
> >  drivers/net/fsl_mdio.c | 66
> > ++++++++++++++++++++++++++++++++++++++----
> >  drivers/net/tsec.c     | 50 ++++++++++----------------------
> >  include/fsl_mdio.h     |  4 +--
> >  3 files changed, 78 insertions(+), 42 deletions(-)
> >
> > diff --git a/drivers/net/fsl_mdio.c b/drivers/net/fsl_mdio.c index
> > 894b52ee66f4..284508062c8e 100644
> > --- a/drivers/net/fsl_mdio.c
> > +++ b/drivers/net/fsl_mdio.c
> > @@ -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(&regs->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
> > diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index
> > 842cddf2297a..93f151a8a6db 100644
> > --- a/drivers/net/tsec.c
> > +++ b/drivers/net/tsec.c
> > @@ -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>
> > @@ -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
>

Thanks for the review. I'll split it apart when submitting it (after
your patches get merged).

> > +     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 */
> > +
> > +#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.h b/include/fsl_mdio.h index
> > b87346ce7ca1..11a6d588aff3 100644
> > --- a/include/fsl_mdio.h
> > +++ b/include/fsl_mdio.h
> > @@ -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,
> > --
> > 2.17.1
>

Regards,
-Vladimir

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO
  2020-05-03 18:52 ` [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO Vladimir Oltean
  2020-05-04  6:22   ` Z.q. Hou
@ 2020-05-05  9:34   ` Madalin Bucur
  2020-07-15 10:37     ` Priyanka Jain
  1 sibling, 1 reply; 9+ messages in thread
From: Madalin Bucur @ 2020-05-05  9:34 UTC (permalink / raw)
  To: u-boot

Hi 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

> -----Original Message-----
> From: U-Boot <u-boot-bounces@lists.denx.de> 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
> <priyanka.jain@nxp.com>
> Cc: Z.q. Hou <zhiqiang.hou@nxp.com>; bmeng.cn at gmail.com; Claudiu Manoil
> <claudiu.manoil@nxp.com>; Alexandru Marginean
> <alexandru.marginean@nxp.com>
> Subject: [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO
> 
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> 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.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO
  2020-05-05  9:34   ` Madalin Bucur
@ 2020-07-15 10:37     ` Priyanka Jain
  0 siblings, 0 replies; 9+ messages in thread
From: Priyanka Jain @ 2020-07-15 10:37 UTC (permalink / raw)
  To: u-boot



>-----Original Message-----
>From: U-Boot <u-boot-bounces@lists.denx.de> On Behalf Of Madalin Bucur
>(OSS)
>Sent: Tuesday, May 5, 2020 3:04 PM
>To: Vladimir Oltean <olteanv@gmail.com>; u-boot at lists.denx.de;
>joe.hershberger at ni.com; Priyanka Jain <priyanka.jain@nxp.com>
>Cc: Z.q. Hou <zhiqiang.hou@nxp.com>; bmeng.cn at gmail.com; Claudiu
>Manoil <claudiu.manoil@nxp.com>; Alexandru Marginean
><alexandru.marginean@nxp.com>
>Subject: RE: [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO
>
>Hi 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
>
Vladimir,

As Madalin patches are now merged, kindly rebase the series and resend.

Thanks
Priyanka
<snip>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-07-15 10:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-03 18:52 [RFC PATCH 0/3] DM_MDIO for fsl_tsec driver Vladimir Oltean
2020-05-03 18:52 ` [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio bus Vladimir Oltean
2020-05-04  6:08   ` Z.q. Hou
2020-05-03 18:52 ` [RFC PATCH 2/3] configs: enable DM_MDIO for LS1021A-TWR and LS1021A-TSN Vladimir Oltean
2020-05-03 18:52 ` [RFC PATCH 3/3] net: tsec: convert fsl_pq_mdio to DM_MDIO Vladimir Oltean
2020-05-04  6:22   ` Z.q. Hou
2020-05-04  8:06     ` Vladimir Oltean
2020-05-05  9:34   ` Madalin Bucur
2020-07-15 10:37     ` Priyanka Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.