mfd: pmic8038-core: Add HK/XOADC device
HouseKeeping ADC (HKADC) on the PMIC is used by clients
to measure voltage, current and temperature. Clients
include the Battery, Charger and Thermal clients that
require reading the ADC in real time. This also
supports reading the ADC channels that are mapped through
the PMIC MPP's such as the PA THERM channel.
Change-Id: I3c4fd9d368550c1cca168ea097e0d457d01d695e
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 92fd1d78..a0f4669 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -790,7 +790,7 @@
config SENSORS_PM8XXX_ADC
tristate "Support for Qualcomm PM8XXX ADC"
- depends on MFD_PM8018_CORE || MFD_PM8921_CORE
+ depends on MFD_PM8XXX
help
This is the ADC arbiter driver for Qualcomm PM8XXX Chip.
diff --git a/drivers/mfd/pm8038-core.c b/drivers/mfd/pm8038-core.c
index f433456..c90ea16 100644
--- a/drivers/mfd/pm8038-core.c
+++ b/drivers/mfd/pm8038-core.c
@@ -142,6 +142,19 @@
.num_resources = ARRAY_SIZE(gpio_cell_resources),
};
+static const struct resource adc_cell_resources[] __devinitconst = {
+ SINGLE_IRQ_RESOURCE(NULL, PM8038_ADC_EOC_USR_IRQ),
+ SINGLE_IRQ_RESOURCE(NULL, PM8038_ADC_BATT_TEMP_WARM_IRQ),
+ SINGLE_IRQ_RESOURCE(NULL, PM8038_ADC_BATT_TEMP_COLD_IRQ),
+};
+
+static struct mfd_cell adc_cell __devinitdata = {
+ .name = PM8XXX_ADC_DEV_NAME,
+ .id = -1,
+ .resources = adc_cell_resources,
+ .num_resources = ARRAY_SIZE(adc_cell_resources),
+};
+
static const struct resource mpp_cell_resources[] __devinitconst = {
{
.start = PM8038_IRQ_BLOCK_BIT(PM8038_MPP_BLOCK_START, 0),
@@ -445,6 +458,18 @@
goto bail;
}
+ if (pdata->adc_pdata) {
+ adc_cell.platform_data = pdata->adc_pdata;
+ adc_cell.pdata_size =
+ sizeof(struct pm8xxx_adc_platform_data);
+ ret = mfd_add_devices(pmic->dev, 0, &adc_cell, 1, NULL,
+ irq_base);
+ if (ret) {
+ pr_err("Failed to add adc subdevices ret=%d\n",
+ ret);
+ }
+ }
+
return 0;
bail:
if (pmic->irq_chip) {