Skip to contentSkip to conversation

Brcm ASP 2.0 Ethernet Controller

PATCH Superseded Justin Chen 5 participants 16 messages May 24, 2023 – May 31, 2023

Subsystems (7)

v5 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Justin Chen

author maintainer
#0 lore raw

v5 cover Brcm ASP 2.0 Ethernet Controller

Add support for the Broadcom ASP 2.0 Ethernet controller which is first introduced with 72165.

Add support for 74165 10/100 integrated Ethernet PHY which also uses the ASP 2.0 Ethernet controller.

Florian Fainelli (2):
dt-bindings: net: Brcm ASP 2.0 Ethernet controller
net: phy: bcm7xxx: Add EPHY entry for 74165

Justin Chen (4):
dt-bindings: net: brcm,unimac-mdio: Add asp-v2.0
net: bcmasp: Add support for ASP2.0 Ethernet controller
net: phy: mdio-bcm-unimac: Add asp v2.0 support
MAINTAINERS: ASP 2.0 Ethernet driver maintainers

 .../devicetree/bindings/net/brcm,asp-v2.0.yaml     |  149 ++
 .../devicetree/bindings/net/brcm,unimac-mdio.yaml  |    2 +
 MAINTAINERS                                        |    9 +
 drivers/net/ethernet/broadcom/Kconfig              |   11 +
 drivers/net/ethernet/broadcom/Makefile             |    1 +
 drivers/net/ethernet/broadcom/asp2/Makefile        |    2 +
 drivers/net/ethernet/broadcom/asp2/bcmasp.c        | 1462 ++++++++++++++++++++
 drivers/net/ethernet/broadcom/asp2/bcmasp.h        |  637 +++++++++
 .../net/ethernet/broadcom/asp2/bcmasp_ethtool.c    |  568 ++++++++
 drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c   | 1425 +++++++++++++++++++
 .../net/ethernet/broadcom/asp2/bcmasp_intf_defs.h  |  238 ++++
 drivers/net/mdio/mdio-bcm-unimac.c                 |    2 +
 drivers/net/phy/bcm7xxx.c                          |    1 +
 include/linux/brcmphy.h                            |    1 +
 14 files changed, 4508 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml
 create mode 100644 drivers/net/ethernet/broadcom/asp2/Makefile
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp.c
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp.h
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp_intf_defs.h
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH v5 1/6 dt-bindings: net: brcm,unimac-mdio: Add asp-v2.0

The ASP 2.0 Ethernet controller uses a brcm unimac.

---
 Documentation/devicetree/bindings/net/brcm,unimac-mdio.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/net/brcm,unimac-mdio.yaml +2 -0
index 0be426ee1e44..6684810fcbf0 100644
@@ -22,6 +22,8 @@ properties:
       - brcm,genet-mdio-v3
       - brcm,genet-mdio-v4
       - brcm,genet-mdio-v5
+      - brcm,asp-v2.0-mdio
+      - brcm,asp-v2.1-mdio
       - brcm,unimac-mdio
 
   reg:
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

PATCH v5 2/6 dt-bindings: net: Brcm ASP 2.0 Ethernet controller

In reply to Justin Chen

From: Florian Fainelli <[email protected]>

Add a binding document for the Broadcom ASP 2.0 Ethernet controller.

---
v5
- Fix compatible string yaml format to properly capture what we want

v4
- Adjust compatible string example to reference SoC and HW ver

v3
- Minor formatting issues
- Change channel prop to brcm,channel for vendor specific format
- Removed redundant v2.0 from compat string
- Fix ranges field

v2
- Minor formatting issues

 .../devicetree/bindings/net/brcm,asp-v2.0.yaml     | 149 +++++++++++++++++++++
 1 file changed, 149 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +149 -0
