* [PATCH 0/3] net: tsec: Fix issues of DM driver
@ 2020-05-03 6:23 Zhiqiang Hou
2020-05-03 6:23 ` [PATCH 1/3] doc: dt-bindings: tsec: Correct the Ethernet port compatible string Zhiqiang Hou
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Zhiqiang Hou @ 2020-05-03 6:23 UTC (permalink / raw)
To: u-boot
From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
This patch set is to fix some issues of eTSEC DM driver.
Hou Zhiqiang (3):
doc: dt-bindings: tsec: Correct the Ethernet port compatible string
net: tsec: Access eTSEC registers using virtual address
net: tsec: Access TBI PHY through the corresponding MII
doc/device-tree-bindings/net/fsl-tsec-phy.txt | 4 ++--
drivers/net/tsec.c | 22 +++++++++++++++----
2 files changed, 20 insertions(+), 6 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] doc: dt-bindings: tsec: Correct the Ethernet port compatible string
2020-05-03 6:23 [PATCH 0/3] net: tsec: Fix issues of DM driver Zhiqiang Hou
@ 2020-05-03 6:23 ` Zhiqiang Hou
2020-05-03 11:13 ` Vladimir Oltean
2020-05-03 6:23 ` [PATCH 2/3] net: tsec: Access eTSEC registers using virtual address Zhiqiang Hou
2020-05-03 6:23 ` [PATCH 3/3] net: tsec: Access TBI PHY through the corresponding MII Zhiqiang Hou
2 siblings, 1 reply; 12+ messages in thread
From: Zhiqiang Hou @ 2020-05-03 6:23 UTC (permalink / raw)
To: u-boot
From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
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 <Zhiqiang.Hou@nxp.com>
---
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";
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] net: tsec: Access eTSEC registers using virtual address
2020-05-03 6:23 [PATCH 0/3] net: tsec: Fix issues of DM driver Zhiqiang Hou
2020-05-03 6:23 ` [PATCH 1/3] doc: dt-bindings: tsec: Correct the Ethernet port compatible string Zhiqiang Hou
@ 2020-05-03 6:23 ` Zhiqiang Hou
2020-05-03 11:36 ` Vladimir Oltean
2020-05-03 6:23 ` [PATCH 3/3] net: tsec: Access TBI PHY through the corresponding MII Zhiqiang Hou
2 siblings, 1 reply; 12+ messages in thread
From: Zhiqiang Hou @ 2020-05-03 6:23 UTC (permalink / raw)
To: u-boot
From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
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 <Zhiqiang.Hou@nxp.com>
---
drivers/net/tsec.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index f85cdcb97e..ce41aec5cf 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,11 @@ 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)
+ 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);
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] net: tsec: Access TBI PHY through the corresponding MII
2020-05-03 6:23 [PATCH 0/3] net: tsec: Fix issues of DM driver Zhiqiang Hou
2020-05-03 6:23 ` [PATCH 1/3] doc: dt-bindings: tsec: Correct the Ethernet port compatible string Zhiqiang Hou
2020-05-03 6:23 ` [PATCH 2/3] net: tsec: Access eTSEC registers using virtual address Zhiqiang Hou
@ 2020-05-03 6:23 ` Zhiqiang Hou
2020-05-03 11:34 ` Vladimir Oltean
2 siblings, 1 reply; 12+ messages in thread
From: Zhiqiang Hou @ 2020-05-03 6:23 UTC (permalink / raw)
To: u-boot
From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
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 <Zhiqiang.Hou@nxp.com>
---
drivers/net/tsec.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index ce41aec5cf..31056f3117 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;
@@ -820,8 +821,8 @@ int tsec_probe(struct udevice *dev)
if (reg == FDT_ADDR_T_NONE)
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);
@@ -830,6 +831,16 @@ int tsec_probe(struct udevice *dev)
priv->tbiaddr = 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);
+ priv->phyregs_sgmii = map_physmem(reg + TSEC_MDIO_REGS_OFFSET, 0,
+ MAP_NOCACHE);
+
phy_mode = dev_read_prop(dev, "phy-connection-type", NULL);
if (phy_mode)
pdata->phy_interface = phy_get_interface_by_name(phy_mode);
@@ -844,7 +855,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)
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 1/3] doc: dt-bindings: tsec: Correct the Ethernet port compatible string
2020-05-03 6:23 ` [PATCH 1/3] doc: dt-bindings: tsec: Correct the Ethernet port compatible string Zhiqiang Hou
@ 2020-05-03 11:13 ` Vladimir Oltean
2020-05-03 13:47 ` Z.q. Hou
0 siblings, 1 reply; 12+ messages in thread
From: Vladimir Oltean @ 2020-05-03 11:13 UTC (permalink / raw)
To: u-boot
On Sun, 3 May 2020 at 09:28, Zhiqiang Hou <Zhiqiang.Hou@nxp.com> wrote:
>
> From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
>
> 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 <Zhiqiang.Hou@nxp.com>
> ---
Acked-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Although I am unclear how the G&D MPC8308 boards
(arch/powerpc/dts/gdsys/mpc8308.dtsi) have ever probed their TSEC
interfaces. Probably not based on DM, since the fsl,tsec compatible
string has never been supported by the mainline tsec driver.
> 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";
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] net: tsec: Access TBI PHY through the corresponding MII
2020-05-03 6:23 ` [PATCH 3/3] net: tsec: Access TBI PHY through the corresponding MII Zhiqiang Hou
@ 2020-05-03 11:34 ` Vladimir Oltean
2020-05-03 13:49 ` Z.q. Hou
0 siblings, 1 reply; 12+ messages in thread
From: Vladimir Oltean @ 2020-05-03 11:34 UTC (permalink / raw)
To: u-boot
On Sun, 3 May 2020 at 09:28, Zhiqiang Hou <Zhiqiang.Hou@nxp.com> wrote:
>
> From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
>
> 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 <Zhiqiang.Hou@nxp.com>
> ---
> drivers/net/tsec.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> index ce41aec5cf..31056f3117 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;
> @@ -820,8 +821,8 @@ int tsec_probe(struct udevice *dev)
> if (reg == FDT_ADDR_T_NONE)
> 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);
> @@ -830,6 +831,16 @@ int tsec_probe(struct udevice *dev)
>
> priv->tbiaddr = 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);
Missing a check
if (reg == FDT_ADDR_T_NONE)
return -ENOENT;
here?
> + priv->phyregs_sgmii = map_physmem(reg + TSEC_MDIO_REGS_OFFSET, 0,
> + MAP_NOCACHE);
> +
> phy_mode = dev_read_prop(dev, "phy-connection-type", NULL);
> if (phy_mode)
> pdata->phy_interface = phy_get_interface_by_name(phy_mode);
> @@ -844,7 +855,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)
> --
> 2.17.1
>
With that:
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
(on LS1021A)
Thanks!
-Vladimir
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] net: tsec: Access eTSEC registers using virtual address
2020-05-03 6:23 ` [PATCH 2/3] net: tsec: Access eTSEC registers using virtual address Zhiqiang Hou
@ 2020-05-03 11:36 ` Vladimir Oltean
2020-05-03 13:50 ` Z.q. Hou
0 siblings, 1 reply; 12+ messages in thread
From: Vladimir Oltean @ 2020-05-03 11:36 UTC (permalink / raw)
To: u-boot
Hi Zhiqiang,
On Sun, 3 May 2020 at 09:28, Zhiqiang Hou <Zhiqiang.Hou@nxp.com> wrote:
>
> From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
>
> 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 <Zhiqiang.Hou@nxp.com>
> ---
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
(on LS1021A)
> drivers/net/tsec.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> index f85cdcb97e..ce41aec5cf 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,11 @@ 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)
> + 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);
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] doc: dt-bindings: tsec: Correct the Ethernet port compatible string
2020-05-03 11:13 ` Vladimir Oltean
@ 2020-05-03 13:47 ` Z.q. Hou
0 siblings, 0 replies; 12+ messages in thread
From: Z.q. Hou @ 2020-05-03 13:47 UTC (permalink / raw)
To: u-boot
Hi Vladimir,
Thanks a lot for your ack!
> -----Original Message-----
> From: Vladimir Oltean <olteanv@gmail.com>
> Sent: 2020?5?3? 19:13
> To: Z.q. Hou <zhiqiang.hou@nxp.com>
> Cc: u-boot <u-boot@lists.denx.de>; Joe Hershberger
> <joe.hershberger@ni.com>; Bin Meng <bmeng.cn@gmail.com>; Priyanka
> Jain <priyanka.jain@nxp.com>; mario.six at gdsys.cc
> Subject: Re: [PATCH 1/3] doc: dt-bindings: tsec: Correct the Ethernet port
> compatible string
>
> On Sun, 3 May 2020 at 09:28, Zhiqiang Hou <Zhiqiang.Hou@nxp.com>
> wrote:
> >
> > From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> >
> > 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 <Zhiqiang.Hou@nxp.com>
> > ---
>
> Acked-by: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> Although I am unclear how the G&D MPC8308 boards
> (arch/powerpc/dts/gdsys/mpc8308.dtsi) have ever probed their TSEC
> interfaces. Probably not based on DM, since the fsl,tsec compatible string
> has never been supported by the mainline tsec driver.
I agree with you, they seems using legacy driver. I'm working on the support
of compatible "gianfar", the MPC8308 boards can shift to the DM driver then.
Thanks,
Zhiqiang
>
> > 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";
> > --
> > 2.17.1
> >
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] net: tsec: Access TBI PHY through the corresponding MII
2020-05-03 11:34 ` Vladimir Oltean
@ 2020-05-03 13:49 ` Z.q. Hou
2020-05-03 14:07 ` Vladimir Oltean
0 siblings, 1 reply; 12+ messages in thread
From: Z.q. Hou @ 2020-05-03 13:49 UTC (permalink / raw)
To: u-boot
Hi Vladimir,
Thanks a lot for your review and test!
> -----Original Message-----
> From: Vladimir Oltean <olteanv@gmail.com>
> Sent: 2020?5?3? 19:35
> To: Z.q. Hou <zhiqiang.hou@nxp.com>
> Cc: u-boot <u-boot@lists.denx.de>; Joe Hershberger
> <joe.hershberger@ni.com>; Bin Meng <bmeng.cn@gmail.com>; Priyanka
> Jain <priyanka.jain@nxp.com>
> Subject: Re: [PATCH 3/3] net: tsec: Access TBI PHY through the
> corresponding MII
>
> On Sun, 3 May 2020 at 09:28, Zhiqiang Hou <Zhiqiang.Hou@nxp.com>
> wrote:
> >
> > From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> >
> > 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 <Zhiqiang.Hou@nxp.com>
> > ---
> > drivers/net/tsec.c | 17 ++++++++++++++---
> > 1 file changed, 14 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index
> > ce41aec5cf..31056f3117 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; @@ -820,8 +821,8 @@ int
> > tsec_probe(struct udevice *dev)
> > if (reg == FDT_ADDR_T_NONE)
> > 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); @@
> -830,6
> > +831,16 @@ int tsec_probe(struct udevice *dev)
> >
> > priv->tbiaddr = 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);
>
> Missing a check
>
> if (reg == FDT_ADDR_T_NONE)
> return -ENOENT;
>
> here?
Yes, will fix in v2.
Thanks,
Zhiqiang
>
> > + priv->phyregs_sgmii = map_physmem(reg +
> TSEC_MDIO_REGS_OFFSET, 0,
> > + MAP_NOCACHE);
> > +
> > phy_mode = dev_read_prop(dev, "phy-connection-type", NULL);
> > if (phy_mode)
> > pdata->phy_interface =
> > phy_get_interface_by_name(phy_mode);
> > @@ -844,7 +855,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)
> > --
> > 2.17.1
> >
>
> With that:
>
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> (on LS1021A)
>
> Thanks!
> -Vladimir
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] net: tsec: Access eTSEC registers using virtual address
2020-05-03 11:36 ` Vladimir Oltean
@ 2020-05-03 13:50 ` Z.q. Hou
0 siblings, 0 replies; 12+ messages in thread
From: Z.q. Hou @ 2020-05-03 13:50 UTC (permalink / raw)
To: u-boot
Hi Vladimir,
Thanks a lot for your review and test!
Thanks,
Zhiqiang
> -----Original Message-----
> From: Vladimir Oltean <olteanv@gmail.com>
> Sent: 2020?5?3? 19:36
> To: Z.q. Hou <zhiqiang.hou@nxp.com>
> Cc: u-boot <u-boot@lists.denx.de>; Joe Hershberger
> <joe.hershberger@ni.com>; Bin Meng <bmeng.cn@gmail.com>; Priyanka
> Jain <priyanka.jain@nxp.com>
> Subject: Re: [PATCH 2/3] net: tsec: Access eTSEC registers using virtual
> address
>
> Hi Zhiqiang,
>
> On Sun, 3 May 2020 at 09:28, Zhiqiang Hou <Zhiqiang.Hou@nxp.com>
> wrote:
> >
> > From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> >
> > 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 <Zhiqiang.Hou@nxp.com>
> > ---
>
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> (on LS1021A)
>
> > drivers/net/tsec.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index
> > f85cdcb97e..ce41aec5cf 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,11 @@ 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)
> > + 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);
> > --
> > 2.17.1
> >
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] net: tsec: Access TBI PHY through the corresponding MII
2020-05-03 13:49 ` Z.q. Hou
@ 2020-05-03 14:07 ` Vladimir Oltean
2020-05-03 14:41 ` Z.q. Hou
0 siblings, 1 reply; 12+ messages in thread
From: Vladimir Oltean @ 2020-05-03 14:07 UTC (permalink / raw)
To: u-boot
Hi Zhiqiang,
On Sun, 3 May 2020 at 16:49, Z.q. Hou <zhiqiang.hou@nxp.com> wrote:
>
> Hi Vladimir,
>
> Thanks a lot for your review and test!
>
> > -----Original Message-----
> > From: Vladimir Oltean <olteanv@gmail.com>
> > Sent: 2020?5?3? 19:35
> > To: Z.q. Hou <zhiqiang.hou@nxp.com>
> > Cc: u-boot <u-boot@lists.denx.de>; Joe Hershberger
> > <joe.hershberger@ni.com>; Bin Meng <bmeng.cn@gmail.com>; Priyanka
> > Jain <priyanka.jain@nxp.com>
> > Subject: Re: [PATCH 3/3] net: tsec: Access TBI PHY through the
> > corresponding MII
> >
> > On Sun, 3 May 2020 at 09:28, Zhiqiang Hou <Zhiqiang.Hou@nxp.com>
> > wrote:
> > >
> > > From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> > >
> > > 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 <Zhiqiang.Hou@nxp.com>
> > > ---
> > > drivers/net/tsec.c | 17 ++++++++++++++---
> > > 1 file changed, 14 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index
> > > ce41aec5cf..31056f3117 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; @@ -820,8 +821,8 @@ int
> > > tsec_probe(struct udevice *dev)
> > > if (reg == FDT_ADDR_T_NONE)
> > > 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); @@
> > -830,6
> > > +831,16 @@ int tsec_probe(struct udevice *dev)
> > >
> > > priv->tbiaddr = 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);
> >
> > Missing a check
> >
> > if (reg == FDT_ADDR_T_NONE)
> > return -ENOENT;
> >
> > here?
>
> Yes, will fix in v2.
>
> Thanks,
> Zhiqiang
Actually since the TBI PHY is optional (not present on RGMII
interfaces and such), I don't believe you should return an error, but
just skip the phyregs_sgmii initialization.
>
> >
> > > + priv->phyregs_sgmii = map_physmem(reg +
> > TSEC_MDIO_REGS_OFFSET, 0,
> > > + MAP_NOCACHE);
> > > +
> > > phy_mode = dev_read_prop(dev, "phy-connection-type", NULL);
> > > if (phy_mode)
> > > pdata->phy_interface =
> > > phy_get_interface_by_name(phy_mode);
> > > @@ -844,7 +855,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)
> > > --
> > > 2.17.1
> > >
> >
> > With that:
> >
> > Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> >
> > (on LS1021A)
> >
> > Thanks!
> > -Vladimir
Thanks,
-Vladimir
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] net: tsec: Access TBI PHY through the corresponding MII
2020-05-03 14:07 ` Vladimir Oltean
@ 2020-05-03 14:41 ` Z.q. Hou
0 siblings, 0 replies; 12+ messages in thread
From: Z.q. Hou @ 2020-05-03 14:41 UTC (permalink / raw)
To: u-boot
Hi Vladimir,
Thanks a lot for your comments!
> -----Original Message-----
> From: Vladimir Oltean <olteanv@gmail.com>
> Sent: 2020?5?3? 22:07
> To: Z.q. Hou <zhiqiang.hou@nxp.com>
> Cc: u-boot <u-boot@lists.denx.de>; Joe Hershberger
> <joe.hershberger@ni.com>; Bin Meng <bmeng.cn@gmail.com>; Priyanka
> Jain <priyanka.jain@nxp.com>
> Subject: Re: [PATCH 3/3] net: tsec: Access TBI PHY through the
> corresponding MII
>
> Hi Zhiqiang,
>
> On Sun, 3 May 2020 at 16:49, Z.q. Hou <zhiqiang.hou@nxp.com> wrote:
> >
> > Hi Vladimir,
> >
> > Thanks a lot for your review and test!
> >
> > > -----Original Message-----
> > > From: Vladimir Oltean <olteanv@gmail.com>
> > > Sent: 2020?5?3? 19:35
> > > To: Z.q. Hou <zhiqiang.hou@nxp.com>
> > > Cc: u-boot <u-boot@lists.denx.de>; Joe Hershberger
> > > <joe.hershberger@ni.com>; Bin Meng <bmeng.cn@gmail.com>;
> Priyanka
> > > Jain <priyanka.jain@nxp.com>
> > > Subject: Re: [PATCH 3/3] net: tsec: Access TBI PHY through the
> > > corresponding MII
> > >
> > > On Sun, 3 May 2020 at 09:28, Zhiqiang Hou <Zhiqiang.Hou@nxp.com>
> > > wrote:
> > > >
> > > > From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> > > >
> > > > 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 <Zhiqiang.Hou@nxp.com>
> > > > ---
> > > > drivers/net/tsec.c | 17 ++++++++++++++---
> > > > 1 file changed, 14 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index
> > > > ce41aec5cf..31056f3117 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; @@ -820,8 +821,8 @@
> int
> > > > tsec_probe(struct udevice *dev)
> > > > if (reg == FDT_ADDR_T_NONE)
> > > > 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);
> @@
> > > -830,6
> > > > +831,16 @@ int tsec_probe(struct udevice *dev)
> > > >
> > > > priv->tbiaddr = 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);
> > >
> > > Missing a check
> > >
> > > if (reg == FDT_ADDR_T_NONE)
> > > return -ENOENT;
> > >
> > > here?
> >
> > Yes, will fix in v2.
> >
> > Thanks,
> > Zhiqiang
>
> Actually since the TBI PHY is optional (not present on RGMII interfaces and
> such), I don't believe you should return an error, but just skip the
> phyregs_sgmii initialization.
Correct, I just realized it.
Thanks,
Zhiqiang
>
> >
> > >
> > > > + priv->phyregs_sgmii = map_physmem(reg +
> > > TSEC_MDIO_REGS_OFFSET, 0,
> > > > + MAP_NOCACHE);
> > > > +
> > > > phy_mode = dev_read_prop(dev, "phy-connection-type",
> NULL);
> > > > if (phy_mode)
> > > > pdata->phy_interface =
> > > > phy_get_interface_by_name(phy_mode);
> > > > @@ -844,7 +855,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)
> > > > --
> > > > 2.17.1
> > > >
> > >
> > > With that:
> > >
> > > Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > > Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > >
> > > (on LS1021A)
> > >
> > > Thanks!
> > > -Vladimir
>
> Thanks,
> -Vladimir
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-05-03 14:41 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-03 6:23 [PATCH 0/3] net: tsec: Fix issues of DM driver Zhiqiang Hou
2020-05-03 6:23 ` [PATCH 1/3] doc: dt-bindings: tsec: Correct the Ethernet port compatible string Zhiqiang Hou
2020-05-03 11:13 ` Vladimir Oltean
2020-05-03 13:47 ` Z.q. Hou
2020-05-03 6:23 ` [PATCH 2/3] net: tsec: Access eTSEC registers using virtual address Zhiqiang Hou
2020-05-03 11:36 ` Vladimir Oltean
2020-05-03 13:50 ` Z.q. Hou
2020-05-03 6:23 ` [PATCH 3/3] net: tsec: Access TBI PHY through the corresponding MII Zhiqiang Hou
2020-05-03 11:34 ` Vladimir Oltean
2020-05-03 13:49 ` Z.q. Hou
2020-05-03 14:07 ` Vladimir Oltean
2020-05-03 14:41 ` Z.q. Hou
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.