Lines Matching defs: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
1020 * of charger cable.
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;
1038 charger = &desc->charger_regulators[i];
1040 charger->consumer = regulator_get(cm->dev,
1041 charger->regulator_name);
1042 if (IS_ERR(charger->consumer)) {
1043 dev_err(cm->dev, "Cannot find charger(%s)\n",
1044 charger->regulator_name);
1045 return PTR_ERR(charger->consumer);
1047 charger->cm = cm;
1049 for (j = 0; j < charger->num_cables; j++) {
1050 struct charger_cable *cable = &charger->cables[j];
1054 dev_err(cm->dev, "Cannot initialize charger(%s)\n",
1055 charger->regulator_name);
1058 cable->charger = charger;
1071 /* help function of sysfs node to control charger(regulator) */
1075 struct charger_regulator *charger
1078 return sysfs_emit(buf, "%s\n", charger->regulator_name);
1084 struct charger_regulator *charger
1088 if (!charger->externally_control)
1089 state = regulator_is_enabled(charger->consumer);
1097 struct charger_regulator *charger = container_of(attr,
1100 return sysfs_emit(buf, "%d\n", charger->externally_control);
1107 struct charger_regulator *charger
1110 struct charger_manager *cm = charger->cm;
1124 charger->externally_control = 0;
1129 if (&desc->charger_regulators[i] != charger &&
1132 * At least, one charger is controlled by
1133 * charger-manager
1142 try_charger_enable(charger->cm, false);
1143 charger->externally_control = externally_control;
1144 try_charger_enable(charger->cm, true);
1146 charger->externally_control = externally_control;
1150 "'%s' regulator should be controlled in charger-manager because charger-manager must need at least one charger for charging\n",
1151 charger->regulator_name);
1158 * charger_manager_prepare_sysfs - Prepare sysfs entry for each charger
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;
1178 /* Create sysfs entry to control charger(regulator) */
1180 charger = &desc->charger_regulators[i];
1182 name = devm_kasprintf(cm->dev, GFP_KERNEL, "charger.%d", i);
1186 charger->attrs[0] = &charger->attr_name.attr;
1187 charger->attrs[1] = &charger->attr_state.attr;
1188 charger->attrs[2] = &charger->attr_externally_control.attr;
1189 charger->attrs[3] = NULL;
1191 charger->attr_grp.name = name;
1192 charger->attr_grp.attrs = charger->attrs;
1193 desc->sysfs_groups[i] = &charger->attr_grp;
1195 sysfs_attr_init(&charger->attr_name.attr);
1196 charger->attr_name.attr.name = "name";
1197 charger->attr_name.attr.mode = 0444;
1198 charger->attr_name.show = charger_name_show;
1200 sysfs_attr_init(&charger->attr_state.attr);
1201 charger->attr_state.attr.name = "state";
1202 charger->attr_state.attr.mode = 0444;
1203 charger->attr_state.show = charger_state_show;
1205 sysfs_attr_init(&charger->attr_externally_control.attr);
1206 charger->attr_externally_control.attr.name
1208 charger->attr_externally_control.attr.mode = 0644;
1209 charger->attr_externally_control.show
1211 charger->attr_externally_control.store
1219 charger->regulator_name, charger->externally_control);
1223 dev_err(cm->dev, "Cannot register regulator because charger-manager must need at least one charger for charging battery\n");
1275 .compatible = "charger-manager",
1344 /* battery charger regulators */
1373 /* charger cables */
1487 /* Check if charger's supplies are present at probe */
1576 /* Register sysfs entry for charger(regulator) */
1589 dev_err(&pdev->dev, "Cannot register charger-manager with name \"%s\"\n",
1594 /* Register extcon device for charger cable */
1615 * initialization of charger-manager and then update current charging
1656 { "charger-manager", 0 },
1738 .name = "charger-manager",