summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddartha Mohanadoss <smohanad@codeaurora.org>2016-06-16 17:22:48 -0700
committerKyle Yan <kyan@codeaurora.org>2016-06-27 19:53:03 -0700
commit3e39d1775a4ee592da697a3c37c3a93678fbbd80 (patch)
tree09bbcd07cf2b29fecb02de05c302c99b754402cb
parent3213a9e52ace2e2ef4a432b0069fd3789fca2780 (diff)
hwmon: qpnp-adc-voltage: Add optional VADC property
Add option to select whether a fresh calibration needs to be performed when performing the channel measurement. If the property is not present the default value of using calibration measurement collected from a timer will be used. For most cases using a measurement collected from a timer interval should suffice and the default value can be used. Change-Id: I632a9466f04d5d0712de436fc3e1251f7e2e7ad2 Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
-rw-r--r--Documentation/devicetree/bindings/hwmon/qpnp-adc-voltage.txt24
-rw-r--r--drivers/hwmon/qpnp-adc-common.c13
2 files changed, 32 insertions, 5 deletions
diff --git a/Documentation/devicetree/bindings/hwmon/qpnp-adc-voltage.txt b/Documentation/devicetree/bindings/hwmon/qpnp-adc-voltage.txt
index dd0d75d9c304..1dfa97ca6648 100644
--- a/Documentation/devicetree/bindings/hwmon/qpnp-adc-voltage.txt
+++ b/Documentation/devicetree/bindings/hwmon/qpnp-adc-voltage.txt
@@ -8,8 +8,8 @@ for the USR peripheral of the VADC.
VADC node
Required properties:
-- compatible : should be "qcom,qpnp-vadc" for Voltage ADC driver and
- "qcom,qpnp-vadc-hc" for VADC_HC voltage ADC driver.
+- compatible : should be "qcom,qpnp-vadc" for Voltage ADC device driver and
+ "qcom,qpnp-vadc-hc" for VADC_HC voltage ADC device driver.
- reg : offset and length of the PMIC Aribter register map.
- address-cells : Must be one.
- size-cells : Must be zero.
@@ -40,6 +40,12 @@ Optional properties:
by the thermal framework.
- hkadc_ldo-supply : Add this property if VADC needs to perform a Software Vote for the HKADC.
- hkadc_ok-supply : Add this property if the VADC needs to perform a Software vote for the HKADC VREG_OK.
+- qcom,cal-val : Add this property for VADC_HC voltage ADC device to select from the following
+ unsigned int. If the property is not present the default calibration value of
+ using the timer value is chosen.
+ 0 : The calibration values used for measurement are from a timer.
+ 1 : Forces a fresh measurement for calibration values at the same time
+ measurement is taken.
Client required property:
- qcom,<consumer name>-vadc : The phandle to the corresponding vadc device.
@@ -51,11 +57,15 @@ Required properties:
- label : Channel name used for sysfs entry.
- reg : AMUX channel number.
- qcom,decimation : Sampling rate to use for the individual channel measurement.
- Select from following unsigned int.
+ Select from following unsigned int for Voltage ADC device.
0 : 512
1 : 1K
2 : 2K
3 : 4K
+ Select from following unsigned int for VADC_HC voltage ADC device.
+ 0 : 256
+ 1 : 512
+ 2 : 1024
- qcom,pre-div-channel-scaling : Pre-div used for the channel before the signal
is being measured. Some of the AMUX channels
support dividing the signal from a predetermined
@@ -109,7 +119,7 @@ Required properties:
- qcom,fast-avg-setup : Average number of samples to be used for measurement. Fast averaging
provides the option to obtain a single measurement from the ADC that
is an average of multiple samples. The value selected is 2^(value)
- Select from the following unsigned int.
+ Select from the following unsigned int for Voltage ADC device.
0 : 1
1 : 2
2 : 4
@@ -119,6 +129,12 @@ Required properties:
6 : 64
7 : 128
8 : 256
+ Select from the following unsigned int for VADC_HC ADC device.
+ 0 : 1
+ 1 : 2
+ 2 : 4
+ 3 : 8
+ 4 : 16
Example:
/* Main Node */
diff --git a/drivers/hwmon/qpnp-adc-common.c b/drivers/hwmon/qpnp-adc-common.c
index aeca77c9390d..ba54e7bde795 100644
--- a/drivers/hwmon/qpnp-adc-common.c
+++ b/drivers/hwmon/qpnp-adc-common.c
@@ -1789,7 +1789,7 @@ int32_t qpnp_adc_get_devicetree_data(struct platform_device *pdev,
struct qpnp_adc_properties *adc_prop;
struct qpnp_adc_amux_properties *amux_prop;
int count_adc_channel_list = 0, decimation, rc = 0, i = 0;
- int decimation_tm_hc = 0, fast_avg_setup_tm_hc = 0;
+ int decimation_tm_hc = 0, fast_avg_setup_tm_hc = 0, cal_val_hc = 0;
bool adc_hc;
if (!node)
@@ -1948,6 +1948,17 @@ int32_t qpnp_adc_get_devicetree_data(struct platform_device *pdev,
fast_avg_setup = fast_avg_setup_tm_hc;
}
+ if (of_device_is_compatible(node, "qcom,qpnp-vadc-hc")) {
+ rc = of_property_read_u32(child, "qcom,cal-val",
+ &cal_val_hc);
+ if (rc) {
+ pr_debug("Use calibration value from timer\n");
+ adc_channel_list[i].cal_val = ADC_TIMER_CAL;
+ } else {
+ adc_channel_list[i].cal_val = cal_val_hc;
+ }
+ }
+
/* Individual channel properties */
adc_channel_list[i].name = (char *)channel_name;
adc_channel_list[i].channel_num = channel_num;