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. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJWGnjfAAoJEFSFNJnE9BaIcT4QAIeirEuh12/H59AUHUyyaPER Rf5YTsQv5sTDHbvPMaycGqDesQcJjBGeOPfq8+BBURKaRD6wwRtARoUxfH+WXDq0 y/rxKB9xTzrqBVWz812akSh3d+cJ2t0ECAjQbU2jOXZi52j8hQsPmO4XKoJngaeS 2+cgGAmCjGZ8Lx5K2VXmGZabDup07KAS+LmtylhQGOsYklA/Hj/FqKjiaOlSB0rZ uB4oS4jAvLNk/P0evwVIWZ3tNOh3BtnNo4+DHQelIEiIoZGEBnIMTTQgi0/MTYw3 Zr8o1/z2dr9Yova2wf8c+a4/Dn9DvH2SK6YAd5oxoCiImWxu/ZqeOtHZuq5m1edy 6OpM0b1GEWw7Pk6UVUdARJqsP7ZNRzN/knjCLMR6RjvHYV08Na4za5tKHJdWdN7D 8z0ep4lWslC+WyAMwrav5sLGtTuTWZmvizCUne+VcaRgKbeYTopsO0x6VHQB9TcF /dCQxMCxvDGBWn3Ha631TaeECtNXfVihlb+IK0ZfaR51J32UquqifG9WjFqlLkHR wFKBjJedWtPt7iZ8eBhh0Ddqlk+39EtCIXgaRatjrTULDhL8OcJeu/zMnUem0AnL GlBU3G4MyoQqL5bDK+LWB+dhfxbAnc/4/YTZHUJ58NIrQVlBhRDfP4wNsGHWWv0B 06De7SPs7h0YItriZUN9 =ZH04 -----END PGP SIGNATURE----- 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.
This commit is contained in:
commit
4301de3b0a
4 changed files with 40 additions and 11 deletions
|
@ -149,8 +149,6 @@
|
||||||
#define ST_ACCEL_4_BDU_MASK 0x40
|
#define ST_ACCEL_4_BDU_MASK 0x40
|
||||||
#define ST_ACCEL_4_DRDY_IRQ_ADDR 0x21
|
#define ST_ACCEL_4_DRDY_IRQ_ADDR 0x21
|
||||||
#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK 0x04
|
#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK 0x04
|
||||||
#define ST_ACCEL_4_IG1_EN_ADDR 0x21
|
|
||||||
#define ST_ACCEL_4_IG1_EN_MASK 0x08
|
|
||||||
#define ST_ACCEL_4_MULTIREAD_BIT true
|
#define ST_ACCEL_4_MULTIREAD_BIT true
|
||||||
|
|
||||||
/* CUSTOM VALUES FOR SENSOR 5 */
|
/* CUSTOM VALUES FOR SENSOR 5 */
|
||||||
|
@ -489,10 +487,6 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
|
||||||
.drdy_irq = {
|
.drdy_irq = {
|
||||||
.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
|
.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
|
||||||
.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
|
.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
|
||||||
.ig1 = {
|
|
||||||
.en_addr = ST_ACCEL_4_IG1_EN_ADDR,
|
|
||||||
.en_mask = ST_ACCEL_4_IG1_EN_MASK,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
.multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT,
|
.multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT,
|
||||||
.bootime = 2, /* guess */
|
.bootime = 2, /* guess */
|
||||||
|
|
|
@ -45,13 +45,18 @@
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/gfp.h>
|
#include <linux/gfp.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
|
#include <linux/regulator/consumer.h>
|
||||||
|
|
||||||
#include <linux/iio/iio.h>
|
#include <linux/iio/iio.h>
|
||||||
|
|
||||||
|
#define TWL4030_USB_SEL_MADC_MCPC (1<<3)
|
||||||
|
#define TWL4030_USB_CARKIT_ANA_CTRL 0xBB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct twl4030_madc_data - a container for madc info
|
* struct twl4030_madc_data - a container for madc info
|
||||||
* @dev: Pointer to device structure for madc
|
* @dev: Pointer to device structure for madc
|
||||||
* @lock: Mutex protecting this data structure
|
* @lock: Mutex protecting this data structure
|
||||||
|
* @regulator: Pointer to bias regulator for madc
|
||||||
* @requests: Array of request struct corresponding to SW1, SW2 and RT
|
* @requests: Array of request struct corresponding to SW1, SW2 and RT
|
||||||
* @use_second_irq: IRQ selection (main or co-processor)
|
* @use_second_irq: IRQ selection (main or co-processor)
|
||||||
* @imr: Interrupt mask register of MADC
|
* @imr: Interrupt mask register of MADC
|
||||||
|
@ -60,6 +65,7 @@
|
||||||
struct twl4030_madc_data {
|
struct twl4030_madc_data {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct mutex lock; /* mutex protecting this data structure */
|
struct mutex lock; /* mutex protecting this data structure */
|
||||||
|
struct regulator *usb3v1;
|
||||||
struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS];
|
struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS];
|
||||||
bool use_second_irq;
|
bool use_second_irq;
|
||||||
u8 imr;
|
u8 imr;
|
||||||
|
@ -841,6 +847,32 @@ static int twl4030_madc_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
twl4030_madc = madc;
|
twl4030_madc = madc;
|
||||||
|
|
||||||
|
/* Configure MADC[3:6] */
|
||||||
|
ret = twl_i2c_read_u8(TWL_MODULE_USB, ®val,
|
||||||
|
TWL4030_USB_CARKIT_ANA_CTRL);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(&pdev->dev, "unable to read reg CARKIT_ANA_CTRL 0x%X\n",
|
||||||
|
TWL4030_USB_CARKIT_ANA_CTRL);
|
||||||
|
goto err_i2c;
|
||||||
|
}
|
||||||
|
regval |= TWL4030_USB_SEL_MADC_MCPC;
|
||||||
|
ret = twl_i2c_write_u8(TWL_MODULE_USB, regval,
|
||||||
|
TWL4030_USB_CARKIT_ANA_CTRL);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(&pdev->dev, "unable to write reg CARKIT_ANA_CTRL 0x%X\n",
|
||||||
|
TWL4030_USB_CARKIT_ANA_CTRL);
|
||||||
|
goto err_i2c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Enable 3v1 bias regulator for MADC[3:6] */
|
||||||
|
madc->usb3v1 = devm_regulator_get(madc->dev, "vusb3v1");
|
||||||
|
if (IS_ERR(madc->usb3v1))
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
ret = regulator_enable(madc->usb3v1);
|
||||||
|
if (ret)
|
||||||
|
dev_err(madc->dev, "could not enable 3v1 bias regulator\n");
|
||||||
|
|
||||||
ret = iio_device_register(iio_dev);
|
ret = iio_device_register(iio_dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "could not register iio device\n");
|
dev_err(&pdev->dev, "could not register iio device\n");
|
||||||
|
@ -866,6 +898,8 @@ static int twl4030_madc_remove(struct platform_device *pdev)
|
||||||
twl4030_madc_set_current_generator(madc, 0, 0);
|
twl4030_madc_set_current_generator(madc, 0, 0);
|
||||||
twl4030_madc_set_power(madc, 0);
|
twl4030_madc_set_power(madc, 0);
|
||||||
|
|
||||||
|
regulator_disable(madc->usb3v1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ static int sca3000_read_first_n_hw_rb(struct iio_buffer *r,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
|
|
||||||
for (i = 0; i < num_read; i++)
|
for (i = 0; i < num_read / sizeof(u16); i++)
|
||||||
*(((u16 *)rx) + i) = be16_to_cpup((__be16 *)rx + i);
|
*(((u16 *)rx) + i) = be16_to_cpup((__be16 *)rx + i);
|
||||||
|
|
||||||
if (copy_to_user(buf, rx, num_read))
|
if (copy_to_user(buf, rx, num_read))
|
||||||
|
|
|
@ -915,11 +915,12 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
|
||||||
case IIO_CHAN_INFO_OFFSET:
|
case IIO_CHAN_INFO_OFFSET:
|
||||||
if (chan->type == IIO_TEMP) {
|
if (chan->type == IIO_TEMP) {
|
||||||
/* The calculated value from the ADC is in Kelvin, we
|
/* The calculated value from the ADC is in Kelvin, we
|
||||||
* want Celsius for hwmon so the offset is
|
* want Celsius for hwmon so the offset is -273.15
|
||||||
* -272.15 * scale
|
* The offset is applied before scaling so it is
|
||||||
|
* actually -213.15 * 4 / 1.012 = -1079.644268
|
||||||
*/
|
*/
|
||||||
*val = -1075;
|
*val = -1079;
|
||||||
*val2 = 691699;
|
*val2 = 644268;
|
||||||
|
|
||||||
return IIO_VAL_INT_PLUS_MICRO;
|
return IIO_VAL_INT_PLUS_MICRO;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue