Lines Matching full:charger
3 * Power supply driver for ChromeOS EC based USB PD Charger.
26 #define DRV_NAME "cros-usbpd-charger"
42 struct charger_data *charger; member
82 return port->port_number >= port->charger->num_usbpd_ports; in cros_usbpd_charger_port_is_dedicated()
85 static int cros_usbpd_charger_ec_command(struct charger_data *charger, in cros_usbpd_charger_ec_command() argument
93 struct cros_ec_dev *ec_dev = charger->ec_dev; in cros_usbpd_charger_ec_command()
109 ret = cros_ec_cmd_xfer_status(charger->ec_device, msg); in cros_usbpd_charger_ec_command()
117 static int cros_usbpd_charger_get_num_ports(struct charger_data *charger) in cros_usbpd_charger_get_num_ports() argument
122 ret = cros_usbpd_charger_ec_command(charger, 0, in cros_usbpd_charger_get_num_ports()
131 static int cros_usbpd_charger_get_usbpd_num_ports(struct charger_data *charger) in cros_usbpd_charger_get_usbpd_num_ports() argument
136 ret = cros_usbpd_charger_ec_command(charger, 0, EC_CMD_USB_PD_PORTS, in cros_usbpd_charger_get_usbpd_num_ports()
146 struct charger_data *charger = port->charger; in cros_usbpd_charger_get_discovery_info() local
153 ret = cros_usbpd_charger_ec_command(charger, 0, in cros_usbpd_charger_get_discovery_info()
158 dev_err(charger->dev, in cros_usbpd_charger_get_discovery_info()
163 dev_dbg(charger->dev, "Port %d: VID = 0x%x, PID=0x%x, PTYPE=0x%x\n", in cros_usbpd_charger_get_discovery_info()
175 struct charger_data *charger = port->charger; in cros_usbpd_charger_get_power_info() local
179 struct device *dev = charger->dev; in cros_usbpd_charger_get_power_info()
183 ret = cros_usbpd_charger_ec_command(charger, 0, in cros_usbpd_charger_get_power_info()
259 * While the EC is trying to determine the type of charger that in cros_usbpd_charger_get_power_info()
260 * has been plugged in, it will report the charger type as in cros_usbpd_charger_get_power_info()
318 static int cros_usbpd_charger_set_ext_power_limit(struct charger_data *charger, in cros_usbpd_charger_set_ext_power_limit() argument
328 ret = cros_usbpd_charger_ec_command(charger, 0, in cros_usbpd_charger_set_ext_power_limit()
332 dev_err(charger->dev, in cros_usbpd_charger_set_ext_power_limit()
341 struct charger_data *charger = port->charger; in cros_usbpd_charger_power_changed() local
344 for (i = 0; i < charger->num_registered_psy; i++) in cros_usbpd_charger_power_changed()
345 cros_usbpd_charger_get_port_status(charger->ports[i], false); in cros_usbpd_charger_power_changed()
353 struct charger_data *charger = port->charger; in cros_usbpd_charger_get_prop() local
354 struct cros_ec_device *ec_device = charger->ec_device; in cros_usbpd_charger_get_prop()
355 struct device *dev = charger->dev; in cros_usbpd_charger_get_prop()
440 struct charger_data *charger = port->charger; in cros_usbpd_charger_set_prop() local
441 struct device *dev = charger->dev; in cros_usbpd_charger_set_prop()
456 ret = cros_usbpd_charger_set_ext_power_limit(charger, intval, in cros_usbpd_charger_set_prop()
471 ret = cros_usbpd_charger_set_ext_power_limit(charger, in cros_usbpd_charger_set_prop()
514 struct charger_data *charger = container_of(nb, struct charger_data, in cros_usbpd_charger_ec_event() local
517 cros_usbpd_charger_power_changed(charger->ports[0]->psy); in cros_usbpd_charger_ec_event()
523 struct charger_data *charger = data; in cros_usbpd_charger_unregister_notifier() local
525 cros_usbpd_unregister_notify(&charger->notifier); in cros_usbpd_charger_unregister_notifier()
534 struct charger_data *charger; in cros_usbpd_charger_probe() local
540 charger = devm_kzalloc(dev, sizeof(struct charger_data), in cros_usbpd_charger_probe()
542 if (!charger) in cros_usbpd_charger_probe()
545 charger->dev = dev; in cros_usbpd_charger_probe()
546 charger->ec_dev = ec_dev; in cros_usbpd_charger_probe()
547 charger->ec_device = ec_device; in cros_usbpd_charger_probe()
549 platform_set_drvdata(pd, charger); in cros_usbpd_charger_probe()
556 charger->num_usbpd_ports = in cros_usbpd_charger_probe()
557 cros_usbpd_charger_get_usbpd_num_ports(charger); in cros_usbpd_charger_probe()
558 if (charger->num_usbpd_ports <= 0) { in cros_usbpd_charger_probe()
566 charger->num_charger_ports = cros_usbpd_charger_get_num_ports(charger); in cros_usbpd_charger_probe()
567 if (charger->num_charger_ports < 0) { in cros_usbpd_charger_probe()
572 * let's set up the number of charger ports equal to the number in cros_usbpd_charger_probe()
575 dev_info(dev, "Could not get charger port count\n"); in cros_usbpd_charger_probe()
576 charger->num_charger_ports = charger->num_usbpd_ports; in cros_usbpd_charger_probe()
579 if (charger->num_charger_ports <= 0) { in cros_usbpd_charger_probe()
594 if (charger->num_charger_ports < charger->num_usbpd_ports || in cros_usbpd_charger_probe()
595 charger->num_charger_ports > (charger->num_usbpd_ports + 1)) { in cros_usbpd_charger_probe()
601 for (i = 0; i < charger->num_charger_ports; i++) { in cros_usbpd_charger_probe()
610 port->charger = charger; in cros_usbpd_charger_probe()
655 charger->ports[charger->num_registered_psy++] = port; in cros_usbpd_charger_probe()
658 if (!charger->num_registered_psy) { in cros_usbpd_charger_probe()
665 charger->notifier.notifier_call = cros_usbpd_charger_ec_event; in cros_usbpd_charger_probe()
666 ret = cros_usbpd_register_notify(&charger->notifier); in cros_usbpd_charger_probe()
672 charger); in cros_usbpd_charger_probe()
690 struct charger_data *charger = dev_get_drvdata(dev); in cros_usbpd_charger_resume() local
693 if (!charger) in cros_usbpd_charger_resume()
696 for (i = 0; i < charger->num_registered_psy; i++) { in cros_usbpd_charger_resume()
697 power_supply_changed(charger->ports[i]->psy); in cros_usbpd_charger_resume()
698 charger->ports[i]->last_update = in cros_usbpd_charger_resume()
727 MODULE_DESCRIPTION("ChromeOS EC USBPD charger");