# 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 <justin.chen@broadcom.com>
  - Florian Fainelli <florian.fainelli@broadcom.com>

description: Broadcom Ethernet controller first introduced with 72165

properties:
  compatible:
    oneOf:
      - items:
          - enum:
              - brcm,bcm74165-asp
          - const: brcm,asp-v2.1
      - items:
          - enum:
              - brcm,bcm72165-asp
          - const: brcm,asp-v2.0

  "#address-cells":
    const: 1
  "#size-cells":
    const: 1

  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#

        unevaluatedProperties: false

        properties:
          reg:
            maxItems: 1
            description: Port number

          brcm,channel:
            $ref: /schemas/types.yaml#/definitions/uint32
            description: |
              ASP Channel Number

              The depacketizer channel that consumes packets from
              the unimac/port.

        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>;
            };
        };
    };
