linux/drivers/iio/imu/kmx61.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * KMX61 - Kionix 6-axis Accelerometer/Magnetometer
 *
 * Copyright (c) 2014, Intel Corporation.
 *
 * IIO driver for KMX61 (7-bit I2C slave address 0x0E or 0x0F).
 */

#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/acpi.h>
#include <linux/interrupt.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/events.h>
#include <linux/iio/trigger.h>
#include <linux/iio/buffer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>

#define KMX61_DRV_NAME
#define KMX61_IRQ_NAME

#define KMX61_REG_WHO_AM_I
#define KMX61_REG_INS1
#define KMX61_REG_INS2

/*
 * three 16-bit accelerometer output registers for X/Y/Z axis
 * we use only XOUT_L as a base register, all other addresses
 * can be obtained by applying an offset and are provided here
 * only for clarity.
 */
#define KMX61_ACC_XOUT_L
#define KMX61_ACC_XOUT_H
#define KMX61_ACC_YOUT_L
#define KMX61_ACC_YOUT_H
#define KMX61_ACC_ZOUT_L
#define KMX61_ACC_ZOUT_H

/*
 * one 16-bit temperature output register
 */
#define KMX61_TEMP_L
#define KMX61_TEMP_H

/*
 * three 16-bit magnetometer output registers for X/Y/Z axis
 */
#define KMX61_MAG_XOUT_L
#define KMX61_MAG_XOUT_H
#define KMX61_MAG_YOUT_L
#define KMX61_MAG_YOUT_H
#define KMX61_MAG_ZOUT_L
#define KMX61_MAG_ZOUT_H

#define KMX61_REG_INL
#define KMX61_REG_STBY
#define KMX61_REG_CTRL1
#define KMX61_REG_CTRL2
#define KMX61_REG_ODCNTL
#define KMX61_REG_INC1

#define KMX61_REG_WUF_THRESH
#define KMX61_REG_WUF_TIMER

#define KMX61_ACC_STBY_BIT
#define KMX61_MAG_STBY_BIT
#define KMX61_ACT_STBY_BIT

#define KMX61_ALL_STBY

#define KMX61_REG_INS1_BIT_WUFS

#define KMX61_REG_INS2_BIT_ZP
#define KMX61_REG_INS2_BIT_ZN
#define KMX61_REG_INS2_BIT_YP
#define KMX61_REG_INS2_BIT_YN
#define KMX61_REG_INS2_BIT_XP
#define KMX61_REG_INS2_BIT_XN

#define KMX61_REG_CTRL1_GSEL_MASK

#define KMX61_REG_CTRL1_BIT_RES
#define KMX61_REG_CTRL1_BIT_DRDYE
#define KMX61_REG_CTRL1_BIT_WUFE
#define KMX61_REG_CTRL1_BIT_BTSE

#define KMX61_REG_INC1_BIT_WUFS
#define KMX61_REG_INC1_BIT_DRDYM
#define KMX61_REG_INC1_BIT_DRDYA
#define KMX61_REG_INC1_BIT_IEN

#define KMX61_ACC_ODR_SHIFT
#define KMX61_MAG_ODR_SHIFT
#define KMX61_ACC_ODR_MASK
#define KMX61_MAG_ODR_MASK

#define KMX61_OWUF_MASK

#define KMX61_DEFAULT_WAKE_THRESH
#define KMX61_DEFAULT_WAKE_DURATION

#define KMX61_SLEEP_DELAY_MS

#define KMX61_CHIP_ID

/* KMX61 devices */
#define KMX61_ACC
#define KMX61_MAG

struct kmx61_data {};

enum kmx61_range {};

enum kmx61_axis {};

static const u16 kmx61_uscale_table[] =;

static const struct {} kmx61_samp_freq_table[] =;

static const struct {} kmx61_wake_up_odr_table[] =;

static IIO_CONST_ATTR(accel_scale_available, "0.009582 0.019163 0.038326");
static IIO_CONST_ATTR(magn_scale_available, "0.001465");
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
	"0.781000 1.563000 3.125000 6.250000 12.500000 25 50 100 200 400 800");

static struct attribute *kmx61_acc_attributes[] =;

static struct attribute *kmx61_mag_attributes[] =;

static const struct attribute_group kmx61_acc_attribute_group =;

static const struct attribute_group kmx61_mag_attribute_group =;

static const struct iio_event_spec kmx61_event =;

#define KMX61_ACC_CHAN(_axis)

#define KMX61_MAG_CHAN(_axis)

static const struct iio_chan_spec kmx61_acc_channels[] =;

static const struct iio_chan_spec kmx61_mag_channels[] =;

static void kmx61_set_data(struct iio_dev *indio_dev, struct kmx61_data *data)
{}

static struct kmx61_data *kmx61_get_data(struct iio_dev *indio_dev)
{}

static int kmx61_convert_freq_to_bit(int val, int val2)
{}

