ppc: qemu: Add eTSEC support
Subsystems (4)
v2 cover ppc: qemu: Add eTSEC support
QEMU ppce500 machine can dynamically instantiate an eTSEC device if "-device eTSEC" is given to QEMU.
This series updates the fixed-link ethernet PHY driver as well as the Freescale eTSEC driver to support the QEMU ppce500 board.
3 patches related to fixed phy in v1 are dropped in v2 as the changes were done by Vladimir's fixed phy & Sandbox DSA series [1]. Vladimir's series is now included in v2, and updated as needed.
This cover letter is cc'ed to QEMU mailing list for a heads-up. A future patch will be sent to QEMU mailing list to bring its in-tree U-Boot source codes up-to-date.
This series is avaiable at u-boot-x86/eTSEC for testing.
[1] https://patchwork.ozlabs.org/project/uboot/patch/20210216224804.3355044-2-olteanv at gmail.com/
Changes in v2:
- move device tree parsing from xilinxgmiitorgmii_probe() to xilinxgmiitorgmii_config() and use OF APIs
- new patch: split from <[email protected]>
- include <asm/global_data.h>
- use a Kconfig option CONFIG_SIMPLE_BUS_CORRECT_RANGE to control the new behavior for boards that want this
- default y if SANDBOX for CONFIG_SIMPLE_BUS_CORRECT_RANGE
- turn on CONFIG_SIMPLE_BUS_CORRECT_RANGE in qemu-ppce500_defconfig
Bin Meng (17):
dt-bindings: net: Add the old DT bindings for "fixed-link"
of: extra: Introduce ofnode_phy_is_fixed_link() API
test: dm: Add a case to test ofnode_phy_is_fixed_link()
dm: mdio: Use ofnode_phy_is_fixed_link() API
net: phy: xilinx: Be compatible with live OF tree
net: phy: xilinx: Drop #ifdef CONFIG_DM_ETH around
phy_connect_gmii2rgmii()
net: phy: Simplify the logic of phy_connect_fixed()
net: phy: fixed: Make driver ops static
net: phy: fixed: Add the missing ending newline
net: phy: fixed: Support the old DT binding
dt-bindings: net: Update Freescale TSEC to support "queue-group"
net: tsec: Support <reg> property from the subnode "queue-group"
dm: core: Correctly read <ranges> of simple-bus
test: dm: Add a test case for simple-bus <ranges>
ppc: qemu: Create a virtual memory mapping of the platform bus
ppc: qemu: Enable eTSEC support
doc: board: qemu-ppce500: Document eTSEC usage
Claudiu Manoil (1):
sandbox: Add a DSA sandbox driver and unit test
Vladimir Oltean (3):
net: phy: fixed: Be compatible with live OF tree
net: phy: fixed: Drop #ifdef CONFIG_DM_ETH around phy_connect_fixed
net: tsec: Use dm_eth_phy_connect() directly for the DM case
arch/Kconfig | 2 + arch/sandbox/dts/test.dts | 59 ++++++ board/emulation/qemu-ppce500/Kconfig | 6 + board/emulation/qemu-ppce500/qemu-ppce500.c | 18 ++ configs/qemu-ppce500_defconfig | 5 + doc/board/emulation/qemu-ppce500.rst | 5 + doc/device-tree-bindings/net/fixed-link.txt | 47 +++-- doc/device-tree-bindings/net/fsl-tsec-phy.txt | 15 +- drivers/core/Kconfig | 14 ++ drivers/core/of_extra.c | 26 +++ drivers/core/simple-bus.c | 32 +++- drivers/net/Kconfig | 9 + drivers/net/Makefile | 1 + drivers/net/dsa_sandbox.c | 179 ++++++++++++++++++ drivers/net/phy/Kconfig | 1 + drivers/net/phy/fixed.c | 54 ++++-- drivers/net/phy/phy.c | 63 +++--- drivers/net/phy/xilinx_gmii2rgmii.c | 61 +++--- drivers/net/tsec.c | 32 +++- include/configs/sandbox.h | 2 + include/dm/of_extra.h | 18 ++ include/dm/simple_bus.h | 6 +- net/mdio-uclass.c | 7 +- test/dm/Makefile | 2 + test/dm/dsa.c | 82 ++++++++ test/dm/eth.c | 10 +- test/dm/of_extra.c | 18 ++ test/dm/simple-bus.c | 33 ++++ 28 files changed, 687 insertions(+), 120 deletions(-) create mode 100644 drivers/net/dsa_sandbox.c create mode 100644 test/dm/dsa.c create mode 100644 test/dm/simple-bus.c
Signature · 1 line
2.25.1
PATCH v2 1/21 dt-bindings: net: Add the old DT bindings for "fixed-link"
Per the upstream Linux kernel doc:
Documentation/devicetree/bindings/net/ethernet-controller.yaml
There are two ways to describe a fixed PHY attached to an Ethernet device. This updates our dt-bindings doc to add the old DT bindings.
---
(no changes since v1)
doc/device-tree-bindings/net/fixed-link.txt | 47 +++++++++++++++------ 1 file changed, 35 insertions(+), 12 deletions(-)
doc/device-tree-bindings/net/fixed-link.txt +35 -12
@@ -5,21 +5,36 @@ Some Ethernet MACs have a "fixed link", and are not connected to a normal MDIO-managed PHY device. For those situations, a Device Tree binding allows to describe a "fixed link". -Such a fixed link situation is described by creating a 'fixed-link' -sub-node of the Ethernet MAC device node, with the following -properties: - -* 'speed' (integer, mandatory), to indicate the link speed. Accepted - values are 10, 100 and 1000 -* 'full-duplex' (boolean, optional), to indicate that full duplex is - used. When absent, half duplex is assumed. -* 'pause' (boolean, optional), to indicate that pause should be - enabled. -* 'asym-pause' (boolean, optional), to indicate that asym_pause should - be enabled. +Note there are two ways to describe a fixed PHY attached to an +Ethernet device: + +- The new DT binding, where 'fixed-link' is a sub-node of the Ethernet + MAC device node, with the following properties: + + * 'speed' (integer, mandatory), to indicate the link speed. Accepted + values are 10, 100 and 1000 + * 'full-duplex' (boolean, optional), to indicate that full duplex is + used. When absent, half duplex is assumed. + * 'pause' (boolean, optional), to indicate that pause should be + enabled. + * 'asym-pause' (boolean, optional), to indicate that asym_pause should + be enabled. + +- The old DT binding, where 'fixed-link' is a property with 5 cells + encoding various information about the fixed PHY, in the form of + <phy_id, full-duplex, speed, pause, asym-pause>. + + * 'phy_id', emulated PHY ID, choose any but unique to the all specified + fixed-links + * 'full-duplex', 0 for half duplex or 1 for full duplex + * 'speed', link speed in Mbits/sec, accepts only 10, 100 and 1000 + * 'pause', 0 for no pause, 1 for pause + * 'asym-pause', 0 for no asymmetric pause, 1 for asymmetric pause Examples: +The new binding: + ethernet at 0 { ... fixed-link {
@@ -28,3 +43,11 @@ ethernet at 0 { }; ... }; + +The old binding: + +ethernet at 0 { + ... + fixed-link = <0 1 1000 0 0>; + ... +};
Signature · 1 line
2.25.1
PATCH v2 2/21 of: extra: Introduce ofnode_phy_is_fixed_link() API
In reply to Bin MengIntroduce a helper API ofnode_phy_is_fixed_link() to detect whether the ethernet controller connects to a fixed-link pseudo-PHY device.
Note there are two ways to describe a fixed PHY attached to an Ethernet device:
- the new DT binding, where 'fixed-link' is a sub-node of the Ethernet device
- the old DT binding, where 'fixed-link' is a property with 5 cells encoding various information about the fixed PHY
---
(no changes since v1)
drivers/core/of_extra.c | 26 ++++++++++++++++++++++++++ include/dm/of_extra.h | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+)
drivers/core/of_extra.c +26 -0
@@ -130,3 +130,29 @@ int ofnode_decode_memory_region(ofnode config_node, const char *mem_type,return 0 ; } + +bool ofnode_phy_is_fixed_link (ofnode eth_node,ofnode *phy_node) +{ +bool found = false; +ofnode node, subnode; +int len; + +/* new binding */ + subnode =ofnode_find_subnode (eth_node,"fixed-link" ); +if (ofnode_valid (subnode)) { + node = subnode; + found = true; + } + +/* old binding */ +if (ofnode_get_property (eth_node,"fixed-link" , &len) && + len == (5 *sizeof (__be32))) { + node = eth_node; + found = true; + } + +if (found && phy_node) + *phy_node = node; + +return found; +}
include/dm/of_extra.h +18 -0
@@ -86,4 +86,22 @@ int ofnode_decode_memory_region(ofnode config_node, const char *mem_type, const char *suffix, fdt_addr_t *basep, fdt_size_t *sizep); +/** +* ofnode_phy_is_fixed_link() - Detect fixed-link pseudo-PHY device +* +* This function detects whether the ethernet controller connects to a +* fixed-link pseudo-PHY device. +* +* This function supports the following two DT bindings: +* - the new DT binding, where 'fixed-link' is a sub-node of the +* Ethernet device +* - the old DT binding, where 'fixed-link' is a property with 5 +* cells encoding various information about the fixed PHY +* +* @param eth_node ofnode containing the fixed-link subnode/property +* @param phy_node if fixed-link PHY detected, containing the PHY ofnode +* @return true if a fixed-link pseudo-PHY device exists, false otherwise +*/ +bool ofnode_phy_is_fixed_link (ofnode eth_node,ofnode *phy_node); +#endif
Signature · 1 line
2.25.1
PATCH v2 3/21 test: dm: Add a case to test ofnode_phy_is_fixed_link()
In reply to Bin MengThis adds a test case to test the new ofnode_phy_is_fixed_link() API. Both the new and old DT bindings are covered.
---
(no changes since v1)
arch/sandbox/dts/test.dts | 11 +++++++++++ test/dm/of_extra.c | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+)
arch/sandbox/dts/test.dts +11 -0
@@ -478,6 +478,17 @@ fake-host-hwaddr = [00 00 66 44 22 22]; }; + fixed-link-test1 { + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + fixed-link-test2 { + fixed-link = <0 1 1000 0 0>; + }; + firmware { sandbox_firmware: sandbox-firmware { compatible = "sandbox,firmware";
test/dm/of_extra.c +18 -0
@@ -36,3 +36,21 @@ static int dm_test_ofnode_read_fmap_entry(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_ofnode_read_fmap_entry,0 ); + +static int dm_test_ofnode_phy_is_fixed_link (struct unit_test_state *uts) +{ +ofnode eth_node, phy_node, node; + + eth_node =ofnode_path ("/fixed-link-test1" ); +ut_assert (ofnode_phy_is_fixed_link (eth_node, &phy_node)); + node =ofnode_path ("/fixed-link-test1/fixed-link" ); +ut_asserteq_mem (&phy_node, &node,sizeof (ofnode)); + + eth_node =ofnode_path ("/fixed-link-test2" ); +ut_assert (ofnode_phy_is_fixed_link (eth_node, &phy_node)); + node = eth_node; +ut_asserteq_mem (&phy_node, &node,sizeof (ofnode)); + +return 0 ; +} +DM_TEST (dm_test_ofnode_phy_is_fixed_link,0 );
Signature · 1 line
2.25.1
PATCH v2 4/21 dm: mdio: Use ofnode_phy_is_fixed_link() API
In reply to Bin MengSwitch to use the ofnode_phy_is_fixed_link() API which can support both the new and old DT bindings.
---
(no changes since v1)
net/mdio-uclass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mdio-uclass.c +2 -1
@@ -11,6 +11,7 @@#include <miiphy.h> #include <dm/device-internal.h> #include <dm/device_compat.h> +#include <dm/of_extra.h> #include <dm/uclass-internal.h> #include <linux/compat.h>
@@ -140,7 +141,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,int i;if (CONFIG_IS_ENABLED (PHY_FIXED ) && -ofnode_valid (dev_read_subnode (ethdev,"fixed-link" ))) { +ofnode_phy_is_fixed_link (dev_ofnode (ethdev),NULL )) { phy =phy_connect (NULL ,-1 , ethdev, interface); goto out; }
Signature · 1 line
2.25.1
PATCH v2 5/21 net: phy: fixed: Be compatible with live OF tree
In reply to Bin MengFrom: Vladimir Oltean <[email protected]>
On systems that use CONFIG_OF_LIVE, the "ofnode" type is defined as const struct device_node *np, while on the flat DT systems it is defined as a long of_offset into gd->fdt_blob.
It is desirable that the fixed PHY driver uses the higher-level ofnode abstraction instead of parsing gd->fdt_blob directly, because that enables it to work on live OF systems.
The fixed PHY driver has used a nasty hack since its introduction in commit db40c1aa1c10 ("drivers/net/phy: add fixed-phy / fixed-link support"), which is to pass the long gd->fdt_blob offset inside int phydev->addr (a value that normally holds the MDIO bus address at which the PHY responds). Even ignoring the fact that the types were already mismatched leading to a potential truncation (flat OF offset was supposed to be a long and not an int), we really cannot extend this hack any longer, because there's no way an int will hold the other representation of ofnode, the struct device_node *np.
So we unfortunately need to do the right thing, which is to use the framework introduced by Grygorii Strashko in
commit eef0b8a930d1 ("net: phy: add ofnode node to struct phy_device"). This will populate phydev->node for the fixed PHY.
Note that phydev->node will not be valid in the probe function, since that is called synchronously from phy_device_create and we really have no way of passing the ofnode directly through the phy_device_create API. So we do what other drivers do too: we move the OF parsing logic from the .probe to the .config method of the PHY driver. The new function will be called at phy_config() time.
I do believe I've converted all the possible call paths for creating a PHY with PHY_FIXED_ID, so there is really no reason to maintain compatibility with the old logic of retrieving a flat OF tree offset from phydev->addr. We just pass 0 to phydev->addr now.
Message-Id: <[email protected]>
---
(no changes since v1)
drivers/net/phy/fixed.c | 26 +++++++++++++++++--------- drivers/net/phy/phy.c | 30 +++++++++++++++--------------- net/mdio-uclass.c | 6 ++++-- 3 files changed, 36 insertions(+), 26 deletions(-)
drivers/net/phy/fixed.c +17 -9
@@ -17,13 +17,23 @@ DECLARE_GLOBAL_DATA_PTR;int fixedphy_probe (struct phy_device *phydev) { +/* fixed-link phy must not be reset by core phy code */ + phydev->flags |=PHY_FLAG_BROKEN_RESET ; + +return 0 ; +} + +int fixedphy_config (struct phy_device *phydev) +{ +ofnode node =phy_get_ofnode (phydev);struct fixed_link *priv; -int ofnode = phydev->addr;u32 val; +if (!ofnode_valid (node)) +return -EINVAL ; +/* check for mandatory properties within fixed-link node */ - val =fdt_getprop_u32_default_node (gd->fdt_blob, - ofnode,0 ,"speed" ,0 ); + val =ofnode_read_u32_default (node,"speed" ,0 );if (val !=SPEED_10 && val !=SPEED_100 && val !=SPEED_1000 && val !=SPEED_2500 && val !=SPEED_10000 ) {printf ("ERROR: no/invalid speed given in fixed-link node!" );
@@ -38,12 +48,9 @@ int fixedphy_probe(struct phy_device *phydev) phydev->priv = priv; priv->link_speed = val; - priv->duplex =fdtdec_get_bool (gd->fdt_blob, ofnode,"full-duplex" ); - priv->pause =fdtdec_get_bool (gd->fdt_blob, ofnode,"pause" ); - priv->asym_pause =fdtdec_get_bool (gd->fdt_blob, ofnode,"asym-pause" ); - -/* fixed-link phy must not be reset by core phy code */ - phydev->flags |=PHY_FLAG_BROKEN_RESET ; + priv->duplex =ofnode_read_bool (node,"full-duplex" ); + priv->pause =ofnode_read_bool (node,"pause" ); + priv->asym_pause =ofnode_read_bool (node,"asym-pause" );return 0 ; }
@@ -72,6 +79,7 @@ static struct phy_driver fixedphy_driver = { .name = "Fixed PHY", .features = PHY_GBIT_FEATURES | SUPPORTED_MII, .probe = fixedphy_probe, + .config = fixedphy_config, .startup = fixedphy_startup, .shutdown = fixedphy_shutdown, };
drivers/net/phy/phy.c +15 -15
@@ -988,6 +988,7 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,struct phy_device *fixed_phy_create (ofnode node) {phy_interface_t interface =PHY_INTERFACE_MODE_NONE ; +struct phy_device *phydev;const char *if_str;ofnode subnode;
@@ -1004,8 +1005,11 @@ struct phy_device *fixed_phy_create(ofnode node)return NULL ; } -return phy_device_create (NULL ,ofnode_to_offset (subnode),PHY_FIXED_ID , - false, interface); + phydev =phy_device_create (NULL ,0 ,PHY_FIXED_ID , false, interface); +if (phydev) + phydev->node = subnode; + +return phydev; }#ifdef CONFIG_DM_ETH
@@ -1018,20 +1022,16 @@ static struct phy_device *phy_connect_fixed(struct mii_dev *bus, phy_interface_t interface) #endif { -struct phy_device *phydev =NULL ; -int sn; -const char *name; +ofnode node =dev_ofnode (dev), subnode; +struct phy_device *phydev; - sn =fdt_first_subnode (gd->fdt_blob,dev_of_offset (dev)); -while (sn >0 ) { - name =fdt_get_name (gd->fdt_blob, sn,NULL ); -if (name &&strcmp (name,"fixed-link" ) ==0 ) { - phydev =phy_device_create (bus, sn,PHY_FIXED_ID , false, - interface); -break ; - } - sn =fdt_next_subnode (gd->fdt_blob, sn); - } + subnode =ofnode_find_subnode (node,"fixed-link" ); +if (!ofnode_valid (subnode)) +return NULL ; + + phydev =phy_device_create (bus,0 ,PHY_FIXED_ID , false, interface); +if (phydev) + phydev->node = subnode;return phydev; }
net/mdio-uclass.c +4 -2
@@ -138,11 +138,13 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,struct udevice *mdiodev;struct phy_device *phy;struct ofnode_phandle_args phandle = {.node =ofnode_null ()}; +ofnode phynode;int i;if (CONFIG_IS_ENABLED (PHY_FIXED ) && -ofnode_phy_is_fixed_link (dev_ofnode (ethdev),NULL )) { - phy =phy_connect (NULL ,-1 , ethdev, interface); +ofnode_phy_is_fixed_link (dev_ofnode (ethdev), &phynode)) { + phy =phy_connect (NULL ,0 , ethdev, interface); + phandle.node = phynode; goto out; }
Signature · 1 line
2.25.1
PATCH v2 6/21 net: phy: fixed: Drop #ifdef CONFIG_DM_ETH around phy_connect_fixed
In reply to Bin MengFrom: Vladimir Oltean <[email protected]>
In drivers/net/phy/Kconfig, CONFIG_PHY_FIXED already depends on CONFIG_DM_ETH, so the function prototype definition when CONFIG_DM_ETH=n does nothing, so it can be dropped. It is also never reachable, since the whole function is already under #ifdef CONFIG_PHY_FIXED (which again, as I said, depends on CONFIG_DM_ETH=y).
Message-Id: <[email protected]>
---
(no changes since v1)
drivers/net/phy/phy.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/net/phy/phy.c +0 -6
@@ -1012,15 +1012,9 @@ struct phy_device *fixed_phy_create(ofnode node)return phydev; } -#ifdef CONFIG_DM_ETH static struct phy_device *phy_connect_fixed (struct mii_dev *bus,struct udevice *dev,phy_interface_t interface) -#else -static struct phy_device *phy_connect_fixed (struct mii_dev *bus, -struct eth_device *dev, - phy_interface_t interface) -#endif {ofnode node =dev_ofnode (dev), subnode;struct phy_device *phydev;
Signature · 1 line
2.25.1
PATCH v2 7/21 net: phy: xilinx: Be compatible with live OF tree
In reply to Bin MengFollowing the same updates that were done to the fixed phy driver, use ofnode_ APIs instead of fdt_ APIs so that the Xilinx PHY driver can support live DT.
---
Changes in v2:
- move device tree parsing from xilinxgmiitorgmii_probe() to xilinxgmiitorgmii_config() and use OF APIs
drivers/net/phy/phy.c | 23 +++++------ drivers/net/phy/xilinx_gmii2rgmii.c | 61 ++++++++++++++--------------- 2 files changed, 40 insertions(+), 44 deletions(-)
drivers/net/phy/phy.c +10 -13
@@ -953,23 +953,20 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,#endif {struct phy_device *phydev =NULL ; -int sn =dev_of_offset (dev); -int off; - -while (sn >0 ) { - off =fdt_node_offset_by_compatible (gd->fdt_blob, sn, -"xlnx,gmii-to-rgmii-1.0" ); -if (off >0 ) { - phydev =phy_device_create (bus, off, +ofnode node =dev_ofnode (dev); + +while (ofnode_valid (node)) { + node =ofnode_by_compatible (node,"xlnx,gmii-to-rgmii-1.0" ); +if (ofnode_valid (node)) { + phydev =phy_device_create (bus,0 ,PHY_GMII2RGMII_ID , false, interface); +if (phydev) + phydev->node = node;break ; } -if (off == -FDT_ERR_NOTFOUND ) - sn =fdt_first_subnode (gd->fdt_blob, sn); -else -printf ("%s: Error finding compat string:%d\n" , - __func__, off); + + node =ofnode_first_subnode (node); }return phydev;
drivers/net/phy/xilinx_gmii2rgmii.c +30 -31
81 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 8/21 net: phy: xilinx: Drop #ifdef CONFIG_DM_ETH around phy_connect_gmii2rgmii()
In reply to Bin MengAt present phy_connect_gmii2rgmii() is implemented using a DM API dev_of_offset() hence it cannot support a non-DM configuration. Remove the non-DM version prototype of phy_connect_gmii2rgmii() and make the driver depend on CONFIG_DM_ETH.
---
(no changes since v1)
drivers/net/phy/Kconfig | 1 + drivers/net/phy/phy.c | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/net/phy/Kconfig +1 -0
@@ -292,6 +292,7 @@ config PHY_XILINX config PHY_XILINX_GMII2RGMII bool "Xilinx GMII to RGMII Ethernet PHYs support" + depends on DM_ETH help This adds support for Xilinx GMII to RGMII IP core. This IP acts as bridge between MAC connected over GMII and external phy that
drivers/net/phy/phy.c +0 -6
@@ -942,15 +942,9 @@ void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev) }#ifdef CONFIG_PHY_XILINX_GMII2RGMII -#ifdef CONFIG_DM_ETHstatic struct phy_device *phy_connect_gmii2rgmii (struct mii_dev *bus,struct udevice *dev,phy_interface_t interface) -#else -static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus, - struct eth_device *dev, - phy_interface_t interface) -#endif {struct phy_device *phydev =NULL ;ofnode node =dev_ofnode (dev);
Signature · 1 line
2.25.1
PATCH v2 9/21 net: phy: Simplify the logic of phy_connect_fixed()
In reply to Bin MengSimplify the logic of phy_connect_fixed() by using the new API ofnode_phy_is_fixed_link(), which brings additional bonus of supporting the old DT bindings.
---
(no changes since v1)
drivers/net/phy/phy.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/phy/phy.c +8 -8
@@ -18,6 +18,7 @@#include <phy.h> #include <errno.h> #include <asm/global_data.h> +#include <dm/of_extra.h> #include <linux/bitops.h> #include <linux/delay.h> #include <linux/err.h>
@@ -1008,15 +1009,14 @@ static struct phy_device *phy_connect_fixed(struct mii_dev *bus, phy_interface_t interface) {ofnode node =dev_ofnode (dev), subnode; -struct phy_device *phydev; - - subnode =ofnode_find_subnode (node,"fixed-link" ); -if (!ofnode_valid (subnode)) -return NULL ; +struct phy_device *phydev =NULL ; - phydev =phy_device_create (bus,0 ,PHY_FIXED_ID , false, interface); -if (phydev) - phydev->node = subnode; +if (ofnode_phy_is_fixed_link (node, &subnode)) { + phydev =phy_device_create (bus,0 ,PHY_FIXED_ID , + false, interface); +if (phydev) + phydev->node = subnode; + }return phydev; }
Signature · 1 line
2.25.1
PATCH v2 10/21 net: phy: fixed: Make driver ops static
In reply to Bin MengThe PHY driver ops should be made static.
---
(no changes since v1)
drivers/net/phy/fixed.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/phy/fixed.c +4 -4
@@ -15,7 +15,7 @@DECLARE_GLOBAL_DATA_PTR ; -int fixedphy_probe (struct phy_device *phydev) +static int fixedphy_probe (struct phy_device *phydev) {/* fixed-link phy must not be reset by core phy code */ phydev->flags |=PHY_FLAG_BROKEN_RESET ;
@@ -23,7 +23,7 @@ int fixedphy_probe(struct phy_device *phydev)return 0 ; } -int fixedphy_config (struct phy_device *phydev) +static int fixedphy_config (struct phy_device *phydev) {ofnode node =phy_get_ofnode (phydev);struct fixed_link *priv;
@@ -55,7 +55,7 @@ int fixedphy_config(struct phy_device *phydev)return 0 ; } -int fixedphy_startup (struct phy_device *phydev) +static int fixedphy_startup (struct phy_device *phydev) {struct fixed_link *priv = phydev->priv;
@@ -68,7 +68,7 @@ int fixedphy_startup(struct phy_device *phydev)return 0 ; } -int fixedphy_shutdown (struct phy_device *phydev) +static int fixedphy_shutdown (struct phy_device *phydev) {return 0 ; }
Signature · 1 line
2.25.1
PATCH v2 11/21 net: phy: fixed: Add the missing ending newline
In reply to Bin MengThe printf statement doesn't end with a newline. Add it.
---
(no changes since v1)
drivers/net/phy/fixed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/fixed.c +1 -1
@@ -36,7 +36,7 @@ static int fixedphy_config(struct phy_device *phydev) val =ofnode_read_u32_default (node,"speed" ,0 );if (val !=SPEED_10 && val !=SPEED_100 && val !=SPEED_1000 && val !=SPEED_2500 && val !=SPEED_10000 ) { -printf ("ERROR: no/invalid speed given in fixed-link node!" ); +printf ("ERROR: no/invalid speed given in fixed-link node!\n" );return -EINVAL ; }
Signature · 1 line
2.25.1
PATCH v2 12/21 net: phy: fixed: Support the old DT binding
In reply to Bin MengUpdate fixedphy_probe() to support the old DT binding.
---
(no changes since v1)
drivers/net/phy/fixed.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
drivers/net/phy/fixed.c +23 -3
@@ -27,13 +27,27 @@ static int fixedphy_config(struct phy_device *phydev) {ofnode node =phy_get_ofnode (phydev);struct fixed_link *priv; +bool old_binding = false;u32 val; +u32 old_val[5 ];if (!ofnode_valid (node))return -EINVAL ;/* check for mandatory properties within fixed-link node */ val =ofnode_read_u32_default (node,"speed" ,0 ); + +if (!val) { +/* try old binding */ + old_binding = true; +if (ofnode_read_u32_array (node,"fixed-link" , old_val, +ARRAY_SIZE (old_val))) { +printf ("ERROR: no/invalid <fixed-link> property!\n" ); +return -ENOENT ; + } + val = old_val[2 ]; + } +if (val !=SPEED_10 && val !=SPEED_100 && val !=SPEED_1000 && val !=SPEED_2500 && val !=SPEED_10000 ) {printf ("ERROR: no/invalid speed given in fixed-link node!\n" );
@@ -48,9 +62,15 @@ static int fixedphy_config(struct phy_device *phydev) phydev->priv = priv; priv->link_speed = val; - priv->duplex =ofnode_read_bool (node,"full-duplex" ); - priv->pause =ofnode_read_bool (node,"pause" ); - priv->asym_pause =ofnode_read_bool (node,"asym-pause" ); +if (!old_binding) { + priv->duplex =ofnode_read_bool (node,"full-duplex" ); + priv->pause =ofnode_read_bool (node,"pause" ); + priv->asym_pause =ofnode_read_bool (node,"asym-pause" ); + }else { + priv->duplex = old_val[1 ]; + priv->pause = old_val[3 ]; + priv->asym_pause = old_val[4 ]; + }return 0 ; }
Signature · 1 line
2.25.1
PATCH v2 13/21 net: tsec: Use dm_eth_phy_connect() directly for the DM case
In reply to Bin MengFrom: Vladimir Oltean <[email protected]>
Now that the fixed phy driver has been fully adapted to OF APIs, and dm_eth_phy_connect() already can handle the fixed phy, call dm_eth_phy_connect() directly in the DM tsec driver.
Message-Id: <[email protected]>
---
Changes in v2:
- new patch: split from <[email protected]>
drivers/net/tsec.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/tsec.c +1 -5
@@ -707,11 +707,7 @@ static int init_phy(struct tsec_private *priv)tsec_configure_serdes (priv);#if defined(CONFIG_DM_ETH ) && defined(CONFIG_DM_MDIO ) -if (ofnode_valid (ofnode_find_subnode (dev_ofnode (priv->dev), -"fixed-link" ))) - phydev =phy_connect (NULL ,0 , priv->dev, priv->interface); -else - phydev =dm_eth_phy_connect (priv->dev); + phydev =dm_eth_phy_connect (priv->dev);#else phydev =phy_connect (priv->bus, priv->phyaddr, priv->dev, priv->interface);
Signature · 1 line
2.25.1
PATCH v2 14/21 sandbox: Add a DSA sandbox driver and unit test
In reply to Bin MengFrom: Claudiu Manoil <[email protected]>
The DSA sandbox driver is used for unit testing the DSA class code. It implements a simple 2 port switch plus 1 CPU port, and uses a very simple tag to identify the ports.
The DSA sandbox device is connected via CPU port to a regular Ethernet sandbox device, called 'dsa-test-eth, managed by the existing eth sandbox driver. The 'dsa-test-eth' is not intended for testing the eth class code however, but it is used to emulate traffic through the 'lan0' and 'lan1' front pannel switch ports. To achieve this the dsa sandbox driver registers a tx handler for the 'dsa-test-eth' device. The switch ports, labeled as 'lan0' and 'lan1', are also registered as eth devices by the dsa class code this time. So pinging through these switch ports is as easy as:
=> setenv ethact lan0
=> ping 1.2.3.5
Unit tests for the dsa class code were also added. The 'dsa_probe' test exercises most API functions from dsa.h. The 'dsa' unit test simply exercises ARP/ICMP traffic through the two switch ports, including tag injection and extraction, with the help of the dsa sandbox driver.
I took care to minimize the impact on the existing eth unit tests, though some adjustments needed to be made with the addition of extra eth interfaces used by the dsa unit tests. The additional eth interfaces also require MAC addresses, these have been added to the sandbox default environment.
Message-Id: <[email protected]>
---
(no changes since v1)
arch/Kconfig | 2 + arch/sandbox/dts/test.dts | 48 ++++++++++ drivers/net/Kconfig | 9 ++ drivers/net/Makefile | 1 + drivers/net/dsa_sandbox.c | 179 ++++++++++++++++++++++++++++++++++++++ include/configs/sandbox.h | 2 + test/dm/Makefile | 1 + test/dm/dsa.c | 82 +++++++++++++++++ test/dm/eth.c | 10 +-- 9 files changed, 329 insertions(+), 5 deletions(-) create mode 100644 drivers/net/dsa_sandbox.c create mode 100644 test/dm/dsa.c
arch/Kconfig +2 -0
@@ -160,6 +160,8 @@ config SANDBOX imply CMD_CLONE imply SILENT_CONSOLE imply BOOTARGS_SUBST + imply PHY_FIXED + imply DM_DSA config SH bool "SuperH architecture"
arch/sandbox/dts/test.dts +48 -0
61 lines not on this page · raw message
drivers/net/Kconfig +9 -0
@@ -78,6 +78,15 @@ config DM_ETH_PHY help Enable driver model for Ethernet Generic PHY . +config DSA_SANDBOX + depends on DM_DSA && SANDBOX + default y + bool "Sandbox: Mocked DSA driver" + help + This driver implements a dummy DSA switch connected to a dummy sandbox + Ethernet device used as DSA master, to test DSA class code, including + exported DSA API and datapath processing of Ethernet traffic. + menuconfig NETDEVICES bool "Network device support" depends on NET
drivers/net/Makefile +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o obj-$(CONFIG_ETH_DESIGNWARE_S700) += dwmac_s700.o obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o obj-$(CONFIG_DNET) += dnet.o +obj-$(CONFIG_DSA_SANDBOX) += dsa_sandbox.o obj-$(CONFIG_DM_ETH_PHY) += eth-phy-uclass.o obj-$(CONFIG_E1000) += e1000.o obj-$(CONFIG_E1000_SPI) += e1000_spi.o
drivers/net/dsa_sandbox.c new file +179 -0
179 lines not on this page · raw message
include/configs/sandbox.h +2 -0
@@ -93,7 +93,9 @@#endif #define SANDBOX_ETH_SETTINGS "ethaddr=00:00:11:22:33:44\0" \ + "eth2addr=00:00:11:22:33:48\0" \ "eth3addr=00:00:11:22:33:45\0" \ + "eth4addr=00:00:11:22:33:48\0" \ "eth5addr=00:00:11:22:33:46\0" \ "eth6addr=00:00:11:22:33:47\0" \ "ipaddr=1.2.3.4\0"
test/dm/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_CLK) += clk.o clk_ccf.o obj-$(CONFIG_CROS_EC) += cros_ec.o obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o +obj-$(CONFIG_DM_DSA) += dsa.o obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_FIRMWARE) += firmware.o obj-$(CONFIG_DM_GPIO) += gpio.o
test/dm/dsa.c new file +82 -0
82 lines not on this page · raw message
test/dm/eth.c +5 -5
@@ -53,8 +53,8 @@ static int dm_test_eth_alias(struct unit_test_state *uts)ut_assertok (net_loop (PING ));ut_asserteq_str ("eth at 10004000" ,env_get ("ethact" )); -/* Expected to fail since eth2 is not defined in the device tree */ -env_set ("ethact" ,"eth2" ); +/* Expected to fail since eth1 is not defined in the device tree */ +env_set ("ethact" ,"eth1" );ut_assertok (net_loop (PING ));ut_asserteq_str ("eth at 10002000" ,env_get ("ethact" ));
@@ -227,7 +227,7 @@ static int _dm_test_net_retry(struct unit_test_state *uts)* the active device should be eth0 */ sandbox_eth_disable_response (1 , true); -env_set ("ethact" ,"eth at 10004000" ); +env_set ("ethact" ,"lan1" );env_set ("netretry" ,"yes" );sandbox_eth_skip_timeout ();ut_assertok (net_loop (PING ));
@@ -237,11 +237,11 @@ static int _dm_test_net_retry(struct unit_test_state *uts)* eth1 is disabled and netretry is no, so the ping should fail and the * active device should be eth1 */ -env_set ("ethact" ,"eth at 10004000" ); +env_set ("ethact" ,"lan1" );env_set ("netretry" ,"no" );sandbox_eth_skip_timeout ();ut_asserteq (-ENONET ,net_loop (PING )); -ut_asserteq_str ("eth at 10004000" ,env_get ("ethact" )); +ut_asserteq_str ("lan1" ,env_get ("ethact" ));return 0 ; }
Signature · 1 line
2.25.1
PATCH v2 15/21 dt-bindings: net: Update Freescale TSEC to support "queue-group"
In reply to Bin MengAt present the Freescale TSEC node DT bindings doc requires a <reg> property in the TSEC node. But this might not always be the case. In the upstream Linux kernel, there is no DT bindings doc for it but the kernel driver tests a subnode of a name prefixed with "queue-group", as we can see from gfar_of_init():
for_each_available_child_of_node(np, child) {
if (!of_node_name_eq(child, "queue-group"))
...in drivers/net/ethernet/freescale/gianfar.c
Update our DT bindings to describe this alternate description.
---
(no changes since v1)
doc/device-tree-bindings/net/fsl-tsec-phy.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
doc/device-tree-bindings/net/fsl-tsec-phy.txt +14 -1
@@ -3,7 +3,9 @@ Properties: - compatible : Should be "fsl,etsec2" or "gianfar" - - reg : Offset and length of the register set for the device + - reg : Offset and length of the register set for the device. If this is + missing, a subnode with a name prefix "queue-group" must be provided to + provide the <reg> property. - phy-handle : See ethernet.txt file in the same directory. - phy-connection-type : See ethernet.txt file in the same directory. This property is only really needed if the connection is of type "rgmii-id",
@@ -18,6 +20,17 @@ Example: phy-connection-type = "sgmii"; }; +An alternate description with "queue-group" subnode example: + ethernet at 24000 { + compatible = "fsl,etsec2"; + phy-handle = <&phy0>; + phy-connection-type = "sgmii"; + + queue-group { + reg = <0x24000 0x1000>; + }; + }; + Child nodes of the TSEC controller are typically the individual PHY devices connected via the MDIO bus (sometimes the MDIO bus controller is separate).
Signature · 1 line
2.25.1
PATCH v2 16/21 net: tsec: Support <reg> property from the subnode "queue-group"
In reply to Bin MengAt present the tsec driver uses a non-standard DT bindings to get its <reg> base / size. The upstream Linux kernel seems to require the <reg> base / size to be put under a subnode of the eTSEC node with a name prefix "queue-group". This is not documented in the kernel DT bindings, but it looks every dtsi file that contains the eTSEC node was written like this.
This commit updates the tsec driver to handle this case.
---
(no changes since v1)
drivers/net/tsec.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/net/tsec.c +24 -2
@@ -827,13 +827,35 @@ int tsec_probe(struct udevice *dev)struct tsec_data *data;const char *phy_mode;fdt_addr_t reg; -ofnode parent; +ofnode parent, child;int ret; data = (struct tsec_data *)dev_get_driver_data (dev); pdata->iobase = (phys_addr_t )dev_read_addr (dev); - priv->regs =dev_remap_addr (dev); +if (pdata->iobase !=FDT_ADDR_T_NONE ) { + priv->regs =dev_remap_addr (dev); + }else { +ofnode_for_each_subnode (child,dev_ofnode (dev)) { +if (!strncmp (ofnode_get_name (child),"queue-group" , +strlen ("queue-group" ))) { + reg =ofnode_get_addr (child); +if (reg ==FDT_ADDR_T_NONE ) { +printf ("No 'reg' property of <queue-group>\n" ); +return -ENOENT ; + } + pdata->iobase = reg; + priv->regs =map_physmem (pdata->iobase,0 , +MAP_NOCACHE ); +break ; + } + } + +if (!ofnode_valid (child)) { +printf ("No child node for <queue-group>?\n" ); +return -ENOENT ; + } + } ret =dev_read_phandle_with_args (dev,"tbi-handle" ,NULL ,0 ,0 , &phandle_args);
Signature · 1 line
2.25.1
PATCH v2 17/21 dm: core: Correctly read <ranges> of simple-bus
In reply to Bin MengAt present we decode simple bus <ranges> using the following assumption:
- parent #address-cells 1
- child #address-cells 1
- child #size-cells 1
However this might not always be the case.
Update to use fdt_addr_t and fdt_size_t in 'struct simple_bus_plat', and use fdt_read_ranges() to correctly decode it according to the actual parent and child #address-cells / #size-cells under a Kconfig option CONFIG_SIMPLE_BUS_CORRECT_RANGE which can be turned on for any board that needs it.
---
Changes in v2:
- include <asm/global_data.h>
- use a Kconfig option CONFIG_SIMPLE_BUS_CORRECT_RANGE to control the new behavior for boards that want this
drivers/core/Kconfig | 13 +++++++++++++ drivers/core/simple-bus.c | 32 +++++++++++++++++++++++++------- include/dm/simple_bus.h | 6 +++--- 3 files changed, 41 insertions(+), 10 deletions(-)
drivers/core/Kconfig +13 -0
@@ -235,6 +235,19 @@ config SPL_SIMPLE_BUS Supports the 'simple-bus' driver, which is used on some systems in SPL. +config SIMPLE_BUS_CORRECT_RANGE + bool "Decode the 'simple-bus' <range> by honoring the #address-cells and #size-cells" + depends on SIMPLE_BUS + help + Decoding the 'simple-bus' <range> by honoring the #address-cells + and #size-cells of parent/child bus. If unset, #address-cells of + parent bus is assumed to be 1, #address-cells and #size-cells of + child bus is also assumed to be 1, to save some spaces of using + an advanced API to decode the <range>, which benefits SPL image + builds that have size limits. + + If you are unsure about this, Say N here. + config SIMPLE_PM_BUS bool "Support simple-pm-bus driver" depends on DM && OF_CONTROL && CLK && POWER_DOMAIN
drivers/core/simple-bus.c +25 -7
@@ -4,8 +4,12 @@*/ #include <common.h> +#include <asm/global_data.h> #include <dm.h> #include <dm/simple_bus.h> +#include <fdt_support.h> + +DECLARE_GLOBAL_DATA_PTR ;fdt_addr_t simple_bus_translate (struct udevice *dev,fdt_addr_t addr) {
@@ -22,16 +26,30 @@ static int simple_bus_post_bind(struct udevice *dev)#if CONFIG_IS_ENABLED (OF_PLATDATA )return 0 ;#else -u32 cell[3 ]; +struct simple_bus_plat *plat =dev_get_uclass_plat (dev);int ret; - ret =dev_read_u32_array (dev,"ranges" , cell,ARRAY_SIZE (cell)); -if (!ret) { -struct simple_bus_plat *plat =dev_get_uclass_plat (dev); +if (CONFIG_IS_ENABLED (SIMPLE_BUS_CORRECT_RANGE )) { +uint64_t caddr, paddr, len; + +/* only read range index 0 */ + ret =fdt_read_range ((void *)gd->fdt_blob,dev_of_offset (dev), +0 , &caddr, &paddr, &len); +if (!ret) { + plat->base = caddr; + plat->target = paddr; + plat->size = len; + } + }else { +u32 cell[3 ]; - plat->base = cell[0 ]; - plat->target = cell[1 ]; - plat->size = cell[2 ]; + ret =dev_read_u32_array (dev,"ranges" , cell, +ARRAY_SIZE (cell)); +if (!ret) { + plat->base = cell[0 ]; + plat->target = cell[1 ]; + plat->size = cell[2 ]; + } }return dm_scan_fdt_dev (dev);
include/dm/simple_bus.h +3 -3
@@ -7,9 +7,9 @@#define __DM_SIMPLE_BUS_Hstruct simple_bus_plat { -u32 base; -u32 size; -u32 target; +fdt_addr_t base; +fdt_size_t size; +fdt_addr_t target; };#endif
Signature · 1 line
2.25.1
PATCH v2 18/21 test: dm: Add a test case for simple-bus <ranges>
In reply to Bin MengThis adds a test case to verify reading <ranges> of a simple-bus is working as expected.
---
Changes in v2:
- default y if SANDBOX for CONFIG_SIMPLE_BUS_CORRECT_RANGE
drivers/core/Kconfig | 1 + test/dm/Makefile | 1 + test/dm/simple-bus.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 test/dm/simple-bus.c
drivers/core/Kconfig +1 -0
@@ -238,6 +238,7 @@ config SPL_SIMPLE_BUS config SIMPLE_BUS_CORRECT_RANGE bool "Decode the 'simple-bus' <range> by honoring the #address-cells and #size-cells" depends on SIMPLE_BUS + default y if SANDBOX help Decoding the 'simple-bus' <range> by honoring the #address-cells and #size-cells of parent/child bus. If unset, #address-cells of
test/dm/Makefile +1 -0
@@ -90,6 +90,7 @@ obj-$(CONFIG_DM_MDIO) += mdio.o obj-$(CONFIG_DM_MDIO_MUX) += mdio_mux.o obj-$(CONFIG_DM_RNG) += rng.o obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o +obj-$(CONFIG_SIMPLE_BUS) += simple-bus.o obj-$(CONFIG_SIMPLE_PM_BUS) += simple-pm-bus.o obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o obj-$(CONFIG_SCMI_FIRMWARE) += scmi.o
test/dm/simple-bus.c new file +33 -0
@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021, Bin Meng <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <dm/test.h> +#include <dm/simple_bus.h> +#include <dm/uclass-internal.h> +#include <test/ut.h> + +static int dm_test_simple_bus (struct unit_test_state *uts) +{ +struct udevice *dev; +struct simple_bus_plat *plat; + +/* locate the dummy device @ translation-test node */ +ut_assertok (uclass_find_device_by_seq (UCLASS_TEST_DUMMY ,0 , &dev)); +ut_asserteq_str ("dev at 0,0" , dev->name); + +/* locate the parent node which is a simple-bus */ +ut_assertnonnull (dev =dev_get_parent (dev)); +ut_asserteq_str ("translation-test at 8000" , dev->name); + +ut_assertnonnull (plat =dev_get_uclass_plat (dev)); +ut_asserteq (0 , plat->base); +ut_asserteq (0x8000 , plat->target); +ut_asserteq (0x1000 , plat->size); + +return 0 ; +} +DM_TEST (dm_test_simple_bus,UT_TESTF_SCAN_FDT |UT_TESTF_FLAT_TREE );
Signature · 1 line
2.25.1
PATCH v2 19/21 ppc: qemu: Create a virtual memory mapping of the platform bus
In reply to Bin MengQEMU ppce500 target can dynamically instantiate an eTSEC device on a platform bus if "-device eTSEC" is given to QEMU. It is presented as a "simple-bus" in the device tree, with an additional compatible string "qemu,platform".
Let's create a virtual memory mapping for it in misc_init_r(), in preparation to adding eTSEC support.
---
Changes in v2:
- turn on CONFIG_SIMPLE_BUS_CORRECT_RANGE in qemu-ppce500_defconfig
board/emulation/qemu-ppce500/Kconfig | 6 ++++++ board/emulation/qemu-ppce500/qemu-ppce500.c | 18 ++++++++++++++++++ configs/qemu-ppce500_defconfig | 1 + 3 files changed, 25 insertions(+)
board/emulation/qemu-ppce500/Kconfig +6 -0
@@ -9,4 +9,10 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "qemu-ppce500" +config PLATFORM_BUS_MAP_ADDR + hex + default 0xf0000000 + help + The QEMU platform bus base mapped address in the virtual memory space. + endif
board/emulation/qemu-ppce500/qemu-ppce500.c +18 -0
@@ -14,6 +14,8 @@#include <net.h> #include <pci.h> #include <time.h> +#include <dm/simple_bus.h> +#include <dm/uclass-internal.h> #include <asm/global_data.h> #include <asm/processor.h> #include <asm/mmu.h>
@@ -148,6 +150,22 @@ int misc_init_r(void)*/ disable_tlb (find_tlb_idx ((void *)CONFIG_SYS_TMPVIRT ,1 )); +/* +* Detect the presence of the platform bus node, and +* create a virtual memory mapping for it. +*/ +for (ret =uclass_find_first_device (UCLASS_SIMPLE_BUS , &dev); + dev; + ret =uclass_find_next_device (&dev)) { +if (device_is_compatible (dev,"qemu,platform" )) { +struct simple_bus_plat *plat =dev_get_uclass_plat (dev); + +assert (!tlb_map_range (CONFIG_PLATFORM_BUS_MAP_ADDR , + plat->target, plat->size, +TLB_MAP_IO )); + } + } +return 0 ; }
configs/qemu-ppce500_defconfig +1 -0
@@ -28,6 +28,7 @@ CONFIG_OF_BOARD=y CONFIG_ENV_OVERWRITE=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_DM=y +CONFIG_SIMPLE_BUS_CORRECT_RANGE=y CONFIG_BLK=y CONFIG_HAVE_BLOCK_DEVICE=y CONFIG_MPC8XXX_GPIO=y
Signature · 1 line
2.25.1
PATCH v2 20/21 ppc: qemu: Enable eTSEC support
In reply to Bin MengQEMU ppce500 target can dynamically instantiate an eTSEC device if "-device eTSEC" is given to QEMU. This commit enables eTSEC driver and the required fixed PHY driver to create a usable network configuration using eTSEC.
Unlike a real world 85xx board that usually stores the eTSEC MAC address in an EEPROM, CONFIG_NET_RANDOM_ETHADDR is required for QEMU otherwise U-Boot ethernet initialization complains no valid ethernet address is set.
---
(no changes since v1)
configs/qemu-ppce500_defconfig | 4 ++++ 1 file changed, 4 insertions(+)
configs/qemu-ppce500_defconfig +4 -0
@@ -27,6 +27,7 @@ CONFIG_OF_CONTROL=y CONFIG_OF_BOARD=y CONFIG_ENV_OVERWRITE=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_DM=y CONFIG_SIMPLE_BUS_CORRECT_RANGE=y CONFIG_BLK=y
@@ -35,8 +36,11 @@ CONFIG_MPC8XXX_GPIO=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_FSL=y # CONFIG_MMC is not set +CONFIG_PHY_FIXED=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_E1000=y +CONFIG_TSEC_ENET=y CONFIG_DM_PCI=y CONFIG_PCI_MPC85XX=y CONFIG_DM_RTC=y
Signature · 1 line
2.25.1
PATCH v2 21/21 doc: board: qemu-ppce500: Document eTSEC usage
In reply to Bin MengDocument how to launch a QEMU session with eTSEC as a network device.
---
(no changes since v1)
doc/board/emulation/qemu-ppce500.rst | 5 +++++ 1 file changed, 5 insertions(+)
doc/board/emulation/qemu-ppce500.rst +5 -0
@@ -70,6 +70,11 @@ interface at PCI address 0.1.0, but we can switch that to an e1000 NIC by:: $ qemu-system-ppc -nographic -machine ppce500 -bios u-boot \ -nic tap,ifname=tap0,script=no,downscript=no,model=e1000 +The QEMU ppce500 machine can also dynamically instantiate an eTSEC device if +"-device eTSEC" is given to QEMU:: + + -netdev tap,ifname=tap0,script=no,downscript=no,id=net0 -device eTSEC,netdev=net0 + VirtIO BLK driver is also enabled to support booting from a disk image where a kernel image is stored. Append the following to QEMU::
Signature · 1 line
2.25.1
PATCH v2 7/21 net: phy: xilinx: Be compatible with live OF tree
In reply to Bin Meng+Karthik/Ashok
Quoted 133 lines · Bin Meng
Following the same updates that were done to the fixed phy driver, use
ofnode_APIs instead offdt_APIs so that the Xilinx PHY driver can support live DT.Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- move device tree parsing fromxilinxgmiitorgmii_probe()toxilinxgmiitorgmii_config()and use OF APIsdrivers/net/phy/phy.c | 23 +++++------ drivers/net/phy/xilinx_gmii2rgmii.c | 61 ++++++++++++++--------------- 2 files changed, 40 insertions(+), 44 deletions(-)drivers/net/phy/phy.c +10
-13@@ -953,23 +953,20 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,#endif {struct phy_device *phydev =NULL ; -int sn =dev_of_offset (dev); -int off; - -while (sn >0 ) { - off =fdt_node_offset_by_compatible (gd->fdt_blob, sn, -"xlnx,gmii-to-rgmii-1.0" ); -if (off >0 ) { - phydev =phy_device_create (bus, off, +ofnode node =dev_ofnode (dev); + +while (ofnode_valid (node)) { + node =ofnode_by_compatible (node,"xlnx,gmii-to-rgmii-1.0" ); +if (ofnode_valid (node)) { + phydev =phy_device_create (bus,0 ,PHY_GMII2RGMII_ID , false, interface); +if (phydev) + phydev->node = node;break ; } -if (off == -FDT_ERR_NOTFOUND ) - sn =fdt_first_subnode (gd->fdt_blob, sn); -else -printf ("%s: Error finding compat string:%d\n" , - __func__, off); + + node =ofnode_first_subnode (node); }return phydev;drivers/net/phy/xilinx_gmii2rgmii.c +30
-24@@ -18,9 +18,38 @@ DECLARE_GLOBAL_DATA_PTR;static int xilinxgmiitorgmii_config (struct phy_device *phydev) { -struct phy_device *ext_phydev = phydev->priv; +ofnode node =phy_get_ofnode (phydev); +struct phy_device *ext_phydev; +struct ofnode_phandle_args phandle; +int ext_phyaddr =-1 ; +int ret;debug ("%s\n" , __func__); + +if (!ofnode_valid (node)) +return -EINVAL ; + + phydev->addr =ofnode_read_u32_default (node,"reg" ,-1 ); + ret =ofnode_parse_phandle_with_args (node,"phy-handle" , +NULL ,0 ,0 , &phandle); +if (ret) +return ret; + + ext_phyaddr =ofnode_read_u32_default (phandle.node,"reg" ,-1 ); + ext_phydev =phy_find_by_mask (phydev->bus, +1 << ext_phyaddr, +PHY_INTERFACE_MODE_RGMII ); +if (!ext_phydev) { +printf ("%s, No external phy device found\n" , __func__); +return -EINVAL ; + } + + ext_phydev->node = phandle.node; + phydev->priv = ext_phydev; + +debug ("%s, gmii2rgmmi:0x%x, extphy:0x%x\n" , __func__, phydev->addr, + ext_phyaddr); +if (ext_phydev->drv->config) ext_phydev->drv->config (ext_phydev);@@ -83,11 +112,6 @@ static int xilinxgmiitorgmii_startup(struct phy_device *phydev)static int xilinxgmiitorgmii_probe (struct phy_device *phydev) { -int ofnode = phydev->addr; -u32 phy_of_handle; -int ext_phyaddr =-1 ; -struct phy_device *ext_phydev; -debug ("%s\n" , __func__);if (phydev->interface !=PHY_INTERFACE_MODE_GMII ) {@@ -95,31 +119,6 @@ static int xilinxgmiitorgmii_probe(struct phy_device *phydev)return -EINVAL ; } -/* -* Read the phy address again as the one we read in ethernet driver -* was overwritten for the purpose of storing the ofnode -*/ - phydev->addr =fdtdec_get_int (gd->fdt_blob, ofnode,"reg" ,-1 ); - phy_of_handle =fdtdec_lookup_phandle (gd->fdt_blob, ofnode, -"phy-handle" ); -if (phy_of_handle >0 ) - ext_phyaddr =fdtdec_get_int (gd->fdt_blob, - phy_of_handle, -"reg" ,-1 ); - ext_phydev =phy_find_by_mask (phydev->bus, -1 << ext_phyaddr, -PHY_INTERFACE_MODE_RGMII ); -if (!ext_phydev) { -printf ("%s, No external phy device found\n" , __func__); -return -EINVAL ; - }
drivers/net/phy/xilinx_gmii2rgmii.c static int xilinxgmiitorgmii_probe(struct phy_device *phydev) · line 124
Quoted 10 lines
drivers/net/phy/xilinx_gmii2rgmii.c +0
-7- - ext_phydev->node =offset_to_ofnode (phy_of_handle); - phydev->priv = ext_phydev; - -debug ("%s, gmii2rgmmi:0x%x, extphy:0x%x\n" , __func__, phydev->addr, - ext_phyaddr); - phydev->flags |=PHY_FLAG_BROKEN_RESET ;return 0 ;
Karthik/Ashok: Please retest it.
Thanks,
Michal
v2 cover ppc: qemu: Add eTSEC support
In reply to Bin MengQuoted 19 lines · Bin Meng
QEMU ppce500 machine can dynamically instantiate an eTSEC device if "-device eTSEC" is given to QEMU.
This series updates the fixed-link ethernet PHY driver as well as the Freescale eTSEC driver to support the QEMU ppce500 board.
3 patches related to fixed phy in v1 are dropped in v2 as the changes were done by Vladimir's fixed phy & Sandbox DSA series [1]. Vladimir's series is now included in v2, and updated as needed.
This cover letter is cc'ed to QEMU mailing list for a heads-up. A future patch will be sent to QEMU mailing list to bring its in-tree U-Boot source codes up-to-date.
This series is avaiable at u-boot-x86/eTSEC for testing.
[1] https://patchwork.ozlabs.org/project/uboot/patch/20210216224804.3355044-2-olteanv at gmail.com/
Quoted 9 lines
Changes in v2:
- move device tree parsing fromxilinxgmiitorgmii_probe()toxilinxgmiitorgmii_config()and use OF APIs
- new patch: split from <[email protected]>
- include <asm/global_data.h>
- use aKconfigoptionCONFIG_SIMPLE_BUS_CORRECT_RANGEto control the new behavior for boards that want this
- default y if SANDBOX forCONFIG_SIMPLE_BUS_CORRECT_RANGE
- turn onCONFIG_SIMPLE_BUS_CORRECT_RANGEin qemu-ppce500_defconfig
Azure results: PASS
https://dev.azure.com/bmeng/GitHub/_build/results?buildId=340&view=results
PATCH v2 17/21 dm: core: Correctly read <ranges> of simple-bus
In reply to Bin MengQuoted 24 lines · Bin Meng
At present we decode simple bus <ranges> using the following assumption:
- parent #address-cells 1
- child #address-cells 1
- child #size-cells 1However this might not always be the case.
Update to use
fdt_addr_tandfdt_size_tin 'structsimple_bus_plat', and usefdt_read_ranges()to correctly decode it according to the actual parent and child #address-cells / #size-cells under aKconfigoptionCONFIG_SIMPLE_BUS_CORRECT_RANGEwhich can be turned on for any board that needs it.Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- include <asm/global_data.h>
- use aKconfigoptionCONFIG_SIMPLE_BUS_CORRECT_RANGEto control the new behavior for boards that want this
Quoted 4 lines
drivers/core/Kconfig | 13 +++++++++++++ drivers/core/simple-bus.c | 32 +++++++++++++++++++++++++------- include/dm/simple_bus.h | 6 +++--- 3 files changed, 41 insertions(+), 10 deletions(-)
PATCH v2 1/21 dt-bindings: net: Add the old DT bindings for "fixed-link"
In reply to Bin MengQuoted 10 lines · Bin Meng
Per the upstream Linux kernel doc:
Documentation/devicetree/bindings/net/ethernet-controller.yamlThere are two ways to describe a fixed PHY attached to an Ethernet device. This updates our dt-bindings doc to add the old DT bindings.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
Why?
Do we even parse the old-style bindings? And if so, where?
PATCH v2 2/21 of: extra: Introduce ofnode_phy_is_fixed_link() API
In reply to Bin MengQuoted 6 lines · Bin Meng
Introduce a helper API
ofnode_phy_is_fixed_link()to detect whether the ethernet controller connects to a fixed-link pseudo-PHY device.Note there are two ways to describe a fixed PHY attached to an Ethernet device:
Quoted 8 lines
- the new DT binding, where 'fixed-link' is a sub-node of the Ethernet device
- the old DT binding, where 'fixed-link' is a property with 5 cells encoding various information about the fixed PHYSigned-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
I ran a 'grep -r "ofnode_get_property.*fixed-link" .' and saw no in-tree users of the old binding. Why do we bother to be compatible with something which isn't used?
PATCH v2 2/21 of: extra: Introduce ofnode_phy_is_fixed_link() API
Quoted 12 lines · Vladimir Oltean
Quoted 11 lines · Bin Meng
Introduce a helper API
ofnode_phy_is_fixed_link()to detect whether the ethernet controller connects to a fixed-link pseudo-PHY device.Note there are two ways to describe a fixed PHY attached to an Ethernet device:
- the new DT binding, where 'fixed-link' is a sub-node of the Ethernet device
- the old DT binding, where 'fixed-link' is a property with 5 cells encoding various information about the fixed PHY
Quoted 7 lines
Quoted 3 lines
Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
I ran a 'grep -r "ofnode_get_property.*fixed-link" .' and saw no in-tree users of the old binding. Why do we bother to be compatible with something which isn't used?
Ah, I see what's going on.
QEMU fixes up the device tree here:
https://github.com/qemu/qemu/blob/master/hw/ppc/e500.c#L239
and adds an old-style fixed-link binding.
Can't you modify it to add a new-style fixed-link property? It's not like you didn't have to modify it for the "ranges" property too :)
https://github.com/qemu/qemu/commit/e5943b00d35efc68ca72ed304cfca98a9f3a647c
PATCH v2 15/21 dt-bindings: net: Update Freescale TSEC to support "queue-group"
In reply to Bin MengQuoted 10 lines · Bin Meng
At present the Freescale TSEC node DT bindings doc requires a <reg> property in the TSEC node. But this might not always be the case. In the upstream Linux kernel, there is no DT bindings doc for it but the kernel driver tests a subnode of a name prefixed with "queue-group", as we can see from
gfar_of_init():for_each_available_child_of_node(np, child) { if (!of_node_name_eq(child, "queue-group")) ...
Quoted 7 lines
in
drivers/net/ethernet/freescale/gianfar.cUpdate our DT bindings to describe this alternate description.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
Fascinating. I did not even notice that the Linux DT bindings do not have a "reg" property and rely on "ranges" for translation to the queue-group. I guess that changes things. I'll go again through the patches starting from the first one.
PATCH v2 1/21 dt-bindings: net: Add the old DT bindings for "fixed-link"
In reply to Bin Mengdoc/device-tree-bindings/net/fixed-link.txt Some Ethernet MACs have a "fixed link", and are not connected to a · line 28
Quoted 6 lines · Bin Meng
+- The old DT binding, where 'fixed-link' is a property with 5 cells
doc/device-tree-bindings/net/fixed-link.txt +5
-0+ encoding various information about the fixed PHY, in the form of + <phy_id, full-duplex, speed, pause, asym-pause>. + + * 'phy_id', emulated PHY ID, choose any but unique to the all specified + fixed-links
Could you please explicitly state that U-Boot deliberately ignores the phy_id and unconditionally uses PHY_FIXED_ID? It would be suicidal to do anything else (and I see Linux ignores fixed_link_prop[0] too), but at least we should be upfront about it.
doc/device-tree-bindings/net/fixed-link.txt Some Ethernet MACs have a "fixed link", and are not connected to a · line 32
Quoted 4 lines
doc/device-tree-bindings/net/fixed-link.txt +4
-0+ * 'full-duplex', 0 for half duplex or 1 for full duplex + * 'speed', link speed in Mbits/sec, accepts only 10, 100 and 1000 + * 'pause', 0 for no pause, 1 for pause + * 'asym-pause', 0 for no asymmetric pause, 1 for asymmetric pause
PATCH v2 2/21 of: extra: Introduce ofnode_phy_is_fixed_link() API
In reply to Bin MengQuoted 5 lines · Bin Meng
drivers/core/of_extra.c +5
-0+bool ofnode_phy_is_fixed_link (ofnode eth_node,ofnode *phy_node) +{ +bool found = false; +ofnode node, subnode; +int len;
drivers/core/of_extra.c int ofnode_decode_memory_region(ofnode config_node, const char *mem_type, · line 148
Quoted 10 lines
drivers/core/of_extra.c +10
-0+ +/* new binding */ + subnode =ofnode_find_subnode (eth_node,"fixed-link" ); +if (ofnode_valid (subnode)) { + node = subnode; + found = true; + } + +/* old binding */ + if (ofnode_get_property(eth_node, "fixed-link", &len) &&
Maybe "else if" here? If an old-style and a new-style binding exist, we should prefer looking at the new one.
And with that "else if", we could remove the "found" variable:
if (ofnode_valid(subnode)) {
} else if (ofnode_get_property(eth_node, "fixed-link", &len) &&
len == (5 * sizeof(__be32))) {
} else {
return false;
}
if (phy_node)
*phy_node = node;Quoted 10 lines
drivers/core/of_extra.c +10
-0+ len == (5 * sizeof(__be32))) { + node = eth_node; + found = true; + } + +if (found && phy_node) + *phy_node = node; + +return found; +}
PATCH v2 3/21 test: dm: Add a case to test ofnode_phy_is_fixed_link()
In reply to Bin MengQuoted 6 lines · Bin Meng
This adds a test case to test the new
ofnode_phy_is_fixed_link()API. Both the new and old DT bindings are covered.Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
The DSA sandbox patch adds three fixed-link nodes already. Can't you convert one of those three fixed-link nodes to an old-style binding, and modify your test case to cover those existing nodes?
PATCH v2 4/21 dm: mdio: Use ofnode_phy_is_fixed_link() API
In reply to Bin MengQuoted 6 lines · Bin Meng
Switch to use the
ofnode_phy_is_fixed_link()API which can support both the new and old DT bindings.Signed-off-by Bin Meng <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
PATCH v2 5/21 net: phy: fixed: Be compatible with live OF tree
In reply to Bin MengQuoted 37 lines · Bin Meng
From: Vladimir Oltean <[email protected]>
On systems that use
CONFIG_OF_LIVE, the "ofnode" type is defined as const structdevice_node*np, while on the flat DT systems it is defined as a longof_offsetintogd->fdt_blob.It is desirable that the fixed PHY driver uses the higher-level ofnode abstraction instead of parsing
gd->fdt_blobdirectly, because that enables it to work on live OF systems.The fixed PHY driver has used a nasty hack since its introduction in commit
db40c1aa1c10("drivers/net/phy: add fixed-phy / fixed-link support"), which is to pass the longgd->fdt_bloboffset inside intphydev->addr(a value that normally holds the MDIO bus address at which the PHY responds). Even ignoring the fact that the types were already mismatched leading to a potential truncation (flat OF offset was supposed to be a long and not an int), we really cannot extend this hack any longer, because there's no way an int will hold the other representation of ofnode, the structdevice_node*np.So we unfortunately need to do the right thing, which is to use the framework introduced by Grygorii Strashko in
commiteef0b8a930d1("net: phy: add ofnode node to structphy_device"). This will populatephydev->nodefor the fixed PHY.Note that
phydev->nodewill not be valid in the probe function, since that is called synchronously fromphy_device_createand we really have no way of passing the ofnode directly through thephy_device_createAPI. So we do what other drivers do too: we move the OF parsing logic from the .probe to the .config method of the PHY driver. The new function will be called atphy_config()time.I do believe I've converted all the possible call paths for creating a PHY with
PHY_FIXED_ID, so there is really no reason to maintain compatibility with the old logic of retrieving a flat OF tree offset fromphydev->addr. We just pass 0 tophydev->addrnow.
Quoted 7 lines
Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Message-Id: <[email protected]>
[bmeng: keep fixedphy_probe(); update mdio-uclass.c to handle fixed phy]Signed-off-by Bin Meng <[email protected]>---
PATCH v2 6/21 net: phy: fixed: Drop #ifdef CONFIG_DM_ETH around phy_connect_fixed
In reply to Bin MengQuoted 8 lines · Bin Meng
From: Vladimir Oltean <[email protected]>
In
drivers/net/phy/Kconfig,CONFIG_PHY_FIXEDalready depends onCONFIG_DM_ETH, so the function prototype definition whenCONFIG_DM_ETH=ndoes nothing, so it can be dropped. It is also never reachable, since the whole function is already under #ifdefCONFIG_PHY_FIXED(which again, as I said, depends onCONFIG_DM_ETH=y).
Quoted 6 lines
Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Message-Id: <[email protected]>
Signed-off-by Bin Meng <[email protected]>---
PATCH v2 8/21 net: phy: xilinx: Drop #ifdef CONFIG_DM_ETH around phy_connect_gmii2rgmii()
In reply to Bin MengQuoted 9 lines · Bin Meng
At present
phy_connect_gmii2rgmii()is implemented using a DM APIdev_of_offset()hence it cannot support a non-DM configuration. Remove the non-DM version prototype ofphy_connect_gmii2rgmii()and make the driver depend onCONFIG_DM_ETH.Signed-off-by Bin Meng <[email protected]>Acked-by Michal Simek <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
PATCH v2 9/21 net: phy: Simplify the logic of phy_connect_fixed()
In reply to Bin MengQuoted 7 lines · Bin Meng
Simplify the logic of
phy_connect_fixed()by using the new APIofnode_phy_is_fixed_link(), which brings additional bonus of supporting the old DT bindings.Signed-off-by Bin Meng <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
PATCH v2 10/21 net: phy: fixed: Make driver ops static
In reply to Bin MengQuoted 5 lines · Bin Meng
The PHY driver ops should be made static.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
PATCH v2 11/21 net: phy: fixed: Add the missing ending newline
In reply to Bin MengQuoted 5 lines · Bin Meng
The printf statement doesn't end with a newline. Add it.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
PATCH v2 12/21 net: phy: fixed: Support the old DT binding
In reply to Bin MengQuoted 16 lines · Bin Meng
Update
fixedphy_probe()to support the old DT binding.Signed-off-by Bin Meng <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
(no changes since v1)
drivers/net/phy/fixed.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)drivers/net/phy/fixed.c +0
-0
drivers/net/phy/fixed.c static int fixedphy_config(struct phy_device *phydev) · line 32
Quoted 6 lines
drivers/net/phy/fixed.c +2
-0@@ -27,13 +27,27 @@ static int fixedphy_config(struct phy_device *phydev) {ofnode node =phy_get_ofnode (phydev);struct fixed_link *priv; +bool old_binding = false;u32 val; +u32 old_val[5 ];
Perhaps a pet peeve from Linux networking, but could you please keep the variable definitions sorted by line length? Thanks.
PATCH v2 13/21 net: tsec: Use dm_eth_phy_connect() directly for the DM case
In reply to Bin MengQuoted 6 lines · Bin Meng
From: Vladimir Oltean <[email protected]>
Now that the fixed phy driver has been fully adapted to OF APIs, and
dm_eth_phy_connect()already can handle the fixed phy, calldm_eth_phy_connect()directly in the DM tsec driver.
Quoted 8 lines
Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Message-Id: <[email protected]>
[bmeng: split from "net: mdio: teach dm_eth_phy_connect to connect to fixed PHY"]Signed-off-by Bin Meng <[email protected]>---
PATCH v2 16/21 net: tsec: Support <reg> property from the subnode "queue-group"
In reply to Bin MengQuoted 23 lines · Bin Meng
At present the tsec driver uses a non-standard DT bindings to get its <reg> base / size. The upstream Linux kernel seems to require the <reg> base / size to be put under a subnode of the eTSEC node with a name prefix "queue-group". This is not documented in the kernel DT bindings, but it looks every dtsi file that contains the eTSEC node was written like this.
This commit updates the tsec driver to handle this case.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
(no changes since v1)
drivers/net/tsec.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)drivers/net/tsec.c +0
-0
drivers/net/tsec.c int tsec_probe(struct udevice *dev) · line 830
Quoted 5 lines
drivers/net/tsec.c +1
-1@@ -827,13 +827,35 @@ int tsec_probe(struct udevice *dev)struct tsec_data *data;const char *phy_mode;fdt_addr_t reg; -ofnode parent; +ofnode parent, child;
Same comment about the "reverse Christmas tree" notation.
drivers/net/tsec.c int tsec_probe(struct udevice *dev) · line 841
Quoted 12 lines
drivers/net/tsec.c +6
-1int ret; data = (struct tsec_data *)dev_get_driver_data (dev); pdata->iobase = (phys_addr_t )dev_read_addr (dev); - priv->regs =dev_remap_addr (dev); +if (pdata->iobase !=FDT_ADDR_T_NONE ) { + priv->regs =dev_remap_addr (dev); + }else { +ofnode_for_each_subnode (child,dev_ofnode (dev)) { +if (!strncmp (ofnode_get_name (child),"queue-group" , +strlen ("queue-group" ))) {
I would prefer the syntax:
if (strncmp(ofnode_get_name(child), "queue-group",
strlen("queue-group")))
continue;which allows us to reduce the indentation level.
drivers/net/tsec.c int tsec_probe(struct udevice *dev) · line 849
Quoted 8 lines
drivers/net/tsec.c +8
-0+ reg =ofnode_get_addr (child); +if (reg ==FDT_ADDR_T_NONE ) { +printf ("No 'reg' property of <queue-group>\n" ); +return -ENOENT ; + } + pdata->iobase = reg; + priv->regs =map_physmem (pdata->iobase,0 , +MAP_NOCACHE );
Hmm, can't you just populate pdata->iobase, and call the same dev_remap_addr in the common code path?
drivers/net/tsec.c int tsec_probe(struct udevice *dev) · line 850
Quoted 1 line
drivers/net/tsec.c +1
-0+break ;
Could you please add a comment that if there are multiple queue groups, we only use the first one?
Quoted 8 lines
drivers/net/tsec.c +8
-0+ } + } + +if (!ofnode_valid (child)) { +printf ("No child node for <queue-group>?\n" ); +return -ENOENT ; + } + }
PATCH v2 19/21 ppc: qemu: Create a virtual memory mapping of the platform bus
In reply to Bin MengQuoted 55 lines · Bin Meng
QEMU ppce500 target can dynamically instantiate an eTSEC device on a platform bus if "-device eTSEC" is given to QEMU. It is presented as a "simple-bus" in the device tree, with an additional compatible string "qemu,platform".
Let's create a virtual memory mapping for it in
misc_init_r(), in preparation to adding eTSEC support.Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- turn onCONFIG_SIMPLE_BUS_CORRECT_RANGEin qemu-ppce500_defconfigboard/emulation/qemu-ppce500/Kconfig | 6 ++++++ board/emulation/qemu-ppce500/qemu-ppce500.c | 18 ++++++++++++++++++ configs/qemu-ppce500_defconfig | 1 + 3 files changed, 25 insertions(+)board/emulation/qemu-ppce500/Kconfig +6
-0@@ -9,4 +9,10 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "qemu-ppce500" +config PLATFORM_BUS_MAP_ADDR + hex + default 0xf0000000 + help + The QEMU platform bus base mapped address in the virtual memory space. + endifboard/emulation/qemu-ppce500/qemu-ppce500.c +5
-0@@ -14,6 +14,8 @@#include <net.h> #include <pci.h> #include <time.h> +#include <dm/simple_bus.h> +#include <dm/uclass-internal.h> #include <asm/global_data.h> #include <asm/processor.h> #include <asm/mmu.h> @@ -148,6 +150,22 @@ int misc_init_r(void)*/ disable_tlb (find_tlb_idx ((void *)CONFIG_SYS_TMPVIRT ,1 )); +/* +* Detect the presence of the platform bus node, and +* create a virtual memory mapping for it.
board/emulation/qemu-ppce500/qemu-ppce500.c int misc_init_r(void) · line 165
Quoted 10 lines
board/emulation/qemu-ppce500/qemu-ppce500.c +10
-0+*/ +for (ret =uclass_find_first_device (UCLASS_SIMPLE_BUS , &dev); + dev; + ret =uclass_find_next_device (&dev)) { +if (device_is_compatible (dev,"qemu,platform" )) { +struct simple_bus_plat *plat =dev_get_uclass_plat (dev); + +assert (!tlb_map_range (CONFIG_PLATFORM_BUS_MAP_ADDR , + plat->target, plat->size, +TLB_MAP_IO ));
A break here, maybe?
If there are multiple qemu,platform nodes, your code will attempt to create multiple TLB mappings towards the same virtual address CONFIG_PLATFORM_BUS_MAP_ADDR, which will not work. So better avoid that.
And maybe you can refactor this into a dedicated function, similar to what exists for PCI.
board/emulation/qemu-ppce500/qemu-ppce500.c int misc_init_r(void) · line 170
Quoted 5 lines
board/emulation/qemu-ppce500/qemu-ppce500.c +3
-0+ } + } +return 0 ; }
}
Quoted 16 lines
configs/qemu-ppce500_defconfig +1
-0@@ -28,6 +28,7 @@ CONFIG_OF_BOARD=y CONFIG_ENV_OVERWRITE=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_DM=y +CONFIG_SIMPLE_BUS_CORRECT_RANGE=y CONFIG_BLK=y CONFIG_HAVE_BLOCK_DEVICE=y CONFIG_MPC8XXX_GPIO=ySignature · 1 line
2.25.1
PATCH v2 20/21 ppc: qemu: Enable eTSEC support
In reply to Bin MengQuoted 5 lines · Bin Meng
QEMU ppce500 target can dynamically instantiate an eTSEC device if "-device eTSEC" is given to QEMU. This commit enables eTSEC driver and the required fixed PHY driver to create a usable network configuration using eTSEC.
Quoted 7 lines
Unlike a real world 85xx board that usually stores the eTSEC MAC address in an EEPROM,
CONFIG_NET_RANDOM_ETHADDRis required for QEMU otherwise U-Boot ethernet initialization complains no valid ethernet address is set.Signed-off-by Bin Meng <[email protected]>---
PATCH v2 21/21 doc: board: qemu-ppce500: Document eTSEC usage
In reply to Bin MengQuoted 5 lines · Bin Meng
Document how to launch a QEMU session with eTSEC as a network device.
Signed-off-by Bin Meng <[email protected]>---
PATCH v2 2/21 of: extra: Introduce ofnode_phy_is_fixed_link() API
In reply to Vladimir OlteanHi Vladimir,
Quoted 12 lines · Vladimir Oltean
Quoted 10 lines · Bin Meng
drivers/core/of_extra.c +10
-0+bool ofnode_phy_is_fixed_link (ofnode eth_node,ofnode *phy_node) +{ +bool found = false; +ofnode node, subnode; +int len; + +/* new binding */ + subnode =ofnode_find_subnode (eth_node,"fixed-link" ); +if (ofnode_valid (subnode)) { + node = subnode;
Quoted 9 lines
drivers/core/of_extra.c int ofnode_decode_memory_region(ofnode config_node, const char *mem_type, · line 148
Quoted 5 lines
drivers/core/of_extra.c +5
-0+ found = true; + } + +/* old binding */ + if (ofnode_get_property(eth_node, "fixed-link", &len) &&Maybe "else if" here? If an old-style and a new-style binding exist, we should prefer looking at the new one.
Agree. Will do in v3.
Quoted 1 line
And with that "else if", we could remove the "found" variable:
Regards,
Bin
PATCH v2 2/21 of: extra: Introduce ofnode_phy_is_fixed_link() API
In reply to Vladimir OlteanHi Vladimir,
Quoted 22 lines · Vladimir Oltean
Quoted 12 lines · Vladimir Oltean
Quoted 11 lines · Bin Meng
Introduce a helper API
ofnode_phy_is_fixed_link()to detect whether the ethernet controller connects to a fixed-link pseudo-PHY device.Note there are two ways to describe a fixed PHY attached to an Ethernet device:
- the new DT binding, where 'fixed-link' is a sub-node of the Ethernet device
- the old DT binding, where 'fixed-link' is a property with 5 cells encoding various information about the fixed PHYQuoted 7 lines
Quoted 3 lines
Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
I ran a 'grep -r "ofnode_get_property.*fixed-link" .' and saw no in-tree users of the old binding. Why do we bother to be compatible with something which isn't used?
Quoted 5 lines
Ah, I see what's going on.
QEMU fixes up the device tree here:
https://github.com/qemu/qemu/blob/master/hw/ppc/e500.c#L239
and adds an old-style fixed-link binding.
Can't you modify it to add a new-style fixed-link property?
I am afraid that may break guests that haven't supported new-style DT bindings yet.
Quoted 2 lines
It's not like you didn't have to modify it for the "ranges" property too :)
https://github.com/qemu/qemu/commit/e5943b00d35efc68ca72ed304cfca98a9f3a647c
Regards,
Bin