new file mode 100644
index 000000000000..c4cd24492bfd
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/brcm,asp-v2.0.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom ASP 2.0 Ethernet controller
+
+maintainers:
+  - Justin Chen <[email protected]>
+  - Florian Fainelli <[email protected]>
+
+description: Broadcom Ethernet controller first introduced with 72165
+
+properties:
+  '#address-cells':
+    const: 1
+  '#size-cells':
+    const: 1
+
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - brcm,bcm74165-asp
+          - const: brcm,asp-v2.1
+      - items:
+          - enum:
+              - brcm,bcm72165-asp
+          - const: brcm,asp-v2.0
+
+  reg:
+    maxItems: 1
+
+  ranges: true
+
+  interrupts:
+    minItems: 1
+    items:
+      - description: RX/TX interrupt
+      - description: Port 0 Wake-on-LAN
+      - description: Port 1 Wake-on-LAN
+
+  clocks:
+    maxItems: 1
+
+  ethernet-ports:
+    type: object
+    properties:
+      '#address-cells':
+        const: 1
+      '#size-cells':
+        const: 0
+
+    patternProperties:
+      "^port@[0-9]+$":
+        type: object
+
+        $ref: ethernet-controller.yaml#
+
+        properties:
+          reg:
+            maxItems: 1
+            description: Port number
+
+          brcm,channel:
+            $ref: /schemas/types.yaml#/definitions/uint32
+            description: ASP channel number
+
+        required:
+          - reg
+          - brcm,channel
+
+    additionalProperties: false
+
+patternProperties:
+  "^mdio@[0-9a-f]+$":
+    type: object
+    $ref: brcm,unimac-mdio.yaml
+
+    description:
+      ASP internal UniMAC MDIO bus
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - ranges
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    ethernet@9c00000 {
+        compatible = "brcm,bcm72165-asp", "brcm,asp-v2.0";
+        reg = <0x9c00000 0x1fff14>;
+        interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>;
+        ranges = <0x0 0x9c00000 0x1fff14>;
+        clocks = <&scmi 14>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        mdio@c614 {
+            compatible = "brcm,asp-v2.0-mdio";
+            reg = <0xc614 0x8>;
+            reg-names = "mdio";
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            phy0: ethernet-phy@1 {
+                reg = <1>;
+            };
+       };
+
+        mdio@ce14 {
+            compatible = "brcm,asp-v2.0-mdio";
+            reg = <0xce14 0x8>;
+            reg-names = "mdio";
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            phy1: ethernet-phy@1 {
+                reg = <1>;
+            };
+        };
+
+        ethernet-ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            port@0 {
+                reg = <0>;
+                brcm,channel = <8>;
+                phy-mode = "rgmii";
+                phy-handle = <&phy0>;
+            };
+
+            port@1 {
+                reg = <1>;
+                brcm,channel = <9>;
+                phy-mode = "rgmii";
+                phy-handle = <&phy1>;
+            };
+        };
+    };
Signature · 1 line
2.7.4
Reviewed-by on v5 2/6
#3 lore raw

Re: [PATCH net-next v5 2/6] dt-bindings: net: Brcm ASP 2.0 Ethernet controller

Quoted 53 lines · Justin Chen

From: Florian Fainelli <[email protected]>

Add a binding document for the Broadcom ASP 2.0 Ethernet controller.

---
v5
- Fix compatible string yaml format to properly capture what we want

v4
- Adjust compatible string example to reference SoC and HW ver

v3
- Minor formatting issues
- Change channel prop to brcm,channel for vendor specific format
- Removed redundant v2.0 from compat string
- Fix ranges field

v2
- Minor formatting issues

 .../devicetree/bindings/net/brcm,asp-v2.0.yaml     | 149 +++++++++++++++++++++
 1 file changed, 149 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +20 -0
new file mode 100644
index 000000000000..c4cd24492bfd
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/brcm,asp-v2.0.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom ASP 2.0 Ethernet controller
+
+maintainers:
+  - Justin Chen <[email protected]>
+  - Florian Fainelli <[email protected]>
+
+description: Broadcom Ethernet controller first introduced with 72165
+
+properties:
+  '#address-cells':
+    const: 1
+  '#size-cells':
+    const: 1
+

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +10 -0
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - brcm,bcm74165-asp
+          - const: brcm,asp-v2.1
+      - items:
+          - enum:
+              - brcm,bcm72165-asp
+          - const: brcm,asp-v2.0

Sorry if I did not notice this before, conventionally compatible goes first here. IFF there is another version, could you shuffle things around? Otherwise,

Thanks,
Conor.

#4 lore raw

Re: [PATCH net-next v5 2/6] dt-bindings: net: Brcm ASP 2.0 Ethernet controller

In reply to Justin Chen
Quoted 39 lines · Justin Chen

From: Florian Fainelli <[email protected]>

Add a binding document for the Broadcom ASP 2.0 Ethernet controller.

---
v5
- Fix compatible string yaml format to properly capture what we want

v4
- Adjust compatible string example to reference SoC and HW ver

v3
- Minor formatting issues
- Change channel prop to brcm,channel for vendor specific format
- Removed redundant v2.0 from compat string
- Fix ranges field

v2
- Minor formatting issues

 .../devicetree/bindings/net/brcm,asp-v2.0.yaml     | 149 +++++++++++++++++++++
 1 file changed, 149 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +6 -0
