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

title: StarFive JHB100 Peripheral-0 Pin Controller

description: |
  Pinctrl bindings for JHB100 RISC-V SoC from StarFive Technology Ltd.

  The JHB100 SoC has 13 pinctrl domains - sys0, sys0h, sys1, sys2, per0, per1,
  per2, per2pok, per3, adc0, adc1, emmc, and vga.
  This document provides an overview of the "per0" pinctrl domain.

  The "per0" domain has a pin controller which provides
  - function selection for GPIO pads.
  - GPIO pad configuration.
  - GPIO interrupt handling.

  In the Peripheral-0  Pin Controller, there are 60 multi-function GPIO_PADs.
  Each of them can be multiplexed to several hardware blocks through function
  selection. Each iopad has a maximum of up to 3 functions - 0, 1, and 2.
  Function 0 is the default function which is generally the GPIO function.
  Function 1 and 2 are the alternate function or signal of an iopad.  The
  function 1 and function 2 are other optional functions or peripheral
  signals that can be routed to an iopad. The function selection can be carried
  out by writing the function number to the iopad function select register.

  Each iopad is configurable with parameters such as input-enable, internal
  pull-up/pull-down bias, drive strength, schmitt trigger, slew rate, input
  debounce nanoseconds, power source and drive type (open-drain or push-pull).

maintainers:
  - Changhuang Liang <changhuang.liang@starfivetech.com>

properties:
  compatible:
    items:
      - const: starfive,jhb100-per0-pinctrl

  reg:
    maxItems: 1

  clocks:
    maxItems: 1

  resets:
    maxItems: 1

  interrupts:
    maxItems: 1

  interrupt-controller: true

  '#interrupt-cells':
    const: 2

  gpio-controller: true

  '#gpio-cells':
    const: 2

  gpio-ranges: true

  gpio-line-names: true

patternProperties:
  '-grp$':
    type: object
    additionalProperties: false
    patternProperties:
      '-pins$':
        type: object
        description: |
          A pinctrl node should contain at least one subnode representing the
          pinctrl groups available in the domain. Each subnode will list the
          pins it needs, and how they should be configured, with regard to
          function selection, bias, input enable/disable, input schmitt
          trigger enable/disable, slew-rate, input debounce nanoseconds,
          drive-open-drain, drive-push-pull, power-source and drive-strength.
        allOf:
          - $ref: /schemas/pinctrl/pincfg-node.yaml
          - $ref: /schemas/pinctrl/pinmux-node.yaml
        additionalProperties: false

        properties:
          pins:
            description:
              The list of IOs that properties in the pincfg node apply to.

          function:
            description:
              A string containing the name of the function to mux for these
              pins.
            enum: [ gmac_mdio, gpio, i2c, i3c, smbalert, wdt ]

          bias-disable: true

          bias-pull-down:
            type: boolean

          bias-pull-up:
            oneOf:
              - type: boolean
              - enum: [ 600, 900, 1200, 2000 ]
                description: Pull up RSEL type resistance values (in ohms)
            description:
              For normal pull up type there is no need to specify a resistance
              value, hence this can be specified as a boolean property.
              For RSEL pull up type a resistance value (in ohms) can be added.

          drive-open-drain: true

          drive-push-pull: true

          drive-strength:
            enum: [ 2, 4, 8, 12 ]

          drive-strength-microamp:
            enum: [ 2000, 4000, 8000, 12000 ]

          input-debounce-ns:
            minimum: 0
            maximum: 10485680
            description:
              Debounce time in nanoseconds. The hardware counts in 80 ns
              stages with a 17-bit counter, so the maximum is 10485680 ns.

          input-disable: true

          input-enable: true

          input-schmitt-enable: true

          input-schmitt-disable: true

          power-source:
            enum: [ 1800, 3300 ]
            description: I/O voltage in millivolt.

          slew-rate:
            enum: [ 0, 1 ]
            default: 0
            description: |
                0: slow
                1: fast

required:
  - compatible
  - reg
  - resets
  - interrupts
  - interrupt-controller
  - '#interrupt-cells'
  - gpio-controller
  - '#gpio-cells'
  - gpio-ranges

additionalProperties: false

examples:
  - |
    soc {
        #address-cells = <2>;
        #size-cells = <2>;

        pinctrl_per0: pinctrl@11a0a000 {
            compatible = "starfive,jhb100-per0-pinctrl";
            reg = <0x0 0x11a0a000 0x0 0x1000>;
            resets = <&per0crg 0>;
            interrupts = <60>;
            interrupt-controller;
            #interrupt-cells = <2>;
            gpio-controller;
            #gpio-cells = <2>;
            gpio-ranges = <&pinctrl_per0 0 0 60>;
        };
    };