linux/drivers/iio/chemical/ccs811.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * ccs811.c - Support for AMS CCS811 VOC Sensor
 *
 * Copyright (C) 2017 Narcisa Vasile <[email protected]>
 *
 * Datasheet: ams.com/content/download/951091/2269479/CCS811_DS000459_3-00.pdf
 *
 * IIO driver for AMS CCS811 (I2C address 0x5A/0x5B set by ADDR Low/High)
 *
 * TODO:
 * 1. Make the drive mode selectable form userspace
 * 2. Add support for interrupts
 * 3. Adjust time to wait for data to be ready based on selected operation mode
 * 4. Read error register and put the information in logs
 */

#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
#include <linux/iio/trigger.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/module.h>

#define CCS811_STATUS
#define CCS811_MEAS_MODE
#define CCS811_ALG_RESULT_DATA
#define CCS811_RAW_DATA
#define CCS811_HW_ID
#define CCS811_HW_ID_VALUE
#define CCS811_HW_VERSION
#define CCS811_HW_VERSION_VALUE
#define CCS811_HW_VERSION_MASK
#define CCS811_ERR
/* Used to transition from boot to application mode */
#define CCS811_APP_START
#define CCS811_SW_RESET

/* Status register flags */
#define CCS811_STATUS_ERROR
#define CCS811_STATUS_DATA_READY
#define CCS811_STATUS_APP_VALID_MASK
#define CCS811_STATUS_APP_VALID_LOADED
/*
 * Value of FW_MODE bit of STATUS register describes the sensor's state:
 * 0: Firmware is in boot mode, this allows new firmware to be loaded
 * 1: Firmware is in application mode. CCS811 is ready to take ADC measurements
 */
#define CCS811_STATUS_FW_MODE_MASK
#define CCS811_STATUS_FW_MODE_APPLICATION

/* Measurement modes */
#define CCS811_MODE_IDLE
#define CCS811_MODE_IAQ_1SEC
#define CCS811_MODE_IAQ_10SEC
#define CCS811_MODE_IAQ_60SEC
#define CCS811_MODE_RAW_DATA

#define CCS811_MEAS_MODE_INTERRUPT

#define CCS811_VOLTAGE_MASK

struct ccs811_reading {} __attribute__((packed));

struct ccs811_data {};

static const struct iio_chan_spec ccs811_channels[] =;

/*
 * The CCS811 powers-up in boot mode. A setup write to CCS811_APP_START will
 * transition the sensor to application mode.
 */
static int ccs811_start_sensor_application(struct i2c_client *client)
{}

static int ccs811_setup(struct i2c_client *client)
{}

static void ccs811_set_wakeup(struct ccs811_data *data, bool enable)
{}

static int ccs811_get_measurement(struct ccs811_data *data)
{}

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

static const struct iio_info ccs811_info =;

static int ccs811_set_trigger_state(struct iio_trigger *trig,
				    bool state)
{}

static const struct iio_trigger_ops ccs811_trigger_ops =;

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

static irqreturn_t ccs811_data_rdy_trigger_poll(int irq, void *private)
{}

static int ccs811_reset(struct i2c_client *client)
{}

static int ccs811_probe(struct i2c_client *client)
{}

static void ccs811_remove(struct i2c_client *client)
{}

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

static const struct of_device_id ccs811_dt_ids[] =;
MODULE_DEVICE_TABLE(of, ccs811_dt_ids);

static struct i2c_driver ccs811_driver =;
module_i2c_driver();

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