DM_ETH v mpc83xx fixups
Subsystems (2)
cover DM_ETH v mpc83xx fixups
Hi Heiko
I finally managed to figure out what was wrong; the fixed-link phy was simply ignored. This is fixed by the first patch, though I don't know if that's the proper way to make this work.
While poking around the code I found two minor things that might as well be fixed.
I'd also like to do a somewhat more extensive change to dm_qe_uec.c: I find it very confusing with the qe_uec_priv versus uec_priv, so I'd like to just add a phydev member to struct uec_priv, remove struct qe_uec_priv, make .priv_auto_alloc_size = sizeof(struct uec_priv), and eliminate the malloc/free pair in .prove/.remove. It's mostly mechanical using coccinelle, but WDYT?
Rasmus Villemoes (3):
mdio-uclass.c: support fixed-link subnodes dm_qe_uec.c: fix indentation in uec_set_mac_if_mode() uec.h: fix COFIG_DM typo
drivers/net/qe/dm_qe_uec.c | 4 ++-- drivers/net/qe/uec.h | 2 +- net/mdio-uclass.c | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-)
Signature · 1 line
2.23.0
PATCH 1/3 mdio-uclass.c: support fixed-link subnodes
When trying to port our mpc8309-based board to DM_ETH, on top of Heiko's patches, I found that nothing in mdio-uclass.c seems to support the use of a fixed-link subnode of the ethernet DT node. That is, the ethernet node looks like
enet0: ethernet at 2000 {
device_type = "network";
compatible = "ucc_geth";
...
fixed-link {
reg = <0xffffffff>;
speed = <100>;
full-duplex;
};but the current code expects there to be phy-handle property. Adding that, i.e.
phy-handle = <&enet0phy>;
enet0phy: fixed-link {just makes the code break a few lines later since a fixed-link node doesn't have a reg property. Ignoring the dtc complaint and adding a dummy reg property, we of course hit "can't find MDIO bus for node ethernet at 2000" since indeed, the parent node of the phy node does not represent an MDIO bus. So that's obviously the wrong path.
Now, in linux, it seems that the fixed link case is treated specially; in the of_phy_get_and_connect() which roughly corresponds to dm_eth_connect_phy_handle() we have
if (of_phy_is_fixed_link(np)) {
ret = of_phy_register_fixed_link(np);
...
} else {
phy_np = of_parse_phandle(np, "phy-handle", 0);
...
}
phy = of_phy_connect(dev, phy_np, hndlr, 0, iface);And U-Boot's phy_connect() does have support for fixed-link subnodes. Calling phy_connect() directly with NULL bus and a dummy address does seem to make the ethernet work.
--- net/mdio-uclass.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/mdio-uclass.c +7 -0
@@ -139,6 +139,12 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,struct ofnode_phandle_args phandle = {.node =ofnode_null ()};int i; +if (CONFIG_IS_ENABLED (PHY_FIXED ) && +ofnode_valid (dev_read_subnode (ethdev,"fixed-link" ))) { + phy =phy_connect (NULL ,-1 , ethdev, interface); + goto out; + } +for (i =0 ; i <PHY_HANDLE_STR_CNT ; i++)if (!dev_read_phandle_with_args (ethdev, phy_handle_str[i],NULL ,0 ,0 , &phandle))
@@ -168,6 +174,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, phy =dm_mdio_phy_connect (mdiodev, phy_addr, ethdev, interface); +out:if (phy) phy->node = phandle.node;
Signature · 1 line
2.23.0
PATCH 1/3 mdio-uclass.c: support fixed-link subnodes
Hello Rasmus,
Am 05.10.2020 um 15:15 schrieb Rasmus Villemoes:
Quoted 68 lines
When trying to port our mpc8309-based board to
DM_ETH, on top of Heiko's patches, I found that nothing inmdio-uclass.cseems to support the use of a fixed-link subnode of the ethernet DT node. That is, the ethernet node looks likeenet0: ethernet at 2000 { device_type = "network"; compatible = "ucc_geth"; ... fixed-link { reg = <0xffffffff>; speed = <100>; full-duplex; };but the current code expects there to be phy-handle property. Adding that, i.e.
phy-handle = <&enet0phy>; enet0phy: fixed-link {just makes the code break a few lines later since a fixed-link node doesn't have a reg property. Ignoring the dtc complaint and adding a dummy reg property, we of course hit "can't find MDIO bus for node ethernet at 2000" since indeed, the parent node of the phy node does not represent an MDIO bus. So that's obviously the wrong path.
Now, in linux, it seems that the fixed link case is treated specially; in the
of_phy_get_and_connect()which roughly corresponds todm_eth_connect_phy_handle()we haveif (of_phy_is_fixed_link(np)) { ret = of_phy_register_fixed_link(np); ... } else { phy_np = of_parse_phandle(np, "phy-handle", 0); ... } phy = of_phy_connect(dev, phy_np, hndlr, 0, iface);And U-Boot's
phy_connect()does have support for fixed-link subnodes. Callingphy_connect()directly with NULL bus and a dummy address does seem to make the ethernet work.Signed-off-by Rasmus Villemoes <[email protected]>--- net/mdio-uclass.c | 7 +++++++ 1 file changed, 7 insertions(+)net/mdio-uclass.c +6
-0@@ -139,6 +139,12 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,struct ofnode_phandle_args phandle = {.node =ofnode_null ()};int i; +if (CONFIG_IS_ENABLED (PHY_FIXED ) && +ofnode_valid (dev_read_subnode (ethdev,"fixed-link" ))) { + phy =phy_connect (NULL ,-1 , ethdev, interface); + goto out; + } +for (i =0 ; i <PHY_HANDLE_STR_CNT ; i++)if (!dev_read_phandle_with_args (ethdev, phy_handle_str[i],NULL ,0 ,0 , &phandle))
net/mdio-uclass.c static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, · line 179
Quoted 6 lines
net/mdio-uclass.c +1
-0@@ -168,6 +174,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, phy =dm_mdio_phy_connect (mdiodev, phy_addr, ethdev, interface); +out:if (phy) phy->node = phandle.node;
Looks good to me... but I am not an expert in net subsystem... nevertheless:
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 1/3 mdio-uclass.c: support fixed-link subnodes
Quoted 14 lines · Heiko Schocher
Hello Rasmus,
Am 05.10.2020 um 15:15 schrieb Rasmus Villemoes:
Quoted 11 lines
When trying to port our mpc8309-based board to
DM_ETH, on top of Heiko's patches, I found that nothing inmdio-uclass.cseems to support the use of a fixed-link subnode of the ethernet DT node. That is, the ethernet node looks like??????? enet0: ethernet at 2000 {
???????????device_type= "network";
??????????? compatible = "ucc_geth";
??????????? ...
??????????? fixed-link {
??????????????? reg = <0xffffffff>;
Well, it looks like that when a dummy reg property has been added, not IRL. Sorry.
Quoted 32 lines
Quoted 25 lines
---
?net/mdio-uclass.c| 7 +++++++
? 1 file changed, 7 insertions(+)net/mdio-uclass.c +0
-0@@ -139,6 +139,12 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, ????? struct ofnode_phandle_args phandle = {.node = ofnode_null()}; ????? int i;? +??? if (
CONFIG_IS_ENABLED(PHY_FIXED)&&
+???????ofnode_valid(dev_read_subnode(ethdev, "fixed-link"))) { +??????? phy =phy_connect(NULL, -1, ethdev, interface); +??????? goto out;
+??? }
+
????? for (i = 0; i <PHY_HANDLE_STR_CNT; i++)
????????? if (!dev_read_phandle_with_args(ethdev, phy_handle_str[i], NULL,
????????????????????????? 0, 0, &phandle))net/mdio-uclass.c +0
-0@@ -168,6 +174,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, ? ????? phy = dm_mdio_phy_connect(mdiodev, phy_addr, ethdev, interface);Quoted 3 lines
? +out:
????? if (phy)
?????????phy->node= phandle.node;Looks good to me... but I am not an expert in net subsystem... nevertheless:
Quoted 1 line
Reviewed-by Heiko Schocher <[email protected]>
Thanks.
Yeah, as I said, I have no idea if this is the right way to do things. Some ethernet drivers seem to call phy_connect directly instead of going through dm_eth_phy_connect(), some handle fixed-link themselves, etc. But from a very selfish POV, this is the minimal patch to make our board (and others with a ucc_geth ethernet dev with a fixed-link) work with DM_ETH.
Rasmus
PATCH 1/3 mdio-uclass.c: support fixed-link subnodes
In reply to Rasmus VillemoesQuoted 41 lines · Rasmus Villemoes
When trying to port our mpc8309-based board to
DM_ETH, on top of Heiko's patches, I found that nothing inmdio-uclass.cseems to support the use of a fixed-link subnode of the ethernet DT node. That is, the ethernet node looks likeenet0: ethernet at 2000 { device_type = "network"; compatible = "ucc_geth"; ... fixed-link { reg = <0xffffffff>; speed = <100>; full-duplex; };but the current code expects there to be phy-handle property. Adding that, i.e.
phy-handle = <&enet0phy>; enet0phy: fixed-link {just makes the code break a few lines later since a fixed-link node doesn't have a reg property. Ignoring the dtc complaint and adding a dummy reg property, we of course hit "can't find MDIO bus for node ethernet at 2000" since indeed, the parent node of the phy node does not represent an MDIO bus. So that's obviously the wrong path.
Now, in linux, it seems that the fixed link case is treated specially; in the
of_phy_get_and_connect()which roughly corresponds todm_eth_connect_phy_handle()we haveif (of_phy_is_fixed_link(np)) { ret = of_phy_register_fixed_link(np); ... } else { phy_np = of_parse_phandle(np, "phy-handle", 0); ... } phy = of_phy_connect(dev, phy_np, hndlr, 0, iface);
Quoted 6 lines
And U-Boot's
phy_connect()does have support for fixed-link subnodes. Callingphy_connect()directly with NULL bus and a dummy address does seem to make the ethernet work.Signed-off-by Rasmus Villemoes <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210222/df0a8a17/attachment.sig>
PATCH 2/3 dm_qe_uec.c: fix indentation in uec_set_mac_if_mode()
In reply to Rasmus Villemoes--- drivers/net/qe/dm_qe_uec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/qe/dm_qe_uec.c +2 -2
@@ -171,8 +171,8 @@ static int uec_set_mac_if_mode(struct uec_priv *uec)break ;default :return -EINVAL ; - } -break ; + } +break ;case SPEED_1000 : maccfg2 |=MACCFG2_INTERFACE_MODE_BYTE ;switch (enet_if_mode) {
Signature · 1 line
2.23.0
PATCH 2/3 dm_qe_uec.c: fix indentation in uec_set_mac_if_mode()
Hello Rasmus,
Am 05.10.2020 um 15:15 schrieb Rasmus Villemoes:
Quoted 11 lines
Signed-off-by Rasmus Villemoes <[email protected]>--- drivers/net/qe/dm_qe_uec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/qe/dm_qe_uec.c +0
-0
drivers/net/qe/dm_qe_uec.c static int uec_set_mac_if_mode(struct uec_priv *uec) · line 178
Quoted 10 lines
drivers/net/qe/dm_qe_uec.c +2
-2@@ -171,8 +171,8 @@ static int uec_set_mac_if_mode(struct uec_priv *uec)break ;default :return -EINVAL ; - } -break ; + } +break ;case SPEED_1000 : maccfg2 |=MACCFG2_INTERFACE_MODE_BYTE ;switch (enet_if_mode) {
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 2/3 dm_qe_uec.c: fix indentation in uec_set_mac_if_mode()
In reply to Rasmus VillemoesQuoted 2 lines · Rasmus Villemoes
Signed-off-by Rasmus Villemoes <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210222/c8961063/attachment.sig>
PATCH 3/3 uec.h: fix COFIG_DM typo
In reply to Rasmus Villemoes--- drivers/net/qe/uec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/qe/uec.h +1 -1
@@ -678,7 +678,7 @@ struct uec_priv {int grace_stopped_tx;int grace_stopped_rx;int the_first_run; -#if !defined(COFIG_DM ) +#if !defined(CONFIG_DM )/* PHY specific */ struct uec_mii_info *mii_info;int oldspeed;
Signature · 1 line
2.23.0
PATCH 3/3 uec.h: fix COFIG_DM typo
Hello Rasmus,
Am 05.10.2020 um 15:15 schrieb Rasmus Villemoes:
Quoted 11 lines
Signed-off-by Rasmus Villemoes <[email protected]>--- drivers/net/qe/uec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/qe/uec.h +0
-0
drivers/net/qe/uec.h struct uec_priv { · line 684
Quoted 8 lines
drivers/net/qe/uec.h +1
-1@@ -678,7 +678,7 @@ struct uec_priv {int grace_stopped_tx;int grace_stopped_rx;int the_first_run; -#if !defined(COFIG_DM ) +#if !defined(CONFIG_DM )/* PHY specific */ struct uec_mii_info *mii_info;int oldspeed;
Ouch... Thanks for detecting this!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 3/3 uec.h: fix COFIG_DM typo
In reply to Rasmus VillemoesQuoted 2 lines · Rasmus Villemoes
Signed-off-by Rasmus Villemoes <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210222/dca33b3b/attachment.sig>
cover DM_ETH v mpc83xx fixups
In reply to Rasmus VillemoesHello Rasmus,
Am 05.10.2020 um 15:15 schrieb Rasmus Villemoes:
Quoted 8 lines
Hi Heiko
I finally managed to figure out what was wrong; the fixed-link phy was simply ignored. This is fixed by the first patch, though I don't know if that's the proper way to make this work.
While poking around the code I found two minor things that might as well be fixed.
Thanks for the fixes (and testing)!
Quoted 6 lines
I'd also like to do a somewhat more extensive change to
dm_qe_uec.c: I find it very confusing with theqe_uec_privversusuec_priv, so I'd like to just add a phydev member to structuec_priv, remove structqe_uec_priv, make .priv_auto_alloc_size =sizeof(struct uec_priv), and eliminate the malloc/free pair in .prove/.remove. It's mostly mechanical using coccinelle, but WDYT?
Sounds good, so please send a patch... thanks!
bye,
Heiko
Quoted 11 lines
Rasmus Villemoes (3):
mdio-uclass.c: support fixed-link subnodesdm_qe_uec.c: fix indentation inuec_set_mac_if_mode()uec.h: fixCOFIG_DMtypodrivers/net/qe/dm_qe_uec.c | 4 ++-- drivers/net/qe/uec.h | 2 +- net/mdio-uclass.c | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-)
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de