.. | .. |
---|
25 | 25 | |
---|
26 | 26 | #define VADC_DECIMATION_MIN 512 |
---|
27 | 27 | #define VADC_DECIMATION_MAX 4096 |
---|
| 28 | +#define ADC5_DEF_VBAT_PRESCALING 1 /* 1:3 */ |
---|
| 29 | +#define ADC5_DECIMATION_SHORT 250 |
---|
| 30 | +#define ADC5_DECIMATION_MEDIUM 420 |
---|
| 31 | +#define ADC5_DECIMATION_LONG 840 |
---|
| 32 | +/* Default decimation - 1024 for rev2, 840 for pmic5 */ |
---|
| 33 | +#define ADC5_DECIMATION_DEFAULT 2 |
---|
| 34 | +#define ADC5_DECIMATION_SAMPLES_MAX 3 |
---|
28 | 35 | |
---|
29 | 36 | #define VADC_HW_SETTLE_DELAY_MAX 10000 |
---|
| 37 | +#define VADC_HW_SETTLE_SAMPLES_MAX 16 |
---|
30 | 38 | #define VADC_AVG_SAMPLES_MAX 512 |
---|
| 39 | +#define ADC5_AVG_SAMPLES_MAX 16 |
---|
31 | 40 | |
---|
32 | | -#define KELVINMIL_CELSIUSMIL 273150 |
---|
| 41 | +#define PMIC5_CHG_TEMP_SCALE_FACTOR 377500 |
---|
| 42 | +#define PMIC5_SMB_TEMP_CONSTANT 419400 |
---|
| 43 | +#define PMIC5_SMB_TEMP_SCALE_FACTOR 356 |
---|
33 | 44 | |
---|
34 | 45 | #define PMI_CHG_SCALE_1 -138890 |
---|
35 | 46 | #define PMI_CHG_SCALE_2 391750000000LL |
---|
| 47 | + |
---|
| 48 | +#define VADC5_MAX_CODE 0x7fff |
---|
| 49 | +#define ADC5_FULL_SCALE_CODE 0x70e4 |
---|
| 50 | +#define ADC5_USR_DATA_CHECK 0x8000 |
---|
| 51 | + |
---|
| 52 | +#define R_PU_100K 100000 |
---|
| 53 | +#define RATIO_MAX_ADC7 BIT(14) |
---|
| 54 | + |
---|
| 55 | +#define DIE_TEMP_ADC7_SCALE_1 -60000 |
---|
| 56 | +#define DIE_TEMP_ADC7_SCALE_2 20000 |
---|
| 57 | +#define DIE_TEMP_ADC7_SCALE_FACTOR 1000 |
---|
| 58 | +#define DIE_TEMP_ADC7_MAX 160000 |
---|
36 | 59 | |
---|
37 | 60 | /** |
---|
38 | 61 | * struct vadc_map_pt - Map the graph representation for ADC channel |
---|
.. | .. |
---|
89 | 112 | * SCALE_PMIC_THERM: Returns result in milli degree's Centigrade. |
---|
90 | 113 | * SCALE_XOTHERM: Returns XO thermistor voltage in millidegC. |
---|
91 | 114 | * SCALE_PMI_CHG_TEMP: Conversion for PMI CHG temp |
---|
| 115 | + * SCALE_HW_CALIB_DEFAULT: Default scaling to convert raw adc code to |
---|
| 116 | + * voltage (uV) with hardware applied offset/slope values to adc code. |
---|
| 117 | + * SCALE_HW_CALIB_THERM_100K_PULLUP: Returns temperature in millidegC using |
---|
| 118 | + * lookup table. The hardware applies offset/slope to adc code. |
---|
| 119 | + * SCALE_HW_CALIB_XOTHERM: Returns XO thermistor voltage in millidegC using |
---|
| 120 | + * 100k pullup. The hardware applies offset/slope to adc code. |
---|
| 121 | + * SCALE_HW_CALIB_THERM_100K_PU_PM7: Returns temperature in millidegC using |
---|
| 122 | + * lookup table for PMIC7. The hardware applies offset/slope to adc code. |
---|
| 123 | + * SCALE_HW_CALIB_PMIC_THERM: Returns result in milli degree's Centigrade. |
---|
| 124 | + * The hardware applies offset/slope to adc code. |
---|
| 125 | + * SCALE_HW_CALIB_PMIC_THERM: Returns result in milli degree's Centigrade. |
---|
| 126 | + * The hardware applies offset/slope to adc code. This is for PMIC7. |
---|
| 127 | + * SCALE_HW_CALIB_PM5_CHG_TEMP: Returns result in millidegrees for PMIC5 |
---|
| 128 | + * charger temperature. |
---|
| 129 | + * SCALE_HW_CALIB_PM5_SMB_TEMP: Returns result in millidegrees for PMIC5 |
---|
| 130 | + * SMB1390 temperature. |
---|
92 | 131 | */ |
---|
93 | 132 | enum vadc_scale_fn_type { |
---|
94 | 133 | SCALE_DEFAULT = 0, |
---|
.. | .. |
---|
96 | 135 | SCALE_PMIC_THERM, |
---|
97 | 136 | SCALE_XOTHERM, |
---|
98 | 137 | SCALE_PMI_CHG_TEMP, |
---|
| 138 | + SCALE_HW_CALIB_DEFAULT, |
---|
| 139 | + SCALE_HW_CALIB_THERM_100K_PULLUP, |
---|
| 140 | + SCALE_HW_CALIB_XOTHERM, |
---|
| 141 | + SCALE_HW_CALIB_THERM_100K_PU_PM7, |
---|
| 142 | + SCALE_HW_CALIB_PMIC_THERM, |
---|
| 143 | + SCALE_HW_CALIB_PMIC_THERM_PM7, |
---|
| 144 | + SCALE_HW_CALIB_PM5_CHG_TEMP, |
---|
| 145 | + SCALE_HW_CALIB_PM5_SMB_TEMP, |
---|
| 146 | + SCALE_HW_CALIB_INVALID, |
---|
| 147 | +}; |
---|
| 148 | + |
---|
| 149 | +struct adc5_data { |
---|
| 150 | + const u32 full_scale_code_volt; |
---|
| 151 | + const u32 full_scale_code_cur; |
---|
| 152 | + const struct adc5_channels *adc_chans; |
---|
| 153 | + const struct iio_info *info; |
---|
| 154 | + unsigned int *decimation; |
---|
| 155 | + unsigned int *hw_settle_1; |
---|
| 156 | + unsigned int *hw_settle_2; |
---|
99 | 157 | }; |
---|
100 | 158 | |
---|
101 | 159 | int qcom_vadc_scale(enum vadc_scale_fn_type scaletype, |
---|
.. | .. |
---|
104 | 162 | bool absolute, |
---|
105 | 163 | u16 adc_code, int *result_mdec); |
---|
106 | 164 | |
---|
| 165 | +struct qcom_adc5_scale_type { |
---|
| 166 | + int (*scale_fn)(const struct vadc_prescale_ratio *prescale, |
---|
| 167 | + const struct adc5_data *data, u16 adc_code, int *result); |
---|
| 168 | +}; |
---|
| 169 | + |
---|
| 170 | +int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, |
---|
| 171 | + const struct vadc_prescale_ratio *prescale, |
---|
| 172 | + const struct adc5_data *data, |
---|
| 173 | + u16 adc_code, int *result_mdec); |
---|
| 174 | + |
---|
107 | 175 | int qcom_vadc_decimation_from_dt(u32 value); |
---|
108 | 176 | |
---|
109 | 177 | #endif /* QCOM_VADC_COMMON_H */ |
---|