msm: Enable msm_adc for 7x27a/8x25
The msm_adc interface is used to read the HKADC from the
remote processor. It uses the DALRPC layer to communicate
to the remote HKADC driver.
Add support to read PMIC Thermistor from the HKADC to support
thermal clients on the apps. PMIC temperature is one of the
thermal nodes used for performing thermal mitigation.
Change-Id: I9d9e8178e19daf5d830588281855dd8a40de1f0d
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-msm7x27a.c b/arch/arm/mach-msm/board-msm7x27a.c
index 5b60af0..c3650fa 100644
--- a/arch/arm/mach-msm/board-msm7x27a.c
+++ b/arch/arm/mach-msm/board-msm7x27a.c
@@ -49,6 +49,7 @@
#include <linux/smsc911x.h>
#include <linux/atmel_maxtouch.h>
#include <linux/fmem.h>
+#include <linux/msm_adc.h>
#include "devices.h"
#include "timer.h"
#include "board-msm7x27a-regulator.h"
@@ -712,6 +713,24 @@
"eth_fifo_sel" },
};
+static char *msm_adc_surf_device_names[] = {
+ "XO_ADC",
+};
+
+static struct msm_adc_platform_data msm_adc_pdata = {
+ .dev_names = msm_adc_surf_device_names,
+ .num_adc = ARRAY_SIZE(msm_adc_surf_device_names),
+ .target_hw = MSM_8x25,
+};
+
+static struct platform_device msm_adc_device = {
+ .name = "msm_adc",
+ .id = -1,
+ .dev = {
+ .platform_data = &msm_adc_pdata,
+ },
+};
+
#define ETH_FIFO_SEL_GPIO 49
static void msm7x27a_cfg_smsc911x(void)
{
@@ -814,6 +833,7 @@
&asoc_msm_dai0,
&asoc_msm_dai1,
&msm_batt_device,
+ &msm_adc_device,
};
static struct platform_device *msm8625_surf_devices[] __initdata = {
diff --git a/arch/arm/mach-msm/board-qrd7627a.c b/arch/arm/mach-msm/board-qrd7627a.c
index 4a6b150..3e8dd8f 100644
--- a/arch/arm/mach-msm/board-qrd7627a.c
+++ b/arch/arm/mach-msm/board-qrd7627a.c
@@ -30,6 +30,7 @@
#include <linux/regulator/consumer.h>
#include <linux/memblock.h>
#include <linux/input/ft5x06_ts.h>
+#include <linux/msm_adc.h>
#include <asm/mach/mmc.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -599,6 +600,24 @@
.dev.platform_data = &msm_psy_batt_data,
};
+static char *msm_adc_surf_device_names[] = {
+ "XO_ADC",
+};
+
+static struct msm_adc_platform_data msm_adc_pdata = {
+ .dev_names = msm_adc_surf_device_names,
+ .num_adc = ARRAY_SIZE(msm_adc_surf_device_names),
+ .target_hw = MSM_8x25,
+};
+
+static struct platform_device msm_adc_device = {
+ .name = "msm_adc",
+ .id = -1,
+ .dev = {
+ .platform_data = &msm_adc_pdata,
+ },
+};
+
static struct platform_device *common_devices[] __initdata = {
&android_usb_device,
&android_pmem_device,
@@ -610,6 +629,7 @@
&asoc_msm_pcm,
&asoc_msm_dai0,
&asoc_msm_dai1,
+ &msm_adc_device,
};
static struct platform_device *qrd7627a_devices[] __initdata = {
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 36c370e..3762bac 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -777,7 +777,7 @@
config SENSORS_MSM_ADC
tristate "MSM ADC Driver for current measurement"
- depends on ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_FSM9XXX
+ depends on ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_FSM9XXX || ARCH_MSM7X27A
default n
help
Provides interface for measuring the ADC's on AMUX channels of XOADC,
diff --git a/drivers/hwmon/msm_adc.c b/drivers/hwmon/msm_adc.c
index 39bfc3a..e4a607f 100644
--- a/drivers/hwmon/msm_adc.c
+++ b/drivers/hwmon/msm_adc.c
@@ -41,6 +41,9 @@
#define MSM_ADC_DALRC_CONV_TIMEOUT (5 * HZ) /* 5 seconds */
+#define MSM_8x25_ADC_DEV_ID 0
+#define MSM_8x25_CHAN_ID 16
+
enum dal_error {
DAL_ERROR_INVALID_DEVICE_IDX = 1,
DAL_ERROR_INVALID_CHANNEL_IDX,
@@ -1171,18 +1174,26 @@
goto dev_init_err;
}
- /* DAL device lookup */
- rc = msm_adc_getinputproperties(msm_adc, adc_dev->name,
+ if (!pdata->target_hw == MSM_8x25) {
+ /* DAL device lookup */
+ rc = msm_adc_getinputproperties(msm_adc, adc_dev->name,
&target);
- if (rc) {
- dev_err(&pdev->dev, "No such DAL device[%s]\n",
+ if (rc) {
+ dev_err(&pdev->dev, "No such DAL device[%s]\n",
adc_dev->name);
- goto dev_init_err;
+ goto dev_init_err;
+ }
+
+ adc_dev->transl.dal_dev_idx = target.dal.dev_idx;
+ adc_dev->nchans = target.dal.chan_idx;
+ } else {
+ /* On targets prior to MSM7x30 the remote driver has
+ only the channel list and no device id. */
+ adc_dev->transl.dal_dev_idx = MSM_8x25_ADC_DEV_ID;
+ adc_dev->nchans = MSM_8x25_CHAN_ID;
}
- adc_dev->transl.dal_dev_idx = target.dal.dev_idx;
adc_dev->transl.hwmon_dev_idx = i;
- adc_dev->nchans = target.dal.chan_idx;
adc_dev->transl.hwmon_start = hwmon_cntr;
adc_dev->transl.hwmon_end = hwmon_cntr + adc_dev->nchans - 1;
hwmon_cntr += adc_dev->nchans;
diff --git a/include/linux/msm_adc.h b/include/linux/msm_adc.h
index 51371a6..c303e69 100644
--- a/include/linux/msm_adc.h
+++ b/include/linux/msm_adc.h
@@ -236,6 +236,7 @@
MSM_7x30,
MSM_8x60,
FSM_9xxx,
+ MSM_8x25,
};
enum epm_gpio_config {
@@ -344,23 +345,23 @@
int32_t adc_channel_request_conv(void *h, struct completion *conv_complete_evt);
int32_t adc_channel_read_result(void *h, struct adc_chan_result *chan_result);
#else
-static int32_t adc_channel_open(uint32_t channel, void **h)
+static inline int32_t adc_channel_open(uint32_t channel, void **h)
{
pr_err("%s.not supported.\n", __func__);
return -ENODEV;
}
-static int32_t adc_channel_close(void *h)
+static inline int32_t adc_channel_close(void *h)
{
pr_err("%s.not supported.\n", __func__);
return -ENODEV;
}
-static int32_t
+static inline int32_t
adc_channel_request_conv(void *h, struct completion *conv_complete_evt)
{
pr_err("%s.not supported.\n", __func__);
return -ENODEV;
}
-static int32_t
+static inline int32_t
adc_channel_read_result(void *h, struct adc_chan_result *chan_result)
{
pr_err("%s.not supported.\n", __func__);