Commit 612a0f0b authored by AngeloGioacchino Del Regno's avatar AngeloGioacchino Del Regno Committed by Dmitry Torokhov
Browse files

dt-bindings: input: Convert mtk-pmic-keys to DT schema



Convert the mtk-pmic-keys to DT schema format.

The old binding was missing documentation for key press/release
interrupts, even though it was supported in hardware and driver,
so support for the same was added during the conversion.

Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: default avatarMattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: default avatarRob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220914103021.43593-2-angelogioacchino.delregno@collabora.com


Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 7984b435
Loading
Loading
Loading
Loading
+113 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/input/mediatek,pmic-keys.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: MediaTek PMIC Keys

maintainers:
  - Chen Zhong <chen.zhong@mediatek.com>

allOf:
  - $ref: input.yaml#

description: |
  There are two key functions provided by MT6397, MT6323 and other MediaTek
  PMICs: pwrkey and homekey.
  The key functions are defined as the subnode of the function node provided
  by the PMIC that is defined as a Multi-Function Device (MFD).

  For MediaTek MT6323/MT6397 PMIC bindings see
  Documentation/devicetree/bindings/mfd/mt6397.txt

properties:
  compatible:
    enum:
      - mediatek,mt6323-keys
      - mediatek,mt6358-keys
      - mediatek,mt6397-keys

  power-off-time-sec: true

  mediatek,long-press-mode:
    description: |
      Key long-press force shutdown setting
      0 - disabled
      1 - pwrkey
      2 - pwrkey+homekey
    $ref: /schemas/types.yaml#/definitions/uint32
    default: 0
    maximum: 2

patternProperties:
  "^((power|home)|(key-[a-z0-9-]+|[a-z0-9-]+-key))$":
    $ref: input.yaml#

    properties:
      interrupts:
        minItems: 1
        items:
          - description: Key press interrupt
          - description: Key release interrupt

      interrupt-names: true

      linux-keycodes:
        maxItems: 1

      wakeup-source: true

    required:
      - linux,keycodes

    if:
      properties:
        interrupt-names:
          contains:
            const: powerkey
    then:
      properties:
        interrupt-names:
          minItems: 1
          items:
            - const: powerkey
            - const: powerkey_r
    else:
      properties:
        interrupt-names:
          minItems: 1
          items:
            - const: homekey
            - const: homekey_r

    unevaluatedProperties: false

required:
  - compatible

unevaluatedProperties: false

examples:
  - |
    #include <dt-bindings/input/input.h>
    #include <dt-bindings/interrupt-controller/arm-gic.h>

    pmic {
        compatible = "mediatek,mt6397";

        keys {
          compatible = "mediatek,mt6397-keys";
          mediatek,long-press-mode = <1>;
          power-off-time-sec = <0>;

          key-power {
            linux,keycodes = <KEY_POWER>;
            wakeup-source;
          };

          key-home {
            linux,keycodes = <KEY_VOLUMEDOWN>;
          };
        };
    };
+0 −46
Original line number Diff line number Diff line
MediaTek MT6397/MT6323 PMIC Keys Device Driver

There are two key functions provided by MT6397/MT6323 PMIC, pwrkey
and homekey. The key functions are defined as the subnode of the function
node provided by MT6397/MT6323 PMIC that is being defined as one kind
of Muti-Function Device (MFD)

For MT6397/MT6323 MFD bindings see:
Documentation/devicetree/bindings/mfd/mt6397.txt

Required properties:
- compatible: Should be one of:
	- "mediatek,mt6397-keys"
	- "mediatek,mt6323-keys"
	- "mediatek,mt6358-keys"
- linux,keycodes: See Documentation/devicetree/bindings/input/input.yaml

Optional Properties:
- wakeup-source: See Documentation/devicetree/bindings/power/wakeup-source.txt
- mediatek,long-press-mode: Long press key shutdown setting, 1 for
	pwrkey only, 2 for pwrkey/homekey together, others for disabled.
- power-off-time-sec: See Documentation/devicetree/bindings/input/input.yaml

Example:

	pmic: mt6397 {
		compatible = "mediatek,mt6397";

		...

		mt6397keys: mt6397keys {
			compatible = "mediatek,mt6397-keys";
			mediatek,long-press-mode = <1>;
			power-off-time-sec = <0>;

			power {
				linux,keycodes = <116>;
				wakeup-source;
			};

			home {
				linux,keycodes = <114>;
			};
		};

	};