# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/wiznet,w5100.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Wiznet w5100/w5200/w5500 SPI Ethernet Controller

maintainers:
  - Arthur Crepin Leblond <arthur@marmottus.net>

description: |
  This is a standalone 10/100 MBit Ethernet controller with SPI interface.

properties:
  compatible:
    enum:
      - wiznet,w5100
      - wiznet,w5200
      - wiznet,w5500

  interrupts:
    minItems: 1
    description:
      The main interrupt (INT pin) is mandatory on all devices. The w5500
      additionally supports an optional second interrupt for link status changes
      (LINKLED pin). If it is not specified, link state changes will not be
      reported.
    items:
      - description: Main interrupt (INT pin on the device).
      - description:
          Optional interrupt for link status changes (LINKLED pin on w5500).

  reg:
    maxItems: 1

  spi-max-frequency:
    description:
      According to the datasheets, w5500 and w5200 allow a maximum of 80 MHz
      while w5100 is reported by users to allow a maximum of 14 MHz. However,
      board designs may need to limit this value.
    maximum: 80000000

required:
  - compatible
  - reg
  - interrupts

allOf:
  - $ref: /schemas/net/ethernet-controller.yaml#
  - $ref: /schemas/spi/spi-peripheral-props.yaml#
  - if:
      not:
        properties:
          compatible:
            contains:
              enum:
                - wiznet,w5500
    then:
      properties:
        interrupts:
          maxItems: 1

unevaluatedProperties: false

examples:
  - |
    /* Example (for Raspberry Pi with pin control stuff for GPIO irq) */

    #include <dt-bindings/interrupt-controller/irq.h>

    spi {
        #address-cells = <1>;
        #size-cells = <0>;

        ethernet@0 {
            compatible = "wiznet,w5500";
            reg = <0>;
            interrupt-parent = <&gpio>;
            interrupts = <25 IRQ_TYPE_LEVEL_LOW>,
                         <24 IRQ_TYPE_EDGE_BOTH>;
            local-mac-address = [ a0 b0 c0 d0 e0 f0 ];
            pinctrl-0 = <&eth1_pins>;
            pinctrl-names = "default";
            spi-max-frequency = <30000000>;
        };
    };
...