Commit 9584051f authored by Jonghwa Lee's avatar Jonghwa Lee Committed by Sebastian Reichel

power: supply: charger-manager: Remove cm_notify_event function

cm_notify_event() was introduced to get an event associated with the
battery status externally (ie in board files), but no one ever used it.
Moreover it makes charger manager driver more complicated. Drop the
function and all data related to it to simplify the driver.
Signed-off-by: default avatarJonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: default avatarJonathan Bakker <xc-racer2@live.ca>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 033dea16
...@@ -434,25 +434,18 @@ static int try_charger_restart(struct charger_manager *cm) ...@@ -434,25 +434,18 @@ static int try_charger_restart(struct charger_manager *cm)
/** /**
* fullbatt_vchk - Check voltage drop some times after "FULL" event. * fullbatt_vchk - Check voltage drop some times after "FULL" event.
* @work: the work_struct appointing the function
* *
* If a user has designated "fullbatt_vchkdrop_ms/uV" values with * If a user has designated "fullbatt_vchkdrop_uV" values with
* charger_desc, Charger Manager checks voltage drop after the battery * charger_desc, Charger Manager checks voltage drop after the battery
* "FULL" event. It checks whether the voltage has dropped more than * "FULL" event. It checks whether the voltage has dropped more than
* fullbatt_vchkdrop_uV by calling this function after fullbatt_vchkrop_ms. * fullbatt_vchkdrop_uV by calling this function after fullbatt_vchkrop_ms.
*/ */
static void fullbatt_vchk(struct work_struct *work) static void fullbatt_vchk(struct charger_manager *cm)
{ {
struct delayed_work *dwork = to_delayed_work(work);
struct charger_manager *cm = container_of(dwork,
struct charger_manager, fullbatt_vchk_work);
struct charger_desc *desc = cm->desc; struct charger_desc *desc = cm->desc;
int batt_uV, err, diff; int batt_uV, err, diff;
/* remove the appointment for fullbatt_vchk */ if (!desc->fullbatt_vchkdrop_uV)
cm->fullbatt_vchk_jiffies_at = 0;
if (!desc->fullbatt_vchkdrop_uV || !desc->fullbatt_vchkdrop_ms)
return; return;
err = get_batt_uV(cm, &batt_uV); err = get_batt_uV(cm, &batt_uV);
...@@ -588,9 +581,11 @@ static int cm_check_thermal_status(struct charger_manager *cm) ...@@ -588,9 +581,11 @@ static int cm_check_thermal_status(struct charger_manager *cm)
} }
if (temp > upper_limit) if (temp > upper_limit)
ret = CM_EVENT_BATT_OVERHEAT; ret = CM_BATT_OVERHEAT;
else if (temp < lower_limit) else if (temp < lower_limit)
ret = CM_EVENT_BATT_COLD; ret = CM_BATT_COLD;
else
ret = CM_BATT_OK;
return ret; return ret;
} }
...@@ -635,7 +630,7 @@ static bool _cm_monitor(struct charger_manager *cm) ...@@ -635,7 +630,7 @@ static bool _cm_monitor(struct charger_manager *cm)
*/ */
} else if (!cm->emergency_stop && is_ext_pwr_online(cm) && } else if (!cm->emergency_stop && is_ext_pwr_online(cm) &&
!cm->charger_enabled) { !cm->charger_enabled) {
fullbatt_vchk(&cm->fullbatt_vchk_work.work); fullbatt_vchk(cm);
/* /*
* Check whether fully charged state to protect overcharge * Check whether fully charged state to protect overcharge
...@@ -648,7 +643,7 @@ static bool _cm_monitor(struct charger_manager *cm) ...@@ -648,7 +643,7 @@ static bool _cm_monitor(struct charger_manager *cm)
try_charger_enable(cm, false); try_charger_enable(cm, false);
fullbatt_vchk(&cm->fullbatt_vchk_work.work); fullbatt_vchk(cm);
} else { } else {
cm->emergency_stop = 0; cm->emergency_stop = 0;
if (is_ext_pwr_online(cm)) { if (is_ext_pwr_online(cm)) {
...@@ -750,66 +745,6 @@ static void cm_monitor_poller(struct work_struct *work) ...@@ -750,66 +745,6 @@ static void cm_monitor_poller(struct work_struct *work)
schedule_work(&setup_polling); schedule_work(&setup_polling);
} }
/**
* fullbatt_handler - Event handler for CM_EVENT_BATT_FULL
* @cm: the Charger Manager representing the battery.
*/
static void fullbatt_handler(struct charger_manager *cm)
{
struct charger_desc *desc = cm->desc;
if (!desc->fullbatt_vchkdrop_uV || !desc->fullbatt_vchkdrop_ms)
goto out;
if (cm_suspended)
device_set_wakeup_capable(cm->dev, true);
mod_delayed_work(cm_wq, &cm->fullbatt_vchk_work,
msecs_to_jiffies(desc->fullbatt_vchkdrop_ms));
cm->fullbatt_vchk_jiffies_at = jiffies + msecs_to_jiffies(
desc->fullbatt_vchkdrop_ms);
if (cm->fullbatt_vchk_jiffies_at == 0)
cm->fullbatt_vchk_jiffies_at = 1;
out:
dev_info(cm->dev, "EVENT_HANDLE: Battery Fully Charged\n");
power_supply_changed(cm->charger_psy);
}
/**
* battout_handler - Event handler for CM_EVENT_BATT_OUT
* @cm: the Charger Manager representing the battery.
*/
static void battout_handler(struct charger_manager *cm)
{
if (cm_suspended)
device_set_wakeup_capable(cm->dev, true);
if (!is_batt_present(cm)) {
dev_emerg(cm->dev, "Battery Pulled Out!\n");
power_supply_changed(cm->charger_psy);
} else {
power_supply_changed(cm->charger_psy);
}
}
/**
* misc_event_handler - Handler for other events
* @cm: the Charger Manager representing the battery.
* @type: the Charger Manager representing the battery.
*/
static void misc_event_handler(struct charger_manager *cm,
enum cm_event_types type)
{
if (cm_suspended)
device_set_wakeup_capable(cm->dev, true);
if (is_polling_required(cm) && cm->desc->polling_interval_ms)
schedule_work(&setup_polling);
power_supply_changed(cm->charger_psy);
}
static int charger_get_property(struct power_supply *psy, static int charger_get_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
...@@ -1000,21 +935,6 @@ static bool cm_setup_timer(void) ...@@ -1000,21 +935,6 @@ static bool cm_setup_timer(void)
mutex_lock(&cm_list_mtx); mutex_lock(&cm_list_mtx);
list_for_each_entry(cm, &cm_list, entry) { list_for_each_entry(cm, &cm_list, entry) {
unsigned int fbchk_ms = 0;
/* fullbatt_vchk is required. setup timer for that */
if (cm->fullbatt_vchk_jiffies_at) {
fbchk_ms = jiffies_to_msecs(cm->fullbatt_vchk_jiffies_at
- jiffies);
if (time_is_before_eq_jiffies(
cm->fullbatt_vchk_jiffies_at) ||
msecs_to_jiffies(fbchk_ms) < CM_JIFFIES_SMALL) {
fullbatt_vchk(&cm->fullbatt_vchk_work.work);
fbchk_ms = 0;
}
}
CM_MIN_VALID(wakeup_ms, fbchk_ms);
/* Skip if polling is not required for this CM */ /* Skip if polling is not required for this CM */
if (!is_polling_required(cm) && !cm->emergency_stop) if (!is_polling_required(cm) && !cm->emergency_stop)
continue; continue;
...@@ -1422,8 +1342,6 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) ...@@ -1422,8 +1342,6 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
of_property_read_u32(np, "cm-poll-interval", of_property_read_u32(np, "cm-poll-interval",
&desc->polling_interval_ms); &desc->polling_interval_ms);
of_property_read_u32(np, "cm-fullbatt-vchkdrop-ms",
&desc->fullbatt_vchkdrop_ms);
of_property_read_u32(np, "cm-fullbatt-vchkdrop-volt", of_property_read_u32(np, "cm-fullbatt-vchkdrop-volt",
&desc->fullbatt_vchkdrop_uV); &desc->fullbatt_vchkdrop_uV);
of_property_read_u32(np, "cm-fullbatt-voltage", &desc->fullbatt_uV); of_property_read_u32(np, "cm-fullbatt-voltage", &desc->fullbatt_uV);
...@@ -1585,9 +1503,8 @@ static int charger_manager_probe(struct platform_device *pdev) ...@@ -1585,9 +1503,8 @@ static int charger_manager_probe(struct platform_device *pdev)
if (desc->fullbatt_uV == 0) { if (desc->fullbatt_uV == 0) {
dev_info(&pdev->dev, "Ignoring full-battery voltage threshold as it is not supplied\n"); dev_info(&pdev->dev, "Ignoring full-battery voltage threshold as it is not supplied\n");
} }
if (!desc->fullbatt_vchkdrop_ms || !desc->fullbatt_vchkdrop_uV) { if (!desc->fullbatt_vchkdrop_uV) {
dev_info(&pdev->dev, "Disabling full-battery voltage drop checking mechanism as it is not supplied\n"); dev_info(&pdev->dev, "Disabling full-battery voltage drop checking mechanism as it is not supplied\n");
desc->fullbatt_vchkdrop_ms = 0;
desc->fullbatt_vchkdrop_uV = 0; desc->fullbatt_vchkdrop_uV = 0;
} }
if (desc->fullbatt_soc == 0) { if (desc->fullbatt_soc == 0) {
...@@ -1693,8 +1610,6 @@ static int charger_manager_probe(struct platform_device *pdev) ...@@ -1693,8 +1610,6 @@ static int charger_manager_probe(struct platform_device *pdev)
cm->charger_psy_desc.properties = properties; cm->charger_psy_desc.properties = properties;
cm->charger_psy_desc.num_properties = num_properties; cm->charger_psy_desc.num_properties = num_properties;
INIT_DELAYED_WORK(&cm->fullbatt_vchk_work, fullbatt_vchk);
/* Register sysfs entry for charger(regulator) */ /* Register sysfs entry for charger(regulator) */
ret = charger_manager_prepare_sysfs(cm); ret = charger_manager_prepare_sysfs(cm);
if (ret < 0) { if (ret < 0) {
...@@ -1834,8 +1749,6 @@ static bool cm_need_to_awake(void) ...@@ -1834,8 +1749,6 @@ static bool cm_need_to_awake(void)
static int cm_suspend_prepare(struct device *dev) static int cm_suspend_prepare(struct device *dev)
{ {
struct charger_manager *cm = dev_get_drvdata(dev);
if (cm_need_to_awake()) if (cm_need_to_awake())
return -EBUSY; return -EBUSY;
...@@ -1847,7 +1760,6 @@ static int cm_suspend_prepare(struct device *dev) ...@@ -1847,7 +1760,6 @@ static int cm_suspend_prepare(struct device *dev)
if (cm_timer_set) { if (cm_timer_set) {
cancel_work_sync(&setup_polling); cancel_work_sync(&setup_polling);
cancel_delayed_work_sync(&cm_monitor_work); cancel_delayed_work_sync(&cm_monitor_work);
cancel_delayed_work(&cm->fullbatt_vchk_work);
} }
return 0; return 0;
...@@ -1872,31 +1784,6 @@ static void cm_suspend_complete(struct device *dev) ...@@ -1872,31 +1784,6 @@ static void cm_suspend_complete(struct device *dev)
_cm_monitor(cm); _cm_monitor(cm);
/* Re-enqueue delayed work (fullbatt_vchk_work) */
if (cm->fullbatt_vchk_jiffies_at) {
unsigned long delay = 0;
unsigned long now = jiffies + CM_JIFFIES_SMALL;
if (time_after_eq(now, cm->fullbatt_vchk_jiffies_at)) {
delay = (unsigned long)((long)now
- (long)(cm->fullbatt_vchk_jiffies_at));
delay = jiffies_to_msecs(delay);
} else {
delay = 0;
}
/*
* Account for cm_suspend_duration_ms with assuming that
* timer stops in suspend.
*/
if (delay > cm_suspend_duration_ms)
delay -= cm_suspend_duration_ms;
else
delay = 0;
queue_delayed_work(cm_wq, &cm->fullbatt_vchk_work,
msecs_to_jiffies(delay));
}
device_set_wakeup_capable(cm->dev, false); device_set_wakeup_capable(cm->dev, false);
} }
...@@ -1938,56 +1825,6 @@ static void __exit charger_manager_cleanup(void) ...@@ -1938,56 +1825,6 @@ static void __exit charger_manager_cleanup(void)
} }
module_exit(charger_manager_cleanup); module_exit(charger_manager_cleanup);
/**
* cm_notify_event - charger driver notify Charger Manager of charger event
* @psy: pointer to instance of charger's power_supply
* @type: type of charger event
* @msg: optional message passed to uevent_notify function
*/
void cm_notify_event(struct power_supply *psy, enum cm_event_types type,
char *msg)
{
struct charger_manager *cm;
bool found_power_supply = false;
if (psy == NULL)
return;
mutex_lock(&cm_list_mtx);
list_for_each_entry(cm, &cm_list, entry) {
if (match_string(cm->desc->psy_charger_stat, -1,
psy->desc->name) >= 0) {
found_power_supply = true;
break;
}
}
mutex_unlock(&cm_list_mtx);
if (!found_power_supply)
return;
switch (type) {
case CM_EVENT_BATT_FULL:
fullbatt_handler(cm);
break;
case CM_EVENT_BATT_OUT:
battout_handler(cm);
break;
case CM_EVENT_BATT_IN:
case CM_EVENT_EXT_PWR_IN_OUT ... CM_EVENT_CHG_START_STOP:
misc_event_handler(cm, type);
break;
case CM_EVENT_UNKNOWN:
case CM_EVENT_OTHERS:
power_supply_changed(cm->charger_psy);
break;
default:
dev_err(cm->dev, "%s: type not specified\n", __func__);
break;
}
}
EXPORT_SYMBOL_GPL(cm_notify_event);
MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>"); MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
MODULE_DESCRIPTION("Charger Manager"); MODULE_DESCRIPTION("Charger Manager");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -31,16 +31,10 @@ enum polling_modes { ...@@ -31,16 +31,10 @@ enum polling_modes {
CM_POLL_CHARGING_ONLY, CM_POLL_CHARGING_ONLY,
}; };
enum cm_event_types { enum cm_batt_temp {
CM_EVENT_UNKNOWN = 0, CM_BATT_OK = 0,
CM_EVENT_BATT_FULL, CM_BATT_OVERHEAT,
CM_EVENT_BATT_IN, CM_BATT_COLD,
CM_EVENT_BATT_OUT,
CM_EVENT_BATT_OVERHEAT,
CM_EVENT_BATT_COLD,
CM_EVENT_EXT_PWR_IN_OUT,
CM_EVENT_CHG_START_STOP,
CM_EVENT_OTHERS,
}; };
/** /**
...@@ -131,11 +125,10 @@ struct charger_regulator { ...@@ -131,11 +125,10 @@ struct charger_regulator {
* @psy_name: the name of power-supply-class for charger manager * @psy_name: the name of power-supply-class for charger manager
* @polling_mode: * @polling_mode:
* Determine which polling mode will be used * Determine which polling mode will be used
* @fullbatt_vchkdrop_ms:
* @fullbatt_vchkdrop_uV: * @fullbatt_vchkdrop_uV:
* Check voltage drop after the battery is fully charged. * Check voltage drop after the battery is fully charged.
* If it has dropped more than fullbatt_vchkdrop_uV after * If it has dropped more than fullbatt_vchkdrop_uV
* fullbatt_vchkdrop_ms, CM will restart charging. * CM will restart charging.
* @fullbatt_uV: voltage in microvolt * @fullbatt_uV: voltage in microvolt
* If VBATT >= fullbatt_uV, it is assumed to be full. * If VBATT >= fullbatt_uV, it is assumed to be full.
* @fullbatt_soc: state of Charge in % * @fullbatt_soc: state of Charge in %
...@@ -172,7 +165,6 @@ struct charger_desc { ...@@ -172,7 +165,6 @@ struct charger_desc {
enum polling_modes polling_mode; enum polling_modes polling_mode;
unsigned int polling_interval_ms; unsigned int polling_interval_ms;
unsigned int fullbatt_vchkdrop_ms;
unsigned int fullbatt_vchkdrop_uV; unsigned int fullbatt_vchkdrop_uV;
unsigned int fullbatt_uV; unsigned int fullbatt_uV;
unsigned int fullbatt_soc; unsigned int fullbatt_soc;
...@@ -211,9 +203,6 @@ struct charger_desc { ...@@ -211,9 +203,6 @@ struct charger_desc {
* @charger_stat: array of power_supply for chargers * @charger_stat: array of power_supply for chargers
* @tzd_batt : thermal zone device for battery * @tzd_batt : thermal zone device for battery
* @charger_enabled: the state of charger * @charger_enabled: the state of charger
* @fullbatt_vchk_jiffies_at:
* jiffies at the time full battery check will occur.
* @fullbatt_vchk_work: work queue for full battery check
* @emergency_stop: * @emergency_stop:
* When setting true, stop charging * When setting true, stop charging
* @psy_name_buf: the name of power-supply-class for charger manager * @psy_name_buf: the name of power-supply-class for charger manager
...@@ -235,9 +224,6 @@ struct charger_manager { ...@@ -235,9 +224,6 @@ struct charger_manager {
#endif #endif
bool charger_enabled; bool charger_enabled;
unsigned long fullbatt_vchk_jiffies_at;
struct delayed_work fullbatt_vchk_work;
int emergency_stop; int emergency_stop;
char psy_name_buf[PSY_NAME_MAX + 1]; char psy_name_buf[PSY_NAME_MAX + 1];
...@@ -248,11 +234,4 @@ struct charger_manager { ...@@ -248,11 +234,4 @@ struct charger_manager {
u64 charging_end_time; u64 charging_end_time;
}; };
#if IS_ENABLED(CONFIG_CHARGER_MANAGER)
extern void cm_notify_event(struct power_supply *psy,
enum cm_event_types type, char *msg);
#else
static inline void cm_notify_event(struct power_supply *psy,
enum cm_event_types type, char *msg) { }
#endif
#endif /* _CHARGER_MANAGER_H */ #endif /* _CHARGER_MANAGER_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment