diff options
| -rw-r--r-- | drivers/input/touchscreen/ads7846.c | 30 | ||||
| -rw-r--r-- | include/linux/spi/ads7846.h | 2 |
2 files changed, 19 insertions, 13 deletions
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 03e527c16c23..c34e59b720a6 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
| @@ -145,15 +145,16 @@ struct ads7846 { | |||
| 145 | #define MAX_12BIT ((1<<12)-1) | 145 | #define MAX_12BIT ((1<<12)-1) |
| 146 | 146 | ||
| 147 | /* leave ADC powered up (disables penirq) between differential samples */ | 147 | /* leave ADC powered up (disables penirq) between differential samples */ |
| 148 | #define READ_12BIT_DFR(x) (ADS_START | ADS_A2A1A0_d_ ## x \ | 148 | #define READ_12BIT_DFR(x, adc, vref) (ADS_START | ADS_A2A1A0_d_ ## x \ |
| 149 | | ADS_12_BIT | ADS_DFR) | 149 | | ADS_12_BIT | ADS_DFR | \ |
| 150 | (adc ? ADS_PD10_ADC_ON : 0) | (vref ? ADS_PD10_REF_ON : 0)) | ||
| 150 | 151 | ||
| 151 | #define READ_Y (READ_12BIT_DFR(y) | ADS_PD10_ADC_ON) | 152 | #define READ_Y(vref) (READ_12BIT_DFR(y, 1, vref)) |
| 152 | #define READ_Z1 (READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON) | 153 | #define READ_Z1(vref) (READ_12BIT_DFR(z1, 1, vref)) |
| 153 | #define READ_Z2 (READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON) | 154 | #define READ_Z2(vref) (READ_12BIT_DFR(z2, 1, vref)) |
| 154 | 155 | ||
| 155 | #define READ_X (READ_12BIT_DFR(x) | ADS_PD10_ADC_ON) | 156 | #define READ_X(vref) (READ_12BIT_DFR(x, 1, vref)) |
| 156 | #define PWRDOWN (READ_12BIT_DFR(y) | ADS_PD10_PDOWN) /* LAST */ | 157 | #define PWRDOWN (READ_12BIT_DFR(y, 0, 0)) /* LAST */ |
| 157 | 158 | ||
| 158 | /* single-ended samples need to first power up reference voltage; | 159 | /* single-ended samples need to first power up reference voltage; |
| 159 | * we leave both ADC and VREF powered | 160 | * we leave both ADC and VREF powered |
| @@ -161,8 +162,8 @@ struct ads7846 { | |||
| 161 | #define READ_12BIT_SER(x) (ADS_START | ADS_A2A1A0_ ## x \ | 162 | #define READ_12BIT_SER(x) (ADS_START | ADS_A2A1A0_ ## x \ |
| 162 | | ADS_12_BIT | ADS_SER) | 163 | | ADS_12_BIT | ADS_SER) |
| 163 | 164 | ||
| 164 | #define REF_ON (READ_12BIT_DFR(x) | ADS_PD10_ALL_ON) | 165 | #define REF_ON (READ_12BIT_DFR(x, 1, 1)) |
| 165 | #define REF_OFF (READ_12BIT_DFR(y) | ADS_PD10_PDOWN) | 166 | #define REF_OFF (READ_12BIT_DFR(y, 0, 0)) |
| 166 | 167 | ||
| 167 | /*--------------------------------------------------------------------------*/ | 168 | /*--------------------------------------------------------------------------*/ |
| 168 | 169 | ||
| @@ -670,6 +671,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
| 670 | struct ads7846_platform_data *pdata = spi->dev.platform_data; | 671 | struct ads7846_platform_data *pdata = spi->dev.platform_data; |
| 671 | struct spi_message *m; | 672 | struct spi_message *m; |
| 672 | struct spi_transfer *x; | 673 | struct spi_transfer *x; |
| 674 | int vref; | ||
| 673 | int err; | 675 | int err; |
| 674 | 676 | ||
| 675 | if (!spi->irq) { | 677 | if (!spi->irq) { |
| @@ -767,6 +769,8 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
| 767 | input_set_abs_params(input_dev, ABS_PRESSURE, | 769 | input_set_abs_params(input_dev, ABS_PRESSURE, |
| 768 | pdata->pressure_min, pdata->pressure_max, 0, 0); | 770 | pdata->pressure_min, pdata->pressure_max, 0, 0); |
| 769 | 771 | ||
| 772 | vref = pdata->keep_vref_on; | ||
| 773 | |||
| 770 | /* set up the transfers to read touchscreen state; this assumes we | 774 | /* set up the transfers to read touchscreen state; this assumes we |
| 771 | * use formula #2 for pressure, not #3. | 775 | * use formula #2 for pressure, not #3. |
| 772 | */ | 776 | */ |
| @@ -776,7 +780,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
| 776 | spi_message_init(m); | 780 | spi_message_init(m); |
| 777 | 781 | ||
| 778 | /* y- still on; turn on only y+ (and ADC) */ | 782 | /* y- still on; turn on only y+ (and ADC) */ |
| 779 | ts->read_y = READ_Y; | 783 | ts->read_y = READ_Y(vref); |
| 780 | x->tx_buf = &ts->read_y; | 784 | x->tx_buf = &ts->read_y; |
| 781 | x->len = 1; | 785 | x->len = 1; |
| 782 | spi_message_add_tail(x, m); | 786 | spi_message_add_tail(x, m); |
| @@ -794,7 +798,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
| 794 | 798 | ||
| 795 | /* turn y- off, x+ on, then leave in lowpower */ | 799 | /* turn y- off, x+ on, then leave in lowpower */ |
| 796 | x++; | 800 | x++; |
| 797 | ts->read_x = READ_X; | 801 | ts->read_x = READ_X(vref); |
| 798 | x->tx_buf = &ts->read_x; | 802 | x->tx_buf = &ts->read_x; |
| 799 | x->len = 1; | 803 | x->len = 1; |
| 800 | spi_message_add_tail(x, m); | 804 | spi_message_add_tail(x, m); |
| @@ -813,7 +817,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
| 813 | spi_message_init(m); | 817 | spi_message_init(m); |
| 814 | 818 | ||
| 815 | x++; | 819 | x++; |
| 816 | ts->read_z1 = READ_Z1; | 820 | ts->read_z1 = READ_Z1(vref); |
| 817 | x->tx_buf = &ts->read_z1; | 821 | x->tx_buf = &ts->read_z1; |
| 818 | x->len = 1; | 822 | x->len = 1; |
| 819 | spi_message_add_tail(x, m); | 823 | spi_message_add_tail(x, m); |
| @@ -830,7 +834,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
| 830 | spi_message_init(m); | 834 | spi_message_init(m); |
| 831 | 835 | ||
| 832 | x++; | 836 | x++; |
| 833 | ts->read_z2 = READ_Z2; | 837 | ts->read_z2 = READ_Z2(vref); |
| 834 | x->tx_buf = &ts->read_z2; | 838 | x->tx_buf = &ts->read_z2; |
| 835 | x->len = 1; | 839 | x->len = 1; |
| 836 | spi_message_add_tail(x, m); | 840 | spi_message_add_tail(x, m); |
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h index 1663f940ca11..3387e44dfd13 100644 --- a/include/linux/spi/ads7846.h +++ b/include/linux/spi/ads7846.h | |||
| @@ -14,6 +14,8 @@ enum ads7846_filter { | |||
| 14 | struct ads7846_platform_data { | 14 | struct ads7846_platform_data { |
| 15 | u16 model; /* 7843, 7845, 7846. */ | 15 | u16 model; /* 7843, 7845, 7846. */ |
| 16 | u16 vref_delay_usecs; /* 0 for external vref; etc */ | 16 | u16 vref_delay_usecs; /* 0 for external vref; etc */ |
| 17 | int keep_vref_on:1; /* set to keep vref on for differential | ||
| 18 | * measurements as well */ | ||
| 17 | u16 x_plate_ohms; | 19 | u16 x_plate_ohms; |
| 18 | u16 y_plate_ohms; | 20 | u16 y_plate_ohms; |
| 19 | 21 | ||
