mbox series

[net-next,RFC,00/14] net: phy: Support DT PHY package

Message ID 20231120135041.15259-1-ansuelsmth@gmail.com (mailing list archive)
Headers show
Series net: phy: Support DT PHY package | expand

Message

Christian Marangi Nov. 20, 2023, 1:50 p.m. UTC
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

Comments

Maxime Chevallier Nov. 20, 2023, 3:11 p.m. UTC | #1
Hello Christian,

On Mon, 20 Nov 2023 14:50:27 +0100
Christian Marangi <ansuelsmth@gmail.com> wrote:

> 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