Add samsung specific changes

This commit is contained in:
2025-08-11 14:29:00 +02:00
parent c66122e619
commit 4d134a1294
2688 changed files with 1127995 additions and 11475 deletions

View File

@@ -6,6 +6,7 @@
#ifndef QCOM_VADC_COMMON_H
#define QCOM_VADC_COMMON_H
#include <linux/adc-tm-clients.h>
#include <linux/math.h>
#include <linux/types.h>
@@ -32,8 +33,9 @@
#define ADC5_DECIMATION_SHORT 250
#define ADC5_DECIMATION_MEDIUM 420
#define ADC5_DECIMATION_LONG 840
/* Default decimation - 1024 for rev2, 840 for pmic5 */
/* Default decimation - 1024 for rev2, 840 for pmic5, 1360 for adc5_gen3 and 340 for adc5_gen4 */
#define ADC5_DECIMATION_DEFAULT 2
#define ADC5_GEN4_DECIMATION_DEFAULT 1
#define ADC5_DECIMATION_SAMPLES_MAX 3
#define VADC_HW_SETTLE_DELAY_MAX 10000
@@ -44,6 +46,11 @@
#define PMIC5_CHG_TEMP_SCALE_FACTOR 377500
#define PMIC5_SMB_TEMP_CONSTANT 419400
#define PMIC5_SMB_TEMP_SCALE_FACTOR 356
#define PMIC5_SMB1398_TEMP_CONSTANT 268235
#define PMIC5_SMB1398_TEMP_SCALE_FACTOR 340
#define PMIC5_PM2250_S3_DIE_TEMP_SCALE_FACTOR 187263
#define PMIC5_PM2250_S3_DIE_TEMP_CONSTANT 720100
#define PMI_CHG_SCALE_1 -138890
#define PMI_CHG_SCALE_2 391750000000LL
@@ -52,9 +59,14 @@
#define ADC5_FULL_SCALE_CODE 0x70e4
#define ADC5_USR_DATA_CHECK 0x8000
#define R_PU_10K 10000
#define R_PU_100K 100000
#define RATIO_MAX_ADC7 BIT(14)
#define PMIC5_GEN3_USB_IN_I_SCALE_FACTOR 9248
#define ADC_VDD_REF 1875000
/*
* VADC_CALIB_ABSOLUTE: uses the 625mV and 1.25V as reference channels.
* VADC_CALIB_RATIOMETRIC: uses the reference voltage (1.8V) and GND for
@@ -80,6 +92,54 @@ struct vadc_linear_graph {
s32 gnd;
};
/**
* enum adc_tm_rscale_fn_type - Scaling function used to convert the
* channels input voltage/temperature to corresponding ADC code that is
* applied for thresholds. Check the corresponding channels scaling to
* determine the appropriate temperature/voltage units that are passed
* to the scaling function. Example battery follows the power supply
* framework that needs its units to be in decidegreesC so it passes
* deci-degreesC. PA_THERM clients pass the temperature in degrees.
* The order below should match the one in the driver for
* adc_tm_rscale_fn[].
*/
enum adc_tm_rscale_fn_type {
SCALE_R_ABSOLUTE = 0,
SCALE_RSCALE_NONE,
};
/**
* struct adc_tm_config - Represent ADC Thermal Monitor configuration.
* @high_thr_temp: Temperature at which high threshold notification is required.
* @low_thr_temp: Temperature at which low threshold notification is required.
* @low_thr_voltage : Low threshold voltage ADC code used for reverse
* calibration.
* @high_thr_voltage: High threshold voltage ADC code used for reverse
* calibration.
*/
struct adc_tm_config {
int high_thr_temp;
int low_thr_temp;
int64_t high_thr_voltage;
int64_t low_thr_voltage;
};
struct adc_tm_reverse_scale_fn {
int32_t (*chan)(struct adc_tm_config *tm_config);
};
struct adc_tm_client_info {
struct list_head list;
struct adc_tm_param *param;
int32_t low_thr_requested;
int32_t high_thr_requested;
bool notify_low_thr;
bool notify_high_thr;
bool high_thr_set;
bool low_thr_set;
enum adc_tm_state_request state_request;
};
/**
* enum vadc_scale_fn_type - Scaling function to convert ADC code to
* physical scaled units for the channel.
@@ -99,12 +159,48 @@ struct vadc_linear_graph {
* lookup table for PMIC7. The hardware applies offset/slope to adc code.
* SCALE_HW_CALIB_PMIC_THERM: Returns result in milli degree's Centigrade.
* The hardware applies offset/slope to adc code.
* SCALE_HW_CALIB_PMIC_THERM: Returns result in milli degree's Centigrade.
* SCALE_HW_CALIB_PMIC_THERM_PM7: Returns result in milli degree's Centigrade.
* The hardware applies offset/slope to adc code. This is for PMIC7.
* SCALE_HW_CALIB_PM5_CHG_TEMP: Returns result in millidegrees for PMIC5
* charger temperature.
* SCALE_HW_CALIB_PM5_SMB_TEMP: Returns result in millidegrees for PMIC5
* SMB1390 temperature.
* SCALE_HW_CALIB_BATT_THERM_100K: Returns battery thermistor temperature in
* decidegC using 100k pullup. The hardware applies offset/slope to adc
* code.
* SCALE_HW_CALIB_BATT_THERM_30K: Returns battery thermistor temperature in
* decidegC using 30k pullup. The hardware applies offset/slope to adc
* code.
* SCALE_HW_CALIB_BATT_THERM_400K: Returns battery thermistor temperature in
* decidegC using 400k pullup. The hardware applies offset/slope to adc
* code.
* SCALE_HW_CALIB_PM5_SMB1398_TEMP: Returns result in millidegrees for PMIC5
* SMB1398 temperature.
* SCALE_HW_CALIB_PM7_SMB_TEMP: Returns result in millidegrees for PMIC7
* SMB139x temperature.
* SCALE_HW_CALIB_PM7_CHG_TEMP: Returns result in millidegrees for PMIC7
* charger temperature.
* SCALE_HW_CALIB_CUR: Returns result in microamperes for PMIC7 channels that
* use voltage scaling.
* SCALE_HW_CALIB_CUR_RAW: Returns result in microamperes for PMIC7 channels
* that use raw ADC code.
* SCALE_HW_CALIB_PM2250_S3_DIE_TEMP: Returns result in millidegrees for
* S3 die temperature channel on PM2250.
* SCALE_HW_CALIB_PM5_CUR: Returns result in microamperes for PMIC5 channels
* that use voltage scaling.
* SCALE_HW_CALIB_PM5_GEN3_BATT_THERM_100K: Returns battery thermistor
* temperature in decidegC using 100k pullup. The hardware applies
* offset/slope to adc code.
* SCALE_HW_CALIB_PM5_GEN3_BATT_ID_100K: Returns battery ID resistance
* in ohms using 100k pullup. The hardware applies offset/slope to
* adc code.
* SCALE_HW_CALIB_PM5_GEN3_USB_IN_I: Returns USB input current in microamperes.
* SCALE_HW_CALIB_PM5_GEN4_BATT_THERM_10K: Returns battery thermistor
* temperature in decidegC using 10k pullup. The hardware applies
* offset/slope to adc code.
* SCALE_HW_CALIB_PM5_GEN4_BATT_ID_10K: Returns battery ID resistance
* in ohms using 10k pullup. The hardware applies offset/slope to
* adc code.
*/
enum vadc_scale_fn_type {
SCALE_DEFAULT = 0,
@@ -120,12 +216,34 @@ enum vadc_scale_fn_type {
SCALE_HW_CALIB_PMIC_THERM_PM7,
SCALE_HW_CALIB_PM5_CHG_TEMP,
SCALE_HW_CALIB_PM5_SMB_TEMP,
SCALE_HW_CALIB_BATT_THERM_100K,
SCALE_HW_CALIB_BATT_THERM_30K,
SCALE_HW_CALIB_BATT_THERM_400K,
SCALE_HW_CALIB_PM5_SMB1398_TEMP,
SCALE_HW_CALIB_PM7_SMB_TEMP,
SCALE_HW_CALIB_PM7_CHG_TEMP,
SCALE_HW_CALIB_CUR,
SCALE_HW_CALIB_CUR_RAW,
SCALE_HW_CALIB_PM2250_S3_DIE_TEMP,
SCALE_HW_CALIB_PM5_CUR,
SCALE_HW_CALIB_PM5_GEN3_BATT_THERM_100K,
SCALE_HW_CALIB_PM5_GEN3_BATT_ID_100K,
SCALE_HW_CALIB_PM5_GEN3_USB_IN_I,
SCALE_HW_CALIB_PM5_GEN4_BATT_THERM_10K,
SCALE_HW_CALIB_PM5_GEN4_BATT_ID_10K,
SCALE_HW_CALIB_INVALID,
};
enum vadc_generation {
ADC5_GEN3 = 0,
ADC5_GEN4,
};
struct adc5_data {
const char *name;
const u32 full_scale_code_volt;
const u32 full_scale_code_cur;
const u32 full_scale_code_raw;
const struct adc5_channels *adc_chans;
const struct iio_info *info;
unsigned int *decimation;
@@ -164,4 +282,9 @@ int qcom_adc5_decimation_from_dt(u32 value, const unsigned int *decimation);
int qcom_vadc_decimation_from_dt(u32 value);
void adc_tm_scale_therm_voltage_100k_gen3(struct adc_tm_config *param,
const struct adc5_data *data);
int32_t adc_tm_absolute_rthr_gen3(struct adc_tm_config *tm_config);
#endif /* QCOM_VADC_COMMON_H */