From patchwork Sun May 3 14:48:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiqiang Hou X-Patchwork-Id: 244937 List-Id: U-Boot discussion From: Zhiqiang.Hou at nxp.com (Zhiqiang Hou) Date: Sun, 3 May 2020 22:48:41 +0800 Subject: [PATCHv2 1/3] doc: dt-bindings: tsec: Correct the Ethernet port compatible string In-Reply-To: <20200503144843.36949-1-Zhiqiang.Hou@nxp.com> References: <20200503144843.36949-1-Zhiqiang.Hou@nxp.com> Message-ID: <20200503144843.36949-2-Zhiqiang.Hou@nxp.com> From: Hou Zhiqiang Change the compatible string to "fsl,etsec2" for the Ethernet ports, which is used in the current driver's match table. Fixes: 69a00875e3db ("doc: dt-bindings: Describe Freescale TSEC ethernet controller") Signed-off-by: Hou Zhiqiang Acked-by: Vladimir Oltean --- V2: - No change. doc/device-tree-bindings/net/fsl-tsec-phy.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/device-tree-bindings/net/fsl-tsec-phy.txt b/doc/device-tree-bindings/net/fsl-tsec-phy.txt index 59989e3b09..8e8574bc97 100644 --- a/doc/device-tree-bindings/net/fsl-tsec-phy.txt +++ b/doc/device-tree-bindings/net/fsl-tsec-phy.txt @@ -2,7 +2,7 @@ Properties: - - compatible : Should be "fsl,tsec" + - compatible : Should be "fsl,etsec2" - reg : Offset and length of the register set for the device - phy-handle : See ethernet.txt file in the same directory. - phy-connection-type : See ethernet.txt file in the same directory. This @@ -12,7 +12,7 @@ Properties: Example: ethernet at 24000 { - compatible = "fsl,tsec"; + compatible = "fsl,etsec2"; reg = <0x24000 0x1000>; phy-handle = <&phy0>; phy-connection-type = "sgmii"; From patchwork Sun May 3 14:48:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiqiang Hou X-Patchwork-Id: 244938 List-Id: U-Boot discussion From: Zhiqiang.Hou at nxp.com (Zhiqiang Hou) Date: Sun, 3 May 2020 22:48:42 +0800 Subject: [PATCHv2 2/3] net: tsec: Access eTSEC registers using virtual address In-Reply-To: <20200503144843.36949-1-Zhiqiang.Hou@nxp.com> References: <20200503144843.36949-1-Zhiqiang.Hou@nxp.com> Message-ID: <20200503144843.36949-3-Zhiqiang.Hou@nxp.com> From: Hou Zhiqiang The current code accesses eTSEC registers using physical address directly, it's not correct, though no problem on current platforms. It won't work on platforms, which does not support 1:1 virtual-physical address map. Signed-off-by: Hou Zhiqiang Reviewed-by: Vladimir Oltean Tested-by: Vladimir Oltean --- V2: - Added error message for getting the external PHY MII reg. drivers/net/tsec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index f85cdcb97e..541f964d2e 100644 --- a/drivers/net/tsec.c +++ b/drivers/net/tsec.c @@ -798,7 +798,7 @@ int tsec_probe(struct udevice *dev) int ret; pdata->iobase = (phys_addr_t)dev_read_addr(dev); - priv->regs = (struct tsec *)pdata->iobase; + priv->regs = dev_remap_addr(dev); if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, &phandle_args)) { @@ -817,8 +817,13 @@ int tsec_probe(struct udevice *dev) } reg = ofnode_get_addr_index(parent, 0); - priv->phyregs_sgmii = (struct tsec_mii_mng *) - (reg + TSEC_MDIO_REGS_OFFSET); + if (reg == FDT_ADDR_T_NONE) { + printf("No 'reg' property of MII for external PHY\n"); + return -ENOENT; + } + + priv->phyregs_sgmii = map_physmem(reg + TSEC_MDIO_REGS_OFFSET, 0, + MAP_NOCACHE); ret = dev_read_phandle_with_args(dev, "tbi-handle", NULL, 0, 0, &phandle_args); From patchwork Sun May 3 14:48:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiqiang Hou X-Patchwork-Id: 244939 List-Id: U-Boot discussion From: Zhiqiang.Hou at nxp.com (Zhiqiang Hou) Date: Sun, 3 May 2020 22:48:43 +0800 Subject: [PATCHv2 3/3] net: tsec: Access TBI PHY through the corresponding MII In-Reply-To: <20200503144843.36949-1-Zhiqiang.Hou@nxp.com> References: <20200503144843.36949-1-Zhiqiang.Hou@nxp.com> Message-ID: <20200503144843.36949-4-Zhiqiang.Hou@nxp.com> From: Hou Zhiqiang When an eTSEC is configured to use TBI, configuration of the TBI is done through the MIIM registers for that eTSEC. For example, if a TBI interface is required on eTSEC2, then the MIIM registers starting at offset 0x2_5520 are used to configure it. Fixes: 9a1d6af55ecd ("net: tsec: Add driver model ethernet support") Signed-off-by: Hou Zhiqiang Reviewed-by: Vladimir Oltean Tested-by: Vladimir Oltean --- V2: - Added error message for getting the internal TBI PHY MII reg. - Only try to get TBI PHY MII reg under the condition "tbi-handle". drivers/net/tsec.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index 541f964d2e..842cddf229 100644 --- a/drivers/net/tsec.c +++ b/drivers/net/tsec.c @@ -789,6 +789,7 @@ 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; @@ -822,14 +823,30 @@ int tsec_probe(struct udevice *dev) return -ENOENT; } - priv->phyregs_sgmii = map_physmem(reg + TSEC_MDIO_REGS_OFFSET, 0, - MAP_NOCACHE); + 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) + if (ret == 0) { ofnode_read_u32(phandle_args.node, "reg", &tbiaddr); + parent = ofnode_get_parent(phandle_args.node); + if (!ofnode_valid(parent)) { + printf("No parent node for TBI PHY?\n"); + return -ENOENT; + } + + reg = ofnode_get_addr_index(parent, 0); + if (reg == FDT_ADDR_T_NONE) { + printf("No 'reg' property of MII for TBI PHY\n"); + return -ENOENT; + } + + priv->phyregs_sgmii = map_physmem(reg + TSEC_MDIO_REGS_OFFSET, + 0, MAP_NOCACHE); + } + priv->tbiaddr = tbiaddr; phy_mode = dev_read_prop(dev, "phy-connection-type", NULL); @@ -846,7 +863,7 @@ int tsec_probe(struct udevice *dev) if (priv->interface == PHY_INTERFACE_MODE_SGMII) priv->flags |= TSEC_SGMII; - mdio_info.regs = priv->phyregs_sgmii; + mdio_info.regs = ext_phyregs_mii; mdio_info.name = (char *)dev->name; ret = fsl_pq_mdio_init(NULL, &mdio_info); if (ret)