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

title: TI Palmas Pincontrol

maintainers:
  - Laxman Dewangan <ldewangan@nvidia.com>

description:
  The pins of Palmas device can be set on different option and provides
  the configuration for Pull UP/DOWN, open drain etc.

allOf:
  - $ref: pinctrl.yaml#

properties:
  compatible:
    enum:
      - ti,palmas-pinctrl
      - ti,tps65913-pinctrl
      - ti,tps80036-pinctrl

  ti,palmas-enable-dvfs1:
    type: boolean
    description:
      Enable DVFS1. Configure pins for DVFS1 mode.
      Selection primary or secondary function associated to I2C2_SCL_SCE,
      I2C2_SDA_SDO pin/pad for DVFS1 interface.

  ti,palmas-enable-dvfs2:
    type: boolean
    description:
      Enable DVFS2. Configure pins for DVFS2 mode.
      Selection primary or secondary function associated to GPADC_START
      and SYSEN2 pin/pad for DVFS2 interface.

  ti,palmas-override-powerhold:
    type: boolean
    description:
      This is applicable for PMICs for which GPIO7 is configured in POWERHOLD
      mode which has higher priority over DEV_ON bit and keeps the PMIC
      supplies on even after the DEV_ON bit is turned off. This property enables
      driver to over ride the POWERHOLD value to GPIO7 so as to turn off the PMIC
      in power off scenarios. So for GPIO7 if ti,palmas-override-powerhold is set
      then the GPIO_7 field should never be muxed to anything else.
      It should be set to POWERHOLD by default and only in case of
      power off scenarios the driver will over ride the mux value.

patternProperties:
  '^(pinmux|pins?-[a-z0-9-]+)$':
    type: object
    additionalProperties: false
    patternProperties:
      '^(pin.*|gpio[0-9]+|vac|powergood|nreswarm|pwrdown|gpadc_start|reset_in|nsleep|enable[12]|int)$':
        type: object
        allOf:
          - $ref: /schemas/pinctrl/pinmux-node.yaml
          - $ref: /schemas/pinctrl/pincfg-node.yaml
        unevaluatedProperties: false
        properties:
          pins:
            items:
              enum:
                - gpio0
                - gpio1
                - gpio2
                - gpio3
                - gpio4
                - gpio5
                - gpio6
                - gpio7
                - gpio8
                - gpio9
                - gpio10
                - gpio11
                - gpio12
                - gpio13
                - gpio14
                - gpio15
                - vac
                - powergood
                - nreswarm
                - pwrdown
                - gpadc_start
                - reset_in
                - nsleep
                - enable1
                - enable2
                - int

          function:
            description:
              Selects the mux function. There are 4 special functions opt0,
              opt1, opt2 and opt3. If any of these functions is selected then
              directly pins register will be written with 0, 1, 2 or 3
              respectively if it is valid for that pin or list of pins.
            enum:
              - gpio
              - led
              - pwm
              - regen
              - sysen
              - clk32kgaudio
              - id
              - vbus_det
              - chrg_det
              - vac
              - vacok
              - powergood
              - usb_psel
              - msecure
              - pwrhold
              - int
              - nreswarm
              - simrsto
              - simrsti
              - low_vbat
              - wireless_chrg1
              - rcm
              - pwrdown
              - gpadc_start
              - reset_in
              - nsleep
              - enable
              - opt0
              - opt1
              - opt2
              - opt3

        required:
          - pins

required:
  - compatible

unevaluatedProperties: false

examples:
  - |
    pmic {
        pinctrl {
            compatible = "ti,tps65913-pinctrl";
            ti,palmas-enable-dvfs1;
            pinctrl-names = "default";
            pinctrl-0 = <&palmas_pins_state>;

            pinmux {
                gpio0 {
                    pins = "gpio0";
                    function = "id";
                    bias-pull-up;
                };

                vac {
                    pins = "vac";
                    function = "vacok";
                    bias-pull-down;
                };

                gpio5 {
                    pins = "gpio5";
                    function = "opt0";
                    drive-open-drain = <1>;
                };
            };
        };
    };