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/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;