| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2011 Samsung Electronics Co., Ltd. |
|---|
| 3 | 4 | * MyungJoo.Ham <myungjoo.ham@samsung.com> |
|---|
| .. | .. |
|---|
| 7 | 8 | * monitor charging even in the context of suspend-to-RAM with |
|---|
| 8 | 9 | * an interface combining the chargers. |
|---|
| 9 | 10 | * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 12 | | - * published by the Free Software Foundation. |
|---|
| 13 | 11 | **/ |
|---|
| 14 | 12 | |
|---|
| 15 | 13 | #ifndef _CHARGER_MANAGER_H |
|---|
| .. | .. |
|---|
| 33 | 31 | CM_POLL_CHARGING_ONLY, |
|---|
| 34 | 32 | }; |
|---|
| 35 | 33 | |
|---|
| 36 | | -enum cm_event_types { |
|---|
| 37 | | - CM_EVENT_UNKNOWN = 0, |
|---|
| 38 | | - CM_EVENT_BATT_FULL, |
|---|
| 39 | | - CM_EVENT_BATT_IN, |
|---|
| 40 | | - CM_EVENT_BATT_OUT, |
|---|
| 41 | | - CM_EVENT_BATT_OVERHEAT, |
|---|
| 42 | | - CM_EVENT_BATT_COLD, |
|---|
| 43 | | - CM_EVENT_EXT_PWR_IN_OUT, |
|---|
| 44 | | - CM_EVENT_CHG_START_STOP, |
|---|
| 45 | | - CM_EVENT_OTHERS, |
|---|
| 34 | +enum cm_batt_temp { |
|---|
| 35 | + CM_BATT_OK = 0, |
|---|
| 36 | + CM_BATT_OVERHEAT, |
|---|
| 37 | + CM_BATT_COLD, |
|---|
| 46 | 38 | }; |
|---|
| 47 | 39 | |
|---|
| 48 | 40 | /** |
|---|
| 49 | 41 | * struct charger_cable |
|---|
| 50 | 42 | * @extcon_name: the name of extcon device. |
|---|
| 51 | | - * @name: the name of charger cable(external connector). |
|---|
| 43 | + * @name: the name of the cable connector |
|---|
| 52 | 44 | * @extcon_dev: the extcon device. |
|---|
| 53 | 45 | * @wq: the workqueue to control charger according to the state of |
|---|
| 54 | 46 | * charger cable. If charger cable is attached, enable charger. |
|---|
| .. | .. |
|---|
| 64 | 56 | struct charger_cable { |
|---|
| 65 | 57 | const char *extcon_name; |
|---|
| 66 | 58 | const char *name; |
|---|
| 59 | + struct extcon_dev *extcon_dev; |
|---|
| 60 | + u64 extcon_type; |
|---|
| 67 | 61 | |
|---|
| 68 | 62 | /* The charger-manager use Extcon framework */ |
|---|
| 69 | | - struct extcon_specific_cable_nb extcon_dev; |
|---|
| 70 | 63 | struct work_struct wq; |
|---|
| 71 | 64 | struct notifier_block nb; |
|---|
| 72 | 65 | |
|---|
| .. | .. |
|---|
| 119 | 112 | struct charger_cable *cables; |
|---|
| 120 | 113 | int num_cables; |
|---|
| 121 | 114 | |
|---|
| 122 | | - struct attribute_group attr_g; |
|---|
| 115 | + struct attribute_group attr_grp; |
|---|
| 123 | 116 | struct device_attribute attr_name; |
|---|
| 124 | 117 | struct device_attribute attr_state; |
|---|
| 125 | 118 | struct device_attribute attr_externally_control; |
|---|
| .. | .. |
|---|
| 133 | 126 | * @psy_name: the name of power-supply-class for charger manager |
|---|
| 134 | 127 | * @polling_mode: |
|---|
| 135 | 128 | * Determine which polling mode will be used |
|---|
| 136 | | - * @fullbatt_vchkdrop_ms: |
|---|
| 137 | 129 | * @fullbatt_vchkdrop_uV: |
|---|
| 138 | 130 | * Check voltage drop after the battery is fully charged. |
|---|
| 139 | | - * If it has dropped more than fullbatt_vchkdrop_uV after |
|---|
| 140 | | - * fullbatt_vchkdrop_ms, CM will restart charging. |
|---|
| 131 | + * If it has dropped more than fullbatt_vchkdrop_uV |
|---|
| 132 | + * CM will restart charging. |
|---|
| 141 | 133 | * @fullbatt_uV: voltage in microvolt |
|---|
| 142 | 134 | * If VBATT >= fullbatt_uV, it is assumed to be full. |
|---|
| 143 | 135 | * @fullbatt_soc: state of Charge in % |
|---|
| .. | .. |
|---|
| 174 | 166 | enum polling_modes polling_mode; |
|---|
| 175 | 167 | unsigned int polling_interval_ms; |
|---|
| 176 | 168 | |
|---|
| 177 | | - unsigned int fullbatt_vchkdrop_ms; |
|---|
| 178 | 169 | unsigned int fullbatt_vchkdrop_uV; |
|---|
| 179 | 170 | unsigned int fullbatt_uV; |
|---|
| 180 | 171 | unsigned int fullbatt_soc; |
|---|
| .. | .. |
|---|
| 186 | 177 | |
|---|
| 187 | 178 | int num_charger_regulators; |
|---|
| 188 | 179 | struct charger_regulator *charger_regulators; |
|---|
| 180 | + const struct attribute_group **sysfs_groups; |
|---|
| 189 | 181 | |
|---|
| 190 | 182 | const char *psy_fuel_gauge; |
|---|
| 191 | 183 | |
|---|
| .. | .. |
|---|
| 212 | 204 | * @charger_stat: array of power_supply for chargers |
|---|
| 213 | 205 | * @tzd_batt : thermal zone device for battery |
|---|
| 214 | 206 | * @charger_enabled: the state of charger |
|---|
| 215 | | - * @fullbatt_vchk_jiffies_at: |
|---|
| 216 | | - * jiffies at the time full battery check will occur. |
|---|
| 217 | | - * @fullbatt_vchk_work: work queue for full battery check |
|---|
| 218 | 207 | * @emergency_stop: |
|---|
| 219 | 208 | * When setting true, stop charging |
|---|
| 220 | 209 | * @psy_name_buf: the name of power-supply-class for charger manager |
|---|
| .. | .. |
|---|
| 225 | 214 | * saved status of battery before entering suspend-to-RAM |
|---|
| 226 | 215 | * @charging_start_time: saved start time of enabling charging |
|---|
| 227 | 216 | * @charging_end_time: saved end time of disabling charging |
|---|
| 217 | + * @battery_status: Current battery status |
|---|
| 228 | 218 | */ |
|---|
| 229 | 219 | struct charger_manager { |
|---|
| 230 | 220 | struct list_head entry; |
|---|
| .. | .. |
|---|
| 236 | 226 | #endif |
|---|
| 237 | 227 | bool charger_enabled; |
|---|
| 238 | 228 | |
|---|
| 239 | | - unsigned long fullbatt_vchk_jiffies_at; |
|---|
| 240 | | - struct delayed_work fullbatt_vchk_work; |
|---|
| 241 | | - |
|---|
| 242 | 229 | int emergency_stop; |
|---|
| 243 | 230 | |
|---|
| 244 | 231 | char psy_name_buf[PSY_NAME_MAX + 1]; |
|---|
| .. | .. |
|---|
| 247 | 234 | |
|---|
| 248 | 235 | u64 charging_start_time; |
|---|
| 249 | 236 | u64 charging_end_time; |
|---|
| 237 | + |
|---|
| 238 | + int battery_status; |
|---|
| 250 | 239 | }; |
|---|
| 251 | 240 | |
|---|
| 252 | | -#ifdef CONFIG_CHARGER_MANAGER |
|---|
| 253 | | -extern void cm_notify_event(struct power_supply *psy, |
|---|
| 254 | | - enum cm_event_types type, char *msg); |
|---|
| 255 | | -#else |
|---|
| 256 | | -static inline void cm_notify_event(struct power_supply *psy, |
|---|
| 257 | | - enum cm_event_types type, char *msg) { } |
|---|
| 258 | | -#endif |
|---|
| 259 | 241 | #endif /* _CHARGER_MANAGER_H */ |
|---|