Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
/*
|
2010-05-04 21:43:03 +08:00
|
|
|
* iio/adc/max1363.c
|
|
|
|
* Copyright (C) 2008-2010 Jonathan Cameron
|
|
|
|
*
|
|
|
|
* based on linux/drivers/i2c/chips/max123x
|
|
|
|
* Copyright (C) 2002-2004 Stefan Eletzhofer
|
|
|
|
*
|
|
|
|
* based on linux/drivers/acron/char/pcf8583.c
|
|
|
|
* Copyright (C) 2000 Russell King
|
|
|
|
*
|
2014-10-02 03:59:00 +08:00
|
|
|
* Driver for max1363 and similar chips.
|
|
|
|
*
|
2010-05-04 21:43:03 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/regulator/consumer.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2010-06-26 19:54:14 +08:00
|
|
|
#include <linux/err.h>
|
2011-07-04 03:49:50 +08:00
|
|
|
#include <linux/module.h>
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
|
2012-04-25 22:54:58 +08:00
|
|
|
#include <linux/iio/iio.h>
|
|
|
|
#include <linux/iio/sysfs.h>
|
|
|
|
#include <linux/iio/events.h>
|
|
|
|
#include <linux/iio/buffer.h>
|
|
|
|
#include <linux/iio/driver.h>
|
2012-10-06 21:10:05 +08:00
|
|
|
#include <linux/iio/kfifo_buf.h>
|
|
|
|
#include <linux/iio/trigger_consumer.h>
|
2012-12-31 07:26:00 +08:00
|
|
|
#include <linux/iio/triggered_buffer.h>
|
2012-10-06 21:10:05 +08:00
|
|
|
|
|
|
|
#define MAX1363_SETUP_BYTE(a) ((a) | 0x80)
|
|
|
|
|
|
|
|
/* There is a fair bit more defined here than currently
|
|
|
|
* used, but the intention is to support everything these
|
|
|
|
* chips do in the long run */
|
|
|
|
|
|
|
|
/* see data sheets */
|
|
|
|
/* max1363 and max1236, max1237, max1238, max1239 */
|
|
|
|
#define MAX1363_SETUP_AIN3_IS_AIN3_REF_IS_VDD 0x00
|
|
|
|
#define MAX1363_SETUP_AIN3_IS_REF_EXT_TO_REF 0x20
|
|
|
|
#define MAX1363_SETUP_AIN3_IS_AIN3_REF_IS_INT 0x40
|
|
|
|
#define MAX1363_SETUP_AIN3_IS_REF_REF_IS_INT 0x60
|
|
|
|
#define MAX1363_SETUP_POWER_UP_INT_REF 0x10
|
|
|
|
#define MAX1363_SETUP_POWER_DOWN_INT_REF 0x00
|
|
|
|
|
2012-12-31 07:26:00 +08:00
|
|
|
/* think about including max11600 etc - more settings */
|
2012-10-06 21:10:05 +08:00
|
|
|
#define MAX1363_SETUP_EXT_CLOCK 0x08
|
|
|
|
#define MAX1363_SETUP_INT_CLOCK 0x00
|
|
|
|
#define MAX1363_SETUP_UNIPOLAR 0x00
|
|
|
|
#define MAX1363_SETUP_BIPOLAR 0x04
|
|
|
|
#define MAX1363_SETUP_RESET 0x00
|
|
|
|
#define MAX1363_SETUP_NORESET 0x02
|
|
|
|
/* max1363 only - though don't care on others.
|
|
|
|
* For now monitor modes are not implemented as the relevant
|
|
|
|
* line is not connected on my test board.
|
|
|
|
* The definitions are here as I intend to add this soon.
|
|
|
|
*/
|
|
|
|
#define MAX1363_SETUP_MONITOR_SETUP 0x01
|
|
|
|
|
|
|
|
/* Specific to the max1363 */
|
|
|
|
#define MAX1363_MON_RESET_CHAN(a) (1 << ((a) + 4))
|
|
|
|
#define MAX1363_MON_INT_ENABLE 0x01
|
|
|
|
|
|
|
|
/* defined for readability reasons */
|
|
|
|
/* All chips */
|
|
|
|
#define MAX1363_CONFIG_BYTE(a) ((a))
|
|
|
|
|
|
|
|
#define MAX1363_CONFIG_SE 0x01
|
|
|
|
#define MAX1363_CONFIG_DE 0x00
|
|
|
|
#define MAX1363_CONFIG_SCAN_TO_CS 0x00
|
|
|
|
#define MAX1363_CONFIG_SCAN_SINGLE_8 0x20
|
|
|
|
#define MAX1363_CONFIG_SCAN_MONITOR_MODE 0x40
|
|
|
|
#define MAX1363_CONFIG_SCAN_SINGLE_1 0x60
|
|
|
|
/* max123{6-9} only */
|
|
|
|
#define MAX1236_SCAN_MID_TO_CHANNEL 0x40
|
|
|
|
|
2012-12-31 07:26:00 +08:00
|
|
|
/* max1363 only - merely part of channel selects or don't care for others */
|
2012-10-06 21:10:05 +08:00
|
|
|
#define MAX1363_CONFIG_EN_MON_MODE_READ 0x18
|
|
|
|
|
|
|
|
#define MAX1363_CHANNEL_SEL(a) ((a) << 1)
|
|
|
|
|
|
|
|
/* max1363 strictly 0x06 - but doesn't matter */
|
|
|
|
#define MAX1363_CHANNEL_SEL_MASK 0x1E
|
|
|
|
#define MAX1363_SCAN_MASK 0x60
|
|
|
|
#define MAX1363_SE_DE_MASK 0x01
|
|
|
|
|
|
|
|
#define MAX1363_MAX_CHANNELS 25
|
|
|
|
/**
|
|
|
|
* struct max1363_mode - scan mode information
|
|
|
|
* @conf: The corresponding value of the configuration register
|
|
|
|
* @modemask: Bit mask corresponding to channels enabled in this mode
|
|
|
|
*/
|
|
|
|
struct max1363_mode {
|
|
|
|
int8_t conf;
|
|
|
|
DECLARE_BITMAP(modemask, MAX1363_MAX_CHANNELS);
|
|
|
|
};
|
2011-08-13 00:08:43 +08:00
|
|
|
|
2012-10-06 21:10:05 +08:00
|
|
|
/* This must be maintained along side the max1363_mode_table in max1363_core */
|
|
|
|
enum max1363_modes {
|
|
|
|
/* Single read of a single channel */
|
|
|
|
_s0, _s1, _s2, _s3, _s4, _s5, _s6, _s7, _s8, _s9, _s10, _s11,
|
|
|
|
/* Differential single read */
|
|
|
|
d0m1, d2m3, d4m5, d6m7, d8m9, d10m11,
|
|
|
|
d1m0, d3m2, d5m4, d7m6, d9m8, d11m10,
|
|
|
|
/* Scan to channel and mid to channel where overlapping */
|
|
|
|
s0to1, s0to2, s2to3, s0to3, s0to4, s0to5, s0to6,
|
|
|
|
s6to7, s0to7, s6to8, s0to8, s6to9,
|
|
|
|
s0to9, s6to10, s0to10, s6to11, s0to11,
|
|
|
|
/* Differential scan to channel and mid to channel where overlapping */
|
|
|
|
d0m1to2m3, d0m1to4m5, d0m1to6m7, d6m7to8m9,
|
|
|
|
d0m1to8m9, d6m7to10m11, d0m1to10m11, d1m0to3m2,
|
|
|
|
d1m0to5m4, d1m0to7m6, d7m6to9m8, d1m0to9m8,
|
|
|
|
d7m6to11m10, d1m0to11m10,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct max1363_chip_info - chip specifc information
|
|
|
|
* @info: iio core function callbacks structure
|
2012-10-06 21:37:44 +08:00
|
|
|
* @channels: channel specification
|
|
|
|
* @num_channels: number of channels
|
2012-10-06 21:10:05 +08:00
|
|
|
* @mode_list: array of available scan modes
|
|
|
|
* @default_mode: the scan mode in which the chip starts up
|
2012-10-06 21:37:44 +08:00
|
|
|
* @int_vref_mv: the internal reference voltage
|
2012-12-31 07:26:00 +08:00
|
|
|
* @num_modes: number of modes
|
2012-10-06 21:37:44 +08:00
|
|
|
* @bits: accuracy of the adc in bits
|
2012-10-06 21:10:05 +08:00
|
|
|
*/
|
|
|
|
struct max1363_chip_info {
|
|
|
|
const struct iio_info *info;
|
2012-10-06 21:37:44 +08:00
|
|
|
const struct iio_chan_spec *channels;
|
|
|
|
int num_channels;
|
2012-10-06 21:10:05 +08:00
|
|
|
const enum max1363_modes *mode_list;
|
|
|
|
enum max1363_modes default_mode;
|
|
|
|
u16 int_vref_mv;
|
|
|
|
u8 num_modes;
|
|
|
|
u8 bits;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct max1363_state - driver instance specific data
|
|
|
|
* @client: i2c_client
|
|
|
|
* @setupbyte: cache of current device setup byte
|
|
|
|
* @configbyte: cache of current device config byte
|
2012-12-31 07:26:00 +08:00
|
|
|
* @chip_info: chip model specific constants, available modes, etc.
|
2012-10-06 21:10:05 +08:00
|
|
|
* @current_mode: the scan mode of this chip
|
|
|
|
* @requestedmask: a valid requested set of channels
|
|
|
|
* @reg: supply regulator
|
|
|
|
* @monitor_on: whether monitor mode is enabled
|
|
|
|
* @monitor_speed: parameter corresponding to device monitor speed setting
|
|
|
|
* @mask_high: bitmask for enabled high thresholds
|
|
|
|
* @mask_low: bitmask for enabled low thresholds
|
|
|
|
* @thresh_high: high threshold values
|
|
|
|
* @thresh_low: low threshold values
|
2013-02-03 08:59:00 +08:00
|
|
|
* @vref: Reference voltage regulator
|
|
|
|
* @vref_uv: Actual (external or internal) reference voltage
|
2013-10-21 02:02:00 +08:00
|
|
|
* @send: function used to send data to the chip
|
|
|
|
* @recv: function used to receive data from the chip
|
2012-10-06 21:10:05 +08:00
|
|
|
*/
|
|
|
|
struct max1363_state {
|
|
|
|
struct i2c_client *client;
|
|
|
|
u8 setupbyte;
|
|
|
|
u8 configbyte;
|
|
|
|
const struct max1363_chip_info *chip_info;
|
|
|
|
const struct max1363_mode *current_mode;
|
|
|
|
u32 requestedmask;
|
|
|
|
struct regulator *reg;
|
|
|
|
|
|
|
|
/* Using monitor modes and buffer at the same time is
|
|
|
|
currently not supported */
|
|
|
|
bool monitor_on;
|
|
|
|
unsigned int monitor_speed:3;
|
|
|
|
u8 mask_high;
|
|
|
|
u8 mask_low;
|
|
|
|
/* 4x unipolar first then the fours bipolar ones */
|
|
|
|
s16 thresh_high[8];
|
|
|
|
s16 thresh_low[8];
|
2013-02-03 08:59:00 +08:00
|
|
|
struct regulator *vref;
|
|
|
|
u32 vref_uv;
|
2013-10-21 02:02:00 +08:00
|
|
|
int (*send)(const struct i2c_client *client,
|
|
|
|
const char *buf, int count);
|
|
|
|
int (*recv)(const struct i2c_client *client,
|
|
|
|
char *buf, int count);
|
2012-10-06 21:10:05 +08:00
|
|
|
};
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
|
2011-05-18 21:42:38 +08:00
|
|
|
#define MAX1363_MODE_SINGLE(_num, _mask) { \
|
|
|
|
.conf = MAX1363_CHANNEL_SEL(_num) \
|
|
|
|
| MAX1363_CONFIG_SCAN_SINGLE_1 \
|
|
|
|
| MAX1363_CONFIG_SE, \
|
2011-09-03 00:14:38 +08:00
|
|
|
.modemask[0] = _mask, \
|
2011-05-18 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX1363_MODE_SCAN_TO_CHANNEL(_num, _mask) { \
|
|
|
|
.conf = MAX1363_CHANNEL_SEL(_num) \
|
|
|
|
| MAX1363_CONFIG_SCAN_TO_CS \
|
|
|
|
| MAX1363_CONFIG_SE, \
|
2011-09-03 00:14:38 +08:00
|
|
|
.modemask[0] = _mask, \
|
2011-05-18 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* note not available for max1363 hence naming */
|
|
|
|
#define MAX1236_MODE_SCAN_MID_TO_CHANNEL(_mid, _num, _mask) { \
|
|
|
|
.conf = MAX1363_CHANNEL_SEL(_num) \
|
|
|
|
| MAX1236_SCAN_MID_TO_CHANNEL \
|
|
|
|
| MAX1363_CONFIG_SE, \
|
2011-09-03 00:14:38 +08:00
|
|
|
.modemask[0] = _mask \
|
2011-05-18 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX1363_MODE_DIFF_SINGLE(_nump, _numm, _mask) { \
|
|
|
|
.conf = MAX1363_CHANNEL_SEL(_nump) \
|
|
|
|
| MAX1363_CONFIG_SCAN_SINGLE_1 \
|
|
|
|
| MAX1363_CONFIG_DE, \
|
2011-09-03 00:14:38 +08:00
|
|
|
.modemask[0] = _mask \
|
2011-05-18 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Can't think how to automate naming so specify for now */
|
|
|
|
#define MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(_num, _numvals, _mask) { \
|
|
|
|
.conf = MAX1363_CHANNEL_SEL(_num) \
|
|
|
|
| MAX1363_CONFIG_SCAN_TO_CS \
|
|
|
|
| MAX1363_CONFIG_DE, \
|
2011-09-03 00:14:38 +08:00
|
|
|
.modemask[0] = _mask \
|
2011-05-18 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* note only available for max1363 hence naming */
|
|
|
|
#define MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(_num, _numvals, _mask) { \
|
|
|
|
.conf = MAX1363_CHANNEL_SEL(_num) \
|
|
|
|
| MAX1236_SCAN_MID_TO_CHANNEL \
|
|
|
|
| MAX1363_CONFIG_SE, \
|
2011-09-03 00:14:38 +08:00
|
|
|
.modemask[0] = _mask \
|
2011-05-18 21:42:38 +08:00
|
|
|
}
|
2010-05-04 21:43:03 +08:00
|
|
|
|
|
|
|
static const struct max1363_mode max1363_mode_table[] = {
|
|
|
|
/* All of the single channel options first */
|
|
|
|
MAX1363_MODE_SINGLE(0, 1 << 0),
|
|
|
|
MAX1363_MODE_SINGLE(1, 1 << 1),
|
|
|
|
MAX1363_MODE_SINGLE(2, 1 << 2),
|
|
|
|
MAX1363_MODE_SINGLE(3, 1 << 3),
|
|
|
|
MAX1363_MODE_SINGLE(4, 1 << 4),
|
|
|
|
MAX1363_MODE_SINGLE(5, 1 << 5),
|
|
|
|
MAX1363_MODE_SINGLE(6, 1 << 6),
|
|
|
|
MAX1363_MODE_SINGLE(7, 1 << 7),
|
|
|
|
MAX1363_MODE_SINGLE(8, 1 << 8),
|
|
|
|
MAX1363_MODE_SINGLE(9, 1 << 9),
|
|
|
|
MAX1363_MODE_SINGLE(10, 1 << 10),
|
|
|
|
MAX1363_MODE_SINGLE(11, 1 << 11),
|
|
|
|
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(0, 1, 1 << 12),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(2, 3, 1 << 13),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(4, 5, 1 << 14),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(6, 7, 1 << 15),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(8, 9, 1 << 16),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(10, 11, 1 << 17),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(1, 0, 1 << 18),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(3, 2, 1 << 19),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(5, 4, 1 << 20),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(7, 6, 1 << 21),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(9, 8, 1 << 22),
|
|
|
|
MAX1363_MODE_DIFF_SINGLE(11, 10, 1 << 23),
|
|
|
|
|
|
|
|
/* The multichannel scans next */
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(1, 0x003),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(2, 0x007),
|
|
|
|
MAX1236_MODE_SCAN_MID_TO_CHANNEL(2, 3, 0x00C),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(3, 0x00F),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(4, 0x01F),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(5, 0x03F),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(6, 0x07F),
|
|
|
|
MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 7, 0x0C0),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(7, 0x0FF),
|
|
|
|
MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 8, 0x1C0),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(8, 0x1FF),
|
|
|
|
MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 9, 0x3C0),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(9, 0x3FF),
|
|
|
|
MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 10, 0x7C0),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(10, 0x7FF),
|
|
|
|
MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 11, 0xFC0),
|
|
|
|
MAX1363_MODE_SCAN_TO_CHANNEL(11, 0xFFF),
|
|
|
|
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(2, 2, 0x003000),
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(4, 3, 0x007000),
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(6, 4, 0x00F000),
|
|
|
|
MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(8, 2, 0x018000),
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(8, 5, 0x01F000),
|
|
|
|
MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(10, 3, 0x038000),
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(10, 6, 0x3F000),
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(3, 2, 0x0C0000),
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(5, 3, 0x1C0000),
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(7, 4, 0x3C0000),
|
|
|
|
MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(9, 2, 0x600000),
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(9, 5, 0x7C0000),
|
|
|
|
MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(11, 3, 0xE00000),
|
|
|
|
MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(11, 6, 0xFC0000),
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
};
|
|
|
|
|
2012-10-06 21:10:05 +08:00
|
|
|
static const struct max1363_mode
|
2011-12-06 05:37:15 +08:00
|
|
|
*max1363_match_mode(const unsigned long *mask,
|
2012-12-31 07:26:00 +08:00
|
|
|
const struct max1363_chip_info *ci)
|
2010-05-05 13:24:05 +08:00
|
|
|
{
|
2010-05-04 21:43:03 +08:00
|
|
|
int i;
|
|
|
|
if (mask)
|
|
|
|
for (i = 0; i < ci->num_modes; i++)
|
2011-09-03 00:14:38 +08:00
|
|
|
if (bitmap_subset(mask,
|
|
|
|
max1363_mode_table[ci->mode_list[i]].
|
|
|
|
modemask,
|
|
|
|
MAX1363_MAX_CHANNELS))
|
2010-05-05 13:24:05 +08:00
|
|
|
return &max1363_mode_table[ci->mode_list[i]];
|
|
|
|
return NULL;
|
2010-05-23 15:10:30 +08:00
|
|
|
}
|
2010-05-04 21:43:03 +08:00
|
|
|
|
2013-10-21 02:02:00 +08:00
|
|
|
static int max1363_smbus_send(const struct i2c_client *client, const char *buf,
|
|
|
|
int count)
|
2010-05-04 21:43:03 +08:00
|
|
|
{
|
2013-10-21 02:02:00 +08:00
|
|
|
int i, err;
|
2010-05-04 21:43:03 +08:00
|
|
|
|
2013-10-21 02:02:00 +08:00
|
|
|
for (i = err = 0; err == 0 && i < count; ++i)
|
|
|
|
err = i2c_smbus_write_byte(client, buf[i]);
|
|
|
|
|
|
|
|
return err ? err : count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int max1363_smbus_recv(const struct i2c_client *client, char *buf,
|
|
|
|
int count)
|
|
|
|
{
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
ret = i2c_smbus_read_byte(client);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
buf[i] = ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int max1363_write_basic_config(struct max1363_state *st)
|
|
|
|
{
|
|
|
|
u8 tx_buf[2] = { st->setupbyte, st->configbyte };
|
|
|
|
|
|
|
|
return st->send(st->client, tx_buf, 2);
|
2010-05-04 21:43:03 +08:00
|
|
|
}
|
|
|
|
|
2012-10-06 21:10:05 +08:00
|
|
|
static int max1363_set_scan_mode(struct max1363_state *st)
|
2010-05-04 21:43:03 +08:00
|
|
|
{
|
|
|
|
st->configbyte &= ~(MAX1363_CHANNEL_SEL_MASK
|
|
|
|
| MAX1363_SCAN_MASK
|
|
|
|
| MAX1363_SE_DE_MASK);
|
|
|
|
st->configbyte |= st->current_mode->conf;
|
|
|
|
|
2013-10-21 02:02:00 +08:00
|
|
|
return max1363_write_basic_config(st);
|
2010-05-04 21:43:03 +08:00
|
|
|
}
|
|
|
|
|
2011-05-18 21:40:53 +08:00
|
|
|
static int max1363_read_single_chan(struct iio_dev *indio_dev,
|
|
|
|
struct iio_chan_spec const *chan,
|
|
|
|
int *val,
|
|
|
|
long m)
|
2010-05-04 21:43:03 +08:00
|
|
|
{
|
2011-05-18 21:40:53 +08:00
|
|
|
int ret = 0;
|
|
|
|
s32 data;
|
2013-02-01 05:43:00 +08:00
|
|
|
u8 rxbuf[2];
|
2011-05-18 21:40:53 +08:00
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
|
|
|
struct i2c_client *client = st->client;
|
2010-05-04 21:43:03 +08:00
|
|
|
|
2011-04-16 01:55:58 +08:00
|
|
|
mutex_lock(&indio_dev->mlock);
|
2010-06-26 19:54:23 +08:00
|
|
|
/*
|
|
|
|
* If monitor mode is enabled, the method for reading a single
|
|
|
|
* channel will have to be rather different and has not yet
|
|
|
|
* been implemented.
|
2011-12-06 06:18:25 +08:00
|
|
|
*
|
|
|
|
* Also, cannot read directly if buffered capture enabled.
|
2010-06-26 19:54:23 +08:00
|
|
|
*/
|
2011-12-06 06:18:25 +08:00
|
|
|
if (st->monitor_on || iio_buffer_enabled(indio_dev)) {
|
2010-06-26 19:54:23 +08:00
|
|
|
ret = -EBUSY;
|
|
|
|
goto error_ret;
|
|
|
|
}
|
|
|
|
|
2011-12-06 06:18:25 +08:00
|
|
|
/* Check to see if current scan mode is correct */
|
|
|
|
if (st->current_mode != &max1363_mode_table[chan->address]) {
|
|
|
|
/* Update scan mode if needed */
|
|
|
|
st->current_mode = &max1363_mode_table[chan->address];
|
|
|
|
ret = max1363_set_scan_mode(st);
|
|
|
|
if (ret < 0)
|
|
|
|
goto error_ret;
|
|
|
|
}
|
|
|
|
if (st->chip_info->bits != 8) {
|
|
|
|
/* Get reading */
|
2013-10-21 02:02:00 +08:00
|
|
|
data = st->recv(client, rxbuf, 2);
|
2010-05-04 21:43:03 +08:00
|
|
|
if (data < 0) {
|
|
|
|
ret = data;
|
|
|
|
goto error_ret;
|
|
|
|
}
|
2013-02-01 05:43:00 +08:00
|
|
|
data = (rxbuf[1] | rxbuf[0] << 8) &
|
|
|
|
((1 << st->chip_info->bits) - 1);
|
2010-05-04 21:43:03 +08:00
|
|
|
} else {
|
2011-12-06 06:18:25 +08:00
|
|
|
/* Get reading */
|
2013-10-21 02:02:00 +08:00
|
|
|
data = st->recv(client, rxbuf, 1);
|
2011-12-06 06:18:25 +08:00
|
|
|
if (data < 0) {
|
|
|
|
ret = data;
|
|
|
|
goto error_ret;
|
2010-05-04 21:43:03 +08:00
|
|
|
}
|
2011-12-06 06:18:25 +08:00
|
|
|
data = rxbuf[0];
|
2010-05-04 21:43:03 +08:00
|
|
|
}
|
2011-05-18 21:40:53 +08:00
|
|
|
*val = data;
|
2010-05-04 21:43:03 +08:00
|
|
|
error_ret:
|
2011-04-16 01:55:58 +08:00
|
|
|
mutex_unlock(&indio_dev->mlock);
|
2011-05-18 21:40:53 +08:00
|
|
|
return ret;
|
|
|
|
|
2010-05-04 21:43:03 +08:00
|
|
|
}
|
|
|
|
|
2011-05-18 21:40:53 +08:00
|
|
|
static int max1363_read_raw(struct iio_dev *indio_dev,
|
|
|
|
struct iio_chan_spec const *chan,
|
|
|
|
int *val,
|
|
|
|
int *val2,
|
|
|
|
long m)
|
2010-05-04 21:43:03 +08:00
|
|
|
{
|
2011-05-18 21:40:53 +08:00
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
|
|
|
int ret;
|
2013-02-03 08:59:00 +08:00
|
|
|
|
2011-05-18 21:40:53 +08:00
|
|
|
switch (m) {
|
2012-04-16 00:41:18 +08:00
|
|
|
case IIO_CHAN_INFO_RAW:
|
2011-05-18 21:40:53 +08:00
|
|
|
ret = max1363_read_single_chan(indio_dev, chan, val, m);
|
2011-08-12 23:55:29 +08:00
|
|
|
if (ret < 0)
|
2011-05-18 21:40:53 +08:00
|
|
|
return ret;
|
|
|
|
return IIO_VAL_INT;
|
2011-10-27 00:41:36 +08:00
|
|
|
case IIO_CHAN_INFO_SCALE:
|
2013-09-28 17:31:00 +08:00
|
|
|
*val = st->vref_uv / 1000;
|
|
|
|
*val2 = st->chip_info->bits;
|
|
|
|
return IIO_VAL_FRACTIONAL_LOG2;
|
2011-05-18 21:40:53 +08:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
2010-05-04 21:43:03 +08:00
|
|
|
}
|
|
|
|
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
/* Applies to max1363 */
|
|
|
|
static const enum max1363_modes max1363_mode_list[] = {
|
|
|
|
_s0, _s1, _s2, _s3,
|
|
|
|
s0to1, s0to2, s0to3,
|
|
|
|
d0m1, d2m3, d1m0, d3m2,
|
|
|
|
d0m1to2m3, d1m0to3m2,
|
|
|
|
};
|
|
|
|
|
2013-10-07 22:11:00 +08:00
|
|
|
static const struct iio_event_spec max1363_events[] = {
|
|
|
|
{
|
|
|
|
.type = IIO_EV_TYPE_THRESH,
|
|
|
|
.dir = IIO_EV_DIR_RISING,
|
|
|
|
.mask_separate = BIT(IIO_EV_INFO_VALUE) |
|
|
|
|
BIT(IIO_EV_INFO_ENABLE),
|
|
|
|
}, {
|
|
|
|
.type = IIO_EV_TYPE_THRESH,
|
|
|
|
.dir = IIO_EV_DIR_FALLING,
|
|
|
|
.mask_separate = BIT(IIO_EV_INFO_VALUE) |
|
|
|
|
BIT(IIO_EV_INFO_ENABLE),
|
|
|
|
},
|
|
|
|
};
|
2013-02-20 05:11:35 +08:00
|
|
|
|
2013-10-07 22:11:00 +08:00
|
|
|
#define MAX1363_CHAN_U(num, addr, si, bits, ev_spec, num_ev_spec) \
|
2011-09-03 00:14:45 +08:00
|
|
|
{ \
|
|
|
|
.type = IIO_VOLTAGE, \
|
|
|
|
.indexed = 1, \
|
|
|
|
.channel = num, \
|
|
|
|
.address = addr, \
|
2013-02-20 05:11:35 +08:00
|
|
|
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
|
|
|
|
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
|
2011-12-06 05:56:01 +08:00
|
|
|
.datasheet_name = "AIN"#num, \
|
2011-12-06 05:37:16 +08:00
|
|
|
.scan_type = { \
|
|
|
|
.sign = 'u', \
|
|
|
|
.realbits = bits, \
|
|
|
|
.storagebits = (bits > 8) ? 16 : 8, \
|
|
|
|
.endianness = IIO_BE, \
|
|
|
|
}, \
|
2011-09-03 00:14:45 +08:00
|
|
|
.scan_index = si, \
|
2013-10-07 22:11:00 +08:00
|
|
|
.event_spec = ev_spec, \
|
|
|
|
.num_event_specs = num_ev_spec, \
|
2011-09-03 00:14:45 +08:00
|
|
|
}
|
2011-05-18 21:40:53 +08:00
|
|
|
|
|
|
|
/* bipolar channel */
|
2013-10-07 22:11:00 +08:00
|
|
|
#define MAX1363_CHAN_B(num, num2, addr, si, bits, ev_spec, num_ev_spec) \
|
2011-09-03 00:14:45 +08:00
|
|
|
{ \
|
|
|
|
.type = IIO_VOLTAGE, \
|
|
|
|
.differential = 1, \
|
|
|
|
.indexed = 1, \
|
|
|
|
.channel = num, \
|
|
|
|
.channel2 = num2, \
|
|
|
|
.address = addr, \
|
2013-02-20 05:11:35 +08:00
|
|
|
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
|
|
|
|
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
|
2011-12-06 05:56:01 +08:00
|
|
|
.datasheet_name = "AIN"#num"-AIN"#num2, \
|
2011-12-06 05:37:16 +08:00
|
|
|
.scan_type = { \
|
|
|
|
.sign = 's', \
|
|
|
|
.realbits = bits, \
|
|
|
|
.storagebits = (bits > 8) ? 16 : 8, \
|
|
|
|
.endianness = IIO_BE, \
|
|
|
|
}, \
|
2011-09-03 00:14:45 +08:00
|
|
|
.scan_index = si, \
|
2013-10-07 22:11:00 +08:00
|
|
|
.event_spec = ev_spec, \
|
|
|
|
.num_event_specs = num_ev_spec, \
|
2011-05-18 21:40:53 +08:00
|
|
|
}
|
|
|
|
|
2013-10-07 22:11:00 +08:00
|
|
|
#define MAX1363_4X_CHANS(bits, ev_spec, num_ev_spec) { \
|
|
|
|
MAX1363_CHAN_U(0, _s0, 0, bits, ev_spec, num_ev_spec), \
|
|
|
|
MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec), \
|
|
|
|
MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec), \
|
|
|
|
MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec), \
|
|
|
|
MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec), \
|
|
|
|
MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec), \
|
|
|
|
MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec), \
|
|
|
|
MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec), \
|
|
|
|
IIO_CHAN_SOFT_TIMESTAMP(8) \
|
2011-09-03 00:14:45 +08:00
|
|
|
}
|
|
|
|
|
2013-10-07 22:11:00 +08:00
|
|
|
static const struct iio_chan_spec max1036_channels[] =
|
|
|
|
MAX1363_4X_CHANS(8, NULL, 0);
|
|
|
|
static const struct iio_chan_spec max1136_channels[] =
|
|
|
|
MAX1363_4X_CHANS(10, NULL, 0);
|
|
|
|
static const struct iio_chan_spec max1236_channels[] =
|
|
|
|
MAX1363_4X_CHANS(12, NULL, 0);
|
2012-08-09 15:51:00 +08:00
|
|
|
static const struct iio_chan_spec max1361_channels[] =
|
2013-10-07 22:11:00 +08:00
|
|
|
MAX1363_4X_CHANS(10, max1363_events, ARRAY_SIZE(max1363_events));
|
2012-08-09 15:51:00 +08:00
|
|
|
static const struct iio_chan_spec max1363_channels[] =
|
2013-10-07 22:11:00 +08:00
|
|
|
MAX1363_4X_CHANS(12, max1363_events, ARRAY_SIZE(max1363_events));
|
2011-05-18 21:40:53 +08:00
|
|
|
|
2012-03-01 14:00:38 +08:00
|
|
|
/* Applies to max1236, max1237 */
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
static const enum max1363_modes max1236_mode_list[] = {
|
|
|
|
_s0, _s1, _s2, _s3,
|
|
|
|
s0to1, s0to2, s0to3,
|
|
|
|
d0m1, d2m3, d1m0, d3m2,
|
|
|
|
d0m1to2m3, d1m0to3m2,
|
|
|
|
s2to3,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Applies to max1238, max1239 */
|
|
|
|
static const enum max1363_modes max1238_mode_list[] = {
|
|
|
|
_s0, _s1, _s2, _s3, _s4, _s5, _s6, _s7, _s8, _s9, _s10, _s11,
|
|
|
|
s0to1, s0to2, s0to3, s0to4, s0to5, s0to6,
|
|
|
|
s0to7, s0to8, s0to9, s0to10, s0to11,
|
|
|
|
d0m1, d2m3, d4m5, d6m7, d8m9, d10m11,
|
|
|
|
d1m0, d3m2, d5m4, d7m6, d9m8, d11m10,
|
|
|
|
d0m1to2m3, d0m1to4m5, d0m1to6m7, d0m1to8m9, d0m1to10m11,
|
|
|
|
d1m0to3m2, d1m0to5m4, d1m0to7m6, d1m0to9m8, d1m0to11m10,
|
|
|
|
s6to7, s6to8, s6to9, s6to10, s6to11,
|
2010-05-04 21:43:03 +08:00
|
|
|
d6m7to8m9, d6m7to10m11, d7m6to9m8, d7m6to11m10,
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
};
|
|
|
|
|
2013-10-07 22:11:00 +08:00
|
|
|
#define MAX1363_12X_CHANS(bits) { \
|
|
|
|
MAX1363_CHAN_U(0, _s0, 0, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(1, _s1, 1, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(2, _s2, 2, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(3, _s3, 3, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(4, _s4, 4, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(5, _s5, 5, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(6, _s6, 6, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(7, _s7, 7, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(8, _s8, 8, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(9, _s9, 9, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(10, _s10, 10, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(11, _s11, 11, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(0, 1, d0m1, 12, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(2, 3, d2m3, 13, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(4, 5, d4m5, 14, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(6, 7, d6m7, 15, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(8, 9, d8m9, 16, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(10, 11, d10m11, 17, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(1, 0, d1m0, 18, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(3, 2, d3m2, 19, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(5, 4, d5m4, 20, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(7, 6, d7m6, 21, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(9, 8, d9m8, 22, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(11, 10, d11m10, 23, bits, NULL, 0), \
|
|
|
|
IIO_CHAN_SOFT_TIMESTAMP(24) \
|
2011-05-18 21:40:53 +08:00
|
|
|
}
|
2012-08-09 15:51:00 +08:00
|
|
|
static const struct iio_chan_spec max1038_channels[] = MAX1363_12X_CHANS(8);
|
|
|
|
static const struct iio_chan_spec max1138_channels[] = MAX1363_12X_CHANS(10);
|
|
|
|
static const struct iio_chan_spec max1238_channels[] = MAX1363_12X_CHANS(12);
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
|
2010-05-04 21:43:09 +08:00
|
|
|
static const enum max1363_modes max11607_mode_list[] = {
|
|
|
|
_s0, _s1, _s2, _s3,
|
|
|
|
s0to1, s0to2, s0to3,
|
|
|
|
s2to3,
|
|
|
|
d0m1, d2m3, d1m0, d3m2,
|
|
|
|
d0m1to2m3, d1m0to3m2,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const enum max1363_modes max11608_mode_list[] = {
|
|
|
|
_s0, _s1, _s2, _s3, _s4, _s5, _s6, _s7,
|
|
|
|
s0to1, s0to2, s0to3, s0to4, s0to5, s0to6, s0to7,
|
|
|
|
s6to7,
|
|
|
|
d0m1, d2m3, d4m5, d6m7,
|
|
|
|
d1m0, d3m2, d5m4, d7m6,
|
|
|
|
d0m1to2m3, d0m1to4m5, d0m1to6m7,
|
|
|
|
d1m0to3m2, d1m0to5m4, d1m0to7m6,
|
|
|
|
};
|
|
|
|
|
2011-09-03 00:14:45 +08:00
|
|
|
#define MAX1363_8X_CHANS(bits) { \
|
2013-10-07 22:11:00 +08:00
|
|
|
MAX1363_CHAN_U(0, _s0, 0, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(1, _s1, 1, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(2, _s2, 2, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(3, _s3, 3, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(4, _s4, 4, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(5, _s5, 5, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(6, _s6, 6, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(7, _s7, 7, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(0, 1, d0m1, 8, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(2, 3, d2m3, 9, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(4, 5, d4m5, 10, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(6, 7, d6m7, 11, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(1, 0, d1m0, 12, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(3, 2, d3m2, 13, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(5, 4, d5m4, 14, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(7, 6, d7m6, 15, bits, NULL, 0), \
|
2011-09-03 00:14:45 +08:00
|
|
|
IIO_CHAN_SOFT_TIMESTAMP(16) \
|
|
|
|
}
|
2012-08-09 15:51:00 +08:00
|
|
|
static const struct iio_chan_spec max11602_channels[] = MAX1363_8X_CHANS(8);
|
|
|
|
static const struct iio_chan_spec max11608_channels[] = MAX1363_8X_CHANS(10);
|
|
|
|
static const struct iio_chan_spec max11614_channels[] = MAX1363_8X_CHANS(12);
|
2010-05-04 21:43:09 +08:00
|
|
|
|
2011-05-18 21:42:10 +08:00
|
|
|
static const enum max1363_modes max11644_mode_list[] = {
|
|
|
|
_s0, _s1, s0to1, d0m1, d1m0,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX1363_2X_CHANS(bits) { \
|
2013-10-07 22:11:00 +08:00
|
|
|
MAX1363_CHAN_U(0, _s0, 0, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_U(1, _s1, 1, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(0, 1, d0m1, 2, bits, NULL, 0), \
|
|
|
|
MAX1363_CHAN_B(1, 0, d1m0, 3, bits, NULL, 0), \
|
2011-05-18 21:42:10 +08:00
|
|
|
IIO_CHAN_SOFT_TIMESTAMP(4) \
|
|
|
|
}
|
|
|
|
|
2012-08-09 15:51:00 +08:00
|
|
|
static const struct iio_chan_spec max11646_channels[] = MAX1363_2X_CHANS(10);
|
|
|
|
static const struct iio_chan_spec max11644_channels[] = MAX1363_2X_CHANS(12);
|
2011-05-18 21:42:10 +08:00
|
|
|
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
enum { max1361,
|
|
|
|
max1362,
|
|
|
|
max1363,
|
|
|
|
max1364,
|
2010-05-04 21:43:10 +08:00
|
|
|
max1036,
|
|
|
|
max1037,
|
|
|
|
max1038,
|
|
|
|
max1039,
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
max1136,
|
|
|
|
max1137,
|
|
|
|
max1138,
|
|
|
|
max1139,
|
|
|
|
max1236,
|
|
|
|
max1237,
|
|
|
|
max1238,
|
|
|
|
max1239,
|
2010-05-04 21:43:10 +08:00
|
|
|
max11600,
|
|
|
|
max11601,
|
|
|
|
max11602,
|
|
|
|
max11603,
|
|
|
|
max11604,
|
|
|
|
max11605,
|
2010-05-04 21:43:09 +08:00
|
|
|
max11606,
|
|
|
|
max11607,
|
|
|
|
max11608,
|
|
|
|
max11609,
|
|
|
|
max11610,
|
|
|
|
max11611,
|
|
|
|
max11612,
|
|
|
|
max11613,
|
|
|
|
max11614,
|
|
|
|
max11615,
|
|
|
|
max11616,
|
|
|
|
max11617,
|
2011-05-18 21:42:10 +08:00
|
|
|
max11644,
|
|
|
|
max11645,
|
|
|
|
max11646,
|
|
|
|
max11647
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
};
|
|
|
|
|
2010-06-26 19:54:23 +08:00
|
|
|
static const int max1363_monitor_speeds[] = { 133000, 665000, 33300, 16600,
|
|
|
|
8300, 4200, 2000, 1000 };
|
|
|
|
|
|
|
|
static ssize_t max1363_monitor_show_freq(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
2012-05-12 21:39:42 +08:00
|
|
|
struct max1363_state *st = iio_priv(dev_to_iio_dev(dev));
|
2010-06-26 19:54:23 +08:00
|
|
|
return sprintf(buf, "%d\n", max1363_monitor_speeds[st->monitor_speed]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t max1363_monitor_store_freq(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf,
|
|
|
|
size_t len)
|
|
|
|
{
|
2012-05-12 21:39:42 +08:00
|
|
|
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
2011-04-16 01:55:59 +08:00
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
2010-06-26 19:54:23 +08:00
|
|
|
int i, ret;
|
|
|
|
unsigned long val;
|
|
|
|
bool found = false;
|
|
|
|
|
2013-06-01 15:10:00 +08:00
|
|
|
ret = kstrtoul(buf, 10, &val);
|
2010-06-26 19:54:23 +08:00
|
|
|
if (ret)
|
|
|
|
return -EINVAL;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(max1363_monitor_speeds); i++)
|
|
|
|
if (val == max1363_monitor_speeds[i]) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-04-16 01:55:58 +08:00
|
|
|
mutex_lock(&indio_dev->mlock);
|
2010-06-26 19:54:23 +08:00
|
|
|
st->monitor_speed = i;
|
2011-04-16 01:55:58 +08:00
|
|
|
mutex_unlock(&indio_dev->mlock);
|
2010-06-26 19:54:23 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR,
|
|
|
|
max1363_monitor_show_freq,
|
|
|
|
max1363_monitor_store_freq);
|
|
|
|
|
|
|
|
static IIO_CONST_ATTR(sampling_frequency_available,
|
|
|
|
"133000 665000 33300 16600 8300 4200 2000 1000");
|
|
|
|
|
2011-05-18 21:40:53 +08:00
|
|
|
static int max1363_read_thresh(struct iio_dev *indio_dev,
|
2013-10-07 22:11:00 +08:00
|
|
|
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)
|
2010-06-26 19:54:23 +08:00
|
|
|
{
|
2011-04-16 01:55:59 +08:00
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
2013-10-07 22:11:00 +08:00
|
|
|
if (dir == IIO_EV_DIR_FALLING)
|
|
|
|
*val = st->thresh_low[chan->channel];
|
2010-06-26 19:54:23 +08:00
|
|
|
else
|
2013-10-07 22:11:00 +08:00
|
|
|
*val = st->thresh_high[chan->channel];
|
|
|
|
return IIO_VAL_INT;
|
2010-06-26 19:54:23 +08:00
|
|
|
}
|
|
|
|
|
2011-05-18 21:40:53 +08:00
|
|
|
static int max1363_write_thresh(struct iio_dev *indio_dev,
|
2013-10-07 22:11:00 +08:00
|
|
|
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)
|
2010-06-26 19:54:23 +08:00
|
|
|
{
|
2011-05-18 21:40:53 +08:00
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
|
|
|
/* make it handle signed correctly as well */
|
2010-06-26 19:54:23 +08:00
|
|
|
switch (st->chip_info->bits) {
|
|
|
|
case 10:
|
|
|
|
if (val > 0x3FF)
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
if (val > 0xFFF)
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-10-07 22:11:00 +08:00
|
|
|
switch (dir) {
|
2011-05-18 21:40:53 +08:00
|
|
|
case IIO_EV_DIR_FALLING:
|
2013-10-07 22:11:00 +08:00
|
|
|
st->thresh_low[chan->channel] = val;
|
2010-06-26 19:54:23 +08:00
|
|
|
break;
|
2011-05-18 21:40:53 +08:00
|
|
|
case IIO_EV_DIR_RISING:
|
2013-10-07 22:11:00 +08:00
|
|
|
st->thresh_high[chan->channel] = val;
|
2010-06-26 19:54:23 +08:00
|
|
|
break;
|
2013-10-07 22:11:00 +08:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
2010-06-26 19:54:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-03 00:14:39 +08:00
|
|
|
static const u64 max1363_event_codes[] = {
|
2011-09-27 16:56:41 +08:00
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 0,
|
|
|
|
IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING),
|
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 1,
|
|
|
|
IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING),
|
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 2,
|
|
|
|
IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING),
|
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 3,
|
|
|
|
IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING),
|
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 0,
|
|
|
|
IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING),
|
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 1,
|
|
|
|
IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING),
|
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 2,
|
|
|
|
IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING),
|
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 3,
|
|
|
|
IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING),
|
2011-05-18 21:42:38 +08:00
|
|
|
};
|
|
|
|
|
2011-05-18 21:41:16 +08:00
|
|
|
static irqreturn_t max1363_event_handler(int irq, void *private)
|
2010-06-26 19:54:23 +08:00
|
|
|
{
|
2011-05-18 21:41:16 +08:00
|
|
|
struct iio_dev *indio_dev = private;
|
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
|
|
|
s64 timestamp = iio_get_time_ns();
|
2011-05-18 21:42:38 +08:00
|
|
|
unsigned long mask, loc;
|
2010-06-26 19:54:23 +08:00
|
|
|
u8 rx;
|
|
|
|
u8 tx[2] = { st->setupbyte,
|
|
|
|
MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0 };
|
|
|
|
|
2013-10-21 02:02:00 +08:00
|
|
|
st->recv(st->client, &rx, 1);
|
2011-05-18 21:42:38 +08:00
|
|
|
mask = rx;
|
|
|
|
for_each_set_bit(loc, &mask, 8)
|
2011-08-30 19:41:06 +08:00
|
|
|
iio_push_event(indio_dev, max1363_event_codes[loc], timestamp);
|
2013-10-21 02:02:00 +08:00
|
|
|
st->send(st->client, tx, 2);
|
2011-05-18 21:41:16 +08:00
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
2010-06-26 19:54:23 +08:00
|
|
|
}
|
|
|
|
|
2011-05-18 21:40:53 +08:00
|
|
|
static int max1363_read_event_config(struct iio_dev *indio_dev,
|
2013-10-07 22:11:00 +08:00
|
|
|
const struct iio_chan_spec *chan, enum iio_event_type type,
|
|
|
|
enum iio_event_direction dir)
|
2010-06-26 19:54:23 +08:00
|
|
|
{
|
2011-04-16 01:55:59 +08:00
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
2011-05-18 21:40:53 +08:00
|
|
|
int val;
|
2013-10-07 22:11:00 +08:00
|
|
|
int number = chan->channel;
|
2012-10-06 21:38:11 +08:00
|
|
|
|
2011-04-16 01:55:58 +08:00
|
|
|
mutex_lock(&indio_dev->mlock);
|
2013-10-07 22:11:00 +08:00
|
|
|
if (dir == IIO_EV_DIR_FALLING)
|
2011-05-18 21:40:53 +08:00
|
|
|
val = (1 << number) & st->mask_low;
|
2010-06-26 19:54:23 +08:00
|
|
|
else
|
2011-05-18 21:40:53 +08:00
|
|
|
val = (1 << number) & st->mask_high;
|
2011-04-16 01:55:58 +08:00
|
|
|
mutex_unlock(&indio_dev->mlock);
|
2010-06-26 19:54:23 +08:00
|
|
|
|
2011-05-18 21:40:53 +08:00
|
|
|
return val;
|
2010-06-26 19:54:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int max1363_monitor_mode_update(struct max1363_state *st, int enabled)
|
|
|
|
{
|
|
|
|
u8 *tx_buf;
|
|
|
|
int ret, i = 3, j;
|
|
|
|
unsigned long numelements;
|
|
|
|
int len;
|
2011-09-03 00:14:38 +08:00
|
|
|
const long *modemask;
|
2010-06-26 19:54:23 +08:00
|
|
|
|
|
|
|
if (!enabled) {
|
2012-10-06 21:19:01 +08:00
|
|
|
/* transition to buffered capture is not currently supported */
|
2010-06-26 19:54:23 +08:00
|
|
|
st->setupbyte &= ~MAX1363_SETUP_MONITOR_SETUP;
|
|
|
|
st->configbyte &= ~MAX1363_SCAN_MASK;
|
|
|
|
st->monitor_on = false;
|
2013-10-21 02:02:00 +08:00
|
|
|
return max1363_write_basic_config(st);
|
2010-06-26 19:54:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure we are in the relevant mode */
|
|
|
|
st->setupbyte |= MAX1363_SETUP_MONITOR_SETUP;
|
|
|
|
st->configbyte &= ~(MAX1363_CHANNEL_SEL_MASK
|
|
|
|
| MAX1363_SCAN_MASK
|
|
|
|
| MAX1363_SE_DE_MASK);
|
|
|
|
st->configbyte |= MAX1363_CONFIG_SCAN_MONITOR_MODE;
|
|
|
|
if ((st->mask_low | st->mask_high) & 0x0F) {
|
|
|
|
st->configbyte |= max1363_mode_table[s0to3].conf;
|
|
|
|
modemask = max1363_mode_table[s0to3].modemask;
|
|
|
|
} else if ((st->mask_low | st->mask_high) & 0x30) {
|
|
|
|
st->configbyte |= max1363_mode_table[d0m1to2m3].conf;
|
|
|
|
modemask = max1363_mode_table[d0m1to2m3].modemask;
|
|
|
|
} else {
|
|
|
|
st->configbyte |= max1363_mode_table[d1m0to3m2].conf;
|
|
|
|
modemask = max1363_mode_table[d1m0to3m2].modemask;
|
|
|
|
}
|
2011-09-03 00:14:38 +08:00
|
|
|
numelements = bitmap_weight(modemask, MAX1363_MAX_CHANNELS);
|
2010-06-26 19:54:23 +08:00
|
|
|
len = 3 * numelements + 3;
|
|
|
|
tx_buf = kmalloc(len, GFP_KERNEL);
|
|
|
|
if (!tx_buf) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto error_ret;
|
|
|
|
}
|
|
|
|
tx_buf[0] = st->configbyte;
|
|
|
|
tx_buf[1] = st->setupbyte;
|
|
|
|
tx_buf[2] = (st->monitor_speed << 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* So we need to do yet another bit of nefarious scan mode
|
|
|
|
* setup to match what we need.
|
|
|
|
*/
|
|
|
|
for (j = 0; j < 8; j++)
|
2011-09-03 00:14:38 +08:00
|
|
|
if (test_bit(j, modemask)) {
|
2010-06-26 19:54:23 +08:00
|
|
|
/* Establish the mode is in the scan */
|
|
|
|
if (st->mask_low & (1 << j)) {
|
|
|
|
tx_buf[i] = (st->thresh_low[j] >> 4) & 0xFF;
|
|
|
|
tx_buf[i + 1] = (st->thresh_low[j] << 4) & 0xF0;
|
|
|
|
} else if (j < 4) {
|
|
|
|
tx_buf[i] = 0;
|
|
|
|
tx_buf[i + 1] = 0;
|
|
|
|
} else {
|
|
|
|
tx_buf[i] = 0x80;
|
|
|
|
tx_buf[i + 1] = 0;
|
|
|
|
}
|
|
|
|
if (st->mask_high & (1 << j)) {
|
|
|
|
tx_buf[i + 1] |=
|
|
|
|
(st->thresh_high[j] >> 8) & 0x0F;
|
|
|
|
tx_buf[i + 2] = st->thresh_high[j] & 0xFF;
|
|
|
|
} else if (j < 4) {
|
|
|
|
tx_buf[i + 1] |= 0x0F;
|
|
|
|
tx_buf[i + 2] = 0xFF;
|
|
|
|
} else {
|
|
|
|
tx_buf[i + 1] |= 0x07;
|
|
|
|
tx_buf[i + 2] = 0xFF;
|
|
|
|
}
|
|
|
|
i += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-21 02:02:00 +08:00
|
|
|
ret = st->send(st->client, tx_buf, len);
|
2010-06-26 19:54:23 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto error_ret;
|
|
|
|
if (ret != len) {
|
|
|
|
ret = -EIO;
|
|
|
|
goto error_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that we hopefully have sensible thresholds in place it is
|
|
|
|
* time to turn the interrupts on.
|
|
|
|
* It is unclear from the data sheet if this should be necessary
|
|
|
|
* (i.e. whether monitor mode setup is atomic) but it appears to
|
|
|
|
* be in practice.
|
|
|
|
*/
|
|
|
|
tx_buf[0] = st->setupbyte;
|
|
|
|
tx_buf[1] = MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0;
|
2013-10-21 02:02:00 +08:00
|
|
|
ret = st->send(st->client, tx_buf, 2);
|
2010-06-26 19:54:23 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto error_ret;
|
|
|
|
if (ret != 2) {
|
|
|
|
ret = -EIO;
|
|
|
|
goto error_ret;
|
|
|
|
}
|
|
|
|
ret = 0;
|
|
|
|
st->monitor_on = true;
|
|
|
|
error_ret:
|
|
|
|
|
|
|
|
kfree(tx_buf);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-03-31 09:57:33 +08:00
|
|
|
* To keep this manageable we always use one of 3 scan modes.
|
2010-06-26 19:54:23 +08:00
|
|
|
* Scan 0...3, 0-1,2-3 and 1-0,3-2
|
|
|
|
*/
|
2011-05-18 21:40:53 +08:00
|
|
|
|
2010-06-26 19:54:23 +08:00
|
|
|
static inline int __max1363_check_event_mask(int thismask, int checkmask)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
/* Is it unipolar */
|
|
|
|
if (thismask < 4) {
|
|
|
|
if (checkmask & ~0x0F) {
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto error_ret;
|
|
|
|
}
|
|
|
|
} else if (thismask < 6) {
|
|
|
|
if (checkmask & ~0x30) {
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto error_ret;
|
|
|
|
}
|
|
|
|
} else if (checkmask & ~0xC0)
|
|
|
|
ret = -EBUSY;
|
|
|
|
error_ret:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-05-18 21:40:53 +08:00
|
|
|
static int max1363_write_event_config(struct iio_dev *indio_dev,
|
2013-10-07 22:11:00 +08:00
|
|
|
const struct iio_chan_spec *chan, enum iio_event_type type,
|
|
|
|
enum iio_event_direction dir, int state)
|
2010-06-26 19:54:23 +08:00
|
|
|
{
|
2011-05-18 21:40:53 +08:00
|
|
|
int ret = 0;
|
2011-04-16 01:55:59 +08:00
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
2010-06-26 19:54:23 +08:00
|
|
|
u16 unifiedmask;
|
2013-10-07 22:11:00 +08:00
|
|
|
int number = chan->channel;
|
2011-05-18 21:40:53 +08:00
|
|
|
|
2011-04-16 01:55:59 +08:00
|
|
|
mutex_lock(&indio_dev->mlock);
|
2010-06-26 19:54:23 +08:00
|
|
|
unifiedmask = st->mask_low | st->mask_high;
|
2013-10-07 22:11:00 +08:00
|
|
|
if (dir == IIO_EV_DIR_FALLING) {
|
2011-05-18 21:40:53 +08:00
|
|
|
|
|
|
|
if (state == 0)
|
|
|
|
st->mask_low &= ~(1 << number);
|
2010-06-26 19:54:23 +08:00
|
|
|
else {
|
2011-05-18 21:40:53 +08:00
|
|
|
ret = __max1363_check_event_mask((1 << number),
|
|
|
|
unifiedmask);
|
2010-06-26 19:54:23 +08:00
|
|
|
if (ret)
|
|
|
|
goto error_ret;
|
2011-05-18 21:40:53 +08:00
|
|
|
st->mask_low |= (1 << number);
|
2010-06-26 19:54:23 +08:00
|
|
|
}
|
|
|
|
} else {
|
2011-05-18 21:40:53 +08:00
|
|
|
if (state == 0)
|
|
|
|
st->mask_high &= ~(1 << number);
|
2010-06-26 19:54:23 +08:00
|
|
|
else {
|
2011-05-18 21:40:53 +08:00
|
|
|
ret = __max1363_check_event_mask((1 << number),
|
|
|
|
unifiedmask);
|
2010-06-26 19:54:23 +08:00
|
|
|
if (ret)
|
|
|
|
goto error_ret;
|
2011-05-18 21:40:53 +08:00
|
|
|
st->mask_high |= (1 << number);
|
2010-06-26 19:54:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
max1363_monitor_mode_update(st, !!(st->mask_high | st->mask_low));
|
|
|
|
error_ret:
|
2011-04-16 01:55:59 +08:00
|
|
|
mutex_unlock(&indio_dev->mlock);
|
2010-06-26 19:54:23 +08:00
|
|
|
|
2011-05-18 21:40:53 +08:00
|
|
|
return ret;
|
2010-06-26 19:54:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* As with scan_elements, only certain sets of these can
|
|
|
|
* be combined.
|
|
|
|
*/
|
|
|
|
static struct attribute *max1363_event_attributes[] = {
|
|
|
|
&iio_dev_attr_sampling_frequency.dev_attr.attr,
|
|
|
|
&iio_const_attr_sampling_frequency_available.dev_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2011-05-18 21:42:37 +08:00
|
|
|
static struct attribute_group max1363_event_attribute_group = {
|
|
|
|
.attrs = max1363_event_attributes,
|
2011-08-30 19:32:45 +08:00
|
|
|
.name = "events",
|
2011-05-18 21:42:37 +08:00
|
|
|
};
|
|
|
|
|
2012-10-06 21:10:05 +08:00
|
|
|
static int max1363_update_scan_mode(struct iio_dev *indio_dev,
|
|
|
|
const unsigned long *scan_mask)
|
|
|
|
{
|
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Need to figure out the current mode based upon the requested
|
|
|
|
* scan mask in iio_dev
|
|
|
|
*/
|
|
|
|
st->current_mode = max1363_match_mode(scan_mask, st->chip_info);
|
|
|
|
if (!st->current_mode)
|
|
|
|
return -EINVAL;
|
|
|
|
max1363_set_scan_mode(st);
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-18 21:42:37 +08:00
|
|
|
|
|
|
|
static const struct iio_info max1238_info = {
|
|
|
|
.read_raw = &max1363_read_raw,
|
|
|
|
.driver_module = THIS_MODULE,
|
2012-04-11 04:11:05 +08:00
|
|
|
.update_scan_mode = &max1363_update_scan_mode,
|
2011-05-18 21:42:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct iio_info max1363_info = {
|
2013-12-07 18:45:00 +08:00
|
|
|
.read_event_value = &max1363_read_thresh,
|
|
|
|
.write_event_value = &max1363_write_thresh,
|
|
|
|
.read_event_config = &max1363_read_event_config,
|
|
|
|
.write_event_config = &max1363_write_event_config,
|
2011-05-18 21:42:37 +08:00
|
|
|
.read_raw = &max1363_read_raw,
|
2011-12-06 05:37:15 +08:00
|
|
|
.update_scan_mode = &max1363_update_scan_mode,
|
2011-05-18 21:42:37 +08:00
|
|
|
.driver_module = THIS_MODULE,
|
|
|
|
.event_attrs = &max1363_event_attribute_group,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* max1363 and max1368 tested - rest from data sheet */
|
|
|
|
static const struct max1363_chip_info max1363_chip_info_tbl[] = {
|
|
|
|
[max1361] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1363_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1363_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.channels = max1361_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1361_channels),
|
|
|
|
.info = &max1363_info,
|
|
|
|
},
|
|
|
|
[max1362] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max1363_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1363_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.channels = max1361_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1361_channels),
|
|
|
|
.info = &max1363_info,
|
|
|
|
},
|
|
|
|
[max1363] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1363_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1363_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.channels = max1363_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1363_channels),
|
|
|
|
.info = &max1363_info,
|
|
|
|
},
|
|
|
|
[max1364] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max1363_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1363_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.channels = max1363_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1363_channels),
|
|
|
|
.info = &max1363_info,
|
|
|
|
},
|
|
|
|
[max1036] = {
|
|
|
|
.bits = 8,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max1236_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1236_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1036_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1036_channels),
|
|
|
|
},
|
|
|
|
[max1037] = {
|
|
|
|
.bits = 8,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1236_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1236_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1036_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1036_channels),
|
|
|
|
},
|
|
|
|
[max1038] = {
|
|
|
|
.bits = 8,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1038_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1038_channels),
|
|
|
|
},
|
|
|
|
[max1039] = {
|
|
|
|
.bits = 8,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1038_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1038_channels),
|
|
|
|
},
|
|
|
|
[max1136] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max1236_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1236_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1136_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1136_channels),
|
|
|
|
},
|
|
|
|
[max1137] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1236_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1236_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1136_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1136_channels),
|
|
|
|
},
|
|
|
|
[max1138] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1138_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1138_channels),
|
|
|
|
},
|
|
|
|
[max1139] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1138_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1138_channels),
|
|
|
|
},
|
|
|
|
[max1236] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max1236_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1236_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1236_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1236_channels),
|
|
|
|
},
|
|
|
|
[max1237] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1236_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1236_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1236_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1236_channels),
|
|
|
|
},
|
|
|
|
[max1238] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1238_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1238_channels),
|
|
|
|
},
|
|
|
|
[max1239] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1238_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1238_channels),
|
|
|
|
},
|
|
|
|
[max11600] = {
|
|
|
|
.bits = 8,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max11607_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11607_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1036_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1036_channels),
|
|
|
|
},
|
|
|
|
[max11601] = {
|
|
|
|
.bits = 8,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max11607_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11607_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1036_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1036_channels),
|
|
|
|
},
|
|
|
|
[max11602] = {
|
|
|
|
.bits = 8,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max11608_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11608_mode_list),
|
|
|
|
.default_mode = s0to7,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11602_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11602_channels),
|
|
|
|
},
|
|
|
|
[max11603] = {
|
|
|
|
.bits = 8,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max11608_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11608_mode_list),
|
|
|
|
.default_mode = s0to7,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11602_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11602_channels),
|
|
|
|
},
|
|
|
|
[max11604] = {
|
|
|
|
.bits = 8,
|
2014-02-16 19:47:00 +08:00
|
|
|
.int_vref_mv = 4096,
|
2011-05-18 21:42:37 +08:00
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
2014-05-24 19:52:10 +08:00
|
|
|
.channels = max1038_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1038_channels),
|
2011-05-18 21:42:37 +08:00
|
|
|
},
|
|
|
|
[max11605] = {
|
|
|
|
.bits = 8,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
2014-05-24 19:52:10 +08:00
|
|
|
.channels = max1038_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1038_channels),
|
2011-05-18 21:42:37 +08:00
|
|
|
},
|
|
|
|
[max11606] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max11607_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11607_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1136_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1136_channels),
|
|
|
|
},
|
|
|
|
[max11607] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max11607_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11607_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1136_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1136_channels),
|
|
|
|
},
|
|
|
|
[max11608] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max11608_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11608_mode_list),
|
|
|
|
.default_mode = s0to7,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11608_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11608_channels),
|
|
|
|
},
|
|
|
|
[max11609] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max11608_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11608_mode_list),
|
|
|
|
.default_mode = s0to7,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11608_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11608_channels),
|
|
|
|
},
|
|
|
|
[max11610] = {
|
|
|
|
.bits = 10,
|
2014-02-16 19:47:00 +08:00
|
|
|
.int_vref_mv = 4096,
|
2011-05-18 21:42:37 +08:00
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
2014-05-24 19:52:10 +08:00
|
|
|
.channels = max1138_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1138_channels),
|
2011-05-18 21:42:37 +08:00
|
|
|
},
|
|
|
|
[max11611] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
2014-05-24 19:52:10 +08:00
|
|
|
.channels = max1138_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1138_channels),
|
2011-05-18 21:42:37 +08:00
|
|
|
},
|
|
|
|
[max11612] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max11607_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11607_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1363_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1363_channels),
|
|
|
|
},
|
|
|
|
[max11613] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max11607_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11607_mode_list),
|
|
|
|
.default_mode = s0to3,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1363_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1363_channels),
|
|
|
|
},
|
|
|
|
[max11614] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max11608_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11608_mode_list),
|
|
|
|
.default_mode = s0to7,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11614_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11614_channels),
|
|
|
|
},
|
|
|
|
[max11615] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max11608_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11608_mode_list),
|
|
|
|
.default_mode = s0to7,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11614_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11614_channels),
|
|
|
|
},
|
|
|
|
[max11616] = {
|
|
|
|
.bits = 12,
|
2014-02-16 19:47:00 +08:00
|
|
|
.int_vref_mv = 4096,
|
2011-05-18 21:42:37 +08:00
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1238_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1238_channels),
|
|
|
|
},
|
|
|
|
[max11617] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max1238_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max1238_mode_list),
|
|
|
|
.default_mode = s0to11,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max1238_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max1238_channels),
|
|
|
|
},
|
|
|
|
[max11644] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max11644_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11644_mode_list),
|
|
|
|
.default_mode = s0to1,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11644_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11644_channels),
|
|
|
|
},
|
|
|
|
[max11645] = {
|
|
|
|
.bits = 12,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max11644_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11644_mode_list),
|
|
|
|
.default_mode = s0to1,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11644_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11644_channels),
|
|
|
|
},
|
|
|
|
[max11646] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 2048,
|
|
|
|
.mode_list = max11644_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11644_mode_list),
|
|
|
|
.default_mode = s0to1,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11646_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11646_channels),
|
|
|
|
},
|
|
|
|
[max11647] = {
|
|
|
|
.bits = 10,
|
|
|
|
.int_vref_mv = 4096,
|
|
|
|
.mode_list = max11644_mode_list,
|
|
|
|
.num_modes = ARRAY_SIZE(max11644_mode_list),
|
|
|
|
.default_mode = s0to1,
|
|
|
|
.info = &max1238_info,
|
|
|
|
.channels = max11646_channels,
|
|
|
|
.num_channels = ARRAY_SIZE(max11646_channels),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
static int max1363_initial_setup(struct max1363_state *st)
|
|
|
|
{
|
2013-02-03 08:59:00 +08:00
|
|
|
st->setupbyte = MAX1363_SETUP_INT_CLOCK
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
| MAX1363_SETUP_UNIPOLAR
|
|
|
|
| MAX1363_SETUP_NORESET;
|
|
|
|
|
2013-02-03 08:59:00 +08:00
|
|
|
if (st->vref)
|
|
|
|
st->setupbyte |= MAX1363_SETUP_AIN3_IS_REF_EXT_TO_REF;
|
|
|
|
else
|
|
|
|
st->setupbyte |= MAX1363_SETUP_POWER_UP_INT_REF
|
|
|
|
| MAX1363_SETUP_AIN3_IS_AIN3_REF_IS_INT;
|
|
|
|
|
2012-12-31 07:26:00 +08:00
|
|
|
/* Set scan mode writes the config anyway so wait until then */
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
st->setupbyte = MAX1363_SETUP_BYTE(st->setupbyte);
|
|
|
|
st->current_mode = &max1363_mode_table[st->chip_info->default_mode];
|
|
|
|
st->configbyte = MAX1363_CONFIG_BYTE(st->configbyte);
|
|
|
|
|
|
|
|
return max1363_set_scan_mode(st);
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:21:43 +08:00
|
|
|
static int max1363_alloc_scan_masks(struct iio_dev *indio_dev)
|
2012-02-22 20:16:49 +08:00
|
|
|
{
|
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
|
|
|
unsigned long *masks;
|
|
|
|
int i;
|
|
|
|
|
2013-02-03 08:59:00 +08:00
|
|
|
masks = devm_kzalloc(&indio_dev->dev,
|
|
|
|
BITS_TO_LONGS(MAX1363_MAX_CHANNELS) * sizeof(long) *
|
|
|
|
(st->chip_info->num_modes + 1), GFP_KERNEL);
|
2012-02-22 20:16:49 +08:00
|
|
|
if (!masks)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
for (i = 0; i < st->chip_info->num_modes; i++)
|
|
|
|
bitmap_copy(masks + BITS_TO_LONGS(MAX1363_MAX_CHANNELS)*i,
|
|
|
|
max1363_mode_table[st->chip_info->mode_list[i]]
|
|
|
|
.modemask, MAX1363_MAX_CHANNELS);
|
|
|
|
|
|
|
|
indio_dev->available_scan_masks = masks;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-06 21:10:05 +08:00
|
|
|
static irqreturn_t max1363_trigger_handler(int irq, void *p)
|
|
|
|
{
|
|
|
|
struct iio_poll_func *pf = p;
|
|
|
|
struct iio_dev *indio_dev = pf->indio_dev;
|
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
|
|
|
__u8 *rxbuf;
|
|
|
|
int b_sent;
|
|
|
|
size_t d_size;
|
|
|
|
unsigned long numvals = bitmap_weight(st->current_mode->modemask,
|
|
|
|
MAX1363_MAX_CHANNELS);
|
|
|
|
|
|
|
|
/* Ensure the timestamp is 8 byte aligned */
|
|
|
|
if (st->chip_info->bits != 8)
|
|
|
|
d_size = numvals*2;
|
|
|
|
else
|
|
|
|
d_size = numvals;
|
|
|
|
if (indio_dev->scan_timestamp) {
|
|
|
|
d_size += sizeof(s64);
|
|
|
|
if (d_size % sizeof(s64))
|
|
|
|
d_size += sizeof(s64) - (d_size % sizeof(s64));
|
|
|
|
}
|
|
|
|
/* Monitor mode prevents reading. Whilst not currently implemented
|
|
|
|
* might as well have this test in here in the meantime as it does
|
|
|
|
* no harm.
|
|
|
|
*/
|
|
|
|
if (numvals == 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
rxbuf = kmalloc(d_size, GFP_KERNEL);
|
|
|
|
if (rxbuf == NULL)
|
|
|
|
goto done;
|
|
|
|
if (st->chip_info->bits != 8)
|
2013-10-21 02:02:00 +08:00
|
|
|
b_sent = st->recv(st->client, rxbuf, numvals * 2);
|
2012-10-06 21:10:05 +08:00
|
|
|
else
|
2013-10-21 02:02:00 +08:00
|
|
|
b_sent = st->recv(st->client, rxbuf, numvals);
|
2012-10-06 21:10:05 +08:00
|
|
|
if (b_sent < 0)
|
|
|
|
goto done_free;
|
|
|
|
|
2013-09-19 20:59:00 +08:00
|
|
|
iio_push_to_buffers_with_timestamp(indio_dev, rxbuf, iio_get_time_ns());
|
2012-10-06 21:10:05 +08:00
|
|
|
|
|
|
|
done_free:
|
|
|
|
kfree(rxbuf);
|
|
|
|
done:
|
|
|
|
iio_trigger_notify_done(indio_dev->trig);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:21:43 +08:00
|
|
|
static int max1363_probe(struct i2c_client *client,
|
|
|
|
const struct i2c_device_id *id)
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
{
|
2012-02-22 20:16:49 +08:00
|
|
|
int ret;
|
2011-04-16 01:55:59 +08:00
|
|
|
struct max1363_state *st;
|
|
|
|
struct iio_dev *indio_dev;
|
2013-02-03 08:59:00 +08:00
|
|
|
struct regulator *vref;
|
2011-06-08 14:42:21 +08:00
|
|
|
|
2013-07-22 19:02:00 +08:00
|
|
|
indio_dev = devm_iio_device_alloc(&client->dev,
|
|
|
|
sizeof(struct max1363_state));
|
|
|
|
if (!indio_dev)
|
|
|
|
return -ENOMEM;
|
2012-10-06 21:39:19 +08:00
|
|
|
|
2013-02-01 05:43:00 +08:00
|
|
|
indio_dev->dev.of_node = client->dev.of_node;
|
2012-04-11 04:11:07 +08:00
|
|
|
ret = iio_map_array_register(indio_dev, client->dev.platform_data);
|
|
|
|
if (ret < 0)
|
2013-07-22 19:02:00 +08:00
|
|
|
return ret;
|
2012-10-06 21:39:19 +08:00
|
|
|
|
2011-04-16 01:55:59 +08:00
|
|
|
st = iio_priv(indio_dev);
|
2012-10-06 21:39:19 +08:00
|
|
|
|
2013-02-03 08:59:00 +08:00
|
|
|
st->reg = devm_regulator_get(&client->dev, "vcc");
|
2012-10-06 21:39:19 +08:00
|
|
|
if (IS_ERR(st->reg)) {
|
|
|
|
ret = PTR_ERR(st->reg);
|
|
|
|
goto error_unregister_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = regulator_enable(st->reg);
|
|
|
|
if (ret)
|
2013-02-03 08:59:00 +08:00
|
|
|
goto error_unregister_map;
|
2012-10-06 21:39:19 +08:00
|
|
|
|
2011-04-16 01:55:59 +08:00
|
|
|
/* this is only used for device removal purposes */
|
|
|
|
i2c_set_clientdata(client, indio_dev);
|
|
|
|
|
|
|
|
st->chip_info = &max1363_chip_info_tbl[id->driver_data];
|
|
|
|
st->client = client;
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
|
2013-02-03 08:59:00 +08:00
|
|
|
st->vref_uv = st->chip_info->int_vref_mv * 1000;
|
2014-01-28 02:10:00 +08:00
|
|
|
vref = devm_regulator_get_optional(&client->dev, "vref");
|
2013-02-03 08:59:00 +08:00
|
|
|
if (!IS_ERR(vref)) {
|
|
|
|
int vref_uv;
|
|
|
|
|
|
|
|
ret = regulator_enable(vref);
|
|
|
|
if (ret)
|
|
|
|
goto error_disable_reg;
|
|
|
|
st->vref = vref;
|
|
|
|
vref_uv = regulator_get_voltage(vref);
|
|
|
|
if (vref_uv <= 0) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto error_disable_reg;
|
|
|
|
}
|
|
|
|
st->vref_uv = vref_uv;
|
|
|
|
}
|
|
|
|
|
2013-10-21 02:02:00 +08:00
|
|
|
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
|
|
|
|
st->send = i2c_master_send;
|
|
|
|
st->recv = i2c_master_recv;
|
|
|
|
} else if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)
|
|
|
|
&& st->chip_info->bits == 8) {
|
|
|
|
st->send = max1363_smbus_send;
|
|
|
|
st->recv = max1363_smbus_recv;
|
|
|
|
} else {
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
goto error_disable_reg;
|
|
|
|
}
|
|
|
|
|
2012-02-22 20:16:49 +08:00
|
|
|
ret = max1363_alloc_scan_masks(indio_dev);
|
|
|
|
if (ret)
|
2012-10-06 21:39:19 +08:00
|
|
|
goto error_disable_reg;
|
2010-05-04 21:43:03 +08:00
|
|
|
|
2012-12-31 07:26:00 +08:00
|
|
|
/* Establish that the iio_dev is a child of the i2c device */
|
2011-04-16 01:55:59 +08:00
|
|
|
indio_dev->dev.parent = &client->dev;
|
2011-05-18 21:41:44 +08:00
|
|
|
indio_dev->name = id->name;
|
2011-08-30 19:32:45 +08:00
|
|
|
indio_dev->channels = st->chip_info->channels;
|
|
|
|
indio_dev->num_channels = st->chip_info->num_channels;
|
2011-05-18 21:42:37 +08:00
|
|
|
indio_dev->info = st->chip_info->info;
|
|
|
|
indio_dev->modes = INDIO_DIRECT_MODE;
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
ret = max1363_initial_setup(st);
|
2011-05-18 21:42:38 +08:00
|
|
|
if (ret < 0)
|
2013-02-03 08:59:00 +08:00
|
|
|
goto error_disable_reg;
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
|
2012-12-31 07:26:00 +08:00
|
|
|
ret = iio_triggered_buffer_setup(indio_dev, NULL,
|
2013-09-16 16:34:00 +08:00
|
|
|
&max1363_trigger_handler, NULL);
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
if (ret)
|
2013-02-03 08:59:00 +08:00
|
|
|
goto error_disable_reg;
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
|
2011-05-18 21:42:37 +08:00
|
|
|
if (client->irq) {
|
2013-02-03 08:59:00 +08:00
|
|
|
ret = devm_request_threaded_irq(&client->dev, st->client->irq,
|
2011-05-18 21:41:16 +08:00
|
|
|
NULL,
|
|
|
|
&max1363_event_handler,
|
|
|
|
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
|
|
|
|
"max1363_event",
|
|
|
|
indio_dev);
|
2011-05-18 21:40:53 +08:00
|
|
|
|
2010-06-26 19:54:23 +08:00
|
|
|
if (ret)
|
2012-10-06 21:19:01 +08:00
|
|
|
goto error_uninit_buffer;
|
2010-06-26 19:54:23 +08:00
|
|
|
}
|
|
|
|
|
2011-09-03 00:14:40 +08:00
|
|
|
ret = iio_device_register(indio_dev);
|
|
|
|
if (ret < 0)
|
2013-02-03 08:59:00 +08:00
|
|
|
goto error_uninit_buffer;
|
2011-06-08 14:42:21 +08:00
|
|
|
|
2011-09-03 00:14:40 +08:00
|
|
|
return 0;
|
2013-02-03 08:59:00 +08:00
|
|
|
|
2012-10-06 21:19:01 +08:00
|
|
|
error_uninit_buffer:
|
2012-12-31 07:26:00 +08:00
|
|
|
iio_triggered_buffer_cleanup(indio_dev);
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
error_disable_reg:
|
2013-02-03 08:59:00 +08:00
|
|
|
if (st->vref)
|
|
|
|
regulator_disable(st->vref);
|
2012-10-06 21:39:19 +08:00
|
|
|
regulator_disable(st->reg);
|
2012-12-24 14:24:00 +08:00
|
|
|
error_unregister_map:
|
2013-02-01 05:43:00 +08:00
|
|
|
iio_map_array_unregister(indio_dev);
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:21:43 +08:00
|
|
|
static int max1363_remove(struct i2c_client *client)
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
{
|
2011-04-16 01:55:59 +08:00
|
|
|
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
|
|
|
struct max1363_state *st = iio_priv(indio_dev);
|
2010-06-26 19:54:23 +08:00
|
|
|
|
2011-10-14 21:46:58 +08:00
|
|
|
iio_device_unregister(indio_dev);
|
2012-12-31 07:26:00 +08:00
|
|
|
iio_triggered_buffer_cleanup(indio_dev);
|
2013-02-03 08:59:00 +08:00
|
|
|
if (st->vref)
|
|
|
|
regulator_disable(st->vref);
|
2012-12-24 14:24:00 +08:00
|
|
|
regulator_disable(st->reg);
|
2013-02-01 05:43:00 +08:00
|
|
|
iio_map_array_unregister(indio_dev);
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct i2c_device_id max1363_id[] = {
|
|
|
|
{ "max1361", max1361 },
|
|
|
|
{ "max1362", max1362 },
|
|
|
|
{ "max1363", max1363 },
|
|
|
|
{ "max1364", max1364 },
|
2010-05-04 21:43:10 +08:00
|
|
|
{ "max1036", max1036 },
|
|
|
|
{ "max1037", max1037 },
|
|
|
|
{ "max1038", max1038 },
|
|
|
|
{ "max1039", max1039 },
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
{ "max1136", max1136 },
|
|
|
|
{ "max1137", max1137 },
|
|
|
|
{ "max1138", max1138 },
|
|
|
|
{ "max1139", max1139 },
|
|
|
|
{ "max1236", max1236 },
|
|
|
|
{ "max1237", max1237 },
|
|
|
|
{ "max1238", max1238 },
|
|
|
|
{ "max1239", max1239 },
|
2010-05-04 21:43:10 +08:00
|
|
|
{ "max11600", max11600 },
|
|
|
|
{ "max11601", max11601 },
|
|
|
|
{ "max11602", max11602 },
|
|
|
|
{ "max11603", max11603 },
|
|
|
|
{ "max11604", max11604 },
|
|
|
|
{ "max11605", max11605 },
|
2010-05-04 21:43:09 +08:00
|
|
|
{ "max11606", max11606 },
|
|
|
|
{ "max11607", max11607 },
|
|
|
|
{ "max11608", max11608 },
|
|
|
|
{ "max11609", max11609 },
|
|
|
|
{ "max11610", max11610 },
|
|
|
|
{ "max11611", max11611 },
|
|
|
|
{ "max11612", max11612 },
|
|
|
|
{ "max11613", max11613 },
|
|
|
|
{ "max11614", max11614 },
|
|
|
|
{ "max11615", max11615 },
|
|
|
|
{ "max11616", max11616 },
|
|
|
|
{ "max11617", max11617 },
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(i2c, max1363_id);
|
|
|
|
|
|
|
|
static struct i2c_driver max1363_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "max1363",
|
|
|
|
},
|
|
|
|
.probe = max1363_probe,
|
2012-12-22 05:21:43 +08:00
|
|
|
.remove = max1363_remove,
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
.id_table = max1363_id,
|
|
|
|
};
|
2011-11-16 17:13:38 +08:00
|
|
|
module_i2c_driver(max1363_driver);
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
|
2012-09-03 04:34:59 +08:00
|
|
|
MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>");
|
Staging: IIO: max1363 ADC driver
Core support for MAX1361, MAX1362, MAX1363, MAX1364,
MAX1136, MAX1137, MAX1138, MAX1139, MAX1236, MAX1237,
MAX1238, MAX1239.
Ring buffer support later in series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-19 01:06:20 +08:00
|
|
|
MODULE_DESCRIPTION("Maxim 1363 ADC");
|
|
|
|
MODULE_LICENSE("GPL v2");
|