linux/drivers/iio/pressure/dps310.c

// SPDX-License-Identifier: GPL-2.0+
// Copyright IBM Corp 2019
/*
 * The DPS310 is a barometric pressure and temperature sensor.
 * Currently only reading a single temperature is supported by
 * this driver.
 *
 * https://www.infineon.com/dgdl/?fileId=5546d462576f34750157750826c42242
 *
 * Temperature calculation:
 *   c0 * 0.5 + c1 * T_raw / kT °C
 *
 * TODO:
 *  - Optionally support the FIFO
 */

#include <linux/i2c.h>
#include <linux/limits.h>
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/regmap.h>

#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>

#define DPS310_DEV_NAME

#define DPS310_PRS_B0
#define DPS310_PRS_B1
#define DPS310_PRS_B2
#define DPS310_TMP_B0
#define DPS310_TMP_B1
#define DPS310_TMP_B2
#define DPS310_PRS_CFG
#define DPS310_PRS_RATE_BITS
#define DPS310_PRS_PRC_BITS
#define DPS310_TMP_CFG
#define DPS310_TMP_RATE_BITS
#define DPS310_TMP_PRC_BITS
#define DPS310_TMP_EXT
#define DPS310_MEAS_CFG
#define DPS310_MEAS_CTRL_BITS
#define DPS310_PRS_EN
#define DPS310_TEMP_EN
#define DPS310_BACKGROUND
#define DPS310_PRS_RDY
#define DPS310_TMP_RDY
#define DPS310_SENSOR_RDY
#define DPS310_COEF_RDY
#define DPS310_CFG_REG
#define DPS310_INT_HL
#define DPS310_TMP_SHIFT_EN
#define DPS310_PRS_SHIFT_EN
#define DPS310_FIFO_EN
#define DPS310_SPI_EN
#define DPS310_RESET
#define DPS310_RESET_MAGIC
#define DPS310_COEF_BASE

/* Make sure sleep time is <= 30ms for usleep_range */
#define DPS310_POLL_SLEEP_US(t)
/* Silently handle error in rate value here */
#define DPS310_POLL_TIMEOUT_US(rc)

#define DPS310_PRS_BASE
#define DPS310_TMP_BASE

/*
 * These values (defined in the spec) indicate how to scale the raw register
 * values for each level of precision available.
 */
static const int scale_factors[] =;

struct dps310_data {};

static const struct iio_chan_spec dps310_channels[] =;

/* To be called after checking the COEF_RDY bit in MEAS_CFG */
static int dps310_get_coefs(struct dps310_data *data)
{}

/*
 * Some versions of the chip will read temperatures in the ~60C range when
 * it's actually ~20C. This is the manufacturer recommended workaround
 * to correct the issue. The registers used below are undocumented.
 */
static int dps310_temp_workaround(struct dps310_data *data)
{}

static int dps310_startup(struct dps310_data *data)
{}

static int dps310_get_pres_precision(struct dps310_data *data, int *val)
{}

static int dps310_get_temp_precision(struct dps310_data *data, int *val)
{}

/* Called with lock held */
static int dps310_set_pres_precision(struct dps310_data *data, int val)
{}

/* Called with lock held */
static int dps310_set_temp_precision(struct dps310_data *data, int val)
{}

/* Called with lock held */
static int dps310_set_pres_samp_freq(struct dps310_data *data, int freq)
{}

/* Called with lock held */
static int dps310_set_temp_samp_freq(struct dps310_data *data, int freq)
{}

static int dps310_get_pres_samp_freq(struct dps310_data *data, int *val)
{}

static int dps310_get_temp_samp_freq(struct dps310_data *data, int *val)
{}

static int dps310_get_pres_k(struct dps310_data *data, int *val)
{}

static int dps310_get_temp_k(struct dps310_data *data, int *val)
{}

static int dps310_reset_wait(struct dps310_data *data)
{}

static int dps310_reset_reinit(struct dps310_data *data)
{}

static int dps310_ready_status(struct dps310_data *data, int ready_bit, int timeout)
{}

static int dps310_ready(struct dps310_data *data, int ready_bit, int timeout)
{}

static int dps310_read_pres_raw(struct dps310_data *data)
{}

/* Called with lock held */
static int dps310_read_temp_ready(struct dps310_data *data)
{}

static int dps310_read_temp_raw(struct dps310_data *data)
{}

static bool dps310_is_writeable_reg(struct device *dev, unsigned int reg)
{}

static bool dps310_is_volatile_reg(struct device *dev, unsigned int reg)
{}

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

static int dps310_calculate_pressure(struct dps310_data *data, int *val)
{}

static int dps310_read_pressure(struct dps310_data *data, int *val, int *val2,
				long mask)
{}

static int dps310_calculate_temp(struct dps310_data *data, int *val)
{}

static int dps310_read_temp(struct dps310_data *data, int *val, int *val2,
			    long mask)
{}

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

static void dps310_reset(void *action_data)
{}

static const struct regmap_config dps310_regmap_config =;

static const struct iio_info dps310_info =;

static int dps310_probe(struct i2c_client *client)
{}

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

static const struct acpi_device_id dps310_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, dps310_acpi_match);

static struct i2c_driver dps310_driver =;
module_i2c_driver();

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