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

title: Texas Instruments OMAP SCM bandgap

maintainers:
  - Eduardo Valentin <edubezval@gmail.com>

description:
  In the System Control Module, OMAP supplies a voltage reference and a
  temperature sensor feature that are gathered in the band gap voltage and
  temperature sensor (VBGAPTS) module. The band gap provides current and
  voltage reference for its internal circuits and other analog IP blocks. The
  analog-to-digital converter (ADC) produces an output value that is
  proportional to the silicon temperature.

properties:
  compatible:
    enum:
      - ti,omap34xx-bandgap
      - ti,omap36xx-bandgap
      - ti,omap4430-bandgap
      - ti,omap4460-bandgap
      - ti,omap4470-bandgap
      - ti,omap5430-bandgap
      - ti,dra752-bandgap

  reg:
    minItems: 1
    maxItems: 6

  interrupts:
    maxItems: 1

  gpios:
    maxItems: 1
    description:
      used to inform which GPIO line the tshut signal is routed to. The
      informed GPIO will be treated as an IRQ;

  "#thermal-sensor-cells":
    enum: [0, 1]

required:
  - compatible
  - reg

allOf:
  - $ref: thermal-sensor.yaml#

  - if:
      properties:
        compatible:
          contains:
            enum:
              - ti,omap34xx-bandgap
              - ti,omap36xx-bandgap

    then:
      properties:
        reg:
          minItems: 1
          maxItems: 1

        interrupts: false

        gpios: false

        "#thermal-sensor-cells":
          const: 0

  - if:
      properties:
        compatible:
          contains:
            const: ti,omap4430-bandgap

    then:
      properties:
        reg:
          minItems: 2
          maxItems: 2

        interrupts: false

        "#thermal-sensor-cells":
          const: 0

      required:
        - gpios

  - if:
      properties:
        compatible:
          contains:
            enum:
              - ti,omap4460-bandgap
              - ti,omap4470-bandgap

    then:
      properties:
        reg:
          minItems: 3
          maxItems: 3

        "#thermal-sensor-cells":
          const: 0

      required:
        - interrupts
        - gpios

  - if:
      properties:
        compatible:
          contains:
            const: ti,omap5430-bandgap

    then:
      properties:
        reg:
          minItems: 4
          maxItems: 4

        gpios: false

        "#thermal-sensor-cells":
          const: 1

      required:
        - interrupts

  - if:
      properties:
        compatible:
          contains:
            const: ti,dra752-bandgap

    then:
      properties:
        reg:
          minItems: 6
          maxItems: 6

        gpios: false

        "#thermal-sensor-cells":
          const: 1

      required:
        - interrupts

unevaluatedProperties: false

examples:
  - |
    bandgap@48002524 {
        compatible = "ti,omap34xx-bandgap";
        reg = <0x48002524 0x4>;
        #thermal-sensor-cells = <0>;
    };

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

    bandgap@4a0021e0 {
        compatible = "ti,dra752-bandgap";
        reg = <0x4a0021e0 0xc>, <0x4a00232c 0xc>,
              <0x4a002380 0x2c>, <0x4a0023c0 0x3c>,
              <0x4a002564 0x8>, <0x4a002574 0x50>;
        interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>; /* talert */
        #thermal-sensor-cells = <1>;
    };