net: phy: Support DT PHY package
Subsystems (7)
cover net: phy: Support DT PHY package
Idea of this big series is to introduce the concept of PHY package in DT and generalize the support of it by PHY driver.
The concept of PHY package is nothing new and is already a thing in the kernel with the API phy_package_join/leave/read/write.
The main idea of those API is to permit the PHY to have a shared global data and to run probe/config only once for the PHY package. There are various example of this already in the kernel with the mscc, bcm54140 mediatek ge and micrle driver and they all follow the same pattern.
What is currently lacking is describing this in DT and better reference the PHY in charge of global configuration of the PHY package. For the already present PHY, the implementation is simple enough with only one PHY having the required regs to apply global configuration.
This can be ok for simple PHY package but some Qcom PHY package on ""modern"" SoC have more complex implementation. One example is the PHY for qca807x where some global regs are present in the so-called "combo" port and everything about psgmii calibration is placed in a 5th port in the PHY package.
Given these additional thing, the original phy_package API are extended with support for multiple global PHY for configuration. Each PHY driver will have an enum of the ID for the global PHY to reference and is required to pass to the read/write function.
On top of this, it's added correct DT support for describing PHY package.
One example is this:
ethernet-phy-package {
compatible = "ethernet-phy-package";
#address-cells = <1>;
#size-cells = <0>;
global-phys = <&phy4>;
global-phy-names = "base";
ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <1>;
};
phy4: ethernet-phy@4 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <4>;
};
};The mdio parse functions are changed to address for this additional special node, the function is changed to simply detect this node and search also in this.
If this is detected phy core will join each PHY present in the node and use (if defined) the additional info in the PHY driver to probe/config once the PHY package.
Some PHY package also supports a single phy-mode for every PHY in the PHY package. This is also supported and can be described in DT by defining the phy-mode in the PHY package node.
I hope this implementation is clean enough as I expect more and more of these configuration to appear in the future.
Christian Marangi (12):
net: phy: extend PHY package API to support multiple global address
dt-bindings: net: move PHY modes to common PHY mode types definition
dt-bindings: net: document ethernet PHY package nodes
net: phy: add initial support for PHY package in DT
net: phy: add support for named global PHY in DT PHY package
net: phy: add support for shared priv data size for PHY package in DT
net: phy: add support for driver specific PHY package probe/config
net: phy: add support for PHY package interface mode
net: phy: move mmd_phy_indirect to generic header
net: phy: add support for PHY package MMD read/write
dt-bindings: net: Document Qcom QCA807x PHY package
net: phy: qca807x: Add support for configurable LED
Robert Marko (2):
dt-bindings: net: add QCA807x PHY defines
net: phy: add Qualcom QCA807x driver
.../bindings/net/ethernet-controller.yaml | 47 +- .../bindings/net/ethernet-phy-mode-types.yaml | 132 ++ .../bindings/net/ethernet-phy-package.yaml | 86 ++ .../devicetree/bindings/net/qcom,qca807x.yaml | 143 ++ drivers/net/mdio/of_mdio.c | 60 +- drivers/net/phy/Kconfig | 7 + drivers/net/phy/Makefile | 1 + drivers/net/phy/bcm54140.c | 23 +- drivers/net/phy/mdio_bus.c | 33 +- drivers/net/phy/mediatek-ge-soc.c | 11 +- drivers/net/phy/micrel.c | 13 +- drivers/net/phy/mscc/mscc.h | 7 + drivers/net/phy/mscc/mscc_main.c | 16 +- drivers/net/phy/phy-core.c | 14 - drivers/net/phy/phy_device.c | 218 ++- drivers/net/phy/qca807x.c | 1232 +++++++++++++++++ include/dt-bindings/net/qcom-qca807x.h | 45 + include/linux/phy.h | 178 ++- 18 files changed, 2119 insertions(+), 147 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml create mode 100644 Documentation/devicetree/bindings/net/ethernet-phy-package.yaml create mode 100644 Documentation/devicetree/bindings/net/qcom,qca807x.yaml create mode 100644 drivers/net/phy/qca807x.c create mode 100644 include/dt-bindings/net/qcom-qca807x.h
Signature · 1 line
2.40.1
RFC PATCH 1/14 net: phy: extend PHY package API to support multiple global address
Current API for PHY package are limited to single address to configure global settings for the PHY package.
It was found that some PHY package (for example the qca807x, a PHY package that is shipped with a bundle of 5 PHY) require multiple PHY address to configure global settings. An example scenario is a PHY that have a dedicated PHY for PSGMII/serdes calibrarion and have a specific PHY in the package where the global PHY mode is set and affects every other PHY in the package.
Change the API in the following way:
- Make phy_package_join() require a list of address to be passed and the number of address in the list
- On shared data init, each address is the list is checked and added to the shared struct.
- Make __/phy_package_write/read() require an additional arg that select what global PHY address to use in the provided list.
Each user of this API is updated to follow this new implementation following a pattern where an enum is defined to declare the index of the addr and the addr list is passed.
--- drivers/net/phy/bcm54140.c | 23 +++++++-- drivers/net/phy/mediatek-ge-soc.c | 11 +++- drivers/net/phy/micrel.c | 13 +++-- drivers/net/phy/mscc/mscc.h | 7 +++ drivers/net/phy/mscc/mscc_main.c | 16 ++++-- drivers/net/phy/phy_device.c | 85 ++++++++++++++++++++----------- include/linux/phy.h | 51 +++++++++++++------ 7 files changed, 147 insertions(+), 59 deletions(-)
drivers/net/phy/bcm54140.c +18 -5
@@ -128,6 +128,12 @@#define BCM54140_DEFAULT_DOWNSHIFT 5#define BCM54140_MAX_DOWNSHIFT 9 +enum bcm54140_global_phy { +BCM54140_BASE_ADDR =0 , + + __BCM54140_GLOBAL_PHY_MAX, +}; +struct bcm54140_priv {int port;int base_addr;
@@ -429,11 +435,13 @@ static int bcm54140_base_read_rdb(struct phy_device *phydev, u16 rdb)int ret;phy_lock_mdio_bus (phydev); - ret =__phy_package_write (phydev,MII_BCM54XX_RDB_ADDR , rdb); + ret =__phy_package_write (phydev,BCM54140_BASE_ADDR , +MII_BCM54XX_RDB_ADDR , rdb);if (ret <0 ) goto out; - ret =__phy_package_read (phydev,MII_BCM54XX_RDB_DATA ); + ret =__phy_package_read (phydev,BCM54140_BASE_ADDR , +MII_BCM54XX_RDB_DATA ); out:phy_unlock_mdio_bus (phydev);
@@ -446,11 +454,13 @@ static int bcm54140_base_write_rdb(struct phy_device *phydev,int ret;phy_lock_mdio_bus (phydev); - ret =__phy_package_write (phydev,MII_BCM54XX_RDB_ADDR , rdb); + ret =__phy_package_write (phydev,BCM54140_BASE_ADDR , +MII_BCM54XX_RDB_ADDR , rdb);if (ret <0 ) goto out; - ret =__phy_package_write (phydev,MII_BCM54XX_RDB_DATA , val); + ret =__phy_package_write (phydev,BCM54140_BASE_ADDR , +MII_BCM54XX_RDB_DATA , val); out:phy_unlock_mdio_bus (phydev);
@@ -570,6 +580,7 @@ static int bcm54140_get_base_addr_and_port(struct phy_device *phydev)static int bcm54140_probe (struct phy_device *phydev) { +int addrs[__BCM54140_GLOBAL_PHY_MAX];struct bcm54140_priv *priv;int ret;
@@ -583,7 +594,9 @@ static int bcm54140_probe(struct phy_device *phydev)if (ret)return ret; -devm_phy_package_join (&phydev->mdio.dev, phydev, priv->base_addr,0 ); + addrs[BCM54140_BASE_ADDR ] = priv->base_addr; +devm_phy_package_join (&phydev->mdio.dev, phydev, addrs, +ARRAY_SIZE (addrs),0 );#if IS_ENABLED (CONFIG_HWMON )mutex_init (&priv->alarm_lock);
drivers/net/phy/mediatek-ge-soc.c +10 -1
@@ -298,6 +298,12 @@ struct mtk_socphy_priv {unsigned long led_state; }; +enum mtk_global_phy { +MTK_BASE_ADDR =0 , + + __MTK_GLOBAL_PHY_MAX +}; +struct mtk_socphy_shared {u32 boottrap;struct mtk_socphy_priv priv[4 ];
@@ -1431,13 +1437,16 @@ static void mt798x_phy_leds_state_init(struct phy_device *phydev)static int mt7988_phy_probe (struct phy_device *phydev) {struct mtk_socphy_shared *shared; +int addrs[__MTK_GLOBAL_PHY_MAX];struct mtk_socphy_priv *priv;int err;if (phydev->mdio.addr >3 )return -EINVAL ; - err =devm_phy_package_join (&phydev->mdio.dev, phydev,0 , + addrs[MTK_BASE_ADDR ] =0 ; + err =devm_phy_package_join (&phydev->mdio.dev, phydev, + addrs,ARRAY_SIZE (addrs),sizeof (struct mtk_socphy_shared ));if (err)return err;
drivers/net/phy/micrel.c +10 -3
@@ -328,6 +328,12 @@ struct kszphy_ptp_priv {spinlock_t seconds_lock; }; +enum ksz_global_phy { +KSZ_BASE_ADDR =0 , + + __KZS_GLOBAL_PHY_MAX, +}; +struct kszphy_priv {struct kszphy_ptp_priv ptp_priv;const struct kszphy_type *type;
@@ -3274,8 +3280,8 @@ static int lan8814_release_coma_mode(struct phy_device *phydev)static int lan8814_probe (struct phy_device *phydev) {const struct kszphy_type *type = phydev->drv->driver_data; +int addrs[__KZS_GLOBAL_PHY_MAX];struct kszphy_priv *priv; -u16 addr;int err; priv =devm_kzalloc (&phydev->mdio.dev,sizeof (*priv),GFP_KERNEL );
@@ -3291,9 +3297,10 @@ static int lan8814_probe(struct phy_device *phydev)/* Strap-in value for PHY address, below register read gives starting * phy address value */ - addr =lanphy_read_page_reg (phydev,4 ,0 ) &0x1F ; + addrs[KSZ_BASE_ADDR ] =lanphy_read_page_reg (phydev,4 ,0 ) &0x1F ;devm_phy_package_join (&phydev->mdio.dev, phydev, - addr,sizeof (struct lan8814_shared_priv )); + addrs,ARRAY_SIZE (addrs), +sizeof (struct lan8814_shared_priv ));if (phy_package_init_once (phydev)) { err =lan8814_release_coma_mode (phydev);
drivers/net/phy/mscc/mscc.h +7 -0
@@ -416,6 +416,13 @@ struct vsc8531_private {* gpio_lock: used for PHC operations. Common for all PHYs as the load/save GPIO * is shared. */ + +enum vsc85xx_global_phy { +VSC88XX_BASE_ADDR =0 , + + __VSC8XX_GLOBAL_PHY_MAX, +}; +struct vsc85xx_shared_private {struct mutex gpio_lock; };
drivers/net/phy/mscc/mscc_main.c +11 -5
@@ -711,7 +711,7 @@ int phy_base_write(struct phy_device *phydev, u32 regnum, u16 val)dump_stack (); } -return __phy_package_write (phydev, regnum, val); +return __phy_package_write (phydev,VSC88XX_BASE_ADDR , regnum, val); }/* phydev->bus->mdio_lock should be locked when using this function */
@@ -722,7 +722,7 @@ int phy_base_read(struct phy_device *phydev, u32 regnum)dump_stack (); } -return __phy_package_read (phydev, regnum); +return __phy_package_read (phydev,VSC88XX_BASE_ADDR , regnum); } u32 vsc85xx_csr_read(struct phy_device *phydev,
@@ -2204,6 +2204,7 @@ static int vsc85xx_read_status(struct phy_device *phydev)static int vsc8514_probe (struct phy_device *phydev) { +int addrs[__VSC8XX_GLOBAL_PHY_MAX];struct vsc8531_private *vsc8531;u32 default_mode[4 ] = {VSC8531_LINK_1000_ACTIVITY ,VSC8531_LINK_100_ACTIVITY ,VSC8531_LINK_ACTIVITY ,
@@ -2216,8 +2217,9 @@ static int vsc8514_probe(struct phy_device *phydev) phydev->priv = vsc8531;vsc8584_get_base_addr (phydev); + addrs[VSC88XX_BASE_ADDR ] = vsc8531->base_addr;devm_phy_package_join (&phydev->mdio.dev, phydev, - vsc8531->base_addr,0 ); + addrs,ARRAY_SIZE (addrs),0 ); vsc8531->nleds =4 ; vsc8531->supp_led_modes =VSC85XX_SUPP_LED_MODES ;
@@ -2233,6 +2235,7 @@ static int vsc8514_probe(struct phy_device *phydev)static int vsc8574_probe (struct phy_device *phydev) { +int addrs[__VSC8XX_GLOBAL_PHY_MAX];struct vsc8531_private *vsc8531;u32 default_mode[4 ] = {VSC8531_LINK_1000_ACTIVITY ,VSC8531_LINK_100_ACTIVITY ,VSC8531_LINK_ACTIVITY ,
@@ -2245,8 +2248,9 @@ static int vsc8574_probe(struct phy_device *phydev) phydev->priv = vsc8531;vsc8584_get_base_addr (phydev); + addrs[VSC88XX_BASE_ADDR ] = vsc8531->base_addr;devm_phy_package_join (&phydev->mdio.dev, phydev, - vsc8531->base_addr,0 ); + addrs,ARRAY_SIZE (addrs),0 ); vsc8531->nleds =4 ; vsc8531->supp_led_modes =VSC8584_SUPP_LED_MODES ;
@@ -2262,6 +2266,7 @@ static int vsc8574_probe(struct phy_device *phydev)static int vsc8584_probe (struct phy_device *phydev) { +int addrs[__VSC8XX_GLOBAL_PHY_MAX];struct vsc8531_private *vsc8531;u32 default_mode[4 ] = {VSC8531_LINK_1000_ACTIVITY ,VSC8531_LINK_100_ACTIVITY ,VSC8531_LINK_ACTIVITY ,
@@ -2280,7 +2285,8 @@ static int vsc8584_probe(struct phy_device *phydev) phydev->priv = vsc8531;vsc8584_get_base_addr (phydev); -devm_phy_package_join (&phydev->mdio.dev, phydev, vsc8531->base_addr, + addrs[VSC88XX_BASE_ADDR ] = vsc8531->base_addr; +devm_phy_package_join (&phydev->mdio.dev, phydev, addrs,ARRAY_SIZE (addrs),sizeof (struct vsc85xx_shared_private )); vsc8531->nleds =4 ;
drivers/net/phy/phy_device.c +56 -29
155 lines not on this page · raw message
include/linux/phy.h +35 -16
105 lines not on this page · raw message
Signature · 1 line
2.40.1
RFC PATCH 2/14 dt-bindings: net: move PHY modes to common PHY mode types definition
In reply to Christian MarangiMove PHY modes from ethernet-controller schema to dedicated common PHY mode types definition. This is needed to have a centralized place to define PHY interface mode and permit usage and reference of these modes in other schemas.
--- .../bindings/net/ethernet-controller.yaml | 47 +------ .../bindings/net/ethernet-phy-mode-types.yaml | 132 ++++++++++++++++++ 2 files changed, 133 insertions(+), 46 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml
Documentation/devicetree/bindings/net/ethernet-controller.yaml +1 -46
@@ -55,55 +55,10 @@ properties: const: mac-address phy-connection-type: + $ref: /schemas/net/ethernet-phy-mode-types.yaml#definitions/phy-connection-type description: Specifies interface type between the Ethernet device and a physical layer (PHY) device. - enum: - # There is not a standard bus between the MAC and the PHY, - # something proprietary is being used to embed the PHY in the - # MAC. - - internal - - mii - - gmii - - sgmii - - psgmii - - qsgmii - - qusgmii - - tbi - - rev-mii - - rmii - - rev-rmii - - moca - - # RX and TX delays are added by the MAC when required - - rgmii - - # RGMII with internal RX and TX delays provided by the PHY, - # the MAC should not add the RX or TX delays in this case - - rgmii-id - - # RGMII with internal RX delay provided by the PHY, the MAC - # should not add an RX delay in this case - - rgmii-rxid - - # RGMII with internal TX delay provided by the PHY, the MAC - # should not add an TX delay in this case - - rgmii-txid - - rtbi - - smii - - xgmii - - trgmii - - 1000base-x - - 2500base-x - - 5gbase-r - - rxaui - - xaui - - # 10GBASE-KR, XFI, SFI - - 10gbase-kr - - usxgmii - - 10gbase-r - - 25gbase-r phy-mode: $ref: "#/properties/phy-connection-type"
Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml new file +132 -0
132 lines not on this page · raw message
Signature · 1 line
2.40.1
Rob Herring
maintainerRe: [net-next RFC PATCH 02/14] dt-bindings: net: move PHY modes to common PHY mode types definition
Quoted 5 lines · Christian Marangi
Move PHY modes from ethernet-controller schema to dedicated common PHY mode types definition. This is needed to have a centralized place to define PHY interface mode and permit usage and reference of these modes in other schemas.
Quoted 7 lines
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/net/ethernet-controller.yaml | 47 +------ .../bindings/net/ethernet-phy-mode-types.yaml | 132 ++++++++++++++++++ 2 files changed, 133 insertions(+), 46 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:./Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml:21:9: [warning] wrong indentation: expected 10 but found 8 (indentation)
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml: 'oneOf' conditional failed, one must be fixed:
'unevaluatedProperties' is a required property
'additionalProperties' is a required property
hint: Either unevaluatedProperties or additionalProperties must be present
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml: 'anyOf' conditional failed, one must be fixed:
'properties' is a required property
'patternProperties' is a required property
hint: Metaschema for devicetree binding documentation
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Rob Herring
maintainerRe: [net-next RFC PATCH 02/14] dt-bindings: net: move PHY modes to common PHY mode types definition
In reply to Christian MarangiQuoted 17 lines · Christian Marangi
Move PHY modes from ethernet-controller schema to dedicated common PHY mode types definition. This is needed to have a centralized place to define PHY interface mode and permit usage and reference of these modes in other schemas.
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/net/ethernet-controller.yaml | 47 +------ .../bindings/net/ethernet-phy-mode-types.yaml | 132 ++++++++++++++++++ 2 files changed, 133 insertions(+), 46 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yamlDocumentation/devicetree/bindings/net/ethernet-controller.yaml +0
-0
Documentation/devicetree/bindings/net/ethernet-controller.yaml properties: · line 58
Quoted 4 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +1
-0@@ -55,55 +55,10 @@ properties: const: mac-address phy-connection-type: + $ref: /schemas/net/ethernet-phy-mode-types.yaml#definitions/phy-connection-type
You need a '/' after '#' or it is not a JSON pointer.
Quoted 60 lines
Documentation/devicetree/bindings/net/ethernet-controller.yaml +0
-46description: Specifies interface type between the Ethernet device and a physical layer (PHY) device. - enum: - # There is not a standard bus between the MAC and the PHY, - # something proprietary is being used to embed the PHY in the - # MAC. - - internal - - mii - - gmii - - sgmii - - psgmii - - qsgmii - - qusgmii - - tbi - - rev-mii - - rmii - - rev-rmii - - moca - - # RX and TX delays are added by the MAC when required - - rgmii - - # RGMII with internal RX and TX delays provided by the PHY, - # the MAC should not add the RX or TX delays in this case - - rgmii-id - - # RGMII with internal RX delay provided by the PHY, the MAC - # should not add an RX delay in this case - - rgmii-rxid - - # RGMII with internal TX delay provided by the PHY, the MAC - # should not add an TX delay in this case - - rgmii-txid - - rtbi - - smii - - xgmii - - trgmii - - 1000base-x - - 2500base-x - - 5gbase-r - - rxaui - - xaui - - # 10GBASE-KR, XFI, SFI - - 10gbase-kr - - usxgmii - - 10gbase-r - - 25gbase-r phy-mode: $ref: "#/properties/phy-connection-type"Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml new file +2
-0@@ -0,0 +1,132 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2
Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/net/ethernet-phy-mode-types.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ethernet PHY Common Mode Types + +maintainers: + - David S. Miller <[email protected]> + +definitions:
Use '$defs'
'definitions' is special in that we don't process it at all. That's probably why you ended up with this overly complicated schema below.
But really, there's no need to use $defs or definitions at all here. Just put it under 'properties' And move the references up a level (i.e. to the node, not a property).
Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml line 21
Quoted 9 lines
Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml new file +9
-0+ phy-connection-type: + # const: "internal" + allOf: + - $ref: /schemas/types.yaml#/definitions/string + - oneOf: + # There is not a standard bus between the MAC and the PHY, + # something proprietary is being used to embed the PHY in the + # MAC. + - items:
'items' is for arrays, but you just said this is a 'string', not 'string-array'.
Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml line 22
Quoted 1 line
Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml new file +1
-0+ - type: string
Already covered by the type $ref.
This can all be expressed with just 1 'enum' as it was before.
Quoted 113 lines
Documentation/devicetree/bindings/net/ethernet-phy-mode-types.yaml new file +110
-0+ const: internal + - items: + - type: string + const: mii + - items: + - type: string + const: gmii + - items: + - type: string + const: sgmii + - items: + - type: string + const: psgmii + - items: + - type: string + const: qsgmii + - items: + - type: string + const: qusgmii + - items: + - type: string + const: tbi + - items: + - type: string + const: rev-mii + - items: + - type: string + const: rmii + - items: + - type: string + const: rev-rmii + - items: + - type: string + const: moca + + # RX and TX delays are added by the MAC when required + - items: + - type: string + const: rgmii + + # RGMII with internal RX and TX delays provided by the PHY, + # the MAC should not add the RX or TX delays in this case + - items: + - type: string + const: rgmii-id + + # RGMII with internal RX delay provided by the PHY, the MAC + # should not add an RX delay in this case + - items: + - type: string + const: rgmii-rxid + + # RGMII with internal TX delay provided by the PHY, the MAC + # should not add an TX delay in this case + - items: + - type: string + const: rgmii-txid + + - items: + - type: string + const: rtbi + + - items: + - type: string + const: smii + + - items: + - type: string + const: xgmii + + - items: + - type: string + const: trgmii + + - items: + - type: string + const: 1000base-x + + - items: + - type: string + const: 2500base-x + + - items: + - type: string + const: 5gbase-r + + - items: + - type: string + const: rxaui + + - items: + - type: string + const: xaui + + # 10GBASE-KR, XFI, SFI + - items: + - type: string + const: 10gbase-kr + + - items: + - type: string + const: usxgmii + + - items: + - type: string + const: 10gbase-r + + - items: + - type: string + const: 25gbase-rSignature · 1 line
2.40.1
RFC PATCH 3/14 dt-bindings: net: document ethernet PHY package nodes
In reply to Christian MarangiDocument ethernet PHY package nodes used to describe PHY shipped in bundle of 4-5 PHY. These particular PHY require specific PHY in the package for global onfiguration of the PHY package.
Example are PHY package that have some regs only in one PHY of the package and will affect every other PHY in the package, for example related to PHY interface mode calibration or global PHY mode selection.
The PHY package node should use the global-phys property and the global-phy-names to define PHY in the package required by the PHY driver for global configuration.
It's also possible to specify the property phy-mode to specify that the PHY package sets a global PHY interface mode and every PHY of the package requires to have the same PHY interface mode.
--- .../bindings/net/ethernet-phy-package.yaml | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ethernet-phy-package.yaml
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +86 -0
@@ -0,0 +1,86 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/ethernet-phy-package.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ethernet PHY Package Common Properties + +maintainers: + - Christian Marangi <[email protected] + +properties: + $nodename: + pattern: "^ethernet-phy-package(-[0-9]+)?$" + + compatible: + const: ethernet-phy-package + + '#address-cells': + description: number of address cells for the MDIO bus + const: 1 + + '#size-cells': + description: number of size cells on the MDIO bus + const: 0 + + global-phys: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 1 + maxItems: 31 + description: + List of phandle to the PHY in the package required and + used to configure the PHY package. + + global-phy-names: + $ref: /schemas/types.yaml#/definitions/string-array + minItems: 1 + maxItems: 31 + description: + List of names of the PHY defined in global-phys. + + phy-connection-type: + $ref: /schemas/net/ethernet-phy-mode-types.yaml#definitions/phy-connection-type + description: + Specifies global interface type for the PHY package. + + phy-mode: + $ref: "#/properties/phy-connection-type" + +patternProperties: + ^ethernet-phy(@[a-f0-9]+)?$: + $ref: /schemas/net/ethernet-phy.yaml# + +required: + - compatible + +dependencies: + global-phy-names: [global-phys] + +unevaluatedProperties: false + +examples: + - | + ethernet { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy-package { + compatible = "ethernet-phy-package"; + #address-cells = <1>; + #size-cells = <0>; + + global-phys = <&phy4>; + global-phy-names = "base"; + + ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + phy4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; + };
Signature · 1 line
2.40.1
Rob Herring
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 28 lines · Christian Marangi
Document ethernet PHY package nodes used to describe PHY shipped in bundle of 4-5 PHY. These particular PHY require specific PHY in the package for global onfiguration of the PHY package.
Example are PHY package that have some regs only in one PHY of the package and will affect every other PHY in the package, for example related to PHY interface mode calibration or global PHY mode selection.
The PHY package node should use the global-phys property and the global-phy-names to define PHY in the package required by the PHY driver for global configuration.
It's also possible to specify the property phy-mode to specify that the PHY package sets a global PHY interface mode and every PHY of the package requires to have the same PHY interface mode.
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/net/ethernet-phy-package.yaml | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ethernet-phy-package.yamlDocumentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +0
-0
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml line 10
Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +10
-0@@ -0,0 +1,86 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/ethernet-phy-package.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ethernet PHY Package Common Properties + +maintainers: + - Christian Marangi <[email protected]
Missing a '>'
Quoted 44 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +44
-0+ +properties: + $nodename: + pattern: "^ethernet-phy-package(-[0-9]+)?$" + + compatible: + const: ethernet-phy-package + + '#address-cells': + description: number of address cells for the MDIO bus + const: 1 + + '#size-cells': + description: number of size cells on the MDIO bus + const: 0 + + global-phys: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 1 + maxItems: 31 + description: + List of phandle to the PHY in the package required and + used to configure the PHY package. + + global-phy-names: + $ref: /schemas/types.yaml#/definitions/string-array + minItems: 1 + maxItems: 31 + description: + List of names of the PHY defined in global-phys. + + phy-connection-type: + $ref: /schemas/net/ethernet-phy-mode-types.yaml#definitions/phy-connection-type + description: + Specifies global interface type for the PHY package. + + phy-mode: + $ref: "#/properties/phy-connection-type" + +patternProperties: + ^ethernet-phy(@[a-f0-9]+)?$: + $ref: /schemas/net/ethernet-phy.yaml# + +required:
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml line 64
Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +10
-0+ - compatible + +dependencies: + global-phy-names: [global-phys] + +unevaluatedProperties: false + +examples: + - | + ethernet {
You mean 'mdio' here, right?
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml line 68
Quoted 4 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +4
-0+ #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy-package {
This doesn't work. Child nodes of MDIO bus must be an MDIO device with an address. What you need is a node with all the addresses of the device:
mdio {
...
ethernet-phy@1 {
compatible = "vendor,specifc-compatible-for-device";
reg = <1>, <4>;
... };
};
There's also some MDIO devices which define a secondary address as a child device. Maybe those are similar to your situation. I don't recall which ones offhand.
Quoted 21 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +18
-0+ compatible = "ethernet-phy-package"; + #address-cells = <1>; + #size-cells = <0>; + + global-phys = <&phy4>; + global-phy-names = "base"; + + ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + phy4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; + };Signature · 1 line
2.40.1
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 115 lines · Rob Herring
Quoted 28 lines · Christian Marangi
Document ethernet PHY package nodes used to describe PHY shipped in bundle of 4-5 PHY. These particular PHY require specific PHY in the package for global onfiguration of the PHY package.
Example are PHY package that have some regs only in one PHY of the package and will affect every other PHY in the package, for example related to PHY interface mode calibration or global PHY mode selection.
The PHY package node should use the global-phys property and the global-phy-names to define PHY in the package required by the PHY driver for global configuration.
It's also possible to specify the property phy-mode to specify that the PHY package sets a global PHY interface mode and every PHY of the package requires to have the same PHY interface mode.
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/net/ethernet-phy-package.yaml | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ethernet-phy-package.yamlDocumentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +0
-0Documentation/devicetree/bindings/net/ethernet-phy-package.yaml line 10
Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +10
-0@@ -0,0 +1,86 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/ethernet-phy-package.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ethernet PHY Package Common Properties + +maintainers: + - Christian Marangi <[email protected]Missing a '>'
Quoted 44 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +44
-0+ +properties: + $nodename: + pattern: "^ethernet-phy-package(-[0-9]+)?$" + + compatible: + const: ethernet-phy-package + + '#address-cells': + description: number of address cells for the MDIO bus + const: 1 + + '#size-cells': + description: number of size cells on the MDIO bus + const: 0 + + global-phys: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 1 + maxItems: 31 + description: + List of phandle to the PHY in the package required and + used to configure the PHY package. + + global-phy-names: + $ref: /schemas/types.yaml#/definitions/string-array + minItems: 1 + maxItems: 31 + description: + List of names of the PHY defined in global-phys. + + phy-connection-type: + $ref: /schemas/net/ethernet-phy-mode-types.yaml#definitions/phy-connection-type + description: + Specifies global interface type for the PHY package. + + phy-mode: + $ref: "#/properties/phy-connection-type" + +patternProperties: + ^ethernet-phy(@[a-f0-9]+)?$: + $ref: /schemas/net/ethernet-phy.yaml# + +required:Documentation/devicetree/bindings/net/ethernet-phy-package.yaml line 64
Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +10
-0+ - compatible + +dependencies: + global-phy-names: [global-phys] + +unevaluatedProperties: false + +examples: + - | + ethernet {You mean 'mdio' here, right?
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml line 68
Quoted 4 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +4
-0+ #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy-package {This doesn't work. Child nodes of MDIO bus must be an MDIO device with an address. What you need is a node with all the addresses of the device:
mdio {
...ethernet-phy@1 { compatible = "vendor,specifc-compatible-for-device"; reg = <1>, <4>; ...
Quoted 7 lines
};
};There's also some MDIO devices which define a secondary address as a child device. Maybe those are similar to your situation. I don't recall which ones offhand.
Ehh this is not really a situation. We really need a way to describe PHY package. (In the sense of device that expose multiple PHY package, as they can be treated as single one but they are actually in bulk of 2-4-5 PHY)
qca807x is one example, quickinc is trying to push another PHY with just a similar implementation and Maxime Chevallier just pointed out that Marvell Alaska 88e1543 PHY also have this kind of configuration.
I feel defining PHY in subnode is a MUST and using ethernet-phy might be confusing to describe PHY package (so I think a brand new node name might be a better solution)
About the reg, I wonder if it would like it more if the PHY package node would include the reg as the first address of the package and the reg property as a list of all the reg the PHY package use.
Something like this?
ethernet-phy-package@1 {
compatible = "ethernet-phy-package";
#address-cells = <1>;
#size-cells = <0>;
reg = <1>, <2>, <3>, <4>;
global-phys = <&phy4>;
global-phy-names = "base";
ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <1>;
};
phy4: ethernet-phy@4 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <4>;
};
};Thanks a lot for the review and I hope we can find a good and correct way to model this. Just hope we don't have to add all kind of proprerty to describe the idea of PHY package. (I think the current example makes it very clear that the PHY under the node are all part of a single piece on the device)
Quoted 21 lines
Quoted 21 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +18
-0+ compatible = "ethernet-phy-package"; + #address-cells = <1>; + #size-cells = <0>; + + global-phys = <&phy4>; + global-phy-names = "base"; + + ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + phy4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; + };Signature · 1 line
2.40.1
Signature · 1 line
Ansuel
Andrew Lunn
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
In reply to Christian MarangiQuoted 7 lines · Christian Marangi
Document ethernet PHY package nodes used to describe PHY shipped in bundle of 4-5 PHY. These particular PHY require specific PHY in the package for global onfiguration of the PHY package.
Example are PHY package that have some regs only in one PHY of the package and will affect every other PHY in the package, for example related to PHY interface mode calibration or global PHY mode selection.
I think you are being overly narrow here. The 'global' registers could be spread over multiple addresses. Particularly for a C22 PHY. I suppose they could even be in a N+1 address space, where there is no PHY at all.
Where the global registers are is specific to a PHY package vendor/model. The PHY driver should know this. All the PHY driver needs to know is some sort of base offset. PHY0 in this package is using address X. It can then use relative addressing from this base to access the global registers for this package.
Quoted 3 lines
It's also possible to specify the property phy-mode to specify that the PHY package sets a global PHY interface mode and every PHY of the package requires to have the same PHY interface mode.
I don't think it is what simple. See the QCA8084 for example. 3 of the 4 PHYs must use QXGMII. The fourth PHY can also use QXGMII but it can be multiplexed to a different PMA and use 1000BaseX, SGMII or 2500BaseX.
I do think we need somewhere to put package properties. But i don't think phy-mode is such a property. At the moment, i don't have a good example of a package property.
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml line 71
Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +10
-0+examples: + - | + ethernet { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy-package { + compatible = "ethernet-phy-package"; + #address-cells = <1>; + #size-cells = <0>;
You have the PHYs within the Ethernet node. This is allowed by DT, for historic reasons. However, i don't remember the last time a patch was submitted that actually used this method. Now a days, PHYs are on an MDIO bus, and they are children of that bus in the DT representation. However you represent the package needs to work with MDIO busses.
Andrew
---
pw-bot: cr
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 14 lines · Andrew Lunn
Quoted 7 lines · Christian Marangi
Document ethernet PHY package nodes used to describe PHY shipped in bundle of 4-5 PHY. These particular PHY require specific PHY in the package for global onfiguration of the PHY package.
Example are PHY package that have some regs only in one PHY of the package and will affect every other PHY in the package, for example related to PHY interface mode calibration or global PHY mode selection.
I think you are being overly narrow here. The 'global' registers could be spread over multiple addresses. Particularly for a C22 PHY. I suppose they could even be in a N+1 address space, where there is no PHY at all.
Quoted 5 lines
Where the global registers are is specific to a PHY package vendor/model. The PHY driver should know this. All the PHY driver needs to know is some sort of base offset. PHY0 in this package is using address X. It can then use relative addressing from this base to access the global registers for this package.
Yes that would also work but adds extra fragile code in PHY driver. An idea might be define PHY package node with a reg that is the base addr... and if we really want every PHY in the PHY package node is an offset of the base addr.
Quoted 9 lines
Quoted 4 lines
It's also possible to specify the property phy-mode to specify that the PHY package sets a global PHY interface mode and every PHY of the package requires to have the same PHY interface mode.
I don't think it is what simple. See the QCA8084 for example. 3 of the 4 PHYs must use QXGMII. The fourth PHY can also use QXGMII but it can be multiplexed to a different PMA and use 1000BaseX, SGMII or 2500BaseX.
Yes that is totally a problem but I think it can only be handled with some validation in the PHY driver... I assume probe_once would validate the modes?
Quoted 5 lines
I do think we need somewhere to put package properties. But i don't think phy-mode is such a property. At the moment, i don't have a good example of a package property.
And this is the main problem with this thing... Find a good way to define them that everyone is OK with.
Another idea might be introduce to each PHY a property that point to the PHY package node (phandle) with all the info... But where to place that??? Outside mdio node? That would be confusing... This is why I like this subnode way.
I know it deviates a bit from the normal way of defining small node in the mdio node one for each PHY.
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/net/ethernet-phy-package.yaml new file +8
-0+examples: + - | + ethernet { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy-package { + compatible = "ethernet-phy-package";
Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ #address-cells = <1>; + #size-cells = <0>;You have the PHYs within the Ethernet node. This is allowed by DT, for historic reasons. However, i don't remember the last time a patch was submitted that actually used this method. Now a days, PHYs are on an MDIO bus, and they are children of that bus in the DT representation. However you represent the package needs to work with MDIO busses.
Using the ethernet node was an oversight and actually this is defined as a subnode in the mdio node.
A real DT that use this is (ipq807x):
&mdio {
status = "okay";
pinctrl-0 = <&mdio_pins>;
pinctrl-names = "default";
reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>;
ethernet-phy-package {
compatible = "ethernet-phy-package";
phy-mode = "psgmii";
global-phys = <&qca8075_4>, <&qca8075_psgmii>;
global-phy-names = "combo", "analog_psgmii";
qca8075_0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0>;
};
qca8075_1: ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <1>;
};
qca8075_2: ethernet-phy@2 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <2>;
};
qca8075_3: ethernet-phy@3 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <3>;
};
qca8075_4: ethernet-phy@4 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <4>;
};
qca8075_psgmii: ethernet-phy@5 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <5>;
};
};
qca8081: ethernet-phy@28 {
compatible = "ethernet-phy-id004d.d101";
reg = <28>;
reset-gpios = <&tlmm 31 GPIO_ACTIVE_LOW>;
};
aqr113c: ethernet-phy@8 {
compatible = "ethernet-phy-ieee802.3-c45";
reg = <8>;
reset-gpios = <&tlmm 63 GPIO_ACTIVE_LOW>;
};
};Signature · 1 line
Ansuel
Andrew Lunn
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 19 lines
A real DT that use this is (ipq807x):
&mdio { status = "okay"; pinctrl-0 = <&mdio_pins>; pinctrl-names = "default"; reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; ethernet-phy-package { compatible = "ethernet-phy-package"; phy-mode = "psgmii"; global-phys = <&qca8075_4>, <&qca8075_psgmii>; global-phy-names = "combo", "analog_psgmii"; qca8075_0: ethernet-phy@0 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <0>; };
...
Quoted 7 lines
};
qca8081: ethernet-phy@28 {
compatible = "ethernet-phy-id004d.d101";
reg = <28>;
reset-gpios = <&tlmm 31 GPIO_ACTIVE_LOW>;
};I've no idea if DT allows this. The issue is that reg is the same for both nodes within the ethernet-phy-package container, and ethernet-phy@28. They are all addresses on the same MDIO bus. We are parsing this bus structure ourselves in __of_mdiobus_register(), so we could make it work, but i don't know if we should make it work.
Andrew
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 30 lines · Andrew Lunn
Quoted 19 lines
A real DT that use this is (ipq807x):
&mdio { status = "okay"; pinctrl-0 = <&mdio_pins>; pinctrl-names = "default"; reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; ethernet-phy-package { compatible = "ethernet-phy-package"; phy-mode = "psgmii"; global-phys = <&qca8075_4>, <&qca8075_psgmii>; global-phy-names = "combo", "analog_psgmii"; qca8075_0: ethernet-phy@0 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <0>; };...
Quoted 7 lines
}; qca8081: ethernet-phy@28 { compatible = "ethernet-phy-id004d.d101"; reg = <28>; reset-gpios = <&tlmm 31 GPIO_ACTIVE_LOW>; };
Quoted 6 lines
I've no idea if DT allows this. The issue is that reg is the same for both nodes within the ethernet-phy-package container, and ethernet-phy@28. They are all addresses on the same MDIO bus. We are parsing this bus structure ourselves in
__of_mdiobus_register(), so we could make it work, but i don't know if we should make it work.
And that is why I have some reserve on the idea of defining a reg for ethernet-phy-package. Adding a reg would create some duplicate. Is it really a problem to have a node with no reg in the mdio node?
(patch 04 of this series already updates the parsing function to check one level deeper in the presence of the ethernet-phy-compatible treating any node found as it was defined in the upper mdio node)
Signature · 1 line
Ansuel
Rob Herring
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
In reply to Andrew LunnQuoted 9 lines · Andrew Lunn
Quoted 7 lines · Christian Marangi
Document ethernet PHY package nodes used to describe PHY shipped in bundle of 4-5 PHY. These particular PHY require specific PHY in the package for global onfiguration of the PHY package.
Example are PHY package that have some regs only in one PHY of the package and will affect every other PHY in the package, for example related to PHY interface mode calibration or global PHY mode selection.
Quoted 7 lines
I think you are being overly narrow here. The 'global' registers could be spread over multiple addresses. Particularly for a C22 PHY. I suppose they could even be in a N+1 address space, where there is no PHY at all.
Where the global registers are is specific to a PHY package vendor/model.
For this reason in particular, the package needs a specific compatible.
Quoted 9 lines
The PHY driver should know this. All the PHY driver
needs to know is some sort of base offset. PHY0 in this package is using address X. It can then use relative addressing from this base to access the global registers for this package.Quoted 3 lines
It's also possible to specify the property phy-mode to specify that the PHY package sets a global PHY interface mode and every PHY of the package requires to have the same PHY interface mode.
Quoted 8 lines
I don't think it is what simple. See the QCA8084 for example. 3 of the 4 PHYs must use QXGMII. The fourth PHY can also use QXGMII but it can be multiplexed to a different PMA and use 1000BaseX, SGMII or 2500BaseX.
I do think we need somewhere to put package properties. But i don't think phy-mode is such a property. At the moment, i don't have a good example of a package property.
What about power supplies and reset/enable lines?
Rob
Andrew Lunn
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 5 lines
Quoted 3 lines
I do think we need somewhere to put package properties. But i don't think phy-mode is such a property. At the moment, i don't have a good example of a package property.
What about power supplies and reset/enable lines?
Yes, good point. I can imagine some packages sharing regulators. Reset might also be shared, but it makes things messy to handle.
Andrew
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 9 lines · Andrew Lunn
Quoted 5 lines
Quoted 3 lines
I do think we need somewhere to put package properties. But i don't think phy-mode is such a property. At the moment, i don't have a good example of a package property.
What about power supplies and reset/enable lines?
Yes, good point. I can imagine some packages sharing regulators. Reset might also be shared, but it makes things messy to handle.
Sooooo.... Sorry if I insist but I would really love to have something ""stable"" to move this further. (the changes are easy enough so it's really a matter of finding a good DT structure)
Maybe a good idea would be summarize the concern and see what solution was proposed:
Concern list:
1. ethernet-phy-package MUST be placed in mdio node (not in ethernet, the example was wrong anyway) and MUST have an addr
Current example doesn't have an addr. I would prefer this way but no problem in changing this.
Solution:
- Add reg to the ethernet-phy-package node with the base address of the PHY package (base address = the first PHY address of the package)
We will have a PHY node with the same address of the PHY package node. Each PHY node in the PHY package node will have reg set to the REAL address in the mdio bus.
2. global-phys are redundant and can be dropped.
They are used to facilitate and make it less obscure how the PHY package is described. Can totally be handled internally by the PHY driver. Still I would prefer to keep them as is.
Solution:
- Drop the thing and leave the PHY driver handle it with hardcoded values.
Due to point 1, the shared struct will have the base address of the PHY package and will be handle to reference the global PHY at an offset from the base address.
3. phy-mode is problematic.
It's an optional value to enforce a specific mode for each PHY in the package. For complex configuration the mode won't be defined.
Solution:
- Rename it to package-phy-mode to make it less confusing.
- Add an additional function that PHY package can use to make custom validation on the mode for every PHY attached (in the PHY package).
Would make it less clear but more flexible for complex configuration. Maybe both solution can be implemented and the special function is used if the mode is not defined?
4. Not finding a correct place to put PHY package info.
I'm still convinced the mdio node is the correct place.
- PHY package are PHY in bundle so they are actual PHY
- We already have in the mdio node special handling (every DSA switch use custom compatible and PHY ID is not used to probe them normally)
- Node this way won't be treated as PHY as they won't match the PHY node name pattern and also won't have the compatible pattern for PHY.
Solution:
- ethernet-phy-package node is OK given a reg is defined.
These are the 4 concern we have currently, hoping I didn't miss any, I hope we can sort those so I can send a v2 and make some progress on this.
Signature · 1 line
Ansuel
Andrew Lunn
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 22 lines · Christian Marangi
Quoted 9 lines · Andrew Lunn
Quoted 5 lines
Quoted 3 lines
I do think we need somewhere to put package properties. But i don't think phy-mode is such a property. At the moment, i don't have a good example of a package property.
What about power supplies and reset/enable lines?
Yes, good point. I can imagine some packages sharing regulators. Reset might also be shared, but it makes things messy to handle.
Sooooo.... Sorry if I insist but I would really love to have something ""stable"" to move this further. (the changes are easy enough so it's really a matter of finding a good DT structure)
Maybe a good idea would be summarize the concern and see what solution was proposed:
Concern list:
1. ethernet-phy-package MUST be placed in mdio node (not in ethernet, the example was wrong anyway) and MUST have an addr
Quoted 7 lines
Current example doesn't have an addr. I would prefer this way but no problem in changing this.
Solution:
- Add reg to the ethernet-phy-package node with the base address of the PHY package (base address = the first PHY address of the package)
Yes.
Quoted 3 lines
We will have a PHY node with the same address of the PHY package node. Each PHY node in the PHY package node will have reg set to the REAL address in the mdio bus.
Basically Yes. I actually think the first sentence is not 100% correct. It could be all the package configuration registers are in the base address, without an actual PHY. The PHYs then follow at addresses above it. I can also imagine a case where the first PHY in the package is not used, so its not listed at all. So i think it should be "We often have a PHY node with the same address of the PHY package node."
Quoted 8 lines
3. phy-mode is problematic.
It's an optional value to enforce a specific mode for each PHY in the package. For complex configuration the mode won't be defined.
Solution:
- Rename it to package-phy-mode to make it less confusing.
Quoted 6 lines
- Add an additional function that PHY package can use to make custom validation on the mode for every PHY attached (in the PHY package).
Would make it less clear but more flexible for complex configuration. Maybe both solution can be implemented and the special function is used if the mode is not defined?
The description you give is that there are two SERDES, and both could be connected to a MAC. What does package-phy-mode represent then?
Luo Jie patch for the qca8084 seems to have the same issue. It has two SERDES/PMA, and both could be connected to the MACs. So it seems like QCA devices don't actually fit this model. If we want to describe the package link mode, we probably need to list each PMA, and have a property in the PMA node indicating what link mode the PMA is operating at.
At least for the moment, its not clear we actually need this at all. It seems like the phy-mode is all we need. The PHY driver should know what values are valid per port, and so can validate the value.
Quoted 10 lines
4. Not finding a correct place to put PHY package info.
I'm still convinced the mdio node is the correct place.
- PHY package are PHY in bundle so they are actual PHY
- We already have in the mdio node special handling (every DSA switch use custom compatible and PHY ID is not used to probe them normally)
- Node this way won't be treated as PHY as they won't match the PHY node name pattern and also won't have the compatible pattern for PHY.
We do need a compatible for the package. The kernel is unlikely to use it, but the validation tools will. Each package can have its own DT properties, so we need a .yaml to describe those properties. So i would expect to have a "qca807x-package" compatible, which then lists the tx driver strength etc. The PHYs within the package don't need compatible, they are just linux PHYs, probed using the same code as PHYs outside of a package.
Andrew
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 26 lines · Andrew Lunn
Quoted 25 lines · Christian Marangi
Quoted 9 lines · Andrew Lunn
Quoted 5 lines
Quoted 3 lines
I do think we need somewhere to put package properties. But i don't think phy-mode is such a property. At the moment, i don't have a good example of a package property.
What about power supplies and reset/enable lines?
Yes, good point. I can imagine some packages sharing regulators. Reset might also be shared, but it makes things messy to handle.
Sooooo.... Sorry if I insist but I would really love to have something ""stable"" to move this further. (the changes are easy enough so it's really a matter of finding a good DT structure)
Maybe a good idea would be summarize the concern and see what solution was proposed:
Concern list:
1. ethernet-phy-package MUST be placed in mdio node (not in ethernet, the example was wrong anyway) and MUST have an addrCurrent example doesn't have an addr. I would prefer this way but no problem in changing this.
Quoted 7 lines
Quoted 4 lines
Solution:
- Add reg to the ethernet-phy-package node with the base address of the PHY package (base address = the first PHY address of the package)Yes.
Thanks.
Quoted 4 lines
Quoted 3 lines
We will have a PHY node with the same address of the PHY package node. Each PHY node in the PHY package node will have reg set to the REAL address in the mdio bus.
Quoted 8 lines
Basically Yes. I actually think the first sentence is not 100% correct. It could be all the package configuration registers are in the base address, without an actual PHY. The PHYs then follow at addresses above it. I can also imagine a case where the first PHY in the package is not used, so its not listed at all. So i think it should be "We often have a PHY node with the same address of the PHY package node."
Just to add details, also the opposite can happen. Where the last PHY in the bundle is used for global configuration but is not defined. This is another reason I wanted the global-phy proprerty, having to reference them even if they are not used better describe the actual PHY address used in the mdio bus. If the PHY is handled internally and omitted in DT then people might think that address is not used.
Quoted 25 lines
Quoted 8 lines
3. phy-mode is problematic.
It's an optional value to enforce a specific mode for each PHY in the package. For complex configuration the mode won't be defined.
Solution:
- Rename it to package-phy-mode to make it less confusing.Quoted 6 lines
- Add an additional function that PHY package can use to make custom validation on the mode for every PHY attached (in the PHY package).
Would make it less clear but more flexible for complex configuration. Maybe both solution can be implemented and the special function is used if the mode is not defined?
The description you give is that there are two SERDES, and both could be connected to a MAC. What does package-phy-mode represent then?
Luo Jie patch for the qca8084 seems to have the same issue. It has two SERDES/PMA, and both could be connected to the MACs. So it seems like QCA devices don't actually fit this model. If we want to describe the package link mode, we probably need to list each PMA, and have a property in the PMA node indicating what link mode the PMA is operating at.
Quoted 4 lines
At least for the moment, its not clear we actually need this at all. It seems like the phy-mode is all we need. The PHY driver should know what values are valid per port, and so can validate the value.
Just to be more precise qca807x can operate in 3 different mode:
(this is controlled by the MODE_CFG bits)
- QSGMII: 5 copper port
- PSGMII: 5 copper port
- PSGMII: 4 copper port + 1 combo (that can be both fiber or copper)
When mode is set to QSGMII each PHY needs to have the matching mode or we have no traffic. It makes it difficult driver side to understand what mode should be enforced with all kind of parsing or magic in private struct.
Maybe for this specific case would be ok to introduce a simple specific proprerty? Like qca,qsgmii_mode ?
Quoted 11 lines
Quoted 10 lines
4. Not finding a correct place to put PHY package info.
I'm still convinced the mdio node is the correct place.
- PHY package are PHY in bundle so they are actual PHY
- We already have in the mdio node special handling (every DSA switch use custom compatible and PHY ID is not used to probe them normally)
- Node this way won't be treated as PHY as they won't match the PHY node name pattern and also won't have the compatible pattern for PHY.
Quoted 8 lines
We do need a compatible for the package. The kernel is unlikely to use it, but the validation tools will. Each package can have its own DT properties, so we need a .yaml to describe those properties. So i would expect to have a "qca807x-package" compatible, which then lists the tx driver strength etc. The PHYs within the package don't need compatible, they are just linux PHYs, probed using the same code as PHYs outside of a package.
Since the idea is add OF support for the PHY we also need a generic compatible for it.
Is it ok to have something like
compatible = "ethernet-phy-package", "qca807x-phy-package";
With "ethernet-phy-package" a must and "qca807x-phy-package" used only if additional property are used.
My current idea was to use select and base everything on the possible PHY compatible (and it does work, tested by adding bloat in the DT example and seeing if the schema was rejected). Had this idea since the compatible would never be used.
Signature · 1 line
Ansuel
Andrew Lunn
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 4 lines
Just to be more precise qca807x can operate in 3 different mode:
(this is controlled by theMODE_CFGbits)- QSGMII: 5 copper port
4 slots over QSGMII, plus the second SERDES is connected to the MAC using SGMII/1000BaseX?
Quoted 1 line
- PSGMII: 5 copper port
5 slots over QSGMII, the second SERDES is idle?
Quoted 1 line
- PSGMII: 4 copper port + 1 combo (that can be both fiber or copper)
5 slots over QSGMII, with the second SERDES connected to an SFP cage.
Are ports 1-4 always connected to the P/Q SGMII. Its only port 5 which can use the second SERDES?
Does changing between QSGMII and PSGMII really change the protocol run over the multiplex link? The clock rate is slower, there are only 4 multiplexed slots vs five? Or does it keep using PSGMII and leaves one slot
I can see how it is messy to validate, if you only have phy-mode. So maybe MODE_CFG is a package property. You then can validate the phy-mode against MODE_CFG.
Andrew
Russell King (Oracle)
reviewerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 10 lines · Andrew Lunn
Quoted 4 lines
Just to be more precise qca807x can operate in 3 different mode:
(this is controlled by theMODE_CFGbits)- QSGMII: 5 copper port
4 slots over QSGMII, plus the second SERDES is connected to the MAC using SGMII/1000BaseX?
Quoted 1 line
- PSGMII: 5 copper port
Quoted 8 lines
5 slots over QSGMII, the second SERDES is idle?
Quoted 1 line
- PSGMII: 4 copper port + 1 combo (that can be both fiber or copper)
5 slots over QSGMII, with the second SERDES connected to an SFP cage.
Are ports 1-4 always connected to the P/Q SGMII. Its only port 5 which can use the second SERDES?
I think what would really help here is if there was an ascii table to describe the configurations, rather than trying to put it into words.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Andrew Lunn
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 15 lines · Russell King (Oracle)
Quoted 14 lines · Andrew Lunn
Quoted 4 lines
Just to be more precise qca807x can operate in 3 different mode:
(this is controlled by theMODE_CFGbits)- QSGMII: 5 copper port
4 slots over QSGMII, plus the second SERDES is connected to the MAC using SGMII/1000BaseX?
Quoted 1 line
- PSGMII: 5 copper port
5 slots over QSGMII, the second SERDES is idle?
Quoted 1 line
- PSGMII: 4 copper port + 1 combo (that can be both fiber or copper)
Quoted 7 lines
Quoted 4 lines
5 slots over QSGMII, with the second SERDES connected to an SFP cage.
Are ports 1-4 always connected to the P/Q SGMII. Its only port 5 which can use the second SERDES?
I think what would really help here is if there was an ascii table to describe the configurations, rather than trying to put it into words.
Yes.
And also for ipq4019. We need to merge these two threads of conversation, since in the end they are probably the same driver, same device tree etc.
Andrew
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 21 lines · Andrew Lunn
Quoted 20 lines · Russell King (Oracle)
Quoted 18 lines · Andrew Lunn
Quoted 4 lines
Just to be more precise qca807x can operate in 3 different mode:
(this is controlled by theMODE_CFGbits)- QSGMII: 5 copper port
4 slots over QSGMII, plus the second SERDES is connected to the MAC using SGMII/1000BaseX?
Quoted 1 line
- PSGMII: 5 copper port
5 slots over QSGMII, the second SERDES is idle?
Quoted 1 line
- PSGMII: 4 copper port + 1 combo (that can be both fiber or copper)
5 slots over QSGMII, with the second SERDES connected to an SFP cage.
Are ports 1-4 always connected to the P/Q SGMII. Its only port 5 which can use the second SERDES?
Quoted 9 lines
Quoted 2 lines
I think what would really help here is if there was an ascii table to describe the configurations, rather than trying to put it into words.
Yes.
And also for ipq4019. We need to merge these two threads of conversation, since in the end they are probably the same driver, same device tree etc.
For everyone that missed Robert response in patch 12 let me quote him also here.
"
Hi Andrew,
I think that the description is confusing.
QCA807x supports 3 different modes:
1. PSGMII (5 copper ports)
2. PSGMII (4 copper ports + 1 combo port)
3. QSGMII+SGMII
So, in case option 2 is selected then the combo port can also be used for 1000Base-X and 100Base-FX modules or copper and it will autodetect the exact media.
This is supported via the SFP op-s and I have been using it without issues for a while.
I have not tested option 3 in combination with SFP to the copper module so I cant
say whether that works.
From what I can gather from the typical usage examples in the datasheet, this QSMII+SGMII
mode is basically intended as a backward compatibility thing as only QCA SoC-s have PSGMII
support so that you could still use SoC-s with QSGMII and SGMII support only.
So there is no way to control the SerDes-es individually, only the global mode can be changed via
the Chip configuration register in the Combo port.
You can see the block diagram of this PHY in this public PDF on page 2[1].
[1] https://content.codico.com/fileadmin/media/download/datasheets/qualcomm/qualcomm_qca8075.pdf
"
Signature · 1 line
Ansuel
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 49 lines · Christian Marangi
Quoted 21 lines · Andrew Lunn
Quoted 20 lines · Russell King (Oracle)
Quoted 18 lines · Andrew Lunn
Quoted 4 lines
Just to be more precise qca807x can operate in 3 different mode:
(this is controlled by theMODE_CFGbits)- QSGMII: 5 copper port
4 slots over QSGMII, plus the second SERDES is connected to the MAC using SGMII/1000BaseX?
Quoted 1 line
- PSGMII: 5 copper port
5 slots over QSGMII, the second SERDES is idle?
Quoted 1 line
- PSGMII: 4 copper port + 1 combo (that can be both fiber or copper)
5 slots over QSGMII, with the second SERDES connected to an SFP cage.
Are ports 1-4 always connected to the P/Q SGMII. Its only port 5 which can use the second SERDES?
Quoted 9 lines
Quoted 2 lines
I think what would really help here is if there was an ascii table to describe the configurations, rather than trying to put it into words.
Yes.
And also for ipq4019. We need to merge these two threads of conversation, since in the end they are probably the same driver, same device tree etc.
For everyone that missed Robert response in patch 12 let me quote him also here.
"
Hi Andrew,
I think that the description is confusing.
QCA807x supports 3 different modes:
1. PSGMII (5 copper ports)
2. PSGMII (4 copper ports + 1 combo port)
3. QSGMII+SGMIISo, in case option 2 is selected then the combo port can also be used for 1000Base-X and 100Base-FX modules or copper and it will autodetect the exact media.
This is supported via the SFP op-s and I have been using it without issues for a while.
Quoted 3 lines
I have not tested option 3 in combination with SFP to the copper module so I cant
say whether that works.
For the option3, the last PHY works on SGMII mode, then it can't be used with SFP, only copper is supported in this mode.
Quoted 15 lines
From what I can gather from the typical usage examples in the
datasheet, this QSMII+SGMII
mode is basically intended as a backward compatibility thing as only QCA SoC-s have PSGMII
support so that you could still use SoC-s with QSGMII and SGMII support only.So there is no way to control the SerDes-es individually, only the global mode can be changed via
the Chip configuration register in the Combo port.You can see the block diagram of this PHY in this public PDF on page 2[1].
[1] https://content.codico.com/fileadmin/media/download/datasheets/qualcomm/qualcomm_qca8075.pdf
"
Russell King (Oracle)
reviewerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 52 lines · Jie Luo
Quoted 49 lines · Christian Marangi
Quoted 21 lines · Andrew Lunn
Quoted 20 lines · Russell King (Oracle)
Quoted 18 lines · Andrew Lunn
Quoted 4 lines
Just to be more precise qca807x can operate in 3 different mode:
(this is controlled by theMODE_CFGbits)- QSGMII: 5 copper port
4 slots over QSGMII, plus the second SERDES is connected to the MAC using SGMII/1000BaseX?
Quoted 1 line
- PSGMII: 5 copper port
5 slots over QSGMII, the second SERDES is idle?
Quoted 1 line
- PSGMII: 4 copper port + 1 combo (that can be both fiber or copper)
5 slots over QSGMII, with the second SERDES connected to an SFP cage.
Are ports 1-4 always connected to the P/Q SGMII. Its only port 5 which can use the second SERDES?
Quoted 9 lines
Quoted 2 lines
I think what would really help here is if there was an ascii table to describe the configurations, rather than trying to put it into words.
Yes.
And also for ipq4019. We need to merge these two threads of conversation, since in the end they are probably the same driver, same device tree etc.
For everyone that missed Robert response in patch 12 let me quote him also here.
"
Hi Andrew,
I think that the description is confusing.
QCA807x supports 3 different modes:
1. PSGMII (5 copper ports)
2. PSGMII (4 copper ports + 1 combo port)
3. QSGMII+SGMIISo, in case option 2 is selected then the combo port can also be used for 1000Base-X and 100Base-FX modules or copper and it will autodetect the exact media.
This is supported via the SFP op-s and I have been using it without issues for a while.
Quoted 6 lines
Quoted 3 lines
I have not tested option 3 in combination with SFP to the copper module so I cant
say whether that works.For the option3, the last PHY works on SGMII mode, then it can't be used with SFP, only copper is supported in this mode.
So, from what you've written, and looking at the PDF for QCA8075:
First Serdes mode Second Serdes mode
Option 1 PSGMII for copper Disabled
ports 0-4 Option 2 PSGMII for copper 1000BASE-X / 100BASE-FX ports 0-4
Option 3 QSGMII for copper SGMII for
ports 0-3 copper port 4
In all cases, ports 0-4 have a copper (baseT/baseTx/baseTe) port available.
This is a much easier to understand presentation than writing out a longwinded description of the three modes. Please include the table and the statement below the table in the commit description as that is necessary to describe the hardware setup being addressed in these patches.
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Andrew Lunn
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 7 lines
First Serdes mode Second Serdes mode
Option 1 PSGMII for copper Disabledports 0-4 Option 2 PSGMII for copper 1000BASE-X / 100BASE-FX ports 0-4Option 3 QSGMII for copper SGMII for
ports 0-3 copper port 4
With option 2, can the second SERDES also do SGMII? You are likely to need that when a Copper SFP module is inserted into the cage.
Andrew
Russell King (Oracle)
reviewerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 10 lines · Andrew Lunn
Quoted 7 lines
First Serdes mode Second Serdes mode
Option 1 PSGMII for copper Disabledports 0-4 Option 2 PSGMII for copper 1000BASE-X / 100BASE-FX ports 0-4Option 3 QSGMII for copper SGMII for
ports 0-3 copper port 4With option 2, can the second SERDES also do SGMII? You are likely to need that when a Copper SFP module is inserted into the cage.
The document states "The fiber port supports 1000BASE-X/100BASE-FX".
The same is true of Marvell 88x3310's fiber port - it supports only fiber not SGMII. This is actually something else that - when the patches for stacked PHYs mature - will need to be addressed. If we have a 1G copper SFP plugged into an interface that only supports 1000base-X then we need a way to switch the PHY on the SFP module to 1000base-X if it's in SGMII mode.
Some copper SFPs come up in 1000base-X mode, and we currently rely on the 88e1111 driver to switch them to SGMII mode. Others do want SGMII mode (like Mikrotik RJ01 where the PHY is inaccessible and thus can't be reconfigured.)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 22 lines · Russell King (Oracle)
Quoted 10 lines · Andrew Lunn
Quoted 7 lines
First Serdes mode Second Serdes mode
Option 1 PSGMII for copper Disabledports 0-4 Option 2 PSGMII for copper 1000BASE-X / 100BASE-FX ports 0-4Option 3 QSGMII for copper SGMII for
ports 0-3 copper port 4With option 2, can the second SERDES also do SGMII? You are likely to need that when a Copper SFP module is inserted into the cage.
The document states "The fiber port supports 1000BASE-X/100BASE-FX".
The same is true of Marvell 88x3310's fiber port - it supports only fiber not SGMII. This is actually something else that - when the patches for stacked PHYs mature - will need to be addressed. If we have a 1G copper SFP plugged into an interface that only supports 1000base-X then we need a way to switch the PHY on the SFP module to 1000base-X if it's in SGMII mode.
Quoted 4 lines
Some copper SFPs come up in 1000base-X mode, and we currently rely on the 88e1111 driver to switch them to SGMII mode. Others do want SGMII mode (like Mikrotik RJ01 where the PHY is inaccessible and thus can't be reconfigured.)
I can confirm that SGMII mode doesn't work with Option 2, I have tested this a while ago with Mikrotik RJ01 (I think it has AR803x, but its not accessible as you pointed out) and it was somewhat working but in half duplex only and dropping
packets.
Currently, SFP mode is checked and only 1000Base-X and 100Base-FX are accepted, otherwise the module insert will return and error for unsupported mode.
Regards,
Robert
Quoted 4 lines
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Signature · 7 lines
Robert Marko Staff Embedded Linux Engineer Sartura Ltd. Lendavska ulica 16a 10000 Zagreb, Croatia Email: [email protected] Web: www.sartura.hr
Andrew Lunn
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
In reply to Christian MarangiQuoted 9 lines
compatible = "ethernet-phy-package", "qca807x-phy-package";
With "ethernet-phy-package" a must and "qca807x-phy-package" used only if additional property are used.
My current idea was to use select and base everything on the possible PHY compatible (and it does work, tested by adding bloat in the DT example and seeing if the schema was rejected). Had this idea since the compatible would never be used.
The DT people are unhappy with PHYs don't use compatibles, so validation does not work. It probably too late to add compatibles to very PHY driver. But this is new development work, we don't have any history. So we can add a compatible per package to make the validation tools work.
So for parsing the tree in the kernel we look for 'ethernet-phy-package'. For validating the tree using the yaml tools we use the 'qca807x-phy-package'.
Andrew
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 16 lines · Andrew Lunn
Quoted 9 lines
compatible = "ethernet-phy-package", "qca807x-phy-package";
With "ethernet-phy-package" a must and "qca807x-phy-package" used only if additional property are used.
My current idea was to use select and base everything on the possible PHY compatible (and it does work, tested by adding bloat in the DT example and seeing if the schema was rejected). Had this idea since the compatible would never be used.
The DT people are unhappy with PHYs don't use compatibles, so validation does not work. It probably too late to add compatibles to very PHY driver. But this is new development work, we don't have any history. So we can add a compatible per package to make the validation tools work.
Quoted 4 lines
So for parsing the tree in the kernel we look for 'ethernet-phy-package'. For validating the tree using the yaml tools we use the 'qca807x-phy-package'.
Ok clear, what about the generic ethernet-phy-package.yaml?
Idea was to describe common properties there and then specific PHY package would add every common property with $ref and add their special ones on top of that. Would that be ok? (similar to the current implementation with ethernet-phy-package and qcom,qca807x with the only difference that qcom,qca807x.yaml would also have the compatible set (currently missing from this RFC)
Signature · 1 line
Ansuel
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
In reply to Christian MarangiQuoted 6 lines · Christian Marangi
Sooooo.... Sorry if I insist but I would really love to have something ""stable"" to move this further. (the changes are easy enough so it's really a matter of finding a good DT structure)
Maybe a good idea would be summarize the concern and see what solution was proposed:
Sorry, I didn't follow the entire discussion. I hope I'm not too far off with my understanding of your problems.
I think you are hitting some of the same points I have hit with DSA. The PHY package could be considered an SoC with lots of peripherals on it, for which you'd want separate drivers. Just like a DSA switch would. I don't think it's exactly phylib's place to deal with that, just like it's not DSA's place to deal with complex SoCs, just with the switching IP (like the Ethernet PHY IP for phylib).
https://lore.kernel.org/lkml/20221222134844.lbzyx5hz7z5n763n@skbuf/
Why does the ethernet-phy-package DT binding attempt to be so grand and generic? I would expect the 180 degree opposite. Make it have a _single_ compatible of "qcom,qca807x" (but don't use an "x" wildcard, do specify the full package name).
Make it have a "reg" property which is the base MDIO address of the package.
Write an mdio_device driver that probes on that. The PHY core already knows that if a child on the MDIO bus has a compatible string of the normal form (not like "ethernet-phy-id004d.d0b2"), then it's looking at an mdio_device.
Make the OF node of the package have an "mdio" child with its own compatible string, which represents the place where PHYs are. The driver for the "mdio" child has a very simple implementation of the mii_bus ops, which just calls into the device parent (it can assume a certain parent implementation and private data structures).
Lateral to the "mdio" child node of the "qcom,qca807x" package node, you could put any other device tree properties that you want.
Make the mdio_device driver for "qcom,qca807x" use shared code if you want - but keep the device tree structure hardware-specific. Look at the compatible strings that e.g. the drivers/mfd/simple-mfd-i2c.c driver probes on. You could always change the driver implementation for a certain compatible string, but you'll be stuck with the ultra-generic compatible = "ethernet-phy-package", which has the problems that you mention.
Quoted 5 lines
Concern list:
1. ethernet-phy-package MUST be placed in mdio node (not in ethernet, the example was wrong anyway) and MUST have an addr
Quoted 7 lines
Current example doesn't have an addr. I would prefer this way but no problem in changing this.
Solution:
- Add reg to the ethernet-phy-package node with the base address of the PHY package (base address = the first PHY address of the package)
Correct, what I'm saying is compatible with this.
Quoted 4 lines
We will have a PHY node with the same address of the PHY package node. Each PHY node in the PHY package node will have reg set to the REAL address in the mdio bus.
If the real PHY IPs are children of the package rather than on the same level with it, I don't think this will be a problem. I wonder if some address translation could be done with the "ranges" device tree property. I've never seen this with MDIO though.
Quoted 11 lines
4. Not finding a correct place to put PHY package info.
I'm still convinced the mdio node is the correct place.
- PHY package are PHY in bundle so they are actual PHY
- We already have in the mdio node special handling (every DSA switch use custom compatible and PHY ID is not used to probe them normally)
- Node this way won't be treated as PHY as they won't match the PHY node name pattern and also won't have the compatible pattern for PHY.
Quoted 2 lines
Solution:
- ethernet-phy-package node is OK given a reg is defined.
I agree that it should sit under the MDIO node. I disagree with the idea of a standardized binding for PHY packages.
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 40 lines · Vladimir Oltean
Quoted 6 lines · Christian Marangi
Sooooo.... Sorry if I insist but I would really love to have something ""stable"" to move this further. (the changes are easy enough so it's really a matter of finding a good DT structure)
Maybe a good idea would be summarize the concern and see what solution was proposed:
Sorry, I didn't follow the entire discussion. I hope I'm not too far off with my understanding of your problems.
I think you are hitting some of the same points I have hit with DSA. The PHY package could be considered an SoC with lots of peripherals on it, for which you'd want separate drivers. Just like a DSA switch would. I don't think it's exactly phylib's place to deal with that, just like it's not DSA's place to deal with complex SoCs, just with the switching IP (like the Ethernet PHY IP for phylib).
https://lore.kernel.org/lkml/20221222134844.lbzyx5hz7z5n763n@skbuf/Why does the ethernet-phy-package DT binding attempt to be so grand and generic? I would expect the 180 degree opposite. Make it have a _single_ compatible of "qcom,qca807x" (but don't use an "x" wildcard, do specify the full package name).
Make it have a "reg" property which is the base MDIO address of the package.
Write an
mdio_devicedriver that probes on that. The PHY core already knows that if a child on the MDIO bus has a compatible string of the normal form (not like "ethernet-phy-id004d.d0b2"), then it's looking at anmdio_device.Make the OF node of the package have an "mdio" child with its own compatible string, which represents the place where PHYs are. The driver for the "mdio" child has a very simple implementation of the
mii_busops, which just calls into the device parent (it can assume a certain parent implementation and private data structures).Lateral to the "mdio" child node of the "qcom,qca807x" package node, you could put any other device tree properties that you want.
Quoted 8 lines
Make the
mdio_devicedriver for "qcom,qca807x" use shared code if you want - but keep the device tree structure hardware-specific. Look at the compatible strings that e.g. thedrivers/mfd/simple-mfd-i2c.cdriver probes on. You could always change the driver implementation for a certain compatible string, but you'll be stuck with the ultra-generic compatible = "ethernet-phy-package", which has the problems that you mention.
The main reason is the fact that PHY package are already a thing and API are already there (phy_package_join/leave...) so we just lack any way to support this in DT without using specialized code in the PHY driver.
This is really completing the feature.
The only reason for the generic "ethernet-phy-package" compatible is to have a solid detection of the node in PHY core. (I assume parsing the node name might be problematic? Or maybe not now that we require adding a reg to it)
Also I don't expect tons of special properties for PHY package, with the current probe/config implementation, a PHY driver have lots of flexibility in all kind of validation.
Consider that the additional global-phys and global-phy-names are already expected to be dropped.
(we know the PHY package base address and we can calculate the offset of the global phy from there in the PHY package probe)
And even the phy-mode has been scrapped for more specific solution... (some assumption can be done on probe by checking the PHY mode and set stuff accordingly or even do parsing in the PHY package node as we pass the OF node of the phy package)
The PHY package node would be reduced to a simple compatible (and even this can be dropped) and a reg.
I feel there is a big chance here to generalize it and prevent any kind of mess with all kind of similar/equal code that just do the same thing. (and we already have an example with the PHY package API usage with every PHY having the same exact pattern for probe/config and nothing describing that the PHY are actually a package in DT)
Hope it all makes sense to you.
Quoted 16 lines
Quoted 5 lines
Concern list:
1. ethernet-phy-package MUST be placed in mdio node (not in ethernet, the example was wrong anyway) and MUST have an addrQuoted 7 lines
Current example doesn't have an addr. I would prefer this way but no problem in changing this.
Solution:
- Add reg to the ethernet-phy-package node with the base address of the PHY package (base address = the first PHY address of the package)Correct, what I'm saying is compatible with this.
Quoted 1 line
Quoted 9 lines
Quoted 3 lines
We will have a PHY node with the same address of the PHY package node. Each PHY node in the PHY package node will have reg set to the REAL address in the mdio bus.
If the real PHY IPs are children of the package rather than on the same level with it, I don't think this will be a problem. I wonder if some address translation could be done with the "ranges" device tree property. I've never seen this with MDIO though.
I can check it, I would love some way to describe the address used by the PHY package. (since everything will be handled internally with offsets, would be good to define in DT that (for example) addrs from 0 to 5 are used). Some PHY might be not attached but still used for global configuration of the PHY package.
Quoted 16 lines
Quoted 11 lines
4. Not finding a correct place to put PHY package info.
I'm still convinced the mdio node is the correct place.
- PHY package are PHY in bundle so they are actual PHY
- We already have in the mdio node special handling (every DSA switch use custom compatible and PHY ID is not used to probe them normally)
- Node this way won't be treated as PHY as they won't match the PHY node name pattern and also won't have the compatible pattern for PHY.Quoted 2 lines
Solution:
- ethernet-phy-package node is OK given a reg is defined.I agree that it should sit under the MDIO node. I disagree with the idea of a standardized binding for PHY packages.
Signature · 1 line
Ansuel
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 5 lines · Christian Marangi
The main reason is the fact that PHY package are already a thing and API are already there (phy_package_join/leave...) so we just lack any way to support this in DT without using specialized code in the PHY driver.
This is really completing the feature.
Hmm, I see struct phy_package_shared as a mechanism to tell phylib that multiple device structures are actually related with each other, because the device core, and their parent bus, has no idea. If you're under control of the parent bus code and you can probe PHY devices in any order you want and do whatever you want before probing them, I don't see why you would need struct phy_package_shared any longer? I don't see why this feature needs to be completed, if that involves changes to the device tree structure. PHY packages assumed no changes to the device tree (they rely on a hacky interpretation of the MDIO address AFAIU). If we change that basic premise, all implementation options are on the table, I think.
Quoted 4 lines
The only reason for the generic "ethernet-phy-package" compatible is to have a solid detection of the node in PHY core. (I assume parsing the node name might be problematic? Or maybe not now that we require adding a reg to it)
Our opinions seem to differ, but I don't think that the package needs a solid detection of the node in the PHY core :) I think phy_devices and mdio_devices already cover everything that's necessary to build a solution.
Quoted 9 lines
Also I don't expect tons of special properties for PHY package, with the current probe/config implementation, a PHY driver have lots of flexibility in all kind of validation.
Consider that the additional global-phys and global-phy-names are already expected to be dropped.
(we know the PHY package base address and we can calculate the offset of the global phy from there in the PHY package probe)
Quoted 7 lines
And even the phy-mode has been scrapped for more specific solution... (some assumption can be done on probe by checking the PHY mode and set stuff accordingly or even do parsing in the PHY package node as we pass the OF node of the phy package)
The PHY package node would be reduced to a simple compatible (and even this can be dropped) and a reg.
So why does it need to be described in DT, at this stage? :)
Quoted 7 lines
I feel there is a big chance here to generalize it and prevent any kind of mess with all kind of similar/equal code that just do the same thing. (and we already have an example with the PHY package API usage with every PHY having the same exact pattern for probe/config and nothing describing that the PHY are actually a package in DT)
Hope it all makes sense to you.
Andrew Lunn
maintainerRe: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
In reply to Vladimir OlteanQuoted 3 lines
I think you are hitting some of the same points I have hit with DSA. The PHY package could be considered an SoC with lots of peripherals on it, for which you'd want separate drivers.
At least at the moment, this is not true. The package does just contain PHYs. But it also has some properties which are shared across those PHYs, e.g. reset.
What you describe might become true in the future. e.g. The LED/GPIO controller is currently part of the PHY, and each PHY has its own. I could however imagine that becomes a block of its own, outside of the PHY address space, and maybe it might want its own class LED driver. Some PHYs have temperature sensors, which could be a package sensor, so could in theory be an individual hwmon driver. However, i've not yet seen such a package.
Do we consider this now? At the moment i don't see an MFD style system is required. We could crystal ball gaze and come up with some requirements, but i would prefer to have some real devices and datasheets. Without them, we will get the requirements wrong.
I also think we are not that far away from it, in terms of DT, if you consider the later comments. I suggested we need a phy package specific compatible. At the moment, it will be ignored by the kernel, the kernel does not need it, it probes the PHYs in the current way, using the ID registers. But it could in future be used to probe a real driver, which could be an MFD style driver. We need to see updated DT binding examples, but i don't see why we cannot slot it in at a later date.
Andrew
Re: [net-next RFC PATCH 03/14] dt-bindings: net: document ethernet PHY package nodes
Quoted 21 lines · Andrew Lunn
Quoted 3 lines
I think you are hitting some of the same points I have hit with DSA. The PHY package could be considered an SoC with lots of peripherals on it, for which you'd want separate drivers.
At least at the moment, this is not true. The package does just contain PHYs. But it also has some properties which are shared across those PHYs, e.g. reset.
What you describe might become true in the future. e.g. The LED/GPIO controller is currently part of the PHY, and each PHY has its own. I could however imagine that becomes a block of its own, outside of the PHY address space, and maybe it might want its own class LED driver. Some PHYs have temperature sensors, which could be a package sensor, so could in theory be an individual hwmon driver. However, i've not yet seen such a package.
Do we consider this now? At the moment i don't see an MFD style system is required. We could crystal ball gaze and come up with some requirements, but i would prefer to have some real devices and datasheets. Without them, we will get the requirements wrong.
Quoted 8 lines
I also think we are not that far away from it, in terms of DT, if you consider the later comments. I suggested we need a phy package specific compatible. At the moment, it will be ignored by the kernel, the kernel does not need it, it probes the PHYs in the current way, using the ID registers. But it could in future be used to probe a real driver, which could be an MFD style driver. We need to see updated DT binding examples, but i don't see why we cannot slot it in at a later date.
I'm not suggesting to go for MFD right away. Just with a structure that is extensible to possibly cover that. For now, a package node with a Qualcomm compatible, with the most minimal driver that forwards MDIO access to PHY children.
I can't speak for the future of PHY drivers, since I don't know enough about PHYs. I'm just coming from the DSA background where I really wish we had this sort of infrastructure earlier. Now I have the SJA1110 which still lacks support for the interrupt controller for its integrated PHYs, and a bunch of other IP blocks in the package, because it's so incredibly hard to make the driver support the old-style and the new-style device trees.
RFC PATCH 4/14 net: phy: add initial support for PHY package in DT
In reply to Christian MarangiAdd initial support for PHY package in DT.
Make it easier to define PHY package and describe the global PHY directly in DT by refereincing them by phandles instead of custom functions in each PHY driver.
Each PHY in a package needs to be defined in a dedicated node in the mdio node. This dedicated node needs to have the compatible set to "ethernet-phy-package" and define "global-phys" and "#global-phy-cells" respectively to a list of phandle to the global phy to define for the PHY package and 0 for cells as the phandle won't take any args.
With this defined, the generic PHY probe will join each PHY in this dedicated node to the package.
PHY driver MUST set the required global PHY count in .phy_package_global_phy_num to correctly verify that DT define the correct number of phandle to the required global PHY.
mdio_bus.c and of_mdio.c is updated to now support and parse also PHY package subnote that have the compatible "phy-package".
--- drivers/net/mdio/of_mdio.c | 60 ++++++++++++++++++++++----------- drivers/net/phy/mdio_bus.c | 33 ++++++++++++++----- drivers/net/phy/phy_device.c | 64 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 5 +++ 4 files changed, 135 insertions(+), 27 deletions(-)
drivers/net/mdio/of_mdio.c +41 -19
@@ -139,6 +139,44 @@ bool of_mdiobus_child_is_phy(struct device_node *child) }EXPORT_SYMBOL (of_mdiobus_child_is_phy); +static int __of_mdiobus_parse_phys (struct mii_bus *mdio,struct device_node *np, +bool *scanphys) +{ +struct device_node *child; +int addr, rc; + +/* Loop over the child nodes and register a phy_device for each phy */ +for_each_available_child_of_node (np, child) { +if (of_device_is_compatible (child,"ethernet-phy-package" )) { + rc =__of_mdiobus_parse_phys (mdio, child, scanphys); +if (rc && rc != -ENODEV ) +return rc; + +continue ; + } + + addr =of_mdio_parse_addr (&mdio->dev, child); +if (addr <0 ) { + *scanphys = true; +continue ; + } + +if (of_mdiobus_child_is_phy (child)) + rc =of_mdiobus_register_phy (mdio, child, addr); +else + rc =of_mdiobus_register_device (mdio, child, addr); + +if (rc == -ENODEV ) +dev_err (&mdio->dev, +"MDIO device at address %d is missing.\n" , + addr); +else if (rc) +return rc; + } + +return 0 ; +} +/** * __of_mdiobus_register - Register mii_bus and create PHYs from the device tree * @mdio: pointer to mii_bus structure
@@ -180,25 +218,9 @@ int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,return rc;/* Loop over the child nodes and register a phy_device for each phy */ -for_each_available_child_of_node (np, child) { - addr =of_mdio_parse_addr (&mdio->dev, child); -if (addr <0 ) { - scanphys = true; -continue ; - } - -if (of_mdiobus_child_is_phy (child)) - rc =of_mdiobus_register_phy (mdio, child, addr); -else - rc =of_mdiobus_register_device (mdio, child, addr); - -if (rc == -ENODEV ) -dev_err (&mdio->dev, -"MDIO device at address %d is missing.\n" , - addr); -else if (rc) - goto unregister; - } + rc =__of_mdiobus_parse_phys (mdio, np, &scanphys); +if (rc) + goto unregister;if (!scanphys)return 0 ;
drivers/net/phy/mdio_bus.c +25 -8
@@ -455,19 +455,23 @@ EXPORT_SYMBOL(of_mdio_find_bus);* found, set the of_node pointer for the mdio device. This allows * auto-probed phy devices to be supplied with information passed in * via DT. +* If a PHY package is found, PHY is searched also there. */ -static void of_mdiobus_link_mdiodev (struct mii_bus *bus, -struct mdio_device *mdiodev) +static int of_mdiobus_find_phy (struct device *dev,struct mdio_device *mdiodev, +struct device_node *np) { -struct device *dev = &mdiodev->dev;struct device_node *child; -if (dev->of_node || !bus->dev.of_node) -return ; - -for_each_available_child_of_node (bus->dev.of_node, child) { +for_each_available_child_of_node (np, child) {int addr; +if (of_device_is_compatible (child,"ethernet-phy-package" )) { +if (!of_mdiobus_find_phy (dev, mdiodev, child)) +return 0 ; + +continue ; + } + addr =of_mdio_parse_addr (dev, child);if (addr <0 )continue ;
@@ -477,9 +481,22 @@ static void of_mdiobus_link_mdiodev(struct mii_bus *bus,/* The refcount on "child" is passed to the mdio * device. Do _not_ use of_node_put(child) here. */ - return; + return 0; } } + +return -ENODEV ; +} + +static void of_mdiobus_link_mdiodev (struct mii_bus *bus, +struct mdio_device *mdiodev) +{ +struct device *dev = &mdiodev->dev; + +if (dev->of_node || !bus->dev.of_node) +return ; + +of_mdiobus_find_phy (dev, mdiodev, bus->dev.of_node); }#else /* !IS_ENABLED(CONFIG_OF_MDIO) */ static inline void of_mdiobus_link_mdiodev(struct mii_bus *mdio,
drivers/net/phy/phy_device.c +64 -0
76 lines not on this page · raw message
include/linux/phy.h +5 -0
@@ -339,6 +339,8 @@ struct mdio_bus_stats {* phy_package_leave(). */ struct phy_package_shared { +/* With PHY package defined in DT this points to the PHY package node */ +struct device_node *np;/* addrs list pointer */ /* note that this pointer is shared between different phydevs. * It is allocated and freed automatically by phy_package_join() and
@@ -888,6 +890,8 @@ struct phy_led {* @flags: A bitfield defining certain other features this PHY * supports (like interrupts) * @driver_data: Static driver data +* @phy_package_global_phy_num: Num of the required global phy +* for PHY package global configuration. * * All functions are optional. If config_aneg or read_status * are not implemented, the phy core uses the genphy versions.
@@ -905,6 +909,7 @@ struct phy_driver {const unsigned long *const features;u32 flags;const void *driver_data; +unsigned int phy_package_global_phy_num;/** * @soft_reset: Called to issue a PHY software reset
Signature · 1 line
2.40.1
Simon Horman
reviewerRe: [net-next RFC PATCH 04/14] net: phy: add initial support for PHY package in DT
Quoted 23 lines · Christian Marangi
Add initial support for PHY package in DT.
Make it easier to define PHY package and describe the global PHY directly in DT by refereincing them by phandles instead of custom functions in each PHY driver.
Each PHY in a package needs to be defined in a dedicated node in the mdio node. This dedicated node needs to have the compatible set to "ethernet-phy-package" and define "global-phys" and "#global-phy-cells" respectively to a list of phandle to the global phy to define for the PHY package and 0 for cells as the phandle won't take any args.
With this defined, the generic PHY probe will join each PHY in this dedicated node to the package.
PHY driver MUST set the required global PHY count in .phy_package_global_phy_num to correctly verify that DT define the correct number of phandle to the required global PHY.
mdio_bus.candof_mdio.cis updated to now support and parse also PHY package subnote that have the compatible "phy-package".Signed-off-by Christian Marangi <[email protected]>
...
include/linux/phy.h struct mdio_bus_stats { · line 346
Quoted 13 lines
include/linux/phy.h +2
-0@@ -339,6 +339,8 @@ struct mdio_bus_stats {* phy_package_leave(). */ struct phy_package_shared { +/* With PHY package defined in DT this points to the PHY package node */ +struct device_node *np;/* addrs list pointer */ /* note that this pointer is shared between different phydevs. * It is allocated and freed automatically by phy_package_join() and
Hi Christian,
a minor nit from my side: please add np to the kernel doc for struct phy_package_shared.
Quoted 9 lines
include/linux/phy.h +2
-0@@ -888,6 +890,8 @@ struct phy_led {* @flags: A bitfield defining certain other features this PHY * supports (like interrupts) * @driver_data: Static driver data +* @phy_package_global_phy_num: Num of the required global phy +* for PHY package global configuration. * * All functions are optional. If config_aneg or read_status * are not implemented, the phy core uses the genphy versions.
...
Simon Horman
reviewerRe: [net-next RFC PATCH 04/14] net: phy: add initial support for PHY package in DT
In reply to Christian MarangiQuoted 15 lines · Christian Marangi
Add initial support for PHY package in DT.
Make it easier to define PHY package and describe the global PHY directly in DT by refereincing them by phandles instead of custom functions in each PHY driver.
Each PHY in a package needs to be defined in a dedicated node in the mdio node. This dedicated node needs to have the compatible set to "ethernet-phy-package" and define "global-phys" and "#global-phy-cells" respectively to a list of phandle to the global phy to define for the PHY package and 0 for cells as the phandle won't take any args.
With this defined, the generic PHY probe will join each PHY in this dedicated node to the package.
Quoted 8 lines
PHY driver MUST set the required global PHY count in .phy_package_global_phy_num to correctly verify that DT define the correct number of phandle to the required global PHY.
mdio_bus.candof_mdio.cis updated to now support and parse also PHY package subnote that have the compatible "phy-package".Signed-off-by Christian Marangi <[email protected]>
Hi Christian,
I was a little hasty in hitting send on my previous message. Please find some more minor feedback from my side below.
...
Quoted 10 lines
drivers/net/mdio/of_mdio.c +2
-0@@ -139,6 +139,44 @@ bool of_mdiobus_child_is_phy(struct device_node *child) }EXPORT_SYMBOL (of_mdiobus_child_is_phy); +static int __of_mdiobus_parse_phys (struct mii_bus *mdio,struct device_node *np, +bool *scanphys)
drivers/net/mdio/of_mdio.c bool of_mdiobus_child_is_phy(struct device_node *child) · line 153
Quoted 10 lines
drivers/net/mdio/of_mdio.c +10
-0+{ +struct device_node *child; +int addr, rc; + +/* Loop over the child nodes and register a phy_device for each phy */ +for_each_available_child_of_node (np, child) { +if (of_device_is_compatible (child,"ethernet-phy-package" )) { + rc =__of_mdiobus_parse_phys (mdio, child, scanphys); +if (rc && rc != -ENODEV ) +return rc;
for_each_available_child_of_node() makes calls to of_node_get() and of_node_put(), so when jumping out of a loop it is necessary to call of_node_put(), in this case of_node_put(child).
As flagged by Coccinelle.
Also flagged in of_mdiobus_find_phy() both before and after this patch.
Quoted 45 lines
drivers/net/mdio/of_mdio.c +26
-12+ +continue ; + } + + addr =of_mdio_parse_addr (&mdio->dev, child); +if (addr <0 ) { + *scanphys = true; +continue ; + } + +if (of_mdiobus_child_is_phy (child)) + rc =of_mdiobus_register_phy (mdio, child, addr); +else + rc =of_mdiobus_register_device (mdio, child, addr); + +if (rc == -ENODEV ) +dev_err (&mdio->dev, +"MDIO device at address %d is missing.\n" , + addr); +else if (rc) +return rc; + } + +return 0 ; +} +/** * __of_mdiobus_register - Register mii_bus and create PHYs from the device tree * @mdio: pointer to mii_bus structure @@ -180,25 +218,9 @@ int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,return rc;/* Loop over the child nodes and register a phy_device for each phy */ -for_each_available_child_of_node (np, child) { - addr =of_mdio_parse_addr (&mdio->dev, child); -if (addr <0 ) { - scanphys = true; -continue ; - } - -if (of_mdiobus_child_is_phy (child)) - rc =of_mdiobus_register_phy (mdio, child, addr); -else - rc =of_mdiobus_register_device (mdio, child, addr); -
drivers/net/mdio/of_mdio.c int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np, · line 223
Quoted 10 lines
drivers/net/mdio/of_mdio.c +3
-7-if (rc == -ENODEV ) -dev_err (&mdio->dev, -"MDIO device at address %d is missing.\n" , - addr); -else if (rc) - goto unregister; - } + rc =__of_mdiobus_parse_phys (mdio, np, &scanphys); +if (rc) + goto unregister;
Jumping to unregister will call of_node_put(child), however child appears to be uninitialised here.
Flagged by clang-16 W=1 build, and Smatch.
Quoted 3 lines
drivers/net/mdio/of_mdio.c +0
-0if (!scanphys)return 0 ;
...
Re: [net-next RFC PATCH 04/14] net: phy: add initial support for PHY package in DT
Quoted 23 lines · Simon Horman
Quoted 22 lines · Christian Marangi
Add initial support for PHY package in DT.
Make it easier to define PHY package and describe the global PHY directly in DT by refereincing them by phandles instead of custom functions in each PHY driver.
Each PHY in a package needs to be defined in a dedicated node in the mdio node. This dedicated node needs to have the compatible set to "ethernet-phy-package" and define "global-phys" and "#global-phy-cells" respectively to a list of phandle to the global phy to define for the PHY package and 0 for cells as the phandle won't take any args.
With this defined, the generic PHY probe will join each PHY in this dedicated node to the package.
PHY driver MUST set the required global PHY count in .phy_package_global_phy_num to correctly verify that DT define the correct number of phandle to the required global PHY.
mdio_bus.candof_mdio.cis updated to now support and parse also PHY package subnote that have the compatible "phy-package".
Quoted 7 lines
Quoted 1 line
Signed-off-by Christian Marangi <[email protected]>Hi Christian,
I was a little hasty in hitting send on my previous message. Please find some more minor feedback from my side below.
Thanks a lot for the initial review and sorry for the various warning you had to write about it. I know this was a new concept and that I had to discuss a lot about the DT structure so I was a bit relaxed in releasing OF node. Will handle all of them in v2. Again thanks!
Quoted 97 lines
...
Quoted 10 lines
drivers/net/mdio/of_mdio.c +2
-0@@ -139,6 +139,44 @@ bool of_mdiobus_child_is_phy(struct device_node *child) }EXPORT_SYMBOL (of_mdiobus_child_is_phy); +static int __of_mdiobus_parse_phys (struct mii_bus *mdio,struct device_node *np, +bool *scanphys)drivers/net/mdio/of_mdio.c bool of_mdiobus_child_is_phy(struct device_node *child) · line 153
Quoted 10 lines
drivers/net/mdio/of_mdio.c +10
-0+{ +struct device_node *child; +int addr, rc; + +/* Loop over the child nodes and register a phy_device for each phy */ +for_each_available_child_of_node (np, child) { +if (of_device_is_compatible (child,"ethernet-phy-package" )) { + rc =__of_mdiobus_parse_phys (mdio, child, scanphys); +if (rc && rc != -ENODEV ) +return rc;
for_each_available_child_of_node()makes calls toof_node_get()andof_node_put(), so when jumping out of a loop it is necessary to callof_node_put(), in this caseof_node_put(child).As flagged by Coccinelle.
Also flagged in
of_mdiobus_find_phy()both before and after this patch.Quoted 45 lines
drivers/net/mdio/of_mdio.c +26
-12+ +continue ; + } + + addr =of_mdio_parse_addr (&mdio->dev, child); +if (addr <0 ) { + *scanphys = true; +continue ; + } + +if (of_mdiobus_child_is_phy (child)) + rc =of_mdiobus_register_phy (mdio, child, addr); +else + rc =of_mdiobus_register_device (mdio, child, addr); + +if (rc == -ENODEV ) +dev_err (&mdio->dev, +"MDIO device at address %d is missing.\n" , + addr); +else if (rc) +return rc; + } + +return 0 ; +} +/** * __of_mdiobus_register - Register mii_bus and create PHYs from the device tree * @mdio: pointer to mii_bus structure @@ -180,25 +218,9 @@ int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,return rc;/* Loop over the child nodes and register a phy_device for each phy */ -for_each_available_child_of_node (np, child) { - addr =of_mdio_parse_addr (&mdio->dev, child); -if (addr <0 ) { - scanphys = true; -continue ; - } - -if (of_mdiobus_child_is_phy (child)) - rc =of_mdiobus_register_phy (mdio, child, addr); -else - rc =of_mdiobus_register_device (mdio, child, addr); -drivers/net/mdio/of_mdio.c int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np, · line 223
Quoted 10 lines
drivers/net/mdio/of_mdio.c +3
-7-if (rc == -ENODEV ) -dev_err (&mdio->dev, -"MDIO device at address %d is missing.\n" , - addr); -else if (rc) - goto unregister; - } + rc =__of_mdiobus_parse_phys (mdio, np, &scanphys); +if (rc) + goto unregister;Jumping to unregister will call
of_node_put(child), however child appears to be uninitialised here.Flagged by clang-16 W=1 build, and Smatch.
Quoted 3 lines
drivers/net/mdio/of_mdio.c +0
-0if (!scanphys)return 0 ;...
Signature · 1 line
Ansuel
Simon Horman
reviewerRe: [net-next RFC PATCH 04/14] net: phy: add initial support for PHY package in DT
On Wed, Nov 22, 2023 at 07:15:06PM +0100, Christian Marangi wrote:
...
Quoted 10 lines
Quoted 5 lines
Hi Christian,
I was a little hasty in hitting send on my previous message. Please find some more minor feedback from my side below.
Thanks a lot for the initial review and sorry for the various warning you had to write about it. I know this was a new concept and that I had to discuss a lot about the DT structure so I was a bit relaxed in releasing OF node. Will handle all of them in v2. Again thanks!
No problem. I'm never sure if this kind of feedback is appropriate for and RFC or not. And perhaps in this case it would have been better to wait for at least one more revision. So sorry for the noise at this stage of the patch-set's development.
...
kernel test robot
build botRe: [net-next RFC PATCH 04/14] net: phy: add initial support for PHY package in DT
In reply to Christian Marangikernel test robot noticed the following build warnings:
Hi Christian,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-extend-PHY-package-API-to-support-multiple-global-address/20231120-220405 base: net-next/main patch link: https://lore.kernel.org/r/20231120135041.15259-5-ansuelsmth%40gmail.com patch subject: [net-next RFC PATCH 04/14] net: phy: add initial support for PHY package in DT config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20231122/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231122/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/net/mdio/of_mdio.c:222:6: warning: variable 'child' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (rc)
^~
drivers/net/mdio/of_mdio.c:260:14: note: uninitialized use occurs here
of_node_put(child);
^~~~~
drivers/net/mdio/of_mdio.c:222:2: note: remove the 'if' if its condition is always false
if (rc)
^~~~~~~
drivers/net/mdio/of_mdio.c:192:27: note: initialize the variable 'child' to silence this warning
struct device_node *child;
^
= NULL1 warning generated.
vim +222 drivers/net/mdio/of_mdio.c
179
180 /**
181 * __of_mdiobus_register - Register mii_bus and create PHYs from the device tree
182 * @mdio: pointer to mii_bus structure
183 * @np: pointer to device_node of MDIO bus.
184 * @owner: module owning the @mdio object.
185 *
186 * This function registers the mii_bus structure and registers a phy_device
187 * for each child node of @np.
188 */
189 int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,
190 struct module *owner)
191 {
192 struct device_node *child;
193 bool scanphys = false;
194 int addr, rc;
195
196 if (!np)
197 return __mdiobus_register(mdio, owner);
198
199 /* Do not continue if the node is disabled */
200 if (!of_device_is_available(np))
201 return -ENODEV;
202
203 /* Mask out all PHYs from auto probing. Instead the PHYs listed in
204 * the device tree are populated after the bus has been registered */
205 mdio->phy_mask = ~0;
206
207 device_set_node(&mdio->dev, of_fwnode_handle(np));
208
209 /* Get bus level PHY reset GPIO details */
210 mdio->reset_delay_us = DEFAULT_GPIO_RESET_DELAY;
211 of_property_read_u32(np, "reset-delay-us", &mdio->reset_delay_us);
212 mdio->reset_post_delay_us = 0;
213 of_property_read_u32(np, "reset-post-delay-us", &mdio->reset_post_delay_us);
214
215 /* Register the MDIO bus */
216 rc = __mdiobus_register(mdio, owner);
217 if (rc)
218 return rc;
219
220 /* Loop over the child nodes and register a phy_device for each phy */
221 rc = __of_mdiobus_parse_phys(mdio, np, &scanphys);
> 222 if (rc)
223 goto unregister;
224
225 if (!scanphys)
226 return 0;
227
228 /* auto scan for PHYs with empty reg property */
229 for_each_available_child_of_node(np, child) {
230 /* Skip PHYs with reg property set */
231 if (of_property_present(child, "reg"))
232 continue;
233
234 for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
235 /* skip already registered PHYs */
236 if (mdiobus_is_registered_device(mdio, addr))
237 continue;
238
239 /* be noisy to encourage people to set reg property */
240 dev_info(&mdio->dev, "scan phy %pOFn at address %i\n",
241 child, addr);
242
243 if (of_mdiobus_child_is_phy(child)) {
244 /* -ENODEV is the return code that PHYLIB has
245 * standardized on to indicate that bus
246 * scanning should continue.
247 */
248 rc = of_mdiobus_register_phy(mdio, child, addr);
249 if (!rc)
250 break;
251 if (rc != -ENODEV)
252 goto unregister;
253 }
254 }
255 }
256
257 return 0;
258
259 unregister:
260 of_node_put(child);
261 mdiobus_unregister(mdio);
262 return rc;
263 }
264 EXPORT_SYMBOL(__of_mdiobus_register);
265
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
RFC PATCH 5/14 net: phy: add support for named global PHY in DT PHY package
In reply to Christian MarangiAdd support for named global PHY in DT PHY package definition. A phy-package node can provide the property "global-phy-names" to provide named global PHY to correctly reference the phandle defined in the global-phys list.
Each PHY driver has to define the .phy_package_global_phy_names list to verify correct order of named PHY phandle defined in DT with the expected order in the PHY driver.
If the list is not defined or "global-phy-names" is not defined in DT, global phy addresses are insered in order defined in the "global-phys" property.
--- drivers/net/phy/phy_device.c | 13 +++++++++++++ include/linux/phy.h | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-)
drivers/net/phy/phy_device.c +13 -0
@@ -3198,6 +3198,7 @@ static int of_phy_package(struct phy_device *phydev)struct device_node *node = phydev->mdio.dev.of_node;struct of_phandle_args phy_phandle;struct device_node *package_node; +const char *global_phy_name;int i, global_phys_num, ret;int *global_phy_addrs;
@@ -3236,6 +3237,18 @@ static int of_phy_package(struct phy_device *phydev)if (ret) goto exit; + ret =of_property_read_string_index (package_node,"global-phy-names" , + i, &global_phy_name); +if (!ret && phydev->drv->phy_package_global_phy_names) { +const char *name; + + name = phydev->drv->phy_package_global_phy_names[i]; +if (strcmp (global_phy_name, name)) { + ret = -EINVAL ; + goto exit; + } + } + global_phy_addrs[i] = addr; }
include/linux/phy.h +5 -1
@@ -892,6 +892,10 @@ struct phy_led {* @driver_data: Static driver data * @phy_package_global_phy_num: Num of the required global phy * for PHY package global configuration. +* @phy_package_global_phy_names: List of global PHY names used +* for PHY package global init. If defined, list is compared +* with DT values to match correct PHY phandle order. List +* last element MUST BE an empty string. * * All functions are optional. If config_aneg or read_status * are not implemented, the phy core uses the genphy versions.
@@ -910,6 +914,7 @@ struct phy_driver {u32 flags;const void *driver_data;unsigned int phy_package_global_phy_num; +const char *const *phy_package_global_phy_names;/** * @soft_reset: Called to issue a PHY software reset
@@ -1154,7 +1159,6 @@ struct phy_driver {*/ int (*led_hw_control_get)(struct phy_device *dev,u8 index,unsigned long *rules); - };#define to_phy_driver (d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv)
Signature · 1 line
2.40.1
RFC PATCH 6/14 net: phy: add support for shared priv data size for PHY package in DT
In reply to Christian MarangiAdd support for defining shared data size for PHY package defined in DT.
A PHY driver has to define the value .phy_package_priv_data_size to make the generic OF PHY package function alloc priv data in the shared struct for the PHY package.
--- drivers/net/phy/phy_device.c | 7 ++++++- include/linux/phy.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/net/phy/phy_device.c +6 -1
@@ -3200,6 +3200,7 @@ static int of_phy_package(struct phy_device *phydev)struct device_node *package_node;const char *global_phy_name;int i, global_phys_num, ret; +int shared_priv_data_size;int *global_phy_addrs;if (!node)
@@ -3252,8 +3253,12 @@ static int of_phy_package(struct phy_device *phydev) global_phy_addrs[i] = addr; } + shared_priv_data_size =0 ; +if (phydev->drv->phy_package_priv_data_size) + shared_priv_data_size = phydev->drv->phy_package_priv_data_size; + ret =devm_phy_package_join (&phydev->mdio.dev, phydev, global_phy_addrs, - global_phys_num,0 ); + global_phys_num, shared_priv_data_size);if (ret) goto exit;
include/linux/phy.h +3 -0
@@ -896,6 +896,8 @@ struct phy_led {* for PHY package global init. If defined, list is compared * with DT values to match correct PHY phandle order. List * last element MUST BE an empty string. +* @phy_package_priv_data_size: Size of the priv data to alloc +* for shared struct of PHY package. * * All functions are optional. If config_aneg or read_status * are not implemented, the phy core uses the genphy versions.
@@ -915,6 +917,7 @@ struct phy_driver {const void *driver_data;unsigned int phy_package_global_phy_num;const char *const *phy_package_global_phy_names; +unsigned int phy_package_priv_data_size;/** * @soft_reset: Called to issue a PHY software reset
Signature · 1 line
2.40.1
RFC PATCH 7/14 net: phy: add support for driver specific PHY package probe/config
In reply to Christian MarangiAdd PHY driver specific function to probe and configure PHY package. These function are run only once before the PHY probe and config_init.
They are used in conjunction with DT PHY package define for basic PHY package implementation to setup and probe PHY package with simple functions directly defined in the PHY driver struct.
--- drivers/net/phy/phy_device.c | 14 ++++++++++++++ include/linux/phy.h | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+)
drivers/net/phy/phy_device.c +14 -0
@@ -1246,6 +1246,13 @@ int phy_init_hw(struct phy_device *phydev)if (ret <0 )return ret; +if (phydev->drv->phy_package_config_init_once && +phy_package_init_once (phydev)) { + ret = phydev->drv->phy_package_config_init_once (phydev); +if (ret <0 ) +return ret; + } +if (phydev->drv->config_init) { ret = phydev->drv->config_init (phydev);if (ret <0 )
@@ -3386,6 +3393,13 @@ static int phy_probe(struct device *dev)/* Deassert the reset signal */ phy_device_reset (phydev,0 ); +if (phydev->drv->phy_package_probe_once && +phy_package_probe_once (phydev)) { + err = phydev->drv->phy_package_probe_once (phydev); +if (err) + goto out; + } +if (phydev->drv->probe) { err = phydev->drv->probe (phydev);if (err)
include/linux/phy.h +21 -0
@@ -924,12 +924,33 @@ struct phy_driver {*/ int (*soft_reset)(struct phy_device *phydev); +/** +* @phy_package_config_init_once: Driver specific PHY package +* config init call +* @def: PHY device to use to probe PHY package +* +* Called to initialize the PHY package, including after +* a reset. +* Called BEFORE PHY config_init. +*/ +int (*phy_package_config_init_once)(struct phy_device *dev); +/** * @config_init: Called to initialize the PHY, * including after a reset */ int (*config_init)(struct phy_device *phydev); +/** +* @phy_package_probe_once: Driver specific PHY package probe +* @def: PHY device to use to probe PHY package +* +* Called during discovery once per PHY package. Used to set +* up device-specific PHY package structures, if any. +* Called BEFORE PHY probe. +*/ +int (*phy_package_probe_once)(struct phy_device *dev); +/** * @probe: Called during discovery. Used to set * up device-specific structures, if any
Signature · 1 line
2.40.1
RFC PATCH 8/14 net: phy: add support for PHY package interface mode
In reply to Christian MarangiSome PHY in PHY package supports running only at a specific mode for each PHY in the package. Add support for enforcing this special thing a verify consistency with the requested mode to prevent misconfiguration.
To set the PHY package mode, simply set "phy-mode" in the phy-package node. Each PHY on init will verify if the requested mode match the one set for the PHY package and will return -EINVAL if this is not true.
If PHY package doesn't specify any mode, it's assumed that PHY in the package doesn't have such limitation.
--- drivers/net/phy/phy_device.c | 37 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 6 ++++++ 2 files changed, 43 insertions(+)
drivers/net/phy/phy_device.c +37 -0
@@ -25,6 +25,7 @@#include <linux/mm.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_net.h> #include <linux/netdevice.h> #include <linux/phy.h> #include <linux/phylib_stubs.h>
@@ -1225,8 +1226,17 @@ static int phy_poll_reset(struct phy_device *phydev)int phy_init_hw (struct phy_device *phydev) { +phy_interface_t package_interface;int ret =0 ; +/* Validate we are requesting consistent mode if we +* are in a PHY package and the PHY package requires a +* specific mode. +*/ + ret =phy_package_get_mode (phydev, &package_interface); +if (!ret && phydev->interface != package_interface) +return -EINVAL ; +/* Deassert the reset signal */ phy_device_reset (phydev,0 );
@@ -1776,6 +1786,32 @@ void phy_package_leave(struct phy_device *phydev) }EXPORT_SYMBOL_GPL (phy_package_leave); +/** +* phy_package_get_mode - get PHY interface mode for PHY package +* @phydev: target phy_device struct +* @interface: phy_interface_t pointer where to save the PHY package mode +* +* Gets PHY interface mode for the shared data of the PHY package. +* Returns 0 and updates @interface with the PHY package value, or -ENODEV +* if PHY is not in PHY package or -EINVAL if a PHY package interface mode +* is not set. +*/ +int phy_package_get_mode (struct phy_device *phydev,phy_interface_t *interface) +{ +struct phy_package_shared *shared = phydev->shared; + +if (!shared) +return -ENODEV ; + +if (shared->package_interface ==PHY_INTERFACE_MODE_NA ) +return -EINVAL ; + + *interface = shared->package_interface; + +return 0 ; +} +EXPORT_SYMBOL_GPL (phy_package_get_mode); +static void devm_phy_package_leave (struct device *dev,void *res) {phy_package_leave (*(struct phy_device **)res);
@@ -3270,6 +3306,7 @@ static int of_phy_package(struct phy_device *phydev) goto exit; phydev->shared->np = package_node; +of_get_phy_mode (package_node, &phydev->shared->package_interface); exit:kfree (global_phy_addrs);
include/linux/phy.h +6 -0
@@ -341,6 +341,11 @@ struct mdio_bus_stats {struct phy_package_shared {/* With PHY package defined in DT this points to the PHY package node */ struct device_node *np; +/* PHY package interface +* If defined, each PHY of the package MUST have the interface +* set to the PHY package. +*/ +phy_interface_t package_interface;/* addrs list pointer */ /* note that this pointer is shared between different phydevs. * It is allocated and freed automatically by phy_package_join() and
@@ -2014,6 +2019,7 @@ int phy_ethtool_nway_reset(struct net_device *ndev);int phy_package_join (struct phy_device *phydev,int *addrs,size_t addrs_num,size_t priv_size);void phy_package_leave (struct phy_device *phydev); +int phy_package_get_mode (struct phy_device *phydev,phy_interface_t *interface);int devm_phy_package_join (struct device *dev,struct phy_device *phydev,int *addrs,size_t addrs_num,size_t priv_size);
Signature · 1 line
2.40.1
RFC PATCH 9/14 net: phy: move mmd_phy_indirect to generic header
In reply to Christian MarangiMove mmd_phy_indirect function from phy-core to generic phy.h to permit future usage for PHY package read/write_mmd.
--- drivers/net/phy/phy-core.c | 14 -------------- include/linux/phy.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/net/phy/phy-core.c +0 -14
@@ -526,20 +526,6 @@ int phy_speed_down_core(struct phy_device *phydev)return 0 ; } -static void mmd_phy_indirect (struct mii_bus *bus,int phy_addr,int devad, -u16 regnum) -{ -/* Write the desired MMD Devad */ -__mdiobus_write (bus, phy_addr,MII_MMD_CTRL , devad); - -/* Write the desired MMD register address */ -__mdiobus_write (bus, phy_addr,MII_MMD_DATA , regnum); - -/* Select the Function : DATA with no post increment */ -__mdiobus_write (bus, phy_addr,MII_MMD_CTRL , - devad |MII_MMD_CTRL_NOINCR ); -} -/** * __phy_read_mmd - Convenience function for reading a register * from an MMD on a given PHY.
include/linux/phy.h +14 -0
@@ -1361,6 +1361,20 @@ static inline int __phy_modify_changed(struct phy_device *phydev, u32 regnum, regnum, mask, set); } +static inline void mmd_phy_indirect (struct mii_bus *bus,int phy_addr,int devad, +u16 regnum) +{ +/* Write the desired MMD Devad */ +__mdiobus_write (bus, phy_addr,MII_MMD_CTRL , devad); + +/* Write the desired MMD register address */ +__mdiobus_write (bus, phy_addr,MII_MMD_DATA , regnum); + +/* Select the Function : DATA with no post increment */ +__mdiobus_write (bus, phy_addr,MII_MMD_CTRL , + devad |MII_MMD_CTRL_NOINCR ); +} +/* * phy_read_mmd - Convenience function for reading a register * from an MMD on a given PHY.
Signature · 1 line
2.40.1
RFC PATCH 10/14 net: phy: add support for PHY package MMD read/write
In reply to Christian MarangiSome PHY in PHY package may require to read/write MMD regs to correctly configure the PHY package.
Add support for these additional required function in both lock and no lock variant.
--- include/linux/phy.h | 72 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+)
include/linux/phy.h +72 -0
@@ -2110,6 +2110,78 @@ static inline int __phy_package_write(struct phy_device *phydev,return __mdiobus_write (phydev->mdio.bus, addr, regnum, val); } +static inline int phy_package_read_mmd (struct phy_device *phydev, +int global_phy_index,int devad,u32 regnum) +{ +struct phy_package_shared *shared = phydev->shared; +struct mii_bus *bus = phydev->mdio.bus; +int addr, val; + +if (!shared || global_phy_index > shared->addrs_num -1 ) +return -EIO ; + + addr = shared->addrs[global_phy_index]; + +phy_lock_mdio_bus (phydev); +mmd_phy_indirect (bus, addr, devad, regnum); + val =__mdiobus_read (bus, addr,MII_MMD_DATA ); +phy_unlock_mdio_bus (phydev); + +return val; +} + +static inline int __phy_package_read_mmd (struct phy_device *phydev, +int global_phy_index,int devad,u32 regnum) +{ +struct phy_package_shared *shared = phydev->shared; +struct mii_bus *bus = phydev->mdio.bus; +int addr; + +if (!shared || global_phy_index > shared->addrs_num -1 ) +return -EIO ; + + addr = shared->addrs[global_phy_index]; +mmd_phy_indirect (bus, addr, devad, regnum); +return __mdiobus_read (bus, addr,MII_MMD_DATA ); +} + +static inline int phy_package_write_mmd (struct phy_device *phydev, +int global_phy_index,int devad, +u32 regnum,u16 val) +{ +struct phy_package_shared *shared = phydev->shared; +struct mii_bus *bus = phydev->mdio.bus; +int addr, ret; + +if (!shared || global_phy_index > shared->addrs_num -1 ) +return -EIO ; + + addr = shared->addrs[global_phy_index]; + +phy_lock_mdio_bus (phydev); +mmd_phy_indirect (bus, addr, devad, regnum); + ret =__mdiobus_write (bus, addr,MII_MMD_DATA , val); +phy_unlock_mdio_bus (phydev); + +return ret; +} + +static inline int __phy_package_write_mmd (struct phy_device *phydev, +int global_phy_index,int devad, +u32 regnum,u16 val) +{ +struct phy_package_shared *shared = phydev->shared; +struct mii_bus *bus = phydev->mdio.bus; +int addr; + +if (!shared || global_phy_index > shared->addrs_num -1 ) +return -EIO ; + + addr = shared->addrs[global_phy_index]; +mmd_phy_indirect (bus, addr, devad, regnum); +return __mdiobus_write (bus, addr,MII_MMD_DATA , val); +} +static inline bool __phy_package_set_once (struct phy_device *phydev,unsigned int b) {
Signature · 1 line
2.40.1
RFC PATCH 11/14 dt-bindings: net: add QCA807x PHY defines
In reply to Christian MarangiFrom: Robert Marko <[email protected]>
Add DT bindings defined for Qualcomm QCA807x PHY series related to calibration and DAC settings.
--- include/dt-bindings/net/qcom-qca807x.h | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/dt-bindings/net/qcom-qca807x.h
include/dt-bindings/net/qcom-qca807x.h new file +45 -0
@@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* +* Device Tree constants for the Qualcomm QCA807X PHYs +*/ + +#ifndef _DT_BINDINGS_QCOM_QCA807X_H +#define _DT_BINDINGS_QCOM_QCA807X_H + +#define PSGMII_QSGMII_TX_DRIVER_140MV 0 +#define PSGMII_QSGMII_TX_DRIVER_160MV 1 +#define PSGMII_QSGMII_TX_DRIVER_180MV 2 +#define PSGMII_QSGMII_TX_DRIVER_200MV 3 +#define PSGMII_QSGMII_TX_DRIVER_220MV 4 +#define PSGMII_QSGMII_TX_DRIVER_240MV 5 +#define PSGMII_QSGMII_TX_DRIVER_260MV 6 +#define PSGMII_QSGMII_TX_DRIVER_280MV 7 +#define PSGMII_QSGMII_TX_DRIVER_300MV 8 +#define PSGMII_QSGMII_TX_DRIVER_320MV 9 +#define PSGMII_QSGMII_TX_DRIVER_400MV 10 +#define PSGMII_QSGMII_TX_DRIVER_500MV 11 +/* Default value */ +#define PSGMII_QSGMII_TX_DRIVER_600MV 12 + +/* Full amplitude, full bias current */ +#define QCA807X_CONTROL_DAC_FULL_VOLT_BIAS 0 +/* Amplitude follow DSP (amplitude is adjusted based on cable length), half bias current */ +#define QCA807X_CONTROL_DAC_DSP_VOLT_HALF_BIAS 1 +/* Full amplitude, bias current follow DSP (bias current is adjusted based on cable length) */ +#define QCA807X_CONTROL_DAC_FULL_VOLT_DSP_BIAS 2 +/* Both amplitude and bias current follow DSP */ +#define QCA807X_CONTROL_DAC_DSP_VOLT_BIAS 3 +/* Full amplitude, half bias current */ +#define QCA807X_CONTROL_DAC_FULL_VOLT_HALF_BIAS 4 +/* Amplitude follow DSP setting; 1/4 bias current when cable<10m, +* otherwise half bias current +*/ +#define QCA807X_CONTROL_DAC_DSP_VOLT_QUARTER_BIAS 5 +/* Full amplitude; same bias current setting with “010” and “011”, +* but half more bias is reduced when cable <10m +*/ +#define QCA807X_CONTROL_DAC_FULL_VOLT_HALF_BIAS_SHORT 6 +/* Amplitude follow DSP; same bias current setting with “110”, default value */ +#define QCA807X_CONTROL_DAC_DSP_VOLT_HALF_BIAS_SHORT 7 + +#endif
Signature · 1 line
2.40.1
Andrew Lunn
maintainerRe: [net-next RFC PATCH 11/14] dt-bindings: net: add QCA807x PHY defines
Quoted 30 lines · Christian Marangi
From: Robert Marko <[email protected]>
Add DT bindings defined for Qualcomm QCA807x PHY series related to calibration and DAC settings.
Signed-off-by Robert Marko <[email protected]>Signed-off-by Christian Marangi <[email protected]>--- include/dt-bindings/net/qcom-qca807x.h | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/dt-bindings/net/qcom-qca807x.hinclude/dt-bindings/net/qcom-qca807x.h new file +12
-0@@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* +* Device Tree constants for the Qualcomm QCA807X PHYs +*/ + +#ifndef _DT_BINDINGS_QCOM_QCA807X_H +#define _DT_BINDINGS_QCOM_QCA807X_H + +#define PSGMII_QSGMII_TX_DRIVER_140MV 0 +#define PSGMII_QSGMII_TX_DRIVER_160MV 1 +#define PSGMII_QSGMII_TX_DRIVER_180MV 2 +#define PSGMII_QSGMII_TX_DRIVER_200MV 3
include/dt-bindings/net/qcom-qca807x.h line 22
Quoted 10 lines
include/dt-bindings/net/qcom-qca807x.h new file +10
-0+#define PSGMII_QSGMII_TX_DRIVER_220MV 4 +#define PSGMII_QSGMII_TX_DRIVER_240MV 5 +#define PSGMII_QSGMII_TX_DRIVER_260MV 6 +#define PSGMII_QSGMII_TX_DRIVER_280MV 7 +#define PSGMII_QSGMII_TX_DRIVER_300MV 8 +#define PSGMII_QSGMII_TX_DRIVER_320MV 9 +#define PSGMII_QSGMII_TX_DRIVER_400MV 10 +#define PSGMII_QSGMII_TX_DRIVER_500MV 11 +/* Default value */ +#define PSGMII_QSGMII_TX_DRIVER_600MV 12
Its not clear what these are used for. I think these are actually package properties, so having the correctly documented in the binding would help a lot understand why we need package properties.
Actually using #define like this is probably wrong. You should just have a u32 tx_driver_mv property, and list [140, 160, 180, 200, ... 600] as valid values. The driver should then convert to whatever value it should write into the register.
Andrew
RFC PATCH 12/14 dt-bindings: net: Document Qcom QCA807x PHY package
In reply to Christian MarangiDocument Qcom QCA807x PHY package.
Qualcomm QCA807X Ethernet PHY is PHY package of 2 or 5 IEEE 802.3 clause 22 compliant 10BASE-Te, 100BASE-TX and 1000BASE-T PHY-s.
Document the required property to make the PHY package correctly configure and work.
--- .../devicetree/bindings/net/qcom,qca807x.yaml | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/qcom,qca807x.yaml
Documentation/devicetree/bindings/net/qcom,qca807x.yaml new file +143 -0
@@ -0,0 +1,143 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/qcom,qca807x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm QCA807X Ethernet PHY + +maintainers: + - Christian Marangi <[email protected]> + - Robert Marko <[email protected]> + +description: | + Qualcomm QCA807X Ethernet PHY is PHY package of 2 or 5 + IEEE 802.3 clause 22 compliant 10BASE-Te, 100BASE-TX and + 1000BASE-T PHY-s. + + They feature 2 SerDes, one for PSGMII or QSGMII connection with + MAC, while second one is SGMII for connection to MAC or fiber. + + Both models have a combo port that supports 1000BASE-X and + 100BASE-FX fiber. + + Each PHY inside of QCA807x series has 4 digitally controlled + output only pins that natively drive LED-s for up to 2 attached + LEDs. Some vendor also use these 4 output for GPIO usage without + attaching LEDs. + + Note that output pins can be set to drive LEDs OR GPIO, mixed + definition are not accepted. + +allOf: + - $ref: ethernet-phy-package.yaml# + +select: + properties: + compatible: + contains: + const: ethernet-phy-package + patternProperties: + ^ethernet-phy(@[a-f0-9]+)?$: + properties: + compatible: + contains: + enum: + - ethernet-phy-id004d.d0b2 + - ethernet-phy-id004d.d0b1 + required: + - compatible + +properties: + global-phys: + maxItems: 2 + + global-phy-names: + items: + - const: combo + - const: pqsgmii + + phy-connection-type: + enum: + - qsgmii + - psgmii + +patternProperties: + ^ethernet-phy(@[a-f0-9]+)?$: + $ref: /schemas/net/ethernet-phy.yaml# + + properties: + gpio-controller: + description: set the output lines as GPIO instead of LEDs + type: boolean + + '#gpio-cells': + description: number of GPIO cells for the PHY + const: 2 + + dependencies: + gpio-controller: ['#gpio-cells'] + + unevaluatedProperties: false + +required: + - compatible + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/leds/common.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy-package { + compatible = "ethernet-phy-package"; + #address-cells = <1>; + #size-cells = <0>; + + global-phys = <&qca8075_4>, <&qca8075_psgmii>; + global-phy-names = "combo", "pqsgmii"; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-id004d.d0b2"; + reg = <1>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-id004d.d0b2"; + reg = <2>; + + gpio-controller; + #gpio-cells = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-id004d.d0b2"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-id004d.d0b2"; + reg = <4>; + }; + + qca8075_pqsgmii: ethernet-phy@5 { + reg = <5>; + }; + }; + };
Signature · 1 line
2.40.1
Andrew Lunn
maintainerRe: [net-next RFC PATCH 12/14] dt-bindings: net: Document Qcom QCA807x PHY package
Documentation/devicetree/bindings/net/qcom,qca807x.yaml line 19
Quoted 2 lines
Documentation/devicetree/bindings/net/qcom,qca807x.yaml new file +2
-0+ They feature 2 SerDes, one for PSGMII or QSGMII connection with + MAC, while second one is SGMII for connection to MAC or fiber.
Can you connect 1/5 of the PSGMII SERDES to the SGMII SERDES? So making use of the PHY as a media converter to connect to an SFP cage? I assume the SGMII serdes can also do 1000BaseX?
How do you describe what the SGMII SERDES is connected to?
Andrew
Re: [net-next RFC PATCH 12/14] dt-bindings: net: Document Qcom QCA807x PHY package
Quoted 9 lines · Andrew Lunn
Documentation/devicetree/bindings/net/qcom,qca807x.yaml line 19
Quoted 3 lines
Documentation/devicetree/bindings/net/qcom,qca807x.yaml new file +2
-0+ They feature 2 SerDes, one for PSGMII or QSGMII connection with + MAC, while second one is SGMII for connection to MAC or fiber.Can you connect 1/5 of the PSGMII SERDES to the SGMII SERDES? So making use of the PHY as a media converter to connect to an SFP cage? I assume the SGMII serdes can also do 1000BaseX?
How do you describe what the SGMII SERDES is connected to?
Hi Andrew,
I think that the description is confusing.
QCA807x supports 3 different modes:
1. PSGMII (5 copper ports)
2. PSGMII (4 copper ports + 1 combo port)
3. QSGMII+SGMII
So, in case option 2 is selected then the combo port can also be used for 1000Base-X and 100Base-FX modules or copper and it will autodetect the exact media.
This is supported via the SFP op-s and I have been using it without issues for a while.
I have not tested option 3 in combination with SFP to the copper module so I cant
say whether that works.
From what I can gather from the typical usage examples in the datasheet, this QSMII+SGMII
mode is basically intended as a backward compatibility thing as only QCA SoC-s have PSGMII
support so that you could still use SoC-s with QSGMII and SGMII support only.
So there is no way to control the SerDes-es individually, only the global mode can be changed via
the Chip configuration register in the Combo port.
You can see the block diagram of this PHY in this public PDF on page 2[1].
[1] https://content.codico.com/fileadmin/media/download/datasheets/qualcomm/qualcomm_qca8075.pdf
Quoted 3 lines
Andrew
Signature · 7 lines
Robert Marko Staff Embedded Linux Engineer Sartura Ltd. Lendavska ulica 16a 10000 Zagreb, Croatia Email: [email protected] Web: www.sartura.hr
Russell King (Oracle)
reviewerRe: [net-next RFC PATCH 12/14] dt-bindings: net: Document Qcom QCA807x PHY package
In reply to Christian MarangiQuoted 4 lines · Christian Marangi
Documentation/devicetree/bindings/net/qcom,qca807x.yaml new file +4
-0+examples: + - | + #include <dt-bindings/leds/common.h> +
Documentation/devicetree/bindings/net/qcom,qca807x.yaml line 101
Quoted 10 lines
Documentation/devicetree/bindings/net/qcom,qca807x.yaml new file +10
-0+ mdio { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy-package { + compatible = "ethernet-phy-package"; + #address-cells = <1>; + #size-cells = <0>; + + global-phys = <&qca8075_4>, <&qca8075_psgmii>;
Should the second one be &qca8075_pqsgmii ? (note the addition of 'q').
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
RFC PATCH 13/14 net: phy: add Qualcom QCA807x driver
In reply to Christian MarangiFrom: Robert Marko <[email protected]>
This adds driver for the Qualcomm QCA8072 and QCA8075 PHY-s.
They are 2 or 5 port IEEE 802.3 clause 22 compliant 10BASE-Te, 100BASE-TX and 1000BASE-T PHY-s.
They feature 2 SerDes, one for PSGMII or QSGMII connection with MAC, while second one is SGMII for connection to MAC or fiber.
Both models have a combo port that supports 1000BASE-X and 100BASE-FX fiber.
Each PHY inside of QCA807x series has 4 digitally controlled output only pins that natively drive LED-s.
But some vendors used these to driver generic LED-s controlled by userspace, so lets enable registering each PHY as GPIO controller and add driver for it.
These are commonly used in Qualcomm IPQ40xx, IPQ60xx and IPQ807x boards.
--- drivers/net/phy/Kconfig | 7 + drivers/net/phy/Makefile | 1 + drivers/net/phy/qca807x.c | 864 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 872 insertions(+) create mode 100644 drivers/net/phy/qca807x.c
drivers/net/phy/Kconfig +7 -0
@@ -325,6 +325,13 @@ config AT803X_PHY Currently supports the AR8030, AR8031, AR8033, AR8035 and internal QCA8337(Internal qca8k PHY) model +config QCA807X_PHY + tristate "Qualcomm QCA807x PHYs" + depends on OF_MDIO + help + Currently supports the Qualcomm QCA8072, QCA8075 and the PSGMII + control PHY. + config QSEMI_PHY tristate "Quality Semiconductor PHYs" help
drivers/net/phy/Makefile +1 -0
@@ -82,6 +82,7 @@ obj-$(CONFIG_NCN26000_PHY) += ncn26000.o obj-$(CONFIG_NXP_C45_TJA11XX_PHY) += nxp-c45-tja11xx.o obj-$(CONFIG_NXP_CBTX_PHY) += nxp-cbtx.o obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja11xx.o +obj-$(CONFIG_QCA807X_PHY) += qca807x.o obj-$(CONFIG_QSEMI_PHY) += qsemi.o obj-$(CONFIG_REALTEK_PHY) += realtek.o obj-$(CONFIG_RENESAS_PHY) += uPD60620.o
drivers/net/phy/qca807x.c new file +864 -0
864 lines not on this page · raw message
Signature · 1 line
2.40.1
kernel test robot
build botRe: [net-next RFC PATCH 13/14] net: phy: add Qualcom QCA807x driver
kernel test robot noticed the following build warnings:
Hi Christian,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-extend-PHY-package-API-to-support-multiple-global-address/20231120-220405 base: net-next/main patch link: https://lore.kernel.org/r/20231120135041.15259-14-ansuelsmth%40gmail.com patch subject: [net-next RFC PATCH 13/14] net: phy: add Qualcom QCA807x driver reproduce: (https://download.01.org/0day-ci/archive/20231121/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
versioncheck warnings: (new ones prefixed by >>)
INFO PATH=/opt/cross/clang/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/usr/bin/timeout -k 100 3h /usr/bin/make KCFLAGS= W=1 --keep-going HOSTCC=gcc-12 CC=gcc-12 -j32 KBUILD_MODPOST_WARN=1 ARCH=x86_64 versioncheck find ./* \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o \
-name '*.[hcS]' -type f -print | sort \
| xargs perl -w ./scripts/checkversion.pl
./drivers/accessibility/speakup/genmap.c: 13 linux/version.h not needed.
./drivers/accessibility/speakup/makemapdata.c: 13 linux/version.h not needed.
>> ./drivers/net/phy/qca807x.c: 11 linux/version.h not needed.
./drivers/staging/media/atomisp/include/linux/atomisp.h: 23 linux/version.h not needed. ./samples/bpf/spintest.bpf.c: 8 linux/version.h not needed. ./samples/trace_events/trace_custom_sched.c: 11 linux/version.h not needed. ./sound/soc/codecs/cs42l42.c: 14 linux/version.h not needed. ./tools/lib/bpf/bpf_helpers.h: 403: need linux/version.h ./tools/testing/selftests/bpf/progs/dev_cgroup.c: 9 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/netcnt_prog.c: 3 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/test_map_lock.c: 4 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/test_send_signal_kern.c: 4 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/test_spin_lock.c: 4 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/test_tcp_estats.c: 37 linux/version.h not needed. ./tools/testing/selftests/wireguard/qemu/init.c: 27 linux/version.h not needed.
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [net-next RFC PATCH 13/14] net: phy: add Qualcom QCA807x driver
In reply to Christian Marangikernel test robot noticed the following build warnings:
Hi Christian,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-extend-PHY-package-API-to-support-multiple-global-address/20231120-220405 base: net-next/main patch link: https://lore.kernel.org/r/20231120135041.15259-14-ansuelsmth%40gmail.com patch subject: [net-next RFC PATCH 13/14] net: phy: add Qualcom QCA807x driver config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20231122/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231122/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/net/phy/qca807x.c:342:46: warning: declaration of 'struct gpio_chip' will not be visible outside of this function [-Wvisibility]
static int qca807x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
^
drivers/net/phy/qca807x.c:344:9: error: use of undeclared identifier 'GPIO_LINE_DIRECTION_OUT'
return GPIO_LINE_DIRECTION_OUT;
^
drivers/net/phy/qca807x.c:352:36: warning: declaration of 'struct gpio_chip' will not be visible outside of this function [-Wvisibility]
static int qca807x_gpio_get(struct gpio_chip *gc, unsigned int offset)
^
drivers/net/phy/qca807x.c:354:35: error: call to undeclared function 'gpiochip_get_data'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
^
drivers/net/phy/qca807x.c:354:28: error: incompatible integer to pointer conversion initializing 'struct qca807x_gpio_priv *' with an expression of type 'int' [-Wint-conversion]
struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
^ ~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/qca807x.c:362:37: warning: declaration of 'struct gpio_chip' will not be visible outside of this function [-Wvisibility]
static void qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
^
drivers/net/phy/qca807x.c:364:35: error: call to undeclared function 'gpiochip_get_data'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
^
drivers/net/phy/qca807x.c:364:28: error: incompatible integer to pointer conversion initializing 'struct qca807x_gpio_priv *' with an expression of type 'int' [-Wint-conversion]
struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
^ ~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/qca807x.c:375:40: warning: declaration of 'struct gpio_chip' will not be visible outside of this function [-Wvisibility]
static int qca807x_gpio_dir_out(struct gpio_chip *gc, unsigned int offset, int value)
^
drivers/net/phy/qca807x.c:377:19: error: incompatible pointer types passing 'struct gpio_chip *' to parameter of type 'struct gpio_chip *' [-Werror,-Wincompatible-pointer-types]
qca807x_gpio_set(gc, offset, value);
^~
drivers/net/phy/qca807x.c:362:48: note: passing argument to parameter 'gc' here
static void qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
^
drivers/net/phy/qca807x.c:394:31: error: invalid application of 'sizeof' to an incomplete type 'struct gpio_chip'
gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL);
^~~~~
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:398:4: error: incomplete definition of type 'struct gpio_chip'
gc->label = dev_name(dev);
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:399:4: error: incomplete definition of type 'struct gpio_chip'
gc->base = -1;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:400:4: error: incomplete definition of type 'struct gpio_chip'
gc->ngpio = 2;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:401:4: error: incomplete definition of type 'struct gpio_chip'
gc->parent = dev;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:402:4: error: incomplete definition of type 'struct gpio_chip'
gc->owner = THIS_MODULE;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:403:4: error: incomplete definition of type 'struct gpio_chip'
gc->can_sleep = true;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:404:4: error: incomplete definition of type 'struct gpio_chip'
gc->get_direction = qca807x_gpio_get_direction;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:405:4: error: incomplete definition of type 'struct gpio_chip'
gc->direction_output = qca807x_gpio_dir_out;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:406:4: error: incomplete definition of type 'struct gpio_chip'
gc->get = qca807x_gpio_get;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:407:4: error: incomplete definition of type 'struct gpio_chip'
gc->set = qca807x_gpio_set;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:409:9: error: call to undeclared function 'devm_gpiochip_add_data'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
return devm_gpiochip_add_data(dev, gc, priv);vim +342 drivers/net/phy/qca807x.c
340
341 #ifdef CONFIG_GPIOLIB
> 342 static int qca807x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
343 {
344 return GPIO_LINE_DIRECTION_OUT;
345 }
346
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [net-next RFC PATCH 13/14] net: phy: add Qualcom QCA807x driver
In reply to Christian Marangikernel test robot noticed the following build errors:
Hi Christian,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-extend-PHY-package-API-to-support-multiple-global-address/20231120-220405 base: net-next/main patch link: https://lore.kernel.org/r/20231120135041.15259-14-ansuelsmth%40gmail.com patch subject: [net-next RFC PATCH 13/14] net: phy: add Qualcom QCA807x driver config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20231122/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231122/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/net/phy/qca807x.c:342:46: warning: declaration of 'struct gpio_chip' will not be visible outside of this function [-Wvisibility] static int qca807x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
^
>> drivers/net/phy/qca807x.c:344:9: error: use of undeclared identifier 'GPIO_LINE_DIRECTION_OUT'
return GPIO_LINE_DIRECTION_OUT;
^
drivers/net/phy/qca807x.c:352:36: warning: declaration of 'struct gpio_chip' will not be visible outside of this function [-Wvisibility]
static int qca807x_gpio_get(struct gpio_chip *gc, unsigned int offset)
^
>> drivers/net/phy/qca807x.c:354:35: error: call to undeclared function 'gpiochip_get_data'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
^
>> drivers/net/phy/qca807x.c:354:28: error: incompatible integer to pointer conversion initializing 'struct qca807x_gpio_priv *' with an expression of type 'int' [-Wint-conversion]
struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
^ ~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/qca807x.c:362:37: warning: declaration of 'struct gpio_chip' will not be visible outside of this function [-Wvisibility]
static void qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
^
drivers/net/phy/qca807x.c:364:35: error: call to undeclared function 'gpiochip_get_data'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
^
drivers/net/phy/qca807x.c:364:28: error: incompatible integer to pointer conversion initializing 'struct qca807x_gpio_priv *' with an expression of type 'int' [-Wint-conversion]
struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
^ ~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/qca807x.c:375:40: warning: declaration of 'struct gpio_chip' will not be visible outside of this function [-Wvisibility]
static int qca807x_gpio_dir_out(struct gpio_chip *gc, unsigned int offset, int value)
^
>> drivers/net/phy/qca807x.c:377:19: error: incompatible pointer types passing 'struct gpio_chip *' to parameter of type 'struct gpio_chip *' [-Werror,-Wincompatible-pointer-types]
qca807x_gpio_set(gc, offset, value);
^~
drivers/net/phy/qca807x.c:362:48: note: passing argument to parameter 'gc' here
static void qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
^
>> drivers/net/phy/qca807x.c:394:31: error: invalid application of 'sizeof' to an incomplete type 'struct gpio_chip'
gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL);
^~~~~
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
>> drivers/net/phy/qca807x.c:398:4: error: incomplete definition of type 'struct gpio_chip'
gc->label = dev_name(dev);
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:399:4: error: incomplete definition of type 'struct gpio_chip'
gc->base = -1;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:400:4: error: incomplete definition of type 'struct gpio_chip'
gc->ngpio = 2;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:401:4: error: incomplete definition of type 'struct gpio_chip'
gc->parent = dev;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:402:4: error: incomplete definition of type 'struct gpio_chip'
gc->owner = THIS_MODULE;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:403:4: error: incomplete definition of type 'struct gpio_chip'
gc->can_sleep = true;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:404:4: error: incomplete definition of type 'struct gpio_chip'
gc->get_direction = qca807x_gpio_get_direction;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:405:4: error: incomplete definition of type 'struct gpio_chip'
gc->direction_output = qca807x_gpio_dir_out;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:406:4: error: incomplete definition of type 'struct gpio_chip'
gc->get = qca807x_gpio_get;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
drivers/net/phy/qca807x.c:407:4: error: incomplete definition of type 'struct gpio_chip'
gc->set = qca807x_gpio_set;
~~^
drivers/net/phy/qca807x.c:386:9: note: forward declaration of 'struct gpio_chip'
struct gpio_chip *gc;
^
>> drivers/net/phy/qca807x.c:409:9: error: call to undeclared function 'devm_gpiochip_add_data'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
return devm_gpiochip_add_data(dev, gc, priv);
^
>> drivers/net/phy/qca807x.c:708:36: error: too few arguments to function call, expected 3, have 2
if (of_find_property(node, "leds") &&
~~~~~~~~~~~~~~~~ ^
include/linux/of.h:309:25: note: 'of_find_property' declared here
extern struct property *of_find_property(const struct device_node *np,
^fatal error: too many errors emitted, stopping now [-ferror-limit=] 4 warnings and 20 errors generated.
vim +/GPIO_LINE_DIRECTION_OUT +344 drivers/net/phy/qca807x.c
340
341 #ifdef CONFIG_GPIOLIB
342 static int qca807x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
343 {
> 344 return GPIO_LINE_DIRECTION_OUT;
345 }
346
347 static int qca807x_gpio_get_reg(unsigned int offset)
348 {
349 return QCA807X_MMD7_LED_100N_2 + (offset % 2) * 2;
350 }
351
352 static int qca807x_gpio_get(struct gpio_chip *gc, unsigned int offset)
353 {
> 354 struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
355 int val;
356
357 val = phy_read_mmd(priv->phy, MDIO_MMD_AN, qca807x_gpio_get_reg(offset));
358
359 return FIELD_GET(QCA807X_GPIO_FORCE_MODE_MASK, val);
360 }
361
362 static void qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
363 {
364 struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
365 int val;
366
367 val = phy_read_mmd(priv->phy, MDIO_MMD_AN, qca807x_gpio_get_reg(offset));
368 val &= ~QCA807X_GPIO_FORCE_MODE_MASK;
369 val |= QCA807X_GPIO_FORCE_EN;
370 val |= FIELD_PREP(QCA807X_GPIO_FORCE_MODE_MASK, value);
371
372 phy_write_mmd(priv->phy, MDIO_MMD_AN, qca807x_gpio_get_reg(offset), val);
373 }
374
375 static int qca807x_gpio_dir_out(struct gpio_chip *gc, unsigned int offset, int value)
376 {
> 377 qca807x_gpio_set(gc, offset, value);
378
379 return 0;
380 }
381
382 static int qca807x_gpio(struct phy_device *phydev)
383 {
384 struct device *dev = &phydev->mdio.dev;
385 struct qca807x_gpio_priv *priv;
386 struct gpio_chip *gc;
387
388 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
389 if (!priv)
390 return -ENOMEM;
391
392 priv->phy = phydev;
393
> 394 gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL);
395 if (!gc)
396 return -ENOMEM;
397
> 398 gc->label = dev_name(dev);
399 gc->base = -1;
400 gc->ngpio = 2;
401 gc->parent = dev;
402 gc->owner = THIS_MODULE;
403 gc->can_sleep = true;
404 gc->get_direction = qca807x_gpio_get_direction;
405 gc->direction_output = qca807x_gpio_dir_out;
406 gc->get = qca807x_gpio_get;
407 gc->set = qca807x_gpio_set;
408
> 409 return devm_gpiochip_add_data(dev, gc, priv); 410 }
411 #endif
412
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Andrew Lunn
maintainerRe: [net-next RFC PATCH 13/14] net: phy: add Qualcom QCA807x driver
In reply to Christian MarangiQuoted 13 lines · Christian Marangi
From: Robert Marko <[email protected]>
This adds driver for the Qualcomm QCA8072 and QCA8075 PHY-s.
They are 2 or 5 port IEEE 802.3 clause 22 compliant 10BASE-Te, 100BASE-TX and 1000BASE-T PHY-s.
They feature 2 SerDes, one for PSGMII or QSGMII connection with MAC, while second one is SGMII for connection to MAC or fiber.
Both models have a combo port that supports 1000BASE-X and 100BASE-FX fiber.
Quoted 8 lines
Each PHY inside of QCA807x series has 4 digitally controlled output only pins that natively drive LED-s.
But some vendors used these to driver generic LED-s controlled by userspace, so lets enable registering each PHY as GPIO controller and add driver for it.These are commonly used in Qualcomm IPQ40xx, IPQ60xx and IPQ807x boards.
You need to justification why this is a whole new driver, rather than just extending at803x.c.
I did a few quick checks. The Downshift code is identical, once you take into account the different names. Interrupt handling looks very similar. MDIX looks the same, and Specific status looks similar, etc. There are clear differences, but i think there is enough identical code you should be sharing it.
Andrew
kernel test robot
build botRe: [net-next RFC PATCH 13/14] net: phy: add Qualcom QCA807x driver
In reply to Christian Marangikernel test robot noticed the following build errors:
Hi Christian,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-phy-extend-PHY-package-API-to-support-multiple-global-address/20231120-220405 base: net-next/main patch link: https://lore.kernel.org/r/20231120135041.15259-14-ansuelsmth%40gmail.com patch subject: [net-next RFC PATCH 13/14] net: phy: add Qualcom QCA807x driver config: openrisc-allmodconfig (https://download.01.org/0day-ci/archive/20231124/[email protected]/config) compiler: or1k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231124/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
>> drivers/net/phy/qca807x.c:342:46: warning: 'struct gpio_chip' declared inside parameter list will not be visible outside of this definition or declaration
342 | static int qca807x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
| ^~~~~~~~~
drivers/net/phy/qca807x.c: In function 'qca807x_gpio_get_direction':
>> drivers/net/phy/qca807x.c:344:16: error: 'GPIO_LINE_DIRECTION_OUT' undeclared (first use in this function)
344 | return GPIO_LINE_DIRECTION_OUT;
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/qca807x.c:344:16: note: each undeclared identifier is reported only once for each function it appears in
drivers/net/phy/qca807x.c: At top level:
drivers/net/phy/qca807x.c:352:36: warning: 'struct gpio_chip' declared inside parameter list will not be visible outside of this definition or declaration
352 | static int qca807x_gpio_get(struct gpio_chip *gc, unsigned int offset)
| ^~~~~~~~~
drivers/net/phy/qca807x.c: In function 'qca807x_gpio_get':
>> drivers/net/phy/qca807x.c:354:42: error: implicit declaration of function 'gpiochip_get_data' [-Werror=implicit-function-declaration]
354 | struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
| ^~~~~~~~~~~~~~~~~
>> drivers/net/phy/qca807x.c:354:42: warning: initialization of 'struct qca807x_gpio_priv *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
drivers/net/phy/qca807x.c: At top level:
drivers/net/phy/qca807x.c:362:37: warning: 'struct gpio_chip' declared inside parameter list will not be visible outside of this definition or declaration
362 | static void qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
| ^~~~~~~~~
drivers/net/phy/qca807x.c: In function 'qca807x_gpio_set':
drivers/net/phy/qca807x.c:364:42: warning: initialization of 'struct qca807x_gpio_priv *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
364 | struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
| ^~~~~~~~~~~~~~~~~
drivers/net/phy/qca807x.c: At top level:
drivers/net/phy/qca807x.c:375:40: warning: 'struct gpio_chip' declared inside parameter list will not be visible outside of this definition or declaration
375 | static int qca807x_gpio_dir_out(struct gpio_chip *gc, unsigned int offset, int value)
| ^~~~~~~~~
drivers/net/phy/qca807x.c: In function 'qca807x_gpio_dir_out':
>> drivers/net/phy/qca807x.c:377:26: error: passing argument 1 of 'qca807x_gpio_set' from incompatible pointer type [-Werror=incompatible-pointer-types]
377 | qca807x_gpio_set(gc, offset, value);
| ^~
| |
| struct gpio_chip *
drivers/net/phy/qca807x.c:362:48: note: expected 'struct gpio_chip *' but argument is of type 'struct gpio_chip *'
362 | static void qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
| ~~~~~~~~~~~~~~~~~~^~
drivers/net/phy/qca807x.c: In function 'qca807x_gpio':
>> drivers/net/phy/qca807x.c:394:38: error: invalid application of 'sizeof' to incomplete type 'struct gpio_chip'
394 | gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL);
| ^
>> drivers/net/phy/qca807x.c:398:11: error: invalid use of undefined type 'struct gpio_chip'
398 | gc->label = dev_name(dev);
| ^~
drivers/net/phy/qca807x.c:399:11: error: invalid use of undefined type 'struct gpio_chip'
399 | gc->base = -1;
| ^~
drivers/net/phy/qca807x.c:400:11: error: invalid use of undefined type 'struct gpio_chip'
400 | gc->ngpio = 2;
| ^~
drivers/net/phy/qca807x.c:401:11: error: invalid use of undefined type 'struct gpio_chip'
401 | gc->parent = dev;
| ^~
drivers/net/phy/qca807x.c:402:11: error: invalid use of undefined type 'struct gpio_chip'
402 | gc->owner = THIS_MODULE;
| ^~
drivers/net/phy/qca807x.c:403:11: error: invalid use of undefined type 'struct gpio_chip'
403 | gc->can_sleep = true;
| ^~
drivers/net/phy/qca807x.c:404:11: error: invalid use of undefined type 'struct gpio_chip'
404 | gc->get_direction = qca807x_gpio_get_direction;
| ^~
drivers/net/phy/qca807x.c:405:11: error: invalid use of undefined type 'struct gpio_chip'
405 | gc->direction_output = qca807x_gpio_dir_out;
| ^~
drivers/net/phy/qca807x.c:406:11: error: invalid use of undefined type 'struct gpio_chip'
406 | gc->get = qca807x_gpio_get;
| ^~
drivers/net/phy/qca807x.c:407:11: error: invalid use of undefined type 'struct gpio_chip'
407 | gc->set = qca807x_gpio_set;
| ^~
>> drivers/net/phy/qca807x.c:409:16: error: implicit declaration of function 'devm_gpiochip_add_data' [-Werror=implicit-function-declaration]
409 | return devm_gpiochip_add_data(dev, gc, priv);
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/qca807x.c: In function 'qca807x_probe':
>> drivers/net/phy/qca807x.c:708:21: error: too few arguments to function 'of_find_property'
708 | if (of_find_property(node, "leds") &&
| ^~~~~~~~~~~~~~~~
In file included from drivers/net/phy/qca807x.c:13:
include/linux/of.h:309:25: note: declared here
309 | extern struct property *of_find_property(const struct device_node *np,
| ^~~~~~~~~~~~~~~~
drivers/net/phy/qca807x.c:709:21: error: too few arguments to function 'of_find_property'
709 | of_find_property(node, "gpio-controller")) {
| ^~~~~~~~~~~~~~~~
include/linux/of.h:309:25: note: declared here
309 | extern struct property *of_find_property(const struct device_node *np,
| ^~~~~~~~~~~~~~~~
>> drivers/net/phy/qca807x.c:710:113: error: macro "phydev_err" requires 3 arguments, but only 1 given
710 | phydev_err("Invalid property detected. LEDs and gpio-controller are mutually exclusive.");
| ^
In file included from drivers/net/phy/qca807x.c:14:
include/linux/phy.h:1840: note: macro "phydev_err" defined here
1840 | #define phydev_err(_phydev, format, args...) \
|
>> drivers/net/phy/qca807x.c:710:25: error: 'phydev_err' undeclared (first use in this function); did you mean 'netdev_err'?
710 | phydev_err("Invalid property detected. LEDs and gpio-controller are mutually exclusive.");
| ^~~~~~~~~~
| netdev_errcc1: some warnings being treated as errors
vim +/GPIO_LINE_DIRECTION_OUT +344 drivers/net/phy/qca807x.c
340
341 #ifdef CONFIG_GPIOLIB
> 342 static int qca807x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
343 {
> 344 return GPIO_LINE_DIRECTION_OUT;
345 }
346
347 static int qca807x_gpio_get_reg(unsigned int offset)
348 {
349 return QCA807X_MMD7_LED_100N_2 + (offset % 2) * 2;
350 }
351
352 static int qca807x_gpio_get(struct gpio_chip *gc, unsigned int offset)
353 {
> 354 struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
355 int val;
356
357 val = phy_read_mmd(priv->phy, MDIO_MMD_AN, qca807x_gpio_get_reg(offset));
358
359 return FIELD_GET(QCA807X_GPIO_FORCE_MODE_MASK, val);
360 }
361
362 static void qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
363 {
364 struct qca807x_gpio_priv *priv = gpiochip_get_data(gc);
365 int val;
366
367 val = phy_read_mmd(priv->phy, MDIO_MMD_AN, qca807x_gpio_get_reg(offset));
368 val &= ~QCA807X_GPIO_FORCE_MODE_MASK;
369 val |= QCA807X_GPIO_FORCE_EN;
370 val |= FIELD_PREP(QCA807X_GPIO_FORCE_MODE_MASK, value);
371
372 phy_write_mmd(priv->phy, MDIO_MMD_AN, qca807x_gpio_get_reg(offset), val);
373 }
374
375 static int qca807x_gpio_dir_out(struct gpio_chip *gc, unsigned int offset, int value)
376 {
> 377 qca807x_gpio_set(gc, offset, value);
378
379 return 0;
380 }
381
382 static int qca807x_gpio(struct phy_device *phydev)
383 {
384 struct device *dev = &phydev->mdio.dev;
385 struct qca807x_gpio_priv *priv;
386 struct gpio_chip *gc;
387
388 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
389 if (!priv)
390 return -ENOMEM;
391
392 priv->phy = phydev;
393
> 394 gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL);
395 if (!gc)
396 return -ENOMEM;
397
> 398 gc->label = dev_name(dev);
399 gc->base = -1;
400 gc->ngpio = 2;
401 gc->parent = dev;
402 gc->owner = THIS_MODULE;
403 gc->can_sleep = true;
404 gc->get_direction = qca807x_gpio_get_direction;
405 gc->direction_output = qca807x_gpio_dir_out;
406 gc->get = qca807x_gpio_get;
407 gc->set = qca807x_gpio_set;
408
> 409 return devm_gpiochip_add_data(dev, gc, priv); 410 }
411 #endif
412
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
RFC PATCH 14/14 net: phy: qca807x: Add support for configurable LED
In reply to Christian MarangiQCA8072/5 have up to 2 LEDs attached for PHY.
LEDs can be configured to be ON/hw blink or be set to HW control.
Hw blink mode is set to blink at 4Hz or 250ms.
PHY can support both copper (TP) or fiber (FIBRE) kind and supports different HW control modes based on the port type.
HW control modes supported for netdev trigger for copper ports are:
- LINK_10
- LINK_100
- LINK_1000
- TX
- RX
- FULL_DUPLEX
- HALF_DUPLEX
HW control modes supported for netdev trigger for fiber ports are:
- LINK_100
- LINK_1000
- TX
- RX
- FULL_DUPLEX
- HALF_DUPLEX
LED support conflicts with GPIO controller feature and must be disabled if gpio-controller is used for the PHY.
--- drivers/net/phy/qca807x.c | 382 +++++++++++++++++++++++++++++++++++++- 1 file changed, 375 insertions(+), 7 deletions(-)
drivers/net/phy/qca807x.c +375 -7
@@ -80,17 +80,60 @@#define QCA807X_MMD7_1000BASE_T_POWER_SAVE_PER_CABLE_LENGTH 0x801a#define QCA807X_CONTROL_DAC_MASK GENMASK(2, 0) +#define QCA807X_MMD7_LED_GLOBAL 0x8073 +#define QCA807X_LED_BLINK_1 GENMASK(11, 6) +#define QCA807X_LED_BLINK_2 GENMASK(5, 0) +/* Values are the same for both BLINK_1 and BLINK_2 */ +#define QCA807X_LED_BLINK_FREQ_MASK GENMASK(5, 3) +#define QCA807X_LED_BLINK_FREQ_2HZ FIELD_PREP(QCA807X_LED_BLINK_FREQ_MASK, 0x0) +#define QCA807X_LED_BLINK_FREQ_4HZ FIELD_PREP(QCA807X_LED_BLINK_FREQ_MASK, 0x1) +#define QCA807X_LED_BLINK_FREQ_8HZ FIELD_PREP(QCA807X_LED_BLINK_FREQ_MASK, 0x2) +#define QCA807X_LED_BLINK_FREQ_16HZ FIELD_PREP(QCA807X_LED_BLINK_FREQ_MASK, 0x3) +#define QCA807X_LED_BLINK_FREQ_32HZ FIELD_PREP(QCA807X_LED_BLINK_FREQ_MASK, 0x4) +#define QCA807X_LED_BLINK_FREQ_64HZ FIELD_PREP(QCA807X_LED_BLINK_FREQ_MASK, 0x5) +#define QCA807X_LED_BLINK_FREQ_128HZ FIELD_PREP(QCA807X_LED_BLINK_FREQ_MASK, 0x6) +#define QCA807X_LED_BLINK_FREQ_256HZ FIELD_PREP(QCA807X_LED_BLINK_FREQ_MASK, 0x7) +#define QCA807X_LED_BLINK_DUTY_MASK GENMASK(2, 0) +#define QCA807X_LED_BLINK_DUTY_50_50 FIELD_PREP(QCA807X_LED_BLINK_DUTY_MASK, 0x0) +#define QCA807X_LED_BLINK_DUTY_75_25 FIELD_PREP(QCA807X_LED_BLINK_DUTY_MASK, 0x1) +#define QCA807X_LED_BLINK_DUTY_25_75 FIELD_PREP(QCA807X_LED_BLINK_DUTY_MASK, 0x2) +#define QCA807X_LED_BLINK_DUTY_33_67 FIELD_PREP(QCA807X_LED_BLINK_DUTY_MASK, 0x3) +#define QCA807X_LED_BLINK_DUTY_67_33 FIELD_PREP(QCA807X_LED_BLINK_DUTY_MASK, 0x4) +#define QCA807X_LED_BLINK_DUTY_17_83 FIELD_PREP(QCA807X_LED_BLINK_DUTY_MASK, 0x5) +#define QCA807X_LED_BLINK_DUTY_83_17 FIELD_PREP(QCA807X_LED_BLINK_DUTY_MASK, 0x6) +#define QCA807X_LED_BLINK_DUTY_8_92 FIELD_PREP(QCA807X_LED_BLINK_DUTY_MASK, 0x7)#define QCA807X_MMD7_LED_100N_1 0x8074#define QCA807X_MMD7_LED_100N_2 0x8075#define QCA807X_MMD7_LED_1000N_1 0x8076#define QCA807X_MMD7_LED_1000N_2 0x8077 -#define QCA807X_LED_TXACT_BLK_EN_2 BIT(10) -#define QCA807X_LED_RXACT_BLK_EN_2 BIT(9) -#define QCA807X_LED_GT_ON_EN_2 BIT(6) -#define QCA807X_LED_HT_ON_EN_2 BIT(5) -#define QCA807X_LED_BT_ON_EN_2 BIT(4) -#define QCA807X_GPIO_FORCE_EN BIT(15) -#define QCA807X_GPIO_FORCE_MODE_MASK GENMASK(14, 13) +/* Values are the same for LED1 and LED2 */ +/* Values for control 1 */ +#define QCA807X_LED_COPPER_ON_BLINK_MASK GENMASK(12, 0) +#define QCA807X_LED_FDX_ON_EN BIT(12) +#define QCA807X_LED_HDX_ON_EN BIT(11) +#define QCA807X_LED_TXACT_BLK_EN BIT(10) +#define QCA807X_LED_RXACT_BLK_EN BIT(9) +#define QCA807X_LED_GT_ON_EN BIT(6) +#define QCA807X_LED_HT_ON_EN BIT(5) +#define QCA807X_LED_BT_ON_EN BIT(4) +/* Values for control 2 */ +#define QCA807X_LED_FORCE_EN BIT(15) +#define QCA807X_LED_FORCE_MODE_MASK GENMASK(14, 13) +#define QCA807X_LED_FORCE_BLINK_1 FIELD_PREP(QCA807X_LED_FORCE_MODE_MASK, 0x3) +#define QCA807X_LED_FORCE_BLINK_2 FIELD_PREP(QCA807X_LED_FORCE_MODE_MASK, 0x2) +#define QCA807X_LED_FORCE_ON FIELD_PREP(QCA807X_LED_FORCE_MODE_MASK, 0x1) +#define QCA807X_LED_FORCE_OFF FIELD_PREP(QCA807X_LED_FORCE_MODE_MASK, 0x0) +#define QCA807X_LED_FIBER_ON_BLINK_MASK GENMASK(11, 1) +#define QCA807X_LED_FIBER_TXACT_BLK_EN BIT(10) +#define QCA807X_LED_FIBER_RXACT_BLK_EN BIT(9) +#define QCA807X_LED_FIBER_FDX_ON_EN BIT(6) +#define QCA807X_LED_FIBER_HDX_ON_EN BIT(5) +#define QCA807X_LED_FIBER_1000BX_ON_EN BIT(2) +#define QCA807X_LED_FIBER_100FX_ON_EN BIT(1) + +/* Some device repurpose the LED as GPIO out */ +#define QCA807X_GPIO_FORCE_EN QCA807X_LED_FORCE_EN +#define QCA807X_GPIO_FORCE_MODE_MASK QCA807X_LED_FORCE_MODE_MASK#define QCA807X_INTR_ENABLE 0x12#define QCA807X_INTR_STATUS 0x13
@@ -338,6 +381,320 @@ static int qca807x_cable_test_start(struct phy_device *phydev)return ret; } +static int qca807x_led_parse_netdev (struct phy_device *phydev,unsigned long rules, +u16 *offload_trigger) +{ +/* Parsing specific to netdev trigger */ +switch (phydev->port) { +case PORT_TP : +if (test_bit (TRIGGER_NETDEV_TX , &rules)) + *offload_trigger |=QCA807X_LED_TXACT_BLK_EN ; +if (test_bit (TRIGGER_NETDEV_RX , &rules)) + *offload_trigger |=QCA807X_LED_RXACT_BLK_EN ; +if (test_bit (TRIGGER_NETDEV_LINK_10 , &rules)) + *offload_trigger |=QCA807X_LED_BT_ON_EN ; +if (test_bit (TRIGGER_NETDEV_LINK_100 , &rules)) + *offload_trigger |=QCA807X_LED_HT_ON_EN ; +if (test_bit (TRIGGER_NETDEV_LINK_1000 , &rules)) + *offload_trigger |=QCA807X_LED_GT_ON_EN ; +if (test_bit (TRIGGER_NETDEV_HALF_DUPLEX , &rules)) + *offload_trigger |=QCA807X_LED_HDX_ON_EN ; +if (test_bit (TRIGGER_NETDEV_FULL_DUPLEX , &rules)) + *offload_trigger |=QCA807X_LED_FDX_ON_EN ; +break ; +case PORT_FIBRE : +if (test_bit (TRIGGER_NETDEV_TX , &rules)) + *offload_trigger |=QCA807X_LED_FIBER_TXACT_BLK_EN ; +if (test_bit (TRIGGER_NETDEV_RX , &rules)) + *offload_trigger |=QCA807X_LED_FIBER_RXACT_BLK_EN ; +if (test_bit (TRIGGER_NETDEV_LINK_100 , &rules)) + *offload_trigger |=QCA807X_LED_FIBER_100FX_ON_EN ; +if (test_bit (TRIGGER_NETDEV_LINK_1000 , &rules)) + *offload_trigger |=QCA807X_LED_FIBER_1000BX_ON_EN ; +if (test_bit (TRIGGER_NETDEV_HALF_DUPLEX , &rules)) + *offload_trigger |=QCA807X_LED_FIBER_HDX_ON_EN ; +if (test_bit (TRIGGER_NETDEV_FULL_DUPLEX , &rules)) + *offload_trigger |=QCA807X_LED_FIBER_FDX_ON_EN ; +break ; +default : +return -EOPNOTSUPP ; + } + +if (rules && !*offload_trigger) +return -EOPNOTSUPP ; + +return 0 ; +} + +static int qca807x_led_hw_control_enable (struct phy_device *phydev,u8 index) +{ +int val, reg, ret; + +switch (index) { +case 0 : + reg =QCA807X_MMD7_LED_100N_2 ; +break ; +case 1 : + reg =QCA807X_MMD7_LED_1000N_2 ; +break ; +default : +return -EINVAL ; + } + + val =phy_read_mmd (phydev,MDIO_MMD_AN , reg); + val &= ~QCA807X_LED_FORCE_EN ; + ret =phy_write_mmd (phydev,MDIO_MMD_AN , reg, val); + +return ret; +} + +static int qca807x_led_hw_is_supported (struct phy_device *phydev,u8 index, +unsigned long rules) +{ +u16 offload_trigger =0 ; + +if (index >1 ) +return -EINVAL ; + +return qca807x_led_parse_netdev (phydev, rules, &offload_trigger); +} + +static int qca807x_led_hw_control_set (struct phy_device *phydev,u8 index, +unsigned long rules) +{ +int val, ret, copper_reg, fibre_reg; +u16 offload_trigger =0 ; + +switch (index) { +case 0 : + copper_reg =QCA807X_MMD7_LED_100N_1 ; + fibre_reg =QCA807X_MMD7_LED_100N_2 ; +break ; +case 1 : + copper_reg =QCA807X_MMD7_LED_1000N_1 ; + fibre_reg =QCA807X_MMD7_LED_1000N_2 ; +break ; +default : +return -EINVAL ; + } + + ret =qca807x_led_parse_netdev (phydev, rules, &offload_trigger); +if (ret) +return ret; + + ret =qca807x_led_hw_control_enable (phydev, index); +if (ret) +return ret; + +switch (phydev->port) { +case PORT_TP : + val =phy_read_mmd (phydev,MDIO_MMD_AN , copper_reg); + val &= ~QCA807X_LED_COPPER_ON_BLINK_MASK ; + val |= offload_trigger; + ret =phy_write_mmd (phydev,MDIO_MMD_AN , copper_reg, val); +break ; +case PORT_FIBRE : + val =phy_read_mmd (phydev,MDIO_MMD_AN , fibre_reg); + val &= ~QCA807X_LED_FIBER_ON_BLINK_MASK ; + val |= offload_trigger; + ret =phy_write_mmd (phydev,MDIO_MMD_AN , fibre_reg, val); +break ; +default : +return -EINVAL ; + } + +return ret; +} + +static bool qca807x_led_hw_control_status (struct phy_device *phydev,u8 index) +{ +int val, reg; + +switch (index) { +case 0 : + reg =QCA807X_MMD7_LED_100N_2 ; +break ; +case 1 : + reg =QCA807X_MMD7_LED_1000N_2 ; +break ; +default : +return false; + } + + val =phy_read_mmd (phydev,MDIO_MMD_AN , reg); + +return !(val &QCA807X_LED_FORCE_EN ); +} + +static int qca807x_led_hw_control_get (struct phy_device *phydev,u8 index, +unsigned long *rules) +{ +int val, copper_reg, fibre_reg; + +switch (index) { +case 0 : + copper_reg =QCA807X_MMD7_LED_100N_1 ; + fibre_reg =QCA807X_MMD7_LED_100N_2 ; +break ; +case 1 : + copper_reg =QCA807X_MMD7_LED_1000N_1 ; + fibre_reg =QCA807X_MMD7_LED_100N_2 ; +break ; +default : +return -EINVAL ; + } + +/* Check if we have hw control enabled */ +if (qca807x_led_hw_control_status (phydev, index)) +return -EINVAL ; + +/* Parsing specific to netdev trigger */ +switch (phydev->port) { +case PORT_TP : + val =phy_read_mmd (phydev,MDIO_MMD_AN , copper_reg); +if (val &QCA807X_LED_TXACT_BLK_EN ) +set_bit (TRIGGER_NETDEV_TX , rules); +if (val &QCA807X_LED_RXACT_BLK_EN ) +set_bit (TRIGGER_NETDEV_RX , rules); +if (val &QCA807X_LED_BT_ON_EN ) +set_bit (TRIGGER_NETDEV_LINK_10 , rules); +if (val &QCA807X_LED_HT_ON_EN ) +set_bit (TRIGGER_NETDEV_LINK_100 , rules); +if (val &QCA807X_LED_GT_ON_EN ) +set_bit (TRIGGER_NETDEV_LINK_1000 , rules); +if (val &QCA807X_LED_HDX_ON_EN ) +set_bit (TRIGGER_NETDEV_HALF_DUPLEX , rules); +if (val &QCA807X_LED_FDX_ON_EN ) +set_bit (TRIGGER_NETDEV_FULL_DUPLEX , rules); +break ; +case PORT_FIBRE : + val =phy_read_mmd (phydev,MDIO_MMD_AN , fibre_reg); +if (val &QCA807X_LED_FIBER_TXACT_BLK_EN ) +set_bit (TRIGGER_NETDEV_TX , rules); +if (val &QCA807X_LED_FIBER_RXACT_BLK_EN ) +set_bit (TRIGGER_NETDEV_RX , rules); +if (val &QCA807X_LED_FIBER_100FX_ON_EN ) +set_bit (TRIGGER_NETDEV_LINK_100 , rules); +if (val &QCA807X_LED_FIBER_1000BX_ON_EN ) +set_bit (TRIGGER_NETDEV_LINK_1000 , rules); +if (val &QCA807X_LED_FIBER_HDX_ON_EN ) +set_bit (TRIGGER_NETDEV_HALF_DUPLEX , rules); +if (val &QCA807X_LED_FIBER_FDX_ON_EN ) +set_bit (TRIGGER_NETDEV_FULL_DUPLEX , rules); +break ; +default : +return -EINVAL ; + } + +return 0 ; +} + +static int qca807x_led_hw_control_reset (struct phy_device *phydev,u8 index) +{ +int val, copper_reg, fibre_reg, ret; + +switch (index) { +case 0 : + copper_reg =QCA807X_MMD7_LED_100N_1 ; + fibre_reg =QCA807X_MMD7_LED_100N_2 ; +break ; +case 1 : + copper_reg =QCA807X_MMD7_LED_1000N_1 ; + fibre_reg =QCA807X_MMD7_LED_100N_2 ; +break ; +default : +return -EINVAL ; + } + +switch (phydev->port) { +case PORT_TP : + val =phy_read_mmd (phydev,MDIO_MMD_AN , copper_reg); + val &= ~QCA807X_LED_COPPER_ON_BLINK_MASK ; + ret =phy_write_mmd (phydev,MDIO_MMD_AN , copper_reg, val); +break ; +case PORT_FIBRE : + val =phy_read_mmd (phydev,MDIO_MMD_AN , fibre_reg); + val &= ~QCA807X_LED_FIBER_ON_BLINK_MASK ; + ret =phy_write_mmd (phydev,MDIO_MMD_AN , fibre_reg, val); +break ; +default : +return -EINVAL ; + } + +return ret; +} + +static int qca807x_led_brightness_set (struct phy_device *phydev, +u8 index,enum led_brightness value) +{ +int val, ret; +u16 reg; + +switch (index) { +case 0 : + reg =QCA807X_MMD7_LED_100N_2 ; +break ; +case 1 : + reg =QCA807X_MMD7_LED_1000N_2 ; +break ; +default : +return -EINVAL ; + } + +/* If we are setting off the LED reset any hw control rule */ +if (!value) { + ret =qca807x_led_hw_control_reset (phydev, index); +if (ret) +return ret; + } + + val =phy_read_mmd (phydev,MDIO_MMD_AN , reg); + val &= ~(QCA807X_LED_FORCE_EN |QCA807X_LED_FORCE_MODE_MASK ); + val |=QCA807X_LED_FORCE_EN ; +if (value) + val |=QCA807X_LED_FORCE_ON ; + ret =phy_write_mmd (phydev,MDIO_MMD_AN , reg, val); + +return ret; +} + +static int qca807x_led_blink_set (struct phy_device *phydev,u8 index, +unsigned long *delay_on, +unsigned long *delay_off) +{ +int val, ret; +u16 reg; + +switch (index) { +case 0 : + reg =QCA807X_MMD7_LED_100N_2 ; +break ; +case 1 : + reg =QCA807X_MMD7_LED_1000N_2 ; +break ; +default : +return -EINVAL ; + } + +/* Set blink to 50% off, 50% on at 4Hz by default */ + val =phy_read_mmd (phydev,MDIO_MMD_AN ,QCA807X_MMD7_LED_GLOBAL ); + val &= ~(QCA807X_LED_BLINK_FREQ_MASK |QCA807X_LED_BLINK_DUTY_MASK ); + val |=QCA807X_LED_BLINK_FREQ_4HZ |QCA807X_LED_BLINK_DUTY_50_50 ; + ret =phy_write_mmd (phydev,MDIO_MMD_AN ,QCA807X_MMD7_LED_GLOBAL , val); + +/* We use BLINK_1 for normal blinking */ + val =phy_read_mmd (phydev,MDIO_MMD_AN , reg); + val &= ~(QCA807X_LED_FORCE_EN |QCA807X_LED_FORCE_MODE_MASK ); + val |=QCA807X_LED_FORCE_EN |QCA807X_LED_FORCE_BLINK_1 ; + ret =phy_write_mmd (phydev,MDIO_MMD_AN , reg, val); + +/* We set blink to 4Hz, aka 250ms */ + *delay_on =250 /2 ; + *delay_off =250 /2 ; + +return ret; +} +#ifdef CONFIG_GPIOLIB static int qca807x_gpio_get_direction (struct gpio_chip *gc,unsigned int offset) {
@@ -716,6 +1073,12 @@ static int qca807x_probe(struct phy_device *phydev) ret =qca807x_gpio (phydev);if (ret)return ret; + + phydev->drv->led_brightness_set =NULL ; + phydev->drv->led_blink_set =NULL ; + phydev->drv->led_hw_is_supported =NULL ; + phydev->drv->led_hw_control_set =NULL ; + phydev->drv->led_hw_control_get =NULL ; } }
@@ -843,6 +1206,11 @@ static struct phy_driver qca807x_drivers[] = { .suspend = genphy_suspend, .cable_test_start = qca807x_cable_test_start, .cable_test_get_status = qca807x_cable_test_get_status, + .led_brightness_set = qca807x_led_brightness_set, + .led_blink_set = qca807x_led_blink_set, + .led_hw_is_supported = qca807x_led_hw_is_supported, + .led_hw_control_set = qca807x_led_hw_control_set, + .led_hw_control_get = qca807x_led_hw_control_get,/* PHY package define */ .phy_package_global_phy_num = ARRAY_SIZE(qca807x_global_phy_names), .phy_package_global_phy_names = qca807x_global_phy_names,
Signature · 1 line
2.40.1
Hello Christian,
Quoted 2 lines · On Mon, 20 Nov 2023 14:50:27 +0100 Christian Marangi <[email protected]>…
Idea of this big series is to introduce the concept of PHY package in DT and generalize the support of it by PHY driver.
I don't have much to say on the series itself, I looked at it and didn't find anything obviously wrong, however know that this work can also be helpful for some other use-cases. I have in mind the Marvell Alaska 88e1543 PHY, which is a 4-port package that can either be used as a classic Quad-PHY, or a Dual-PHY, each PHY having 2 ports. Having a DT description of the package is a good step towards being able to auto-detect which configuration to use for that package.
Thanks for this work,
Maxime