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()
1020 * of charger cable.
1021 * @cm: the Charger Manager representing the battery.
1024 * state of charger cables for enabling or disabling charger(regulator) and
1025 * select the charger cable for charging among a number of external cable
1031 struct charger_regulator *charger; in charger_manager_register_extcon() local
1038 charger = &desc->charger_regulators[i]; in charger_manager_register_extcon()
1040 charger->consumer = regulator_get(cm->dev, in charger_manager_register_extcon()
1041 charger->regulator_name); in charger_manager_register_extcon()
1042 if (IS_ERR(charger->consumer)) { in charger_manager_register_extcon()
1043 dev_err(cm->dev, "Cannot find charger(%s)\n", in charger_manager_register_extcon()
1044 charger->regulator_name); in charger_manager_register_extcon()
1045 return PTR_ERR(charger->consumer); in charger_manager_register_extcon()
1047 charger->cm = cm; in charger_manager_register_extcon()
1049 for (j = 0; j < charger->num_cables; j++) { in charger_manager_register_extcon()
1050 struct charger_cable *cable = &charger->cables[j]; in charger_manager_register_extcon()
1054 dev_err(cm->dev, "Cannot initialize charger(%s)\n", in charger_manager_register_extcon()
1055 charger->regulator_name); in charger_manager_register_extcon()
1058 cable->charger = charger; in charger_manager_register_extcon()
1071 /* help function of sysfs node to control charger(regulator) */
1075 struct charger_regulator *charger in charger_name_show() local
1078 return sysfs_emit(buf, "%s\n", charger->regulator_name); in charger_name_show()
1084 struct charger_regulator *charger in charger_state_show() local
1088 if (!charger->externally_control) in charger_state_show()
1089 state = regulator_is_enabled(charger->consumer); in charger_state_show()
1097 struct charger_regulator *charger = container_of(attr, in charger_externally_control_show() local
1100 return sysfs_emit(buf, "%d\n", charger->externally_control); in charger_externally_control_show()
1107 struct charger_regulator *charger in charger_externally_control_store() local
1110 struct charger_manager *cm = charger->cm; in charger_externally_control_store()
1124 charger->externally_control = 0; in charger_externally_control_store()
1129 if (&desc->charger_regulators[i] != charger && in charger_externally_control_store()
1132 * At least, one charger is controlled by in charger_externally_control_store()
1133 * charger-manager in charger_externally_control_store()
1142 try_charger_enable(charger->cm, false); in charger_externally_control_store()
1143 charger->externally_control = externally_control; in charger_externally_control_store()
1144 try_charger_enable(charger->cm, true); in charger_externally_control_store()
1146 charger->externally_control = externally_control; in charger_externally_control_store()
1150 …"'%s' regulator should be controlled in charger-manager because charger-manager must need at least… in charger_externally_control_store()
1151 charger->regulator_name); in charger_externally_control_store()
1158 * charger_manager_prepare_sysfs - Prepare sysfs entry for each charger
1159 * @cm: the Charger Manager representing the battery.
1161 * This function add sysfs entry for charger(regulator) to control charger from
1163 * but only need one charger on specific case which is dependent on user
1165 * class/power_supply/battery/charger.[index]/externally_control'. For example,
1166 * if user enter 1 to 'sys/class/power_supply/battery/charger.[index]/
1167 * externally_control, this charger isn't controlled from charger-manager and
1173 struct charger_regulator *charger; in charger_manager_prepare_sysfs() local
1178 /* Create sysfs entry to control charger(regulator) */ in charger_manager_prepare_sysfs()
1180 charger = &desc->charger_regulators[i]; in charger_manager_prepare_sysfs()
1182 name = devm_kasprintf(cm->dev, GFP_KERNEL, "charger.%d", i); in charger_manager_prepare_sysfs()
1186 charger->attrs[0] = &charger->attr_name.attr; in charger_manager_prepare_sysfs()
1187 charger->attrs[1] = &charger->attr_state.attr; in charger_manager_prepare_sysfs()
1188 charger->attrs[2] = &charger->attr_externally_control.attr; in charger_manager_prepare_sysfs()
1189 charger->attrs[3] = NULL; in charger_manager_prepare_sysfs()
1191 charger->attr_grp.name = name; in charger_manager_prepare_sysfs()
1192 charger->attr_grp.attrs = charger->attrs; in charger_manager_prepare_sysfs()
1193 desc->sysfs_groups[i] = &charger->attr_grp; in charger_manager_prepare_sysfs()
1195 sysfs_attr_init(&charger->attr_name.attr); in charger_manager_prepare_sysfs()
1196 charger->attr_name.attr.name = "name"; in charger_manager_prepare_sysfs()
1197 charger->attr_name.attr.mode = 0444; in charger_manager_prepare_sysfs()
1198 charger->attr_name.show = charger_name_show; in charger_manager_prepare_sysfs()
1200 sysfs_attr_init(&charger->attr_state.attr); in charger_manager_prepare_sysfs()
1201 charger->attr_state.attr.name = "state"; in charger_manager_prepare_sysfs()
1202 charger->attr_state.attr.mode = 0444; in charger_manager_prepare_sysfs()
1203 charger->attr_state.show = charger_state_show; in charger_manager_prepare_sysfs()
1205 sysfs_attr_init(&charger->attr_externally_control.attr); in charger_manager_prepare_sysfs()
1206 charger->attr_externally_control.attr.name in charger_manager_prepare_sysfs()
1208 charger->attr_externally_control.attr.mode = 0644; in charger_manager_prepare_sysfs()
1209 charger->attr_externally_control.show in charger_manager_prepare_sysfs()
1211 charger->attr_externally_control.store in charger_manager_prepare_sysfs()
1219 charger->regulator_name, charger->externally_control); in charger_manager_prepare_sysfs()
1223 …dev_err(cm->dev, "Cannot register regulator because charger-manager must need at least one charger… in charger_manager_prepare_sysfs()
1275 .compatible = "charger-manager",
1344 /* battery charger regulators */ in of_cm_parse_desc()
1373 /* charger cables */ in of_cm_parse_desc()
1487 /* 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 system 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()
1656 { "charger-manager", 0 },
1738 .name = "charger-manager",
1769 MODULE_DESCRIPTION("Charger Manager");