.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Universal power supply monitor class |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Copyright © 2003 Ian Molton <spyro@f2s.com> |
---|
7 | 8 | * |
---|
8 | 9 | * Modified: 2004, Oct Szabolcs Gyurko |
---|
9 | | - * |
---|
10 | | - * You may use this code as per GPL version 2 |
---|
11 | 10 | */ |
---|
12 | 11 | |
---|
13 | 12 | #ifndef __LINUX_POWER_SUPPLY_H__ |
---|
.. | .. |
---|
18 | 17 | #include <linux/leds.h> |
---|
19 | 18 | #include <linux/spinlock.h> |
---|
20 | 19 | #include <linux/notifier.h> |
---|
21 | | -#include <linux/types.h> |
---|
| 20 | +#include <linux/android_kabi.h> |
---|
22 | 21 | |
---|
23 | 22 | /* |
---|
24 | 23 | * All voltages, currents, charges, energies, time and temperatures in uV, |
---|
.. | .. |
---|
41 | 40 | POWER_SUPPLY_STATUS_FULL, |
---|
42 | 41 | }; |
---|
43 | 42 | |
---|
| 43 | +/* What algorithm is the charger using? */ |
---|
44 | 44 | enum { |
---|
45 | 45 | POWER_SUPPLY_CHARGE_TYPE_UNKNOWN = 0, |
---|
46 | 46 | POWER_SUPPLY_CHARGE_TYPE_NONE, |
---|
47 | | - POWER_SUPPLY_CHARGE_TYPE_TRICKLE, |
---|
48 | | - POWER_SUPPLY_CHARGE_TYPE_FAST, |
---|
49 | | - POWER_SUPPLY_CHARGE_TYPE_TAPER, |
---|
| 47 | + POWER_SUPPLY_CHARGE_TYPE_TRICKLE, /* slow speed */ |
---|
| 48 | + POWER_SUPPLY_CHARGE_TYPE_FAST, /* fast speed */ |
---|
| 49 | + POWER_SUPPLY_CHARGE_TYPE_STANDARD, /* normal speed */ |
---|
| 50 | + POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE, /* dynamically adjusted speed */ |
---|
| 51 | + POWER_SUPPLY_CHARGE_TYPE_CUSTOM, /* use CHARGE_CONTROL_* props */ |
---|
| 52 | + POWER_SUPPLY_CHARGE_TYPE_LONGLIFE, /* slow speed, longer life */ |
---|
| 53 | + |
---|
| 54 | + /* |
---|
| 55 | + * force to 50 to minimize the chances of userspace binary |
---|
| 56 | + * incompatibility on newer upstream kernels |
---|
| 57 | + */ |
---|
| 58 | + POWER_SUPPLY_CHARGE_TYPE_TAPER = 50, /* charging in CV phase */ |
---|
50 | 59 | }; |
---|
51 | 60 | |
---|
52 | 61 | enum { |
---|
.. | .. |
---|
60 | 69 | POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE, |
---|
61 | 70 | POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, |
---|
62 | 71 | POWER_SUPPLY_HEALTH_OVERCURRENT, |
---|
| 72 | + POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED, |
---|
63 | 73 | POWER_SUPPLY_HEALTH_WARM, |
---|
64 | 74 | POWER_SUPPLY_HEALTH_COOL, |
---|
65 | 75 | POWER_SUPPLY_HEALTH_HOT, |
---|
.. | .. |
---|
88 | 98 | POWER_SUPPLY_SCOPE_UNKNOWN = 0, |
---|
89 | 99 | POWER_SUPPLY_SCOPE_SYSTEM, |
---|
90 | 100 | POWER_SUPPLY_SCOPE_DEVICE, |
---|
91 | | -}; |
---|
92 | | - |
---|
93 | | -enum { |
---|
94 | | - POWER_SUPPLY_DP_DM_UNKNOWN = 0, |
---|
95 | | - POWER_SUPPLY_DP_DM_PREPARE = 1, |
---|
96 | | - POWER_SUPPLY_DP_DM_UNPREPARE = 2, |
---|
97 | | - POWER_SUPPLY_DP_DM_CONFIRMED_HVDCP3 = 3, |
---|
98 | | - POWER_SUPPLY_DP_DM_DP_PULSE = 4, |
---|
99 | | - POWER_SUPPLY_DP_DM_DM_PULSE = 5, |
---|
100 | | - POWER_SUPPLY_DP_DM_DP0P6_DMF = 6, |
---|
101 | | - POWER_SUPPLY_DP_DM_DP0P6_DM3P3 = 7, |
---|
102 | | - POWER_SUPPLY_DP_DM_DPF_DMF = 8, |
---|
103 | | - POWER_SUPPLY_DP_DM_DPR_DMR = 9, |
---|
104 | | - POWER_SUPPLY_DP_DM_HVDCP3_SUPPORTED = 10, |
---|
105 | | - POWER_SUPPLY_DP_DM_ICL_DOWN = 11, |
---|
106 | | - POWER_SUPPLY_DP_DM_ICL_UP = 12, |
---|
107 | | - POWER_SUPPLY_DP_DM_FORCE_5V = 13, |
---|
108 | | - POWER_SUPPLY_DP_DM_FORCE_9V = 14, |
---|
109 | | - POWER_SUPPLY_DP_DM_FORCE_12V = 15, |
---|
110 | | - POWER_SUPPLY_DP_DM_CONFIRMED_HVDCP3P5 = 16, |
---|
111 | | -}; |
---|
112 | | - |
---|
113 | | -enum { |
---|
114 | | - POWER_SUPPLY_PL_NONE, |
---|
115 | | - POWER_SUPPLY_PL_USBIN_USBIN, |
---|
116 | | - POWER_SUPPLY_PL_USBIN_USBIN_EXT, |
---|
117 | | - POWER_SUPPLY_PL_USBMID_USBMID, |
---|
118 | | -}; |
---|
119 | | - |
---|
120 | | -enum { |
---|
121 | | - POWER_SUPPLY_CHARGER_SEC_NONE = 0, |
---|
122 | | - POWER_SUPPLY_CHARGER_SEC_CP, |
---|
123 | | - POWER_SUPPLY_CHARGER_SEC_PL, |
---|
124 | | - POWER_SUPPLY_CHARGER_SEC_CP_PL, |
---|
125 | | -}; |
---|
126 | | - |
---|
127 | | -enum { |
---|
128 | | - POWER_SUPPLY_CP_NONE = 0, |
---|
129 | | - POWER_SUPPLY_CP_HVDCP3, |
---|
130 | | - POWER_SUPPLY_CP_HVDCP3P5, |
---|
131 | | - POWER_SUPPLY_CP_PPS, |
---|
132 | | - POWER_SUPPLY_CP_WIRELESS, |
---|
133 | | -}; |
---|
134 | | - |
---|
135 | | -enum { |
---|
136 | | - POWER_SUPPLY_CONNECTOR_TYPEC, |
---|
137 | | - POWER_SUPPLY_CONNECTOR_MICRO_USB, |
---|
138 | | -}; |
---|
139 | | - |
---|
140 | | -enum { |
---|
141 | | - POWER_SUPPLY_PL_STACKED_BATFET, |
---|
142 | | - POWER_SUPPLY_PL_NON_STACKED_BATFET, |
---|
143 | | -}; |
---|
144 | | - |
---|
145 | | -/* Parallel output connection topology */ |
---|
146 | | -enum { |
---|
147 | | - POWER_SUPPLY_PL_OUTPUT_NONE, |
---|
148 | | - POWER_SUPPLY_PL_OUTPUT_VPH, |
---|
149 | | - POWER_SUPPLY_PL_OUTPUT_VBAT, |
---|
150 | | -}; |
---|
151 | | - |
---|
152 | | -enum { |
---|
153 | | - POWER_SUPPLY_PD_INACTIVE = 0, |
---|
154 | | - POWER_SUPPLY_PD_ACTIVE, |
---|
155 | | - POWER_SUPPLY_PD_PPS_ACTIVE, |
---|
156 | | -}; |
---|
157 | | - |
---|
158 | | -enum { |
---|
159 | | - POWER_SUPPLY_QC_CTM_DISABLE = BIT(0), |
---|
160 | | - POWER_SUPPLY_QC_THERMAL_BALANCE_DISABLE = BIT(1), |
---|
161 | | - POWER_SUPPLY_QC_INOV_THERMAL_DISABLE = BIT(2), |
---|
162 | | -}; |
---|
163 | | - |
---|
164 | | -enum { |
---|
165 | | - POWER_SUPPLY_ALIGN_CHECKING = 0, |
---|
166 | | - POWER_SUPPLY_ALIGN_MOVE, |
---|
167 | | - POWER_SUPPLY_ALIGN_CENTERED, |
---|
168 | | - POWER_SUPPLY_ALIGN_ERROR, |
---|
169 | 101 | }; |
---|
170 | 102 | |
---|
171 | 103 | enum power_supply_property { |
---|
.. | .. |
---|
205 | 137 | POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, |
---|
206 | 138 | POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, |
---|
207 | 139 | POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, |
---|
| 140 | + POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD, /* in percents! */ |
---|
| 141 | + POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD, /* in percents! */ |
---|
208 | 142 | POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, |
---|
| 143 | + POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT, |
---|
| 144 | + POWER_SUPPLY_PROP_INPUT_POWER_LIMIT, |
---|
209 | 145 | POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, |
---|
210 | 146 | POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN, |
---|
211 | 147 | POWER_SUPPLY_PROP_ENERGY_FULL, |
---|
.. | .. |
---|
215 | 151 | POWER_SUPPLY_PROP_CAPACITY, /* in percents! */ |
---|
216 | 152 | POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, /* in percents! */ |
---|
217 | 153 | POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX, /* in percents! */ |
---|
| 154 | + POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, /* in percents! */ |
---|
218 | 155 | POWER_SUPPLY_PROP_CAPACITY_LEVEL, |
---|
219 | 156 | POWER_SUPPLY_PROP_TEMP, |
---|
220 | 157 | POWER_SUPPLY_PROP_TEMP_MAX, |
---|
.. | .. |
---|
234 | 171 | POWER_SUPPLY_PROP_PRECHARGE_CURRENT, |
---|
235 | 172 | POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, |
---|
236 | 173 | POWER_SUPPLY_PROP_CALIBRATE, |
---|
237 | | - /* Local extensions */ |
---|
238 | | - POWER_SUPPLY_PROP_USB_HC, |
---|
239 | | - POWER_SUPPLY_PROP_USB_OTG, |
---|
240 | | - POWER_SUPPLY_PROP_CHARGE_ENABLED, |
---|
241 | | - POWER_SUPPLY_PROP_SET_SHIP_MODE, |
---|
242 | | - POWER_SUPPLY_PROP_REAL_TYPE, |
---|
243 | | - POWER_SUPPLY_PROP_CHARGE_NOW_RAW, |
---|
244 | | - POWER_SUPPLY_PROP_CHARGE_NOW_ERROR, |
---|
245 | | - POWER_SUPPLY_PROP_CAPACITY_RAW, |
---|
246 | | - POWER_SUPPLY_PROP_BATTERY_CHARGING_ENABLED, |
---|
247 | | - POWER_SUPPLY_PROP_CHARGING_ENABLED, |
---|
248 | | - POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED, |
---|
249 | | - POWER_SUPPLY_PROP_STEP_CHARGING_STEP, |
---|
250 | | - POWER_SUPPLY_PROP_PIN_ENABLED, |
---|
251 | | - POWER_SUPPLY_PROP_INPUT_SUSPEND, |
---|
252 | | - POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION, |
---|
253 | | - POWER_SUPPLY_PROP_INPUT_CURRENT_MAX, |
---|
254 | | - POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM, |
---|
255 | | - POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED, |
---|
256 | | - POWER_SUPPLY_PROP_INPUT_VOLTAGE_SETTLED, |
---|
257 | | - POWER_SUPPLY_PROP_VCHG_LOOP_DBC_BYPASS, |
---|
258 | | - POWER_SUPPLY_PROP_CHARGE_COUNTER_SHADOW, |
---|
259 | | - POWER_SUPPLY_PROP_HI_POWER, |
---|
260 | | - POWER_SUPPLY_PROP_LOW_POWER, |
---|
261 | | - POWER_SUPPLY_PROP_COOL_TEMP, |
---|
262 | | - POWER_SUPPLY_PROP_WARM_TEMP, |
---|
263 | | - POWER_SUPPLY_PROP_COLD_TEMP, |
---|
264 | | - POWER_SUPPLY_PROP_HOT_TEMP, |
---|
265 | | - POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL, |
---|
266 | | - POWER_SUPPLY_PROP_RESISTANCE, |
---|
267 | | - POWER_SUPPLY_PROP_RESISTANCE_CAPACITIVE, |
---|
268 | | - POWER_SUPPLY_PROP_RESISTANCE_ID, /* in Ohms */ |
---|
269 | | - POWER_SUPPLY_PROP_RESISTANCE_NOW, |
---|
270 | | - POWER_SUPPLY_PROP_FLASH_CURRENT_MAX, |
---|
271 | | - POWER_SUPPLY_PROP_UPDATE_NOW, |
---|
272 | | - POWER_SUPPLY_PROP_ESR_COUNT, |
---|
273 | | - POWER_SUPPLY_PROP_BUCK_FREQ, |
---|
274 | | - POWER_SUPPLY_PROP_BOOST_CURRENT, |
---|
275 | | - POWER_SUPPLY_PROP_SAFETY_TIMER_ENABLE, |
---|
276 | | - POWER_SUPPLY_PROP_CHARGE_DONE, |
---|
277 | | - POWER_SUPPLY_PROP_FLASH_ACTIVE, |
---|
278 | | - POWER_SUPPLY_PROP_FLASH_TRIGGER, |
---|
279 | | - POWER_SUPPLY_PROP_FORCE_TLIM, |
---|
280 | | - POWER_SUPPLY_PROP_DP_DM, |
---|
281 | | - POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED, |
---|
282 | | - POWER_SUPPLY_PROP_INPUT_CURRENT_NOW, |
---|
283 | | - POWER_SUPPLY_PROP_CHARGE_QNOVO_ENABLE, |
---|
284 | | - POWER_SUPPLY_PROP_CURRENT_QNOVO, |
---|
285 | | - POWER_SUPPLY_PROP_VOLTAGE_QNOVO, |
---|
286 | | - POWER_SUPPLY_PROP_RERUN_AICL, |
---|
287 | | - POWER_SUPPLY_PROP_CYCLE_COUNT_ID, |
---|
288 | | - POWER_SUPPLY_PROP_SAFETY_TIMER_EXPIRED, |
---|
289 | | - POWER_SUPPLY_PROP_RESTRICTED_CHARGING, |
---|
290 | | - POWER_SUPPLY_PROP_CURRENT_CAPABILITY, |
---|
291 | | - POWER_SUPPLY_PROP_TYPEC_MODE, |
---|
292 | | - POWER_SUPPLY_PROP_TYPEC_CC_ORIENTATION, /* 0: N/C, 1: CC1, 2: CC2 */ |
---|
293 | | - POWER_SUPPLY_PROP_TYPEC_POWER_ROLE, |
---|
294 | | - POWER_SUPPLY_PROP_TYPEC_SRC_RP, |
---|
295 | | - POWER_SUPPLY_PROP_PD_ALLOWED, |
---|
296 | | - POWER_SUPPLY_PROP_PD_ACTIVE, |
---|
297 | | - POWER_SUPPLY_PROP_PD_IN_HARD_RESET, |
---|
298 | | - POWER_SUPPLY_PROP_PD_CURRENT_MAX, |
---|
299 | | - POWER_SUPPLY_PROP_PD_USB_SUSPEND_SUPPORTED, |
---|
300 | | - POWER_SUPPLY_PROP_CHARGER_TEMP, |
---|
301 | | - POWER_SUPPLY_PROP_CHARGER_TEMP_MAX, |
---|
302 | | - POWER_SUPPLY_PROP_PARALLEL_DISABLE, |
---|
303 | | - POWER_SUPPLY_PROP_PE_START, |
---|
304 | | - POWER_SUPPLY_PROP_SOC_REPORTING_READY, |
---|
305 | | - POWER_SUPPLY_PROP_DEBUG_BATTERY, |
---|
306 | | - POWER_SUPPLY_PROP_FCC_DELTA, |
---|
307 | | - POWER_SUPPLY_PROP_ICL_REDUCTION, |
---|
308 | | - POWER_SUPPLY_PROP_PARALLEL_MODE, |
---|
309 | | - POWER_SUPPLY_PROP_DIE_HEALTH, |
---|
310 | | - POWER_SUPPLY_PROP_CONNECTOR_HEALTH, |
---|
311 | | - POWER_SUPPLY_PROP_CTM_CURRENT_MAX, |
---|
312 | | - POWER_SUPPLY_PROP_HW_CURRENT_MAX, |
---|
313 | | - POWER_SUPPLY_PROP_PR_SWAP, |
---|
314 | | - POWER_SUPPLY_PROP_CC_STEP, |
---|
315 | | - POWER_SUPPLY_PROP_CC_STEP_SEL, |
---|
316 | | - POWER_SUPPLY_PROP_SW_JEITA_ENABLED, |
---|
317 | | - POWER_SUPPLY_PROP_PD_VOLTAGE_MAX, |
---|
318 | | - POWER_SUPPLY_PROP_PD_VOLTAGE_MIN, |
---|
319 | | - POWER_SUPPLY_PROP_SDP_CURRENT_MAX, |
---|
320 | | - POWER_SUPPLY_PROP_CONNECTOR_TYPE, |
---|
321 | | - POWER_SUPPLY_PROP_PARALLEL_BATFET_MODE, |
---|
322 | | - POWER_SUPPLY_PROP_PARALLEL_FCC_MAX, |
---|
323 | | - POWER_SUPPLY_PROP_MIN_ICL, |
---|
324 | | - POWER_SUPPLY_PROP_MOISTURE_DETECTED, |
---|
325 | | - POWER_SUPPLY_PROP_BATT_PROFILE_VERSION, |
---|
326 | | - POWER_SUPPLY_PROP_BATT_FULL_CURRENT, |
---|
327 | | - POWER_SUPPLY_PROP_RECHARGE_SOC, |
---|
328 | | - POWER_SUPPLY_PROP_HVDCP_OPTI_ALLOWED, |
---|
329 | | - POWER_SUPPLY_PROP_SMB_EN_MODE, |
---|
330 | | - POWER_SUPPLY_PROP_SMB_EN_REASON, |
---|
331 | | - POWER_SUPPLY_PROP_ESR_ACTUAL, |
---|
332 | | - POWER_SUPPLY_PROP_ESR_NOMINAL, |
---|
333 | | - POWER_SUPPLY_PROP_SOH, |
---|
334 | | - POWER_SUPPLY_PROP_CLEAR_SOH, |
---|
335 | | - POWER_SUPPLY_PROP_FORCE_RECHARGE, |
---|
336 | | - POWER_SUPPLY_PROP_FCC_STEPPER_ENABLE, |
---|
337 | | - POWER_SUPPLY_PROP_TOGGLE_STAT, |
---|
338 | | - POWER_SUPPLY_PROP_MAIN_FCC_MAX, |
---|
339 | | - POWER_SUPPLY_PROP_FG_RESET, |
---|
340 | | - POWER_SUPPLY_PROP_QC_OPTI_DISABLE, |
---|
341 | | - POWER_SUPPLY_PROP_CC_SOC, |
---|
342 | | - POWER_SUPPLY_PROP_BATT_AGE_LEVEL, |
---|
343 | | - POWER_SUPPLY_PROP_SCALE_MODE_EN, |
---|
344 | | - POWER_SUPPLY_PROP_VOLTAGE_VPH, |
---|
345 | | - POWER_SUPPLY_PROP_CHIP_VERSION, |
---|
346 | | - POWER_SUPPLY_PROP_THERM_ICL_LIMIT, |
---|
347 | | - POWER_SUPPLY_PROP_DC_RESET, |
---|
348 | | - POWER_SUPPLY_PROP_VOLTAGE_MAX_LIMIT, |
---|
349 | | - POWER_SUPPLY_PROP_REAL_CAPACITY, |
---|
350 | | - POWER_SUPPLY_PROP_FORCE_MAIN_ICL, |
---|
351 | | - POWER_SUPPLY_PROP_FORCE_MAIN_FCC, |
---|
352 | | - POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL, |
---|
353 | | - POWER_SUPPLY_PROP_ADAPTER_CC_MODE, |
---|
354 | | - POWER_SUPPLY_PROP_SKIN_HEALTH, |
---|
355 | | - POWER_SUPPLY_PROP_CHARGE_DISABLE, |
---|
356 | | - POWER_SUPPLY_PROP_ADAPTER_DETAILS, |
---|
357 | | - POWER_SUPPLY_PROP_DEAD_BATTERY, |
---|
358 | | - POWER_SUPPLY_PROP_VOLTAGE_FIFO, |
---|
359 | | - POWER_SUPPLY_PROP_CC_UAH, |
---|
360 | | - POWER_SUPPLY_PROP_OPERATING_FREQ, |
---|
361 | | - POWER_SUPPLY_PROP_AICL_DELAY, |
---|
362 | | - POWER_SUPPLY_PROP_AICL_ICL, |
---|
363 | | - POWER_SUPPLY_PROP_RTX, |
---|
364 | | - POWER_SUPPLY_PROP_CUTOFF_SOC, |
---|
365 | | - POWER_SUPPLY_PROP_SYS_SOC, |
---|
366 | | - POWER_SUPPLY_PROP_BATT_SOC, |
---|
367 | | - /* Capacity Estimation */ |
---|
368 | | - POWER_SUPPLY_PROP_BATT_CE_CTRL, |
---|
369 | | - POWER_SUPPLY_PROP_CHARGE_FULL_ESTIMATE, |
---|
370 | | - /* Resistance Estimaton */ |
---|
371 | | - POWER_SUPPLY_PROP_RESISTANCE_AVG, |
---|
372 | | - POWER_SUPPLY_PROP_RES_FILTER_COUNT, |
---|
373 | | - POWER_SUPPLY_PROP_AICL_DONE, |
---|
374 | | - POWER_SUPPLY_PROP_VOLTAGE_STEP, |
---|
375 | | - POWER_SUPPLY_PROP_OTG_FASTROLESWAP, |
---|
376 | | - POWER_SUPPLY_PROP_APSD_RERUN, |
---|
377 | | - POWER_SUPPLY_PROP_APSD_TIMEOUT, |
---|
| 174 | + POWER_SUPPLY_PROP_MANUFACTURE_YEAR, |
---|
| 175 | + POWER_SUPPLY_PROP_MANUFACTURE_MONTH, |
---|
| 176 | + POWER_SUPPLY_PROP_MANUFACTURE_DAY, |
---|
| 177 | +#if defined(CONFIG_NO_GKI) |
---|
378 | 178 | /* Charge pump properties */ |
---|
379 | | - POWER_SUPPLY_PROP_CP_STATUS1, |
---|
380 | | - POWER_SUPPLY_PROP_CP_STATUS2, |
---|
381 | | - POWER_SUPPLY_PROP_CP_ENABLE, |
---|
| 179 | + POWER_SUPPLY_PROP_CP_ALARM_STATUS, |
---|
| 180 | + POWER_SUPPLY_PROP_CP_BAT_OVP_ALARM, |
---|
| 181 | + POWER_SUPPLY_PROP_CP_BAT_OCP_ALARM, |
---|
| 182 | + POWER_SUPPLY_PROP_CP_BAT_UCP_ALARM, |
---|
| 183 | + POWER_SUPPLY_PROP_CP_BUS_OVP_ALARM, |
---|
| 184 | + POWER_SUPPLY_PROP_CP_BUS_OCP_ALARM, |
---|
| 185 | + POWER_SUPPLY_PROP_CP_BAT_THERM_ALARM, |
---|
| 186 | + POWER_SUPPLY_PROP_CP_BUS_THERM_ALARM, |
---|
| 187 | + POWER_SUPPLY_PROP_CP_DIE_THERM_ALARM, |
---|
| 188 | + POWER_SUPPLY_PROP_CP_FAULT_STATUS, |
---|
| 189 | + POWER_SUPPLY_PROP_CP_BAT_OVP_FAULT, |
---|
| 190 | + POWER_SUPPLY_PROP_CP_BAT_OCP_FAULT, |
---|
| 191 | + POWER_SUPPLY_PROP_CP_BUS_OVP_FAULT, |
---|
| 192 | + POWER_SUPPLY_PROP_CP_BUS_OCP_FAULT, |
---|
| 193 | + POWER_SUPPLY_PROP_CP_BAT_THERM_FAULT, |
---|
| 194 | + POWER_SUPPLY_PROP_CP_BUS_THERM_FAULT, |
---|
| 195 | + POWER_SUPPLY_PROP_CP_DIE_THERM_FAULT, |
---|
| 196 | + POWER_SUPPLY_PROP_CP_VBUS_ERROR_STATUS, |
---|
| 197 | + POWER_SUPPLY_PROP_CP_VBUS_HERROR_STATUS, |
---|
| 198 | + POWER_SUPPLY_PROP_CP_VBUS_LERROR_STATUS, |
---|
| 199 | + POWER_SUPPLY_PROP_CP_CHARGING_ENABLED, |
---|
| 200 | + POWER_SUPPLY_PROP_CP_WDT_EN, |
---|
| 201 | + POWER_SUPPLY_PROP_CP_VBUS, |
---|
| 202 | + POWER_SUPPLY_PROP_CP_IBUS, |
---|
382 | 203 | POWER_SUPPLY_PROP_CP_SWITCHER_EN, |
---|
383 | | - POWER_SUPPLY_PROP_CP_DIE_TEMP, |
---|
| 204 | + POWER_SUPPLY_PROP_CP_BAT_TEMPERATURE, |
---|
| 205 | + POWER_SUPPLY_PROP_CP_BUS_TEMPERATURE, |
---|
| 206 | + POWER_SUPPLY_PROP_CP_DIE_TEMPERATURE, |
---|
384 | 207 | POWER_SUPPLY_PROP_CP_ISNS, |
---|
385 | | - POWER_SUPPLY_PROP_CP_ISNS_SLAVE, |
---|
386 | 208 | POWER_SUPPLY_PROP_CP_TOGGLE_SWITCHER, |
---|
387 | 209 | POWER_SUPPLY_PROP_CP_IRQ_STATUS, |
---|
388 | 210 | POWER_SUPPLY_PROP_CP_ILIM, |
---|
389 | | - POWER_SUPPLY_PROP_IRQ_STATUS, |
---|
390 | | - POWER_SUPPLY_PROP_PARALLEL_OUTPUT_MODE, |
---|
391 | | - POWER_SUPPLY_PROP_ALIGNMENT, |
---|
392 | | - POWER_SUPPLY_PROP_MOISTURE_DETECTION_ENABLE, |
---|
393 | | - POWER_SUPPLY_PROP_CC_TOGGLE_ENABLE, |
---|
394 | | - POWER_SUPPLY_PROP_FG_TYPE, |
---|
395 | | - POWER_SUPPLY_PROP_CHARGER_STATUS, |
---|
396 | | - /* Local extensions of type int64_t */ |
---|
397 | | - POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT, |
---|
398 | | - POWER_SUPPLY_PROP_CHARGE_CHARGER_STATE, |
---|
| 211 | +#endif |
---|
399 | 212 | /* Properties of type `const char *' */ |
---|
400 | 213 | POWER_SUPPLY_PROP_MODEL_NAME, |
---|
401 | | - POWER_SUPPLY_PROP_PTMC_ID, |
---|
402 | 214 | POWER_SUPPLY_PROP_MANUFACTURER, |
---|
403 | | - POWER_SUPPLY_PROP_BATTERY_TYPE, |
---|
404 | | - POWER_SUPPLY_PROP_CYCLE_COUNTS, |
---|
405 | | - /* |
---|
406 | | - * Add local extensions for properties with string values between |
---|
407 | | - * MODEL_NAME and SERIAL_NUMBER. Don't add below SERIAL_NUMBER. |
---|
408 | | - */ |
---|
409 | 215 | POWER_SUPPLY_PROP_SERIAL_NUMBER, |
---|
410 | 216 | }; |
---|
411 | 217 | |
---|
.. | .. |
---|
422 | 228 | POWER_SUPPLY_TYPE_USB_PD, /* Power Delivery Port */ |
---|
423 | 229 | POWER_SUPPLY_TYPE_USB_PD_DRP, /* PD Dual Role Port */ |
---|
424 | 230 | POWER_SUPPLY_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */ |
---|
425 | | - POWER_SUPPLY_TYPE_USB_HVDCP, /* High Voltage DCP */ |
---|
426 | | - POWER_SUPPLY_TYPE_USB_HVDCP_3, /* Efficient High Voltage DCP */ |
---|
427 | | - POWER_SUPPLY_TYPE_USB_HVDCP_3P5, /* Efficient High Voltage DCP */ |
---|
428 | | - POWER_SUPPLY_TYPE_WIRELESS, /* Accessory Charger Adapters */ |
---|
429 | | - POWER_SUPPLY_TYPE_USB_FLOAT, /* Floating charger */ |
---|
430 | | - POWER_SUPPLY_TYPE_BMS, /* Battery Monitor System */ |
---|
431 | | - POWER_SUPPLY_TYPE_PARALLEL, /* Parallel Path */ |
---|
432 | | - POWER_SUPPLY_TYPE_MAIN, /* Main Path */ |
---|
433 | | - POWER_SUPPLY_TYPE_UFP, /* Type-C UFP */ |
---|
434 | | - POWER_SUPPLY_TYPE_DFP, /* Type-C DFP */ |
---|
| 231 | + POWER_SUPPLY_TYPE_WIRELESS, /* Wireless */ |
---|
| 232 | +#if defined(CONFIG_NO_GKI) |
---|
435 | 233 | POWER_SUPPLY_TYPE_CHARGE_PUMP, /* Charge Pump */ |
---|
| 234 | +#endif |
---|
436 | 235 | }; |
---|
437 | 236 | |
---|
438 | 237 | enum power_supply_usb_type { |
---|
.. | .. |
---|
448 | 247 | POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */ |
---|
449 | 248 | }; |
---|
450 | 249 | |
---|
451 | | -/* Indicates USB Type-C CC connection status */ |
---|
452 | | -enum power_supply_typec_mode { |
---|
453 | | - POWER_SUPPLY_TYPEC_NONE, |
---|
454 | | - |
---|
455 | | - /* Acting as source */ |
---|
456 | | - POWER_SUPPLY_TYPEC_SINK, /* Rd only */ |
---|
457 | | - POWER_SUPPLY_TYPEC_SINK_POWERED_CABLE, /* Rd/Ra */ |
---|
458 | | - POWER_SUPPLY_TYPEC_SINK_DEBUG_ACCESSORY,/* Rd/Rd */ |
---|
459 | | - POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER, /* Ra/Ra */ |
---|
460 | | - POWER_SUPPLY_TYPEC_POWERED_CABLE_ONLY, /* Ra only */ |
---|
461 | | - |
---|
462 | | - /* Acting as sink */ |
---|
463 | | - POWER_SUPPLY_TYPEC_SOURCE_DEFAULT, /* Rp default */ |
---|
464 | | - POWER_SUPPLY_TYPEC_SOURCE_MEDIUM, /* Rp 1.5A */ |
---|
465 | | - POWER_SUPPLY_TYPEC_SOURCE_HIGH, /* Rp 3A */ |
---|
466 | | - POWER_SUPPLY_TYPEC_DAM_DEFAULT, /* Rp-1.5A/Rp-3A */ |
---|
467 | | - POWER_SUPPLY_TYPEC_DAM_MEDIUM, /* Rp-Default/Rp-1.5A */ |
---|
468 | | - POWER_SUPPLY_TYPEC_DAM_HIGH, /* Rp-Default/Rp-3A */ |
---|
469 | | - |
---|
470 | | - /* Non Compliant */ |
---|
471 | | - POWER_SUPPLY_TYPEC_NON_COMPLIANT, |
---|
472 | | - POWER_SUPPLY_TYPEC_RP_STD_STD, /* Rp-Default/Rp-Default */ |
---|
473 | | - POWER_SUPPLY_TYPEC_RP_MED_MED, /* Rp-1.5A/Rp-1.5A */ |
---|
474 | | - POWER_SUPPLY_TYPEC_RP_HIGH_HIGH, /* Rp-3A/Rp-3A */ |
---|
475 | | -}; |
---|
476 | | - |
---|
477 | | -enum power_supply_typec_src_rp { |
---|
478 | | - POWER_SUPPLY_TYPEC_SRC_RP_STD, |
---|
479 | | - POWER_SUPPLY_TYPEC_SRC_RP_1P5A, |
---|
480 | | - POWER_SUPPLY_TYPEC_SRC_RP_3A |
---|
481 | | -}; |
---|
482 | | - |
---|
483 | | -enum power_supply_typec_power_role { |
---|
484 | | - POWER_SUPPLY_TYPEC_PR_NONE, /* CC lines in high-Z */ |
---|
485 | | - POWER_SUPPLY_TYPEC_PR_DUAL, |
---|
486 | | - POWER_SUPPLY_TYPEC_PR_SINK, |
---|
487 | | - POWER_SUPPLY_TYPEC_PR_SOURCE, |
---|
488 | | -}; |
---|
489 | | - |
---|
490 | 250 | enum power_supply_notifier_events { |
---|
491 | 251 | PSY_EVENT_PROP_CHANGED, |
---|
492 | 252 | }; |
---|
.. | .. |
---|
494 | 254 | union power_supply_propval { |
---|
495 | 255 | int intval; |
---|
496 | 256 | const char *strval; |
---|
497 | | - int64_t int64val; |
---|
498 | 257 | }; |
---|
499 | 258 | |
---|
500 | 259 | struct device_node; |
---|
.. | .. |
---|
508 | 267 | /* Driver private data */ |
---|
509 | 268 | void *drv_data; |
---|
510 | 269 | |
---|
| 270 | + /* Device specific sysfs attributes */ |
---|
| 271 | + const struct attribute_group **attr_grp; |
---|
| 272 | + |
---|
511 | 273 | char **supplied_to; |
---|
512 | 274 | size_t num_supplicants; |
---|
| 275 | + |
---|
| 276 | + ANDROID_KABI_RESERVE(1); |
---|
513 | 277 | }; |
---|
514 | 278 | |
---|
515 | 279 | /* Description of power supply */ |
---|
516 | 280 | struct power_supply_desc { |
---|
517 | 281 | const char *name; |
---|
518 | 282 | enum power_supply_type type; |
---|
519 | | - enum power_supply_usb_type *usb_types; |
---|
| 283 | + const enum power_supply_usb_type *usb_types; |
---|
520 | 284 | size_t num_usb_types; |
---|
521 | | - enum power_supply_property *properties; |
---|
| 285 | + const enum power_supply_property *properties; |
---|
522 | 286 | size_t num_properties; |
---|
523 | 287 | |
---|
524 | 288 | /* |
---|
.. | .. |
---|
551 | 315 | bool no_thermal; |
---|
552 | 316 | /* For APM emulation, think legacy userspace. */ |
---|
553 | 317 | int use_for_apm; |
---|
| 318 | + |
---|
| 319 | + ANDROID_KABI_RESERVE(1); |
---|
554 | 320 | }; |
---|
555 | 321 | |
---|
556 | 322 | struct power_supply { |
---|
.. | .. |
---|
592 | 358 | struct led_trigger *charging_blink_full_solid_trig; |
---|
593 | 359 | char *charging_blink_full_solid_trig_name; |
---|
594 | 360 | #endif |
---|
| 361 | + |
---|
| 362 | + ANDROID_KABI_RESERVE(1); |
---|
595 | 363 | }; |
---|
596 | 364 | |
---|
597 | 365 | /* |
---|
.. | .. |
---|
613 | 381 | int use_for_apm; |
---|
614 | 382 | }; |
---|
615 | 383 | |
---|
| 384 | +struct power_supply_battery_ocv_table { |
---|
| 385 | + int ocv; /* microVolts */ |
---|
| 386 | + int capacity; /* percent */ |
---|
| 387 | +}; |
---|
| 388 | + |
---|
| 389 | +struct power_supply_resistance_temp_table { |
---|
| 390 | + int temp; /* celsius */ |
---|
| 391 | + int resistance; /* internal resistance percent */ |
---|
| 392 | +}; |
---|
| 393 | + |
---|
| 394 | +#define POWER_SUPPLY_OCV_TEMP_MAX 20 |
---|
| 395 | + |
---|
616 | 396 | /* |
---|
617 | 397 | * This is the recommended struct to manage static battery parameters, |
---|
618 | 398 | * populated by power_supply_get_battery_info(). Most platform drivers should |
---|
.. | .. |
---|
626 | 406 | int energy_full_design_uwh; /* microWatt-hours */ |
---|
627 | 407 | int charge_full_design_uah; /* microAmp-hours */ |
---|
628 | 408 | int voltage_min_design_uv; /* microVolts */ |
---|
| 409 | + int voltage_max_design_uv; /* microVolts */ |
---|
| 410 | + int tricklecharge_current_ua; /* microAmps */ |
---|
629 | 411 | int precharge_current_ua; /* microAmps */ |
---|
| 412 | + int precharge_voltage_max_uv; /* microVolts */ |
---|
630 | 413 | int charge_term_current_ua; /* microAmps */ |
---|
| 414 | + int charge_restart_voltage_uv; /* microVolts */ |
---|
| 415 | + int overvoltage_limit_uv; /* microVolts */ |
---|
631 | 416 | int constant_charge_current_max_ua; /* microAmps */ |
---|
632 | 417 | int constant_charge_voltage_max_uv; /* microVolts */ |
---|
| 418 | + int factory_internal_resistance_uohm; /* microOhms */ |
---|
| 419 | + int ocv_temp[POWER_SUPPLY_OCV_TEMP_MAX];/* celsius */ |
---|
| 420 | + int temp_ambient_alert_min; /* celsius */ |
---|
| 421 | + int temp_ambient_alert_max; /* celsius */ |
---|
| 422 | + int temp_alert_min; /* celsius */ |
---|
| 423 | + int temp_alert_max; /* celsius */ |
---|
| 424 | + int temp_min; /* celsius */ |
---|
| 425 | + int temp_max; /* celsius */ |
---|
| 426 | + struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX]; |
---|
| 427 | + int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX]; |
---|
| 428 | + struct power_supply_resistance_temp_table *resist_table; |
---|
| 429 | + int resist_table_size; |
---|
| 430 | + |
---|
| 431 | + ANDROID_KABI_RESERVE(1); |
---|
633 | 432 | }; |
---|
634 | 433 | |
---|
635 | 434 | extern struct atomic_notifier_head power_supply_notifier; |
---|
.. | .. |
---|
640 | 439 | #ifdef CONFIG_OF |
---|
641 | 440 | extern struct power_supply *power_supply_get_by_phandle(struct device_node *np, |
---|
642 | 441 | const char *property); |
---|
| 442 | +extern int power_supply_get_by_phandle_array(struct device_node *np, |
---|
| 443 | + const char *property, |
---|
| 444 | + struct power_supply **psy, |
---|
| 445 | + ssize_t size); |
---|
643 | 446 | extern struct power_supply *devm_power_supply_get_by_phandle( |
---|
644 | 447 | struct device *dev, const char *property); |
---|
645 | 448 | #else /* !CONFIG_OF */ |
---|
646 | 449 | static inline struct power_supply * |
---|
647 | 450 | power_supply_get_by_phandle(struct device_node *np, const char *property) |
---|
648 | 451 | { return NULL; } |
---|
| 452 | +static inline int |
---|
| 453 | +power_supply_get_by_phandle_array(struct device_node *np, |
---|
| 454 | + const char *property, |
---|
| 455 | + struct power_supply **psy, |
---|
| 456 | + int size) |
---|
| 457 | +{ return 0; } |
---|
649 | 458 | static inline struct power_supply * |
---|
650 | 459 | devm_power_supply_get_by_phandle(struct device *dev, const char *property) |
---|
651 | 460 | { return NULL; } |
---|
.. | .. |
---|
653 | 462 | |
---|
654 | 463 | extern int power_supply_get_battery_info(struct power_supply *psy, |
---|
655 | 464 | struct power_supply_battery_info *info); |
---|
| 465 | +extern void power_supply_put_battery_info(struct power_supply *psy, |
---|
| 466 | + struct power_supply_battery_info *info); |
---|
| 467 | +extern int power_supply_ocv2cap_simple(struct power_supply_battery_ocv_table *table, |
---|
| 468 | + int table_len, int ocv); |
---|
| 469 | +extern struct power_supply_battery_ocv_table * |
---|
| 470 | +power_supply_find_ocv2cap_table(struct power_supply_battery_info *info, |
---|
| 471 | + int temp, int *table_len); |
---|
| 472 | +extern int power_supply_batinfo_ocv2cap(struct power_supply_battery_info *info, |
---|
| 473 | + int ocv, int temp); |
---|
| 474 | +extern int |
---|
| 475 | +power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *table, |
---|
| 476 | + int table_len, int temp); |
---|
656 | 477 | extern void power_supply_changed(struct power_supply *psy); |
---|
657 | 478 | extern int power_supply_am_i_supplied(struct power_supply *psy); |
---|
658 | 479 | extern int power_supply_set_input_current_limit_from_supplier( |
---|
.. | .. |
---|
668 | 489 | extern int power_supply_get_property(struct power_supply *psy, |
---|
669 | 490 | enum power_supply_property psp, |
---|
670 | 491 | union power_supply_propval *val); |
---|
| 492 | +#if IS_ENABLED(CONFIG_POWER_SUPPLY) |
---|
671 | 493 | extern int power_supply_set_property(struct power_supply *psy, |
---|
672 | 494 | enum power_supply_property psp, |
---|
673 | 495 | const union power_supply_propval *val); |
---|
| 496 | +#else |
---|
| 497 | +static inline int power_supply_set_property(struct power_supply *psy, |
---|
| 498 | + enum power_supply_property psp, |
---|
| 499 | + const union power_supply_propval *val) |
---|
| 500 | +{ return 0; } |
---|
| 501 | +#endif |
---|
674 | 502 | extern int power_supply_property_is_writeable(struct power_supply *psy, |
---|
675 | 503 | enum power_supply_property psp); |
---|
676 | 504 | extern void power_supply_external_power_changed(struct power_supply *psy); |
---|
.. | .. |
---|
754 | 582 | return 0; |
---|
755 | 583 | } |
---|
756 | 584 | |
---|
| 585 | +#ifdef CONFIG_POWER_SUPPLY_HWMON |
---|
| 586 | +int power_supply_add_hwmon_sysfs(struct power_supply *psy); |
---|
| 587 | +void power_supply_remove_hwmon_sysfs(struct power_supply *psy); |
---|
| 588 | +#else |
---|
| 589 | +static inline int power_supply_add_hwmon_sysfs(struct power_supply *psy) |
---|
| 590 | +{ |
---|
| 591 | + return 0; |
---|
| 592 | +} |
---|
| 593 | + |
---|
| 594 | +static inline |
---|
| 595 | +void power_supply_remove_hwmon_sysfs(struct power_supply *psy) {} |
---|
| 596 | +#endif |
---|
| 597 | + |
---|
757 | 598 | #endif /* __LINUX_POWER_SUPPLY_H__ */ |
---|