linux/drivers/iio/chemical/sgp30.c

// SPDX-License-Identifier: GPL-2.0
/*
 * sgp30.c - Support for Sensirion SGP Gas Sensors
 *
 * Copyright (C) 2018 Andreas Brauchli <[email protected]>
 *
 * I2C slave address: 0x58
 *
 * Datasheets:
 * https://www.sensirion.com/file/datasheet_sgp30
 * https://www.sensirion.com/file/datasheet_sgpc3
 *
 * TODO:
 * - baseline support
 * - humidity compensation
 * - power mode switching (SGPC3)
 */

#include <linux/crc8.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/mutex.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>

#define SGP_WORD_LEN
#define SGP_CRC8_POLYNOMIAL
#define SGP_CRC8_INIT
#define SGP_CRC8_LEN
#define SGP_CMD(cmd_word)
#define SGP_CMD_DURATION_US
#define SGP_MEASUREMENT_DURATION_US
#define SGP_CMD_LEN
#define SGP_CMD_MAX_BUF_SIZE
#define SGP_MEASUREMENT_LEN
#define SGP30_MEASURE_INTERVAL_HZ
#define SGPC3_MEASURE_INTERVAL_HZ
#define SGP_VERS_PRODUCT(data)
#define SGP_VERS_RESERVED(data)
#define SGP_VERS_GEN(data)
#define SGP_VERS_ENG_BIT(data)
#define SGP_VERS_MAJOR(data)
#define SGP_VERS_MINOR(data)

DECLARE_CRC8_TABLE(sgp_crc8_table);

enum sgp_product_id {};

enum sgp30_channel_idx {};

enum sgpc3_channel_idx {};

enum sgp_cmd {};

struct sgp_version {};

struct sgp_crc_word {} __attribute__((packed));

sgp_reading;

enum _iaq_buffer_state {};

struct sgp_data {};

struct sgp_device {};

static const struct sgp_version supported_versions_sgp30[] =;

static const struct sgp_version supported_versions_sgpc3[] =;

static const struct iio_chan_spec sgp30_channels[] =;

static const struct iio_chan_spec sgpc3_channels[] =;

static const struct sgp_device sgp_devices[] =;

/**
 * sgp_verify_buffer() - verify the checksums of the data buffer words
 *
 * @data:       SGP data
 * @buf:        Raw data buffer
 * @word_count: Num data words stored in the buffer, excluding CRC bytes
 *
 * Return:      0 on success, negative error otherwise.
 */
static int sgp_verify_buffer(const struct sgp_data *data,
			     union sgp_reading *buf, size_t word_count)
{}

/**
 * sgp_read_cmd() - reads data from sensor after issuing a command
 * The caller must hold data->data_lock for the duration of the call.
 * @data:        SGP data
 * @cmd:         SGP Command to issue
 * @buf:         Raw data buffer to use
 * @word_count:  Num words to read, excluding CRC bytes
 * @duration_us: Time taken to sensor to take a reading and data to be ready.
 *
 * Return:       0 on success, negative error otherwise.
 */
static int sgp_read_cmd(struct sgp_data *data, enum sgp_cmd cmd,
			union sgp_reading *buf, size_t word_count,
			unsigned long duration_us)
{}

/**
 * sgp_measure_iaq() - measure and retrieve IAQ values from sensor
 * The caller must hold data->data_lock for the duration of the call.
 * @data:       SGP data
 *
 * Return:      0 on success, -EBUSY on default values, negative error
 *              otherwise.
 */

static int sgp_measure_iaq(struct sgp_data *data)
{}

static void sgp_iaq_thread_sleep_until(const struct sgp_data *data,
				       unsigned long sleep_jiffies)
{}

static int sgp_iaq_threadfn(void *p)
{}

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

static int sgp_check_compat(struct sgp_data *data,
			    unsigned int product_id)
{}

static void sgp_init(struct sgp_data *data)
{}

static const struct iio_info sgp_info =;

static const struct of_device_id sgp_dt_ids[] =;

static int sgp_probe(struct i2c_client *client)
{}

static void sgp_remove(struct i2c_client *client)
{}

static const struct i2c_device_id sgp_id[] =;

MODULE_DEVICE_TABLE(i2c, sgp_id);
MODULE_DEVICE_TABLE(of, sgp_dt_ids);

static struct i2c_driver sgp_driver =;
module_i2c_driver();

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