Lines Matching refs:charger

6  * This driver enables to monitor battery health and control charger
23 #include <linux/power/charger-manager.h>
222 /* If at least one of the charger is charging, return yes */
224 /* 1. The charger sholuld not be DISABLED */
237 /* 2. The charger should be online (ext-power) */
252 * 3. The charger should not be FULL, DISCHARGING,
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
448 * duration exceed 'discharging _max_duration_ms', charger cable is
675 WARN(cm_wq == NULL, "charger-manager: workqueue not initialized"
908 * charger_extcon_work - enable/diable charger according to the state
909 * of charger cable
920 ret = regulator_set_current_limit(cable->charger->consumer,
924 cable->charger->regulator_name, cable->name);
929 cable->charger->regulator_name,
938 * charger_extcon_notifier - receive the state of charger cable
952 * The newly state of charger cable.
958 * Setup work for controlling charger(regulator)
959 * according to charger cable.
968 * as the charger cable
981 * the charger cable among various external connector
1023 * of charger cable.
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;
1041 charger = &desc->charger_regulators[i];
1043 charger->consumer = regulator_get(cm->dev,
1044 charger->regulator_name);
1045 if (IS_ERR(charger->consumer)) {
1046 dev_err(cm->dev, "Cannot find charger(%s)\n",
1047 charger->regulator_name);
1048 return PTR_ERR(charger->consumer);
1050 charger->cm = cm;
1052 for (j = 0; j < charger->num_cables; j++) {
1053 struct charger_cable *cable = &charger->cables[j];
1057 dev_err(cm->dev, "Cannot initialize charger(%s)\n",
1058 charger->regulator_name);
1061 cable->charger = charger;
1074 /* help function of sysfs node to control charger(regulator) */
1078 struct charger_regulator *charger
1081 return sprintf(buf, "%s\n", charger->regulator_name);
1087 struct charger_regulator *charger
1091 if (!charger->externally_control)
1092 state = regulator_is_enabled(charger->consumer);
1100 struct charger_regulator *charger = container_of(attr,
1103 return sprintf(buf, "%d\n", charger->externally_control);
1110 struct charger_regulator *charger
1113 struct charger_manager *cm = charger->cm;
1127 charger->externally_control = 0;
1132 if (&desc->charger_regulators[i] != charger &&
1135 * At least, one charger is controlled by
1136 * charger-manager
1145 try_charger_enable(charger->cm, false);
1146 charger->externally_control = externally_control;
1147 try_charger_enable(charger->cm, true);
1149 charger->externally_control = externally_control;
1153 "'%s' regulator should be controlled in charger-manager because charger-manager must need at least one charger for charging\n",
1154 charger->regulator_name);
1161 * charger_manager_prepare_sysfs - Prepare sysfs entry for each charger
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;
1181 /* Create sysfs entry to control charger(regulator) */
1183 charger = &desc->charger_regulators[i];
1185 name = devm_kasprintf(cm->dev, GFP_KERNEL, "charger.%d", i);
1189 charger->attrs[0] = &charger->attr_name.attr;
1190 charger->attrs[1] = &charger->attr_state.attr;
1191 charger->attrs[2] = &charger->attr_externally_control.attr;
1192 charger->attrs[3] = NULL;
1194 charger->attr_grp.name = name;
1195 charger->attr_grp.attrs = charger->attrs;
1196 desc->sysfs_groups[i] = &charger->attr_grp;
1198 sysfs_attr_init(&charger->attr_name.attr);
1199 charger->attr_name.attr.name = "name";
1200 charger->attr_name.attr.mode = 0444;
1201 charger->attr_name.show = charger_name_show;
1203 sysfs_attr_init(&charger->attr_state.attr);
1204 charger->attr_state.attr.name = "state";
1205 charger->attr_state.attr.mode = 0444;
1206 charger->attr_state.show = charger_state_show;
1208 sysfs_attr_init(&charger->attr_externally_control.attr);
1209 charger->attr_externally_control.attr.name
1211 charger->attr_externally_control.attr.mode = 0644;
1212 charger->attr_externally_control.show
1214 charger->attr_externally_control.store
1222 charger->regulator_name, charger->externally_control);
1226 dev_err(cm->dev, "Cannot register regulator because charger-manager must need at least one charger for charging battery\n");
1278 .compatible = "charger-manager",
1347 /* battery charger regulators */
1376 /* charger cables */
1490 /* Check if charger's supplies are present at probe */
1577 /* Register sysfs entry for charger(regulator) */
1590 dev_err(&pdev->dev, "Cannot register charger-manager with name \"%s\"\n",
1595 /* Register extcon device for charger cable */
1616 * initialization of charger-manager and then update current charging
1659 { "charger-manager", 0 },
1741 .name = "charger-manager",