Lines Matching full:charger

6  * This driver enables to monitor battery health and control charger
8 * Charger manager depends on other devices. Register this later than
23 #include <linux/power/charger-manager.h>
40 { "FAST-CHARGER", EXTCON_CHG_USB_FAST },
41 { "SLOW-CHARGER", EXTCON_CHG_USB_SLOW },
93 * @cm: the Charger Manager representing the battery.
145 * @cm: the Charger Manager representing the battery.
181 * @cm: the Charger Manager representing the battery.
209 * @cm: the Charger Manager representing the battery.
222 /* If at least one of the charger is charging, return yes */ in is_charging()
224 /* 1. The charger sholuld not be DISABLED */ in is_charging()
237 /* 2. The charger should be online (ext-power) */ in is_charging()
252 * 3. The charger should not be FULL, DISCHARGING, in is_charging()
278 * @cm: the Charger Manager representing the battery.
341 * @cm: the Charger Manager representing the battery.
364 * @cm: the Charger Manager representing the battery.
367 * Note that Charger Manager keeps the charger enabled regardless whether
368 * the charger is charging or not (because battery is full or no external
423 * even if charger was enabled at the other places in try_charger_enable()
444 * @cm: the Charger Manager representing the battery.
448 * duration exceed 'discharging _max_duration_ms', charger cable is
565 * @cm: the Charger Manager representing the battery.
600 * @cm: the Charger Manager representing the battery.
675 WARN(cm_wq == NULL, "charger-manager: workqueue not initialized" in _setup_polling()
854 * Returns true if the alarm is set for Charger Manager to use.
857 * cm_setup_timer does not need to set an alarm for Charger Manager,
893 pr_info("Charger Manager wakeup timer: %u ms\n", wakeup_ms); in cm_setup_timer()
908 * charger_extcon_work - enable/diable charger according to the state
909 * of charger cable
920 ret = regulator_set_current_limit(cable->charger->consumer, in charger_extcon_work()
924 cable->charger->regulator_name, cable->name); in charger_extcon_work()
929 cable->charger->regulator_name, in charger_extcon_work()
938 * charger_extcon_notifier - receive the state of charger cable
952 * The newly state of charger cable. in charger_extcon_notifier()
958 * Setup work for controlling charger(regulator) in charger_extcon_notifier()
959 * according to charger cable. in charger_extcon_notifier()
968 * as the charger cable
970 * @cm: the Charger Manager representing the battery.
971 * @cable: the Charger cable representing the external connector.
980 * Charger manager use Extcon framework to identify in charger_extcon_init()
981 * the charger cable among various external connector in charger_extcon_init()
1023 * of charger cable.
1024 * @cm: the Charger Manager representing the battery.
1027 * state of charger cables for enabling or disabling charger(regulator) and
1028 * select the charger cable for charging among a number of external cable
1034 struct charger_regulator *charger; in charger_manager_register_extcon() local
1041 charger = &desc->charger_regulators[i]; in charger_manager_register_extcon()
1043 charger->consumer = regulator_get(cm->dev, in charger_manager_register_extcon()
1044 charger->regulator_name); in charger_manager_register_extcon()
1045 if (IS_ERR(charger->consumer)) { in charger_manager_register_extcon()
1046 dev_err(cm->dev, "Cannot find charger(%s)\n", in charger_manager_register_extcon()
1047 charger->regulator_name); in charger_manager_register_extcon()
1048 return PTR_ERR(charger->consumer); in charger_manager_register_extcon()
1050 charger->cm = cm; in charger_manager_register_extcon()
1052 for (j = 0; j < charger->num_cables; j++) { in charger_manager_register_extcon()
1053 struct charger_cable *cable = &charger->cables[j]; in charger_manager_register_extcon()
1057 dev_err(cm->dev, "Cannot initialize charger(%s)\n", in charger_manager_register_extcon()
1058 charger->regulator_name); in charger_manager_register_extcon()
1061 cable->charger = charger; in charger_manager_register_extcon()
1074 /* help function of sysfs node to control charger(regulator) */
1078 struct charger_regulator *charger in charger_name_show() local
1081 return sprintf(buf, "%s\n", charger->regulator_name); in charger_name_show()
1087 struct charger_regulator *charger in charger_state_show() local
1091 if (!charger->externally_control) in charger_state_show()
1092 state = regulator_is_enabled(charger->consumer); in charger_state_show()
1100 struct charger_regulator *charger = container_of(attr, in charger_externally_control_show() local
1103 return sprintf(buf, "%d\n", charger->externally_control); in charger_externally_control_show()
1110 struct charger_regulator *charger in charger_externally_control_store() local
1113 struct charger_manager *cm = charger->cm; in charger_externally_control_store()
1127 charger->externally_control = 0; in charger_externally_control_store()
1132 if (&desc->charger_regulators[i] != charger && in charger_externally_control_store()
1135 * At least, one charger is controlled by in charger_externally_control_store()
1136 * charger-manager in charger_externally_control_store()
1145 try_charger_enable(charger->cm, false); in charger_externally_control_store()
1146 charger->externally_control = externally_control; in charger_externally_control_store()
1147 try_charger_enable(charger->cm, true); in charger_externally_control_store()
1149 charger->externally_control = externally_control; in charger_externally_control_store()
1153 …"'%s' regulator should be controlled in charger-manager because charger-manager must need at least… in charger_externally_control_store()
1154 charger->regulator_name); in charger_externally_control_store()
1161 * charger_manager_prepare_sysfs - Prepare sysfs entry for each charger
1162 * @cm: the Charger Manager representing the battery.
1164 * This function add sysfs entry for charger(regulator) to control charger from
1166 * but only need one charger on specific case which is dependent on user
1168 * class/power_supply/battery/charger.[index]/externally_control'. For example,
1169 * if user enter 1 to 'sys/class/power_supply/battery/charger.[index]/
1170 * externally_control, this charger isn't controlled from charger-manager and
1176 struct charger_regulator *charger; in charger_manager_prepare_sysfs() local
1181 /* Create sysfs entry to control charger(regulator) */ in charger_manager_prepare_sysfs()
1183 charger = &desc->charger_regulators[i]; in charger_manager_prepare_sysfs()
1185 name = devm_kasprintf(cm->dev, GFP_KERNEL, "charger.%d", i); in charger_manager_prepare_sysfs()
1189 charger->attrs[0] = &charger->attr_name.attr; in charger_manager_prepare_sysfs()
1190 charger->attrs[1] = &charger->attr_state.attr; in charger_manager_prepare_sysfs()
1191 charger->attrs[2] = &charger->attr_externally_control.attr; in charger_manager_prepare_sysfs()
1192 charger->attrs[3] = NULL; in charger_manager_prepare_sysfs()
1194 charger->attr_grp.name = name; in charger_manager_prepare_sysfs()
1195 charger->attr_grp.attrs = charger->attrs; in charger_manager_prepare_sysfs()
1196 desc->sysfs_groups[i] = &charger->attr_grp; in charger_manager_prepare_sysfs()
1198 sysfs_attr_init(&charger->attr_name.attr); in charger_manager_prepare_sysfs()
1199 charger->attr_name.attr.name = "name"; in charger_manager_prepare_sysfs()
1200 charger->attr_name.attr.mode = 0444; in charger_manager_prepare_sysfs()
1201 charger->attr_name.show = charger_name_show; in charger_manager_prepare_sysfs()
1203 sysfs_attr_init(&charger->attr_state.attr); in charger_manager_prepare_sysfs()
1204 charger->attr_state.attr.name = "state"; in charger_manager_prepare_sysfs()
1205 charger->attr_state.attr.mode = 0444; in charger_manager_prepare_sysfs()
1206 charger->attr_state.show = charger_state_show; in charger_manager_prepare_sysfs()
1208 sysfs_attr_init(&charger->attr_externally_control.attr); in charger_manager_prepare_sysfs()
1209 charger->attr_externally_control.attr.name in charger_manager_prepare_sysfs()
1211 charger->attr_externally_control.attr.mode = 0644; in charger_manager_prepare_sysfs()
1212 charger->attr_externally_control.show in charger_manager_prepare_sysfs()
1214 charger->attr_externally_control.store in charger_manager_prepare_sysfs()
1222 charger->regulator_name, charger->externally_control); in charger_manager_prepare_sysfs()
1226 …dev_err(cm->dev, "Cannot register regulator because charger-manager must need at least one charger in charger_manager_prepare_sysfs()
1278 .compatible = "charger-manager",
1346 /* battery charger regulators */ in of_cm_parse_desc()
1375 /* charger cables */ in of_cm_parse_desc()
1489 /* Check if charger's supplies are present at probe */ in charger_manager_probe()
1576 /* Register sysfs entry for charger(regulator) */ in charger_manager_probe()
1589 dev_err(&pdev->dev, "Cannot register charger-manager with name \"%s\"\n", in charger_manager_probe()
1594 /* Register extcon device for charger cable */ in charger_manager_probe()
1607 * Charger-manager is capable of waking up the systme from sleep in charger_manager_probe()
1614 * Charger-manager have to check the charging state right after in charger_manager_probe()
1615 * initialization of charger-manager and then update current charging in charger_manager_probe()
1658 { "charger-manager", 0 },
1740 .name = "charger-manager",
1771 MODULE_DESCRIPTION("Charger Manager");