diff options
author | H. Nikolaus Schaller <hns@goldelico.com> | 2015-10-16 08:53:38 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-10-25 08:02:41 -0400 |
commit | e08e19c331fb249e6dc86365ee80d16045c4aeb1 (patch) | |
tree | 4981f2fae39537788f0da5a1b39a65395b231755 /include/linux/mfd/palmas.h | |
parent | 75b6548f1793c7a79a8b063cd575df9c04dcc122 (diff) |
iio:adc: add iio driver for Palmas (twl6035/7) gpadc
This driver code was found as:
https://android.googlesource.com/kernel/tegra/+/aaabb2e045f31e5a970109ffdaae900dd403d17e/drivers/staging/iio/adc
Fixed various compilation issues and test this driver on omap5 evm.
Signed-off-by: Pradeep Goudagunta <pgoudagunta@nvidia.com>
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Marek Belisko <marek@goldelico.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'include/linux/mfd/palmas.h')
-rw-r--r-- | include/linux/mfd/palmas.h | 75 |
1 files changed, 51 insertions, 24 deletions
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index 13e1d96935ed..c800dbc42079 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h | |||
@@ -134,21 +134,32 @@ struct palmas_pmic_driver_data { | |||
134 | struct regulator_config config); | 134 | struct regulator_config config); |
135 | }; | 135 | }; |
136 | 136 | ||
137 | struct palmas_adc_wakeup_property { | ||
138 | int adc_channel_number; | ||
139 | int adc_high_threshold; | ||
140 | int adc_low_threshold; | ||
141 | }; | ||
142 | |||
137 | struct palmas_gpadc_platform_data { | 143 | struct palmas_gpadc_platform_data { |
138 | /* Channel 3 current source is only enabled during conversion */ | 144 | /* Channel 3 current source is only enabled during conversion */ |
139 | int ch3_current; | 145 | int ch3_current; /* 0: off; 1: 10uA; 2: 400uA; 3: 800 uA */ |
140 | 146 | ||
141 | /* Channel 0 current source can be used for battery detection. | 147 | /* Channel 0 current source can be used for battery detection. |
142 | * If used for battery detection this will cause a permanent current | 148 | * If used for battery detection this will cause a permanent current |
143 | * consumption depending on current level set here. | 149 | * consumption depending on current level set here. |
144 | */ | 150 | */ |
145 | int ch0_current; | 151 | int ch0_current; /* 0: off; 1: 5uA; 2: 15uA; 3: 20 uA */ |
152 | bool extended_delay; /* use extended delay for conversion */ | ||
146 | 153 | ||
147 | /* default BAT_REMOVAL_DAT setting on device probe */ | 154 | /* default BAT_REMOVAL_DAT setting on device probe */ |
148 | int bat_removal; | 155 | int bat_removal; |
149 | 156 | ||
150 | /* Sets the START_POLARITY bit in the RT_CTRL register */ | 157 | /* Sets the START_POLARITY bit in the RT_CTRL register */ |
151 | int start_polarity; | 158 | int start_polarity; |
159 | |||
160 | int auto_conversion_period_ms; | ||
161 | struct palmas_adc_wakeup_property *adc_wakeup1_data; | ||
162 | struct palmas_adc_wakeup_property *adc_wakeup2_data; | ||
152 | }; | 163 | }; |
153 | 164 | ||
154 | struct palmas_reg_init { | 165 | struct palmas_reg_init { |
@@ -405,28 +416,7 @@ struct palmas_gpadc_calibration { | |||
405 | s32 offset_error; | 416 | s32 offset_error; |
406 | }; | 417 | }; |
407 | 418 | ||
408 | struct palmas_gpadc { | 419 | #define PALMAS_DATASHEET_NAME(_name) "palmas-gpadc-chan-"#_name |
409 | struct device *dev; | ||
410 | struct palmas *palmas; | ||
411 | |||
412 | int ch3_current; | ||
413 | int ch0_current; | ||
414 | |||
415 | int gpadc_force; | ||
416 | |||
417 | int bat_removal; | ||
418 | |||
419 | struct mutex reading_lock; | ||
420 | struct completion irq_complete; | ||
421 | |||
422 | int eoc_sw_irq; | ||
423 | |||
424 | struct palmas_gpadc_calibration *palmas_cal_tbl; | ||
425 | |||
426 | int conv0_channel; | ||
427 | int conv1_channel; | ||
428 | int rt_channel; | ||
429 | }; | ||
430 | 420 | ||
431 | struct palmas_gpadc_result { | 421 | struct palmas_gpadc_result { |
432 | s32 raw_code; | 422 | s32 raw_code; |
@@ -520,6 +510,43 @@ enum palmas_irqs { | |||
520 | PALMAS_NUM_IRQ, | 510 | PALMAS_NUM_IRQ, |
521 | }; | 511 | }; |
522 | 512 | ||
513 | /* Palmas GPADC Channels */ | ||
514 | enum { | ||
515 | PALMAS_ADC_CH_IN0, | ||
516 | PALMAS_ADC_CH_IN1, | ||
517 | PALMAS_ADC_CH_IN2, | ||
518 | PALMAS_ADC_CH_IN3, | ||
519 | PALMAS_ADC_CH_IN4, | ||
520 | PALMAS_ADC_CH_IN5, | ||
521 | PALMAS_ADC_CH_IN6, | ||
522 | PALMAS_ADC_CH_IN7, | ||
523 | PALMAS_ADC_CH_IN8, | ||
524 | PALMAS_ADC_CH_IN9, | ||
525 | PALMAS_ADC_CH_IN10, | ||
526 | PALMAS_ADC_CH_IN11, | ||
527 | PALMAS_ADC_CH_IN12, | ||
528 | PALMAS_ADC_CH_IN13, | ||
529 | PALMAS_ADC_CH_IN14, | ||
530 | PALMAS_ADC_CH_IN15, | ||
531 | PALMAS_ADC_CH_MAX, | ||
532 | }; | ||
533 | |||
534 | /* Palmas GPADC Channel0 Current Source */ | ||
535 | enum { | ||
536 | PALMAS_ADC_CH0_CURRENT_SRC_0, | ||
537 | PALMAS_ADC_CH0_CURRENT_SRC_5, | ||
538 | PALMAS_ADC_CH0_CURRENT_SRC_15, | ||
539 | PALMAS_ADC_CH0_CURRENT_SRC_20, | ||
540 | }; | ||
541 | |||
542 | /* Palmas GPADC Channel3 Current Source */ | ||
543 | enum { | ||
544 | PALMAS_ADC_CH3_CURRENT_SRC_0, | ||
545 | PALMAS_ADC_CH3_CURRENT_SRC_10, | ||
546 | PALMAS_ADC_CH3_CURRENT_SRC_400, | ||
547 | PALMAS_ADC_CH3_CURRENT_SRC_800, | ||
548 | }; | ||
549 | |||
523 | struct palmas_pmic { | 550 | struct palmas_pmic { |
524 | struct palmas *palmas; | 551 | struct palmas *palmas; |
525 | struct device *dev; | 552 | struct device *dev; |