Commit e08e19c3 authored by H. Nikolaus Schaller's avatar H. Nikolaus Schaller Committed by Jonathan Cameron

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: default avatarPradeep Goudagunta <pgoudagunta@nvidia.com>
Signed-off-by: default avatarH. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: default avatarMarek Belisko <marek@goldelico.com>
Acked-by: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: default avatarJonathan Cameron <jic23@kernel.org>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 75b6548f
...@@ -275,6 +275,14 @@ config NAU7802 ...@@ -275,6 +275,14 @@ config NAU7802
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called nau7802. module will be called nau7802.
config PALMAS_GPADC
tristate "TI Palmas General Purpose ADC"
depends on MFD_PALMAS
help
Palmas series pmic chip by Texas Instruments (twl6035/6037)
is used in smartphones and tablets and supports a 16 channel
general purpose ADC.
config QCOM_SPMI_IADC config QCOM_SPMI_IADC
tristate "Qualcomm SPMI PMIC current ADC" tristate "Qualcomm SPMI PMIC current ADC"
depends on SPMI depends on SPMI
......
...@@ -27,6 +27,7 @@ obj-$(CONFIG_MCP320X) += mcp320x.o ...@@ -27,6 +27,7 @@ obj-$(CONFIG_MCP320X) += mcp320x.o
obj-$(CONFIG_MCP3422) += mcp3422.o obj-$(CONFIG_MCP3422) += mcp3422.o
obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o
obj-$(CONFIG_NAU7802) += nau7802.o obj-$(CONFIG_NAU7802) += nau7802.o
obj-$(CONFIG_PALMAS_GPADC) += palmas_gpadc.o
obj-$(CONFIG_QCOM_SPMI_IADC) += qcom-spmi-iadc.o obj-$(CONFIG_QCOM_SPMI_IADC) += qcom-spmi-iadc.o
obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o
obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o
......
This diff is collapsed.
...@@ -134,21 +134,32 @@ struct palmas_pmic_driver_data { ...@@ -134,21 +134,32 @@ struct palmas_pmic_driver_data {
struct regulator_config config); struct regulator_config config);
}; };
struct palmas_adc_wakeup_property {
int adc_channel_number;
int adc_high_threshold;
int adc_low_threshold;
};
struct palmas_gpadc_platform_data { struct palmas_gpadc_platform_data {
/* Channel 3 current source is only enabled during conversion */ /* Channel 3 current source is only enabled during conversion */
int ch3_current; int ch3_current; /* 0: off; 1: 10uA; 2: 400uA; 3: 800 uA */
/* Channel 0 current source can be used for battery detection. /* Channel 0 current source can be used for battery detection.
* If used for battery detection this will cause a permanent current * If used for battery detection this will cause a permanent current
* consumption depending on current level set here. * consumption depending on current level set here.
*/ */
int ch0_current; int ch0_current; /* 0: off; 1: 5uA; 2: 15uA; 3: 20 uA */
bool extended_delay; /* use extended delay for conversion */
/* default BAT_REMOVAL_DAT setting on device probe */ /* default BAT_REMOVAL_DAT setting on device probe */
int bat_removal; int bat_removal;
/* Sets the START_POLARITY bit in the RT_CTRL register */ /* Sets the START_POLARITY bit in the RT_CTRL register */
int start_polarity; int start_polarity;
int auto_conversion_period_ms;
struct palmas_adc_wakeup_property *adc_wakeup1_data;
struct palmas_adc_wakeup_property *adc_wakeup2_data;
}; };
struct palmas_reg_init { struct palmas_reg_init {
...@@ -405,28 +416,7 @@ struct palmas_gpadc_calibration { ...@@ -405,28 +416,7 @@ struct palmas_gpadc_calibration {
s32 offset_error; s32 offset_error;
}; };
struct palmas_gpadc { #define PALMAS_DATASHEET_NAME(_name) "palmas-gpadc-chan-"#_name
struct device *dev;
struct palmas *palmas;
int ch3_current;
int ch0_current;
int gpadc_force;
int bat_removal;
struct mutex reading_lock;
struct completion irq_complete;
int eoc_sw_irq;
struct palmas_gpadc_calibration *palmas_cal_tbl;
int conv0_channel;
int conv1_channel;
int rt_channel;
};
struct palmas_gpadc_result { struct palmas_gpadc_result {
s32 raw_code; s32 raw_code;
...@@ -520,6 +510,43 @@ enum palmas_irqs { ...@@ -520,6 +510,43 @@ enum palmas_irqs {
PALMAS_NUM_IRQ, PALMAS_NUM_IRQ,
}; };
/* Palmas GPADC Channels */
enum {
PALMAS_ADC_CH_IN0,
PALMAS_ADC_CH_IN1,
PALMAS_ADC_CH_IN2,
PALMAS_ADC_CH_IN3,
PALMAS_ADC_CH_IN4,
PALMAS_ADC_CH_IN5,
PALMAS_ADC_CH_IN6,
PALMAS_ADC_CH_IN7,
PALMAS_ADC_CH_IN8,
PALMAS_ADC_CH_IN9,
PALMAS_ADC_CH_IN10,
PALMAS_ADC_CH_IN11,
PALMAS_ADC_CH_IN12,
PALMAS_ADC_CH_IN13,
PALMAS_ADC_CH_IN14,
PALMAS_ADC_CH_IN15,
PALMAS_ADC_CH_MAX,
};
/* Palmas GPADC Channel0 Current Source */
enum {
PALMAS_ADC_CH0_CURRENT_SRC_0,
PALMAS_ADC_CH0_CURRENT_SRC_5,
PALMAS_ADC_CH0_CURRENT_SRC_15,
PALMAS_ADC_CH0_CURRENT_SRC_20,
};
/* Palmas GPADC Channel3 Current Source */
enum {
PALMAS_ADC_CH3_CURRENT_SRC_0,
PALMAS_ADC_CH3_CURRENT_SRC_10,
PALMAS_ADC_CH3_CURRENT_SRC_400,
PALMAS_ADC_CH3_CURRENT_SRC_800,
};
struct palmas_pmic { struct palmas_pmic {
struct palmas *palmas; struct palmas *palmas;
struct device *dev; struct device *dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment