linux/drivers/iio/proximity/srf08.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * srf08.c - Support for Devantech SRFxx ultrasonic ranger
 *           with i2c interface
 * actually supported are srf02, srf08, srf10
 *
 * Copyright (c) 2016, 2017 Andreas Klinger <[email protected]>
 *
 * For details about the device see:
 * https://www.robot-electronics.co.uk/htm/srf08tech.html
 * https://www.robot-electronics.co.uk/htm/srf10tech.htm
 * https://www.robot-electronics.co.uk/htm/srf02tech.htm
 */

#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/bitops.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/buffer.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>

/* registers of SRF08 device */
#define SRF08_WRITE_COMMAND
#define SRF08_WRITE_MAX_GAIN
#define SRF08_WRITE_RANGE
#define SRF08_READ_SW_REVISION
#define SRF08_READ_LIGHT
#define SRF08_READ_ECHO_1_HIGH
#define SRF08_READ_ECHO_1_LOW

#define SRF08_CMD_RANGING_CM

enum srf08_sensor_type {};

struct srf08_chip_info {};

struct srf08_data {};

/*
 * in the documentation one can read about the "Gain" of the device
 * which is used here for amplifying the signal and filtering out unwanted
 * ones.
 * But with ADC's this term is already used differently and that's why it
 * is called "Sensitivity" here.
 */
static const struct srf08_chip_info srf02_chip_info =;

static const int srf08_sensitivity_avail[] =;

static const struct srf08_chip_info srf08_chip_info =;

static const int srf10_sensitivity_avail[] =;

static const struct srf08_chip_info srf10_chip_info =;

static int srf08_read_ranging(struct srf08_data *data)
{}

static irqreturn_t srf08_trigger_handler(int irq, void *p)
{}

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

static ssize_t srf08_show_range_mm_available(struct device *dev,
				struct device_attribute *attr, char *buf)
{}

static IIO_DEVICE_ATTR(sensor_max_range_available, S_IRUGO,
				srf08_show_range_mm_available, NULL, 0);

static ssize_t srf08_show_range_mm(struct device *dev,
				struct device_attribute *attr, char *buf)
{}

/*
 * set the range of the sensor to an even multiple of 43 mm
 * which corresponds to 1 LSB in the register
 *
 * register value    corresponding range
 *         0x00             43 mm
 *         0x01             86 mm
 *         0x02            129 mm
 *         ...
 *         0xFF          11008 mm
 */
static ssize_t srf08_write_range_mm(struct srf08_data *data, unsigned int val)
{}

static ssize_t srf08_store_range_mm(struct device *dev,
					struct device_attribute *attr,
					const char *buf, size_t len)
{}

static IIO_DEVICE_ATTR(sensor_max_range, S_IRUGO | S_IWUSR,
			srf08_show_range_mm, srf08_store_range_mm, 0);

static ssize_t srf08_show_sensitivity_available(struct device *dev,
				struct device_attribute *attr, char *buf)
{}

static IIO_DEVICE_ATTR(sensor_sensitivity_available, S_IRUGO,
				srf08_show_sensitivity_available, NULL, 0);

static ssize_t srf08_show_sensitivity(struct device *dev,
				struct device_attribute *attr, char *buf)
{}

static ssize_t srf08_write_sensitivity(struct srf08_data *data,
							unsigned int val)
{}

static ssize_t srf08_store_sensitivity(struct device *dev,
						struct device_attribute *attr,
						const char *buf, size_t len)
{}

static IIO_DEVICE_ATTR(sensor_sensitivity, S_IRUGO | S_IWUSR,
			srf08_show_sensitivity, srf08_store_sensitivity, 0);

static struct attribute *srf08_attributes[] =;

static const struct attribute_group srf08_attribute_group =;

static const struct iio_chan_spec srf08_channels[] =;

static const struct iio_info srf08_info =;

/*
 * srf02 don't have an adjustable range or sensitivity,
 * so we don't need attributes at all
 */
static const struct iio_info srf02_info =;

static int srf08_probe(struct i2c_client *client)
{}

static const struct of_device_id of_srf08_match[] =;

MODULE_DEVICE_TABLE(of, of_srf08_match);

static const struct i2c_device_id srf08_id[] =;
MODULE_DEVICE_TABLE(i2c, srf08_id);

static struct i2c_driver srf08_driver =;
module_i2c_driver();

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