new file mode 100644
index 000000000000..c4cd24492bfd
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/brcm,asp-v2.0.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 16

Quoted 10 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +10 -0
+title: Broadcom ASP 2.0 Ethernet controller
+
+maintainers:
+  - Justin Chen <[email protected]>
+  - Florian Fainelli <[email protected]>
+
+description: Broadcom Ethernet controller first introduced with 72165
+
+properties:
+  '#address-cells':

Judging by more comments, there will be a v6, thus please also use consistent quotes - either ' or ".

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +5 -0
+    const: 1
+  '#size-cells':
+    const: 1
+
+  compatible:

As Conor pointed out, compatible is always first.

Quoted 37 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +37 -0
+    oneOf:
+      - items:
+          - enum:
+              - brcm,bcm74165-asp
+          - const: brcm,asp-v2.1
+      - items:
+          - enum:
+              - brcm,bcm72165-asp
+          - const: brcm,asp-v2.0
+
+  reg:
+    maxItems: 1
+
+  ranges: true
+
+  interrupts:
+    minItems: 1
+    items:
+      - description: RX/TX interrupt
+      - description: Port 0 Wake-on-LAN
+      - description: Port 1 Wake-on-LAN
+
+  clocks:
+    maxItems: 1
+
+  ethernet-ports:
+    type: object
+    properties:
+      '#address-cells':
+        const: 1
+      '#size-cells':
+        const: 0
+
+    patternProperties:
+      "^port@[0-9]+$":
+        type: object
+

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 68

Quoted 10 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +10 -0
+        $ref: ethernet-controller.yaml#
+
+        properties:
+          reg:
+            maxItems: 1
+            description: Port number
+
+          brcm,channel:
+            $ref: /schemas/types.yaml#/definitions/uint32
+            description: ASP channel number

Why do you need it? reg defines it. Your description does not explain here much, except copying property name. Can we please avoid descriptions which just copy name?

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 77

Quoted 9 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +9 -0
+
+        required:
+          - reg
+          - brcm,channel
+
+    additionalProperties: false
+
+patternProperties:
+  "^mdio@[0-9a-f]+$":

Isn't mdio a property of each ethernet port? Existing users (e.g.bcmgenet, owl-emac, switches) do it that way...

Otherwise how do you define relation-ship? Can one mdio fit multiple ports?

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 88

Quoted 11 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +11 -0
+    type: object
+    $ref: brcm,unimac-mdio.yaml
+
+    description:
+      ASP internal UniMAC MDIO bus
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks

Best regards,
Krzysztof

maintainer
#5 lore raw

Re: [PATCH net-next v5 2/6] dt-bindings: net: Brcm ASP 2.0 Ethernet controller

Quoted 114 lines · Krzysztof Kozlowski
Quoted 39 lines · Justin Chen

From: Florian Fainelli <[email protected]>

Add a binding document for the Broadcom ASP 2.0 Ethernet controller.

---
v5
- Fix compatible string yaml format to properly capture what we want

v4
- Adjust compatible string example to reference SoC and HW ver

v3
- Minor formatting issues
- Change channel prop to brcm,channel for vendor specific format
- Removed redundant v2.0 from compat string
- Fix ranges field

v2
- Minor formatting issues

  .../devicetree/bindings/net/brcm,asp-v2.0.yaml     | 149 +++++++++++++++++++++
  1 file changed, 149 insertions(+)

create mode 100644 Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +6 -0
new file mode 100644
index 000000000000..c4cd24492bfd
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/brcm,asp-v2.0.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 16

Quoted 10 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +10 -0
+title: Broadcom ASP 2.0 Ethernet controller
+
+maintainers:
+  - Justin Chen <[email protected]>
+  - Florian Fainelli <[email protected]>
+
+description: Broadcom Ethernet controller first introduced with 72165
+
+properties:
+  '#address-cells':

Judging by more comments, there will be a v6, thus please also use consistent quotes - either ' or ".

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +5 -0
+    const: 1
+  '#size-cells':
+    const: 1
+
+  compatible:

As Conor pointed out, compatible is always first.

Quoted 37 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +37 -0
+    oneOf:
+      - items:
+          - enum:
+              - brcm,bcm74165-asp
+          - const: brcm,asp-v2.1
+      - items:
+          - enum:
+              - brcm,bcm72165-asp
+          - const: brcm,asp-v2.0
+
+  reg:
+    maxItems: 1
+
+  ranges: true
+
+  interrupts:
+    minItems: 1
+    items:
+      - description: RX/TX interrupt
+      - description: Port 0 Wake-on-LAN
+      - description: Port 1 Wake-on-LAN
+
+  clocks:
+    maxItems: 1
+
+  ethernet-ports:
+    type: object
+    properties:
+      '#address-cells':
+        const: 1
+      '#size-cells':
+        const: 0
+
+    patternProperties:
+      "^port@[0-9]+$":
+        type: object
+

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 68

