diff options
Diffstat (limited to 'include/linux/power')
-rw-r--r-- | include/linux/power/charger-manager.h | 50 | ||||
-rw-r--r-- | include/linux/power/max17042_battery.h | 17 |
2 files changed, 59 insertions, 8 deletions
diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h index 4f75e531c112..241065c9ce51 100644 --- a/include/linux/power/charger-manager.h +++ b/include/linux/power/charger-manager.h @@ -18,6 +18,8 @@ #include <linux/power_supply.h> enum data_source { + CM_BATTERY_PRESENT, + CM_NO_BATTERY, CM_FUEL_GAUGE, CM_CHARGER_STAT, }; @@ -29,6 +31,16 @@ enum polling_modes { CM_POLL_CHARGING_ONLY, }; +enum cm_event_types { + CM_EVENT_UNKNOWN = 0, + CM_EVENT_BATT_FULL, + CM_EVENT_BATT_IN, + CM_EVENT_BATT_OUT, + CM_EVENT_EXT_PWR_IN_OUT, + CM_EVENT_CHG_START_STOP, + CM_EVENT_OTHERS, +}; + /** * struct charger_global_desc * @rtc_name: the name of RTC used to wake up the system from suspend. @@ -38,11 +50,18 @@ enum polling_modes { * rtc_only_wakeup() returning false. * If the RTC given to CM is the only wakeup reason, * rtc_only_wakeup should return true. + * @assume_timer_stops_in_suspend: + * Assume that the jiffy timer stops in suspend-to-RAM. + * When enabled, CM does not rely on jiffies value in + * suspend_again and assumes that jiffies value does not + * change during suspend. */ struct charger_global_desc { char *rtc_name; bool (*rtc_only_wakeup)(void); + + bool assume_timer_stops_in_suspend; }; /** @@ -50,6 +69,11 @@ struct charger_global_desc { * @psy_name: the name of power-supply-class for charger manager * @polling_mode: * Determine which polling mode will be used + * @fullbatt_vchkdrop_ms: + * @fullbatt_vchkdrop_uV: + * Check voltage drop after the battery is fully charged. + * If it has dropped more than fullbatt_vchkdrop_uV after + * fullbatt_vchkdrop_ms, CM will restart charging. * @fullbatt_uV: voltage in microvolt * If it is not being charged and VBATT >= fullbatt_uV, * it is assumed to be full. @@ -76,6 +100,8 @@ struct charger_desc { enum polling_modes polling_mode; unsigned int polling_interval_ms; + unsigned int fullbatt_vchkdrop_ms; + unsigned int fullbatt_vchkdrop_uV; unsigned int fullbatt_uV; enum data_source battery_present; @@ -101,6 +127,11 @@ struct charger_desc { * @fuel_gauge: power_supply for fuel gauge * @charger_stat: array of power_supply for chargers * @charger_enabled: the state of charger + * @fullbatt_vchk_jiffies_at: + * jiffies at the time full battery check will occur. + * @fullbatt_vchk_uV: voltage in microvolt + * criteria for full battery + * @fullbatt_vchk_work: work queue for full battery check * @emergency_stop: * When setting true, stop charging * @last_temp_mC: the measured temperature in milli-Celsius @@ -121,6 +152,10 @@ struct charger_manager { bool charger_enabled; + unsigned long fullbatt_vchk_jiffies_at; + unsigned int fullbatt_vchk_uV; + struct delayed_work fullbatt_vchk_work; + int emergency_stop; int last_temp_mC; @@ -134,14 +169,13 @@ struct charger_manager { #ifdef CONFIG_CHARGER_MANAGER extern int setup_charger_manager(struct charger_global_desc *gd); extern bool cm_suspend_again(void); +extern void cm_notify_event(struct power_supply *psy, + enum cm_event_types type, char *msg); #else -static void __maybe_unused setup_charger_manager(struct charger_global_desc *gd) -{ } - -static bool __maybe_unused cm_suspend_again(void) -{ - return false; -} +static inline int setup_charger_manager(struct charger_global_desc *gd) +{ return 0; } +static inline bool cm_suspend_again(void) { return false; } +static inline void cm_notify_event(struct power_supply *psy, + enum cm_event_types type, char *msg) { } #endif - #endif /* _CHARGER_MANAGER_H */ diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h index e01b167e66f0..89dd84f47c6e 100644 --- a/include/linux/power/max17042_battery.h +++ b/include/linux/power/max17042_battery.h @@ -116,6 +116,18 @@ enum max17042_register { MAX17042_VFSOC = 0xFF, }; +/* Registers specific to max17047/50 */ +enum max17047_register { + MAX17047_QRTbl00 = 0x12, + MAX17047_FullSOCThr = 0x13, + MAX17047_QRTbl10 = 0x22, + MAX17047_QRTbl20 = 0x32, + MAX17047_V_empty = 0x3A, + MAX17047_QRTbl30 = 0x42, +}; + +enum max170xx_chip_type {MAX17042, MAX17047}; + /* * used for setting a register to a desired value * addr : address for a register @@ -144,6 +156,7 @@ struct max17042_config_data { u16 shdntimer; /* 0x03F */ /* App data */ + u16 full_soc_thresh; /* 0x13 */ u16 design_cap; /* 0x18 */ u16 ichgt_term; /* 0x1E */ @@ -162,6 +175,10 @@ struct max17042_config_data { u16 lavg_empty; /* 0x36 */ u16 dqacc; /* 0x45 */ u16 dpacc; /* 0x46 */ + u16 qrtbl00; /* 0x12 */ + u16 qrtbl10; /* 0x22 */ + u16 qrtbl20; /* 0x32 */ + u16 qrtbl30; /* 0x42 */ /* Cell technology from power_supply.h */ u16 cell_technology; |