hwmon: pm8xxx-adc: Limit BTM interval period

Due to a PMIC bug the interval time cannot be set greater than
or equal to 0x15. If a value of 0x15 or higher is set the
measurement interval time ends up reading the battery temperature
continously. Therfore limit the interval time to 0x14 if the input
value is equal or greater than 0x15.

Change-Id: If5a5d2bfe42741064f255ba1535301452960aca1
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
diff --git a/drivers/hwmon/pm8xxx-adc.c b/drivers/hwmon/pm8xxx-adc.c
index 6b3aa0c..72246e5 100644
--- a/drivers/hwmon/pm8xxx-adc.c
+++ b/drivers/hwmon/pm8xxx-adc.c
@@ -122,6 +122,7 @@
 #define PM8XXX_ADC_PA_THERM_VREG_UV_MAX			1800000
 #define PM8XXX_ADC_PA_THERM_VREG_UA_LOAD		100000
 #define PM8XXX_ADC_HWMON_NAME_LENGTH			32
+#define PM8XXX_ADC_BTM_INTERVAL_MAX			0x14
 
 struct pm8xxx_adc {
 	struct device				*dev;
@@ -843,6 +844,12 @@
 		return rc;
 	}
 
+	if (btm_param->interval > PM8XXX_ADC_BTM_INTERVAL_MAX) {
+		pr_info("Bug in PMIC BTM interval time and cannot set"
+		" a value greater than 0x14 %x\n", btm_param->interval);
+		btm_param->interval = PM8XXX_ADC_BTM_INTERVAL_MAX;
+	}
+
 	spin_lock_irqsave(&adc_pmic->btm_lock, flags);
 
 	data_btm_cool_thr0 = ((btm_param->low_thr_voltage << 24) >> 24);