# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/iio/proximity/devantech-srf04.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Devantech SRF04 and Maxbotix mb1000 ultrasonic range finder

maintainers:
  - Andreas Klinger <ak@it-klinger.de>

description: |
  Bit-banging driver using two GPIOs:
  - trigger-gpio is raised by the driver to start sending out an ultrasonic
    burst
  - echo-gpio is held high by the sensor after sending ultrasonic burst
    until it is received once again

  Specifications about the devices can be found at:
  https://www.robot-electronics.co.uk/htm/srf04tech.htm

  https://www.maxbotix.com/documents/LV-MaxSonar-EZ_Datasheet.pdf

properties:
  compatible:
    enum:
      - devantech,srf04
      - maxbotix,mb1000
      - maxbotix,mb1010
      - maxbotix,mb1020
      - maxbotix,mb1030
      - maxbotix,mb1040

  trig-gpios:
    description:
      Definition of the GPIO for the triggering (output)
      This GPIO is set for about 10 us by the driver to tell the device it
      should initiate the measurement cycle.
      See Documentation/devicetree/bindings/gpio/gpio.txt for information
      on how to specify a consumer gpio.
    maxItems: 1

  echo-gpios:
    description:
      Definition of the GPIO for the echo (input)
      This GPIO is set by the device as soon as an ultrasonic burst is sent
      out and reset when the first echo is received.
      Thus this GPIO is set while the ultrasonic waves are doing one round
      trip.
      It needs to be an GPIO which is able to deliver an interrupt because
      the time between two interrupts is measured in the driver.
    maxItems: 1

  power-gpios:
    description:
      Definition of the GPIO for power management of connected peripheral
      (output).
      This GPIO can be used by the external hardware for power management.
      When the device gets suspended it's switched off and when it resumes
      it's switched on again. After some period of inactivity the driver
      get suspended automatically (autosuspend feature).
    maxItems: 1

  startup-time-ms:
    description:
      This is the startup time the device needs after a resume to be up and
      running.
    minimum: 0
    maximum: 1000
    default: 100

required:
  - compatible
  - trig-gpios
  - echo-gpios

additionalProperties: false

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    proximity {
        compatible = "devantech,srf04";
        trig-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
        echo-gpios = <&gpio2  6 GPIO_ACTIVE_HIGH>;
    };