UPSTREAM: usb: dwc2: Add function for session B check

Add a new function to check the session B validity, to be use to check
cable connection.

Change-Id: I914d7353e926df26787261c99f07e5c58dbf24ff
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 2d76160f049c42087011cfa0e6e878aa2ed6b406)
This commit is contained in:
Patrick Delaunay 2019-03-29 15:42:18 +01:00 committed by Frank Wang
parent 5c4beedb87
commit 3015f8bebd
2 changed files with 11 additions and 0 deletions

View File

@ -1153,4 +1153,13 @@ U_BOOT_DRIVER(dwc2_udc_otg) = {
.platdata_auto_alloc_size = sizeof(struct dwc2_plat_otg_data),
.priv_auto_alloc_size = sizeof(struct dwc2_priv_data),
};
int dwc2_udc_B_session_valid(struct udevice *dev)
{
struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev);
struct dwc2_usbotg_reg *usbotg_reg =
(struct dwc2_usbotg_reg *)platdata->regs_otg;
return readl(&usbotg_reg->gotgctl) & B_SESSION_VALID;
}
#endif /* CONFIG_IS_ENABLED(DM_USB_GADGET) */

View File

@ -28,4 +28,6 @@ struct dwc2_plat_otg_data {
int dwc2_udc_probe(struct dwc2_plat_otg_data *pdata);
int dwc2_udc_B_session_valid(struct udevice *dev);
#endif /* __DWC2_USB_GADGET */