diff mbox series

[net-next,RFC,v2,3/3] dt-bindings: net: Document support for Aeonsemi PHYs

Message ID 20250326002404.25530-4-ansuelsmth@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: phy: Add support for new Aeonsemi PHYs | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 129 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Christian Marangi March 26, 2025, 12:23 a.m. UTC
Document support for Aeonsemi PHYs and the requirement of a firmware to
correctly work. Also document the max number of LEDs supported and what
PHY ID expose when no firmware is loaded.

Supported PHYs AS21011JB1, AS21011PB1, AS21010JB1, AS21010PB1,
AS21511JB1, AS21511PB1, AS21510JB1, AS21510PB1, AS21210JB1,
AS21210PB1 that all register with the PHY ID 0x7500 0x9410 on C45
registers before the firmware is loaded.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 .../bindings/net/aeonsemi,as21xxx.yaml        | 122 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 2 files changed, 123 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/aeonsemi,as21xxx.yaml

Comments

Andrew Lunn March 26, 2025, 3:08 p.m. UTC | #1
> +  A PHY with not firmware loaded will be exposed on the MDIO bus with ID
> +  0x7500 0x7500 or 0x7500 0x9410 on C45 registers.

> +select:
> +  properties:
> +    compatible:
> +      contains:
> +        enum:
> +          - ethernet-phy-id7500.9410
> +          - ethernet-phy-id7500.9402
> +          - ethernet-phy-id7500.9412
> +          - ethernet-phy-id7500.9422
> +          - ethernet-phy-id7500.9432
> +          - ethernet-phy-id7500.9442
> +          - ethernet-phy-id7500.9452
> +          - ethernet-phy-id7500.9462
> +          - ethernet-phy-id7500.9472
> +          - ethernet-phy-id7500.9482
> +          - ethernet-phy-id7500.9492

