# Copyright (c) 2020 Vestas Wind Systems A/S
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

description: |
  NXP Kinetis ACMP (Analog CoMParator)

  The following example displays the minimum node layout:

    acmp0: acmp@deadbeef {
            compatible = "nxp,kinetis-acmp";
            reg = <0xdeadbeef 0x1000>;
            interrupts = <0 0>;
            clocks = <&scg KINETIS_SCG_BUS_CLK>;
            status = "disabled";
    };

  Enabling the comparator node requires setting the minimum default
  configuration of the comparator. This includes selecting the
  positive and negative inputs, and routing them using pinctrl:

    &pinctrl {
            acmp0_default: acmp0_default {
                    group0 {
                            ...
                    };
            };
    };

    &acmp0 {
            status = "okay";
            pinctrl-0 = <&acmp0_default>;
            pinctrl-names = "default";

            positive-mux-input = "IN0";
            negative-mux-input = "IN1";
    };

compatible: "nxp,kinetis-acmp"

include:
  - base.yaml
  - pinctrl-device.yaml

properties:
  interrupts:
    required: true

  reg:
    required: true

  nxp,enable-output-pin:
    type: boolean
    deprecated: true
    description: Deprecated. Please use enable-pin-out instead

  nxp,use-unfiltered-output:
    type: boolean
    deprecated: true
    description: Deprecated. Please use use-unfiltered-output instead

  nxp,high-speed-mode:
    type: boolean
    deprecated: true
    description: Deprecated. Please use enable-high-speed-mode instead

  nxp,enable-sample:
    type: boolean
    deprecated: true
    description: Deprecated. Please use filter-enable-sample instead

  nxp,filter-count:
    type: int
    deprecated: true
    description: Deprecated. Please use filter-count instead

  nxp,filter-period:
    type: int
    deprecated: true
    description: Deprecated. Please use filter-period instead

  nxp,window-mode:
    type: boolean
    deprecated: true
    description: Deprecated. Please use enable-window-mode instead

  offset-mode:
    type: string
    enum:
      - "LEVEL0"
      - "LEVEL1"

  hysteresis-mode:
    type: string
    enum:
      - "LEVEL0"
      - "LEVEL1"
      - "LEVEL2"
      - "LEVEL3"

  enable-high-speed-mode:
    type: boolean

  invert-output:
    type: boolean

  use-unfiltered-output:
    type: boolean

  enable-pin-out:
    type: boolean

  enable-window-mode:
    type: boolean

  positive-mux-input:
    type: string
    enum:
      - IN0
      - IN1
      - IN2
      - IN3
      - IN4
      - IN5
      - IN6
      - IN7

  negative-mux-input:
    type: string
    enum:
      - IN0
      - IN1
      - IN2
      - IN3
      - IN4
      - IN5
      - IN6
      - IN7

  positive-port-input:
    type: string
    enum:
      - DAC
      - MUX

  negative-port-input:
    type: string
    enum:
      - DAC
      - MUX

  filter-enable-sample:
    type: boolean

  filter-count:
    type: int
    description: Filter sample count (0 to 7).

  filter-period:
    type: int
    description: Filter sample period in bus clock cycles (0 to 255).

  dac-vref-source:
    type: string
    enum:
      - "VIN1"
      - "VIN2"

  dac-value:
    type: int

  dac-enable:
    type: boolean

  dac-enable-high-speed:
    type: boolean

  discrete-mode-enable-positive-channel:
    type: boolean

  discrete-mode-enable-negative-channel:
    type: boolean

  discrete-mode-enable-resistor-divider:
    type: boolean

  discrete-mode-clock-source:
    type: string
    enum:
      - "SLOW"
      - "FAST"

  discrete-mode-sample-time:
    type: string
    enum:
      - "T1"
      - "T2"
      - "T4"
      - "T8"
      - "T16"
      - "T32"
      - "T64"
      - "T256"

  discrete-mode-phase1-time:
    type: string
    enum:
      - "ALT0"
      - "ALT1"
      - "ALT2"
      - "ALT3"
      - "ALT4"
      - "ALT5"
      - "ALT6"
      - "ALT7"

  discrete-mode-phase2-time:
    type: string
    enum:
      - "ALT0"
      - "ALT1"
      - "ALT2"
      - "ALT3"
      - "ALT4"
      - "ALT5"
      - "ALT6"
      - "ALT7"
