linux/drivers/iio/pressure/rohm-bm1390.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * BM1390 ROHM pressure sensor
 *
 * Copyright (c) 2023, ROHM Semiconductor.
 * https://fscdn.rohm.com/en/products/databook/datasheet/ic/sensor/pressure/bm1390glv-z-e.pdf
 */

#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>

#include <linux/iio/iio.h>
#include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>

#define BM1390_REG_MANUFACT_ID
#define BM1390_REG_PART_ID
#define BM1390_REG_POWER
#define BM1390_MASK_POWER
#define BM1390_POWER_ON
#define BM1390_POWER_OFF
#define BM1390_REG_RESET
#define BM1390_MASK_RESET
#define BM1390_RESET_RELEASE
#define BM1390_RESET
#define BM1390_REG_MODE_CTRL
#define BM1390_MASK_MEAS_MODE
#define BM1390_MASK_DRDY_EN
#define BM1390_MASK_WMI_EN
#define BM1390_MASK_AVE_NUM

/*
 * Data-sheet states that when the IIR is used, the AVE_NUM must be set to
 * value 110b
 */
#define BM1390_IIR_AVE_NUM
#define BM1390_REG_FIFO_CTRL
#define BM1390_MASK_IIR_MODE
#define BM1390_IIR_MODE_OFF
#define BM1390_IIR_MODE_WEAK
#define BM1390_IIR_MODE_MID
#define BM1390_IIR_MODE_STRONG

#define BM1390_MASK_FIFO_LEN
#define BM1390_MASK_FIFO_EN
#define BM1390_WMI_MIN
#define BM1390_WMI_MAX

#define BM1390_REG_FIFO_LVL
#define BM1390_MASK_FIFO_LVL
#define BM1390_REG_STATUS
#define BM1390_REG_PRESSURE_BASE
#define BM1390_REG_TEMP_HI
#define BM1390_REG_TEMP_LO
#define BM1390_MAX_REGISTER

#define BM1390_ID

/* Regmap configs */
static const struct regmap_range bm1390_volatile_ranges[] =;

static const struct regmap_access_table bm1390_volatile_regs =;

static const struct regmap_range bm1390_precious_ranges[] =;

static const struct regmap_access_table bm1390_precious_regs =;

static const struct regmap_range bm1390_read_only_ranges[] =;

static const struct regmap_access_table bm1390_ro_regs =;

static const struct regmap_range bm1390_noinc_read_ranges[] =;

static const struct regmap_access_table bm1390_nir_regs =;

static const struct regmap_config bm1390_regmap =;

enum {};

struct bm1390_data_buf {};

/* BM1390 has FIFO for 4 pressure samples */
#define BM1390_FIFO_LENGTH

struct bm1390_data {};

enum {};

static const struct iio_chan_spec bm1390_channels[] =;

/*
 * We can't skip reading the pressure because the watermark IRQ is acked
 * only when the pressure data is read from the FIFO.
 */
static const unsigned long bm1390_scan_masks[] =;

static int bm1390_read_temp(struct bm1390_data *data, int *temp)
{}

static int bm1390_pressure_read(struct bm1390_data *data, u32 *pressure)
{}

 /* The enum values map directly to register bits */
enum bm1390_meas_mode {};

static int bm1390_meas_set(struct bm1390_data *data, enum bm1390_meas_mode mode)
{}

/*
 * If the trigger is not used we just wait until the measurement has
 * completed. The data-sheet says maximum measurement cycle (regardless
 * the AVE_NUM) is 200 mS so let's just sleep at least that long. If speed
 * is needed the trigger should be used.
 */
#define BM1390_MAX_MEAS_TIME_MS

static int bm1390_read_data(struct bm1390_data *data,
			struct iio_chan_spec const *chan, int *val, int *val2)
{}

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

static int __bm1390_fifo_flush(struct iio_dev *idev, unsigned int samples,
			       s64 timestamp)
{}

static int bm1390_fifo_flush(struct iio_dev *idev, unsigned int samples)
{}

static int bm1390_set_watermark(struct iio_dev *idev, unsigned int val)
{}

static const struct iio_info bm1390_noirq_info =;

static const struct iio_info bm1390_info =;

static int bm1390_chip_init(struct bm1390_data *data)
{}

static int bm1390_fifo_set_wmi(struct bm1390_data *data)
{}

static int bm1390_fifo_enable(struct iio_dev *idev)
{}

static int bm1390_fifo_disable(struct iio_dev *idev)
{}

static int bm1390_buffer_postenable(struct iio_dev *idev)
{}

static int bm1390_buffer_predisable(struct iio_dev *idev)
{}

static const struct iio_buffer_setup_ops bm1390_buffer_ops =;

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

/* Get timestamps and wake the thread if we need to read data */
static irqreturn_t bm1390_irq_handler(int irq, void *private)
{}

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

static int bm1390_set_drdy_irq(struct bm1390_data *data, bool en)
{}

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

static const struct iio_trigger_ops bm1390_trigger_ops =;

static int bm1390_setup_buffer(struct bm1390_data *data, struct iio_dev *idev)
{}

static int bm1390_setup_trigger(struct bm1390_data *data, struct iio_dev *idev,
				int irq)
{}

static int bm1390_probe(struct i2c_client *i2c)
{}

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

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

static struct i2c_driver bm1390_driver =;
module_i2c_driver();

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