/*
* sca3000_core.c -- support VTI sca3000 series accelerometers via SPI
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Copyright (c) 2009 Jonathan Cameron <jic23@kernel.org>
*
* See industrialio/accels/sca3000.h for comments.
*/
#include <linux/interrupt.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/spi/spi.h>
#include <linux/sysfs.h>
#include <linux/module.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/events.h>
#include <linux/iio/buffer.h>
#include "sca3000.h"
enum sca3000_variant {
d01,
e02,
e04,
e05,
};
/* Note where option modes are not defined, the chip simply does not
* support any.
* Other chips in the sca3000 series use i2c and are not included here.
*
* Some of these devices are only listed in the family data sheet and
* do not actually appear to be available.
*/
static const struct sca3000_chip_info sca3000_spi_chip_info_tbl[] = {
[d01] = {
.scale = 7357,
.temp_output = true,
.measurement_mode_freq = 250,
.option_mode_1 = SCA3000_OP_MODE_BYPASS,
.option_mode_1_freq = 250,
.mot_det_mult_xz = {50, 100, 200, 350, 650, 1300},
.mot_det_mult_y = {50, 100, 150, 250, 450, 850, 1750},
},
[e02] = {
.scale = 9810,
.measurement_mode_freq = 125,
.option_mode_1 = SCA3000_OP_MODE_NARROW,
.option_mode_1_freq = 63,
.mot_det_mult_xz = {100, 150, 300, 550, 1050, 2050},
.mot_det_mult_y = {50, 100, 200, 350, 700, 1350, 2700},
},
[e04] = {
.scale = 19620,
.measurement_mode_freq = 100,
.option_mode_1 = SCA3000_OP_MODE_NARROW,
.option_mode_1_freq = 50,
.option_mode_2 = SCA3000_OP_MODE_WIDE,
.option_mode_2_freq = 400,
.mot_det_mult_xz = {200, 300, 600, 1100, 2100, 4100},
.mot_det_mult_y = {100, 200, 400, 7000, 1400, 2700, 54000},
},
[e05] = {
.scale = 61313,
.measurement_mode_freq = 200,
.option_mode_1 = SCA3000_OP_MODE_NARROW,
.option_mode_1_freq = 50,
.option_mode_2 = SCA3000_OP_MODE