linux/drivers/iio/proximity/ping.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * PING: ultrasonic sensor for distance measuring by using only one GPIOs
 *
 * Copyright (c) 2019 Andreas Klinger <[email protected]>
 *
 * For details about the devices see:
 * http://parallax.com/sites/default/files/downloads/28041-LaserPING-2m-Rangefinder-Guide.pdf
 * http://parallax.com/sites/default/files/downloads/28015-PING-Documentation-v1.6.pdf
 *
 * the measurement cycle as timing diagram looks like:
 *
 * GPIO      ___              ________________________
 * ping:  __/   \____________/                        \________________
 *          ^   ^            ^                        ^
 *          |<->|            interrupt                interrupt
 *         udelay(5)         (ts_rising)              (ts_falling)
 *                           |<---------------------->|
 *                           .  pulse time measured   .
 *                           .  --> one round trip of ultra sonic waves
 * ultra                     .                        .
 * sonic            _   _   _.                        .
 * burst: _________/ \_/ \_/ \_________________________________________
 *                                                    .
 * ultra                                              .
 * sonic                                     _   _   _.
 * echo:  __________________________________/ \_/ \_/ \________________
 */
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>

struct ping_cfg {};

struct ping_data {};

static const struct ping_cfg pa_ping_cfg =;

static const struct ping_cfg pa_laser_ping_cfg =;

static irqreturn_t ping_handle_irq(int irq, void *dev_id)
{}

static int ping_read(struct iio_dev *indio_dev)
{}

static int ping_read_raw(struct iio_dev *indio_dev,
			    struct iio_chan_spec const *channel, int *val,
			    int *val2, long info)
{}

static const struct iio_info ping_iio_info =;

static const struct iio_chan_spec ping_chan_spec[] =;

static const struct of_device_id of_ping_match[] =;

MODULE_DEVICE_TABLE(of, of_ping_match);

static int ping_probe(struct platform_device *pdev)
{}

static struct platform_driver ping_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_ALIAS();