Quoted 10 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +10 -0
+        $ref: ethernet-controller.yaml#
+
+        properties:
+          reg:
+            maxItems: 1
+            description: Port number
+
+          brcm,channel:
+            $ref: /schemas/types.yaml#/definitions/uint32
+            description: ASP channel number

Why do you need it? reg defines it. Your description does not explain here much, except copying property name. Can we please avoid descriptions which just copy name?

Quoted 12 lines

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 77

Quoted 9 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +9 -0
+
+        required:
+          - reg
+          - brcm,channel
+
+    additionalProperties: false
+
+patternProperties:
+  "^mdio@[0-9a-f]+$":

Isn't mdio a property of each ethernet port? Existing users (e.g.bcmgenet, owl-emac, switches) do it that way...

They are sub-nodes of the larger Ethernet controller block, hence the property here.

Quoted 2 lines

Otherwise how do you define relation-ship? Can one mdio fit multiple ports?

The relationship is established between Ethernet ports and children nodes of the MDIO controller, such as switches or Ethernet PHYs using 'phy-handle' for instance. And yes, a single/common MDIO controller could be serving multiple Ethernet ports.

Signature · 1 line
Florian
#6 lore raw

Re: [PATCH net-next v5 2/6] dt-bindings: net: Brcm ASP 2.0 Ethernet controller

Quoted 12 lines · Florian Fainelli
Quoted 11 lines

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 77

Quoted 8 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +8 -0
+        required:
+          - reg
+          - brcm,channel
+
+    additionalProperties: false
+
+patternProperties:
+  "^mdio@[0-9a-f]+$":

Isn't mdio a property of each ethernet port? Existing users (e.g.bcmgenet, owl-emac, switches) do it that way...

Quoted 2 lines

They are sub-nodes of the larger Ethernet controller block, hence the property here.

This is the Ethernet controller. They are subnodes here, so what do you mean by that? They are part of some other block?

Quoted 8 lines
Quoted 3 lines

Otherwise how do you define relation-ship? Can one mdio fit multiple ports?

The relationship is established between Ethernet ports and children nodes of the MDIO controller, such as switches or Ethernet PHYs using 'phy-handle' for instance. And yes, a single/common MDIO controller could be serving multiple Ethernet ports.

We do not talk about generic case, but your device.

Best regards,
Krzysztof

maintainer
#7 lore raw

Re: [PATCH net-next v5 2/6] dt-bindings: net: Brcm ASP 2.0 Ethernet controller

Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Florian Fainelli
Quoted 11 lines

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 77

Quoted 8 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +8 -0
+        required:
+          - reg
+          - brcm,channel
+
+    additionalProperties: false
+
+patternProperties:
+  "^mdio@[0-9a-f]+$":

Isn't mdio a property of each ethernet port? Existing users (e.g.bcmgenet, owl-emac, switches) do it that way...

Quoted 5 lines
Quoted 2 lines

They are sub-nodes of the larger Ethernet controller block, hence the property here.

This is the Ethernet controller. They are subnodes here, so what do you mean by that? They are part of some other block?

The block is not just an Ethernet controller it has other functions, which is why we went with a top-level node with a 'ranges' property. One of those functions are the MDIO bus controllers. The examples makes it reasonably clear.

Quoted 11 lines
Quoted 9 lines
Quoted 4 lines

Otherwise how do you define relation-ship? Can one mdio fit multiple ports?

The relationship is established between Ethernet ports and children nodes of the MDIO controller, such as switches or Ethernet PHYs using 'phy-handle' for instance. And yes, a single/common MDIO controller could be serving multiple Ethernet ports.

We do not talk about generic case, but your device.

The generic case is true here as well. We so happen to have a 1:1 mapping between the MDIO controller, PHY, and Ethernet port, in this particular example.

Signature · 1 line
Florian
author maintainer
#8 lore raw

Re: [PATCH net-next v5 2/6] dt-bindings: net: Brcm ASP 2.0 Ethernet controller

In reply to Krzysztof Kozlowski
Quoted 105 lines · Krzysztof Kozlowski
Quoted 39 lines · Justin Chen

From: Florian Fainelli <[email protected]>

