linux/drivers/iio/accel/da311.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * IIO driver for the MiraMEMS DA311 3-axis accelerometer
 *
 * Copyright (c) 2016 Hans de Goede <[email protected]>
 * Copyright (c) 2011-2013 MiraMEMS Sensing Technology Co., Ltd.
 */

#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/byteorder/generic.h>

#define DA311_CHIP_ID

/*
 * Note register addressed go from 0 - 0x3f and then wrap.
 * For some reason there are 2 banks with 0 - 0x3f addresses,
 * rather then a single 0-0x7f bank.
 */

/* Bank 0 regs */
#define DA311_REG_BANK
#define DA311_REG_LDO_REG
#define DA311_REG_CHIP_ID
#define DA311_REG_TEMP_CFG_REG
#define DA311_REG_CTRL_REG1
#define DA311_REG_CTRL_REG3
#define DA311_REG_CTRL_REG4
#define DA311_REG_CTRL_REG5
#define DA311_REG_CTRL_REG6
#define DA311_REG_STATUS_REG
#define DA311_REG_OUT_X_L
#define DA311_REG_OUT_X_H
#define DA311_REG_OUT_Y_L
#define DA311_REG_OUT_Y_H
#define DA311_REG_OUT_Z_L
#define DA311_REG_OUT_Z_H
#define DA311_REG_INT1_CFG
#define DA311_REG_INT1_SRC
#define DA311_REG_INT1_THS
#define DA311_REG_INT1_DURATION
#define DA311_REG_INT2_CFG
#define DA311_REG_INT2_SRC
#define DA311_REG_INT2_THS
#define DA311_REG_INT2_DURATION
#define DA311_REG_CLICK_CFG
#define DA311_REG_CLICK_SRC
#define DA311_REG_CLICK_THS
#define DA311_REG_TIME_LIMIT
#define DA311_REG_TIME_LATENCY
#define DA311_REG_TIME_WINDOW

/* Bank 1 regs */
#define DA311_REG_SOFT_RESET
#define DA311_REG_OTP_XOFF_L
#define DA311_REG_OTP_XOFF_H
#define DA311_REG_OTP_YOFF_L
#define DA311_REG_OTP_YOFF_H
#define DA311_REG_OTP_ZOFF_L
#define DA311_REG_OTP_ZOFF_H
#define DA311_REG_OTP_XSO
#define DA311_REG_OTP_YSO
#define DA311_REG_OTP_ZSO
#define DA311_REG_OTP_TRIM_OSC
#define DA311_REG_LPF_ABSOLUTE
#define DA311_REG_TEMP_OFF1
#define DA311_REG_TEMP_OFF2
#define DA311_REG_TEMP_OFF3
#define DA311_REG_OTP_TRIM_THERM_H

/*
 * a value of + or -1024 corresponds to + or - 1G
 * scale = 9.81 / 1024 = 0.009580078
 */

static const int da311_nscale =;

#define DA311_CHANNEL(reg, axis)

static const struct iio_chan_spec da311_channels[] =;

struct da311_data {};

static int da311_register_mask_write(struct i2c_client *client, u16 addr,
				     u8 mask, u8 data)
{}

/* Init sequence taken from the android driver */
static int da311_reset(struct i2c_client *client)
{}

static int da311_enable(struct i2c_client *client, bool enable)
{}

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

static const struct iio_info da311_info =;

static void da311_disable(void *client)
{}

static int da311_probe(struct i2c_client *client)
{}

static int da311_suspend(struct device *dev)
{}

static int da311_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(da311_pm_ops, da311_suspend, da311_resume);

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

static struct i2c_driver da311_driver =;

module_i2c_driver();

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