usb: dwc2: Add force-b-session-valid support
authorPatrick Delaunay <patrick.delaunay@st.com>
Fri, 29 Mar 2019 14:42:17 +0000 (15:42 +0100)
committerMarek Vasut <marex@denx.de>
Sun, 21 Apr 2019 08:26:52 +0000 (10:26 +0200)
Handle "force-b-session-valid" property from DT.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
drivers/usb/gadget/dwc2_udc_otg.c
drivers/usb/gadget/dwc2_udc_otg_regs.h
include/usb/dwc2_udc.h

index 8169fdbb110cad7f511dd4160675e40d5785a10a..146f11e710804955a93dc7a4a57add5365244a5f 100644 (file)
@@ -1034,6 +1034,9 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
                                                       "g-np-tx-fifo-size", 0);
        platdata->tx_fifo_sz = dev_read_u32_default(dev, "g-tx-fifo-size", 0);
 
+       platdata->force_b_session_valid =
+               dev_read_bool(dev, "force-b-session-valid");
+
        return 0;
 }
 
@@ -1088,6 +1091,8 @@ static int dwc2_udc_otg_probe(struct udevice *dev)
 {
        struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev);
        struct dwc2_priv_data *priv = dev_get_priv(dev);
+       struct dwc2_usbotg_reg *usbotg_reg =
+               (struct dwc2_usbotg_reg *)platdata->regs_otg;
        int ret;
 
        ret = dwc2_udc_otg_clk_init(dev, &priv->clks);
@@ -1102,6 +1107,10 @@ static int dwc2_udc_otg_probe(struct udevice *dev)
        if (ret)
                return ret;
 
+       if (platdata->force_b_session_valid)
+               /* Override B session bits : value and enable */
+               setbits_le32(&usbotg_reg->gotgctl,  B_VALOEN | B_VALOVAL);
+
        ret = dwc2_udc_probe(platdata);
        if (ret)
                return ret;
index a1829b3fd1219db975b0e95e85120ad311200122..0aee4ee9295eae1de97bc155be2732d635dd14e4 100644 (file)
@@ -83,8 +83,12 @@ struct dwc2_usbotg_reg {
 /*definitions related to CSR setting */
 
 /* DWC2_UDC_OTG_GOTGCTL */
-#define B_SESSION_VALID                (0x1<<19)
-#define A_SESSION_VALID                (0x1<<18)
+#define B_SESSION_VALID                        BIT(19)
+#define A_SESSION_VALID                        BIT(18)
+#define B_VALOVAL                      BIT(7)
+#define B_VALOEN                       BIT(6)
+#define A_VALOVAL                      BIT(5)
+#define A_VALOEN                       BIT(4)
 
 /* DWC2_UDC_OTG_GAHBCFG */
 #define PTXFE_HALF                     (0<<8)
index 4068de045dc2c4e204a0cc0ec9da3c7536ebaa7e..3cf20eab92dd3f853122b4a66d6d455a582fad4b 100644 (file)
@@ -22,6 +22,7 @@ struct dwc2_plat_otg_data {
        unsigned int    rx_fifo_sz;
        unsigned int    np_tx_fifo_sz;
        unsigned int    tx_fifo_sz;
+       bool            force_b_session_valid;
 };
 
 int dwc2_udc_probe(struct dwc2_plat_otg_data *pdata);