Skip to content

Commit 4301de3

Browse files
committed
Merge tag 'iio-fixes-for-4.3a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes: First set of IIO fixes for the 4.3 cycle. * twl4030 - incorrect readings for some channels due to a failure to initialize a bias regulator or configure the lines for input rather than USB use. * lis3lv02 - a missunderstanding of the way the interrupts worked on this chip lead to activation of the wrong interrupt. * sca3000 - an old bug meant that memory corruption could occur in the hardware ring buffer readout function. * mxs-lradc - wrong temp offset.
2 parents 25cb62b + b94e228 commit 4301de3

File tree

4 files changed

+40
-11
lines changed

4 files changed

+40
-11
lines changed

drivers/iio/accel/st_accel_core.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@
149149
#define ST_ACCEL_4_BDU_MASK 0x40
150150
#define ST_ACCEL_4_DRDY_IRQ_ADDR 0x21
151151
#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK 0x04
152-
#define ST_ACCEL_4_IG1_EN_ADDR 0x21
153-
#define ST_ACCEL_4_IG1_EN_MASK 0x08
154152
#define ST_ACCEL_4_MULTIREAD_BIT true
155153

156154
/* CUSTOM VALUES FOR SENSOR 5 */
@@ -489,10 +487,6 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
489487
.drdy_irq = {
490488
.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
491489
.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
492-
.ig1 = {
493-
.en_addr = ST_ACCEL_4_IG1_EN_ADDR,
494-
.en_mask = ST_ACCEL_4_IG1_EN_MASK,
495-
},
496490
},
497491
.multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT,
498492
.bootime = 2, /* guess */

drivers/iio/adc/twl4030-madc.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@
4545
#include <linux/types.h>
4646
#include <linux/gfp.h>
4747
#include <linux/err.h>
48+
#include <linux/regulator/consumer.h>
4849

4950
#include <linux/iio/iio.h>
5051

52+
#define TWL4030_USB_SEL_MADC_MCPC (1<<3)
53+
#define TWL4030_USB_CARKIT_ANA_CTRL 0xBB
54+
5155
/**
5256
* struct twl4030_madc_data - a container for madc info
5357
* @dev: Pointer to device structure for madc
5458
* @lock: Mutex protecting this data structure
59+
* @regulator: Pointer to bias regulator for madc
5560
* @requests: Array of request struct corresponding to SW1, SW2 and RT
5661
* @use_second_irq: IRQ selection (main or co-processor)
5762
* @imr: Interrupt mask register of MADC
@@ -60,6 +65,7 @@
6065
struct twl4030_madc_data {
6166
struct device *dev;
6267
struct mutex lock; /* mutex protecting this data structure */
68+
struct regulator *usb3v1;
6369
struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS];
6470
bool use_second_irq;
6571
u8 imr;
@@ -841,6 +847,32 @@ static int twl4030_madc_probe(struct platform_device *pdev)
841847
}
842848
twl4030_madc = madc;
843849

850+
/* Configure MADC[3:6] */
851+
ret = twl_i2c_read_u8(TWL_MODULE_USB, &regval,
852+
TWL4030_USB_CARKIT_ANA_CTRL);
853+
if (ret) {
854+
dev_err(&pdev->dev, "unable to read reg CARKIT_ANA_CTRL 0x%X\n",
855+
TWL4030_USB_CARKIT_ANA_CTRL);
856+
goto err_i2c;
857+
}
858+
regval |= TWL4030_USB_SEL_MADC_MCPC;
859+
ret = twl_i2c_write_u8(TWL_MODULE_USB, regval,
860+
TWL4030_USB_CARKIT_ANA_CTRL);
861+
if (ret) {
862+
dev_err(&pdev->dev, "unable to write reg CARKIT_ANA_CTRL 0x%X\n",
863+
TWL4030_USB_CARKIT_ANA_CTRL);
864+
goto err_i2c;
865+
}
866+
867+
/* Enable 3v1 bias regulator for MADC[3:6] */
868+
madc->usb3v1 = devm_regulator_get(madc->dev, "vusb3v1");
869+
if (IS_ERR(madc->usb3v1))
870+
return -ENODEV;
871+
872+
ret = regulator_enable(madc->usb3v1);
873+
if (ret)
874+
dev_err(madc->dev, "could not enable 3v1 bias regulator\n");
875+
844876
ret = iio_device_register(iio_dev);
845877
if (ret) {
846878
dev_err(&pdev->dev, "could not register iio device\n");
@@ -866,6 +898,8 @@ static int twl4030_madc_remove(struct platform_device *pdev)
866898
twl4030_madc_set_current_generator(madc, 0, 0);
867899
twl4030_madc_set_power(madc, 0);
868900

901+
regulator_disable(madc->usb3v1);
902+
869903
return 0;
870904
}
871905

drivers/staging/iio/accel/sca3000_ring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static int sca3000_read_first_n_hw_rb(struct iio_buffer *r,
116116
if (ret)
117117
goto error_ret;
118118

119-
for (i = 0; i < num_read; i++)
119+
for (i = 0; i < num_read / sizeof(u16); i++)
120120
*(((u16 *)rx) + i) = be16_to_cpup((__be16 *)rx + i);
121121

122122
if (copy_to_user(buf, rx, num_read))

drivers/staging/iio/adc/mxs-lradc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,11 +915,12 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
915915
case IIO_CHAN_INFO_OFFSET:
916916
if (chan->type == IIO_TEMP) {
917917
/* The calculated value from the ADC is in Kelvin, we
918-
* want Celsius for hwmon so the offset is
919-
* -272.15 * scale
918+
* want Celsius for hwmon so the offset is -273.15
919+
* The offset is applied before scaling so it is
920+
* actually -213.15 * 4 / 1.012 = -1079.644268
920921
*/
921-
*val = -1075;
922-
*val2 = 691699;
922+
*val = -1079;
923+
*val2 = 644268;
923924

924925
return IIO_VAL_INT_PLUS_MICRO;
925926
}

0 commit comments

Comments
 (0)