Skip to content

Commit 137abbe

Browse files
Linux Build Service AccountGerrit - the friendly Code Review server
authored andcommitted
Merge "ARM: dts: msm: Add VADC and ADC_TM nodes for QM215"
2 parents 788307b + afaa409 commit 137abbe

File tree

4 files changed

+322
-0
lines changed

4 files changed

+322
-0
lines changed

arch/arm64/boot/dts/qcom/qm215-pm8916.dtsi

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,232 @@
196196
vdd_hf_dig-supply = <&pm8916_s1_level_ao>;
197197
vdd_hf_pll-supply = <&pm8916_l7_ao>;
198198
};
199+
200+
&pm8916_vadc {
201+
chan@0 {
202+
label = "usb_in";
203+
reg = <0>;
204+
qcom,decimation = <0>;
205+
qcom,pre-div-channel-scaling = <7>;
206+
qcom,calibration-type = "absolute";
207+
qcom,scale-function = <0>;
208+
qcom,hw-settle-time = <0>;
209+
qcom,fast-avg-setup = <0>;
210+
};
211+
212+
chan@2 {
213+
label = "ireg_fb";
214+
reg = <2>;
215+
qcom,decimation = <0>;
216+
qcom,pre-div-channel-scaling = <6>;
217+
qcom,calibration-type = "absolute";
218+
qcom,scale-function = <0>;
219+
qcom,hw-settle-time = <0>;
220+
qcom,fast-avg-setup = <0>;
221+
};
222+
223+
chan@5 {
224+
label = "vcoin";
225+
reg = <5>;
226+
qcom,decimation = <0>;
227+
qcom,pre-div-channel-scaling = <1>;
228+
qcom,calibration-type = "absolute";
229+
qcom,scale-function = <0>;
230+
qcom,hw-settle-time = <0>;
231+
qcom,fast-avg-setup = <0>;
232+
};
233+
234+
chan@6 {
235+
label = "vbat_sns";
236+
reg = <6>;
237+
qcom,decimation = <0>;
238+
qcom,pre-div-channel-scaling = <1>;
239+
qcom,calibration-type = "absolute";
240+
qcom,scale-function = <0>;
241+
qcom,hw-settle-time = <0>;
242+
qcom,fast-avg-setup = <0>;
243+
};
244+
245+
chan@7 {
246+
label = "vph_pwr";
247+
reg = <7>;
248+
qcom,decimation = <0>;
249+
qcom,pre-div-channel-scaling = <1>;
250+
qcom,calibration-type = "absolute";
251+
qcom,scale-function = <0>;
252+
qcom,hw-settle-time = <0>;
253+
qcom,fast-avg-setup = <0>;
254+
};
255+
256+
chan@b {
257+
label = "chg_temp";
258+
reg = <0xb>;
259+
qcom,decimation = <0>;
260+
qcom,pre-div-channel-scaling = <0>;
261+
qcom,calibration-type = "absolute";
262+
qcom,scale-function = <3>;
263+
qcom,hw-settle-time = <0>;
264+
qcom,fast-avg-setup = <0>;
265+
};
266+
267+
chan@11 {
268+
label = "skin_therm";
269+
reg = <0x11>;
270+
qcom,decimation = <0>;
271+
qcom,pre-div-channel-scaling = <0>;
272+
qcom,calibration-type = "ratiometric";
273+
qcom,scale-function = <2>;
274+
qcom,hw-settle-time = <2>;
275+
qcom,fast-avg-setup = <0>;
276+
qcom,vadc-thermal-node;
277+
};
278+
279+
chan@30 {
280+
label = "batt_therm";
281+
reg = <0x30>;
282+
qcom,decimation = <0>;
283+
qcom,pre-div-channel-scaling = <0>;
284+
qcom,calibration-type = "ratiometric";
285+
qcom,scale-function = <22>;
286+
qcom,hw-settle-time = <0xb>;
287+
qcom,fast-avg-setup = <0>;
288+
};
289+
290+
chan@31 {
291+
label = "batt_id";
292+
reg = <0x31>;
293+
qcom,decimation = <0>;
294+
qcom,pre-div-channel-scaling = <0>;
295+
qcom,calibration-type = "ratiometric";
296+
qcom,scale-function = <0>;
297+
qcom,hw-settle-time = <0xb>;
298+
qcom,fast-avg-setup = <0>;
299+
};
300+
301+
chan@36 {
302+
label = "pa_therm0";
303+
reg = <0x36>;
304+
qcom,decimation = <0>;
305+
qcom,pre-div-channel-scaling = <0>;
306+
qcom,calibration-type = "ratiometric";
307+
qcom,scale-function = <2>;
308+
qcom,hw-settle-time = <2>;
309+
qcom,fast-avg-setup = <0>;
310+
qcom,vadc-thermal-node;
311+
};
312+
313+
chan@32 {
314+
label = "xo_therm";
315+
reg = <0x32>;
316+
qcom,decimation = <0>;
317+
qcom,pre-div-channel-scaling = <0>;
318+
qcom,calibration-type = "ratiometric";
319+
qcom,scale-function = <4>;
320+
qcom,hw-settle-time = <2>;
321+
qcom,fast-avg-setup = <0>;
322+
qcom,vadc-thermal-node;
323+
};
324+
325+
chan@3c {
326+
label = "xo_therm_buf";
327+
reg = <0x3c>;
328+
qcom,decimation = <0>;
329+
qcom,pre-div-channel-scaling = <0>;
330+
qcom,calibration-type = "ratiometric";
331+
qcom,scale-function = <4>;
332+
qcom,hw-settle-time = <2>;
333+
qcom,fast-avg-setup = <0>;
334+
qcom,vadc-thermal-node;
335+
};
336+
};
337+
338+
&pm8916_adc_tm {
339+
/* Channel Node */
340+
chan@30 {
341+
label = "batt_therm";
342+
reg = <0x30>;
343+
qcom,decimation = <0>;
344+
qcom,pre-div-channel-scaling = <0>;
345+
qcom,calibration-type = "ratiometric";
346+
qcom,scale-function = <8>;
347+
qcom,hw-settle-time = <0xb>;
348+
qcom,fast-avg-setup = <0x2>;
349+
qcom,btm-channel-number = <0x48>;
350+
};
351+
352+
chan@6 {
353+
label = "vbat_sns";
354+
reg = <0x6>;
355+
qcom,decimation = <0>;
356+
qcom,pre-div-channel-scaling = <1>;
357+
qcom,calibration-type = "absolute";
358+
qcom,scale-function = <0>;
359+
qcom,hw-settle-time = <0xb>;
360+
qcom,fast-avg-setup = <0x2>;
361+
qcom,btm-channel-number = <0x68>;
362+
};
363+
};
364+
365+
&soc {
366+
thermal-zones {
367+
xo-therm-buf-adc {
368+
polling-delay-passive = <0>;
369+
polling-delay = <0>;
370+
thermal-sensors = <&pm8916_vadc 0x3c>;
371+
thermal-governor = "user_space";
372+
373+
trips {
374+
active-config0 {
375+
temperature = <65000>;
376+
hysteresis = <1000>;
377+
type = "passive";
378+
};
379+
};
380+
};
381+
382+
xo-therm-adc {
383+
polling-delay-passive = <0>;
384+
polling-delay = <0>;
385+
thermal-sensors = <&pm8916_vadc 0x32>;
386+
thermal-governor = "user_space";
387+
388+
trips {
389+
active-config0 {
390+
temperature = <65000>;
391+
hysteresis = <1000>;
392+
type = "passive";
393+
};
394+
};
395+
};
396+
397+
pa-therm0-adc {
398+
polling-delay-passive = <0>;
399+
polling-delay = <0>;
400+
thermal-sensors = <&pm8916_vadc 0x36>;
401+
thermal-governor = "user_space";
402+
403+
trips {
404+
active-config0 {
405+
temperature = <65000>;
406+
hysteresis = <1000>;
407+
type = "passive";
408+
};
409+
};
410+
};
411+
412+
skin-therm-adc {
413+
polling-delay-passive = <0>;
414+
polling-delay = <0>;
415+
thermal-sensors = <&pm8916_vadc 0x11>;
416+
thermal-governor = "user_space";
417+
418+
trips {
419+
active-config0 {
420+
temperature = <65000>;
421+
hysteresis = <1000>;
422+
type = "passive";
423+
};
424+
};
425+
};
426+
};
427+
};

drivers/hwmon/qpnp-adc-common.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,19 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *chip,
12631263
qpnp_adc_map_voltage_temp(adcmap_batt_therm_qrd,
12641264
ARRAY_SIZE(adcmap_batt_therm_qrd),
12651265
batt_thm_voltage, &adc_chan_result->physical);
1266+
} else {
1267+
1268+
qpnp_adc_scale_with_calib_param(adc_code,
1269+
adc_properties, chan_properties, &batt_thm_voltage);
1270+
1271+
adc_chan_result->measurement = batt_thm_voltage;
1272+
1273+
return qpnp_adc_map_voltage_temp(
1274+
adcmap_batt_therm_qrd,
1275+
ARRAY_SIZE(adcmap_batt_therm_qrd),
1276+
batt_thm_voltage,
1277+
&adc_chan_result->physical);
1278+
12661279
}
12671280
return 0;
12681281
}
@@ -2152,6 +2165,64 @@ int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *chip,
21522165
}
21532166
EXPORT_SYMBOL(qpnp_adc_qrd_skut1_btm_scaler);
21542167

2168+
int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *chip,
2169+
struct qpnp_adc_tm_btm_param *param,
2170+
uint32_t *low_threshold, uint32_t *high_threshold)
2171+
{
2172+
struct qpnp_vadc_linear_graph btm_param;
2173+
int64_t low_output = 0, high_output = 0;
2174+
int rc = 0;
2175+
2176+
if (param->adc_tm_hc) {
2177+
pr_debug("Update scaling for VADC_TM_HC\n");
2178+
return -EINVAL;
2179+
}
2180+
2181+
qpnp_get_vadc_gain_and_offset(chip, &btm_param, CALIB_RATIOMETRIC);
2182+
2183+
pr_debug("warm_temp:%d and cool_temp:%d\n", param->high_temp,
2184+
param->low_temp);
2185+
rc = qpnp_adc_map_voltage_temp(
2186+
adcmap_batt_therm_qrd,
2187+
ARRAY_SIZE(adcmap_batt_therm_qrd),
2188+
(param->low_temp),
2189+
&low_output);
2190+
if (rc) {
2191+
pr_debug("low_temp mapping failed with %d\n", rc);
2192+
return rc;
2193+
}
2194+
2195+
pr_debug("low_output:%lld\n", low_output);
2196+
low_output *= btm_param.dy;
2197+
low_output = div64_s64(low_output, btm_param.adc_vref);
2198+
low_output += btm_param.adc_gnd;
2199+
2200+
rc = qpnp_adc_map_voltage_temp(
2201+
adcmap_batt_therm_qrd,
2202+
ARRAY_SIZE(adcmap_batt_therm_qrd),
2203+
(param->high_temp),
2204+
&high_output);
2205+
if (rc) {
2206+
pr_debug("high temp mapping failed with %d\n", rc);
2207+
return rc;
2208+
}
2209+
2210+
pr_debug("high_output:%lld\n", high_output);
2211+
high_output *= btm_param.dy;
2212+
high_output = div64_s64(high_output, btm_param.adc_vref);
2213+
high_output += btm_param.adc_gnd;
2214+
2215+
/* btm low temperature correspondes to high voltage threshold */
2216+
*low_threshold = high_output;
2217+
/* btm high temperature correspondes to low voltage threshold */
2218+
*high_threshold = low_output;
2219+
2220+
pr_debug("high_volt:%d, low_volt:%d\n", *high_threshold,
2221+
*low_threshold);
2222+
return 0;
2223+
}
2224+
EXPORT_SYMBOL(qpnp_adc_qrd_215_btm_scaler);
2225+
21552226
int32_t qpnp_adc_smb_btm_rscaler(struct qpnp_vadc_chip *chip,
21562227
struct qpnp_adc_tm_btm_param *param,
21572228
uint32_t *low_threshold, uint32_t *high_threshold)

drivers/thermal/qpnp-adc-tm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ static struct qpnp_adc_tm_reverse_scale_fn adc_tm_rscale_fn[] = {
361361
[SCALE_R_ABSOLUTE] = {qpnp_adc_absolute_rthr},
362362
[SCALE_QRD_SKUH_RBATT_THERM] = {qpnp_adc_qrd_skuh_btm_scaler},
363363
[SCALE_QRD_SKUT1_RBATT_THERM] = {qpnp_adc_qrd_skut1_btm_scaler},
364+
[SCALE_QRD_215_RBATT_THERM] = {qpnp_adc_qrd_215_btm_scaler},
364365
};
365366

366367
static int32_t qpnp_adc_tm_read_reg(struct qpnp_adc_tm_chip *chip,

include/linux/qpnp/qpnp-adc.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ enum qpnp_adc_tm_rscale_fn_type {
455455
SCALE_R_ABSOLUTE,
456456
SCALE_QRD_SKUH_RBATT_THERM,
457457
SCALE_QRD_SKUT1_RBATT_THERM,
458+
SCALE_QRD_215_RBATT_THERM,
458459
SCALE_RSCALE_NONE,
459460
};
460461

@@ -1887,6 +1888,22 @@ int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *dev,
18871888
int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *dev,
18881889
struct qpnp_adc_tm_btm_param *param,
18891890
uint32_t *low_threshold, uint32_t *high_threshold);
1891+
/**
1892+
* qpnp_adc_qrd_215_btm_scaler() - Performs reverse calibration on the
1893+
* low/high temperature threshold values passed by the client.
1894+
* The function maps the temperature to voltage and applies
1895+
* ratiometric calibration on the voltage values for SKUT1 board.
1896+
* @dev: Structure device for qpnp vadc
1897+
* @param: The input parameters that contain the low/high temperature
1898+
* values.
1899+
* @low_threshold: The low threshold value that needs to be updated with
1900+
* the above calibrated voltage value.
1901+
* @high_threshold: The low threshold value that needs to be updated with
1902+
* the above calibrated voltage value.
1903+
*/
1904+
int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *dev,
1905+
struct qpnp_adc_tm_btm_param *param,
1906+
uint32_t *low_threshold, uint32_t *high_threshold);
18901907
/**
18911908
* qpnp_adc_tm_scale_therm_voltage_pu2() - Performs reverse calibration
18921909
* and convert given temperature to voltage on supported
@@ -2279,6 +2296,10 @@ static inline int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *dev,
22792296
struct qpnp_adc_tm_btm_param *param,
22802297
uint32_t *low_threshold, uint32_t *high_threshold)
22812298
{ return -ENXIO; }
2299+
static inline int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *dev,
2300+
struct qpnp_adc_tm_btm_param *param,
2301+
uint32_t *low_threshold, uint32_t *high_threshold)
2302+
{ return -ENXIO; }
22822303
static inline int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr(
22832304
struct qpnp_vadc_chip *dev,
22842305
struct qpnp_adc_tm_btm_param *param,

0 commit comments

Comments
 (0)