aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-05-24 14:43:25 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-05-24 14:43:25 -0400
commita8acb4d33d476b5a5f1c549b404bfa49d73cf8b6 (patch)
tree4bf837036302e8332a3eca8340686e808d17262f
parente26081808edadfd257c6c9d81014e3b25e9a6118 (diff)
parente5d732186270e0881f47d95610316c0614b21c3e (diff)
Merge tag 'iio-fixes-for-4.1b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes: Second round of fixes for IIO in the 4.1 cycle. * twl6030-gpadc - Drop a bonus space from the modalias. * adis16400 - Report pressure channel scale (not much use without it) - Use different channel indices for the two voltage channels (ABI) - Compute the san mask from the channel indices instead of using ~0UL as we now care about extra bits being set. - Fix burst mode due to rx buffer not being intialized and wrong tx buffer type being set. Also had the wrong transfer length. All in all it didn't work, now it does ;) - adis16448 has additional registers in burst mode so we skip over them to make it work.
-rw-r--r--drivers/iio/adc/twl6030-gpadc.c2
-rw-r--r--drivers/iio/imu/adis16400.h2
-rw-r--r--drivers/iio/imu/adis16400_buffer.c26
-rw-r--r--drivers/iio/imu/adis16400_core.c41
4 files changed, 50 insertions, 21 deletions
diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
index 89d8aa1d2818..df12c57e6ce0 100644
--- a/drivers/iio/adc/twl6030-gpadc.c
+++ b/drivers/iio/adc/twl6030-gpadc.c
@@ -1001,7 +1001,7 @@ static struct platform_driver twl6030_gpadc_driver = {
1001 1001
1002module_platform_driver(twl6030_gpadc_driver); 1002module_platform_driver(twl6030_gpadc_driver);
1003 1003
1004MODULE_ALIAS("platform: " DRIVER_NAME); 1004MODULE_ALIAS("platform:" DRIVER_NAME);
1005MODULE_AUTHOR("Balaji T K <balajitk@ti.com>"); 1005MODULE_AUTHOR("Balaji T K <balajitk@ti.com>");
1006MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>"); 1006MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>");
1007MODULE_AUTHOR("Oleksandr Kozaruk <oleksandr.kozaruk@ti.com"); 1007MODULE_AUTHOR("Oleksandr Kozaruk <oleksandr.kozaruk@ti.com");
diff --git a/drivers/iio/imu/adis16400.h b/drivers/iio/imu/adis16400.h
index 0916bf6b6c31..73b189c1c0fb 100644
--- a/drivers/iio/imu/adis16400.h
+++ b/drivers/iio/imu/adis16400.h
@@ -139,6 +139,7 @@
139#define ADIS16400_NO_BURST BIT(1) 139#define ADIS16400_NO_BURST BIT(1)
140#define ADIS16400_HAS_SLOW_MODE BIT(2) 140#define ADIS16400_HAS_SLOW_MODE BIT(2)
141#define ADIS16400_HAS_SERIAL_NUMBER BIT(3) 141#define ADIS16400_HAS_SERIAL_NUMBER BIT(3)
142#define ADIS16400_BURST_DIAG_STAT BIT(4)
142 143
143struct adis16400_state; 144struct adis16400_state;
144 145
@@ -165,6 +166,7 @@ struct adis16400_state {
165 int filt_int; 166 int filt_int;
166 167
167 struct adis adis; 168 struct adis adis;
169 unsigned long avail_scan_mask[2];
168}; 170};
169 171
170/* At the moment triggers are only used for ring buffer 172/* At the moment triggers are only used for ring buffer
diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c
index 6e727ffe5262..90c24a23c679 100644
--- a/drivers/iio/imu/adis16400_buffer.c
+++ b/drivers/iio/imu/adis16400_buffer.c
@@ -18,7 +18,8 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,
18{ 18{
19 struct adis16400_state *st = iio_priv(indio_dev); 19 struct adis16400_state *st = iio_priv(indio_dev);
20 struct adis *adis = &st->adis; 20 struct adis *adis = &st->adis;
21 uint16_t *tx; 21 unsigned int burst_length;
22 u8 *tx;
22 23
23 if (st->variant->flags & ADIS16400_NO_BURST) 24 if (st->variant->flags & ADIS16400_NO_BURST)
24 return adis_update_scan_mode(indio_dev, scan_mask); 25 return adis_update_scan_mode(indio_dev, scan_mask);
@@ -26,26 +27,29 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,
26 kfree(adis->xfer); 27 kfree(adis->xfer);
27 kfree(adis->buffer); 28 kfree(adis->buffer);
28 29
30 /* All but the timestamp channel */
31 burst_length = (indio_dev->num_channels - 1) * sizeof(u16);
32 if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
33 burst_length += sizeof(u16);
34
29 adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL); 35 adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL);
30 if (!adis->xfer) 36 if (!adis->xfer)
31 return -ENOMEM; 37 return -ENOMEM;
32 38
33 adis->buffer = kzalloc(indio_dev->scan_bytes + sizeof(u16), 39 adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
34 GFP_KERNEL);
35 if (!adis->buffer) 40 if (!adis->buffer)
36 return -ENOMEM; 41 return -ENOMEM;
37 42
38 tx = adis->buffer + indio_dev->scan_bytes; 43 tx = adis->buffer + burst_length;
39
40 tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD); 44 tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD);
41 tx[1] = 0; 45 tx[1] = 0;
42 46
43 adis->xfer[0].tx_buf = tx; 47 adis->xfer[0].tx_buf = tx;
44 adis->xfer[0].bits_per_word = 8; 48 adis->xfer[0].bits_per_word = 8;
45 adis->xfer[0].len = 2; 49 adis->xfer[0].len = 2;
46 adis->xfer[1].tx_buf = tx; 50 adis->xfer[1].rx_buf = adis->buffer;
47 adis->xfer[1].bits_per_word = 8; 51 adis->xfer[1].bits_per_word = 8;
48 adis->xfer[1].len = indio_dev->scan_bytes; 52 adis->xfer[1].len = burst_length;
49 53
50 spi_message_init(&adis->msg); 54 spi_message_init(&adis->msg);
51 spi_message_add_tail(&adis->xfer[0], &adis->msg); 55 spi_message_add_tail(&adis->xfer[0], &adis->msg);
@@ -61,6 +65,7 @@ irqreturn_t adis16400_trigger_handler(int irq, void *p)
61 struct adis16400_state *st = iio_priv(indio_dev); 65 struct adis16400_state *st = iio_priv(indio_dev);
62 struct adis *adis = &st->adis; 66 struct adis *adis = &st->adis;
63 u32 old_speed_hz = st->adis.spi->max_speed_hz; 67 u32 old_speed_hz = st->adis.spi->max_speed_hz;
68 void *buffer;
64 int ret; 69 int ret;
65 70
66 if (!adis->buffer) 71 if (!adis->buffer)
@@ -81,7 +86,12 @@ irqreturn_t adis16400_trigger_handler(int irq, void *p)
81 spi_setup(st->adis.spi); 86 spi_setup(st->adis.spi);
82 } 87 }
83 88
84 iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer, 89 if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
90 buffer = adis->buffer + sizeof(u16);
91 else
92 buffer = adis->buffer;
93
94 iio_push_to_buffers_with_timestamp(indio_dev, buffer,
85 pf->timestamp); 95 pf->timestamp);
86 96
87 iio_trigger_notify_done(indio_dev->trig); 97 iio_trigger_notify_done(indio_dev->trig);
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
index fa795dcd5f75..2fd68f2219a7 100644
--- a/drivers/iio/imu/adis16400_core.c
+++ b/drivers/iio/imu/adis16400_core.c
@@ -405,6 +405,11 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
405 *val = st->variant->temp_scale_nano / 1000000; 405 *val = st->variant->temp_scale_nano / 1000000;
406 *val2 = (st->variant->temp_scale_nano % 1000000); 406 *val2 = (st->variant->temp_scale_nano % 1000000);
407 return IIO_VAL_INT_PLUS_MICRO; 407 return IIO_VAL_INT_PLUS_MICRO;
408 case IIO_PRESSURE:
409 /* 20 uBar = 0.002kPascal */
410 *val = 0;
411 *val2 = 2000;
412 return IIO_VAL_INT_PLUS_MICRO;
408 default: 413 default:
409 return -EINVAL; 414 return -EINVAL;
410 } 415 }
@@ -454,10 +459,10 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
454 } 459 }
455} 460}
456 461
457#define ADIS16400_VOLTAGE_CHAN(addr, bits, name, si) { \ 462#define ADIS16400_VOLTAGE_CHAN(addr, bits, name, si, chn) { \
458 .type = IIO_VOLTAGE, \ 463 .type = IIO_VOLTAGE, \
459 .indexed = 1, \ 464 .indexed = 1, \
460 .channel = 0, \ 465 .channel = chn, \
461 .extend_name = name, \ 466 .extend_name = name, \
462 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 467 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
463 BIT(IIO_CHAN_INFO_SCALE), \ 468 BIT(IIO_CHAN_INFO_SCALE), \
@@ -474,10 +479,10 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
474} 479}
475 480
476#define ADIS16400_SUPPLY_CHAN(addr, bits) \ 481#define ADIS16400_SUPPLY_CHAN(addr, bits) \
477 ADIS16400_VOLTAGE_CHAN(addr, bits, "supply", ADIS16400_SCAN_SUPPLY) 482 ADIS16400_VOLTAGE_CHAN(addr, bits, "supply", ADIS16400_SCAN_SUPPLY, 0)
478 483
479#define ADIS16400_AUX_ADC_CHAN(addr, bits) \ 484#define ADIS16400_AUX_ADC_CHAN(addr, bits) \
480 ADIS16400_VOLTAGE_CHAN(addr, bits, NULL, ADIS16400_SCAN_ADC) 485 ADIS16400_VOLTAGE_CHAN(addr, bits, NULL, ADIS16400_SCAN_ADC, 1)
481 486
482#define ADIS16400_GYRO_CHAN(mod, addr, bits) { \ 487#define ADIS16400_GYRO_CHAN(mod, addr, bits) { \
483 .type = IIO_ANGL_VEL, \ 488 .type = IIO_ANGL_VEL, \
@@ -773,7 +778,8 @@ static struct adis16400_chip_info adis16400_chips[] = {
773 .channels = adis16448_channels, 778 .channels = adis16448_channels,
774 .num_channels = ARRAY_SIZE(adis16448_channels), 779 .num_channels = ARRAY_SIZE(adis16448_channels),
775 .flags = ADIS16400_HAS_PROD_ID | 780 .flags = ADIS16400_HAS_PROD_ID |
776 ADIS16400_HAS_SERIAL_NUMBER, 781 ADIS16400_HAS_SERIAL_NUMBER |
782 ADIS16400_BURST_DIAG_STAT,
777 .gyro_scale_micro = IIO_DEGREE_TO_RAD(10000), /* 0.01 deg/s */ 783 .gyro_scale_micro = IIO_DEGREE_TO_RAD(10000), /* 0.01 deg/s */
778 .accel_scale_micro = IIO_G_TO_M_S_2(833), /* 1/1200 g */ 784 .accel_scale_micro = IIO_G_TO_M_S_2(833), /* 1/1200 g */
779 .temp_scale_nano = 73860000, /* 0.07386 C */ 785 .temp_scale_nano = 73860000, /* 0.07386 C */
@@ -791,11 +797,6 @@ static const struct iio_info adis16400_info = {
791 .debugfs_reg_access = adis_debugfs_reg_access, 797 .debugfs_reg_access = adis_debugfs_reg_access,
792}; 798};
793 799
794static const unsigned long adis16400_burst_scan_mask[] = {
795 ~0UL,
796 0,
797};
798
799static const char * const adis16400_status_error_msgs[] = { 800static const char * const adis16400_status_error_msgs[] = {
800 [ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure", 801 [ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
801 [ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure", 802 [ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
@@ -843,6 +844,20 @@ static const struct adis_data adis16400_data = {
843 BIT(ADIS16400_DIAG_STAT_POWER_LOW), 844 BIT(ADIS16400_DIAG_STAT_POWER_LOW),
844}; 845};
845 846
847static void adis16400_setup_chan_mask(struct adis16400_state *st)
848{
849 const struct adis16400_chip_info *chip_info = st->variant;
850 unsigned i;
851
852 for (i = 0; i < chip_info->num_channels; i++) {
853 const struct iio_chan_spec *ch = &chip_info->channels[i];
854
855 if (ch->scan_index >= 0 &&
856 ch->scan_index != ADIS16400_SCAN_TIMESTAMP)
857 st->avail_scan_mask[0] |= BIT(ch->scan_index);
858 }
859}
860
846static int adis16400_probe(struct spi_device *spi) 861static int adis16400_probe(struct spi_device *spi)
847{ 862{
848 struct adis16400_state *st; 863 struct adis16400_state *st;
@@ -866,8 +881,10 @@ static int adis16400_probe(struct spi_device *spi)
866 indio_dev->info = &adis16400_info; 881 indio_dev->info = &adis16400_info;
867 indio_dev->modes = INDIO_DIRECT_MODE; 882 indio_dev->modes = INDIO_DIRECT_MODE;
868 883
869 if (!(st->variant->flags & ADIS16400_NO_BURST)) 884 if (!(st->variant->flags & ADIS16400_NO_BURST)) {
870 indio_dev->available_scan_masks = adis16400_burst_scan_mask; 885 adis16400_setup_chan_mask(st);
886 indio_dev->available_scan_masks = st->avail_scan_mask;
887 }
871 888
872 ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data); 889 ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data);
873 if (ret) 890 if (ret)