> +        ethernet-phy@1f {
> +            compatible = "ethernet-phy-id7500.9410",
> +                         "ethernet-phy-ieee802.3-c45";

You need to be careful here. And fully understand what this means.  In
general, you don't list a compatible here, or only
ethernet-phy-ieee802.3-c45. This is because the bus can be enumerated,
you can get the ID from the device. What is in the device is more
likely to be correct than whatever the DT author put here. However,
you can state a compatible with an ID, and when you do that, it means
the PHY device ID in the silicon is broken, ignore it, probe based on
the value here.  So if you state ethernet-phy-id7500.9410, it does not
matter if there is firmware or not in the PHY, what ID the PHY has, it
will get probed as a ethernet-phy-id7500.9410.

Except, if there is a .match_phy_device in the driver ops. If there is
a .match_phy_device the driver does whatever it wants to try to
identify the device and perform a match.

	Andrew
Christian Marangi March 26, 2025, 3:16 p.m. UTC | #2
On Wed, Mar 26, 2025 at 04:08:31PM +0100, Andrew Lunn wrote:
> > +  A PHY with not firmware loaded will be exposed on the MDIO bus with ID
> > +  0x7500 0x7500 or 0x7500 0x9410 on C45 registers.
> 
> > +select:
> > +  properties:
> > +    compatible:
> > +      contains:
> > +        enum:
> > +          - ethernet-phy-id7500.9410
> > +          - ethernet-phy-id7500.9402
> > +          - ethernet-phy-id7500.9412
> > +          - ethernet-phy-id7500.9422
> > +          - ethernet-phy-id7500.9432
> > +          - ethernet-phy-id7500.9442
> > +          - ethernet-phy-id7500.9452
> > +          - ethernet-phy-id7500.9462
> > +          - ethernet-phy-id7500.9472
> > +          - ethernet-phy-id7500.9482
> > +          - ethernet-phy-id7500.9492
> 
> > +        ethernet-phy@1f {
> > +            compatible = "ethernet-phy-id7500.9410",
> > +                         "ethernet-phy-ieee802.3-c45";
> 
> You need to be careful here. And fully understand what this means.  In
> general, you don't list a compatible here, or only
> ethernet-phy-ieee802.3-c45. This is because the bus can be enumerated,
> you can get the ID from the device. What is in the device is more
> likely to be correct than whatever the DT author put here. However,
> you can state a compatible with an ID, and when you do that, it means
> the PHY device ID in the silicon is broken, ignore it, probe based on
> the value here.  So if you state ethernet-phy-id7500.9410, it does not
> matter if there is firmware or not in the PHY, what ID the PHY has, it
> will get probed as a ethernet-phy-id7500.9410.
> 
> Except, if there is a .match_phy_device in the driver ops. If there is
> a .match_phy_device the driver does whatever it wants to try to
> identify the device and perform a match.
>

Yep I will note this for the PHY driver. I really need to use
match_phy_device for the FW load OPs to prevent any kind of bad
compatible.

In C22 75007500 is reported while in C45 a more correct 75009410 is
reported, this is why the c45 compatible.

Aside from this, the compatible listed here are really just to document
the need for firmware-name and to what PHY it should be needed. It's a
pattern I followed from the aquantia schema.

Example for PHY with ID 7500.9410 in C45, firmware-name is required, for
anything else (example 7500.9422) firmware-name property should not be
used (case with a SPI attached for example).
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/aeonsemi,as21xxx.yaml b/Documentation/devicetree/bindings/net/aeonsemi,as21xxx.yaml
new file mode 100644
index 000000000000..69eb29dc4d7b
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/aeonsemi,as21xxx.yaml
@@ -0,0 +1,122 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/aeonsemi,as21xxx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Aeonsemi AS21XXX Ethernet PHY
+
+maintainers:
+  - Christian Marangi <ansuelsmth@gmail.com>
+
+description: |
+  Aeonsemi AS21xxx Ethernet PHYs requires a firmware to be loaded to actually
+  work. The same firmware is compatible with various PHYs of the same family.
+
+  A PHY with not firmware loaded will be exposed on the MDIO bus with ID
+  0x7500 0x7500 or 0x7500 0x9410 on C45 registers.
+
+  This can be done and is implemented by OEM in 2 different way:
+    - Attached SPI flash directly to the PHY with the firmware. The PHY
+      will self load the firmware in the presence of this configuration.
+    - Manually provided firmware loaded from a file in the filesystem.
+
+  Each PHY can support up to 5 LEDs.
+
+  AS2xxx PHY Name logic:
+
+  AS21x1xxB1
+      ^ ^^
+      | |J: Supports SyncE/PTP
+      | |P: No SyncE/PTP support
+      | 1: Supports 2nd Serdes
+      | 2: Not 2nd Serdes support
+      0: 10G, 5G, 2.5G
+      5: 5G, 2.5G
+      2: 2.5G
+
+allOf:
+  - $ref: ethernet-phy.yaml#
+
+select:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - ethernet-phy-id7500.9410
+          - ethernet-phy-id7500.9402
+          - ethernet-phy-id7500.9412
+          - ethernet-phy-id7500.9422
+          - ethernet-phy-id7500.9432
+          - ethernet-phy-id7500.9442
+          - ethernet-phy-id7500.9452
+          - ethernet-phy-id7500.9462
+          - ethernet-phy-id7500.9472
+          - ethernet-phy-id7500.9482
+          - ethernet-phy-id7500.9492
+  required:
+    - compatible
+
+properties:
+  reg:
+    maxItems: 1
+
+  firmware-name:
+    description: specify the name of PHY firmware to load
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+if:
+  properties:
+    compatible:
+      contains:
+        const: ethernet-phy-id7500.9410
+then:
+  required:
+    - firmware-name
+else:
+  properties:
+    firmware-name: false
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/leds/common.h>
+
+    mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ethernet-phy@1f {
+            compatible = "ethernet-phy-id7500.9410",
+                         "ethernet-phy-ieee802.3-c45";
+
+            reg = <31>;
+            firmware-name = "as21x1x_fw.bin";
+
+            leds {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                led@0 {
+                    reg = <0>;
+                    color = <LED_COLOR_ID_GREEN>;
+                    function = LED_FUNCTION_LAN;
+                    function-enumerator = <0>;
+                    default-state = "keep";
+                };
+
+                led@1 {
+                    reg = <1>;
+                    color = <LED_COLOR_ID_GREEN>;
+                    function = LED_FUNCTION_LAN;
+                    function-enumerator = <1>;
+                    default-state = "keep";
+                };
+            };
+        };
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index 9a2df6d221bd..59a863dd3b70 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -649,6 +649,7 @@  AEONSEMI PHY DRIVER
 M:	Christian Marangi <ansuelsmth@gmail.com>
 L:	netdev@vger.kernel.org
 S:	Maintained
+F:	Documentation/devicetree/bindings/net/aeonsemi,as21xxx.yaml
 F:	drivers/net/phy/as21xxx.c
 
 AF8133J THREE-AXIS MAGNETOMETER DRIVER