Add a binding document for the Broadcom ASP 2.0 Ethernet controller.

---
v5
- Fix compatible string yaml format to properly capture what we want

v4
- Adjust compatible string example to reference SoC and HW ver

v3
- Minor formatting issues
- Change channel prop to brcm,channel for vendor specific format
- Removed redundant v2.0 from compat string
- Fix ranges field

v2
- Minor formatting issues

  .../devicetree/bindings/net/brcm,asp-v2.0.yaml     | 149 +++++++++++++++++++++
  1 file changed, 149 insertions(+)

create mode 100644 Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +6 -0
new file mode 100644
index 000000000000..c4cd24492bfd
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/brcm,asp-v2.0.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 16

Quoted 10 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +10 -0
+title: Broadcom ASP 2.0 Ethernet controller
+
+maintainers:
+  - Justin Chen <[email protected]>
+  - Florian Fainelli <[email protected]>
+
+description: Broadcom Ethernet controller first introduced with 72165
+
+properties:
+  '#address-cells':

Judging by more comments, there will be a v6, thus please also use consistent quotes - either ' or ".

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +5 -0
+    const: 1
+  '#size-cells':
+    const: 1
+
+  compatible:

As Conor pointed out, compatible is always first.

Quoted 43 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +43 -0
+    oneOf:
+      - items:
+          - enum:
+              - brcm,bcm74165-asp
+          - const: brcm,asp-v2.1
+      - items:
+          - enum:
+              - brcm,bcm72165-asp
+          - const: brcm,asp-v2.0
+
+  reg:
+    maxItems: 1
+
+  ranges: true
+
+  interrupts:
+    minItems: 1
+    items:
+      - description: RX/TX interrupt
+      - description: Port 0 Wake-on-LAN
+      - description: Port 1 Wake-on-LAN
+
+  clocks:
+    maxItems: 1
+
+  ethernet-ports:
+    type: object
+    properties:
+      '#address-cells':
+        const: 1
+      '#size-cells':
+        const: 0
+
+    patternProperties:
+      "^port@[0-9]+$":
+        type: object
+
+        $ref: ethernet-controller.yaml#
+
+        properties:
+          reg:
+            maxItems: 1
+            description: Port number
Quoted 9 lines

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml line 68

Quoted 4 lines
Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml new file +4 -0
+
+          brcm,channel:
+            $ref: /schemas/types.yaml#/definitions/uint32
+            description: ASP channel number

Why do you need it? reg defines it. Your description does not explain here much, except copying property name. Can we please avoid descriptions which just copy name?

Will add a better description. The values may be different.

Thanks,
Justin

author maintainer
#9 lore raw

PATCH v5 3/6 net: bcmasp: Add support for ASP2.0 Ethernet controller

In reply to Justin Chen

Add support for the Broadcom ASP 2.0 Ethernet controller which is first introduced with 72165. This controller features two distinct Ethernet ports that can be independently operated.

This patch supports:

- Wake-on-LAN using magic packets
- basic ethtool operations (link, counters, message level)
- MAC destination address filtering (promiscuous, ALL_MULTI, etc.)

---
v5
- Remove unnecessary parenthesis
- Use bool for bcmasp_netfilt_check_dup()

v4
- Address sparse warnings
- Fix one more reverse xmas tree violation
- Improve error logic for bcmasp_netfilt_get_reg_offset()
- Remove inlines

v3
- Fix logic error with net stats where some stats were missing
- General clean up addressing formatting/spelling/consistency
- Use dev_err_probe to save a few LoCs
- Use put_unaligned when updating net stats

v2
- Replace a couple functions with helper functions
- Fix a few WoL issues

 drivers/net/ethernet/broadcom/Kconfig              |   11 +
 drivers/net/ethernet/broadcom/Makefile             |    1 +
 drivers/net/ethernet/broadcom/asp2/Makefile        |    2 +
 drivers/net/ethernet/broadcom/asp2/bcmasp.c        | 1462 ++++++++++++++++++++
 drivers/net/ethernet/broadcom/asp2/bcmasp.h        |  637 +++++++++
 .../net/ethernet/broadcom/asp2/bcmasp_ethtool.c    |  568 ++++++++
 drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c   | 1425 +++++++++++++++++++
 .../net/ethernet/broadcom/asp2/bcmasp_intf_defs.h  |  238 ++++
 8 files changed, 4344 insertions(+)
 create mode 100644 drivers/net/ethernet/broadcom/asp2/Makefile
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp.c
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp.h
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
 create mode 100644 drivers/net/ethernet/broadcom/asp2/bcmasp_intf_defs.h
