ACPI MDIO support for Marvell controllers
Subsystems (5)
v2 cover ACPI MDIO support for Marvell controllers
Hi,
The second version of the patchset addresses all comments received during v1 review and introduces a couple of new patches that were requested.
fwnode_mdiobus_register() helper routine was added and it is used now by 2 drivers (xgmac_mdio and mvmdio). In the latter a clock handling was significantly simplified by a switch to
a devm_clk_bulk_get_optional().
Last but not least two additional MAC configuration modes ACPI desctiption were documented ("managed" and "fixed-link") - they can be processed by the existing fwnode_ phylink helpers and comply with the standard _DSD properties and hierarchical data extension. ACPI Maintainers are therefore added to reviewers' list.
More details can be found in the patches and their commit messages.
As before, the feature was verified with ACPI on MacchiatoBin, CN913x-DB and Armada 8040 DB (fixed-link handling).
Moreover regression tests were performed (old firmware with updated kernel, new firmware with old kernel and the operation with DT).
The firmware ACPI description is exposed in the public github branch:
https://github.com/semihalf-wojtas-marcin/edk2-platforms/commits/acpi-mdio-r20210613
There is also MacchiatoBin firmware binary available for testing:
https://drive.google.com/file/d/1eigP_aeM4wYQpEaLAlQzs3IN_w1-kQr0
I'm looking forward to the comments or remarks.
Best regards,
Marcin
Changelog:v1->v2
* 1/7 - new patch
* 2/7 - new patch
* 3/7 - new patch
* 4/7 - new patch
* 5/7 - remove unnecessary if (has_acpi_companion()) and rebase onto the new clock handling
* 6/7 - remove deprecated comment
* 7/7 - no changes
Marcin Wojtas (7):
Documentation: ACPI: DSD: describe additional MAC configuration
net: mdiobus: Introduce fwnode_mdbiobus_register() net/fsl: switch to fwnode_mdiobus_register
net: mvmdio: simplify clock handling
net: mvmdio: add ACPI support
net: mvpp2: enable using phylink with ACPI
net: mvpp2: remove unused 'has_phy' field
drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 3 - include/linux/fwnode_mdio.h | 12 ++++ drivers/net/ethernet/freescale/xgmac_mdio.c | 11 +-- drivers/net/ethernet/marvell/mvmdio.c | 75 ++++++++------------ drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 23 ++++-- drivers/net/mdio/fwnode_mdio.c | 22 ++++++ Documentation/firmware-guide/acpi/dsd/phy.rst | 55 ++++++++++++++ 7 files changed, 138 insertions(+), 63 deletions(-)
Signature · 1 line
2.29.0
PATCH v2 1/7 Documentation: ACPI: DSD: describe additional MAC configuration
Document additional MAC configuration modes which can be processed by the existing fwnode_ phylink helpers:
* "managed" standard ACPI _DSD property [1]
* "fixed-link" data-only subnode linked in the _DSD package via generic mechanism of the hierarchical data extension [2]
[1] https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf
[2] https://github.com/UEFI/DSD-Guide/blob/main/dsd-guide.pdf
--- Documentation/firmware-guide/acpi/dsd/phy.rst | 55 ++++++++++++++++++++ 1 file changed, 55 insertions(+)
Documentation/firmware-guide/acpi/dsd/phy.rst +55 -0
@@ -49,6 +49,21 @@ phy-mode The "phy-mode" _DSD property is used to describe the connection to the PHY. The valid values for "phy-mode" are defined in [4]. +managed +------- +Optional property, which specifies the PHY management type. +The valid values for "managed" are defined in [4]. + +fixed-link +---------- +The "fixed-link" is described by a the data-only subnode of the +MAC port, which is linked in the _DSD package via +hierarchical data extension (UUID dbb8e3e6-5886-4ba6-8795-1319f52a966b +in accordance with [5] "_DSD Implementation Guide" document). +The subnode should comprise a required property ("speed") and +possibly the optional ones - complete list of parameters and +their values are specified in [4]. + The following ASL example illustrates the usage of these properties. DSDT entry for MDIO node
@@ -121,6 +136,44 @@ phy-mode and phy-handle are used as explained earlier. }) } +MAC node example where "managed" property is specified. +------------------------------------------------------- +:: + Scope(\_SB.PP21.ETH0) + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"phy-mode", "sgmii"}, + Package () {"managed", "in-band-status"} + } + }) + } + +MAC node example with a "fixed-link" subnode. +--------------------------------------------- +:: + Scope(\_SB.PP21.ETH1) + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"phy-mode", "sgmii"}, + }, + ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"), + Package () { + Package () {"fixed-link", "LNK0"} + } + }) + Name (LNK0, Package(){ // Data-only subnode of port + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"speed", 1000}, + Package () {"full-duplex", 1} + } + }) + } + References ==========
@@ -131,3 +184,5 @@ References [3] Documentation/firmware-guide/acpi/DSD-properties-rules.rst [4] Documentation/devicetree/bindings/net/ethernet-controller.yaml + +[5] https://github.com/UEFI/DSD-Guide/blob/main/dsd-guide.pdf
Signature · 1 line
2.29.0
PATCH v2 2/7 net: mdiobus: Introduce fwnode_mdbiobus_register()
In reply to Marcin WojtasThis patch introduces a new helper function that
wraps acpi_/of_ mdiobus_register() and allows its
usage via common fwnode_ interface.
Fall back to raw mdiobus_register() in case CONFIG_FWNODE_MDIO is not enabled, in order to satisfy compatibility
in all future user drivers.
--- include/linux/fwnode_mdio.h | 12 +++++++++++ drivers/net/mdio/fwnode_mdio.c | 22 ++++++++++++++++++++ 2 files changed, 34 insertions(+)
include/linux/fwnode_mdio.h +12 -0
@@ -16,6 +16,7 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,int fwnode_mdiobus_register_phy (struct mii_bus *bus,struct fwnode_handle *child,u32 addr); +int fwnode_mdiobus_register (struct mii_bus *bus,struct fwnode_handle *fwnode);#else /* CONFIG_FWNODE_MDIO */ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
@@ -30,6 +31,17 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus, {return -EINVAL ; } + +static inline int fwnode_mdiobus_register (struct mii_bus *bus, +struct fwnode_handle *fwnode) +{ +/* +* Fall back to mdiobus_register() function to register a bus. +* This way, we don't have to keep compat bits around in drivers. +*/ + +return mdiobus_register (mdio); +}#endif #endif /* __LINUX_FWNODE_MDIO_H */
drivers/net/mdio/fwnode_mdio.c +22 -0
@@ -7,8 +7,10 @@*/ #include <linux/acpi.h> +#include <linux/acpi_mdio.h> #include <linux/fwnode_mdio.h> #include <linux/of.h> +#include <linux/of_mdio.h> #include <linux/phy.h> MODULE_AUTHOR ("Calvin Johnson <[email protected]>" );
@@ -142,3 +144,23 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,return 0 ; }EXPORT_SYMBOL (fwnode_mdiobus_register_phy); + +/** +* fwnode_mdiobus_register - bring up all the PHYs on a given MDIO bus and +* attach them to it. +* @bus: Target MDIO bus. +* @fwnode: Pointer to fwnode of the MDIO controller. +* +* Return values are determined accordingly to acpi_/of_ mdiobus_register() +* operation. +*/ +int fwnode_mdiobus_register (struct mii_bus *bus,struct fwnode_handle *fwnode) +{ +if (is_acpi_node (fwnode)) +return acpi_mdiobus_register (bus, fwnode); +else if (is_of_node (fwnode)) +return of_mdiobus_register (bus,to_of_node (fwnode)); +else +return -EINVAL ; +} +EXPORT_SYMBOL (fwnode_mdiobus_register);
Signature · 1 line
2.29.0
Andrew Lunn
maintainerRe: [net-next: PATCH v2 2/7] net: mdiobus: Introduce fwnode_mdbiobus_register()
Quoted 31 lines · Marcin Wojtas
This patch introduces a new helper function that
wraps acpi_/of_mdiobus_register()and allows its
usage via commonfwnode_interface.Fall back to raw
mdiobus_register()in caseCONFIG_FWNODE_MDIOis not enabled, in order to satisfy compatibility
in all future user drivers.Signed-off-by Marcin Wojtas <[email protected]>--- include/linux/fwnode_mdio.h | 12 +++++++++++ drivers/net/mdio/fwnode_mdio.c | 22 ++++++++++++++++++++ 2 files changed, 34 insertions(+)include/linux/fwnode_mdio.h +2
-0@@ -16,6 +16,7 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,int fwnode_mdiobus_register_phy (struct mii_bus *bus,struct fwnode_handle *child,u32 addr); +int fwnode_mdiobus_register (struct mii_bus *bus,struct fwnode_handle *fwnode);#else /* CONFIG_FWNODE_MDIO */ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,@@ -30,6 +31,17 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus, {return -EINVAL ; } +
include/linux/fwnode_mdio.h static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus, · line 44
Quoted 10 lines
include/linux/fwnode_mdio.h +10
-0+static inline int fwnode_mdiobus_register (struct mii_bus *bus, +struct fwnode_handle *fwnode) +{ +/* +* Fall back to mdiobus_register() function to register a bus. +* This way, we don't have to keep compat bits around in drivers. +*/ + +return mdiobus_register (mdio); +}
I'm not sure this fallback is correct.
Any driver which decides to use fwmode is going to select it. If it is not selected, you want a link time error, or a compiler time error to tell you, you are missing FWNODE_MDIO. Calling mdiobus_register() is unlikely to work, or the driver would of done that directly.
Andrew
Re: [net-next: PATCH v2 2/7] net: mdiobus: Introduce fwnode_mdbiobus_register()
śr., 16 cze 2021 o 21:33 Andrew Lunn <[email protected]> napisał(a):
Quoted 46 lines · Marcin Wojtas
Quoted 31 lines
This patch introduces a new helper function that
wraps acpi_/of_mdiobus_register()and allows its
usage via commonfwnode_interface.Fall back to raw
mdiobus_register()in caseCONFIG_FWNODE_MDIOis not enabled, in order to satisfy compatibility
in all future user drivers.Signed-off-by Marcin Wojtas <[email protected]>--- include/linux/fwnode_mdio.h | 12 +++++++++++ drivers/net/mdio/fwnode_mdio.c | 22 ++++++++++++++++++++ 2 files changed, 34 insertions(+)include/linux/fwnode_mdio.h +2
-0@@ -16,6 +16,7 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,int fwnode_mdiobus_register_phy (struct mii_bus *bus,struct fwnode_handle *child,u32 addr); +int fwnode_mdiobus_register (struct mii_bus *bus,struct fwnode_handle *fwnode);#else /* CONFIG_FWNODE_MDIO */ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,@@ -30,6 +31,17 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus, {return -EINVAL ; } +include/linux/fwnode_mdio.h static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus, · line 44
Quoted 10 lines
include/linux/fwnode_mdio.h +10
-0+static inline int fwnode_mdiobus_register (struct mii_bus *bus, +struct fwnode_handle *fwnode) +{ +/* +* Fall back to mdiobus_register() function to register a bus. +* This way, we don't have to keep compat bits around in drivers. +*/ + +return mdiobus_register (mdio); +}I'm not sure this fallback is correct.
Quoted 5 lines
Any driver which decides to use fwmode is going to select it. If it is not selected, you want a link time error, or a compiler time error to tell you, you are missing
FWNODE_MDIO. Callingmdiobus_register()is unlikely to work, or the driver would of done that directly.
This kind of fallback is done in of_mdiobus_register and acpi_mdiobus_register.
Actually mvmdio driver is using this fallback for non-dt platforms (e.g. Orion). Therefore I would prefer to keep the current behavior.
Best regards,
Marcin
Andrew Lunn
maintainerRe: [net-next: PATCH v2 2/7] net: mdiobus: Introduce fwnode_mdbiobus_register()
Quoted 2 lines
Actually mvmdio driver is using this fallback for non-dt platforms (e.g. Orion). Therefore I would prefer to keep the current behavior.
A quick look at Orion5x, it is now a multi arch MACH. It selects ARCH_MULTI_V5. Which seems to imply ARCH_MULTIPLATFORM which selects USE_OF which selects OF.
At least for ARM, i'm not sure you can realistically disable OF.
Having said that acpi_mdiobus_register() also falls back to mdiobus_register(mdio). So it is symmetric. And fwmode_mdiobus_register() falling back would keep with the symmetry. So, O.K.
Andrew
PATCH v2 3/7 net/fsl: switch to fwnode_mdiobus_register
In reply to Marcin WojtasUtilize the newly added helper routine
for registering the MDIO bus via fwnode_
interface.
--- drivers/net/ethernet/freescale/xgmac_mdio.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/net/ethernet/freescale/xgmac_mdio.c +2 -9
@@ -13,7 +13,7 @@*/ #include <linux/acpi.h> -#include <linux/acpi_mdio.h> +#include <linux/fwnode_mdio.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/mdio.h>
@@ -246,7 +246,6 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum)static int xgmac_mdio_probe (struct platform_device *pdev) { -struct fwnode_handle *fwnode;struct mdio_fsl_priv *priv;struct resource *res;struct mii_bus *bus;
@@ -291,13 +290,7 @@ static int xgmac_mdio_probe(struct platform_device *pdev) priv->has_a011043 =device_property_read_bool (&pdev->dev,"fsl,erratum-a011043" ); - fwnode = pdev->dev.fwnode; -if (is_of_node (fwnode)) - ret =of_mdiobus_register (bus,to_of_node (fwnode)); -else if (is_acpi_node (fwnode)) - ret =acpi_mdiobus_register (bus, fwnode); -else - ret = -EINVAL ; + ret =fwnode_mdiobus_register (bus, pdev->dev.fwnode);if (ret) {dev_err (&pdev->dev,"cannot register MDIO bus\n" ); goto err_registration;
Signature · 1 line
2.29.0
Andrew Lunn
maintainerRe: [net-next: PATCH v2 3/7] net/fsl: switch to fwnode_mdiobus_register
Quoted 3 lines · Marcin Wojtas
Utilize the newly added helper routine
for registering the MDIO bus viafwnode_
interface.
You need to add depends on FWNODE_MDIO
Andrew
Re: [net-next: PATCH v2 3/7] net/fsl: switch to fwnode_mdiobus_register
śr., 16 cze 2021 o 21:35 Andrew Lunn <[email protected]> napisał(a):
Quoted 8 lines · Marcin Wojtas
Quoted 3 lines
Utilize the newly added helper routine
for registering the MDIO bus viafwnode_
interface.You need to add depends on
FWNODE_MDIO
Do you mean something like this?
drivers/net/ethernet/freescale/Kconfig +2 -2
@@ -68,8 +68,8 @@ config FSL_PQ_MDIO config FSL_XGMAC_MDIO tristate "Freescale XGMAC MDIO" select PHYLIB - depends on OF - select OF_MDIO + depends on ACPI || OF + select FWNODE_MDIO help
Best regards,
Marcin
Andrew Lunn
maintainerRe: [net-next: PATCH v2 3/7] net/fsl: switch to fwnode_mdiobus_register
Quoted 15 lines · Marcin Wojtas
śr., 16 cze 2021 o 21:35 Andrew Lunn <[email protected]> napisał(a):
Quoted 8 lines · Marcin Wojtas
Quoted 3 lines
Utilize the newly added helper routine
for registering the MDIO bus viafwnode_
interface.You need to add depends on
FWNODE_MDIODo you mean something like this?
drivers/net/ethernet/freescale/Kconfig config FSL_PQ_MDIO · line 73
Quoted 8 lines
drivers/net/ethernet/freescale/Kconfig +2
-2@@ -68,8 +68,8 @@ config FSL_PQ_MDIO config FSL_XGMAC_MDIO tristate "Freescale XGMAC MDIO" select PHYLIB - depends on OF - select OF_MDIO + depends on ACPI || OF + select FWNODE_MDIO help
You should not need depends on ACPI || OF. FWNODE_MDIO implies that. And there are no direct calls to of_ functions, so you can drop the depends on OF.
Andrew
Re: [net-next: PATCH v2 3/7] net/fsl: switch to fwnode_mdiobus_register
czw., 17 cze 2021 o 14:28 Andrew Lunn <[email protected]> napisał(a):
Quoted 14 lines · Marcin Wojtas
Quoted 12 lines
śr., 16 cze 2021 o 21:35 Andrew Lunn <[email protected]> napisał(a):
Quoted 8 lines · Marcin Wojtas
Quoted 3 lines
Utilize the newly added helper routine
for registering the MDIO bus viafwnode_
interface.You need to add depends on
FWNODE_MDIODo you mean something like this?
Quoted 16 lines
drivers/net/ethernet/freescale/Kconfig config FSL_PQ_MDIO · line 73
Quoted 11 lines
drivers/net/ethernet/freescale/Kconfig +2
-2@@ -68,8 +68,8 @@ config FSL_PQ_MDIO config FSL_XGMAC_MDIO tristate "Freescale XGMAC MDIO" select PHYLIB - depends on OF - select OF_MDIO + depends on ACPI || OF + select FWNODE_MDIO helpYou should not need depends on ACPI || OF.
FWNODE_MDIOimplies that. And there are no direct calls toof_functions, so you can drop the depends on OF.
Ok, I'll leave:
depends on FWNODE_MDIO
only.
Thanks,
Marcin
PATCH v2 4/7 net: mvmdio: simplify clock handling
In reply to Marcin WojtasBecause the mvmdio driver supports a wide range of Marvell SoC families it must support multiple types of the HW description and required resources.
Thanks to the devm_clk_bulk_get_optional() helper routine the clock handling could be significantly simplified, as it is compatible with all possible variants within a single call.
--- drivers/net/ethernet/marvell/mvmdio.c | 61 ++++++-------------- 1 file changed, 18 insertions(+), 43 deletions(-)
drivers/net/ethernet/marvell/mvmdio.c +18 -43
@@ -62,9 +62,11 @@#define MVMDIO_XSMI_POLL_INTERVAL_MIN 150#define MVMDIO_XSMI_POLL_INTERVAL_MAX 160 +#define MVMDIO_CLOCK_COUNT 4 +struct orion_mdio_dev {void __iomem *regs; -struct clk *clk[4 ]; +struct clk_bulk_data clks[MVMDIO_CLOCK_COUNT ];/* * If we have access to the error interrupt pin (which is * somewhat misnamed as it not only reflects internal errors
@@ -279,7 +281,7 @@ static int orion_mdio_probe(struct platform_device *pdev)struct resource *r;struct mii_bus *bus;struct orion_mdio_dev *dev; -int i, ret; +int ret; type = (enum orion_mdio_bus_type )of_device_get_match_data (&pdev->dev);
@@ -319,33 +321,20 @@ static int orion_mdio_probe(struct platform_device *pdev)init_waitqueue_head (&dev->smi_busy_wait); -if (pdev->dev.of_node) { -for (i =0 ; i <ARRAY_SIZE (dev->clk); i++) { - dev->clk[i] =of_clk_get (pdev->dev.of_node, i); -if (PTR_ERR (dev->clk[i]) == -EPROBE_DEFER ) { - ret = -EPROBE_DEFER ; - goto out_clk; - } -if (IS_ERR (dev->clk[i])) -break ; -clk_prepare_enable (dev->clk[i]); - } - -if (!IS_ERR (of_clk_get (pdev->dev.of_node, -ARRAY_SIZE (dev->clk)))) -dev_warn (&pdev->dev, - "unsupported number of clocks, limiting to the first " - __stringify(ARRAY_SIZE(dev->clk)) "\n"); - }else { - dev->clk[0 ] =clk_get (&pdev->dev,NULL ); -if (PTR_ERR (dev->clk[0 ]) == -EPROBE_DEFER ) { - ret = -EPROBE_DEFER ; - goto out_clk; - } -if (!IS_ERR (dev->clk[0 ])) -clk_prepare_enable (dev->clk[0 ]); - } + dev->clks[0 ].id ="core" ; + dev->clks[1 ].id ="mg" ; + dev->clks[2 ].id ="mg_core" ; + dev->clks[3 ].id ="axi" ; + ret =devm_clk_bulk_get_optional (&pdev->dev,MVMDIO_CLOCK_COUNT , + dev->clks); +if (ret) +return ret; + ret =clk_bulk_prepare_enable (MVMDIO_CLOCK_COUNT , dev->clks); +if (ret) { +dev_err (&pdev->dev,"Cannot enable clocks\n" ); +return ret; + } dev->err_interrupt =platform_get_irq_optional (pdev,0 ); if (dev->err_interrupt > 0 &&
@@ -383,14 +372,6 @@ static int orion_mdio_probe(struct platform_device *pdev)if (dev->err_interrupt >0 )writel (0 , dev->regs +MVMDIO_ERR_INT_MASK ); -out_clk: -for (i =0 ; i <ARRAY_SIZE (dev->clk); i++) { -if (IS_ERR (dev->clk[i])) -break ; -clk_disable_unprepare (dev->clk[i]); -clk_put (dev->clk[i]); - } -return ret; }
@@ -398,18 +379,12 @@ static int orion_mdio_remove(struct platform_device *pdev) {struct mii_bus *bus =platform_get_drvdata (pdev);struct orion_mdio_dev *dev = bus->priv; -int i;if (dev->err_interrupt >0 )writel (0 , dev->regs +MVMDIO_ERR_INT_MASK );mdiobus_unregister (bus); -for (i =0 ; i <ARRAY_SIZE (dev->clk); i++) { -if (IS_ERR (dev->clk[i])) -break ; -clk_disable_unprepare (dev->clk[i]); -clk_put (dev->clk[i]); - } +clk_bulk_disable_unprepare (MVMDIO_CLOCK_COUNT , dev->clks);return 0 ; }
Signature · 1 line
2.29.0
Andrew Lunn
maintainerRe: [net-next: PATCH v2 4/7] net: mvmdio: simplify clock handling
drivers/net/ethernet/marvell/mvmdio.c static int orion_mdio_probe(struct platform_device *pdev) · line 329
Quoted 6 lines
drivers/net/ethernet/marvell/mvmdio.c +6
-0+ dev->clks[0 ].id ="core" ; + dev->clks[1 ].id ="mg" ; + dev->clks[2 ].id ="mg_core" ; + dev->clks[3 ].id ="axi" ; + ret =devm_clk_bulk_get_optional (&pdev->dev,MVMDIO_CLOCK_COUNT , + dev->clks);
Kirkwood:
mdio: mdio-bus@72004 {
compatible = "marvell,orion-mdio";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x72004 0x84>;
interrupts = <46>;
clocks = <&gate_clk 0>;
status = "disabled";Does this work? There is no clock-names in DT.
Andrew
Re: [net-next: PATCH v2 4/7] net: mvmdio: simplify clock handling
śr., 16 cze 2021 o 21:48 Andrew Lunn <[email protected]> napisał(a):
Quoted 19 lines
drivers/net/ethernet/marvell/mvmdio.c static int orion_mdio_probe(struct platform_device *pdev) · line 329
Quoted 7 lines
drivers/net/ethernet/marvell/mvmdio.c +6
-0+ dev->clks[0 ].id ="core" ; + dev->clks[1 ].id ="mg" ; + dev->clks[2 ].id ="mg_core" ; + dev->clks[3 ].id ="axi" ; + ret =devm_clk_bulk_get_optional (&pdev->dev,MVMDIO_CLOCK_COUNT , + dev->clks);Kirkwood:
mdio: mdio-bus@72004 { compatible = "marvell,orion-mdio"; #address-cells = <1>; #size-cells = <0>; reg = <0x72004 0x84>; interrupts = <46>; clocks = <&gate_clk 0>; status = "disabled";
Quoted 2 lines
Does this work? There is no clock-names in DT.
Neither are the clocks in Armada 7k8k / CN913x:
CP11X_LABEL(mdio): mdio@12a200 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "marvell,orion-mdio";
reg = <0x12a200 0x10>;
clocks = <&CP11X_LABEL(clk) 1 9>,
<&CP11X_LABEL(clk) 1 5>,
<&CP11X_LABEL(clk) 1 6>,
<&CP11X_LABEL(clk) 1 18>;
status = "disabled";
};Apparently I misread the code and got convinced that contrary to devm_clk_get_optional(), the devm_clk_get_bulk_optional() obtains the clocks directly by index, not name (on the tested boards, the same clocks are enabled by the other interfaces, so the problems
I will drop this patch. Thank you for spotting the issue.
Best regards,
Marcin
Re: [net-next: PATCH v2 4/7] net: mvmdio: simplify clock handling
Quoted 38 lines · Marcin Wojtas
śr., 16 cze 2021 o 21:48 Andrew Lunn <[email protected]> napisał(a):
Quoted 19 lines
drivers/net/ethernet/marvell/mvmdio.c static int orion_mdio_probe(struct platform_device *pdev) · line 329
Quoted 7 lines
drivers/net/ethernet/marvell/mvmdio.c +6
-0+ dev->clks[0 ].id ="core" ; + dev->clks[1 ].id ="mg" ; + dev->clks[2 ].id ="mg_core" ; + dev->clks[3 ].id ="axi" ; + ret =devm_clk_bulk_get_optional (&pdev->dev,MVMDIO_CLOCK_COUNT , + dev->clks);Kirkwood:
mdio: mdio-bus@72004 { compatible = "marvell,orion-mdio"; #address-cells = <1>; #size-cells = <0>; reg = <0x72004 0x84>; interrupts = <46>; clocks = <&gate_clk 0>; status = "disabled";Quoted 2 lines
Does this work? There is no clock-names in DT.
Neither are the clocks in Armada 7k8k / CN913x:
CP11X_LABEL(mdio): mdio@12a200 { #address-cells = <1>; #size-cells = <0>; compatible = "marvell,orion-mdio"; reg = <0x12a200 0x10>; clocks = <&CP11X_LABEL(clk) 1 9>, <&CP11X_LABEL(clk) 1 5>, <&CP11X_LABEL(clk) 1 6>, <&CP11X_LABEL(clk) 1 18>; status = "disabled"; };
Quoted 4 lines
Apparently I misread the code and got convinced that contrary to
devm_clk_get_optional(), thedevm_clk_get_bulk_optional()obtains the clocks directly by index, not name (on the tested boards, the same clocks are enabled by the other interfaces, so the problems
Me too. Sorry for the wrong suggestion. I think we need something that actually gets clocks by indices in a bulk, but this is another story.
Quoted 1 line
I will drop this patch. Thank you for spotting the issue.
I'm fine with this.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 5/7 net: mvmdio: add ACPI support
In reply to Marcin WojtasThis patch introducing ACPI support for the mvmdio driver by adding acpi_match_table with two entries:
* "MRVL0100" for the SMI operation
* "MRVL0101" for the XSMI mode
Also clk enabling is skipped, because the tables do not contain such data and clock maintenance relies on the firmware.
--- drivers/net/ethernet/marvell/mvmdio.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mvmdio.c +12 -2
@@ -17,8 +17,10 @@* warranty of any kind, whether express or implied. */ +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/delay.h> +#include <linux/fwnode_mdio.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/kernel.h>
@@ -283,7 +285,7 @@ static int orion_mdio_probe(struct platform_device *pdev)struct orion_mdio_dev *dev;int ret; - type = (enum orion_mdio_bus_type )of_device_get_match_data (&pdev->dev); + type = (enum orion_mdio_bus_type )device_get_match_data (&pdev->dev); r =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!r) {
@@ -358,7 +360,7 @@ static int orion_mdio_probe(struct platform_device *pdev) goto out_mdio; } - ret =of_mdiobus_register (bus, pdev->dev.of_node); + ret =fwnode_mdiobus_register (bus, pdev->dev.fwnode);if (ret <0 ) {dev_err (&pdev->dev,"Cannot register MDIO bus (%d)\n" , ret); goto out_mdio;
@@ -396,12 +398,20 @@ static const struct of_device_id orion_mdio_match[] = { };MODULE_DEVICE_TABLE (of, orion_mdio_match); +static const struct acpi_device_id orion_mdio_acpi_match[] = { + {"MRVL0100" ,BUS_TYPE_SMI }, + {"MRVL0101" ,BUS_TYPE_XSMI }, + { }, +}; +MODULE_DEVICE_TABLE (acpi, orion_mdio_acpi_match); +static struct platform_driver orion_mdio_driver = { .probe = orion_mdio_probe, .remove = orion_mdio_remove, .driver = { .name ="orion-mdio" , .of_match_table = orion_mdio_match, + .acpi_match_table =ACPI_PTR (orion_mdio_acpi_match), }, };
Signature · 1 line
2.29.0
Andrew Lunn
maintainerRe: [net-next: PATCH v2 5/7] net: mvmdio: add ACPI support
Quoted 8 lines · Marcin Wojtas
This patch introducing ACPI support for the mvmdio driver by adding
acpi_match_tablewith two entries:* "MRVL0100" for the SMI operation
* "MRVL0101" for the XSMI modeAlso clk enabling is skipped, because the tables do not contain such data and clock maintenance relies on the firmware.
This last part seems to be no longer true.
Andrew
Re: [net-next: PATCH v2 5/7] net: mvmdio: add ACPI support
śr., 16 cze 2021 o 21:51 Andrew Lunn <[email protected]> napisał(a):
Quoted 13 lines · Marcin Wojtas
Quoted 8 lines
This patch introducing ACPI support for the mvmdio driver by adding
acpi_match_tablewith two entries:* "MRVL0100" for the SMI operation
* "MRVL0101" for the XSMI modeAlso clk enabling is skipped, because the tables do not contain such data and clock maintenance relies on the firmware.
This last part seems to be no longer true.
Well, it is still relies on firmware (no clocks are passed via ACPI), but skipping this enablement is hidden in the internals of devm_clk_bulk_get_optional() and clk_bulk_prepare_enable().
Best regards,
Marcin
Andrew Lunn
maintainerRe: [net-next: PATCH v2 5/7] net: mvmdio: add ACPI support
Quoted 12 lines · Marcin Wojtas
śr., 16 cze 2021 o 21:51 Andrew Lunn <[email protected]> napisał(a):
Quoted 11 lines · Marcin Wojtas
Quoted 8 lines
This patch introducing ACPI support for the mvmdio driver by adding
acpi_match_tablewith two entries:* "MRVL0100" for the SMI operation
* "MRVL0101" for the XSMI modeAlso clk enabling is skipped, because the tables do not contain such data and clock maintenance relies on the firmware.
Quoted 6 lines
Quoted 2 lines
This last part seems to be no longer true.
Well, it is still relies on firmware (no clocks are passed via ACPI), but skipping this enablement is hidden in the internals of
devm_clk_bulk_get_optional()andclk_bulk_prepare_enable().
A quick grep in driver/clk does not reveal any ACPI code. Nor did i spot any generic clock code in drivers/acpi. So even if you did add clocks to the tables, i don't see how they would be used.
Andrew
PATCH v2 6/7 net: mvpp2: enable using phylink with ACPI
In reply to Marcin WojtasNow that the MDIO and phylink are supported in the ACPI world, enable to use them in the mvpp2 driver. Ensure a backward compatibility with the firmware whose ACPI description does not contain the necessary elements for the proper phy handling and fall back to relying on the link interrupts instead.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 22 +++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +17 -5
@@ -4793,9 +4793,8 @@ static int mvpp2_open(struct net_device *dev) goto err_cleanup_txqs; } -/* Phylink isn't supported yet in ACPI mode */ -if (port->of_node) { - err =phylink_of_phy_connect (port->phylink, port->of_node,0 ); +if (port->phylink) { + err =phylink_fwnode_phy_connect (port->phylink, port->fwnode,0 );if (err) {netdev_err (port->dev,"could not attach PHY (%d)\n" , err);
@@ -6703,6 +6702,19 @@ static void mvpp2_acpi_start(struct mvpp2_port *port) SPEED_UNKNOWN, DUPLEX_UNKNOWN, false, false); } +/* In order to ensure backward compatibility for ACPI, check if the port +* firmware node comprises the necessary description allowing to use phylink. +*/ +static bool mvpp2_use_acpi_compat_mode (struct fwnode_handle *port_fwnode) +{ +if (!is_acpi_node (port_fwnode)) +return false; + +return (!fwnode_property_present (port_fwnode,"phy-handle" ) && + !fwnode_property_present (port_fwnode,"managed" ) && + !fwnode_get_named_child_node (port_fwnode,"fixed-link" )); +} +/* Ports initialization */ static int mvpp2_port_probe(struct platform_device *pdev, struct fwnode_handle *port_fwnode,
@@ -6921,8 +6933,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, dev->max_mtu =MVPP2_BM_JUMBO_PKT_SIZE ; dev->dev.of_node = port_node; -/* Phylink isn't used w/ ACPI as of now */ -if (port_node) { +if (!mvpp2_use_acpi_compat_mode (port_fwnode)) { port->phylink_config.dev = &dev->dev; port->phylink_config.type =PHYLINK_NETDEV ;
@@ -6934,6 +6945,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, } port->phylink = phylink; }else { +dev_warn (&pdev->dev,"Use link irqs for port#%d. FW update required\n" , port->id); port->phylink =NULL ; }
Signature · 1 line
2.29.0
PATCH v2 7/7 net: mvpp2: remove unused 'has_phy' field
In reply to Marcin WojtasThe 'has_phy' field from struct mvpp2_port is no longer used. Remove it.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 3 --- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 1 - 2 files changed, 4 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +0 -3
@@ -1197,9 +1197,6 @@ struct mvpp2_port {/* Firmware node associated to the port */ struct fwnode_handle *fwnode; -/* Is a PHY always connected to the port */ -bool has_phy; -/* Per-port registers' base address */ void __iomem *base;void __iomem *stats_base;
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +0 -1
@@ -6790,7 +6790,6 @@ static int mvpp2_port_probe(struct platform_device *pdev, port =netdev_priv (dev); port->dev = dev; port->fwnode = port_fwnode; - port->has_phy = !!of_find_property (port_node,"phy" ,NULL ); port->ntxqs = ntxqs; port->nrxqs = nrxqs; port->priv = priv;
Signature · 1 line
2.29.0
Re: [net-next: PATCH v2 7/7] net: mvpp2: remove unused 'has_phy' field
Quoted 4 lines · Marcin Wojtas
The '
has_phy' field from structmvpp2_portis no longer used. Remove it.Signed-off-by Marcin Wojtas <[email protected]>
Andrew