From: Ioana Ciornei <ioana.ciornei@nxp.com>
This patch set provides ACPI support to DPAA2 network drivers.
It also introduces new fwnode based APIs to support phylink and phy
layers
Following functions are defined:
phylink_fwnode_phy_connect()
fwnode_mdiobus_register_phy()
fwnode_get_phy_id()
fwnode_phy_find_device()
device_phy_find_device()
fwnode_get_phy_node()
fwnode_mdio_find_device()
acpi_get_local_address()
First one helps in connecting phy to phylink instance.
Next three helps in getting phy_id and registering phy to mdiobus
Next two help in finding a phy on a mdiobus.
Next one helps in getting phy_node from a fwnode.
Last one is used to get local address from _ADR object.
Corresponding OF functions are refactored.
Tested-on: LX2160ARDB
Changes in v8:
- fixed some checkpatch warnings/checks
- included linux/fwnode_mdio.h in fwnode_mdio.c (fixed the build warnings)
- added fwnode_find_mii_timestamper() and
fwnode_mdiobus_phy_device_register() in order to get rid of the cycle
dependency.
- change to 'depends on (ACPI || OF) || COMPILE_TEST (for FWNODE_MDIO)
- remove the fwnode_mdiobus_register from fwnode_mdio.c since it
introduces a cycle of dependencies.
Changes in v7:
- correct fwnode_mdio_find_device() description
- check NULL in unregister_mii_timestamper()
- Call unregister_mii_timestamper() without NULL check
- Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()
- include fwnode_mdio.h
- Include headers directly used in acpi_mdio.c
- Move fwnode_mdiobus_register() to fwnode_mdio.c
- Include fwnode_mdio.h
- Alphabetically sort header inclusions
- remove unnecassary checks
Changes in v6:
- Minor cleanup
- fix warning for function parameter of fwnode_mdio_find_device()
- Initialize mii_ts to NULL
- use GENMASK() and ACPI_COMPANION_SET()
- some cleanup
- remove unwanted header inclusion
- remove OF check for fixed-link
- use dev_fwnode()
- remove useless else
- replace of_device_is_available() to fwnode_device_is_available()
Changes in v5:
- More cleanup
- Replace fwnode_get_id() with acpi_get_local_address()
- add missing MODULE_LICENSE()
- replace fwnode_get_id() with OF and ACPI function calls
- replace fwnode_get_id() with OF and ACPI function calls
Changes in v4:
- More cleanup
- Improve code structure to handle all cases
- Remove redundant else from fwnode_mdiobus_register()
- Cleanup xgmac_mdio_probe()
- call phy_device_free() before returning
Changes in v3:
- Add more info on legacy DT properties "phy" and "phy-device"
- Redefine fwnode_phy_find_device() to follow of_phy_find_device()
- Use traditional comparison pattern
- Use GENMASK
- Modified to retrieve reg property value for ACPI as well
- Resolved compilation issue with CONFIG_ACPI = n
- Added more info into documentation
- Use acpi_mdiobus_register()
- Avoid unnecessary line removal
- Remove unused inclusion of acpi.h
Changes in v2:
- Updated with more description in document
- use reverse christmas tree ordering for local variables
- Refactor OF functions to use fwnode functions
Calvin Johnson (15):
Documentation: ACPI: DSD: Document MDIO PHY
net: phy: Introduce fwnode_mdio_find_device()
net: phy: Introduce phy related fwnode functions
of: mdio: Refactor of_phy_find_device()
net: phy: Introduce fwnode_get_phy_id()
of: mdio: Refactor of_get_phy_id()
net: mii_timestamper: check NULL in unregister_mii_timestamper()
net: mdiobus: Introduce fwnode_mdiobus_register_phy()
of: mdio: Refactor of_mdiobus_register_phy()
ACPI: utils: Introduce acpi_get_local_address()
net: mdio: Add ACPI support code for mdio
net/fsl: Use [acpi|of]_mdiobus_register
net: phylink: introduce phylink_fwnode_phy_connect()
net: phylink: Refactor phylink_of_phy_connect()
net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++
MAINTAINERS | 2 +
drivers/acpi/utils.c | 14 ++
.../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 88 ++++++-----
.../net/ethernet/freescale/dpaa2/dpaa2-mac.h | 2 +-
drivers/net/ethernet/freescale/xgmac_mdio.c | 30 ++--
drivers/net/mdio/Kconfig | 14 ++
drivers/net/mdio/Makefile | 4 +-
drivers/net/mdio/acpi_mdio.c | 56 +++++++
drivers/net/mdio/fwnode_mdio.c | 144 ++++++++++++++++++
drivers/net/mdio/of_mdio.c | 138 ++---------------
drivers/net/phy/mii_timestamper.c | 3 +
drivers/net/phy/phy_device.c | 109 ++++++++++++-
drivers/net/phy/phylink.c | 41 +++--
include/linux/acpi.h | 7 +
include/linux/acpi_mdio.h | 26 ++++
include/linux/fwnode_mdio.h | 35 +++++
include/linux/phy.h | 32 ++++
include/linux/phylink.h | 3 +
19 files changed, 691 insertions(+), 190 deletions(-)
create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
create mode 100644 drivers/net/mdio/acpi_mdio.c
create mode 100644 drivers/net/mdio/fwnode_mdio.c
create mode 100644 include/linux/acpi_mdio.h
create mode 100644 include/linux/fwnode_mdio.h
--
2.31.1
From: Calvin Johnson <redacted>
Introduce ACPI mechanism to get PHYs registered on a MDIO bus and
provide them to be connected to MAC.
Describe properties "phy-handle" and "phy-mode".
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7: None
Changes in v6:
- Minor cleanup
Changes in v5:
- More cleanup
Changes in v4:
- More cleanup
Changes in v3: None
Changes in v2:
- Updated with more description in document
Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++
1 file changed, 133 insertions(+)
create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
@@ -0,0 +1,133 @@+.. SPDX-License-Identifier: GPL-2.0++=========================+MDIO bus and PHYs in ACPI+=========================++The PHYs on an MDIO bus [1] are probed and registered using+fwnode_mdiobus_register_phy().++Later, for connecting these PHYs to their respective MACs, the PHYs registered+on the MDIO bus have to be referenced.++This document introduces two _DSD properties that are to be used+for connecting PHYs on the MDIO bus [3] to the MAC layer.++These properties are defined in accordance with the "Device+Properties UUID For _DSD" [2] document and the+daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID must be used in the Device+Data Descriptors containing them.++phy-handle+----------+For each MAC node, a device property "phy-handle" is used to reference+the PHY that is registered on an MDIO bus. This is mandatory for+network interfaces that have PHYs connected to MAC via MDIO bus.++During the MDIO bus driver initialization, PHYs on this bus are probed+using the _ADR object as shown below and are registered on the MDIO bus.++::+ Scope(\_SB.MDI0)+ {+ Device(PHY1) {+ Name (_ADR, 0x1)+ } // end of PHY1++ Device(PHY2) {+ Name (_ADR, 0x2)+ } // end of PHY2+ }++Later, during the MAC driver initialization, the registered PHY devices+have to be retrieved from the MDIO bus. For this, the MAC driver needs+references to the previously registered PHYs which are provided+as device object references (e.g. \_SB.MDI0.PHY1).++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].++The following ASL example illustrates the usage of these properties.++DSDT entry for MDIO node+------------------------++The MDIO bus has an SoC component (MDIO controller) and a platform+component (PHYs on the MDIO bus).++a) Silicon Component+This node describes the MDIO controller, MDI0+---------------------------------------------+::+ Scope(_SB)+ {+ Device(MDI0) {+ Name(_HID, "NXP0006")+ Name(_CCA, 1)+ Name(_UID, 0)+ Name(_CRS, ResourceTemplate() {+ Memory32Fixed(ReadWrite, MDI0_BASE, MDI_LEN)+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared)+ {+ MDI0_IT+ }+ }) // end of _CRS for MDI0+ } // end of MDI0+ }++b) Platform Component+The PHY1 and PHY2 nodes represent the PHYs connected to MDIO bus MDI0+---------------------------------------------------------------------+::+ Scope(\_SB.MDI0)+ {+ Device(PHY1) {+ Name (_ADR, 0x1)+ } // end of PHY1++ Device(PHY2) {+ Name (_ADR, 0x2)+ } // end of PHY2+ }++DSDT entries representing MAC nodes+-----------------------------------++Below are the MAC nodes where PHY nodes are referenced.+phy-mode and phy-handle are used as explained earlier.+------------------------------------------------------+::+ Scope(\_SB.MCE0.PR17)+ {+ Name (_DSD, Package () {+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),+ Package () {+ Package (2) {"phy-mode", "rgmii-id"},+ Package (2) {"phy-handle", \_SB.MDI0.PHY1}+ }+ })+ }++ Scope(\_SB.MCE0.PR18)+ {+ Name (_DSD, Package () {+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),+ Package () {+ Package (2) {"phy-mode", "rgmii-id"},+ Package (2) {"phy-handle", \_SB.MDI0.PHY2}}+ }+ })+ }++References+==========++[1] Documentation/networking/phy.rst++[2] https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf++[3] Documentation/firmware-guide/acpi/DSD-properties-rules.rst++[4] Documentation/devicetree/bindings/net/ethernet-controller.yaml
From: Calvin Johnson <redacted>
Introduce fwnode_mdiobus_register_phy() to register PHYs on the
mdiobus. From the compatible string, identify whether the PHY is
c45 and based on this create a PHY device instance which is
registered on the mdiobus.
Along with fwnode_mdiobus_register_phy() also introduce
fwnode_find_mii_timestamper() and fwnode_mdiobus_phy_device_register()
since they are needed.
While at it, also use the newly introduced fwnode operation in
of_mdiobus_phy_device_register() and remove of_find_mii_timestamper()
since it's not needed anymore.
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8:
- fixed some checkpatch warnings/checks
- included linux/fwnode_mdio.h in fwnode_mdio.c (fixed the build warnings)
- added fwnode_find_mii_timestamper() and fwnode_mdiobus_phy_device_register()
in order to get rid of the cycle dependency.
- change to 'depends on (ACPI || OF) || COMPILE_TEST
Changes in v7:
- Call unregister_mii_timestamper() without NULL check
- Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()
Changes in v6:
- Initialize mii_ts to NULL
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
MAINTAINERS | 1 +
drivers/net/mdio/Kconfig | 7 ++
drivers/net/mdio/Makefile | 3 +-
drivers/net/mdio/fwnode_mdio.c | 144 +++++++++++++++++++++++++++++++++
drivers/net/mdio/of_mdio.c | 61 +-------------
include/linux/fwnode_mdio.h | 35 ++++++++
6 files changed, 193 insertions(+), 58 deletions(-)
create mode 100644 drivers/net/mdio/fwnode_mdio.c
create mode 100644 include/linux/fwnode_mdio.h
@@ -1,7 +1,8 @@# SPDX-License-Identifier: GPL-2.0# Makefile for Linux MDIO bus drivers-obj-$(CONFIG_OF_MDIO)+=of_mdio.o+obj-$(CONFIG_FWNODE_MDIO)+=fwnode_mdio.o+obj-$(CONFIG_OF_MDIO)+=of_mdio.oobj-$(CONFIG_MDIO_ASPEED)+=mdio-aspeed.oobj-$(CONFIG_MDIO_BCM_IPROC)+=mdio-bcm-iproc.o
@@ -0,0 +1,144 @@+// SPDX-License-Identifier: GPL-2.0-only+/*+*fwnodehelpersfortheMDIO(EthernetPHY)API+*+*ThisfileprovideshelperfunctionsforextractingPHYdeviceinformation+*outofthefwnodeandusingittopopulateanmii_bus.+*/++#include<linux/acpi.h>+#include<linux/fwnode_mdio.h>+#include<linux/of.h>+#include<linux/phy.h>++MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");+MODULE_LICENSE("GPL");++staticstructmii_timestamper*+fwnode_find_mii_timestamper(structfwnode_handle*fwnode)+{+structof_phandle_argsarg;+interr;++if(is_acpi_node(fwnode))+returnNULL;++err=of_parse_phandle_with_fixed_args(to_of_node(fwnode),"timestamper",1,0,&arg);++if(err==-ENOENT)+returnNULL;+elseif(err)+returnERR_PTR(err);++if(arg.args_count!=1)+returnERR_PTR(-EINVAL);++returnregister_mii_timestamper(arg.np,arg.args[0]);+}++intfwnode_mdiobus_phy_device_register(structmii_bus*mdio,+structphy_device*phy,+structfwnode_handle*child,u32addr)+{+intrc;++rc=fwnode_irq_get(child,0);+if(rc==-EPROBE_DEFER)+returnrc;++if(rc>0){+phy->irq=rc;+mdio->irq[addr]=rc;+}else{+phy->irq=mdio->irq[addr];+}++if(fwnode_property_read_bool(child,"broken-turn-around"))+mdio->phy_ignore_ta_mask|=1<<addr;++fwnode_property_read_u32(child,"reset-assert-us",+&phy->mdio.reset_assert_delay);+fwnode_property_read_u32(child,"reset-deassert-us",+&phy->mdio.reset_deassert_delay);++/* Associate the fwnode with the device structure so it+*canbelookeduplater+*/+fwnode_handle_get(child);+phy->mdio.dev.fwnode=child;++/* All data is now stored in the phy struct;+*registerit+*/+rc=phy_device_register(phy);+if(rc){+fwnode_handle_put(child);+returnrc;+}++dev_dbg(&mdio->dev,"registered phy %p fwnode at address %i\n",+child,addr);+return0;+}+EXPORT_SYMBOL(fwnode_mdiobus_phy_device_register);++intfwnode_mdiobus_register_phy(structmii_bus*bus,+structfwnode_handle*child,u32addr)+{+structmii_timestamper*mii_ts=NULL;+structphy_device*phy;+boolis_c45=false;+u32phy_id;+intrc;++mii_ts=fwnode_find_mii_timestamper(child);+if(IS_ERR(mii_ts))+returnPTR_ERR(mii_ts);++rc=fwnode_property_match_string(child,"compatible",+"ethernet-phy-ieee802.3-c45");+if(rc>=0)+is_c45=true;++if(is_c45||fwnode_get_phy_id(child,&phy_id))+phy=get_phy_device(bus,addr,is_c45);+else+phy=phy_device_create(bus,addr,phy_id,0,NULL);+if(IS_ERR(phy)){+unregister_mii_timestamper(mii_ts);+returnPTR_ERR(phy);+}++if(is_acpi_node(child)){+phy->irq=bus->irq[addr];++/* Associate the fwnode with the device structure so it+*canbelookeduplater.+*/+phy->mdio.dev.fwnode=child;++/* All data is now stored in the phy struct, so register it */+rc=phy_device_register(phy);+if(rc){+phy_device_free(phy);+fwnode_handle_put(phy->mdio.dev.fwnode);+returnrc;+}+}elseif(is_of_node(child)){+rc=fwnode_mdiobus_phy_device_register(bus,phy,child,addr);+if(rc){+unregister_mii_timestamper(mii_ts);+phy_device_free(phy);+returnrc;+}+}++/* phy->mii_ts may already be defined by the PHY driver. A+*mii_timestamperprobedviathedevicetreewillstillhave+*precedence.+*/+if(mii_ts)+phy->mii_ts=mii_ts;+return0;+}+EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
@@ -32,65 +32,12 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)returnfwnode_get_phy_id(of_fwnode_handle(device),phy_id);}-staticstructmii_timestamper*of_find_mii_timestamper(structdevice_node*node)-{-structof_phandle_argsarg;-interr;--err=of_parse_phandle_with_fixed_args(node,"timestamper",1,0,&arg);--if(err==-ENOENT)-returnNULL;-elseif(err)-returnERR_PTR(err);--if(arg.args_count!=1)-returnERR_PTR(-EINVAL);--returnregister_mii_timestamper(arg.np,arg.args[0]);-}-intof_mdiobus_phy_device_register(structmii_bus*mdio,structphy_device*phy,-structdevice_node*child,u32addr)+structdevice_node*child,u32addr){-intrc;--rc=of_irq_get(child,0);-if(rc==-EPROBE_DEFER)-returnrc;--if(rc>0){-phy->irq=rc;-mdio->irq[addr]=rc;-}else{-phy->irq=mdio->irq[addr];-}--if(of_property_read_bool(child,"broken-turn-around"))-mdio->phy_ignore_ta_mask|=1<<addr;--of_property_read_u32(child,"reset-assert-us",-&phy->mdio.reset_assert_delay);-of_property_read_u32(child,"reset-deassert-us",-&phy->mdio.reset_deassert_delay);--/* Associate the OF node with the device structure so it-*canbelookeduplater*/-of_node_get(child);-phy->mdio.dev.of_node=child;-phy->mdio.dev.fwnode=of_fwnode_handle(child);--/* All data is now stored in the phy struct;-*registerit*/-rc=phy_device_register(phy);-if(rc){-of_node_put(child);-returnrc;-}--dev_dbg(&mdio->dev,"registered phy %pOFn at address %i\n",-child,addr);-return0;+returnfwnode_mdiobus_phy_device_register(mdio,phy,+of_fwnode_handle(child),+addr);}EXPORT_SYMBOL(of_mdiobus_phy_device_register);
From: Calvin Johnson <redacted>
Define fwnode_phy_find_device() to iterate an mdiobus and find the
phy device of the provided phy fwnode. Additionally define
device_phy_find_device() to find phy device of provided device.
Define fwnode_get_phy_node() to get phy_node using named reference.
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Add more info on legacy DT properties "phy" and "phy-device"
- Redefine fwnode_phy_find_device() to follow of_phy_find_device()
Changes in v2:
- use reverse christmas tree ordering for local variables
drivers/net/phy/phy_device.c | 62 ++++++++++++++++++++++++++++++++++++
include/linux/phy.h | 20 ++++++++++++
2 files changed, 82 insertions(+)
@@ -2886,6 +2887,67 @@ struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)}EXPORT_SYMBOL(fwnode_mdio_find_device);+/**+*fwnode_phy_find_device-Forprovidedphy_fwnode,findphy_device.+*+*@phy_fwnode:Pointertothephy'sfwnode.+*+*Ifsuccessful,returnsapointertothephy_devicewiththeembedded+*structdevicerefcountincrementedbyone,orNULLonfailure.+*/+structphy_device*fwnode_phy_find_device(structfwnode_handle*phy_fwnode)+{+structmdio_device*mdiodev;++mdiodev=fwnode_mdio_find_device(phy_fwnode);+if(!mdiodev)+returnNULL;++if(mdiodev->flags&MDIO_DEVICE_FLAG_PHY)+returnto_phy_device(&mdiodev->dev);++put_device(&mdiodev->dev);++returnNULL;+}+EXPORT_SYMBOL(fwnode_phy_find_device);++/**+*device_phy_find_device-Forthegivendevice,getthephy_device+*@dev:Pointertothegivendevice+*+*Referreturnconditionsoffwnode_phy_find_device().+*/+structphy_device*device_phy_find_device(structdevice*dev)+{+returnfwnode_phy_find_device(dev_fwnode(dev));+}+EXPORT_SYMBOL_GPL(device_phy_find_device);++/**+*fwnode_get_phy_node-Getthephy_nodeusingthenamedreference.+*@fwnode:Pointertofwnodefromwhichphy_nodehastobeobtained.+*+*Referreturnconditionsoffwnode_find_reference().+*ForACPI,only"phy-handle"issupported.LegacyDTproperties"phy"+*and"phy-device"arenotsupportedinACPI.DTsupportsallthethree+*namedreferencestothephynode.+*/+structfwnode_handle*fwnode_get_phy_node(structfwnode_handle*fwnode)+{+structfwnode_handle*phy_node;++/* Only phy-handle is used for ACPI */+phy_node=fwnode_find_reference(fwnode,"phy-handle",0);+if(is_acpi_node(fwnode)||!IS_ERR(phy_node))+returnphy_node;+phy_node=fwnode_find_reference(fwnode,"phy",0);+if(IS_ERR(phy_node))+phy_node=fwnode_find_reference(fwnode,"phy-device",0);+returnphy_node;+}+EXPORT_SYMBOL_GPL(fwnode_get_phy_node);+/***phy_probe-probeandinitaPHYdevice*@dev:devicetoprobeandinit
From: Calvin Johnson <redacted>
With the introduction of fwnode_get_phy_id(), refactor of_get_phy_id()
to use fwnode equivalent.
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/net/mdio/of_mdio.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
From: Calvin Johnson <redacted>
Define phylink_fwnode_phy_connect() to connect phy specified by
a fwnode to a phylink instance.
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7: None
Changes in v6:
- remove OF check for fixed-link
Changes in v5: None
Changes in v4:
- call phy_device_free() before returning
Changes in v3: None
Changes in v2: None
drivers/net/phy/phylink.c | 54 +++++++++++++++++++++++++++++++++++++++
include/linux/phylink.h | 3 +++
2 files changed, 57 insertions(+)
@@ -1125,6 +1126,59 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,}EXPORT_SYMBOL_GPL(phylink_of_phy_connect);+/**+*phylink_fwnode_phy_connect()-connectthePHYspecifiedinthefwnode.+*@pl:apointertoa&structphylinkreturnedfromphylink_create()+*@fwnode:apointertoa&structfwnode_handle.+*@flags:PHY-specificflagstocommunicatetothePHYdevicedriver+*+*Connectthephyspecified@fwnodetothephylinkinstancespecified+*by@pl.+*+*Returns0onsuccessoranegativeerrno.+*/+intphylink_fwnode_phy_connect(structphylink*pl,+structfwnode_handle*fwnode,+u32flags)+{+structfwnode_handle*phy_fwnode;+structphy_device*phy_dev;+intret;++/* Fixed links and 802.3z are handled without needing a PHY */+if(pl->cfg_link_an_mode==MLO_AN_FIXED||+(pl->cfg_link_an_mode==MLO_AN_INBAND&&+phy_interface_mode_is_8023z(pl->link_interface)))+return0;++phy_fwnode=fwnode_get_phy_node(fwnode);+if(IS_ERR(phy_fwnode)){+if(pl->cfg_link_an_mode==MLO_AN_PHY)+return-ENODEV;+return0;+}++phy_dev=fwnode_phy_find_device(phy_fwnode);+/* We're done with the phy_node handle */+fwnode_handle_put(phy_fwnode);+if(!phy_dev)+return-ENODEV;++ret=phy_attach_direct(pl->netdev,phy_dev,flags,+pl->link_interface);+if(ret){+phy_device_free(phy_dev);+returnret;+}++ret=phylink_bringup_phy(pl,phy_dev,pl->link_config.interface);+if(ret)+phy_detach(phy_dev);++returnret;+}+EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect);+/***phylink_disconnect_phy()-disconnectanyPHYattachedtothephylink*instance.
From: Calvin Johnson <redacted>
Define fwnode_mdio_find_device() to get a pointer to the
mdio_device from fwnode passed to the function.
Refactor of_mdio_find_device() to use fwnode_mdio_find_device().
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7:
- correct fwnode_mdio_find_device() description
Changes in v6:
- fix warning for function parameter of fwnode_mdio_find_device()
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/net/mdio/of_mdio.c | 11 +----------
drivers/net/phy/phy_device.c | 23 +++++++++++++++++++++++
include/linux/phy.h | 7 +++++++
3 files changed, 31 insertions(+), 10 deletions(-)
From: Calvin Johnson <redacted>
Callers of unregister_mii_timestamper() currently check for NULL
value of mii_ts before calling it.
Place the NULL check inside unregister_mii_timestamper() and update
the callers accordingly.
Signed-off-by: Calvin Johnson <redacted>
Reviewed-by: Andy Shevchenko <redacted>
Suggested-by: Andy Shevchenko <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7:
- check NULL in unregister_mii_timestamper()
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/net/mdio/of_mdio.c | 6 ++----
drivers/net/phy/mii_timestamper.c | 3 +++
drivers/net/phy/phy_device.c | 3 +--
3 files changed, 6 insertions(+), 6 deletions(-)
From: Calvin Johnson <redacted>
Extract phy_id from compatible string. This will be used by
fwnode_mdiobus_register_phy() to create phy device using the
phy_id.
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Use traditional comparison pattern
- Use GENMASK
Changes in v2: None
drivers/net/phy/phy_device.c | 21 +++++++++++++++++++++
include/linux/phy.h | 5 +++++
2 files changed, 26 insertions(+)
@@ -834,6 +834,27 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)return0;}+/* Extract the phy ID from the compatible string of the form+*ethernet-phy-idAAAA.BBBB.+*/+intfwnode_get_phy_id(structfwnode_handle*fwnode,u32*phy_id)+{+unsignedintupper,lower;+constchar*cp;+intret;++ret=fwnode_property_read_string(fwnode,"compatible",&cp);+if(ret)+returnret;++if(sscanf(cp,"ethernet-phy-id%4x.%4x",&upper,&lower)!=2)+return-EINVAL;++*phy_id=((upper&GENMASK(15,0))<<16)|(lower&GENMASK(15,0));+return0;+}+EXPORT_SYMBOL(fwnode_get_phy_id);+/***get_phy_device-readsthespecifiedPHYdeviceandreturnsits@phy_device*struct
From: Calvin Johnson <redacted>
Refactor of_mdiobus_register_phy() to use fwnode_mdiobus_register_phy().
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7:
- include fwnode_mdio.h
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/net/mdio/of_mdio.c | 39 ++------------------------------------
1 file changed, 2 insertions(+), 37 deletions(-)
@@ -44,43 +45,7 @@ EXPORT_SYMBOL(of_mdiobus_phy_device_register);staticintof_mdiobus_register_phy(structmii_bus*mdio,structdevice_node*child,u32addr){-structmii_timestamper*mii_ts;-structphy_device*phy;-boolis_c45;-intrc;-u32phy_id;--mii_ts=of_find_mii_timestamper(child);-if(IS_ERR(mii_ts))-returnPTR_ERR(mii_ts);--is_c45=of_device_is_compatible(child,-"ethernet-phy-ieee802.3-c45");--if(!is_c45&&!of_get_phy_id(child,&phy_id))-phy=phy_device_create(mdio,addr,phy_id,0,NULL);-else-phy=get_phy_device(mdio,addr,is_c45);-if(IS_ERR(phy)){-unregister_mii_timestamper(mii_ts);-returnPTR_ERR(phy);-}--rc=of_mdiobus_phy_device_register(mdio,phy,child,addr);-if(rc){-unregister_mii_timestamper(mii_ts);-phy_device_free(phy);-returnrc;-}--/* phy->mii_ts may already be defined by the PHY driver. A-*mii_timestamperprobedviathedevicetreewillstillhave-*precedence.-*/-if(mii_ts)-phy->mii_ts=mii_ts;--return0;+returnfwnode_mdiobus_register_phy(mdio,of_fwnode_handle(child),addr);}staticintof_mdiobus_register_device(structmii_bus*mdio,
From: Calvin Johnson <redacted>
Modify dpaa2_mac_get_node() to get the dpmac fwnode from either
DT or ACPI.
Modify dpaa2_mac_get_if_mode() to get interface mode from dpmac_node
which is a fwnode.
Modify dpaa2_pcs_create() to create pcs from dpmac_node fwnode.
Modify dpaa2_mac_connect() to support ACPI along with DT.
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8:
- adjust code over latest changes applied on the driver
Changes in v7:
- remove unnecassary checks
Changes in v6:
- use dev_fwnode()
- remove useless else
- replace of_device_is_available() to fwnode_device_is_available()
Changes in v5:
- replace fwnode_get_id() with OF and ACPI function calls
Changes in v4: None
Changes in v3: None
Changes in v2:
- Refactor OF functions to use fwnode functions
.../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 88 +++++++++++--------
.../net/ethernet/freescale/dpaa2/dpaa2-mac.h | 2 +-
2 files changed, 53 insertions(+), 37 deletions(-)
@@ -34,39 +37,51 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)return0;}-/* Caller must call of_node_put on the returned value */-staticstructdevice_node*dpaa2_mac_get_node(u16dpmac_id)+staticstructfwnode_handle*dpaa2_mac_get_node(structdevice*dev,+u16dpmac_id){-structdevice_node*dpmacs,*dpmac=NULL;-u32id;+structfwnode_handle*fwnode,*parent,*child=NULL;+structdevice_node*dpmacs=NULL;interr;+u32id;-dpmacs=of_find_node_by_name(NULL,"dpmacs");-if(!dpmacs)-returnNULL;+fwnode=dev_fwnode(dev->parent);+if(is_of_node(fwnode)){+dpmacs=of_find_node_by_name(NULL,"dpmacs");+if(!dpmacs)+returnNULL;+parent=of_fwnode_handle(dpmacs);+}elseif(is_acpi_node(fwnode)){+parent=fwnode;+}-while((dpmac=of_get_next_child(dpmacs,dpmac))!=NULL){-err=of_property_read_u32(dpmac,"reg",&id);+fwnode_for_each_child_node(parent,child){+err=-EINVAL;+if(is_acpi_device_node(child))+err=acpi_get_local_address(ACPI_HANDLE_FWNODE(child),&id);+elseif(is_of_node(child))+err=of_property_read_u32(to_of_node(child),"reg",&id);if(err)continue;-if(id==dpmac_id)-break;-}+if(id==dpmac_id){+of_node_put(dpmacs);+returnchild;+}+}of_node_put(dpmacs);--returndpmac;+returnNULL;}-staticintdpaa2_mac_get_if_mode(structdevice_node*node,+staticintdpaa2_mac_get_if_mode(structfwnode_handle*dpmac_node,structdpmac_attrattr){phy_interface_tif_mode;interr;-err=of_get_phy_mode(node,&if_mode);-if(!err)-returnif_mode;+err=fwnode_get_phy_mode(dpmac_node);+if(err>0)+returnerr;err=phy_mode(attr.eth_if,&if_mode);if(!err)
@@ -235,26 +250,27 @@ static const struct phylink_mac_ops dpaa2_mac_phylink_ops = {};staticintdpaa2_pcs_create(structdpaa2_mac*mac,-structdevice_node*dpmac_node,intid)+structfwnode_handle*dpmac_node,+intid){structmdio_device*mdiodev;-structdevice_node*node;+structfwnode_handle*node;-node=of_parse_phandle(dpmac_node,"pcs-handle",0);-if(!node){+node=fwnode_find_reference(dpmac_node,"pcs-handle",0);+if(IS_ERR(node)){/* do not error out on old DTS files */netdev_warn(mac->net_dev,"pcs-handle node not found\n");return0;}-if(!of_device_is_available(node)){+if(!fwnode_device_is_available(node)){netdev_err(mac->net_dev,"pcs-handle node not available\n");-of_node_put(node);+fwnode_handle_put(node);return-ENODEV;}-mdiodev=of_mdio_find_device(node);-of_node_put(node);+mdiodev=fwnode_mdio_find_device(node);+fwnode_handle_put(node);if(!mdiodev)return-EPROBE_DEFER;
@@ -384,8 +400,8 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)/* Find the device node representing the MAC device and link the device*behindtheassociatednetdevtoit.*/-mac->of_node=dpaa2_mac_get_node(mac->attr.id);-net_dev->dev.of_node=mac->of_node;+mac->fw_node=dpaa2_mac_get_node(&mac->mc_dev->dev,mac->attr.id);+net_dev->dev.of_node=to_of_node(mac->fw_node);return0;
From: Calvin Johnson <redacted>
Depending on the device node type, call the specific OF or ACPI
mdiobus_register function.
Note: For both ACPI and DT cases, endianness of MDIO controller
need to be specified using "little-endian" property.
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8:
- Directly call the OF or ACPI variants of registering the MDIO bus.
This is needed because the fwnode_mdio.c module should only implement
features which can be achieved without going back to the OF/ACPI
variants. Without this restrictions we directly end up in a dependency
cycle: of_mdio -> fwnode_mdio -> of_mdio.
- Changed the commit title since the fwnode_mdiobus_register() is no
longer available
Changes in v7:
- Include fwnode_mdio.h
- Alphabetically sort header inclusions
Changes in v6: None
Changes in v5: None
Changes in v4:
- Cleanup xgmac_mdio_probe()
Changes in v3:
- Avoid unnecessary line removal
- Remove unused inclusion of acpi.h
Changes in v2: None
drivers/net/ethernet/freescale/xgmac_mdio.c | 30 ++++++++++++++-------
1 file changed, 21 insertions(+), 9 deletions(-)
@@ -11,15 +12,17 @@*kind,whetherexpressorimplied.*/-#include<linux/kernel.h>-#include<linux/slab.h>+#include<linux/acpi.h>+#include<linux/acpi_mdio.h>#include<linux/interrupt.h>-#include<linux/module.h>-#include<linux/phy.h>+#include<linux/kernel.h>#include<linux/mdio.h>+#include<linux/module.h>#include<linux/of_address.h>-#include<linux/of_platform.h>#include<linux/of_mdio.h>+#include<linux/of_platform.h>+#include<linux/phy.h>+#include<linux/slab.h>/* Number of microseconds to wait for a register to respond */#define TIMEOUT 1000
@@ -243,10 +246,10 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum)staticintxgmac_mdio_probe(structplatform_device*pdev){-structdevice_node*np=pdev->dev.of_node;-structmii_bus*bus;-structresource*res;+structfwnode_handle*fwnode;structmdio_fsl_priv*priv;+structresource*res;+structmii_bus*bus;intret;/* In DPAA-1, MDIO is one of the many FMan sub-devices. The FMan
@@ -279,13 +282,22 @@ static int xgmac_mdio_probe(struct platform_device *pdev)gotoerr_ioremap;}+/* For both ACPI and DT cases, endianness of MDIO controller+*needstobespecifiedusing"little-endian"property.+*/priv->is_little_endian=device_property_read_bool(&pdev->dev,"little-endian");priv->has_a011043=device_property_read_bool(&pdev->dev,"fsl,erratum-a011043");-ret=of_mdiobus_register(bus,np);+fwnode=pdev->dev.fwnode;+if(is_of_node(fwnode))+ret=of_mdiobus_register(bus,to_of_node(fwnode));+elseif(is_acpi_node(fwnode))+ret=acpi_mdiobus_register(bus,fwnode);+else+ret=-EINVAL;if(ret){dev_err(&pdev->dev,"cannot register MDIO bus\n");gotoerr_registration;
From: Calvin Johnson <redacted>
Introduce a wrapper around the _ADR evaluation.
Signed-off-by: Calvin Johnson <redacted>
Reviewed-by: Andy Shevchenko <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
- Replace fwnode_get_id() with acpi_get_local_address()
Changes in v4:
- Improve code structure to handle all cases
Changes in v3:
- Modified to retrieve reg property value for ACPI as well
- Resolved compilation issue with CONFIG_ACPI = n
- Added more info into documentation
drivers/acpi/utils.c | 14 ++++++++++++++
include/linux/acpi.h | 7 +++++++
2 files changed, 21 insertions(+)
@@ -1,6 +1,7 @@# SPDX-License-Identifier: GPL-2.0# Makefile for Linux MDIO bus drivers+obj-$(CONFIG_ACPI_MDIO)+=acpi_mdio.oobj-$(CONFIG_FWNODE_MDIO)+=fwnode_mdio.oobj-$(CONFIG_OF_MDIO)+=of_mdio.o
@@ -0,0 +1,56 @@+// SPDX-License-Identifier: GPL-2.0-only+/*+*ACPIhelpersfortheMDIO(EthernetPHY)API+*+*ThisfileprovideshelperfunctionsforextractingPHYdeviceinformation+*outoftheACPIASLandusingittopopulateanmii_bus.+*/++#include<linux/acpi.h>+#include<linux/acpi_mdio.h>+#include<linux/bits.h>+#include<linux/dev_printk.h>+#include<linux/fwnode_mdio.h>+#include<linux/module.h>+#include<linux/types.h>++MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");+MODULE_LICENSE("GPL");++/**+*acpi_mdiobus_register-Registermii_busandcreatePHYsfromtheACPIASL.+*@mdio:pointertomii_busstructure+*@fwnode:pointertofwnodeofMDIObus.+*+*Thisfunctionregistersthemii_busstructureandregistersaphy_device+*foreachchildnodeof@fwnode.+*/+intacpi_mdiobus_register(structmii_bus*mdio,structfwnode_handle*fwnode)+{+structfwnode_handle*child;+u32addr;+intret;++/* Mask out all PHYs from auto probing. */+mdio->phy_mask=GENMASK(31,0);+ret=mdiobus_register(mdio);+if(ret)+returnret;++ACPI_COMPANION_SET(&mdio->dev,to_acpi_device_node(fwnode));++/* Loop over the child nodes and register a phy_device for each PHY */+fwnode_for_each_child_node(fwnode,child){+ret=acpi_get_local_address(ACPI_HANDLE_FWNODE(child),&addr);+if(ret||addr>=PHY_MAX_ADDR)+continue;++ret=fwnode_mdiobus_register_phy(mdio,child,addr);+if(ret==-ENODEV)+dev_err(&mdio->dev,+"MDIO device at address %d is missing.\n",+addr);+}+return0;+}+EXPORT_SYMBOL(acpi_mdiobus_register);
@@ -1085,44 +1085,7 @@ EXPORT_SYMBOL_GPL(phylink_connect_phy);intphylink_of_phy_connect(structphylink*pl,structdevice_node*dn,u32flags){-structdevice_node*phy_node;-structphy_device*phy_dev;-intret;--/* Fixed links and 802.3z are handled without needing a PHY */-if(pl->cfg_link_an_mode==MLO_AN_FIXED||-(pl->cfg_link_an_mode==MLO_AN_INBAND&&-phy_interface_mode_is_8023z(pl->link_interface)))-return0;--phy_node=of_parse_phandle(dn,"phy-handle",0);-if(!phy_node)-phy_node=of_parse_phandle(dn,"phy",0);-if(!phy_node)-phy_node=of_parse_phandle(dn,"phy-device",0);--if(!phy_node){-if(pl->cfg_link_an_mode==MLO_AN_PHY)-return-ENODEV;-return0;-}--phy_dev=of_phy_find_device(phy_node);-/* We're done with the phy_node handle */-of_node_put(phy_node);-if(!phy_dev)-return-ENODEV;--ret=phy_attach_direct(pl->netdev,phy_dev,flags,-pl->link_interface);-if(ret)-returnret;--ret=phylink_bringup_phy(pl,phy_dev,pl->link_config.interface);-if(ret)-phy_detach(phy_dev);--returnret;+returnphylink_fwnode_phy_connect(pl,of_fwnode_handle(dn),flags);}EXPORT_SYMBOL_GPL(phylink_of_phy_connect);
Andrew,
The ACPI maintainers did bless the use of the ACPI standards followed
in this patchset, and their only abstinence from ACK'ing the patchset
was whether the code was used in production systems. Well currently,
not only have we, SolidRun, been using this patchset and the associated
ACPI tables in our SystemsReady certified firmware for the HoneyComb,
but we also have customers using this same patchset and firmware on
their systems rolled out to customers.
Additionally we have an entire new product line based on Marvell's
Armada CN913x series, which also needs this patchset to be fully
functional.
I am quite certain this is more than enough production systems using
this ACPI description method for networking to progress this patchset
forward.
-Jon
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2021-06-10 18:05:56
On Thu, Jun 10, 2021 at 6:40 PM Ioana Ciornei [off-list ref] wrote:
From: Calvin Johnson <redacted>
Introduce ACPI mechanism to get PHYs registered on a MDIO bus and
provide them to be connected to MAC.
This is not an "ACPI mechanism", because it is not part of the ACPI
specification or support documentation thereof.
I would call it "a mechanism based on generic ACPI _DSD device
properties definition []1]". And provide a reference to the _DSD
properties definition document.
With that changed, you can add
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
to this patch.
Note, however, that within the traditional ACPI framework, the _DSD
properties are consumed by the driver that binds to the device
represented by the ACPI device object containing the _DSD in question
in its scope, while in this case IIUC the properties are expected to
be consumed by the general networking code in the kernel. That is not
wrong in principle, but it means that operating systems other than
Linux are not likely to be using them.
quoted hunk
Describe properties "phy-handle" and "phy-mode".
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7: None
Changes in v6:
- Minor cleanup
Changes in v5:
- More cleanup
Changes in v4:
- More cleanup
Changes in v3: None
Changes in v2:
- Updated with more description in document
Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++
1 file changed, 133 insertions(+)
create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
@@ -0,0 +1,133 @@+.. SPDX-License-Identifier: GPL-2.0++=========================+MDIO bus and PHYs in ACPI+=========================++The PHYs on an MDIO bus [1] are probed and registered using+fwnode_mdiobus_register_phy().++Later, for connecting these PHYs to their respective MACs, the PHYs registered+on the MDIO bus have to be referenced.++This document introduces two _DSD properties that are to be used+for connecting PHYs on the MDIO bus [3] to the MAC layer.++These properties are defined in accordance with the "Device+Properties UUID For _DSD" [2] document and the+daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID must be used in the Device+Data Descriptors containing them.++phy-handle+----------+For each MAC node, a device property "phy-handle" is used to reference+the PHY that is registered on an MDIO bus. This is mandatory for+network interfaces that have PHYs connected to MAC via MDIO bus.++During the MDIO bus driver initialization, PHYs on this bus are probed+using the _ADR object as shown below and are registered on the MDIO bus.++::+ Scope(\_SB.MDI0)+ {+ Device(PHY1) {+ Name (_ADR, 0x1)+ } // end of PHY1++ Device(PHY2) {+ Name (_ADR, 0x2)+ } // end of PHY2+ }++Later, during the MAC driver initialization, the registered PHY devices+have to be retrieved from the MDIO bus. For this, the MAC driver needs+references to the previously registered PHYs which are provided+as device object references (e.g. \_SB.MDI0.PHY1).++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].++The following ASL example illustrates the usage of these properties.++DSDT entry for MDIO node+------------------------++The MDIO bus has an SoC component (MDIO controller) and a platform+component (PHYs on the MDIO bus).++a) Silicon Component+This node describes the MDIO controller, MDI0+---------------------------------------------+::+ Scope(_SB)+ {+ Device(MDI0) {+ Name(_HID, "NXP0006")+ Name(_CCA, 1)+ Name(_UID, 0)+ Name(_CRS, ResourceTemplate() {+ Memory32Fixed(ReadWrite, MDI0_BASE, MDI_LEN)+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared)+ {+ MDI0_IT+ }+ }) // end of _CRS for MDI0+ } // end of MDI0+ }++b) Platform Component+The PHY1 and PHY2 nodes represent the PHYs connected to MDIO bus MDI0+---------------------------------------------------------------------+::+ Scope(\_SB.MDI0)+ {+ Device(PHY1) {+ Name (_ADR, 0x1)+ } // end of PHY1++ Device(PHY2) {+ Name (_ADR, 0x2)+ } // end of PHY2+ }++DSDT entries representing MAC nodes+-----------------------------------++Below are the MAC nodes where PHY nodes are referenced.+phy-mode and phy-handle are used as explained earlier.+------------------------------------------------------+::+ Scope(\_SB.MCE0.PR17)+ {+ Name (_DSD, Package () {+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),+ Package () {+ Package (2) {"phy-mode", "rgmii-id"},+ Package (2) {"phy-handle", \_SB.MDI0.PHY1}+ }+ })+ }++ Scope(\_SB.MCE0.PR18)+ {+ Name (_DSD, Package () {+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),+ Package () {+ Package (2) {"phy-mode", "rgmii-id"},+ Package (2) {"phy-handle", \_SB.MDI0.PHY2}}+ }+ })+ }++References+==========++[1] Documentation/networking/phy.rst++[2] https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf++[3] Documentation/firmware-guide/acpi/DSD-properties-rules.rst++[4] Documentation/devicetree/bindings/net/ethernet-controller.yaml--
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2021-06-10 18:09:43
On Thu, Jun 10, 2021 at 6:40 PM Ioana Ciornei [off-list ref] wrote:
From: Calvin Johnson <redacted>
Introduce a wrapper around the _ADR evaluation.
Signed-off-by: Calvin Johnson <redacted>
Reviewed-by: Andy Shevchenko <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
quoted hunk
---
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
- Replace fwnode_get_id() with acpi_get_local_address()
Changes in v4:
- Improve code structure to handle all cases
Changes in v3:
- Modified to retrieve reg property value for ACPI as well
- Resolved compilation issue with CONFIG_ACPI = n
- Added more info into documentation
drivers/acpi/utils.c | 14 ++++++++++++++
include/linux/acpi.h | 7 +++++++
2 files changed, 21 insertions(+)
From: Grant Likely <hidden> Date: 2021-06-10 18:12:01
On 10/06/2021 17:39, Ioana Ciornei wrote:
From: Calvin Johnson <redacted>
Introduce ACPI mechanism to get PHYs registered on a MDIO bus and
provide them to be connected to MAC.
Describe properties "phy-handle" and "phy-mode".
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Looks reasonable to me. I'm not a kernel maintainer any more, so my
Acked-by: may not be very valuable, but here it is anyway:
Acked-by: Grant Likely <redacted>
quoted hunk
--- >
Changes in v8: None
Changes in v7: None
Changes in v6:
- Minor cleanup
Changes in v5:
- More cleanup
Changes in v4:
- More cleanup
Changes in v3: None
Changes in v2:
- Updated with more description in document
Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++
1 file changed, 133 insertions(+)
create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
@@ -0,0 +1,133 @@+.. SPDX-License-Identifier: GPL-2.0++=========================+MDIO bus and PHYs in ACPI+=========================++The PHYs on an MDIO bus [1] are probed and registered using+fwnode_mdiobus_register_phy().++Later, for connecting these PHYs to their respective MACs, the PHYs registered+on the MDIO bus have to be referenced.++This document introduces two _DSD properties that are to be used+for connecting PHYs on the MDIO bus [3] to the MAC layer.++These properties are defined in accordance with the "Device+Properties UUID For _DSD" [2] document and the+daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID must be used in the Device+Data Descriptors containing them.++phy-handle+----------+For each MAC node, a device property "phy-handle" is used to reference+the PHY that is registered on an MDIO bus. This is mandatory for+network interfaces that have PHYs connected to MAC via MDIO bus.++During the MDIO bus driver initialization, PHYs on this bus are probed+using the _ADR object as shown below and are registered on the MDIO bus.++::+ Scope(\_SB.MDI0)+ {+ Device(PHY1) {+ Name (_ADR, 0x1)+ } // end of PHY1++ Device(PHY2) {+ Name (_ADR, 0x2)+ } // end of PHY2+ }++Later, during the MAC driver initialization, the registered PHY devices+have to be retrieved from the MDIO bus. For this, the MAC driver needs+references to the previously registered PHYs which are provided+as device object references (e.g. \_SB.MDI0.PHY1).++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].++The following ASL example illustrates the usage of these properties.++DSDT entry for MDIO node+------------------------++The MDIO bus has an SoC component (MDIO controller) and a platform+component (PHYs on the MDIO bus).++a) Silicon Component+This node describes the MDIO controller, MDI0+---------------------------------------------+::+ Scope(_SB)+ {+ Device(MDI0) {+ Name(_HID, "NXP0006")+ Name(_CCA, 1)+ Name(_UID, 0)+ Name(_CRS, ResourceTemplate() {+ Memory32Fixed(ReadWrite, MDI0_BASE, MDI_LEN)+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared)+ {+ MDI0_IT+ }+ }) // end of _CRS for MDI0+ } // end of MDI0+ }++b) Platform Component+The PHY1 and PHY2 nodes represent the PHYs connected to MDIO bus MDI0+---------------------------------------------------------------------+::+ Scope(\_SB.MDI0)+ {+ Device(PHY1) {+ Name (_ADR, 0x1)+ } // end of PHY1++ Device(PHY2) {+ Name (_ADR, 0x2)+ } // end of PHY2+ }++DSDT entries representing MAC nodes+-----------------------------------++Below are the MAC nodes where PHY nodes are referenced.+phy-mode and phy-handle are used as explained earlier.+------------------------------------------------------+::+ Scope(\_SB.MCE0.PR17)+ {+ Name (_DSD, Package () {+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),+ Package () {+ Package (2) {"phy-mode", "rgmii-id"},+ Package (2) {"phy-handle", \_SB.MDI0.PHY1}+ }+ })+ }++ Scope(\_SB.MCE0.PR18)+ {+ Name (_DSD, Package () {+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),+ Package () {+ Package (2) {"phy-mode", "rgmii-id"},+ Package (2) {"phy-handle", \_SB.MDI0.PHY2}}+ }+ })+ }++References+==========++[1] Documentation/networking/phy.rst++[2] https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf++[3] Documentation/firmware-guide/acpi/DSD-properties-rules.rst++[4] Documentation/devicetree/bindings/net/ethernet-controller.yaml
From: Grant Likely <hidden> Date: 2021-06-10 18:19:42
On 10/06/2021 17:39, Ioana Ciornei wrote:
From: Ioana Ciornei <ioana.ciornei@nxp.com>
This patch set provides ACPI support to DPAA2 network drivers.
It also introduces new fwnode based APIs to support phylink and phy
layers
Following functions are defined:
phylink_fwnode_phy_connect()
fwnode_mdiobus_register_phy()
fwnode_get_phy_id()
fwnode_phy_find_device()
device_phy_find_device()
fwnode_get_phy_node()
fwnode_mdio_find_device()
acpi_get_local_address()
First one helps in connecting phy to phylink instance.
Next three helps in getting phy_id and registering phy to mdiobus
Next two help in finding a phy on a mdiobus.
Next one helps in getting phy_node from a fwnode.
Last one is used to get local address from _ADR object.
Corresponding OF functions are refactored.
In terms of design, this whole series looks right to me. The way data is
encoded in ACPI is entirely appropriate. As long as Rob Herring is okay
with the DT code changes I support this series being merged.
For the whole series:
Acked-by: Grant Likely <redacted>
Tested-on: LX2160ARDB
Changes in v8:
- fixed some checkpatch warnings/checks
- included linux/fwnode_mdio.h in fwnode_mdio.c (fixed the build warnings)
- added fwnode_find_mii_timestamper() and
fwnode_mdiobus_phy_device_register() in order to get rid of the cycle
dependency.
- change to 'depends on (ACPI || OF) || COMPILE_TEST (for FWNODE_MDIO)
- remove the fwnode_mdiobus_register from fwnode_mdio.c since it
introduces a cycle of dependencies.
Changes in v7:
- correct fwnode_mdio_find_device() description
- check NULL in unregister_mii_timestamper()
- Call unregister_mii_timestamper() without NULL check
- Create fwnode_mdio.c and move fwnode_mdiobus_register_phy()
- include fwnode_mdio.h
- Include headers directly used in acpi_mdio.c
- Move fwnode_mdiobus_register() to fwnode_mdio.c
- Include fwnode_mdio.h
- Alphabetically sort header inclusions
- remove unnecassary checks
Changes in v6:
- Minor cleanup
- fix warning for function parameter of fwnode_mdio_find_device()
- Initialize mii_ts to NULL
- use GENMASK() and ACPI_COMPANION_SET()
- some cleanup
- remove unwanted header inclusion
- remove OF check for fixed-link
- use dev_fwnode()
- remove useless else
- replace of_device_is_available() to fwnode_device_is_available()
Changes in v5:
- More cleanup
- Replace fwnode_get_id() with acpi_get_local_address()
- add missing MODULE_LICENSE()
- replace fwnode_get_id() with OF and ACPI function calls
- replace fwnode_get_id() with OF and ACPI function calls
Changes in v4:
- More cleanup
- Improve code structure to handle all cases
- Remove redundant else from fwnode_mdiobus_register()
- Cleanup xgmac_mdio_probe()
- call phy_device_free() before returning
Changes in v3:
- Add more info on legacy DT properties "phy" and "phy-device"
- Redefine fwnode_phy_find_device() to follow of_phy_find_device()
- Use traditional comparison pattern
- Use GENMASK
- Modified to retrieve reg property value for ACPI as well
- Resolved compilation issue with CONFIG_ACPI = n
- Added more info into documentation
- Use acpi_mdiobus_register()
- Avoid unnecessary line removal
- Remove unused inclusion of acpi.h
Changes in v2:
- Updated with more description in document
- use reverse christmas tree ordering for local variables
- Refactor OF functions to use fwnode functions
Calvin Johnson (15):
Documentation: ACPI: DSD: Document MDIO PHY
net: phy: Introduce fwnode_mdio_find_device()
net: phy: Introduce phy related fwnode functions
of: mdio: Refactor of_phy_find_device()
net: phy: Introduce fwnode_get_phy_id()
of: mdio: Refactor of_get_phy_id()
net: mii_timestamper: check NULL in unregister_mii_timestamper()
net: mdiobus: Introduce fwnode_mdiobus_register_phy()
of: mdio: Refactor of_mdiobus_register_phy()
ACPI: utils: Introduce acpi_get_local_address()
net: mdio: Add ACPI support code for mdio
net/fsl: Use [acpi|of]_mdiobus_register
net: phylink: introduce phylink_fwnode_phy_connect()
net: phylink: Refactor phylink_of_phy_connect()
net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++
MAINTAINERS | 2 +
drivers/acpi/utils.c | 14 ++
.../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 88 ++++++-----
.../net/ethernet/freescale/dpaa2/dpaa2-mac.h | 2 +-
drivers/net/ethernet/freescale/xgmac_mdio.c | 30 ++--
drivers/net/mdio/Kconfig | 14 ++
drivers/net/mdio/Makefile | 4 +-
drivers/net/mdio/acpi_mdio.c | 56 +++++++
drivers/net/mdio/fwnode_mdio.c | 144 ++++++++++++++++++
drivers/net/mdio/of_mdio.c | 138 ++---------------
drivers/net/phy/mii_timestamper.c | 3 +
drivers/net/phy/phy_device.c | 109 ++++++++++++-
drivers/net/phy/phylink.c | 41 +++--
include/linux/acpi.h | 7 +
include/linux/acpi_mdio.h | 26 ++++
include/linux/fwnode_mdio.h | 35 +++++
include/linux/phy.h | 32 ++++
include/linux/phylink.h | 3 +
19 files changed, 691 insertions(+), 190 deletions(-)
create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
create mode 100644 drivers/net/mdio/acpi_mdio.c
create mode 100644 drivers/net/mdio/fwnode_mdio.c
create mode 100644 include/linux/acpi_mdio.h
create mode 100644 include/linux/fwnode_mdio.h
@@ -1,6 +1,7 @@# SPDX-License-Identifier: GPL-2.0# Makefile for Linux MDIO bus drivers+obj-$(CONFIG_ACPI_MDIO)+=acpi_mdio.oobj-$(CONFIG_FWNODE_MDIO)+=fwnode_mdio.oobj-$(CONFIG_OF_MDIO)+=of_mdio.o
@@ -0,0 +1,56 @@+// SPDX-License-Identifier: GPL-2.0-only+/*+*ACPIhelpersfortheMDIO(EthernetPHY)API+*+*ThisfileprovideshelperfunctionsforextractingPHYdeviceinformation+*outoftheACPIASLandusingittopopulateanmii_bus.+*/++#include<linux/acpi.h>+#include<linux/acpi_mdio.h>+#include<linux/bits.h>+#include<linux/dev_printk.h>+#include<linux/fwnode_mdio.h>+#include<linux/module.h>+#include<linux/types.h>++MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");+MODULE_LICENSE("GPL");++/**+*acpi_mdiobus_register-Registermii_busandcreatePHYsfromtheACPIASL.+*@mdio:pointertomii_busstructure+*@fwnode:pointertofwnodeofMDIObus.+*+*Thisfunctionregistersthemii_busstructureandregistersaphy_device+*foreachchildnodeof@fwnode.
It would be good to mention that @fwnode is expected to represent an
ACPI device object corresponding to mdiio and its children are
expected to correspond to the PHY devices on that bus (if my
understanding of this is correct, that is).
With that addressed, please feel free to add
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
to this patch.
quoted hunk
+ */
+int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
+{
+ struct fwnode_handle *child;
+ u32 addr;
+ int ret;
+
+ /* Mask out all PHYs from auto probing. */
+ mdio->phy_mask = GENMASK(31, 0);
+ ret = mdiobus_register(mdio);
+ if (ret)
+ return ret;
+
+ ACPI_COMPANION_SET(&mdio->dev, to_acpi_device_node(fwnode));
+
+ /* Loop over the child nodes and register a phy_device for each PHY */
+ fwnode_for_each_child_node(fwnode, child) {
+ ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
+ if (ret || addr >= PHY_MAX_ADDR)
+ continue;
+
+ ret = fwnode_mdiobus_register_phy(mdio, child, addr);
+ if (ret == -ENODEV)
+ dev_err(&mdio->dev,
+ "MDIO device at address %d is missing.\n",
+ addr);
+ }
+ return 0;
+}
+EXPORT_SYMBOL(acpi_mdiobus_register);
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2021-06-10 18:23:43
On Thu, Jun 10, 2021 at 6:40 PM Ioana Ciornei [off-list ref] wrote:
From: Calvin Johnson <redacted>
Modify dpaa2_mac_get_node() to get the dpmac fwnode from either
DT or ACPI.
Modify dpaa2_mac_get_if_mode() to get interface mode from dpmac_node
which is a fwnode.
Modify dpaa2_pcs_create() to create pcs from dpmac_node fwnode.
Modify dpaa2_mac_connect() to support ACPI along with DT.
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
From the ACPI side
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
quoted hunk
---
Changes in v8:
- adjust code over latest changes applied on the driver
Changes in v7:
- remove unnecassary checks
Changes in v6:
- use dev_fwnode()
- remove useless else
- replace of_device_is_available() to fwnode_device_is_available()
Changes in v5:
- replace fwnode_get_id() with OF and ACPI function calls
Changes in v4: None
Changes in v3: None
Changes in v2:
- Refactor OF functions to use fwnode functions
.../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 88 +++++++++++--------
.../net/ethernet/freescale/dpaa2/dpaa2-mac.h | 2 +-
2 files changed, 53 insertions(+), 37 deletions(-)
@@ -34,39 +37,51 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)return0;}-/* Caller must call of_node_put on the returned value */-staticstructdevice_node*dpaa2_mac_get_node(u16dpmac_id)+staticstructfwnode_handle*dpaa2_mac_get_node(structdevice*dev,+u16dpmac_id){-structdevice_node*dpmacs,*dpmac=NULL;-u32id;+structfwnode_handle*fwnode,*parent,*child=NULL;+structdevice_node*dpmacs=NULL;interr;+u32id;-dpmacs=of_find_node_by_name(NULL,"dpmacs");-if(!dpmacs)-returnNULL;+fwnode=dev_fwnode(dev->parent);+if(is_of_node(fwnode)){+dpmacs=of_find_node_by_name(NULL,"dpmacs");+if(!dpmacs)+returnNULL;+parent=of_fwnode_handle(dpmacs);+}elseif(is_acpi_node(fwnode)){+parent=fwnode;+}-while((dpmac=of_get_next_child(dpmacs,dpmac))!=NULL){-err=of_property_read_u32(dpmac,"reg",&id);+fwnode_for_each_child_node(parent,child){+err=-EINVAL;+if(is_acpi_device_node(child))+err=acpi_get_local_address(ACPI_HANDLE_FWNODE(child),&id);+elseif(is_of_node(child))+err=of_property_read_u32(to_of_node(child),"reg",&id);if(err)continue;-if(id==dpmac_id)-break;-}+if(id==dpmac_id){+of_node_put(dpmacs);+returnchild;+}+}of_node_put(dpmacs);--returndpmac;+returnNULL;}-staticintdpaa2_mac_get_if_mode(structdevice_node*node,+staticintdpaa2_mac_get_if_mode(structfwnode_handle*dpmac_node,structdpmac_attrattr){phy_interface_tif_mode;interr;-err=of_get_phy_mode(node,&if_mode);-if(!err)-returnif_mode;+err=fwnode_get_phy_mode(dpmac_node);+if(err>0)+returnerr;err=phy_mode(attr.eth_if,&if_mode);if(!err)
@@ -235,26 +250,27 @@ static const struct phylink_mac_ops dpaa2_mac_phylink_ops = {};staticintdpaa2_pcs_create(structdpaa2_mac*mac,-structdevice_node*dpmac_node,intid)+structfwnode_handle*dpmac_node,+intid){structmdio_device*mdiodev;-structdevice_node*node;+structfwnode_handle*node;-node=of_parse_phandle(dpmac_node,"pcs-handle",0);-if(!node){+node=fwnode_find_reference(dpmac_node,"pcs-handle",0);+if(IS_ERR(node)){/* do not error out on old DTS files */netdev_warn(mac->net_dev,"pcs-handle node not found\n");return0;}-if(!of_device_is_available(node)){+if(!fwnode_device_is_available(node)){netdev_err(mac->net_dev,"pcs-handle node not available\n");-of_node_put(node);+fwnode_handle_put(node);return-ENODEV;}-mdiodev=of_mdio_find_device(node);-of_node_put(node);+mdiodev=fwnode_mdio_find_device(node);+fwnode_handle_put(node);if(!mdiodev)return-EPROBE_DEFER;
@@ -384,8 +400,8 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)/* Find the device node representing the MAC device and link the device*behindtheassociatednetdevtoit.*/-mac->of_node=dpaa2_mac_get_node(mac->attr.id);-net_dev->dev.of_node=mac->of_node;+mac->fw_node=dpaa2_mac_get_node(&mac->mc_dev->dev,mac->attr.id);+net_dev->dev.of_node=to_of_node(mac->fw_node);return0;
From: Grant Likely <hidden> Date: 2021-06-10 18:23:53
On 10/06/2021 19:05, Rafael J. Wysocki wrote:
On Thu, Jun 10, 2021 at 6:40 PM Ioana Ciornei [off-list ref] wrote:
quoted
From: Calvin Johnson <redacted>
Introduce ACPI mechanism to get PHYs registered on a MDIO bus and
provide them to be connected to MAC.
This is not an "ACPI mechanism", because it is not part of the ACPI
specification or support documentation thereof.
I would call it "a mechanism based on generic ACPI _DSD device
properties definition []1]". And provide a reference to the _DSD
properties definition document.
With that changed, you can add
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
to this patch.
Note, however, that within the traditional ACPI framework, the _DSD
properties are consumed by the driver that binds to the device
represented by the ACPI device object containing the _DSD in question
in its scope, while in this case IIUC the properties are expected to
be consumed by the general networking code in the kernel. That is not
wrong in principle, but it means that operating systems other than
Linux are not likely to be using them.
Doesn't this land at the level of device drivers though? None of this
data needs to be consumed by the OS generic ACPI parsing code, but the
network device driver can use it to parse the MDIO and MAC configuraiton
and set itself up appropriately.
The only difference in the Linux case is that the code is implemented in
a way that can be leveraged by other network drivers instead of being
entirely contained within the dpaa driver.
g.
quoted
Describe properties "phy-handle" and "phy-mode".
Signed-off-by: Calvin Johnson <redacted>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v8: None
Changes in v7: None
Changes in v6:
- Minor cleanup
Changes in v5:
- More cleanup
Changes in v4:
- More cleanup
Changes in v3: None
Changes in v2:
- Updated with more description in document
Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++
1 file changed, 133 insertions(+)
create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
@@ -0,0 +1,133 @@+.. SPDX-License-Identifier: GPL-2.0++=========================+MDIO bus and PHYs in ACPI+=========================++The PHYs on an MDIO bus [1] are probed and registered using+fwnode_mdiobus_register_phy().++Later, for connecting these PHYs to their respective MACs, the PHYs registered+on the MDIO bus have to be referenced.++This document introduces two _DSD properties that are to be used+for connecting PHYs on the MDIO bus [3] to the MAC layer.++These properties are defined in accordance with the "Device+Properties UUID For _DSD" [2] document and the+daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID must be used in the Device+Data Descriptors containing them.++phy-handle+----------+For each MAC node, a device property "phy-handle" is used to reference+the PHY that is registered on an MDIO bus. This is mandatory for+network interfaces that have PHYs connected to MAC via MDIO bus.++During the MDIO bus driver initialization, PHYs on this bus are probed+using the _ADR object as shown below and are registered on the MDIO bus.++::+ Scope(\_SB.MDI0)+ {+ Device(PHY1) {+ Name (_ADR, 0x1)+ } // end of PHY1++ Device(PHY2) {+ Name (_ADR, 0x2)+ } // end of PHY2+ }++Later, during the MAC driver initialization, the registered PHY devices+have to be retrieved from the MDIO bus. For this, the MAC driver needs+references to the previously registered PHYs which are provided+as device object references (e.g. \_SB.MDI0.PHY1).++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].++The following ASL example illustrates the usage of these properties.++DSDT entry for MDIO node+------------------------++The MDIO bus has an SoC component (MDIO controller) and a platform+component (PHYs on the MDIO bus).++a) Silicon Component+This node describes the MDIO controller, MDI0+---------------------------------------------+::+ Scope(_SB)+ {+ Device(MDI0) {+ Name(_HID, "NXP0006")+ Name(_CCA, 1)+ Name(_UID, 0)+ Name(_CRS, ResourceTemplate() {+ Memory32Fixed(ReadWrite, MDI0_BASE, MDI_LEN)+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared)+ {+ MDI0_IT+ }+ }) // end of _CRS for MDI0+ } // end of MDI0+ }++b) Platform Component+The PHY1 and PHY2 nodes represent the PHYs connected to MDIO bus MDI0+---------------------------------------------------------------------+::+ Scope(\_SB.MDI0)+ {+ Device(PHY1) {+ Name (_ADR, 0x1)+ } // end of PHY1++ Device(PHY2) {+ Name (_ADR, 0x2)+ } // end of PHY2+ }++DSDT entries representing MAC nodes+-----------------------------------++Below are the MAC nodes where PHY nodes are referenced.+phy-mode and phy-handle are used as explained earlier.+------------------------------------------------------+::+ Scope(\_SB.MCE0.PR17)+ {+ Name (_DSD, Package () {+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),+ Package () {+ Package (2) {"phy-mode", "rgmii-id"},+ Package (2) {"phy-handle", \_SB.MDI0.PHY1}+ }+ })+ }++ Scope(\_SB.MCE0.PR18)+ {+ Name (_DSD, Package () {+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),+ Package () {+ Package (2) {"phy-mode", "rgmii-id"},+ Package (2) {"phy-handle", \_SB.MDI0.PHY2}}+ }+ })+ }++References+==========++[1] Documentation/networking/phy.rst++[2] https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf++[3] Documentation/firmware-guide/acpi/DSD-properties-rules.rst++[4] Documentation/devicetree/bindings/net/ethernet-controller.yaml--
Andrew,
The ACPI maintainers did bless the use of the ACPI standards followed
in this patchset, and their only abstinence from ACK'ing the patchset
was whether the code was used in production systems. Well currently,
not only have we, SolidRun, been using this patchset and the associated
ACPI tables in our SystemsReady certified firmware for the HoneyComb,
but we also have customers using this same patchset and firmware on
their systems rolled out to customers.
Additionally we have an entire new product line based on Marvell's
Armada CN913x series, which also needs this patchset to be fully
functional.
I am quite certain this is more than enough production systems using
this ACPI description method for networking to progress this patchset
forward.
And I believe that you have all of the requisite ACKs from the ACPI
side now, so it is up to the networking guys to decide what to do
next.
Thanks,
Rafael
Andrew,
The ACPI maintainers did bless the use of the ACPI standards followed
in this patchset, and their only abstinence from ACK'ing the patchset
was whether the code was used in production systems. Well currently,
not only have we, SolidRun, been using this patchset and the associated
ACPI tables in our SystemsReady certified firmware for the HoneyComb,
but we also have customers using this same patchset and firmware on
their systems rolled out to customers.
Additionally we have an entire new product line based on Marvell's
Armada CN913x series, which also needs this patchset to be fully
functional.
I am quite certain this is more than enough production systems using
this ACPI description method for networking to progress this patchset
forward.
And I believe that you have all of the requisite ACKs from the ACPI
side now, so it is up to the networking guys to decide what to do
next.
You've also my ACK as emeritus Devicetree maintainer. It is well past
time for this series to get merged.
g.
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2021-06-10 18:32:11
On Thu, Jun 10, 2021 at 8:23 PM Grant Likely [off-list ref] wrote:
On 10/06/2021 19:05, Rafael J. Wysocki wrote:
quoted
On Thu, Jun 10, 2021 at 6:40 PM Ioana Ciornei [off-list ref] wrote:
quoted
From: Calvin Johnson <redacted>
Introduce ACPI mechanism to get PHYs registered on a MDIO bus and
provide them to be connected to MAC.
This is not an "ACPI mechanism", because it is not part of the ACPI
specification or support documentation thereof.
I would call it "a mechanism based on generic ACPI _DSD device
properties definition []1]". And provide a reference to the _DSD
properties definition document.
With that changed, you can add
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
to this patch.
Note, however, that within the traditional ACPI framework, the _DSD
properties are consumed by the driver that binds to the device
represented by the ACPI device object containing the _DSD in question
in its scope, while in this case IIUC the properties are expected to
be consumed by the general networking code in the kernel. That is not
wrong in principle, but it means that operating systems other than
Linux are not likely to be using them.
Doesn't this land at the level of device drivers though? None of this
data needs to be consumed by the OS generic ACPI parsing code, but the
network device driver can use it to parse the MDIO and MAC configuraiton
and set itself up appropriately.
That's right in general, which is why I said that doing it this way
wasn't wrong.
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-06-10 18:41:15
And I believe that you have all of the requisite ACKs from the ACPI
side now, so it is up to the networking guys to decide what to do
next.
Thanks for the Acked-by's.
Since they were missing, the networking guys have deliberately been
ignoring this code. Now they have been given, we will start the review
work.
Thanks
Andrew
From: Andy Shevchenko <hidden> Date: 2021-06-11 08:57:55
On Thu, Jun 10, 2021 at 7:40 PM Ioana Ciornei [off-list ref] wrote:
From: Calvin Johnson <redacted>
Depending on the device node type, call the specific OF or ACPI
mdiobus_register function.
Note: For both ACPI and DT cases, endianness of MDIO controller
controllers
need to be specified using "little-endian" property.
using the
...
Changes in v8:
- Directly call the OF or ACPI variants of registering the MDIO bus.
This is needed because the fwnode_mdio.c module should only implement
features which can be achieved without going back to the OF/ACPI
variants. Without this restrictions we directly end up in a dependency
cycle: of_mdio -> fwnode_mdio -> of_mdio.
Shouldn't be simple fwnode_mdio.h.
The idea of fwnode APIs that they provide a common ground for all
resource providers.
- Changed the commit title since the fwnode_mdiobus_register() is no
longer available
Changes in v7:
- Include fwnode_mdio.h
- Alphabetically sort header inclusions
I suppose this should be a separate change.
--
With Best Regards,
Andy Shevchenko
From: Andy Shevchenko <hidden> Date: 2021-06-11 09:01:33
On Thu, Jun 10, 2021 at 7:40 PM Ioana Ciornei [off-list ref] wrote:
From: Ioana Ciornei <ioana.ciornei@nxp.com>
This patch set provides ACPI support to DPAA2 network drivers.
It also introduces new fwnode based APIs to support phylink and phy
layers
Following functions are defined:
phylink_fwnode_phy_connect()
fwnode_mdiobus_register_phy()
fwnode_get_phy_id()
fwnode_phy_find_device()
device_phy_find_device()
fwnode_get_phy_node()
fwnode_mdio_find_device()
acpi_get_local_address()
First one helps in connecting phy to phylink instance.
Next three helps in getting phy_id and registering phy to mdiobus
Next two help in finding a phy on a mdiobus.
Next one helps in getting phy_node from a fwnode.
Last one is used to get local address from _ADR object.
Corresponding OF functions are refactored.
In general it looks fine to me. What really worries me is the calls like
of_foo -> fwnode_bar -> of_baz.
As I have commented in one patch the idea of fwnode APIs is to have a
common ground for all resource providers. So, at the end it shouldn't
be a chain of calls like above mentioned. Either fix the name (so, the
first one will be in fwnode or device namespace) or fix the API that
it will be fwnode/device API.
--
With Best Regards,
Andy Shevchenko
On Fri, Jun 11, 2021 at 12:00:02PM +0300, Andy Shevchenko wrote:
On Thu, Jun 10, 2021 at 7:40 PM Ioana Ciornei [off-list ref] wrote:
quoted
From: Ioana Ciornei <ioana.ciornei@nxp.com>
This patch set provides ACPI support to DPAA2 network drivers.
It also introduces new fwnode based APIs to support phylink and phy
layers
Following functions are defined:
phylink_fwnode_phy_connect()
fwnode_mdiobus_register_phy()
fwnode_get_phy_id()
fwnode_phy_find_device()
device_phy_find_device()
fwnode_get_phy_node()
fwnode_mdio_find_device()
acpi_get_local_address()
First one helps in connecting phy to phylink instance.
Next three helps in getting phy_id and registering phy to mdiobus
Next two help in finding a phy on a mdiobus.
Next one helps in getting phy_node from a fwnode.
Last one is used to get local address from _ADR object.
Corresponding OF functions are refactored.
In general it looks fine to me. What really worries me is the calls like
of_foo -> fwnode_bar -> of_baz.
As I have commented in one patch the idea of fwnode APIs is to have a
common ground for all resource providers. So, at the end it shouldn't
be a chain of calls like above mentioned. Either fix the name (so, the
first one will be in fwnode or device namespace) or fix the API that
it will be fwnode/device API.
These types of cyclic calls do not exist anymore.
The fwnode_mdio does not call back into of_mdio but instead it directly
implements any necessary operations using the fwnode_handle.
The only calls happening are 'of_mdio -> fwnode_mdio' so that we
leverage the common fwnode handling and do not duplicate code.
Ioana