# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2008-2011 Freescale Semiconductor Inc.
%YAML 1.2
---
$id: http://devicetree.org/schemas/crypto/fsl,sec-v4.0-mon.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Freescale Secure Non-Volatile Storage (SNVS)

maintainers:
  - '"Horia Geantă" <horia.geanta@nxp.com>'
  - Pankaj Gupta <pankaj.gupta@nxp.com>
  - Gaurav Jain <gaurav.jain@nxp.com>

description:
  Node defines address range and the associated interrupt for the SNVS function.
  This function monitors security state information & reports security
  violations. This also included rtc, system power off and ON/OFF key.

properties:
  compatible:
    oneOf:
      - items:
          - const: fsl,sec-v4.0-mon
          - const: syscon
          - const: simple-mfd
      - items:
          - const: fsl,sec-v5.0-mon
          - const: fsl,sec-v4.0-mon
      - items:
          - enum:
              - fsl,sec-v5.3-mon
              - fsl,sec-v5.4-mon
          - const: fsl,sec-v5.0-mon
          - const: fsl,sec-v4.0-mon

  reg:
    maxItems: 1

  interrupts:
    maxItems: 2

  snvs-rtc-lp:
    type: object
    additionalProperties: false
    description:
      Secure Non-Volatile Storage (SNVS) Low Power (LP) RTC Node

    properties:
      compatible:
        const: fsl,sec-v4.0-mon-rtc-lp

      clocks:
        maxItems: 1

      clock-names:
        const: snvs-rtc

      interrupts:
        # VFxxx has only one. What is the 2nd one?
        minItems: 1
        maxItems: 2

      regmap:
        description: Parent node containing registers
        $ref: /schemas/types.yaml#/definitions/phandle

      offset:
        description: LP register offset
        $ref: /schemas/types.yaml#/definitions/uint32
        default: 0x34

    required:
      - compatible
      - interrupts
      - regmap

  snvs-powerkey:
    type: object
    additionalProperties: false
    description:
      The snvs-pwrkey is designed to enable POWER key function which controlled
      by SNVS ONOFF, the driver can report the status of POWER key and wakeup
      system if pressed after system suspend.

    properties:
      compatible:
        const: fsl,sec-v4.0-pwrkey

      clocks:
        maxItems: 1

      clock-names:
        const: snvs-pwrkey

      interrupts:
        maxItems: 1

      regmap:
        description: Parent node containing registers
        $ref: /schemas/types.yaml#/definitions/phandle

      wakeup-source: true

      linux,keycode:
        $ref: /schemas/types.yaml#/definitions/uint32
        default: 116
        deprecated: true

      linux,keycodes:
        maxItems: 1
        default: 116

    required:
      - compatible
      - interrupts
      - regmap

  snvs-lpgpr:
    $ref: /schemas/nvmem/snvs-lpgpr.yaml#

  snvs-poweroff:
    description:
      The SNVS could drive signal to PMIC to turn off system power by setting
      SNVS_LP LPCR register.
    $ref: /schemas/power/reset/syscon-poweroff.yaml#

required:
  - compatible
  - reg

additionalProperties: false

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

    sec_mon: sec-mon@314000 {
        compatible = "fsl,sec-v4.0-mon", "syscon", "simple-mfd";
        reg = <0x314000 0x1000>;

        snvs-rtc-lp {
            compatible = "fsl,sec-v4.0-mon-rtc-lp";
            regmap = <&sec_mon>;
            offset = <0x34>;
            clocks = <&clks IMX7D_SNVS_CLK>;
            clock-names = "snvs-rtc";
            interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
        };

        snvs-powerkey {
            compatible = "fsl,sec-v4.0-pwrkey";
            regmap = <&sec_mon>;
            clocks = <&clks IMX7D_SNVS_CLK>;
            clock-names = "snvs-pwrkey";
            interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
            linux,keycode = <116>; /* KEY_POWER */
            wakeup-source;
        };
    };