Lines Matching full:charger

3  * Power supply driver for ChromeOS EC based USB PD Charger.
25 #define DRV_NAME "cros-usbpd-charger"
41 struct charger_data *charger; member
92 return port->port_number >= port->charger->num_usbpd_ports; in cros_usbpd_charger_port_is_dedicated()
95 static int cros_usbpd_charger_ec_command(struct charger_data *charger, in cros_usbpd_charger_ec_command() argument
103 struct cros_ec_dev *ec_dev = charger->ec_dev; in cros_usbpd_charger_ec_command()
119 ret = cros_ec_cmd_xfer_status(charger->ec_device, msg); in cros_usbpd_charger_ec_command()
127 static int cros_usbpd_charger_get_num_ports(struct charger_data *charger) in cros_usbpd_charger_get_num_ports() argument
132 ret = cros_usbpd_charger_ec_command(charger, 0, in cros_usbpd_charger_get_num_ports()
141 static int cros_usbpd_charger_get_usbpd_num_ports(struct charger_data *charger) in cros_usbpd_charger_get_usbpd_num_ports() argument
146 ret = cros_usbpd_charger_ec_command(charger, 0, EC_CMD_USB_PD_PORTS, in cros_usbpd_charger_get_usbpd_num_ports()
156 struct charger_data *charger = port->charger; in cros_usbpd_charger_get_discovery_info() local
163 ret = cros_usbpd_charger_ec_command(charger, 0, in cros_usbpd_charger_get_discovery_info()
168 dev_err(charger->dev, in cros_usbpd_charger_get_discovery_info()
173 dev_dbg(charger->dev, "Port %d: VID = 0x%x, PID=0x%x, PTYPE=0x%x\n", in cros_usbpd_charger_get_discovery_info()
185 struct charger_data *charger = port->charger; in cros_usbpd_charger_get_power_info() local
189 struct device *dev = charger->dev; in cros_usbpd_charger_get_power_info()
193 ret = cros_usbpd_charger_ec_command(charger, 0, in cros_usbpd_charger_get_power_info()
269 * While the EC is trying to determine the type of charger that in cros_usbpd_charger_get_power_info()
270 * has been plugged in, it will report the charger type as in cros_usbpd_charger_get_power_info()
328 static int cros_usbpd_charger_set_ext_power_limit(struct charger_data *charger, in cros_usbpd_charger_set_ext_power_limit() argument
338 ret = cros_usbpd_charger_ec_command(charger, 0, in cros_usbpd_charger_set_ext_power_limit()
342 dev_err(charger->dev, in cros_usbpd_charger_set_ext_power_limit()
351 struct charger_data *charger = port->charger; in cros_usbpd_charger_power_changed() local
354 for (i = 0; i < charger->num_registered_psy; i++) in cros_usbpd_charger_power_changed()
355 cros_usbpd_charger_get_port_status(charger->ports[i], false); in cros_usbpd_charger_power_changed()
363 struct charger_data *charger = port->charger; in cros_usbpd_charger_get_prop() local
364 struct cros_ec_device *ec_device = charger->ec_device; in cros_usbpd_charger_get_prop()
365 struct device *dev = charger->dev; in cros_usbpd_charger_get_prop()
450 struct charger_data *charger = port->charger; in cros_usbpd_charger_set_prop() local
451 struct device *dev = charger->dev; in cros_usbpd_charger_set_prop()
466 ret = cros_usbpd_charger_set_ext_power_limit(charger, intval, in cros_usbpd_charger_set_prop()
481 ret = cros_usbpd_charger_set_ext_power_limit(charger, in cros_usbpd_charger_set_prop()
524 struct charger_data *charger = container_of(nb, struct charger_data, in cros_usbpd_charger_ec_event() local
527 cros_usbpd_charger_power_changed(charger->ports[0]->psy); in cros_usbpd_charger_ec_event()
533 struct charger_data *charger = data; in cros_usbpd_charger_unregister_notifier() local
535 cros_usbpd_unregister_notify(&charger->notifier); in cros_usbpd_charger_unregister_notifier()
544 struct charger_data *charger; in cros_usbpd_charger_probe() local
550 charger = devm_kzalloc(dev, sizeof(struct charger_data), in cros_usbpd_charger_probe()
552 if (!charger) in cros_usbpd_charger_probe()
555 charger->dev = dev; in cros_usbpd_charger_probe()
556 charger->ec_dev = ec_dev; in cros_usbpd_charger_probe()
557 charger->ec_device = ec_device; in cros_usbpd_charger_probe()
559 platform_set_drvdata(pd, charger); in cros_usbpd_charger_probe()
566 charger->num_usbpd_ports = in cros_usbpd_charger_probe()
567 cros_usbpd_charger_get_usbpd_num_ports(charger); in cros_usbpd_charger_probe()
568 if (charger->num_usbpd_ports <= 0) { in cros_usbpd_charger_probe()
576 charger->num_charger_ports = cros_usbpd_charger_get_num_ports(charger); in cros_usbpd_charger_probe()
577 if (charger->num_charger_ports < 0) { in cros_usbpd_charger_probe()
582 * let's set up the number of charger ports equal to the number in cros_usbpd_charger_probe()
585 dev_info(dev, "Could not get charger port count\n"); in cros_usbpd_charger_probe()
586 charger->num_charger_ports = charger->num_usbpd_ports; in cros_usbpd_charger_probe()
589 if (charger->num_charger_ports <= 0) { in cros_usbpd_charger_probe()
604 if (charger->num_charger_ports < charger->num_usbpd_ports || in cros_usbpd_charger_probe()
605 charger->num_charger_ports > (charger->num_usbpd_ports + 1)) { in cros_usbpd_charger_probe()
611 for (i = 0; i < charger->num_charger_ports; i++) { in cros_usbpd_charger_probe()
620 port->charger = charger; in cros_usbpd_charger_probe()
660 charger->ports[charger->num_registered_psy++] = port; in cros_usbpd_charger_probe()
663 if (!charger->num_registered_psy) { in cros_usbpd_charger_probe()
670 charger->notifier.notifier_call = cros_usbpd_charger_ec_event; in cros_usbpd_charger_probe()
671 ret = cros_usbpd_register_notify(&charger->notifier); in cros_usbpd_charger_probe()
677 charger); in cros_usbpd_charger_probe()
695 struct charger_data *charger = dev_get_drvdata(dev); in cros_usbpd_charger_resume() local
698 if (!charger) in cros_usbpd_charger_resume()
701 for (i = 0; i < charger->num_registered_psy; i++) { in cros_usbpd_charger_resume()
702 power_supply_changed(charger->ports[i]->psy); in cros_usbpd_charger_resume()
703 charger->ports[i]->last_update = in cros_usbpd_charger_resume()
725 MODULE_DESCRIPTION("ChromeOS EC USBPD charger");