Lines Matching +full:force +full:- +full:hpd

1 // SPDX-License-Identifier: GPL-2.0
7 #include <linux/extcon-provider.h>
49 * cros_ec_pd_command() - Send a command to the EC.
73 return -ENOMEM; in cros_ec_pd_command()
75 msg->version = version; in cros_ec_pd_command()
76 msg->command = command; in cros_ec_pd_command()
77 msg->outsize = outsize; in cros_ec_pd_command()
78 msg->insize = insize; in cros_ec_pd_command()
81 memcpy(msg->data, outdata, outsize); in cros_ec_pd_command()
83 ret = cros_ec_cmd_xfer_status(info->ec, msg); in cros_ec_pd_command()
85 memcpy(indata, msg->data, insize); in cros_ec_pd_command()
92 * cros_ec_usb_get_power_type() - Get power type info about PD device attached
104 req.port = info->port_id; in cros_ec_usb_get_power_type()
114 * cros_ec_usb_get_pd_mux_state() - Get PD mux state for given port.
125 req.port = info->port_id; in cros_ec_usb_get_pd_mux_state()
136 * cros_ec_usb_get_role() - Get role info about possible PD device attached to a
141 * Return: role info on success, -ENOTCONN if no cable is connected, <0 on
151 pd_control.port = info->port_id; in cros_ec_usb_get_role()
162 return -ENOTCONN; in cros_ec_usb_get_role()
170 * cros_ec_pd_get_num_ports() - Get number of EC charge ports.
228 * here from that code because that breaks Suzy-Q and other kinds of in cros_ec_usb_power_type_is_wall_wart()
229 * USB Type-C cables and peripherals. in cros_ec_usb_power_type_is_wall_wart()
248 bool force) in extcon_cros_ec_detect_cable() argument
250 struct device *dev = info->dev; in extcon_cros_ec_detect_cable()
257 bool hpd = false; in extcon_cros_ec_detect_cable() local
268 if (role != -ENOTCONN) { in extcon_cros_ec_detect_cable()
284 hpd = pd_mux_state & USB_PD_MUX_HPD_IRQ; in extcon_cros_ec_detect_cable()
287 "connected role 0x%x pwr type %d dr %d pr %d pol %d mux %d dp %d hpd %d\n", in extcon_cros_ec_detect_cable()
288 role, power_type, dr, pr, polarity, mux, dp, hpd); in extcon_cros_ec_detect_cable()
299 if (force || info->dr != dr || info->pr != pr || info->dp != dp || in extcon_cros_ec_detect_cable()
300 info->mux != mux || info->power_type != power_type) { in extcon_cros_ec_detect_cable()
306 info->dr = dr; in extcon_cros_ec_detect_cable()
307 info->pr = pr; in extcon_cros_ec_detect_cable()
308 info->dp = dp; in extcon_cros_ec_detect_cable()
309 info->mux = mux; in extcon_cros_ec_detect_cable()
310 info->power_type = power_type; in extcon_cros_ec_detect_cable()
317 extcon_set_state(info->edev, EXTCON_USB, device_connected); in extcon_cros_ec_detect_cable()
318 extcon_set_state(info->edev, EXTCON_USB_HOST, host_connected); in extcon_cros_ec_detect_cable()
319 extcon_set_state(info->edev, EXTCON_DISP_DP, dp); in extcon_cros_ec_detect_cable()
320 extcon_set_property(info->edev, EXTCON_USB, in extcon_cros_ec_detect_cable()
323 extcon_set_property(info->edev, EXTCON_USB_HOST, in extcon_cros_ec_detect_cable()
326 extcon_set_property(info->edev, EXTCON_USB, in extcon_cros_ec_detect_cable()
329 extcon_set_property(info->edev, EXTCON_USB_HOST, in extcon_cros_ec_detect_cable()
332 extcon_set_property(info->edev, EXTCON_DISP_DP, in extcon_cros_ec_detect_cable()
335 extcon_set_property(info->edev, EXTCON_USB, in extcon_cros_ec_detect_cable()
338 extcon_set_property(info->edev, EXTCON_USB_HOST, in extcon_cros_ec_detect_cable()
341 extcon_set_property(info->edev, EXTCON_DISP_DP, in extcon_cros_ec_detect_cable()
344 extcon_set_property(info->edev, EXTCON_DISP_DP, in extcon_cros_ec_detect_cable()
346 (union extcon_property_value)(int)hpd); in extcon_cros_ec_detect_cable()
348 extcon_sync(info->edev, EXTCON_USB); in extcon_cros_ec_detect_cable()
349 extcon_sync(info->edev, EXTCON_USB_HOST); in extcon_cros_ec_detect_cable()
350 extcon_sync(info->edev, EXTCON_DISP_DP); in extcon_cros_ec_detect_cable()
352 } else if (hpd) { in extcon_cros_ec_detect_cable()
353 extcon_set_property(info->edev, EXTCON_DISP_DP, in extcon_cros_ec_detect_cable()
355 (union extcon_property_value)(int)hpd); in extcon_cros_ec_detect_cable()
356 extcon_sync(info->edev, EXTCON_DISP_DP); in extcon_cros_ec_detect_cable()
371 ec = info->ec; in extcon_cros_ec_event()
386 struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); in extcon_cros_ec_probe()
387 struct device *dev = &pdev->dev; in extcon_cros_ec_probe()
388 struct device_node *np = dev->of_node; in extcon_cros_ec_probe()
393 return -ENOMEM; in extcon_cros_ec_probe()
395 info->dev = dev; in extcon_cros_ec_probe()
396 info->ec = ec; in extcon_cros_ec_probe()
401 ret = of_property_read_u32(np, "google,usb-port-id", &port); in extcon_cros_ec_probe()
403 dev_err(dev, "Missing google,usb-port-id property\n"); in extcon_cros_ec_probe()
406 info->port_id = port; in extcon_cros_ec_probe()
408 info->port_id = pdev->id; in extcon_cros_ec_probe()
418 if (info->port_id >= numports) { in extcon_cros_ec_probe()
420 return -ENODEV; in extcon_cros_ec_probe()
423 info->edev = devm_extcon_dev_allocate(dev, usb_type_c_cable); in extcon_cros_ec_probe()
424 if (IS_ERR(info->edev)) { in extcon_cros_ec_probe()
426 return -ENOMEM; in extcon_cros_ec_probe()
429 ret = devm_extcon_dev_register(dev, info->edev); in extcon_cros_ec_probe()
435 extcon_set_property_capability(info->edev, EXTCON_USB, in extcon_cros_ec_probe()
437 extcon_set_property_capability(info->edev, EXTCON_USB_HOST, in extcon_cros_ec_probe()
439 extcon_set_property_capability(info->edev, EXTCON_USB, in extcon_cros_ec_probe()
441 extcon_set_property_capability(info->edev, EXTCON_USB_HOST, in extcon_cros_ec_probe()
443 extcon_set_property_capability(info->edev, EXTCON_DISP_DP, in extcon_cros_ec_probe()
445 extcon_set_property_capability(info->edev, EXTCON_USB, in extcon_cros_ec_probe()
447 extcon_set_property_capability(info->edev, EXTCON_USB_HOST, in extcon_cros_ec_probe()
449 extcon_set_property_capability(info->edev, EXTCON_DISP_DP, in extcon_cros_ec_probe()
451 extcon_set_property_capability(info->edev, EXTCON_DISP_DP, in extcon_cros_ec_probe()
454 info->dr = DR_NONE; in extcon_cros_ec_probe()
455 info->pr = false; in extcon_cros_ec_probe()
460 info->notifier.notifier_call = extcon_cros_ec_event; in extcon_cros_ec_probe()
461 ret = blocking_notifier_chain_register(&info->ec->event_notifier, in extcon_cros_ec_probe()
462 &info->notifier); in extcon_cros_ec_probe()
478 blocking_notifier_chain_unregister(&info->ec->event_notifier, in extcon_cros_ec_probe()
479 &info->notifier); in extcon_cros_ec_probe()
487 blocking_notifier_chain_unregister(&info->ec->event_notifier, in extcon_cros_ec_remove()
488 &info->notifier); in extcon_cros_ec_remove()
520 { .compatible = "google,extcon-usbc-cros-ec" },
528 .name = "extcon-usbc-cros-ec",