# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/mfd/wlf,arizona.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Cirrus Logic/Wolfson Microelectronics Arizona class audio SoCs

maintainers:
  - patches@opensource.cirrus.com

description: |
  These devices are audio SoCs with extensive digital capabilities and a
  range of analogue I/O.

allOf:
  - $ref: /schemas/sound/wlf,arizona.yaml#
  - $ref: /schemas/regulator/wlf,arizona.yaml#
  - $ref: /schemas/extcon/wlf,arizona.yaml#
  - if:
      properties:
        compatible:
          contains:
            enum:
              - cirrus,cs47l24
              - wlf,wm1831
    then:
      required:
        - DCVDD-supply
        - MICVDD-supply
    else:
      properties:
        LDOVDD-supply:
          description:
            Digital power supply, used internally to generate DCVDD when
            internally supplied.

  - if:
      properties:
        compatible:
          contains:
            enum:
              - wlf,wm1814
              - wlf,wm5102
              - wlf,wm5110
              - wlf,wm8280
              - wlf,wm8997
              - wlf,wm8998
    then:
      properties:
        DBVDD2-supply:
          description:
            Databus power supply.

      required:
        - DBVDD2-supply
  - if:
      properties:
        compatible:
          contains:
            enum:
              - wlf,wm1814
              - wlf,wm5102
              - wlf,wm5110
              - wlf,wm8280
              - wlf,wm8998
    then:
      properties:
        DBVDD3-supply:
          description:
            Databus power supply.

      required:
        - DBVDD3-supply
  - if:
      properties:
        compatible:
          contains:
            enum:
              - cirrus,cs47l24
              - wlf,wm1831
              - wlf,wm8997
    then:
      properties:
        SPKVDD-supply:
          description:
            Mono speaker driver power supply.

      required:
        - SPKVDD-supply
    else:
      properties:
        SPKVDDL-supply:
          description:
            Left speaker driver power supply.

        SPKVDDR-supply:
          description:
            Right speaker driver power supply.

      required:
        - SPKVDDL-supply
        - SPKVDDR-supply

properties:
  compatible:
    enum:
      - cirrus,cs47l24
      - wlf,wm1814
      - wlf,wm1831
      - wlf,wm5102
      - wlf,wm5110
      - wlf,wm8280
      - wlf,wm8997
      - wlf,wm8998

  reg:
    maxItems: 1

  AVDD-supply:
    description:
      Analogue power supply.

  CPVDD-supply:
    description:
      Charge pump power supply.

  DBVDD1-supply:
    description:
      Databus power supply.

  DCVDD-supply:
    description:
      Digital power supply, normally supplied internally except on cs47l24,
      wm1831 where it is mandatory.

  MICVDD-supply:
    description:
      Microphone power supply, normally supplied internally except on
      cs47l24, wm1831 where it is mandatory.

  gpio-controller: true

  '#gpio-cells':
    description:
      The first cell is the pin number and the second cell is used to
      specify optional parameters.
    const: 2

  wlf,gpio-defaults:
    description:
      A list of GPIO configuration register values. Defines for the
      appropriate values can found in dt-bindings/mfd/arizona.h. If
      absent, no configuration of these registers is performed. If any
      entry has a value that is out of range for a 16 bit register then the
      chip default will be used. If present exactly five values must be
      specified.
    $ref: "/schemas/types.yaml#/definitions/uint32-array"
    minItems: 1
    maxItems: 5

  interrupt-controller: true

  '#interrupt-cells':
    description:
      The first cell is the IRQ number.  The second cell is the flags,
      encoded as trigger masks.
    const: 2

  interrupts:
    maxItems: 1

  clocks:
    description:
      Should reference the clocks supplied on MCLK1 and MCLK2.
    minItems: 1
    maxItems: 2

  clock-names:
    description:
      Should contains two strings mclk1 for the clock supplied on MCLK1,
      recommended to be a high quality audio reference clock mclk2 for the
      clock supplied on MCLK2, recommended to be an always on 32k clock.
    oneOf:
      - items:
          - const: mclk1
      - items:
          - const: mclk2
      - items:
          - const: mclk1
          - const: mclk2

  reset-gpios:
    maxItems: 1

  wlf,reset:
    description:
      GPIO specifier for the GPIO controlling RESET
    deprecated: true
    $ref: /schemas/types.yaml#/definitions/phandle-array
    maxItems: 1

required:
  - compatible
  - AVDD-supply
  - CPVDD-supply
  - DBVDD1-supply
  - gpio-controller
  - '#gpio-cells'
  - interrupt-controller
  - '#interrupt-cells'
  - interrupts

unevaluatedProperties: false

examples:
  - |
    #include <dt-bindings/mfd/arizona.h>
    i2c@e0004000 {
        #address-cells = <1>;
        #size-cells = <0>;
        reg = <0xe0004000 0x1000>;

        wm5102: codec@1a {
            compatible = "wlf,wm5102";
            reg = <0x1a>;

            reset-gpios = <&gpio 0>;
            wlf,ldoena = <&gpio 1>;

            AVDD-supply = <&vdd1v8>;
            DBVDD1-supply = <&vdd1v8>;
            DBVDD2-supply = <&vdd1v8>;
            DBVDD3-supply = <&vdd1v8>;
            CPVDD-supply = <&vdd1v8>;
            LDOVDD-supply = <&vdd1v8>;
            SPKVDDL-supply = <&vdd5v>;
            SPKVDDR-supply = <&vdd5v>;

            interrupts = <347>;
            interrupt-controller;
            #interrupt-cells = <2>;
            interrupt-parent = <&gic>;

            gpio-controller;
            #gpio-cells = <2>;

            #sound-dai-cells = <1>;

            wlf,gpio-defaults = <
                ARIZONA_GP_FN_TXLRCLK
                ARIZONA_GP_DEFAULT
                ARIZONA_GP_DEFAULT
                ARIZONA_GP_DEFAULT
                ARIZONA_GP_DEFAULT
            >;

            clocks = <&clks 0>, <&clks 1>;
            clock-names = "mclk1", "mclk2";

            wlf,inmode = <ARIZONA_INMODE_DIFF ARIZONA_INMODE_DMIC>;
            wlf,dmic-ref = <ARIZONA_DMIC_MICBIAS1 ARIZONA_DMIC_MICBIAS3>;

            wlf,use-jd2;
            wlf,use-jd2-nopull;
            wlf,jd-invert;

            wlf,micd-software-compare;
            wlf,micd-detect-debounce = <0>;
            wlf,micd-pol-gpio = <&codec 2 0>;
            wlf,micd-rate = <ARIZONA_MICD_TIME_8MS>;
            wlf,micd-dbtime = <4>;
            wlf,micd-timeout-ms = <100>;
            wlf,micd-force-micbias;
            wlf,micd-configs = <0 ARIZONA_DMIC_MICBIAS1 0>,
                               <0x2000 ARIZONA_DMIC_MICBIAS2 1>;

            wlf,gpsw = <ARIZONA_GPSW_OPEN>;
        };
    };
