From: Marcin Wojtas <hidden> Date: 2021-06-16 19:08:25
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(-)
--
2.29.0
From: Marcin Wojtas <hidden> Date: 2021-06-16 19:08:32
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
Signed-off-by: Marcin Wojtas <redacted>
---
Documentation/firmware-guide/acpi/dsd/phy.rst | 55 ++++++++++++++++++++
1 file changed, 55 insertions(+)
@@ -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 ==========
From: Marcin Wojtas <hidden> Date: 2021-06-16 19:08:35
This 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.
Signed-off-by: Marcin Wojtas <redacted>
---
include/linux/fwnode_mdio.h | 12 +++++++++++
drivers/net/mdio/fwnode_mdio.c | 22 ++++++++++++++++++++
2 files changed, 34 insertions(+)
From: Marcin Wojtas <hidden> Date: 2021-06-16 19:08:36
Utilize the newly added helper routine
for registering the MDIO bus via fwnode_
interface.
Signed-off-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/freescale/xgmac_mdio.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
@@ -246,7 +246,6 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum)staticintxgmac_mdio_probe(structplatform_device*pdev){-structfwnode_handle*fwnode;structmdio_fsl_priv*priv;structresource*res;structmii_bus*bus;
From: Marcin Wojtas <hidden> Date: 2021-06-16 19:08:39
Because 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.
Suggested-by: Andy Shevchenko <redacted>
Signed-off-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvmdio.c | 61 ++++++--------------
1 file changed, 18 insertions(+), 43 deletions(-)
@@ -279,7 +281,7 @@ static int orion_mdio_probe(struct platform_device *pdev)structresource*r;structmii_bus*bus;structorion_mdio_dev*dev;-inti,ret;+intret;type=(enumorion_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;-gotoout_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;-gotoout_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)+returnret;+ret=clk_bulk_prepare_enable(MVMDIO_CLOCK_COUNT,dev->clks);+if(ret){+dev_err(&pdev->dev,"Cannot enable clocks\n");+returnret;+}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]);-}-returnret;}
@@ -398,18 +379,12 @@ static int orion_mdio_remove(struct platform_device *pdev){structmii_bus*bus=platform_get_drvdata(pdev);structorion_mdio_dev*dev=bus->priv;-inti;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);return0;}
From: Marcin Wojtas <hidden> Date: 2021-06-16 19:08:46
This 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.
Signed-off-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvmdio.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
From: Marcin Wojtas <hidden> Date: 2021-06-16 19:08:48
Now 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.
Signed-off-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 22 +++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
@@ -4793,9 +4793,8 @@ static int mvpp2_open(struct net_device *dev)gotoerr_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+*firmwarenodecomprisesthenecessarydescriptionallowingtousephylink.+*/+staticboolmvpp2_use_acpi_compat_mode(structfwnode_handle*port_fwnode)+{+if(!is_acpi_node(port_fwnode))+returnfalse;++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 */staticintmvpp2_port_probe(structplatform_device*pdev,structfwnode_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;}
From: Marcin Wojtas <hidden> Date: 2021-06-16 19:08:50
The 'has_phy' field from struct mvpp2_port is no longer used.
Remove it.
Signed-off-by: Marcin Wojtas <redacted>
---
drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 3 ---
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 1 -
2 files changed, 4 deletions(-)
@@ -1197,9 +1197,6 @@ struct mvpp2_port {/* Firmware node associated to the port */structfwnode_handle*fwnode;-/* Is a PHY always connected to the port */-boolhas_phy;-/* Per-port registers' base address */void__iomem*base;void__iomem*stats_base;
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-06-16 19:33:19
On Wed, Jun 16, 2021 at 09:07:54PM +0200, Marcin Wojtas wrote:
This 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.
@@ -30,6 +31,17 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,{return-EINVAL;}++staticinlineintfwnode_mdiobus_register(structmii_bus*bus,+structfwnode_handle*fwnode)+{+/*+*Fallbacktomdiobus_register()functiontoregisterabus.+*Thisway,wedon'thavetokeepcompatbitsaroundindrivers.+*/++returnmdiobus_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
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
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-06-16 19:51:09
On Wed, Jun 16, 2021 at 09:07:57PM +0200, Marcin Wojtas wrote:
This 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.
From: Marcin Wojtas <hidden> Date: 2021-06-16 22:37:22
śr., 16 cze 2021 o 21:51 Andrew Lunn [off-list ref] napisał(a):
On Wed, Jun 16, 2021 at 09:07:57PM +0200, Marcin Wojtas wrote:
quoted
This 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.
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
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-06-16 23:01:41
On Thu, Jun 17, 2021 at 12:37:06AM +0200, Marcin Wojtas wrote:
śr., 16 cze 2021 o 21:51 Andrew Lunn [off-list ref] napisał(a):
quoted
On Wed, Jun 16, 2021 at 09:07:57PM +0200, Marcin Wojtas wrote:
quoted
This 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.
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().
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
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.
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
From: Marcin Wojtas <hidden> Date: 2021-06-16 23:51:14
śr., 16 cze 2021 o 21:33 Andrew Lunn [off-list ref] napisał(a):
On Wed, Jun 16, 2021 at 09:07:54PM +0200, Marcin Wojtas wrote:
quoted
This 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.
@@ -30,6 +31,17 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,{return-EINVAL;}++staticinlineintfwnode_mdiobus_register(structmii_bus*bus,+structfwnode_handle*fwnode)+{+/*+*Fallbacktomdiobus_register()functiontoregisterabus.+*Thisway,wedon'thavetokeepcompatbitsaroundindrivers.+*/++returnmdiobus_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.
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
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.
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
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.
I will drop this patch. Thank you for spotting the issue.
I'm fine with this.
--
With Best Regards,
Andy Shevchenko
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
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-06-17 12:59:12
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
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.
Ok, I'll leave:
depends on FWNODE_MDIO
only.
Thanks,
Marcin