drivers/net/ethernet/broadcom/Kconfig +11 -0
index 948586bf1b5b..d4166141145d 100644
@@ -255,4 +255,15 @@ config BNXT_HWMON
 	  Say Y if you want to expose the thermal sensor data on NetXtreme-C/E
 	  devices, via the hwmon sysfs interface.
 
+config BCMASP
+	tristate "Broadcom ASP 2.0 Ethernet support"
+	default ARCH_BRCMSTB
+	depends on OF
+	select MII
+	select PHYLIB
+	select MDIO_BCM_UNIMAC
+	help
+	  This configuration enables the Broadcom ASP 2.0 Ethernet controller
+	  driver which is present in Broadcom STB SoCs such as 72165.
+
 endif # NET_VENDOR_BROADCOM
drivers/net/ethernet/broadcom/Makefile +1 -0
index 0ddfb5b5d53c..bac5cb6ad0cd 100644
@@ -17,3 +17,4 @@ obj-$(CONFIG_BGMAC_BCMA) += bgmac-bcma.o bgmac-bcma-mdio.o
 obj-$(CONFIG_BGMAC_PLATFORM) += bgmac-platform.o
 obj-$(CONFIG_SYSTEMPORT) += bcmsysport.o
 obj-$(CONFIG_BNXT) += bnxt/
+obj-$(CONFIG_BCMASP) += asp2/
drivers/net/ethernet/broadcom/asp2/Makefile new file +2 -0
new file mode 100644
index 000000000000..e07550315f83
@@ -0,0 +1,2 @@
+obj-$(CONFIG_BCMASP) += bcm-asp.o
+bcm-asp-objs := bcmasp.o bcmasp_intf.o bcmasp_ethtool.o
drivers/net/ethernet/broadcom/asp2/bcmasp.c new file +1462 -0

1,462 lines not on this page · raw message

drivers/net/ethernet/broadcom/asp2/bcmasp.h new file +637 -0

637 lines not on this page · raw message

drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c new file +568 -0

568 lines not on this page · raw message

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +1425 -0

312 lines not on this page · raw message

drivers/net/ethernet/broadcom/asp2/bcmasp_intf_defs.h new file +238 -0

238 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

maintainer
#10 lore raw

Re: [PATCH net-next v5 3/6] net: bcmasp: Add support for ASP2.0 Ethernet controller

Quoted 15 lines · On Wed, 24 May 2023 16:01:50 -0700 Justin Chen wrote:

Add support for the Broadcom ASP 2.0 Ethernet controller which is first introduced with 72165. This controller features two distinct Ethernet ports that can be independently operated.

This patch supports:

- Wake-on-LAN using magic packets
- basic ethtool operations (link, counters, message level)
- MAC destination address filtering (promiscuous, ALL_MULTI, etc.)

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +5 -0
+static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct bcmasp_intf *intf = netdev_priv(dev);
+	int spb_index, nr_frags, ret, i, j;
+	unsigned int total_bytes, size;

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c line 287

Quoted 10 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +10 -0
+	struct bcmasp_tx_cb *txcb;
+	dma_addr_t mapping, valid;
+	struct bcmasp_desc *desc;
+	bool csum_hw = false;
+	struct device *kdev;
+	skb_frag_t *frag;
+
+	kdev = &intf->parent->pdev->dev;
+
+	spin_lock(&intf->tx_lock);

What is the tx_lock for? netdevs already have a tx lock, unless you declare the device as lockless.

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c line 1146

