Commit 64b3d8b1 authored by Tomasz Duszynski's avatar Tomasz Duszynski Committed by Jonathan Cameron

iio: chemical: scd30: add core driver

Add Sensirion SCD30 carbon dioxide core driver.
Signed-off-by: default avatarTomasz Duszynski <tomasz.duszynski@octakon.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 477c653f
What: /sys/bus/iio/devices/iio:deviceX/calibration_auto_enable
Date: June 2020
KernelVersion: 5.8
Contact: linux-iio@vger.kernel.org
Description:
Contaminants build-up in the measurement chamber or optical
elements deterioration leads to sensor drift.
One can compensate for sensor drift by using automatic self
calibration procedure (asc).
Writing 1 or 0 to this attribute will respectively activate or
deactivate asc.
Upon reading current asc status is returned.
What: /sys/bus/iio/devices/iio:deviceX/calibration_forced_value
Date: June 2020
KernelVersion: 5.8
Contact: linux-iio@vger.kernel.org
Description:
Contaminants build-up in the measurement chamber or optical
elements deterioration leads to sensor drift.
One can compensate for sensor drift by using forced
recalibration (frc). This is useful in case there's known
co2 reference available nearby the sensor.
Picking value from the range [400 1 2000] and writing it to the
sensor will set frc.
Upon reading current frc value is returned. Note that after
power cycling default value (i.e 400) is returned even though
internally sensor had recalibrated itself.
......@@ -15351,6 +15351,12 @@ S: Maintained
F: drivers/misc/phantom.c
F: include/uapi/linux/phantom.h
SENSIRION SCD30 CARBON DIOXIDE SENSOR DRIVER
M: Tomasz Duszynski <tomasz.duszynski@octakon.com>
S: Maintained
F: drivers/iio/chemical/scd30.h
F: drivers/iio/chemical/scd30_core.c
SENSIRION SPS30 AIR POLLUTION SENSOR DRIVER
M: Tomasz Duszynski <tduszyns@gmail.com>
S: Maintained
......
......@@ -85,6 +85,17 @@ config PMS7003
To compile this driver as a module, choose M here: the module will
be called pms7003.
config SCD30_CORE
tristate "SCD30 carbon dioxide sensor driver"
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help
Say Y here to build support for the Sensirion SCD30 sensor with carbon
dioxide, relative humidity and temperature sensing capabilities.
To compile this driver as a module, choose M here: the module will
be called scd30_core.
config SENSIRION_SGP30
tristate "Sensirion SGPxx gas sensors"
depends on I2C
......
......@@ -12,6 +12,7 @@ obj-$(CONFIG_BME680_SPI) += bme680_spi.o
obj-$(CONFIG_CCS811) += ccs811.o
obj-$(CONFIG_IAQCORE) += ams-iaq-core.o
obj-$(CONFIG_PMS7003) += pms7003.o
obj-$(CONFIG_SCD30_CORE) += scd30_core.o
obj-$(CONFIG_SENSIRION_SGP30) += sgp30.o
obj-$(CONFIG_SPS30) += sps30.o
obj-$(CONFIG_VZ89X) += vz89x.o
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _SCD30_H
#define _SCD30_H
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/pm.h>
#include <linux/regulator/consumer.h>
#include <linux/types.h>
struct scd30_state;
enum scd30_cmd {
/* start continuous measurement with pressure compensation */
CMD_START_MEAS,
/* stop continuous measurement */
CMD_STOP_MEAS,
/* set/get measurement interval */
CMD_MEAS_INTERVAL,
/* check whether new measurement is ready */
CMD_MEAS_READY,
/* get measurement */
CMD_READ_MEAS,
/* turn on/off automatic self calibration */
CMD_ASC,
/* set/get forced recalibration value */
CMD_FRC,
/* set/get temperature offset */
CMD_TEMP_OFFSET,
/* get firmware version */
CMD_FW_VERSION,
/* reset sensor */
CMD_RESET,
/*
* Command for altitude compensation was omitted intentionally because
* the same can be achieved by means of CMD_START_MEAS which takes
* pressure above the sea level as an argument.
*/
};
#define SCD30_MEAS_COUNT 3
typedef int (*scd30_command_t)(struct scd30_state *state, enum scd30_cmd cmd, u16 arg,
void *response, int size);
struct scd30_state {
/* serialize access to the device */
struct mutex lock;
struct device *dev;
struct regulator *vdd;
struct completion meas_ready;
/*
* priv pointer is solely for serdev driver private data. We keep it
* here because driver_data inside dev has been already used for iio and
* struct serdev_device doesn't have one.
*/
void *priv;
int irq;
/*
* no way to retrieve current ambient pressure compensation value from
* the sensor so keep one around
*/
u16 pressure_comp;
u16 meas_interval;
int meas[SCD30_MEAS_COUNT];
scd30_command_t command;
};
int scd30_suspend(struct device *dev);
int scd30_resume(struct device *dev);
static __maybe_unused SIMPLE_DEV_PM_OPS(scd30_pm_ops, scd30_suspend, scd30_resume);
int scd30_probe(struct device *dev, int irq, const char *name, void *priv, scd30_command_t command);
#endif
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment