Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: dwc3: core: Introduce glue callbacks for flattened implementations

In certain situations like role switching, the glue layers need to be
informed of these events, so that they can take any necessary action.
But in non-flattened implementations, the glue drivers have no data on
when the core driver probe was successful post invoking of_platform_
populate. Now that the core driver supports flattened implementations
as well, introduce vendor callbacks that can be passed on from glue to
core before invoking dwc3_core_probe.

Introduce callbacks to notify glue layer of role_switch and run_stop
changes. These can be used by flattened implementation of Qualcomm
glue layer to generate connect/disconnect events in controller during
cable connect and run stop modifications by udc in device mode.

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250907181412.2174616-2-krishna.kurapati@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Krishna Kurapati and committed by
Greg Kroah-Hartman
643df901 5df186e2

+29
+1
drivers/usb/dwc3/core.c
··· 2352 2352 return -ENOMEM; 2353 2353 2354 2354 dwc->dev = &pdev->dev; 2355 + dwc->glue_ops = NULL; 2355 2356 2356 2357 probe_data.dwc = dwc; 2357 2358 probe_data.res = res;
+26
drivers/usb/dwc3/core.h
··· 993 993 }; 994 994 995 995 /** 996 + * struct dwc3_glue_ops - The ops indicate the notifications that 997 + * need to be passed on to glue layer 998 + * @pre_set_role: Notify glue of role switch notifications 999 + * @pre_run_stop: Notify run stop enable/disable information to glue 1000 + */ 1001 + struct dwc3_glue_ops { 1002 + void (*pre_set_role)(struct dwc3 *dwc, enum usb_role role); 1003 + void (*pre_run_stop)(struct dwc3 *dwc, bool is_on); 1004 + }; 1005 + 1006 + /** 996 1007 * struct dwc3 - representation of our controller 997 1008 * @drd_work: workqueue used for role swapping 998 1009 * @ep0_trb: trb which is used for the ctrl_req ··· 1023 1012 * @eps: endpoint array 1024 1013 * @gadget: device side representation of the peripheral controller 1025 1014 * @gadget_driver: pointer to the gadget driver 1015 + * @glue_ops: Vendor callbacks for flattened device implementations. 1026 1016 * @bus_clk: clock for accessing the registers 1027 1017 * @ref_clk: reference clock 1028 1018 * @susp_clk: clock used when the SS phy is in low power (S3) state ··· 1208 1196 1209 1197 struct usb_gadget *gadget; 1210 1198 struct usb_gadget_driver *gadget_driver; 1199 + 1200 + const struct dwc3_glue_ops *glue_ops; 1211 1201 1212 1202 struct clk *bus_clk; 1213 1203 struct clk *ref_clk; ··· 1627 1613 1628 1614 int dwc3_core_soft_reset(struct dwc3 *dwc); 1629 1615 void dwc3_enable_susphy(struct dwc3 *dwc, bool enable); 1616 + 1617 + static inline void dwc3_pre_set_role(struct dwc3 *dwc, enum usb_role role) 1618 + { 1619 + if (dwc->glue_ops && dwc->glue_ops->pre_set_role) 1620 + dwc->glue_ops->pre_set_role(dwc, role); 1621 + } 1622 + 1623 + static inline void dwc3_pre_run_stop(struct dwc3 *dwc, bool is_on) 1624 + { 1625 + if (dwc->glue_ops && dwc->glue_ops->pre_run_stop) 1626 + dwc->glue_ops->pre_run_stop(dwc, is_on); 1627 + } 1630 1628 1631 1629 #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE) 1632 1630 int dwc3_host_init(struct dwc3 *dwc);
+1
drivers/usb/dwc3/drd.c
··· 464 464 break; 465 465 } 466 466 467 + dwc3_pre_set_role(dwc, role); 467 468 dwc3_set_mode(dwc, mode); 468 469 return 0; 469 470 }
+1
drivers/usb/dwc3/gadget.c
··· 2662 2662 dwc->pullups_connected = false; 2663 2663 } 2664 2664 2665 + dwc3_pre_run_stop(dwc, is_on); 2665 2666 dwc3_gadget_dctl_write_safe(dwc, reg); 2666 2667 2667 2668 do {