Commit f3fb0011 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

iio:staging:accelerometers move towards the new abi

Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ff7723e2
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include "../sysfs.h" #include "../sysfs.h"
/* Accelerometer types of attribute */ /* Accelerometer types of attribute */
#define IIO_DEV_ATTR_ACCEL_X_OFFSET(_mode, _show, _store, _addr) \ #define IIO_DEV_ATTR_ACCEL_X_OFFSET(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(accel_x_offset, _mode, _show, _store, _addr) IIO_DEVICE_ATTR(accel_x_offset, _mode, _show, _store, _addr)
...@@ -22,13 +21,13 @@ ...@@ -22,13 +21,13 @@
IIO_DEVICE_ATTR(accel_z_gain, _mode, _show, _store, _addr) IIO_DEVICE_ATTR(accel_z_gain, _mode, _show, _store, _addr)
#define IIO_DEV_ATTR_ACCEL_X(_show, _addr) \ #define IIO_DEV_ATTR_ACCEL_X(_show, _addr) \
IIO_DEVICE_ATTR(accel_x, S_IRUGO, _show, NULL, _addr) IIO_DEVICE_ATTR(accel_x_raw, S_IRUGO, _show, NULL, _addr)
#define IIO_DEV_ATTR_ACCEL_Y(_show, _addr) \ #define IIO_DEV_ATTR_ACCEL_Y(_show, _addr) \
IIO_DEVICE_ATTR(accel_y, S_IRUGO, _show, NULL, _addr) IIO_DEVICE_ATTR(accel_y_raw, S_IRUGO, _show, NULL, _addr)
#define IIO_DEV_ATTR_ACCEL_Z(_show, _addr) \ #define IIO_DEV_ATTR_ACCEL_Z(_show, _addr) \
IIO_DEVICE_ATTR(accel_z, S_IRUGO, _show, NULL, _addr) IIO_DEVICE_ATTR(accel_z_raw, S_IRUGO, _show, NULL, _addr)
/* Thresholds are somewhat chip dependent - may need quite a few defs here */ /* Thresholds are somewhat chip dependent - may need quite a few defs here */
/* For unified thresholds (shared across all directions */ /* For unified thresholds (shared across all directions */
...@@ -61,7 +60,6 @@ ...@@ -61,7 +60,6 @@
#define IIO_DEV_ATTR_ACCEL_THRESH_Z(_mode, _show, _store, _addr) \ #define IIO_DEV_ATTR_ACCEL_THRESH_Z(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(thresh_accel_z, _mode, _show, _store, _addr) IIO_DEVICE_ATTR(thresh_accel_z, _mode, _show, _store, _addr)
/** /**
* IIO_EVENT_ATTR_ACCEL_X_HIGH: threshold event, x acceleration * IIO_EVENT_ATTR_ACCEL_X_HIGH: threshold event, x acceleration
* @_show: read x acceleration high threshold * @_show: read x acceleration high threshold
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h>
#include "../iio.h" #include "../iio.h"
#include "../sysfs.h" #include "../sysfs.h"
...@@ -51,8 +52,10 @@ ...@@ -51,8 +52,10 @@
#define KXSD9_READ(a) (0x80 | (a)) #define KXSD9_READ(a) (0x80 | (a))
#define KXSD9_WRITE(a) (a) #define KXSD9_WRITE(a) (a)
#define IIO_DEV_ATTR_ACCEL_SET_RANGE(_mode, _show, _store) \ #define KXSD9_SCALE_2G "0.011978"
IIO_DEVICE_ATTR(accel_range, _mode, _show, _store, 0) #define KXSD9_SCALE_4G "0.023927"
#define KXSD9_SCALE_6G "0.035934"
#define KXSD9_SCALE_8G "0.047853"
#define KXSD9_STATE_RX_SIZE 2 #define KXSD9_STATE_RX_SIZE 2
#define KXSD9_STATE_TX_SIZE 4 #define KXSD9_STATE_TX_SIZE 4
...@@ -73,9 +76,9 @@ struct kxsd9_state { ...@@ -73,9 +76,9 @@ struct kxsd9_state {
}; };
/* This may want to move to mili g to allow for non integer ranges */ /* This may want to move to mili g to allow for non integer ranges */
static ssize_t kxsd9_read_accel_range(struct device *dev, static ssize_t kxsd9_read_scale(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
int ret; int ret;
ssize_t len = 0; ssize_t len = 0;
...@@ -101,16 +104,16 @@ static ssize_t kxsd9_read_accel_range(struct device *dev, ...@@ -101,16 +104,16 @@ static ssize_t kxsd9_read_accel_range(struct device *dev,
switch (st->rx[1] & KXSD9_FS_MASK) { switch (st->rx[1] & KXSD9_FS_MASK) {
case KXSD9_FS_8: case KXSD9_FS_8:
len += sprintf(buf, "8\n"); len += sprintf(buf, "%s\n", KXSD9_SCALE_8G);
break; break;
case KXSD9_FS_6: case KXSD9_FS_6:
len += sprintf(buf, "6\n"); len += sprintf(buf, "%s\n", KXSD9_SCALE_6G);
break; break;
case KXSD9_FS_4: case KXSD9_FS_4:
len += sprintf(buf, "4\n"); len += sprintf(buf, "%s\n", KXSD9_SCALE_4G);
break; break;
case KXSD9_FS_2: case KXSD9_FS_2:
len += sprintf(buf, "2\n"); len += sprintf(buf, "%s\n", KXSD9_SCALE_2G);
break; break;
} }
...@@ -119,12 +122,12 @@ static ssize_t kxsd9_read_accel_range(struct device *dev, ...@@ -119,12 +122,12 @@ static ssize_t kxsd9_read_accel_range(struct device *dev,
return ret ? ret : len; return ret ? ret : len;
} }
static ssize_t kxsd9_write_accel_range(struct device *dev, static ssize_t kxsd9_write_scale(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t len) size_t len)
{ {
long readin;
struct spi_message msg; struct spi_message msg;
int ret; int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev);
...@@ -145,25 +148,25 @@ static ssize_t kxsd9_write_accel_range(struct device *dev, ...@@ -145,25 +148,25 @@ static ssize_t kxsd9_write_accel_range(struct device *dev,
}, },
}; };
ret = strict_strtol(buf, 10, &readin); if (!strncmp(buf, KXSD9_SCALE_8G,
if (ret) strlen(buf) < strlen(KXSD9_SCALE_8G)
return ret; ? strlen(buf) : strlen(KXSD9_SCALE_8G)))
switch (readin) {
case 8:
val = KXSD9_FS_8; val = KXSD9_FS_8;
break; else if (!strncmp(buf, KXSD9_SCALE_6G,
case 6: strlen(buf) < strlen(KXSD9_SCALE_6G)
? strlen(buf) : strlen(KXSD9_SCALE_6G)))
val = KXSD9_FS_6; val = KXSD9_FS_6;
break; else if (!strncmp(buf, KXSD9_SCALE_4G,
case 4: strlen(buf) < strlen(KXSD9_SCALE_4G)
? strlen(buf) : strlen(KXSD9_SCALE_4G)))
val = KXSD9_FS_4; val = KXSD9_FS_4;
break; else if (!strncmp(buf, KXSD9_SCALE_2G,
case 2: strlen(buf) < strlen(KXSD9_SCALE_2G)
? strlen(buf) : strlen(KXSD9_SCALE_2G)))
val = KXSD9_FS_2; val = KXSD9_FS_2;
break; else
default:
return -EINVAL; return -EINVAL;
}
mutex_lock(&st->buf_lock); mutex_lock(&st->buf_lock);
st->tx[0] = KXSD9_READ(KXSD9_REG_CTRL_C); st->tx[0] = KXSD9_READ(KXSD9_REG_CTRL_C);
st->tx[1] = 0; st->tx[1] = 0;
...@@ -182,6 +185,7 @@ static ssize_t kxsd9_write_accel_range(struct device *dev, ...@@ -182,6 +185,7 @@ static ssize_t kxsd9_write_accel_range(struct device *dev,
mutex_unlock(&st->buf_lock); mutex_unlock(&st->buf_lock);
return ret ? ret : len; return ret ? ret : len;
} }
static ssize_t kxsd9_read_accel(struct device *dev, static ssize_t kxsd9_read_accel(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -227,17 +231,27 @@ static ssize_t kxsd9_read_accel(struct device *dev, ...@@ -227,17 +231,27 @@ static ssize_t kxsd9_read_accel(struct device *dev,
static IIO_DEV_ATTR_ACCEL_X(kxsd9_read_accel, KXSD9_REG_X); static IIO_DEV_ATTR_ACCEL_X(kxsd9_read_accel, KXSD9_REG_X);
static IIO_DEV_ATTR_ACCEL_Y(kxsd9_read_accel, KXSD9_REG_Y); static IIO_DEV_ATTR_ACCEL_Y(kxsd9_read_accel, KXSD9_REG_Y);
static IIO_DEV_ATTR_ACCEL_Z(kxsd9_read_accel, KXSD9_REG_Z); static IIO_DEV_ATTR_ACCEL_Z(kxsd9_read_accel, KXSD9_REG_Z);
static IIO_DEV_ATTR_ADC(0, kxsd9_read_accel, KXSD9_REG_AUX); static IIO_DEV_ATTR_IN_RAW(0, kxsd9_read_accel, KXSD9_REG_AUX);
static IIO_DEV_ATTR_ACCEL_SET_RANGE(S_IRUGO | S_IWUSR,
kxsd9_read_accel_range, static IIO_DEVICE_ATTR(accel_scale,
kxsd9_write_accel_range); S_IRUGO | S_IWUSR,
kxsd9_read_scale,
kxsd9_write_scale,
0);
static IIO_CONST_ATTR(accel_scale_available,
KXSD9_SCALE_2G " "
KXSD9_SCALE_4G " "
KXSD9_SCALE_6G " "
KXSD9_SCALE_8G);
static struct attribute *kxsd9_attributes[] = { static struct attribute *kxsd9_attributes[] = {
&iio_dev_attr_accel_x.dev_attr.attr, &iio_dev_attr_accel_x_raw.dev_attr.attr,
&iio_dev_attr_accel_y.dev_attr.attr, &iio_dev_attr_accel_y_raw.dev_attr.attr,
&iio_dev_attr_accel_z.dev_attr.attr, &iio_dev_attr_accel_z_raw.dev_attr.attr,
&iio_dev_attr_adc_0.dev_attr.attr, &iio_dev_attr_in0_raw.dev_attr.attr,
&iio_dev_attr_accel_range.dev_attr.attr, &iio_dev_attr_accel_scale.dev_attr.attr,
&iio_const_attr_accel_scale_available.dev_attr.attr,
NULL, NULL,
}; };
......
...@@ -179,10 +179,6 @@ int lis3l02dq_spi_read_reg_8(struct device *dev, ...@@ -179,10 +179,6 @@ int lis3l02dq_spi_read_reg_8(struct device *dev,
int lis3l02dq_spi_write_reg_8(struct device *dev, int lis3l02dq_spi_write_reg_8(struct device *dev,
u8 reg_address, u8 reg_address,
u8 *val); u8 *val);
#define LIS3L02DQ_SCAN_ACC_X 0
#define LIS3L02DQ_SCAN_ACC_Y 1
#define LIS3L02DQ_SCAN_ACC_Z 2
#ifdef CONFIG_IIO_RING_BUFFER #ifdef CONFIG_IIO_RING_BUFFER
/* At the moment triggers are only used for ring buffer /* At the moment triggers are only used for ring buffer
......
...@@ -458,41 +458,39 @@ static int lis3l02dq_initial_setup(struct lis3l02dq_state *st) ...@@ -458,41 +458,39 @@ static int lis3l02dq_initial_setup(struct lis3l02dq_state *st)
return ret; return ret;
} }
static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO, #define LIS3L02DQ_SIGNED_ATTR(name, reg) \
lis3l02dq_read_signed, IIO_DEVICE_ATTR(name, \
lis3l02dq_write_signed, S_IWUSR | S_IRUGO, \
LIS3L02DQ_REG_OFFSET_X_ADDR); lis3l02dq_read_signed, \
lis3l02dq_write_signed, \
static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO, reg);
lis3l02dq_read_signed,
lis3l02dq_write_signed, #define LIS3L02DQ_UNSIGNED_ATTR(name, reg) \
LIS3L02DQ_REG_OFFSET_Y_ADDR); IIO_DEVICE_ATTR(name, \
S_IWUSR | S_IRUGO, \
static IIO_DEV_ATTR_ACCEL_Z_OFFSET(S_IWUSR | S_IRUGO, lis3l02dq_read_unsigned, \
lis3l02dq_read_signed, lis3l02dq_write_unsigned, \
lis3l02dq_write_signed, reg);
LIS3L02DQ_REG_OFFSET_Z_ADDR);
static LIS3L02DQ_SIGNED_ATTR(accel_x_calibbias,
static IIO_DEV_ATTR_ACCEL_X_GAIN(S_IWUSR | S_IRUGO, LIS3L02DQ_REG_OFFSET_X_ADDR);
lis3l02dq_read_unsigned, static LIS3L02DQ_SIGNED_ATTR(accel_y_calibbias,
lis3l02dq_write_unsigned, LIS3L02DQ_REG_OFFSET_Y_ADDR);
LIS3L02DQ_REG_GAIN_X_ADDR); static LIS3L02DQ_SIGNED_ATTR(accel_z_calibbias,
LIS3L02DQ_REG_OFFSET_Z_ADDR);
static IIO_DEV_ATTR_ACCEL_Y_GAIN(S_IWUSR | S_IRUGO,
lis3l02dq_read_unsigned, static LIS3L02DQ_UNSIGNED_ATTR(accel_x_calibscale,
lis3l02dq_write_unsigned, LIS3L02DQ_REG_GAIN_X_ADDR);
LIS3L02DQ_REG_GAIN_Y_ADDR); static LIS3L02DQ_UNSIGNED_ATTR(accel_y_calibscale,
LIS3L02DQ_REG_GAIN_Y_ADDR);
static IIO_DEV_ATTR_ACCEL_Z_GAIN(S_IWUSR | S_IRUGO, static LIS3L02DQ_UNSIGNED_ATTR(accel_z_calibscale,
lis3l02dq_read_unsigned, LIS3L02DQ_REG_GAIN_Z_ADDR);
lis3l02dq_write_unsigned,
LIS3L02DQ_REG_GAIN_Z_ADDR); static IIO_DEVICE_ATTR(accel_mag_either_rising_value,
S_IWUSR | S_IRUGO,
static IIO_DEV_ATTR_ACCEL_THRESH(S_IWUSR | S_IRUGO, lis3l02dq_read_16bit_signed,
lis3l02dq_read_16bit_signed, lis3l02dq_write_16bit_signed,
lis3l02dq_write_16bit_signed, LIS3L02DQ_REG_THS_L_ADDR);
LIS3L02DQ_REG_THS_L_ADDR);
/* RFC The reading method for these will change depending on whether /* RFC The reading method for these will change depending on whether
* ring buffer capture is in use. Is it worth making these take two * ring buffer capture is in use. Is it worth making these take two
* functions and let the core handle which to call, or leave as in this * functions and let the core handle which to call, or leave as in this
...@@ -512,7 +510,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ...@@ -512,7 +510,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
lis3l02dq_read_frequency, lis3l02dq_read_frequency,
lis3l02dq_write_frequency); lis3l02dq_write_frequency);
static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("280 560 1120 4480"); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("280 560 1120 4480");
static ssize_t lis3l02dq_read_interrupt_config(struct device *dev, static ssize_t lis3l02dq_read_interrupt_config(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
...@@ -522,7 +520,7 @@ static ssize_t lis3l02dq_read_interrupt_config(struct device *dev, ...@@ -522,7 +520,7 @@ static ssize_t lis3l02dq_read_interrupt_config(struct device *dev,
s8 val; s8 val;
struct iio_event_attr *this_attr = to_iio_event_attr(attr); struct iio_event_attr *this_attr = to_iio_event_attr(attr);
ret = lis3l02dq_spi_read_reg_8(dev, ret = lis3l02dq_spi_read_reg_8(dev->parent,
LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
(u8 *)&val); (u8 *)&val);
...@@ -545,7 +543,7 @@ static ssize_t lis3l02dq_write_interrupt_config(struct device *dev, ...@@ -545,7 +543,7 @@ static ssize_t lis3l02dq_write_interrupt_config(struct device *dev,
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
/* read current value */ /* read current value */
ret = lis3l02dq_spi_read_reg_8(dev, ret = lis3l02dq_spi_read_reg_8(dev->parent,
LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
&valold); &valold);
if (ret) if (ret)
...@@ -618,7 +616,7 @@ static int lis3l02dq_thresh_handler_th(struct iio_dev *dev_info, ...@@ -618,7 +616,7 @@ static int lis3l02dq_thresh_handler_th(struct iio_dev *dev_info,
static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s) static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s)
{ {
struct iio_work_cont *wc struct iio_work_cont *wc
= container_of(work_s, struct iio_work_cont, ws_nocheck); = container_of(work_s, struct iio_work_cont, ws);
struct lis3l02dq_state *st = wc->st; struct lis3l02dq_state *st = wc->st;
u8 t; u8 t;
...@@ -668,43 +666,51 @@ static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s) ...@@ -668,43 +666,51 @@ static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s)
/* A shared handler for a number of threshold types */ /* A shared handler for a number of threshold types */
IIO_EVENT_SH(threshold, &lis3l02dq_thresh_handler_th); IIO_EVENT_SH(threshold, &lis3l02dq_thresh_handler_th);
IIO_EVENT_ATTR_ACCEL_X_HIGH_SH(iio_event_threshold, IIO_EVENT_ATTR_SH(accel_x_mag_pos_rising_en,
lis3l02dq_read_interrupt_config, iio_event_threshold,
lis3l02dq_write_interrupt_config, lis3l02dq_read_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_HIGH); lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_HIGH);
IIO_EVENT_ATTR_ACCEL_Y_HIGH_SH(iio_event_threshold,
lis3l02dq_read_interrupt_config, IIO_EVENT_ATTR_SH(accel_y_mag_pos_rising_en,
lis3l02dq_write_interrupt_config, iio_event_threshold,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_HIGH); lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config,
IIO_EVENT_ATTR_ACCEL_Z_HIGH_SH(iio_event_threshold, LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_HIGH);
lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config, IIO_EVENT_ATTR_SH(accel_z_mag_pos_rising_en,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_HIGH); iio_event_threshold,
lis3l02dq_read_interrupt_config,
IIO_EVENT_ATTR_ACCEL_X_LOW_SH(iio_event_threshold, lis3l02dq_write_interrupt_config,
lis3l02dq_read_interrupt_config, LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_HIGH);
lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_LOW); IIO_EVENT_ATTR_SH(accel_x_mag_neg_rising_en,
iio_event_threshold,
IIO_EVENT_ATTR_ACCEL_Y_LOW_SH(iio_event_threshold, lis3l02dq_read_interrupt_config,
lis3l02dq_read_interrupt_config, lis3l02dq_write_interrupt_config,
lis3l02dq_write_interrupt_config, LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_LOW);
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_LOW);
IIO_EVENT_ATTR_SH(accel_y_mag_neg_rising_en,
iio_event_threshold,
lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_LOW);
IIO_EVENT_ATTR_SH(accel_z_mag_neg_rising_en,
iio_event_threshold,
lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_LOW);
IIO_EVENT_ATTR_ACCEL_Z_LOW_SH(iio_event_threshold,
lis3l02dq_read_interrupt_config,
lis3l02dq_write_interrupt_config,
LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_LOW);
static struct attribute *lis3l02dq_event_attributes[] = { static struct attribute *lis3l02dq_event_attributes[] = {
&iio_event_attr_accel_x_high.dev_attr.attr, &iio_event_attr_accel_x_mag_pos_rising_en.dev_attr.attr,
&iio_event_attr_accel_y_high.dev_attr.attr, &iio_event_attr_accel_y_mag_pos_rising_en.dev_attr.attr,
&iio_event_attr_accel_z_high.dev_attr.attr, &iio_event_attr_accel_z_mag_pos_rising_en.dev_attr.attr,
&iio_event_attr_accel_x_low.dev_attr.attr, &iio_event_attr_accel_x_mag_neg_rising_en.dev_attr.attr,
&iio_event_attr_accel_y_low.dev_attr.attr, &iio_event_attr_accel_y_mag_neg_rising_en.dev_attr.attr,
&iio_event_attr_accel_z_low.dev_attr.attr, &iio_event_attr_accel_z_mag_neg_rising_en.dev_attr.attr,
&iio_dev_attr_accel_mag_either_rising_value.dev_attr.attr,
NULL NULL
}; };
...@@ -713,20 +719,21 @@ static struct attribute_group lis3l02dq_event_attribute_group = { ...@@ -713,20 +719,21 @@ static struct attribute_group lis3l02dq_event_attribute_group = {
}; };
static IIO_CONST_ATTR(name, "lis3l02dq"); static IIO_CONST_ATTR(name, "lis3l02dq");
static IIO_CONST_ATTR(accel_scale, "0.00958");
static struct attribute *lis3l02dq_attributes[] = { static struct attribute *lis3l02dq_attributes[] = {
&iio_dev_attr_accel_x_offset.dev_attr.attr, &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
&iio_dev_attr_accel_y_offset.dev_attr.attr, &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
&iio_dev_attr_accel_z_offset.dev_attr.attr, &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
&iio_dev_attr_accel_x_gain.dev_attr.attr, &iio_dev_attr_accel_x_calibscale.dev_attr.attr,
&iio_dev_attr_accel_y_gain.dev_attr.attr, &iio_dev_attr_accel_y_calibscale.dev_attr.attr,
&iio_dev_attr_accel_z_gain.dev_attr.attr, &iio_dev_attr_accel_z_calibscale.dev_attr.attr,
&iio_dev_attr_thresh.dev_attr.attr, &iio_const_attr_accel_scale.dev_attr.attr,
&iio_dev_attr_accel_x.dev_attr.attr, &iio_dev_attr_accel_x_raw.dev_attr.attr,
&iio_dev_attr_accel_y.dev_attr.attr, &iio_dev_attr_accel_y_raw.dev_attr.attr,
&iio_dev_attr_accel_z.dev_attr.attr, &iio_dev_attr_accel_z_raw.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr,
&iio_const_attr_available_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_const_attr_name.dev_attr.attr, &iio_const_attr_name.dev_attr.attr,
NULL NULL
}; };
......
...@@ -75,16 +75,16 @@ static int lis3l02dq_scan_el_set_state(struct iio_scan_el *scan_el, ...@@ -75,16 +75,16 @@ static int lis3l02dq_scan_el_set_state(struct iio_scan_el *scan_el,
return ret; return ret;
} }
static IIO_SCAN_EL_C(accel_x, LIS3L02DQ_SCAN_ACC_X, IIO_SIGNED(16), static IIO_SCAN_EL_C(accel_x, 0, IIO_SIGNED(16),
LIS3L02DQ_REG_OUT_X_L_ADDR, LIS3L02DQ_REG_OUT_X_L_ADDR,
&lis3l02dq_scan_el_set_state); &lis3l02dq_scan_el_set_state);
static IIO_SCAN_EL_C(accel_y, LIS3L02DQ_SCAN_ACC_Y, IIO_SIGNED(16), static IIO_SCAN_EL_C(accel_y, 1, IIO_SIGNED(16),
LIS3L02DQ_REG_OUT_Y_L_ADDR, LIS3L02DQ_REG_OUT_Y_L_ADDR,
&lis3l02dq_scan_el_set_state); &lis3l02dq_scan_el_set_state);
static IIO_SCAN_EL_C(accel_z, LIS3L02DQ_SCAN_ACC_Z, IIO_SIGNED(16), static IIO_SCAN_EL_C(accel_z, 2, IIO_SIGNED(16),
LIS3L02DQ_REG_OUT_Z_L_ADDR, LIS3L02DQ_REG_OUT_Z_L_ADDR,
&lis3l02dq_scan_el_set_state); &lis3l02dq_scan_el_set_state);
static IIO_SCAN_EL_TIMESTAMP; static IIO_SCAN_EL_TIMESTAMP(3);
static struct attribute *lis3l02dq_scan_el_attrs[] = { static struct attribute *lis3l02dq_scan_el_attrs[] = {
&iio_scan_el_accel_x.dev_attr.attr, &iio_scan_el_accel_x.dev_attr.attr,
......
...@@ -187,6 +187,7 @@ struct sca3000_state { ...@@ -187,6 +187,7 @@ struct sca3000_state {
/** /**
* struct sca3000_chip_info - model dependant parameters * struct sca3000_chip_info - model dependant parameters
* @name: model identification * @name: model identification
* @scale: string containing floating point scale factor
* @temp_output: some devices have temperature sensors. * @temp_output: some devices have temperature sensors.
* @measurement_mode_freq: normal mode sampling frequency * @measurement_mode_freq: normal mode sampling frequency
* @option_mode_1: first optional mode. Not all models have one * @option_mode_1: first optional mode. Not all models have one
...@@ -199,6 +200,7 @@ struct sca3000_state { ...@@ -199,6 +200,7 @@ struct sca3000_state {
**/ **/
struct sca3000_chip_info { struct sca3000_chip_info {
const char *name; const char *name;
const char *scale;
bool temp_output; bool temp_output;
int measurement_mode_freq; int measurement_mode_freq;
int option_mode_1; int option_mode_1;
......
...@@ -27,11 +27,9 @@ ...@@ -27,11 +27,9 @@
enum sca3000_variant { enum sca3000_variant {
d01, d01,
d03,
e02, e02,
e04, e04,
e05, e05,
l01,
}; };
/* Note where option modes are not defined, the chip simply does not /* Note where option modes are not defined, the chip simply does not
...@@ -44,21 +42,20 @@ enum sca3000_variant { ...@@ -44,21 +42,20 @@ enum sca3000_variant {
static const struct sca3000_chip_info sca3000_spi_chip_info_tbl[] = { static const struct sca3000_chip_info sca3000_spi_chip_info_tbl[] = {
{ {
.name = "sca3000-d01", .name = "sca3000-d01",
.scale = " 0.0073575",
.temp_output = true, .temp_output = true,
.measurement_mode_freq = 250, .measurement_mode_freq = 250,
.option_mode_1 = SCA3000_OP_MODE_BYPASS, .option_mode_1 = SCA3000_OP_MODE_BYPASS,
.option_mode_1_freq = 250, .option_mode_1_freq = 250,
}, {
/* No data sheet available - may be the same as the 3100-d03?*/
.name = "sca3000-d03",
.temp_output = true,
}, { }, {
.name = "sca3000-e02", .name = "sca3000-e02",
.scale = "0.00981",
.measurement_mode_freq = 125, .measurement_mode_freq = 125,
.option_mode_1 = SCA3000_OP_MODE_NARROW, .option_mode_1 = SCA3000_OP_MODE_NARROW,
.option_mode_1_freq = 63, .option_mode_1_freq = 63,
}, { }, {
.name = "sca3000-e04", .name = "sca3000-e04",
.scale = "0.01962",
.measurement_mode_freq = 100, .measurement_mode_freq = 100,
.option_mode_1 = SCA3000_OP_MODE_NARROW, .option_mode_1 = SCA3000_OP_MODE_NARROW,
.option_mode_1_freq = 50, .option_mode_1_freq = 50,
...@@ -66,18 +63,12 @@ static const struct sca3000_chip_info sca3000_spi_chip_info_tbl[] = { ...@@ -66,18 +63,12 @@ static const struct sca3000_chip_info sca3000_spi_chip_info_tbl[] = {
.option_mode_2_freq = 400, .option_mode_2_freq = 400,
}, { }, {
.name = "sca3000-e05", .name = "sca3000-e05",
.scale = "0.0613125",
.measurement_mode_freq = 200, .measurement_mode_freq = 200,
.option_mode_1 = SCA3000_OP_MODE_NARROW, .option_mode_1 = SCA3000_OP_MODE_NARROW,
.option_mode_1_freq = 50, .option_mode_1_freq = 50,
.option_mode_2 = SCA3000_OP_MODE_WIDE, .option_mode_2 = SCA3000_OP_MODE_WIDE,
.option_mode_2_freq = 400, .option_mode_2_freq = 400,
}, {
/* No data sheet available.
* Frequencies are unknown.
*/
.name = "sca3000-l01",
.temp_output = true,
.option_mode_1 = SCA3000_OP_MODE_BYPASS,
}, },
}; };
...@@ -327,6 +318,14 @@ static ssize_t sca3000_read_13bit_signed(struct device *dev, ...@@ -327,6 +318,14 @@ static ssize_t sca3000_read_13bit_signed(struct device *dev,
return ret ? ret : len; return ret ? ret : len;
} }
static ssize_t sca3000_show_scale(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *dev_info = dev_get_drvdata(dev);
struct sca3000_state *st = dev_info->dev_data;
return sprintf(buf, "%s\n", st->info->scale);
}
static ssize_t sca3000_show_name(struct device *dev, static ssize_t sca3000_show_name(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
...@@ -495,7 +494,7 @@ sca3000_store_measurement_mode(struct device *dev, ...@@ -495,7 +494,7 @@ sca3000_store_measurement_mode(struct device *dev,
/* Not even vaguely standard attributes so defined here rather than /* Not even vaguely standard attributes so defined here rather than
* in the relevant IIO core headers * in the relevant IIO core headers
*/ */
static IIO_DEVICE_ATTR(available_measurement_modes, S_IRUGO, static IIO_DEVICE_ATTR(measurement_mode_available, S_IRUGO,
sca3000_show_available_measurement_modes, sca3000_show_available_measurement_modes,
NULL, 0); NULL, 0);
...@@ -508,6 +507,8 @@ static IIO_DEVICE_ATTR(measurement_mode, S_IRUGO | S_IWUSR, ...@@ -508,6 +507,8 @@ static IIO_DEVICE_ATTR(measurement_mode, S_IRUGO | S_IWUSR,
static IIO_DEV_ATTR_NAME(sca3000_show_name); static IIO_DEV_ATTR_NAME(sca3000_show_name);
static IIO_DEV_ATTR_REV(sca3000_show_rev); static IIO_DEV_ATTR_REV(sca3000_show_rev);
static IIO_DEVICE_ATTR(accel_scale, S_IRUGO, sca3000_show_scale,
NULL, 0);
static IIO_DEV_ATTR_ACCEL_X(sca3000_read_13bit_signed, static IIO_DEV_ATTR_ACCEL_X(sca3000_read_13bit_signed,
SCA3000_REG_ADDR_X_MSB); SCA3000_REG_ADDR_X_MSB);
...@@ -683,7 +684,7 @@ static ssize_t sca3000_set_frequency(struct device *dev, ...@@ -683,7 +684,7 @@ static ssize_t sca3000_set_frequency(struct device *dev,
/* Should only really be registered if ring buffer support is compiled in. /* Should only really be registered if ring buffer support is compiled in.
* Does no harm however and doing it right would add a fair bit of complexity * Does no harm however and doing it right would add a fair bit of complexity
*/ */
static IIO_DEV_ATTR_AVAIL_SAMP_FREQ(sca3000_read_av_freq); static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(sca3000_read_av_freq);
static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
sca3000_read_frequency, sca3000_read_frequency,
...@@ -718,7 +719,10 @@ static ssize_t sca3000_read_temp(struct device *dev, ...@@ -718,7 +719,10 @@ static ssize_t sca3000_read_temp(struct device *dev,
error_ret: error_ret:
return ret; return ret;
} }
static IIO_DEV_ATTR_TEMP(sca3000_read_temp); static IIO_DEV_ATTR_TEMP_RAW(sca3000_read_temp);
static IIO_CONST_ATTR(temp_scale, "0.555556");
static IIO_CONST_ATTR(temp_offset, "-214.6");
/** /**
* sca3000_show_thresh() sysfs query of a threshold * sca3000_show_thresh() sysfs query of a threshold
...@@ -770,31 +774,34 @@ static ssize_t sca3000_write_thresh(struct device *dev, ...@@ -770,31 +774,34 @@ static ssize_t sca3000_write_thresh(struct device *dev,
return ret ? ret : len; return ret ? ret : len;
} }
static IIO_DEV_ATTR_ACCEL_THRESH_X(S_IRUGO | S_IWUSR, static IIO_DEVICE_ATTR(accel_x_mag_either_rising_value,
sca3000_show_thresh, S_IRUGO | S_IWUSR,
sca3000_write_thresh, sca3000_show_thresh,
SCA3000_REG_CTRL_SEL_MD_X_TH); sca3000_write_thresh,
static IIO_DEV_ATTR_ACCEL_THRESH_Y(S_IRUGO | S_IWUSR, SCA3000_REG_CTRL_SEL_MD_X_TH);
sca3000_show_thresh,
sca3000_write_thresh, static IIO_DEVICE_ATTR(accel_y_mag_either_rising_value,
SCA3000_REG_CTRL_SEL_MD_Y_TH); S_IRUGO | S_IWUSR,
static IIO_DEV_ATTR_ACCEL_THRESH_Z(S_IRUGO | S_IWUSR, sca3000_show_thresh,
sca3000_show_thresh, sca3000_write_thresh,
sca3000_write_thresh, SCA3000_REG_CTRL_SEL_MD_Y_TH);
SCA3000_REG_CTRL_SEL_MD_Z_TH);
static IIO_DEVICE_ATTR(accel_z_mag_either_rising_value,
S_IRUGO | S_IWUSR,
sca3000_show_thresh,
sca3000_write_thresh,
SCA3000_REG_CTRL_SEL_MD_Z_TH);
static struct attribute *sca3000_attributes[] = { static struct attribute *sca3000_attributes[] = {
&iio_dev_attr_name.dev_attr.attr, &iio_dev_attr_name.dev_attr.attr,
&iio_dev_attr_revision.dev_attr.attr, &iio_dev_attr_revision.dev_attr.attr,
&iio_dev_attr_accel_x.dev_attr.attr, &iio_dev_attr_accel_scale.dev_attr.attr,
&iio_dev_attr_accel_y.dev_attr.attr, &iio_dev_attr_accel_x_raw.dev_attr.attr,
&iio_dev_attr_accel_z.dev_attr.attr, &iio_dev_attr_accel_y_raw.dev_attr.attr,
&iio_dev_attr_thresh_accel_x.dev_attr.attr, &iio_dev_attr_accel_z_raw.dev_attr.attr,
&iio_dev_attr_thresh_accel_y.dev_attr.attr, &iio_dev_attr_measurement_mode_available.dev_attr.attr,
&iio_dev_attr_thresh_accel_z.dev_attr.attr,
&iio_dev_attr_available_measurement_modes.dev_attr.attr,
&iio_dev_attr_measurement_mode.dev_attr.attr, &iio_dev_attr_measurement_mode.dev_attr.attr,
&iio_dev_attr_available_sampling_frequency.dev_attr.attr, &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr,
NULL, NULL,
}; };
...@@ -802,18 +809,18 @@ static struct attribute *sca3000_attributes[] = { ...@@ -802,18 +809,18 @@ static struct attribute *sca3000_attributes[] = {
static struct attribute *sca3000_attributes_with_temp[] = { static struct attribute *sca3000_attributes_with_temp[] = {
&iio_dev_attr_name.dev_attr.attr, &iio_dev_attr_name.dev_attr.attr,
&iio_dev_attr_revision.dev_attr.attr, &iio_dev_attr_revision.dev_attr.attr,
&iio_dev_attr_accel_x.dev_attr.attr, &iio_dev_attr_accel_scale.dev_attr.attr,
&iio_dev_attr_accel_y.dev_attr.attr, &iio_dev_attr_accel_x_raw.dev_attr.attr,
&iio_dev_attr_accel_z.dev_attr.attr, &iio_dev_attr_accel_y_raw.dev_attr.attr,
&iio_dev_attr_thresh_accel_x.dev_attr.attr, &iio_dev_attr_accel_z_raw.dev_attr.attr,
&iio_dev_attr_thresh_accel_y.dev_attr.attr, &iio_dev_attr_measurement_mode_available.dev_attr.attr,
&iio_dev_attr_thresh_accel_z.dev_attr.attr,
&iio_dev_attr_available_measurement_modes.dev_attr.attr,
&iio_dev_attr_measurement_mode.dev_attr.attr, &iio_dev_attr_measurement_mode.dev_attr.attr,
&iio_dev_attr_available_sampling_frequency.dev_attr.attr, &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr,
/* Only present if temp sensor is */ /* Only present if temp sensor is */
&iio_dev_attr_temp.dev_attr.attr, &iio_dev_attr_temp_raw.dev_attr.attr,
&iio_const_attr_temp_offset.dev_attr.attr,
&iio_const_attr_temp_scale.dev_attr.attr,
NULL, NULL,
}; };
...@@ -910,7 +917,7 @@ static ssize_t sca3000_query_mo_det(struct device *dev, ...@@ -910,7 +917,7 @@ static ssize_t sca3000_query_mo_det(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
struct sca3000_state *st = indio_dev->dev_data; struct sca3000_state *st = indio_dev->dev_data;
struct iio_event_attr *this_attr = to_iio_event_attr(attr); struct iio_event_attr *this_attr = to_iio_event_attr(attr);
int ret, len = 0; int ret, len = 0;
...@@ -975,7 +982,7 @@ static ssize_t sca3000_query_ring_int(struct device *dev, ...@@ -975,7 +982,7 @@ static ssize_t sca3000_query_ring_int(struct device *dev,
struct iio_event_attr *this_attr = to_iio_event_attr(attr); struct iio_event_attr *this_attr = to_iio_event_attr(attr);
int ret, len; int ret, len;
u8 *rx; u8 *rx;
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
struct sca3000_state *st = indio_dev->dev_data; struct sca3000_state *st = indio_dev->dev_data;
mutex_lock(&st->lock); mutex_lock(&st->lock);
ret = sca3000_read_data(st, SCA3000_REG_ADDR_INT_MASK, &rx, 1); ret = sca3000_read_data(st, SCA3000_REG_ADDR_INT_MASK, &rx, 1);
...@@ -995,7 +1002,7 @@ static ssize_t sca3000_set_ring_int(struct device *dev, ...@@ -995,7 +1002,7 @@ static ssize_t sca3000_set_ring_int(struct device *dev,
const char *buf, const char *buf,
size_t len) size_t len)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
struct sca3000_state *st = indio_dev->dev_data; struct sca3000_state *st = indio_dev->dev_data;
struct iio_event_attr *this_attr = to_iio_event_attr(attr); struct iio_event_attr *this_attr = to_iio_event_attr(attr);
...@@ -1085,7 +1092,7 @@ static ssize_t sca3000_set_mo_det(struct device *dev, ...@@ -1085,7 +1092,7 @@ static ssize_t sca3000_set_mo_det(struct device *dev,
const char *buf, const char *buf,
size_t len) size_t len)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
struct sca3000_state *st = indio_dev->dev_data; struct sca3000_state *st = indio_dev->dev_data;
struct iio_event_attr *this_attr = to_iio_event_attr(attr); struct iio_event_attr *this_attr = to_iio_event_attr(attr);
long val; long val;
...@@ -1155,20 +1162,23 @@ IIO_EVENT_ATTR_FREE_FALL_DETECT_SH(iio_event_all, ...@@ -1155,20 +1162,23 @@ IIO_EVENT_ATTR_FREE_FALL_DETECT_SH(iio_event_all,
0) 0)
/* Motion detector related event attributes */ /* Motion detector related event attributes */
IIO_EVENT_ATTR_ACCEL_X_HIGH_SH(iio_event_all, IIO_EVENT_ATTR_SH(accel_x_mag_either_rising_en,
sca3000_query_mo_det, iio_event_all,
sca3000_set_mo_det, sca3000_query_mo_det,
SCA3000_MD_CTRL_OR_X); sca3000_set_mo_det,
SCA3000_MD_CTRL_OR_X);
IIO_EVENT_ATTR_ACCEL_Y_HIGH_SH(iio_event_all,
sca3000_query_mo_det, IIO_EVENT_ATTR_SH(accel_y_mag_either_rising_en,
sca3000_set_mo_det, iio_event_all,
SCA3000_MD_CTRL_OR_Y); sca3000_query_mo_det,
sca3000_set_mo_det,
IIO_EVENT_ATTR_ACCEL_Z_HIGH_SH(iio_event_all, SCA3000_MD_CTRL_OR_Y);
sca3000_query_mo_det,
sca3000_set_mo_det, IIO_EVENT_ATTR_SH(accel_z_mag_either_rising_en,
SCA3000_MD_CTRL_OR_Z); iio_event_all,
sca3000_query_mo_det,
sca3000_set_mo_det,
SCA3000_MD_CTRL_OR_Z);
/* Hardware ring buffer related event attributes */ /* Hardware ring buffer related event attributes */
IIO_EVENT_ATTR_RING_50_FULL_SH(iio_event_all, IIO_EVENT_ATTR_RING_50_FULL_SH(iio_event_all,
...@@ -1183,11 +1193,14 @@ IIO_EVENT_ATTR_RING_75_FULL_SH(iio_event_all, ...@@ -1183,11 +1193,14 @@ IIO_EVENT_ATTR_RING_75_FULL_SH(iio_event_all,
static struct attribute *sca3000_event_attributes[] = { static struct attribute *sca3000_event_attributes[] = {
&iio_event_attr_free_fall.dev_attr.attr, &iio_event_attr_free_fall.dev_attr.attr,
&iio_event_attr_accel_x_high.dev_attr.attr, &iio_event_attr_accel_x_mag_either_rising_en.dev_attr.attr,
&iio_event_attr_accel_y_high.dev_attr.attr, &iio_event_attr_accel_y_mag_either_rising_en.dev_attr.attr,
&iio_event_attr_accel_z_high.dev_attr.attr, &iio_event_attr_accel_z_mag_either_rising_en.dev_attr.attr,
&iio_event_attr_ring_50_full.dev_attr.attr, &iio_event_attr_ring_50_full.dev_attr.attr,
&iio_event_attr_ring_75_full.dev_attr.attr, &iio_event_attr_ring_75_full.dev_attr.attr,
&iio_dev_attr_accel_x_mag_either_rising_value.dev_attr.attr,
&iio_dev_attr_accel_y_mag_either_rising_value.dev_attr.attr,
&iio_dev_attr_accel_z_mag_either_rising_value.dev_attr.attr,
NULL, NULL,
}; };
...@@ -1344,9 +1357,10 @@ static int __devinit __sca3000_probe(struct spi_device *spi, ...@@ -1344,9 +1357,10 @@ static int __devinit __sca3000_probe(struct spi_device *spi,
* is overkill. At very least a simpler registration method * is overkill. At very least a simpler registration method
* might be worthwhile. * might be worthwhile.
*/ */
iio_add_event_to_list(iio_event_attr_accel_z_high.listel, iio_add_event_to_list(
&st->indio_dev iio_event_attr_accel_z_mag_either_rising_en.listel,
->interrupts[0]->ev_list); &st->indio_dev
->interrupts[0]->ev_list);
} }
sca3000_register_ring_funcs(st->indio_dev); sca3000_register_ring_funcs(st->indio_dev);
ret = sca3000_clean_setup(st); ret = sca3000_clean_setup(st);
...@@ -1437,9 +1451,6 @@ static int sca3000_remove(struct spi_device *spi) ...@@ -1437,9 +1451,6 @@ static int sca3000_remove(struct spi_device *spi)
SCA3000_VARIANT_PROBE(d01); SCA3000_VARIANT_PROBE(d01);
static SCA3000_VARIANT_SPI_DRIVER(d01); static SCA3000_VARIANT_SPI_DRIVER(d01);
SCA3000_VARIANT_PROBE(d03);
static SCA3000_VARIANT_SPI_DRIVER(d03);
SCA3000_VARIANT_PROBE(e02); SCA3000_VARIANT_PROBE(e02);
static SCA3000_VARIANT_SPI_DRIVER(e02); static SCA3000_VARIANT_SPI_DRIVER(e02);
...@@ -1449,9 +1460,6 @@ static SCA3000_VARIANT_SPI_DRIVER(e04); ...@@ -1449,9 +1460,6 @@ static SCA3000_VARIANT_SPI_DRIVER(e04);
SCA3000_VARIANT_PROBE(e05); SCA3000_VARIANT_PROBE(e05);
static SCA3000_VARIANT_SPI_DRIVER(e05); static SCA3000_VARIANT_SPI_DRIVER(e05);
SCA3000_VARIANT_PROBE(l01);
static SCA3000_VARIANT_SPI_DRIVER(l01);
static __init int sca3000_init(void) static __init int sca3000_init(void)
{ {
int ret; int ret;
...@@ -1459,32 +1467,22 @@ static __init int sca3000_init(void) ...@@ -1459,32 +1467,22 @@ static __init int sca3000_init(void)
ret = spi_register_driver(&sca3000_d01_driver); ret = spi_register_driver(&sca3000_d01_driver);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = spi_register_driver(&sca3000_d03_driver);
if (ret)
goto error_unreg_d01;
ret = spi_register_driver(&sca3000_e02_driver); ret = spi_register_driver(&sca3000_e02_driver);
if (ret) if (ret)
goto error_unreg_d03; goto error_unreg_d01;
ret = spi_register_driver(&sca3000_e04_driver); ret = spi_register_driver(&sca3000_e04_driver);
if (ret) if (ret)
goto error_unreg_e02; goto error_unreg_e02;
ret = spi_register_driver(&sca3000_e05_driver); ret = spi_register_driver(&sca3000_e05_driver);
if (ret) if (ret)
goto error_unreg_e04; goto error_unreg_e04;
ret = spi_register_driver(&sca3000_l01_driver);
if (ret)
goto error_unreg_e05;
return 0; return 0;
error_unreg_e05:
spi_unregister_driver(&sca3000_e05_driver);
error_unreg_e04: error_unreg_e04:
spi_unregister_driver(&sca3000_e04_driver); spi_unregister_driver(&sca3000_e04_driver);
error_unreg_e02: error_unreg_e02:
spi_unregister_driver(&sca3000_e02_driver); spi_unregister_driver(&sca3000_e02_driver);
error_unreg_d03:
spi_unregister_driver(&sca3000_d03_driver);
error_unreg_d01: error_unreg_d01:
spi_unregister_driver(&sca3000_d01_driver); spi_unregister_driver(&sca3000_d01_driver);
error_ret: error_ret:
...@@ -1494,11 +1492,9 @@ static __init int sca3000_init(void) ...@@ -1494,11 +1492,9 @@ static __init int sca3000_init(void)
static __exit void sca3000_exit(void) static __exit void sca3000_exit(void)
{ {
spi_unregister_driver(&sca3000_l01_driver);
spi_unregister_driver(&sca3000_e05_driver); spi_unregister_driver(&sca3000_e05_driver);
spi_unregister_driver(&sca3000_e04_driver); spi_unregister_driver(&sca3000_e04_driver);
spi_unregister_driver(&sca3000_e02_driver); spi_unregister_driver(&sca3000_e02_driver);
spi_unregister_driver(&sca3000_d03_driver);
spi_unregister_driver(&sca3000_d01_driver); spi_unregister_driver(&sca3000_d01_driver);
} }
......
...@@ -186,11 +186,29 @@ static ssize_t sca3000_store_ring_bpse(struct device *dev, ...@@ -186,11 +186,29 @@ static ssize_t sca3000_store_ring_bpse(struct device *dev,
return ret ? ret : len; return ret ? ret : len;
} }
static IIO_CONST_ATTR(bpse_available, "8 11"); static IIO_SCAN_EL_C(accel_x, 0, 0, 0, 0);
static IIO_SCAN_EL_C(accel_y, 1, 0, 0, 0);
static IIO_SCAN_EL_C(accel_z, 2, 0, 0, 0);
static IIO_CONST_ATTR(accel_precision_available, "8 11");
static IIO_DEVICE_ATTR(accel_precision,
S_IRUGO | S_IWUSR,
sca3000_show_ring_bpse,
sca3000_store_ring_bpse,
0);
static struct attribute *sca3000_scan_el_attrs[] = {
&iio_scan_el_accel_x.dev_attr.attr,
&iio_scan_el_accel_y.dev_attr.attr,
&iio_scan_el_accel_z.dev_attr.attr,
&iio_const_attr_accel_precision_available.dev_attr.attr,
&iio_dev_attr_accel_precision.dev_attr.attr,
NULL
};
static IIO_DEV_ATTR_BPSE(S_IRUGO | S_IWUSR, static struct attribute_group sca3000_scan_el_group = {
sca3000_show_ring_bpse, .attrs = sca3000_scan_el_attrs,
sca3000_store_ring_bpse); .name = "scan_elements",
};
/* /*
* Ring buffer attributes * Ring buffer attributes
...@@ -198,17 +216,15 @@ static IIO_DEV_ATTR_BPSE(S_IRUGO | S_IWUSR, ...@@ -198,17 +216,15 @@ static IIO_DEV_ATTR_BPSE(S_IRUGO | S_IWUSR,
* only apply to the ring buffer. At all times full rate and accuracy * only apply to the ring buffer. At all times full rate and accuracy
* is available via direct reading from registers. * is available via direct reading from registers.
*/ */
static struct attribute *iio_ring_attributes[] = { static struct attribute *sca3000_ring_attributes[] = {
&dev_attr_length.attr, &dev_attr_length.attr,
&dev_attr_bps.attr, &dev_attr_bps.attr,
&dev_attr_ring_enable.attr, &dev_attr_ring_enable.attr,
&iio_dev_attr_bpse.dev_attr.attr,
&iio_const_attr_bpse_available.dev_attr.attr,
NULL, NULL,
}; };
static struct attribute_group sca3000_ring_attr = { static struct attribute_group sca3000_ring_attr = {
.attrs = iio_ring_attributes, .attrs = sca3000_ring_attributes,
}; };
static const struct attribute_group *sca3000_ring_attr_groups[] = { static const struct attribute_group *sca3000_ring_attr_groups[] = {
...@@ -248,6 +264,7 @@ static inline void sca3000_rb_free(struct iio_ring_buffer *r) ...@@ -248,6 +264,7 @@ static inline void sca3000_rb_free(struct iio_ring_buffer *r)
int sca3000_configure_ring(struct iio_dev *indio_dev) int sca3000_configure_ring(struct iio_dev *indio_dev)
{ {
indio_dev->scan_el_attrs = &sca3000_scan_el_group;
indio_dev->ring = sca3000_rb_allocate(indio_dev); indio_dev->ring = sca3000_rb_allocate(indio_dev);
if (indio_dev->ring == NULL) if (indio_dev->ring == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -248,9 +248,9 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr, ...@@ -248,9 +248,9 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr,
* *
* Odd one out. Handled slightly differently from other scan elements. * Odd one out. Handled slightly differently from other scan elements.
**/ **/
#define IIO_SCAN_EL_TIMESTAMP \ #define IIO_SCAN_EL_TIMESTAMP(number) \
struct iio_scan_el iio_scan_el_timestamp = { \ struct iio_scan_el iio_scan_el_timestamp = { \
.dev_attr = __ATTR(scan_en_timestamp, \ .dev_attr = __ATTR(number##_timestamp_en, \
S_IRUGO | S_IWUSR, \ S_IRUGO | S_IWUSR, \
iio_scan_el_ts_show, \ iio_scan_el_ts_show, \
iio_scan_el_ts_store), \ iio_scan_el_ts_store), \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment