iio: adc: spmi-vadc: Add adc support for SPF targets
Update the channel type and scaling function for the VADC channels that are used by legacy SPF targets. Change-Id: I6637388ace022c5726a8f00fb1f8c0eb98c39f5c Signed-off-by: Asha Magadi Venkateshamurthy <amagad@codeaurora.org> Signed-off-by: Archana Sriram <apsrir@codeaurora.org>
This commit is contained in:
parent
a5eb56f58a
commit
a2e940bc10
@ -1,14 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* Copyright (c) 2012-2016,2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/bitops.h>
|
||||
@ -560,19 +552,19 @@ static const struct vadc_channels vadc_chans[] = {
|
||||
VADC_CHAN_NO_SCALE(SPARE1_03, 1)
|
||||
VADC_CHAN_NO_SCALE(USB_ID_MV, 1)
|
||||
VADC_CHAN_VOLT(VCOIN, 1, SCALE_DEFAULT)
|
||||
VADC_CHAN_NO_SCALE(VBAT_SNS, 1)
|
||||
VADC_CHAN_VOLT(VBAT_SNS, 1, SCALE_DEFAULT)
|
||||
VADC_CHAN_VOLT(VSYS, 1, SCALE_DEFAULT)
|
||||
VADC_CHAN_TEMP(DIE_TEMP, 0, SCALE_PMIC_THERM)
|
||||
VADC_CHAN_VOLT(REF_625MV, 0, SCALE_DEFAULT)
|
||||
VADC_CHAN_VOLT(REF_1250MV, 0, SCALE_DEFAULT)
|
||||
VADC_CHAN_NO_SCALE(CHG_TEMP, 0)
|
||||
VADC_CHAN_NO_SCALE(SPARE1, 0)
|
||||
VADC_CHAN_VOLT(SPARE1, 0, SCALE_DEFAULT)
|
||||
VADC_CHAN_TEMP(SPARE2, 0, SCALE_PMI_CHG_TEMP)
|
||||
VADC_CHAN_VOLT(GND_REF, 0, SCALE_DEFAULT)
|
||||
VADC_CHAN_VOLT(VDD_VADC, 0, SCALE_DEFAULT)
|
||||
|
||||
VADC_CHAN_NO_SCALE(P_MUX1_1_1, 0)
|
||||
VADC_CHAN_NO_SCALE(P_MUX2_1_1, 0)
|
||||
VADC_CHAN_TEMP(P_MUX2_1_1, 0, SCALE_THERM_100K_PULLUP)
|
||||
VADC_CHAN_NO_SCALE(P_MUX3_1_1, 0)
|
||||
VADC_CHAN_NO_SCALE(P_MUX4_1_1, 0)
|
||||
VADC_CHAN_NO_SCALE(P_MUX5_1_1, 0)
|
||||
@ -606,18 +598,18 @@ static const struct vadc_channels vadc_chans[] = {
|
||||
VADC_CHAN_NO_SCALE(P_MUX16_1_3, 1)
|
||||
|
||||
VADC_CHAN_NO_SCALE(LR_MUX1_BAT_THERM, 0)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX2_BAT_ID, 0)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX3_XO_THERM, 0)
|
||||
VADC_CHAN_VOLT(LR_MUX2_BAT_ID, 0, SCALE_DEFAULT)
|
||||
VADC_CHAN_TEMP(LR_MUX3_XO_THERM, 0, SCALE_THERM_100K_PULLUP)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX4_AMUX_THM1, 0)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX5_AMUX_THM2, 0)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX6_AMUX_THM3, 0)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX7_HW_ID, 0)
|
||||
VADC_CHAN_TEMP(LR_MUX7_HW_ID, 0, SCALE_THERM_100K_PULLUP)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX8_AMUX_THM4, 0)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX9_AMUX_THM5, 0)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX10_USB_ID, 0)
|
||||
VADC_CHAN_NO_SCALE(AMUX_PU1, 0)
|
||||
VADC_CHAN_NO_SCALE(AMUX_PU2, 0)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX3_BUF_XO_THERM, 0)
|
||||
VADC_CHAN_TEMP(LR_MUX3_BUF_XO_THERM, 0, SCALE_THERM_100K_PULLUP)
|
||||
|
||||
VADC_CHAN_NO_SCALE(LR_MUX1_PU1_BAT_THERM, 0)
|
||||
VADC_CHAN_NO_SCALE(LR_MUX2_PU1_BAT_ID, 0)
|
||||
|
@ -759,6 +759,61 @@ static const struct vadc_map_pt adcmap7_100k[] = {
|
||||
{ 2420, 130048 }
|
||||
};
|
||||
|
||||
/* Voltage to temperature */
|
||||
static const struct vadc_map_pt adcmap_batt_therm_qrd_215[] = {
|
||||
{1575, -200},
|
||||
{1549, -180},
|
||||
{1522, -160},
|
||||
{1493, -140},
|
||||
{1463, -120},
|
||||
{1431, -100},
|
||||
{1398, -80},
|
||||
{1364, -60},
|
||||
{1329, -40},
|
||||
{1294, -20},
|
||||
{1258, 0},
|
||||
{1222, 20},
|
||||
{1187, 40},
|
||||
{1151, 60},
|
||||
{1116, 80},
|
||||
{1082, 100},
|
||||
{1049, 120},
|
||||
{1016, 140},
|
||||
{985, 160},
|
||||
{955, 180},
|
||||
{926, 200},
|
||||
{899, 220},
|
||||
{873, 240},
|
||||
{849, 260},
|
||||
{825, 280},
|
||||
{804, 300},
|
||||
{783, 320},
|
||||
{764, 340},
|
||||
{746, 360},
|
||||
{729, 380},
|
||||
{714, 400},
|
||||
{699, 420},
|
||||
{686, 440},
|
||||
{673, 460},
|
||||
{662, 480},
|
||||
{651, 500},
|
||||
{641, 520},
|
||||
{632, 540},
|
||||
{623, 560},
|
||||
{615, 580},
|
||||
{608, 600},
|
||||
{601, 620},
|
||||
{595, 640},
|
||||
{589, 660},
|
||||
{583, 680},
|
||||
{578, 700},
|
||||
{574, 720},
|
||||
{569, 740},
|
||||
{565, 760},
|
||||
{562, 780},
|
||||
{558, 800}
|
||||
};
|
||||
|
||||
static int qcom_vadc_map_voltage_temp(const struct vadc_map_pt *pts,
|
||||
u32 tablesize, s32 input, s64 *output)
|
||||
{
|
||||
@ -830,6 +885,10 @@ static int qcom_vadc_scale_volt(const struct vadc_linear_graph *calib_graph,
|
||||
|
||||
voltage = voltage * prescale->den;
|
||||
result = div64_s64(voltage, prescale->num);
|
||||
|
||||
if (!absolute)
|
||||
result *= 1000;
|
||||
|
||||
*result_uv = result;
|
||||
|
||||
return 0;
|
||||
@ -860,6 +919,29 @@ static int qcom_vadc_scale_therm(const struct vadc_linear_graph *calib_graph,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qcom_vadc_scale_therm_qrd_215(
|
||||
const struct vadc_linear_graph *calib_graph,
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
bool absolute, u16 adc_code,
|
||||
int *result_mdec)
|
||||
{
|
||||
s64 voltage = 0, result = 0;
|
||||
int ret;
|
||||
|
||||
qcom_vadc_scale_calib(calib_graph, adc_code, absolute, &voltage);
|
||||
|
||||
ret = qcom_vadc_map_voltage_temp(adcmap_batt_therm_qrd_215,
|
||||
ARRAY_SIZE(adcmap_batt_therm_qrd_215),
|
||||
voltage, &result);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*result_mdec = result;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int qcom_vadc_scale_die_temp(const struct vadc_linear_graph *calib_graph,
|
||||
const struct vadc_prescale_ratio *prescale,
|
||||
bool absolute,
|
||||
@ -1307,6 +1389,10 @@ int qcom_vadc_scale(enum vadc_scale_fn_type scaletype,
|
||||
return qcom_vadc_scale_therm(calib_graph, prescale,
|
||||
absolute, adc_code,
|
||||
result);
|
||||
case SCALE_BATT_THERM_QRD_215:
|
||||
return qcom_vadc_scale_therm_qrd_215(calib_graph, prescale,
|
||||
absolute, adc_code,
|
||||
result);
|
||||
case SCALE_PMIC_THERM:
|
||||
return qcom_vadc_scale_die_temp(calib_graph, prescale,
|
||||
absolute, adc_code,
|
||||
|
@ -198,6 +198,7 @@ enum vadc_scale_fn_type {
|
||||
SCALE_HW_CALIB_PM2250_S3_DIE_TEMP,
|
||||
SCALE_HW_CALIB_THERM_100K_PU_PM7,
|
||||
SCALE_HW_CALIB_PMIC_THERM_PM7,
|
||||
SCALE_BATT_THERM_QRD_215,
|
||||
SCALE_HW_CALIB_MAX,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user