diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-03-08 15:20:10 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-03-08 15:20:10 -0400 |
| commit | 47df986b684ec1de77e243bc5be17725afca18c4 (patch) | |
| tree | d83c1b883c523f1e2faccfab3410dc85fa23e3a4 | |
| parent | 29191c7f71aa55401c83df60482417d3c511edde (diff) | |
| parent | abe46b8932dd9a6dfc3698e3eb121809b7b9ed28 (diff) | |
Merge tag 'staging-4.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging driver fixes from Greg KH:
"Here are some IIO and staging driver fixes for 4.0-rc3.
Details are in the shortlog, nothing major, mostly IIO fixes for
reported issues.
All have been in linux-next successfully"
* tag 'staging-4.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (23 commits)
staging: comedi: adv_pci1710: fix AI INSN_READ for non-zero channel
staging: comedi: vmk80xx: remove "firmware version" kernel messages
staging: comedi: comedi_isadma: fix "stalled" detect in comedi_isadma_disable_on_sample()
iio: ak8975: fix AK09911 dependencies
iio: common: ssp_sensors: Protect PM-only functions to kill warning
IIO: si7020: Allocate correct amount of memory in devm_iio_device_alloc
Revert "iio:humidity:si7020: fix pointer to i2c client"
iio: light: gp2ap020a00f: Select REGMAP_I2C
iio: light: jsa1212: Select REGMAP_I2C
iio: ad5686: fix optional reference voltage declaration
iio:adc:mcp3422 Fix incorrect scales table
iio: mxs-lradc: fix iio channel map regression
iio: imu: adis16400: Fix sign extension
staging: iio: ad2s1200: Fix sign extension
iio: mxs-lradc: only update the buffer when its conversions have finished
iio: mxs-lradc: make ADC reads not unschedule touchscreen conversions
iio: mxs-lradc: make ADC reads not disable touchscreen interrupts
iio: mxs-lradc: separate touchscreen and buffer virtual channels
iio: imu: inv_mpu6050: Prevent dereferencing NULL
iio: iadc: wait_for_completion_timeout time in jiffies
...
| -rw-r--r-- | drivers/iio/adc/mcp3422.c | 17 | ||||
| -rw-r--r-- | drivers/iio/adc/qcom-spmi-iadc.c | 3 | ||||
| -rw-r--r-- | drivers/iio/common/ssp_sensors/ssp_dev.c | 2 | ||||
| -rw-r--r-- | drivers/iio/dac/ad5686.c | 2 | ||||
| -rw-r--r-- | drivers/iio/humidity/dht11.c | 69 | ||||
| -rw-r--r-- | drivers/iio/humidity/si7020.c | 6 | ||||
| -rw-r--r-- | drivers/iio/imu/adis16400_core.c | 3 | ||||
| -rw-r--r-- | drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 6 | ||||
| -rw-r--r-- | drivers/iio/light/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/iio/magnetometer/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/staging/comedi/drivers/adv_pci1710.c | 3 | ||||
| -rw-r--r-- | drivers/staging/comedi/drivers/comedi_isadma.c | 5 | ||||
| -rw-r--r-- | drivers/staging/comedi/drivers/vmk80xx.c | 71 | ||||
| -rw-r--r-- | drivers/staging/iio/adc/mxs-lradc.c | 207 | ||||
| -rw-r--r-- | drivers/staging/iio/resolver/ad2s1200.c | 3 |
15 files changed, 175 insertions, 226 deletions
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index 51672256072b..b96c636470ef 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c | |||
| @@ -58,20 +58,11 @@ | |||
| 58 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ | 58 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | /* LSB is in nV to eliminate floating point */ | ||
| 62 | static const u32 rates_to_lsb[] = {1000000, 250000, 62500, 15625}; | ||
| 63 | |||
| 64 | /* | ||
| 65 | * scales calculated as: | ||
| 66 | * rates_to_lsb[sample_rate] / (1 << pga); | ||
| 67 | * pga is 1 for 0, 2 | ||
| 68 | */ | ||
| 69 | |||
| 70 | static const int mcp3422_scales[4][4] = { | 61 | static const int mcp3422_scales[4][4] = { |
| 71 | { 1000000, 250000, 62500, 15625 }, | 62 | { 1000000, 500000, 250000, 125000 }, |
| 72 | { 500000 , 125000, 31250, 7812 }, | 63 | { 250000 , 125000, 62500 , 31250 }, |
| 73 | { 250000 , 62500 , 15625, 3906 }, | 64 | { 62500 , 31250 , 15625 , 7812 }, |
| 74 | { 125000 , 31250 , 7812 , 1953 } }; | 65 | { 15625 , 7812 , 3906 , 1953 } }; |
| 75 | 66 | ||
| 76 | /* Constant msleep times for data acquisitions */ | 67 | /* Constant msleep times for data acquisitions */ |
| 77 | static const int mcp3422_read_times[4] = { | 68 | static const int mcp3422_read_times[4] = { |
diff --git a/drivers/iio/adc/qcom-spmi-iadc.c b/drivers/iio/adc/qcom-spmi-iadc.c index b9666f2f5e51..fabd24edc2a1 100644 --- a/drivers/iio/adc/qcom-spmi-iadc.c +++ b/drivers/iio/adc/qcom-spmi-iadc.c | |||
| @@ -296,7 +296,8 @@ static int iadc_do_conversion(struct iadc_chip *iadc, int chan, u16 *data) | |||
| 296 | if (iadc->poll_eoc) { | 296 | if (iadc->poll_eoc) { |
| 297 | ret = iadc_poll_wait_eoc(iadc, wait); | 297 | ret = iadc_poll_wait_eoc(iadc, wait); |
| 298 | } else { | 298 | } else { |
| 299 | ret = wait_for_completion_timeout(&iadc->complete, wait); | 299 | ret = wait_for_completion_timeout(&iadc->complete, |
| 300 | usecs_to_jiffies(wait)); | ||
| 300 | if (!ret) | 301 | if (!ret) |
| 301 | ret = -ETIMEDOUT; | 302 | ret = -ETIMEDOUT; |
| 302 | else | 303 | else |
diff --git a/drivers/iio/common/ssp_sensors/ssp_dev.c b/drivers/iio/common/ssp_sensors/ssp_dev.c index 52d70435f5a1..55a90082a29b 100644 --- a/drivers/iio/common/ssp_sensors/ssp_dev.c +++ b/drivers/iio/common/ssp_sensors/ssp_dev.c | |||
| @@ -640,6 +640,7 @@ static int ssp_remove(struct spi_device *spi) | |||
| 640 | return 0; | 640 | return 0; |
| 641 | } | 641 | } |
| 642 | 642 | ||
| 643 | #ifdef CONFIG_PM_SLEEP | ||
| 643 | static int ssp_suspend(struct device *dev) | 644 | static int ssp_suspend(struct device *dev) |
| 644 | { | 645 | { |
| 645 | int ret; | 646 | int ret; |
| @@ -688,6 +689,7 @@ static int ssp_resume(struct device *dev) | |||
| 688 | 689 | ||
| 689 | return 0; | 690 | return 0; |
| 690 | } | 691 | } |
| 692 | #endif /* CONFIG_PM_SLEEP */ | ||
| 691 | 693 | ||
| 692 | static const struct dev_pm_ops ssp_pm_ops = { | 694 | static const struct dev_pm_ops ssp_pm_ops = { |
| 693 | SET_SYSTEM_SLEEP_PM_OPS(ssp_suspend, ssp_resume) | 695 | SET_SYSTEM_SLEEP_PM_OPS(ssp_suspend, ssp_resume) |
diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index f57562aa396f..15c73e20272d 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c | |||
| @@ -322,7 +322,7 @@ static int ad5686_probe(struct spi_device *spi) | |||
| 322 | st = iio_priv(indio_dev); | 322 | st = iio_priv(indio_dev); |
| 323 | spi_set_drvdata(spi, indio_dev); | 323 | spi_set_drvdata(spi, indio_dev); |
| 324 | 324 | ||
| 325 | st->reg = devm_regulator_get(&spi->dev, "vcc"); | 325 | st->reg = devm_regulator_get_optional(&spi->dev, "vcc"); |
| 326 | if (!IS_ERR(st->reg)) { | 326 | if (!IS_ERR(st->reg)) { |
| 327 | ret = regulator_enable(st->reg); | 327 | ret = regulator_enable(st->reg); |
| 328 | if (ret) | 328 | if (ret) |
diff --git a/drivers/iio/humidity/dht11.c b/drivers/iio/humidity/dht11.c index 623c145d8a97..7d79a1ac5f5f 100644 --- a/drivers/iio/humidity/dht11.c +++ b/drivers/iio/humidity/dht11.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include <linux/wait.h> | 29 | #include <linux/wait.h> |
| 30 | #include <linux/bitops.h> | 30 | #include <linux/bitops.h> |
| 31 | #include <linux/completion.h> | 31 | #include <linux/completion.h> |
| 32 | #include <linux/mutex.h> | ||
| 32 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
| 33 | #include <linux/gpio.h> | 34 | #include <linux/gpio.h> |
| 34 | #include <linux/of_gpio.h> | 35 | #include <linux/of_gpio.h> |
| @@ -39,8 +40,12 @@ | |||
| 39 | 40 | ||
| 40 | #define DHT11_DATA_VALID_TIME 2000000000 /* 2s in ns */ | 41 | #define DHT11_DATA_VALID_TIME 2000000000 /* 2s in ns */ |
| 41 | 42 | ||
| 42 | #define DHT11_EDGES_PREAMBLE 4 | 43 | #define DHT11_EDGES_PREAMBLE 2 |
| 43 | #define DHT11_BITS_PER_READ 40 | 44 | #define DHT11_BITS_PER_READ 40 |
| 45 | /* | ||
| 46 | * Note that when reading the sensor actually 84 edges are detected, but | ||
| 47 | * since the last edge is not significant, we only store 83: | ||
| 48 | */ | ||
| 44 | #define DHT11_EDGES_PER_READ (2*DHT11_BITS_PER_READ + DHT11_EDGES_PREAMBLE + 1) | 49 | #define DHT11_EDGES_PER_READ (2*DHT11_BITS_PER_READ + DHT11_EDGES_PREAMBLE + 1) |
| 45 | 50 | ||
| 46 | /* Data transmission timing (nano seconds) */ | 51 | /* Data transmission timing (nano seconds) */ |
| @@ -57,6 +62,7 @@ struct dht11 { | |||
| 57 | int irq; | 62 | int irq; |
| 58 | 63 | ||
| 59 | struct completion completion; | 64 | struct completion completion; |
| 65 | struct mutex lock; | ||
| 60 | 66 | ||
| 61 | s64 timestamp; | 67 | s64 timestamp; |
| 62 | int temperature; | 68 | int temperature; |
| @@ -88,7 +94,7 @@ static int dht11_decode(struct dht11 *dht11, int offset) | |||
| 88 | unsigned char temp_int, temp_dec, hum_int, hum_dec, checksum; | 94 | unsigned char temp_int, temp_dec, hum_int, hum_dec, checksum; |
| 89 | 95 | ||
| 90 | /* Calculate timestamp resolution */ | 96 | /* Calculate timestamp resolution */ |
| 91 | for (i = 0; i < dht11->num_edges; ++i) { | 97 | for (i = 1; i < dht11->num_edges; ++i) { |
| 92 | t = dht11->edges[i].ts - dht11->edges[i-1].ts; | 98 | t = dht11->edges[i].ts - dht11->edges[i-1].ts; |
| 93 | if (t > 0 && t < timeres) | 99 | if (t > 0 && t < timeres) |
| 94 | timeres = t; | 100 | timeres = t; |
| @@ -138,6 +144,27 @@ static int dht11_decode(struct dht11 *dht11, int offset) | |||
| 138 | return 0; | 144 | return 0; |
| 139 | } | 145 | } |
| 140 | 146 | ||
| 147 | /* | ||
| 148 | * IRQ handler called on GPIO edges | ||
| 149 | */ | ||
| 150 | static irqreturn_t dht11_handle_irq(int irq, void *data) | ||
| 151 | { | ||
| 152 | struct iio_dev *iio = data; | ||
| 153 | struct dht11 *dht11 = iio_priv(iio); | ||
| 154 | |||
| 155 | /* TODO: Consider making the handler safe for IRQ sharing */ | ||
| 156 | if (dht11->num_edges < DHT11_EDGES_PER_READ && dht11->num_edges >= 0) { | ||
| 157 | dht11->edges[dht11->num_edges].ts = iio_get_time_ns(); | ||
| 158 | dht11->edges[dht11->num_edges++].value = | ||
| 159 | gpio_get_value(dht11->gpio); | ||
| 160 | |||
| 161 | if (dht11->num_edges >= DHT11_EDGES_PER_READ) | ||
| 162 | complete(&dht11->completion); | ||
| 163 | } | ||
| 164 | |||
| 165 | return IRQ_HANDLED; | ||
| 166 | } | ||
| 167 | |||
| 141 | static int dht11_read_raw(struct iio_dev *iio_dev, | 168 | static int dht11_read_raw(struct iio_dev *iio_dev, |
| 142 | const struct iio_chan_spec *chan, | 169 | const struct iio_chan_spec *chan, |
| 143 | int *val, int *val2, long m) | 170 | int *val, int *val2, long m) |
| @@ -145,6 +172,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev, | |||
| 145 | struct dht11 *dht11 = iio_priv(iio_dev); | 172 | struct dht11 *dht11 = iio_priv(iio_dev); |
| 146 | int ret; | 173 | int ret; |
| 147 | 174 | ||
| 175 | mutex_lock(&dht11->lock); | ||
| 148 | if (dht11->timestamp + DHT11_DATA_VALID_TIME < iio_get_time_ns()) { | 176 | if (dht11->timestamp + DHT11_DATA_VALID_TIME < iio_get_time_ns()) { |
| 149 | reinit_completion(&dht11->completion); | 177 | reinit_completion(&dht11->completion); |
| 150 | 178 | ||
| @@ -157,8 +185,17 @@ static int dht11_read_raw(struct iio_dev *iio_dev, | |||
| 157 | if (ret) | 185 | if (ret) |
| 158 | goto err; | 186 | goto err; |
| 159 | 187 | ||
| 188 | ret = request_irq(dht11->irq, dht11_handle_irq, | ||
| 189 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
| 190 | iio_dev->name, iio_dev); | ||
| 191 | if (ret) | ||
| 192 | goto err; | ||
| 193 | |||
| 160 | ret = wait_for_completion_killable_timeout(&dht11->completion, | 194 | ret = wait_for_completion_killable_timeout(&dht11->completion, |
| 161 | HZ); | 195 | HZ); |
| 196 | |||
| 197 | free_irq(dht11->irq, iio_dev); | ||
| 198 | |||
| 162 | if (ret == 0 && dht11->num_edges < DHT11_EDGES_PER_READ - 1) { | 199 | if (ret == 0 && dht11->num_edges < DHT11_EDGES_PER_READ - 1) { |
| 163 | dev_err(&iio_dev->dev, | 200 | dev_err(&iio_dev->dev, |
| 164 | "Only %d signal edges detected\n", | 201 | "Only %d signal edges detected\n", |
| @@ -185,6 +222,7 @@ static int dht11_read_raw(struct iio_dev *iio_dev, | |||
| 185 | ret = -EINVAL; | 222 | ret = -EINVAL; |
| 186 | err: | 223 | err: |
| 187 | dht11->num_edges = -1; | 224 | dht11->num_edges = -1; |
| 225 | mutex_unlock(&dht11->lock); | ||
| 188 | return ret; | 226 | return ret; |
| 189 | } | 227 | } |
| 190 | 228 | ||
| @@ -193,27 +231,6 @@ static const struct iio_info dht11_iio_info = { | |||
| 193 | .read_raw = dht11_read_raw, | 231 | .read_raw = dht11_read_raw, |
| 194 | }; | 232 | }; |
| 195 | 233 | ||
| 196 | /* | ||
| 197 | * IRQ handler called on GPIO edges | ||
| 198 | */ | ||
| 199 | static irqreturn_t dht11_handle_irq(int irq, void *data) | ||
| 200 | { | ||
| 201 | struct iio_dev *iio = data; | ||
| 202 | struct dht11 *dht11 = iio_priv(iio); | ||
| 203 | |||
| 204 | /* TODO: Consider making the handler safe for IRQ sharing */ | ||
| 205 | if (dht11->num_edges < DHT11_EDGES_PER_READ && dht11->num_edges >= 0) { | ||
| 206 | dht11->edges[dht11->num_edges].ts = iio_get_time_ns(); | ||
| 207 | dht11->edges[dht11->num_edges++].value = | ||
| 208 | gpio_get_value(dht11->gpio); | ||
| 209 | |||
| 210 | if (dht11->num_edges >= DHT11_EDGES_PER_READ) | ||
| 211 | complete(&dht11->completion); | ||
| 212 | } | ||
| 213 | |||
| 214 | return IRQ_HANDLED; | ||
| 215 | } | ||
| 216 | |||
| 217 | static const struct iio_chan_spec dht11_chan_spec[] = { | 234 | static const struct iio_chan_spec dht11_chan_spec[] = { |
| 218 | { .type = IIO_TEMP, | 235 | { .type = IIO_TEMP, |
| 219 | .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), }, | 236 | .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), }, |
| @@ -256,11 +273,6 @@ static int dht11_probe(struct platform_device *pdev) | |||
| 256 | dev_err(dev, "GPIO %d has no interrupt\n", dht11->gpio); | 273 | dev_err(dev, "GPIO %d has no interrupt\n", dht11->gpio); |
| 257 | return -EINVAL; | 274 | return -EINVAL; |
| 258 | } | 275 | } |
| 259 | ret = devm_request_irq(dev, dht11->irq, dht11_handle_irq, | ||
| 260 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
| 261 | pdev->name, iio); | ||
| 262 | if (ret) | ||
| 263 | return ret; | ||
| 264 | 276 | ||
| 265 | dht11->timestamp = iio_get_time_ns() - DHT11_DATA_VALID_TIME - 1; | 277 | dht11->timestamp = iio_get_time_ns() - DHT11_DATA_VALID_TIME - 1; |
| 266 | dht11->num_edges = -1; | 278 | dht11->num_edges = -1; |
| @@ -268,6 +280,7 @@ static int dht11_probe(struct platform_device *pdev) | |||
| 268 | platform_set_drvdata(pdev, iio); | 280 | platform_set_drvdata(pdev, iio); |
| 269 | 281 | ||
| 270 | init_completion(&dht11->completion); | 282 | init_completion(&dht11->completion); |
| 283 | mutex_init(&dht11->lock); | ||
| 271 | iio->name = pdev->name; | 284 | iio->name = pdev->name; |
| 272 | iio->dev.parent = &pdev->dev; | 285 | iio->dev.parent = &pdev->dev; |
| 273 | iio->info = &dht11_iio_info; | 286 | iio->info = &dht11_iio_info; |
diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c index b54164677b89..fa3b809aff5e 100644 --- a/drivers/iio/humidity/si7020.c +++ b/drivers/iio/humidity/si7020.c | |||
| @@ -45,12 +45,12 @@ static int si7020_read_raw(struct iio_dev *indio_dev, | |||
| 45 | struct iio_chan_spec const *chan, int *val, | 45 | struct iio_chan_spec const *chan, int *val, |
| 46 | int *val2, long mask) | 46 | int *val2, long mask) |
| 47 | { | 47 | { |
| 48 | struct i2c_client *client = iio_priv(indio_dev); | 48 | struct i2c_client **client = iio_priv(indio_dev); |
| 49 | int ret; | 49 | int ret; |
| 50 | 50 | ||
| 51 | switch (mask) { | 51 | switch (mask) { |
| 52 | case IIO_CHAN_INFO_RAW: | 52 | case IIO_CHAN_INFO_RAW: |
| 53 | ret = i2c_smbus_read_word_data(client, | 53 | ret = i2c_smbus_read_word_data(*client, |
| 54 | chan->type == IIO_TEMP ? | 54 | chan->type == IIO_TEMP ? |
| 55 | SI7020CMD_TEMP_HOLD : | 55 | SI7020CMD_TEMP_HOLD : |
| 56 | SI7020CMD_RH_HOLD); | 56 | SI7020CMD_RH_HOLD); |
| @@ -126,7 +126,7 @@ static int si7020_probe(struct i2c_client *client, | |||
| 126 | /* Wait the maximum power-up time after software reset. */ | 126 | /* Wait the maximum power-up time after software reset. */ |
| 127 | msleep(15); | 127 | msleep(15); |
| 128 | 128 | ||
| 129 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*client)); | 129 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); |
| 130 | if (!indio_dev) | 130 | if (!indio_dev) |
| 131 | return -ENOMEM; | 131 | return -ENOMEM; |
| 132 | 132 | ||
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index b70873de04ea..fa795dcd5f75 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/list.h> | 26 | #include <linux/list.h> |
| 27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
| 28 | #include <linux/debugfs.h> | 28 | #include <linux/debugfs.h> |
| 29 | #include <linux/bitops.h> | ||
| 29 | 30 | ||
| 30 | #include <linux/iio/iio.h> | 31 | #include <linux/iio/iio.h> |
| 31 | #include <linux/iio/sysfs.h> | 32 | #include <linux/iio/sysfs.h> |
| @@ -414,7 +415,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, | |||
| 414 | mutex_unlock(&indio_dev->mlock); | 415 | mutex_unlock(&indio_dev->mlock); |
| 415 | if (ret) | 416 | if (ret) |
| 416 | return ret; | 417 | return ret; |
| 417 | val16 = ((val16 & 0xFFF) << 4) >> 4; | 418 | val16 = sign_extend32(val16, 11); |
| 418 | *val = val16; | 419 | *val = val16; |
| 419 | return IIO_VAL_INT; | 420 | return IIO_VAL_INT; |
| 420 | case IIO_CHAN_INFO_OFFSET: | 421 | case IIO_CHAN_INFO_OFFSET: |
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index f73e60b7a796..d8d5bed65e07 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | |||
| @@ -780,7 +780,11 @@ static int inv_mpu_probe(struct i2c_client *client, | |||
| 780 | 780 | ||
| 781 | i2c_set_clientdata(client, indio_dev); | 781 | i2c_set_clientdata(client, indio_dev); |
| 782 | indio_dev->dev.parent = &client->dev; | 782 | indio_dev->dev.parent = &client->dev; |
| 783 | indio_dev->name = id->name; | 783 | /* id will be NULL when enumerated via ACPI */ |
| 784 | if (id) | ||
| 785 | indio_dev->name = (char *)id->name; | ||
| 786 | else | ||
| 787 | indio_dev->name = (char *)dev_name(&client->dev); | ||
| 784 | indio_dev->channels = inv_mpu_channels; | 788 | indio_dev->channels = inv_mpu_channels; |
| 785 | indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels); | 789 | indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels); |
| 786 | 790 | ||
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index ae68c64bdad3..a224afd6380c 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig | |||
| @@ -73,6 +73,7 @@ config CM36651 | |||
| 73 | config GP2AP020A00F | 73 | config GP2AP020A00F |
| 74 | tristate "Sharp GP2AP020A00F Proximity/ALS sensor" | 74 | tristate "Sharp GP2AP020A00F Proximity/ALS sensor" |
| 75 | depends on I2C | 75 | depends on I2C |
| 76 | select REGMAP_I2C | ||
| 76 | select IIO_BUFFER | 77 | select IIO_BUFFER |
| 77 | select IIO_TRIGGERED_BUFFER | 78 | select IIO_TRIGGERED_BUFFER |
| 78 | select IRQ_WORK | 79 | select IRQ_WORK |
| @@ -126,6 +127,7 @@ config HID_SENSOR_PROX | |||
| 126 | config JSA1212 | 127 | config JSA1212 |
| 127 | tristate "JSA1212 ALS and proximity sensor driver" | 128 | tristate "JSA1212 ALS and proximity sensor driver" |
| 128 | depends on I2C | 129 | depends on I2C |
| 130 | select REGMAP_I2C | ||
| 129 | help | 131 | help |
| 130 | Say Y here if you want to build a IIO driver for JSA1212 | 132 | Say Y here if you want to build a IIO driver for JSA1212 |
| 131 | proximity & ALS sensor device. | 133 | proximity & ALS sensor device. |
diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index 4c7a4c52dd06..a5d6de72c523 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig | |||
| @@ -18,6 +18,8 @@ config AK8975 | |||
| 18 | 18 | ||
| 19 | config AK09911 | 19 | config AK09911 |
| 20 | tristate "Asahi Kasei AK09911 3-axis Compass" | 20 | tristate "Asahi Kasei AK09911 3-axis Compass" |
| 21 | depends on I2C | ||
| 22 | depends on GPIOLIB | ||
| 21 | select AK8975 | 23 | select AK8975 |
| 22 | help | 24 | help |
| 23 | Deprecated: AK09911 is now supported by AK8975 driver. | 25 | Deprecated: AK09911 is now supported by AK8975 driver. |
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 9800c01e6fb9..3f72451d2de0 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c | |||
| @@ -426,7 +426,6 @@ static int pci171x_ai_insn_read(struct comedi_device *dev, | |||
| 426 | unsigned int *data) | 426 | unsigned int *data) |
| 427 | { | 427 | { |
| 428 | struct pci1710_private *devpriv = dev->private; | 428 | struct pci1710_private *devpriv = dev->private; |
| 429 | unsigned int chan = CR_CHAN(insn->chanspec); | ||
| 430 | int ret = 0; | 429 | int ret = 0; |
| 431 | int i; | 430 | int i; |
| 432 | 431 | ||
| @@ -447,7 +446,7 @@ static int pci171x_ai_insn_read(struct comedi_device *dev, | |||
| 447 | if (ret) | 446 | if (ret) |
| 448 | break; | 447 | break; |
| 449 | 448 | ||
| 450 | ret = pci171x_ai_read_sample(dev, s, chan, &val); | 449 | ret = pci171x_ai_read_sample(dev, s, 0, &val); |
| 451 | if (ret) | 450 | if (ret) |
| 452 | break; | 451 | break; |
| 453 | 452 | ||
diff --git a/drivers/staging/comedi/drivers/comedi_isadma.c b/drivers/staging/comedi/drivers/comedi_isadma.c index dbdea71d6b95..e856f01ca077 100644 --- a/drivers/staging/comedi/drivers/comedi_isadma.c +++ b/drivers/staging/comedi/drivers/comedi_isadma.c | |||
| @@ -91,9 +91,10 @@ unsigned int comedi_isadma_disable_on_sample(unsigned int dma_chan, | |||
| 91 | stalled++; | 91 | stalled++; |
| 92 | if (stalled > 10) | 92 | if (stalled > 10) |
| 93 | break; | 93 | break; |
| 94 | } else { | ||
| 95 | residue = new_residue; | ||
| 96 | stalled = 0; | ||
| 94 | } | 97 | } |
| 95 | residue = new_residue; | ||
| 96 | stalled = 0; | ||
| 97 | } | 98 | } |
| 98 | return residue; | 99 | return residue; |
| 99 | } | 100 | } |
diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c index e37118321a27..a0906685e27f 100644 --- a/drivers/staging/comedi/drivers/vmk80xx.c +++ b/drivers/staging/comedi/drivers/vmk80xx.c | |||
| @@ -103,11 +103,6 @@ enum vmk80xx_model { | |||
| 103 | VMK8061_MODEL | 103 | VMK8061_MODEL |
| 104 | }; | 104 | }; |
| 105 | 105 | ||
| 106 | struct firmware_version { | ||
| 107 | unsigned char ic3_vers[32]; /* USB-Controller */ | ||
| 108 | unsigned char ic6_vers[32]; /* CPU */ | ||
| 109 | }; | ||
| 110 | |||
| 111 | static const struct comedi_lrange vmk8061_range = { | 106 | static const struct comedi_lrange vmk8061_range = { |
| 112 | 2, { | 107 | 2, { |
| 113 | UNI_RANGE(5), | 108 | UNI_RANGE(5), |
| @@ -156,68 +151,12 @@ static const struct vmk80xx_board vmk80xx_boardinfo[] = { | |||
| 156 | struct vmk80xx_private { | 151 | struct vmk80xx_private { |
| 157 | struct usb_endpoint_descriptor *ep_rx; | 152 | struct usb_endpoint_descriptor *ep_rx; |
| 158 | struct usb_endpoint_descriptor *ep_tx; | 153 | struct usb_endpoint_descriptor *ep_tx; |
| 159 | struct firmware_version fw; | ||
| 160 | struct semaphore limit_sem; | 154 | struct semaphore limit_sem; |
| 161 | unsigned char *usb_rx_buf; | 155 | unsigned char *usb_rx_buf; |
| 162 | unsigned char *usb_tx_buf; | 156 | unsigned char *usb_tx_buf; |
| 163 | enum vmk80xx_model model; | 157 | enum vmk80xx_model model; |
| 164 | }; | 158 | }; |
| 165 | 159 | ||
| 166 | static int vmk80xx_check_data_link(struct comedi_device *dev) | ||
| 167 | { | ||
| 168 | struct vmk80xx_private *devpriv = dev->private; | ||
| 169 | struct usb_device *usb = comedi_to_usb_dev(dev); | ||
| 170 | unsigned int tx_pipe; | ||
| 171 | unsigned int rx_pipe; | ||
| 172 | unsigned char tx[1]; | ||
| 173 | unsigned char rx[2]; | ||
| 174 | |||
| 175 | tx_pipe = usb_sndbulkpipe(usb, 0x01); | ||
| 176 | rx_pipe = usb_rcvbulkpipe(usb, 0x81); | ||
| 177 | |||
| 178 | tx[0] = VMK8061_CMD_RD_PWR_STAT; | ||
| 179 | |||
| 180 | /* | ||
| 181 | * Check that IC6 (PIC16F871) is powered and | ||
| 182 | * running and the data link between IC3 and | ||
| 183 | * IC6 is working properly | ||
| 184 | */ | ||
| 185 | usb_bulk_msg(usb, tx_pipe, tx, 1, NULL, devpriv->ep_tx->bInterval); | ||
| 186 | usb_bulk_msg(usb, rx_pipe, rx, 2, NULL, HZ * 10); | ||
| 187 | |||
| 188 | return (int)rx[1]; | ||
| 189 | } | ||
| 190 | |||
| 191 | static void vmk80xx_read_eeprom(struct comedi_device *dev, int flag) | ||
| 192 | { | ||
| 193 | struct vmk80xx_private *devpriv = dev->private; | ||
| 194 | struct usb_device *usb = comedi_to_usb_dev(dev); | ||
| 195 | unsigned int tx_pipe; | ||
| 196 | unsigned int rx_pipe; | ||
| 197 | unsigned char tx[1]; | ||
| 198 | unsigned char rx[64]; | ||
| 199 | int cnt; | ||
| 200 | |||
| 201 | tx_pipe = usb_sndbulkpipe(usb, 0x01); | ||
| 202 | rx_pipe = usb_rcvbulkpipe(usb, 0x81); | ||
| 203 | |||
| 204 | tx[0] = VMK8061_CMD_RD_VERSION; | ||
| 205 | |||
| 206 | /* | ||
| 207 | * Read the firmware version info of IC3 and | ||
| 208 | * IC6 from the internal EEPROM of the IC | ||
| 209 | */ | ||
| 210 | usb_bulk_msg(usb, tx_pipe, tx, 1, NULL, devpriv->ep_tx->bInterval); | ||
| 211 | usb_bulk_msg(usb, rx_pipe, rx, 64, &cnt, HZ * 10); | ||
| 212 | |||
| 213 | rx[cnt] = '\0'; | ||
| 214 | |||
| 215 | if (flag & IC3_VERSION) | ||
| 216 | strncpy(devpriv->fw.ic3_vers, rx + 1, 24); | ||
| 217 | else /* IC6_VERSION */ | ||
| 218 | strncpy(devpriv->fw.ic6_vers, rx + 25, 24); | ||
| 219 | } | ||
| 220 | |||
| 221 | static void vmk80xx_do_bulk_msg(struct comedi_device *dev) | 160 | static void vmk80xx_do_bulk_msg(struct comedi_device *dev) |
| 222 | { | 161 | { |
| 223 | struct vmk80xx_private *devpriv = dev->private; | 162 | struct vmk80xx_private *devpriv = dev->private; |
| @@ -878,16 +817,6 @@ static int vmk80xx_auto_attach(struct comedi_device *dev, | |||
| 878 | 817 | ||
| 879 | usb_set_intfdata(intf, devpriv); | 818 | usb_set_intfdata(intf, devpriv); |
| 880 | 819 | ||
| 881 | if (devpriv->model == VMK8061_MODEL) { | ||
| 882 | vmk80xx_read_eeprom(dev, IC3_VERSION); | ||
| 883 | dev_info(&intf->dev, "%s\n", devpriv->fw.ic3_vers); | ||
| 884 | |||
| 885 | if (vmk80xx_check_data_link(dev)) { | ||
| 886 | vmk80xx_read_eeprom(dev, IC6_VERSION); | ||
| 887 | dev_info(&intf->dev, "%s\n", devpriv->fw.ic6_vers); | ||
| 888 | } | ||
| 889 | } | ||
| 890 | |||
| 891 | if (devpriv->model == VMK8055_MODEL) | 820 | if (devpriv->model == VMK8055_MODEL) |
| 892 | vmk80xx_reset_device(dev); | 821 | vmk80xx_reset_device(dev); |
| 893 | 822 | ||
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index d9d6fad7cb00..816174388f13 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c | |||
| @@ -214,11 +214,17 @@ struct mxs_lradc { | |||
| 214 | unsigned long is_divided; | 214 | unsigned long is_divided; |
| 215 | 215 | ||
| 216 | /* | 216 | /* |
| 217 | * Touchscreen LRADC channels receives a private slot in the CTRL4 | 217 | * When the touchscreen is enabled, we give it two private virtual |
| 218 | * register, the slot #7. Therefore only 7 slots instead of 8 in the | 218 | * channels: #6 and #7. This means that only 6 virtual channels (instead |
| 219 | * CTRL4 register can be mapped to LRADC channels when using the | 219 | * of 8) will be available for buffered capture. |
| 220 | * touchscreen. | 220 | */ |
| 221 | * | 221 | #define TOUCHSCREEN_VCHANNEL1 7 |
| 222 | #define TOUCHSCREEN_VCHANNEL2 6 | ||
| 223 | #define BUFFER_VCHANS_LIMITED 0x3f | ||
| 224 | #define BUFFER_VCHANS_ALL 0xff | ||
| 225 | u8 buffer_vchans; | ||
| 226 | |||
| 227 | /* | ||
| 222 | * Furthermore, certain LRADC channels are shared between touchscreen | 228 | * Furthermore, certain LRADC channels are shared between touchscreen |
| 223 | * and/or touch-buttons and generic LRADC block. Therefore when using | 229 | * and/or touch-buttons and generic LRADC block. Therefore when using |
| 224 | * either of these, these channels are not available for the regular | 230 | * either of these, these channels are not available for the regular |
| @@ -342,6 +348,9 @@ struct mxs_lradc { | |||
| 342 | #define LRADC_CTRL4 0x140 | 348 | #define LRADC_CTRL4 0x140 |
| 343 | #define LRADC_CTRL4_LRADCSELECT_MASK(n) (0xf << ((n) * 4)) | 349 | #define LRADC_CTRL4_LRADCSELECT_MASK(n) (0xf << ((n) * 4)) |
| 344 | #define LRADC_CTRL4_LRADCSELECT_OFFSET(n) ((n) * 4) | 350 | #define LRADC_CTRL4_LRADCSELECT_OFFSET(n) ((n) * 4) |
| 351 | #define LRADC_CTRL4_LRADCSELECT(n, x) \ | ||
| 352 | (((x) << LRADC_CTRL4_LRADCSELECT_OFFSET(n)) & \ | ||
| 353 | LRADC_CTRL4_LRADCSELECT_MASK(n)) | ||
| 345 | 354 | ||
| 346 | #define LRADC_RESOLUTION 12 | 355 | #define LRADC_RESOLUTION 12 |
| 347 | #define LRADC_SINGLE_SAMPLE_MASK ((1 << LRADC_RESOLUTION) - 1) | 356 | #define LRADC_SINGLE_SAMPLE_MASK ((1 << LRADC_RESOLUTION) - 1) |
| @@ -416,6 +425,14 @@ static bool mxs_lradc_check_touch_event(struct mxs_lradc *lradc) | |||
| 416 | LRADC_STATUS_TOUCH_DETECT_RAW); | 425 | LRADC_STATUS_TOUCH_DETECT_RAW); |
| 417 | } | 426 | } |
| 418 | 427 | ||
| 428 | static void mxs_lradc_map_channel(struct mxs_lradc *lradc, unsigned vch, | ||
| 429 | unsigned ch) | ||
| 430 | { | ||
| 431 | mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(vch), | ||
| 432 | LRADC_CTRL4); | ||
| 433 | mxs_lradc_reg_set(lradc, LRADC_CTRL4_LRADCSELECT(vch, ch), LRADC_CTRL4); | ||
| 434 | } | ||
| 435 | |||
| 419 | static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch) | 436 | static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch) |
| 420 | { | 437 | { |
| 421 | /* | 438 | /* |
| @@ -450,12 +467,8 @@ static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch) | |||
| 450 | LRADC_DELAY_DELAY(lradc->over_sample_delay - 1), | 467 | LRADC_DELAY_DELAY(lradc->over_sample_delay - 1), |
| 451 | LRADC_DELAY(3)); | 468 | LRADC_DELAY(3)); |
| 452 | 469 | ||
| 453 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ(2) | | 470 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ(ch), LRADC_CTRL1); |
| 454 | LRADC_CTRL1_LRADC_IRQ(3) | LRADC_CTRL1_LRADC_IRQ(4) | | ||
| 455 | LRADC_CTRL1_LRADC_IRQ(5), LRADC_CTRL1); | ||
| 456 | 471 | ||
| 457 | /* wake us again, when the complete conversion is done */ | ||
| 458 | mxs_lradc_reg_set(lradc, LRADC_CTRL1_LRADC_IRQ_EN(ch), LRADC_CTRL1); | ||
| 459 | /* | 472 | /* |
| 460 | * after changing the touchscreen plates setting | 473 | * after changing the touchscreen plates setting |
| 461 | * the signals need some initial time to settle. Start the | 474 | * the signals need some initial time to settle. Start the |
| @@ -509,12 +522,8 @@ static void mxs_lradc_setup_ts_pressure(struct mxs_lradc *lradc, unsigned ch1, | |||
| 509 | LRADC_DELAY_DELAY(lradc->over_sample_delay - 1), | 522 | LRADC_DELAY_DELAY(lradc->over_sample_delay - 1), |
| 510 | LRADC_DELAY(3)); | 523 | LRADC_DELAY(3)); |
| 511 | 524 | ||
| 512 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ(2) | | 525 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ(ch2), LRADC_CTRL1); |
| 513 | LRADC_CTRL1_LRADC_IRQ(3) | LRADC_CTRL1_LRADC_IRQ(4) | | ||
| 514 | LRADC_CTRL1_LRADC_IRQ(5), LRADC_CTRL1); | ||
| 515 | 526 | ||
| 516 | /* wake us again, when the conversions are done */ | ||
| 517 | mxs_lradc_reg_set(lradc, LRADC_CTRL1_LRADC_IRQ_EN(ch2), LRADC_CTRL1); | ||
| 518 | /* | 527 | /* |
| 519 | * after changing the touchscreen plates setting | 528 | * after changing the touchscreen plates setting |
| 520 | * the signals need some initial time to settle. Start the | 529 | * the signals need some initial time to settle. Start the |
| @@ -580,36 +589,6 @@ static unsigned mxs_lradc_read_ts_pressure(struct mxs_lradc *lradc, | |||
| 580 | #define TS_CH_XM 4 | 589 | #define TS_CH_XM 4 |
| 581 | #define TS_CH_YM 5 | 590 | #define TS_CH_YM 5 |
| 582 | 591 | ||
| 583 | static int mxs_lradc_read_ts_channel(struct mxs_lradc *lradc) | ||
| 584 | { | ||
| 585 | u32 reg; | ||
| 586 | int val; | ||
| 587 | |||
| 588 | reg = readl(lradc->base + LRADC_CTRL1); | ||
| 589 | |||
| 590 | /* only channels 3 to 5 are of interest here */ | ||
| 591 | if (reg & LRADC_CTRL1_LRADC_IRQ(TS_CH_YP)) { | ||
| 592 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ_EN(TS_CH_YP) | | ||
| 593 | LRADC_CTRL1_LRADC_IRQ(TS_CH_YP), LRADC_CTRL1); | ||
| 594 | val = mxs_lradc_read_raw_channel(lradc, TS_CH_YP); | ||
| 595 | } else if (reg & LRADC_CTRL1_LRADC_IRQ(TS_CH_XM)) { | ||
| 596 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ_EN(TS_CH_XM) | | ||
| 597 | LRADC_CTRL1_LRADC_IRQ(TS_CH_XM), LRADC_CTRL1); | ||
| 598 | val = mxs_lradc_read_raw_channel(lradc, TS_CH_XM); | ||
| 599 | } else if (reg & LRADC_CTRL1_LRADC_IRQ(TS_CH_YM)) { | ||
| 600 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ_EN(TS_CH_YM) | | ||
| 601 | LRADC_CTRL1_LRADC_IRQ(TS_CH_YM), LRADC_CTRL1); | ||
| 602 | val = mxs_lradc_read_raw_channel(lradc, TS_CH_YM); | ||
| 603 | } else { | ||
| 604 | return -EIO; | ||
| 605 | } | ||
| 606 | |||
| 607 | mxs_lradc_reg_wrt(lradc, 0, LRADC_DELAY(2)); | ||
| 608 | mxs_lradc_reg_wrt(lradc, 0, LRADC_DELAY(3)); | ||
| 609 | |||
| 610 | return val; | ||
| 611 | } | ||
| 612 | |||
| 613 | /* | 592 | /* |
| 614 | * YP(open)--+-------------+ | 593 | * YP(open)--+-------------+ |
| 615 | * | |--+ | 594 | * | |--+ |
| @@ -653,7 +632,8 @@ static void mxs_lradc_prepare_x_pos(struct mxs_lradc *lradc) | |||
| 653 | mxs_lradc_reg_set(lradc, mxs_lradc_drive_x_plate(lradc), LRADC_CTRL0); | 632 | mxs_lradc_reg_set(lradc, mxs_lradc_drive_x_plate(lradc), LRADC_CTRL0); |
| 654 | 633 | ||
| 655 | lradc->cur_plate = LRADC_SAMPLE_X; | 634 | lradc->cur_plate = LRADC_SAMPLE_X; |
| 656 | mxs_lradc_setup_ts_channel(lradc, TS_CH_YP); | 635 | mxs_lradc_map_channel(lradc, TOUCHSCREEN_VCHANNEL1, TS_CH_YP); |
| 636 | mxs_lradc_setup_ts_channel(lradc, TOUCHSCREEN_VCHANNEL1); | ||
| 657 | } | 637 | } |
| 658 | 638 | ||
| 659 | /* | 639 | /* |
| @@ -674,7 +654,8 @@ static void mxs_lradc_prepare_y_pos(struct mxs_lradc *lradc) | |||
| 674 | mxs_lradc_reg_set(lradc, mxs_lradc_drive_y_plate(lradc), LRADC_CTRL0); | 654 | mxs_lradc_reg_set(lradc, mxs_lradc_drive_y_plate(lradc), LRADC_CTRL0); |
| 675 | 655 | ||
| 676 | lradc->cur_plate = LRADC_SAMPLE_Y; | 656 | lradc->cur_plate = LRADC_SAMPLE_Y; |
| 677 | mxs_lradc_setup_ts_channel(lradc, TS_CH_XM); | 657 | mxs_lradc_map_channel(lradc, TOUCHSCREEN_VCHANNEL1, TS_CH_XM); |
| 658 | mxs_lradc_setup_ts_channel(lradc, TOUCHSCREEN_VCHANNEL1); | ||
| 678 | } | 659 | } |
| 679 | 660 | ||
| 680 | /* | 661 | /* |
| @@ -695,7 +676,10 @@ static void mxs_lradc_prepare_pressure(struct mxs_lradc *lradc) | |||
| 695 | mxs_lradc_reg_set(lradc, mxs_lradc_drive_pressure(lradc), LRADC_CTRL0); | 676 | mxs_lradc_reg_set(lradc, mxs_lradc_drive_pressure(lradc), LRADC_CTRL0); |
| 696 | 677 | ||
| 697 | lradc->cur_plate = LRADC_SAMPLE_PRESSURE; | 678 | lradc->cur_plate = LRADC_SAMPLE_PRESSURE; |
| 698 | mxs_lradc_setup_ts_pressure(lradc, TS_CH_XP, TS_CH_YM); | 679 | mxs_lradc_map_channel(lradc, TOUCHSCREEN_VCHANNEL1, TS_CH_YM); |
| 680 | mxs_lradc_map_channel(lradc, TOUCHSCREEN_VCHANNEL2, TS_CH_XP); | ||
| 681 | mxs_lradc_setup_ts_pressure(lradc, TOUCHSCREEN_VCHANNEL2, | ||
| 682 | TOUCHSCREEN_VCHANNEL1); | ||
| 699 | } | 683 | } |
| 700 | 684 | ||
| 701 | static void mxs_lradc_enable_touch_detection(struct mxs_lradc *lradc) | 685 | static void mxs_lradc_enable_touch_detection(struct mxs_lradc *lradc) |
| @@ -708,6 +692,19 @@ static void mxs_lradc_enable_touch_detection(struct mxs_lradc *lradc) | |||
| 708 | mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); | 692 | mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); |
| 709 | } | 693 | } |
| 710 | 694 | ||
| 695 | static void mxs_lradc_start_touch_event(struct mxs_lradc *lradc) | ||
| 696 | { | ||
| 697 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, | ||
| 698 | LRADC_CTRL1); | ||
| 699 | mxs_lradc_reg_set(lradc, | ||
| 700 | LRADC_CTRL1_LRADC_IRQ_EN(TOUCHSCREEN_VCHANNEL1), LRADC_CTRL1); | ||
| 701 | /* | ||
| 702 | * start with the Y-pos, because it uses nearly the same plate | ||
| 703 | * settings like the touch detection | ||
| 704 | */ | ||
| 705 | mxs_lradc_prepare_y_pos(lradc); | ||
| 706 | } | ||
| 707 | |||
| 711 | static void mxs_lradc_report_ts_event(struct mxs_lradc *lradc) | 708 | static void mxs_lradc_report_ts_event(struct mxs_lradc *lradc) |
| 712 | { | 709 | { |
| 713 | input_report_abs(lradc->ts_input, ABS_X, lradc->ts_x_pos); | 710 | input_report_abs(lradc->ts_input, ABS_X, lradc->ts_x_pos); |
| @@ -725,10 +722,12 @@ static void mxs_lradc_complete_touch_event(struct mxs_lradc *lradc) | |||
| 725 | * start a dummy conversion to burn time to settle the signals | 722 | * start a dummy conversion to burn time to settle the signals |
| 726 | * note: we are not interested in the conversion's value | 723 | * note: we are not interested in the conversion's value |
| 727 | */ | 724 | */ |
| 728 | mxs_lradc_reg_wrt(lradc, 0, LRADC_CH(5)); | 725 | mxs_lradc_reg_wrt(lradc, 0, LRADC_CH(TOUCHSCREEN_VCHANNEL1)); |
| 729 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ(5), LRADC_CTRL1); | 726 | mxs_lradc_reg_clear(lradc, |
| 730 | mxs_lradc_reg_set(lradc, LRADC_CTRL1_LRADC_IRQ_EN(5), LRADC_CTRL1); | 727 | LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL1) | |
| 731 | mxs_lradc_reg_wrt(lradc, LRADC_DELAY_TRIGGER(1 << 5) | | 728 | LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL2), LRADC_CTRL1); |
| 729 | mxs_lradc_reg_wrt(lradc, | ||
| 730 | LRADC_DELAY_TRIGGER(1 << TOUCHSCREEN_VCHANNEL1) | | ||
| 732 | LRADC_DELAY_KICK | LRADC_DELAY_DELAY(10), /* waste 5 ms */ | 731 | LRADC_DELAY_KICK | LRADC_DELAY_DELAY(10), /* waste 5 ms */ |
| 733 | LRADC_DELAY(2)); | 732 | LRADC_DELAY(2)); |
| 734 | } | 733 | } |
| @@ -760,59 +759,45 @@ static void mxs_lradc_finish_touch_event(struct mxs_lradc *lradc, bool valid) | |||
| 760 | 759 | ||
| 761 | /* if it is released, wait for the next touch via IRQ */ | 760 | /* if it is released, wait for the next touch via IRQ */ |
| 762 | lradc->cur_plate = LRADC_TOUCH; | 761 | lradc->cur_plate = LRADC_TOUCH; |
| 763 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ, LRADC_CTRL1); | 762 | mxs_lradc_reg_wrt(lradc, 0, LRADC_DELAY(2)); |
| 763 | mxs_lradc_reg_wrt(lradc, 0, LRADC_DELAY(3)); | ||
| 764 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ | | ||
| 765 | LRADC_CTRL1_LRADC_IRQ_EN(TOUCHSCREEN_VCHANNEL1) | | ||
| 766 | LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL1), LRADC_CTRL1); | ||
| 764 | mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); | 767 | mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); |
| 765 | } | 768 | } |
| 766 | 769 | ||
| 767 | /* touchscreen's state machine */ | 770 | /* touchscreen's state machine */ |
| 768 | static void mxs_lradc_handle_touch(struct mxs_lradc *lradc) | 771 | static void mxs_lradc_handle_touch(struct mxs_lradc *lradc) |
| 769 | { | 772 | { |
| 770 | int val; | ||
| 771 | |||
| 772 | switch (lradc->cur_plate) { | 773 | switch (lradc->cur_plate) { |
| 773 | case LRADC_TOUCH: | 774 | case LRADC_TOUCH: |
| 774 | /* | 775 | if (mxs_lradc_check_touch_event(lradc)) |
| 775 | * start with the Y-pos, because it uses nearly the same plate | 776 | mxs_lradc_start_touch_event(lradc); |
| 776 | * settings like the touch detection | ||
| 777 | */ | ||
| 778 | if (mxs_lradc_check_touch_event(lradc)) { | ||
| 779 | mxs_lradc_reg_clear(lradc, | ||
| 780 | LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, | ||
| 781 | LRADC_CTRL1); | ||
| 782 | mxs_lradc_prepare_y_pos(lradc); | ||
| 783 | } | ||
| 784 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ, | 777 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ, |
| 785 | LRADC_CTRL1); | 778 | LRADC_CTRL1); |
| 786 | return; | 779 | return; |
| 787 | 780 | ||
| 788 | case LRADC_SAMPLE_Y: | 781 | case LRADC_SAMPLE_Y: |
| 789 | val = mxs_lradc_read_ts_channel(lradc); | 782 | lradc->ts_y_pos = mxs_lradc_read_raw_channel(lradc, |
| 790 | if (val < 0) { | 783 | TOUCHSCREEN_VCHANNEL1); |
| 791 | mxs_lradc_enable_touch_detection(lradc); /* re-start */ | ||
| 792 | return; | ||
| 793 | } | ||
| 794 | lradc->ts_y_pos = val; | ||
| 795 | mxs_lradc_prepare_x_pos(lradc); | 784 | mxs_lradc_prepare_x_pos(lradc); |
| 796 | return; | 785 | return; |
| 797 | 786 | ||
| 798 | case LRADC_SAMPLE_X: | 787 | case LRADC_SAMPLE_X: |
| 799 | val = mxs_lradc_read_ts_channel(lradc); | 788 | lradc->ts_x_pos = mxs_lradc_read_raw_channel(lradc, |
| 800 | if (val < 0) { | 789 | TOUCHSCREEN_VCHANNEL1); |
| 801 | mxs_lradc_enable_touch_detection(lradc); /* re-start */ | ||
| 802 | return; | ||
| 803 | } | ||
| 804 | lradc->ts_x_pos = val; | ||
| 805 | mxs_lradc_prepare_pressure(lradc); | 790 | mxs_lradc_prepare_pressure(lradc); |
| 806 | return; | 791 | return; |
| 807 | 792 | ||
| 808 | case LRADC_SAMPLE_PRESSURE: | 793 | case LRADC_SAMPLE_PRESSURE: |
| 809 | lradc->ts_pressure = | 794 | lradc->ts_pressure = mxs_lradc_read_ts_pressure(lradc, |
| 810 | mxs_lradc_read_ts_pressure(lradc, TS_CH_XP, TS_CH_YM); | 795 | TOUCHSCREEN_VCHANNEL2, |
| 796 | TOUCHSCREEN_VCHANNEL1); | ||
| 811 | mxs_lradc_complete_touch_event(lradc); | 797 | mxs_lradc_complete_touch_event(lradc); |
| 812 | return; | 798 | return; |
| 813 | 799 | ||
| 814 | case LRADC_SAMPLE_VALID: | 800 | case LRADC_SAMPLE_VALID: |
| 815 | val = mxs_lradc_read_ts_channel(lradc); /* ignore the value */ | ||
| 816 | mxs_lradc_finish_touch_event(lradc, 1); | 801 | mxs_lradc_finish_touch_event(lradc, 1); |
| 817 | break; | 802 | break; |
| 818 | } | 803 | } |
| @@ -844,9 +829,9 @@ static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val) | |||
| 844 | * used if doing raw sampling. | 829 | * used if doing raw sampling. |
| 845 | */ | 830 | */ |
| 846 | if (lradc->soc == IMX28_LRADC) | 831 | if (lradc->soc == IMX28_LRADC) |
| 847 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK, | 832 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ_EN(0), |
| 848 | LRADC_CTRL1); | 833 | LRADC_CTRL1); |
| 849 | mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0); | 834 | mxs_lradc_reg_clear(lradc, 0x1, LRADC_CTRL0); |
| 850 | 835 | ||
| 851 | /* Enable / disable the divider per requirement */ | 836 | /* Enable / disable the divider per requirement */ |
| 852 | if (test_bit(chan, &lradc->is_divided)) | 837 | if (test_bit(chan, &lradc->is_divided)) |
| @@ -1090,9 +1075,8 @@ static void mxs_lradc_disable_ts(struct mxs_lradc *lradc) | |||
| 1090 | { | 1075 | { |
| 1091 | /* stop all interrupts from firing */ | 1076 | /* stop all interrupts from firing */ |
| 1092 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN | | 1077 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN | |
| 1093 | LRADC_CTRL1_LRADC_IRQ_EN(2) | LRADC_CTRL1_LRADC_IRQ_EN(3) | | 1078 | LRADC_CTRL1_LRADC_IRQ_EN(TOUCHSCREEN_VCHANNEL1) | |
| 1094 | LRADC_CTRL1_LRADC_IRQ_EN(4) | LRADC_CTRL1_LRADC_IRQ_EN(5), | 1079 | LRADC_CTRL1_LRADC_IRQ_EN(TOUCHSCREEN_VCHANNEL2), LRADC_CTRL1); |
| 1095 | LRADC_CTRL1); | ||
| 1096 | 1080 | ||
| 1097 | /* Power-down touchscreen touch-detect circuitry. */ | 1081 | /* Power-down touchscreen touch-detect circuitry. */ |
| 1098 | mxs_lradc_reg_clear(lradc, mxs_lradc_plate_mask(lradc), LRADC_CTRL0); | 1082 | mxs_lradc_reg_clear(lradc, mxs_lradc_plate_mask(lradc), LRADC_CTRL0); |
| @@ -1158,26 +1142,31 @@ static irqreturn_t mxs_lradc_handle_irq(int irq, void *data) | |||
| 1158 | struct iio_dev *iio = data; | 1142 | struct iio_dev *iio = data; |
| 1159 | struct mxs_lradc *lradc = iio_priv(iio); | 1143 | struct mxs_lradc *lradc = iio_priv(iio); |
| 1160 | unsigned long reg = readl(lradc->base + LRADC_CTRL1); | 1144 | unsigned long reg = readl(lradc->base + LRADC_CTRL1); |
| 1145 | uint32_t clr_irq = mxs_lradc_irq_mask(lradc); | ||
| 1161 | const uint32_t ts_irq_mask = | 1146 | const uint32_t ts_irq_mask = |
| 1162 | LRADC_CTRL1_TOUCH_DETECT_IRQ | | 1147 | LRADC_CTRL1_TOUCH_DETECT_IRQ | |
| 1163 | LRADC_CTRL1_LRADC_IRQ(2) | | 1148 | LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL1) | |
| 1164 | LRADC_CTRL1_LRADC_IRQ(3) | | 1149 | LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL2); |
| 1165 | LRADC_CTRL1_LRADC_IRQ(4) | | ||
| 1166 | LRADC_CTRL1_LRADC_IRQ(5); | ||
| 1167 | 1150 | ||
| 1168 | if (!(reg & mxs_lradc_irq_mask(lradc))) | 1151 | if (!(reg & mxs_lradc_irq_mask(lradc))) |
| 1169 | return IRQ_NONE; | 1152 | return IRQ_NONE; |
| 1170 | 1153 | ||
| 1171 | if (lradc->use_touchscreen && (reg & ts_irq_mask)) | 1154 | if (lradc->use_touchscreen && (reg & ts_irq_mask)) { |
| 1172 | mxs_lradc_handle_touch(lradc); | 1155 | mxs_lradc_handle_touch(lradc); |
| 1173 | 1156 | ||
| 1174 | if (iio_buffer_enabled(iio)) | 1157 | /* Make sure we don't clear the next conversion's interrupt. */ |
| 1175 | iio_trigger_poll(iio->trig); | 1158 | clr_irq &= ~(LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL1) | |
| 1176 | else if (reg & LRADC_CTRL1_LRADC_IRQ(0)) | 1159 | LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL2)); |
| 1160 | } | ||
| 1161 | |||
| 1162 | if (iio_buffer_enabled(iio)) { | ||
| 1163 | if (reg & lradc->buffer_vchans) | ||
| 1164 | iio_trigger_poll(iio->trig); | ||
| 1165 | } else if (reg & LRADC_CTRL1_LRADC_IRQ(0)) { | ||
| 1177 | complete(&lradc->completion); | 1166 | complete(&lradc->completion); |
| 1167 | } | ||
| 1178 | 1168 | ||
| 1179 | mxs_lradc_reg_clear(lradc, reg & mxs_lradc_irq_mask(lradc), | 1169 | mxs_lradc_reg_clear(lradc, reg & clr_irq, LRADC_CTRL1); |
| 1180 | LRADC_CTRL1); | ||
| 1181 | 1170 | ||
| 1182 | return IRQ_HANDLED; | 1171 | return IRQ_HANDLED; |
| 1183 | } | 1172 | } |
| @@ -1289,9 +1278,10 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio) | |||
| 1289 | } | 1278 | } |
| 1290 | 1279 | ||
| 1291 | if (lradc->soc == IMX28_LRADC) | 1280 | if (lradc->soc == IMX28_LRADC) |
| 1292 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK, | 1281 | mxs_lradc_reg_clear(lradc, |
| 1293 | LRADC_CTRL1); | 1282 | lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET, |
| 1294 | mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0); | 1283 | LRADC_CTRL1); |
| 1284 | mxs_lradc_reg_clear(lradc, lradc->buffer_vchans, LRADC_CTRL0); | ||
| 1295 | 1285 | ||
| 1296 | for_each_set_bit(chan, iio->active_scan_mask, LRADC_MAX_TOTAL_CHANS) { | 1286 | for_each_set_bit(chan, iio->active_scan_mask, LRADC_MAX_TOTAL_CHANS) { |
| 1297 | ctrl4_set |= chan << LRADC_CTRL4_LRADCSELECT_OFFSET(ofs); | 1287 | ctrl4_set |= chan << LRADC_CTRL4_LRADCSELECT_OFFSET(ofs); |
| @@ -1324,10 +1314,11 @@ static int mxs_lradc_buffer_postdisable(struct iio_dev *iio) | |||
| 1324 | mxs_lradc_reg_clear(lradc, LRADC_DELAY_TRIGGER_LRADCS_MASK | | 1314 | mxs_lradc_reg_clear(lradc, LRADC_DELAY_TRIGGER_LRADCS_MASK | |
| 1325 | LRADC_DELAY_KICK, LRADC_DELAY(0)); | 1315 | LRADC_DELAY_KICK, LRADC_DELAY(0)); |
| 1326 | 1316 | ||
| 1327 | mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0); | 1317 | mxs_lradc_reg_clear(lradc, lradc->buffer_vchans, LRADC_CTRL0); |
| 1328 | if (lradc->soc == IMX28_LRADC) | 1318 | if (lradc->soc == IMX28_LRADC) |
| 1329 | mxs_lradc_reg_clear(lradc, LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK, | 1319 | mxs_lradc_reg_clear(lradc, |
| 1330 | LRADC_CTRL1); | 1320 | lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET, |
| 1321 | LRADC_CTRL1); | ||
| 1331 | 1322 | ||
| 1332 | kfree(lradc->buffer); | 1323 | kfree(lradc->buffer); |
| 1333 | mutex_unlock(&lradc->lock); | 1324 | mutex_unlock(&lradc->lock); |
| @@ -1353,7 +1344,7 @@ static bool mxs_lradc_validate_scan_mask(struct iio_dev *iio, | |||
| 1353 | if (lradc->use_touchbutton) | 1344 | if (lradc->use_touchbutton) |
| 1354 | rsvd_chans++; | 1345 | rsvd_chans++; |
| 1355 | if (lradc->use_touchscreen) | 1346 | if (lradc->use_touchscreen) |
| 1356 | rsvd_chans++; | 1347 | rsvd_chans += 2; |
| 1357 | 1348 | ||
| 1358 | /* Test for attempts to map channels with special mode of operation. */ | 1349 | /* Test for attempts to map channels with special mode of operation. */ |
| 1359 | if (bitmap_intersects(mask, &rsvd_mask, LRADC_MAX_TOTAL_CHANS)) | 1350 | if (bitmap_intersects(mask, &rsvd_mask, LRADC_MAX_TOTAL_CHANS)) |
| @@ -1413,6 +1404,13 @@ static const struct iio_chan_spec mxs_lradc_chan_spec[] = { | |||
| 1413 | .channel = 8, | 1404 | .channel = 8, |
| 1414 | .scan_type = {.sign = 'u', .realbits = 18, .storagebits = 32,}, | 1405 | .scan_type = {.sign = 'u', .realbits = 18, .storagebits = 32,}, |
| 1415 | }, | 1406 | }, |
| 1407 | /* Hidden channel to keep indexes */ | ||
| 1408 | { | ||
| 1409 | .type = IIO_TEMP, | ||
| 1410 | .indexed = 1, | ||
| 1411 | .scan_index = -1, | ||
| 1412 | .channel = 9, | ||
| 1413 | }, | ||
| 1416 | MXS_ADC_CHAN(10, IIO_VOLTAGE), /* VDDIO */ | 1414 | MXS_ADC_CHAN(10, IIO_VOLTAGE), /* VDDIO */ |
| 1417 | MXS_ADC_CHAN(11, IIO_VOLTAGE), /* VTH */ | 1415 | MXS_ADC_CHAN(11, IIO_VOLTAGE), /* VTH */ |
| 1418 | MXS_ADC_CHAN(12, IIO_VOLTAGE), /* VDDA */ | 1416 | MXS_ADC_CHAN(12, IIO_VOLTAGE), /* VDDA */ |
| @@ -1583,6 +1581,11 @@ static int mxs_lradc_probe(struct platform_device *pdev) | |||
| 1583 | 1581 | ||
| 1584 | touch_ret = mxs_lradc_probe_touchscreen(lradc, node); | 1582 | touch_ret = mxs_lradc_probe_touchscreen(lradc, node); |
| 1585 | 1583 | ||
| 1584 | if (touch_ret == 0) | ||
| 1585 | lradc->buffer_vchans = BUFFER_VCHANS_LIMITED; | ||
| 1586 | else | ||
| 1587 | lradc->buffer_vchans = BUFFER_VCHANS_ALL; | ||
| 1588 | |||
| 1586 | /* Grab all IRQ sources */ | 1589 | /* Grab all IRQ sources */ |
| 1587 | for (i = 0; i < of_cfg->irq_count; i++) { | 1590 | for (i = 0; i < of_cfg->irq_count; i++) { |
| 1588 | lradc->irq[i] = platform_get_irq(pdev, i); | 1591 | lradc->irq[i] = platform_get_irq(pdev, i); |
diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 017d2f8379b7..c17893b4918c 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
| 19 | #include <linux/gpio.h> | 19 | #include <linux/gpio.h> |
| 20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
| 21 | #include <linux/bitops.h> | ||
| 21 | 22 | ||
| 22 | #include <linux/iio/iio.h> | 23 | #include <linux/iio/iio.h> |
| 23 | #include <linux/iio/sysfs.h> | 24 | #include <linux/iio/sysfs.h> |
| @@ -68,7 +69,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, | |||
| 68 | break; | 69 | break; |
| 69 | case IIO_ANGL_VEL: | 70 | case IIO_ANGL_VEL: |
| 70 | vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); | 71 | vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); |
| 71 | vel = (vel << 4) >> 4; | 72 | vel = sign_extend32(vel, 11); |
| 72 | *val = vel; | 73 | *val = vel; |
| 73 | break; | 74 | break; |
| 74 | default: | 75 | default: |