Quoted 10 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +10 -0
+static void bcmasp_tx_timeout(struct net_device *dev, unsigned int txqueue)
+{
+	struct bcmasp_intf *intf = netdev_priv(dev);
+
+	netif_dbg(intf, tx_err, dev, "transmit timeout!\n");
+
+	netif_trans_update(dev);
+	dev->stats.tx_errors++;
+
+	netif_wake_queue(dev);

If the queue is full xmit will just put it back to sleep. You want to try to reap completions if anything, no?

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c line 1163

Quoted 4 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +4 -0
+static struct net_device_stats *bcmasp_get_stats(struct net_device *dev)
+{
+	return &dev->stats;
+}

you don't have to do this, core will use device stats if there's no ndo

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c line 1227

Quoted 2 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +2 -0
+	ndev = alloc_etherdev(sizeof(struct bcmasp_intf));
+	if (!dev) {

*blink* condition is typo'ed

Quoted 3 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +3 -0
+		dev_warn(dev, "%s: unable to alloc ndev\n", ndev_dn->name);
+		goto err;
+	}
Signature · 1 line
pw-bot: cr
author maintainer
#11 lore raw

Re: [PATCH net-next v5 3/6] net: bcmasp: Add support for ASP2.0 Ethernet controller

Quoted 21 lines · Jakub Kicinski
Quoted 20 lines · On Wed, 24 May 2023 16:01:50 -0700 Justin Chen wrote:

Add support for the Broadcom ASP 2.0 Ethernet controller which is first introduced with 72165. This controller features two distinct Ethernet ports that can be independently operated.

This patch supports:

- Wake-on-LAN using magic packets
- basic ethtool operations (link, counters, message level)
- MAC destination address filtering (promiscuous, ALL_MULTI, etc.)

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +10 -0
+static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct bcmasp_intf *intf = netdev_priv(dev);
+	int spb_index, nr_frags, ret, i, j;
+	unsigned int total_bytes, size;
+	struct bcmasp_tx_cb *txcb;
+	dma_addr_t mapping, valid;
+	struct bcmasp_desc *desc;
+	bool csum_hw = false;
+	struct device *kdev;
Quoted 9 lines

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c line 287

Quoted 5 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +5 -0
+	skb_frag_t *frag;
+
+	kdev = &intf->parent->pdev->dev;
+
+	spin_lock(&intf->tx_lock);

What is the tx_lock for? netdevs already have a tx lock, unless you declare the device as lockless.

Will remove.

Quoted 5 lines
Quoted 5 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +5 -0
+static void bcmasp_tx_timeout(struct net_device *dev, unsigned int txqueue)
+{
+	struct bcmasp_intf *intf = netdev_priv(dev);
+
+	netif_dbg(intf, tx_err, dev, "transmit timeout!\n");
Quoted 9 lines

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c line 1146

Quoted 5 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +5 -0
+
+	netif_trans_update(dev);
+	dev->stats.tx_errors++;
+
+	netif_wake_queue(dev);

If the queue is full xmit will just put it back to sleep. You want to try to reap completions if anything, no?

I can remove the wake. As you mentioned it won't do anything here. There isn't anything to reap if we are in the timeout condition. If it is some HW stall, we could flush and restart the ring, but if that is the case I rather figure out why the HW is stalling. I think we can leave it as a "tell the user we are stalled" and leave it as that.

Quoted 7 lines

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c line 1163

Quoted 4 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +4 -0
+static struct net_device_stats *bcmasp_get_stats(struct net_device *dev)
+{
+	return &dev->stats;
+}

you don't have to do this, core will use device stats if there's no ndo

Quoted 5 lines

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c line 1227

Quoted 2 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +2 -0
+	ndev = alloc_etherdev(sizeof(struct bcmasp_intf));
+	if (!dev) {

*blink* condition is typo'ed

Oops. Good catch.

Thanks,
Justin

Quoted 4 lines
Quoted 3 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +3 -0
+		dev_warn(dev, "%s: unable to alloc ndev\n", ndev_dn->name);
+		goto err;
+	}
maintainer
#12 lore raw

Re: [PATCH net-next v5 3/6] net: bcmasp: Add support for ASP2.0 Ethernet controller

In reply to Justin Chen
Quoted 14 lines · Justin Chen

Add support for the Broadcom ASP 2.0 Ethernet controller which is first introduced with 72165. This controller features two distinct Ethernet ports that can be independently operated.

This patch supports:

- Wake-on-LAN using magic packets
- basic ethtool operations (link, counters, message level)
- MAC destination address filtering (promiscuous, ALL_MULTI, etc.)

---

[snip]

drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c line 1184

Quoted 9 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c new file +9 -0
+static const struct net_device_ops bcmasp_netdev_ops = {
+	.ndo_open		= bcmasp_open,
+	.ndo_stop		= bcmasp_stop,
+	.ndo_start_xmit		= bcmasp_xmit,
+	.ndo_tx_timeout		= bcmasp_tx_timeout,
+	.ndo_set_rx_mode	= bcmasp_set_rx_mode,
+	.ndo_get_phys_port_name	= bcmasp_get_phys_port_name,
+	.ndo_get_stats		= bcmasp_get_stats,
+	.ndo_do_ioctl		= bcmasp_ioctl,

This needs to be:

@@ -1207,7 +1196,7 @@ static const struct net_device_ops bcmasp_netdev_ops = {
.ndo_set_rx_mode = bcmasp_set_rx_mode,
.ndo_get_phys_port_name = bcmasp_get_phys_port_name,
.ndo_get_stats = bcmasp_get_stats,

-       .ndo_do_ioctl           = bcmasp_ioctl,
+       .ndo_eth_ioctl          = phy_do_ioctl_running,
        .ndo_set_mac_address    = bcmasp_set_mac_address,

};

such that MII ioctls work properly.

Signature · 1 line
Florian
author maintainer
#13 lore raw

PATCH v5 4/6 net: phy: mdio-bcm-unimac: Add asp v2.0 support

In reply to Justin Chen

Add mdio compat string for ASP 2.0 ethernet driver.

---
 drivers/net/mdio/mdio-bcm-unimac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/mdio/mdio-bcm-unimac.c +2 -0
index bfc9be23c973..6b26a0803696 100644
@@ -334,6 +334,8 @@ static SIMPLE_DEV_PM_OPS(unimac_mdio_pm_ops,
 			 unimac_mdio_suspend, unimac_mdio_resume);
 
 static const struct of_device_id unimac_mdio_ids[] = {
+	{ .compatible = "brcm,asp-v2.1-mdio", },
+	{ .compatible = "brcm,asp-v2.0-mdio", },
 	{ .compatible = "brcm,genet-mdio-v5", },
 	{ .compatible = "brcm,genet-mdio-v4", },
 	{ .compatible = "brcm,genet-mdio-v3", },
Signature · 1 line
2.7.4
author maintainer
#14 lore raw

PATCH v5 5/6 net: phy: bcm7xxx: Add EPHY entry for 74165

In reply to Justin Chen

From: Florian Fainelli <[email protected]>

74165 is a 16nm process SoC with a 10/100 integrated Ethernet PHY, utilize the recently defined 16nm EPHY macro to configure that PHY.

---
 drivers/net/phy/bcm7xxx.c | 1 +
 include/linux/brcmphy.h   | 1 +
 2 files changed, 2 insertions(+)
drivers/net/phy/bcm7xxx.c +1 -0
index f8c17a253f8b..8478b081c058 100644
@@ -913,6 +913,7 @@ static struct phy_driver bcm7xxx_driver[] = {
 	BCM7XXX_28NM_GPHY(PHY_ID_BCM7278, "Broadcom BCM7278"),
 	BCM7XXX_28NM_GPHY(PHY_ID_BCM7364, "Broadcom BCM7364"),
 	BCM7XXX_28NM_GPHY(PHY_ID_BCM7366, "Broadcom BCM7366"),
+	BCM7XXX_16NM_EPHY(PHY_ID_BCM74165, "Broadcom BCM74165"),
 	BCM7XXX_28NM_GPHY(PHY_ID_BCM74371, "Broadcom BCM74371"),
 	BCM7XXX_28NM_GPHY(PHY_ID_BCM7439, "Broadcom BCM7439"),
 	BCM7XXX_28NM_GPHY(PHY_ID_BCM7439_2, "Broadcom BCM7439 (2)"),
include/linux/brcmphy.h +1 -0
index e9afbfb6d7a5..409ec9d35051 100644
@@ -44,6 +44,7 @@
 #define PHY_ID_BCM7366			0x600d8490
 #define PHY_ID_BCM7346			0x600d8650
 #define PHY_ID_BCM7362			0x600d84b0
+#define PHY_ID_BCM74165			0x359052c0
 #define PHY_ID_BCM7425			0x600d86b0
 #define PHY_ID_BCM7429			0x600d8730
 #define PHY_ID_BCM7435			0x600d8750
Signature · 1 line
2.7.4
author maintainer
#15 lore raw

PATCH v5 6/6 MAINTAINERS: ASP 2.0 Ethernet driver maintainers

In reply to Justin Chen

Add maintainers entry for ASP 2.0 Ethernet driver.

---
v3
- Change from gmail to broadcom emails

 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
index e2fd64c2ebdc..732a099f4a10 100644
@@ -4198,6 +4198,15 @@ F:	drivers/net/mdio/mdio-bcm-unimac.c
 F:	include/linux/platform_data/bcmgenet.h
 F:	include/linux/platform_data/mdio-bcm-unimac.h
 
+BROADCOM ASP 2.0 ETHERNET DRIVER
+M:	Justin Chen <[email protected]>
+M:	Florian Fainelli <[email protected]>
+L:	[email protected]
+L:	[email protected]
+S:	Supported
+F:	Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml
+F:	drivers/net/ethernet/broadcom/asp2/
+
 BROADCOM IPROC ARM ARCHITECTURE
 M:	Ray Jui <[email protected]>
 M:	Scott Branden <[email protected]>
Signature · 1 line
2.7.4