static int kmx61_convert_wake_up_odr_to_bit(int val, int val2)
{}

/**
 * kmx61_set_mode() - set KMX61 device operating mode
 * @data: kmx61 device private data pointer
 * @mode: bitmask, indicating operating mode for @device
 * @device: bitmask, indicating device for which @mode needs to be set
 * @update: update stby bits stored in device's private  @data
 *
 * For each sensor (accelerometer/magnetometer) there are two operating modes
 * STANDBY and OPERATION. Neither accel nor magn can be disabled independently
 * if they are both enabled. Internal sensors state is saved in acc_stby and
 * mag_stby members of driver's private @data.
 */
static int kmx61_set_mode(struct kmx61_data *data, u8 mode, u8 device,
			  bool update)
{}

static int kmx61_get_mode(struct kmx61_data *data, u8 *mode, u8 device)
{}

static int kmx61_set_wake_up_odr(struct kmx61_data *data, int val, int val2)
{}

static int kmx61_set_odr(struct kmx61_data *data, int val, int val2, u8 device)
{}

static int kmx61_get_odr(struct kmx61_data *data, int *val, int *val2,
			 u8 device)
{}

static int kmx61_set_range(struct kmx61_data *data, u8 range)
{}

static int kmx61_set_scale(struct kmx61_data *data, u16 uscale)
{}

static int kmx61_chip_init(struct kmx61_data *data)
{}

static int kmx61_setup_new_data_interrupt(struct kmx61_data *data,
					  bool status, u8 device)
{}

static int kmx61_chip_update_thresholds(struct kmx61_data *data)
{}

static int kmx61_setup_any_motion_interrupt(struct kmx61_data *data,
					    bool status)
{}

/**
 * kmx61_set_power_state() - set power state for kmx61 @device
 * @data: kmx61 device private pointer
 * @on: power state to be set for @device
 * @device: bitmask indicating device for which @on state needs to be set
 *
 * Notice that when ACC power state needs to be set to ON and MAG is in
 * OPERATION then we know that kmx61_runtime_resume was already called
 * so we must set ACC OPERATION mode here. The same happens when MAG power
 * state needs to be set to ON and ACC is in OPERATION.
 */
static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device)
{}

static int kmx61_read_measurement(struct kmx61_data *data, u8 base, u8 offset)
{}

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

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

static int kmx61_read_event(struct iio_dev *indio_dev,
			    const struct iio_chan_spec *chan,
			    enum iio_event_type type,
			    enum iio_event_direction dir,
			    enum iio_event_info info,
			    int *val, int *val2)
{}

static int kmx61_write_event(struct iio_dev *indio_dev,
			     const struct iio_chan_spec *chan,
			     enum iio_event_type type,
			     enum iio_event_direction dir,
			     enum iio_event_info info,
			     int val, int val2)
{}

static int kmx61_read_event_config(struct iio_dev *indio_dev,
				   const struct iio_chan_spec *chan,
				   enum iio_event_type type,
				   enum iio_event_direction dir)
{}

static int kmx61_write_event_config(struct iio_dev *indio_dev,
				    const struct iio_chan_spec *chan,
				    enum iio_event_type type,
				    enum iio_event_direction dir,
				    int state)
{}

static int kmx61_acc_validate_trigger(struct iio_dev *indio_dev,
				      struct iio_trigger *trig)
{}

static int kmx61_mag_validate_trigger(struct iio_dev *indio_dev,
				      struct iio_trigger *trig)
{}

static const struct iio_info kmx61_acc_info =;

static const struct iio_info kmx61_mag_info =;


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

static void kmx61_trig_reenable(struct iio_trigger *trig)
{}

static const struct iio_trigger_ops kmx61_trigger_ops =;

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

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

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

static const char *kmx61_match_acpi_device(struct device *dev)
{}

static struct iio_dev *kmx61_indiodev_setup(struct kmx61_data *data,
					    const struct iio_info *info,
					    const struct iio_chan_spec *chan,
					    int num_channels,
					    const char *name)
{}

static struct iio_trigger *kmx61_trigger_setup(struct kmx61_data *data,
					       struct iio_dev *indio_dev,
					       const char *tag)
{}

static int kmx61_probe(struct i2c_client *client)
{}

static void kmx61_remove(struct i2c_client *client)
{}

static int kmx61_suspend(struct device *dev)
{}

static int kmx61_resume(struct device *dev)
{}

static int kmx61_runtime_suspend(struct device *dev)
{}

static int kmx61_runtime_resume(struct device *dev)
{}

static const struct dev_pm_ops kmx61_pm_ops =;

static const struct acpi_device_id kmx61_acpi_match[] =;

MODULE_DEVICE_TABLE(acpi, kmx61_acpi_match);

static const struct i2c_device_id kmx61_id[] =;

MODULE_DEVICE_TABLE(i2c, kmx61_id);

static struct i2c_driver kmx61_driver =;

module_i2c_driver();

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