Lines Matching refs:hsotg
16 static void dwc2_ovr_init(struct dwc2_hsotg *hsotg)
21 spin_lock_irqsave(&hsotg->lock, flags);
23 gotgctl = dwc2_readl(hsotg, GOTGCTL);
27 dwc2_writel(hsotg, gotgctl, GOTGCTL);
29 spin_unlock_irqrestore(&hsotg->lock, flags);
31 dwc2_force_mode(hsotg, (hsotg->dr_mode == USB_DR_MODE_HOST));
34 static int dwc2_ovr_avalid(struct dwc2_hsotg *hsotg, bool valid)
36 u32 gotgctl = dwc2_readl(hsotg, GOTGCTL);
48 dwc2_writel(hsotg, gotgctl, GOTGCTL);
53 static int dwc2_ovr_bvalid(struct dwc2_hsotg *hsotg, bool valid)
55 u32 gotgctl = dwc2_readl(hsotg, GOTGCTL);
67 dwc2_writel(hsotg, gotgctl, GOTGCTL);
74 struct dwc2_hsotg *hsotg = usb_role_switch_get_drvdata(sw);
79 if ((role == USB_ROLE_DEVICE && hsotg->dr_mode == USB_DR_MODE_HOST) ||
80 (role == USB_ROLE_HOST && hsotg->dr_mode == USB_DR_MODE_PERIPHERAL))
86 if (role == USB_ROLE_NONE && hsotg->test_mode) {
87 dev_dbg(hsotg->dev, "Core is in test mode\n");
99 if (!hsotg->ll_hw_enabled && hsotg->clk) {
100 int ret = clk_prepare_enable(hsotg->clk);
106 spin_lock_irqsave(&hsotg->lock, flags);
109 already = dwc2_ovr_avalid(hsotg, true);
111 already = dwc2_ovr_bvalid(hsotg, true);
112 if (dwc2_is_device_enabled(hsotg)) {
114 dwc2_hsotg_core_connect(hsotg);
117 if (dwc2_is_device_mode(hsotg)) {
118 if (!dwc2_ovr_bvalid(hsotg, false))
120 dwc2_hsotg_core_disconnect(hsotg);
122 dwc2_ovr_avalid(hsotg, false);
126 spin_unlock_irqrestore(&hsotg->lock, flags);
128 if (!already && hsotg->dr_mode == USB_DR_MODE_OTG)
130 dwc2_force_mode(hsotg, role == USB_ROLE_HOST);
132 if (!hsotg->ll_hw_enabled && hsotg->clk)
133 clk_disable_unprepare(hsotg->clk);
135 dev_dbg(hsotg->dev, "%s-session valid\n",
142 int dwc2_drd_init(struct dwc2_hsotg *hsotg)
148 if (!device_property_read_bool(hsotg->dev, "usb-role-switch"))
151 role_sw_desc.driver_data = hsotg;
152 role_sw_desc.fwnode = dev_fwnode(hsotg->dev);
156 role_sw = usb_role_switch_register(hsotg->dev, &role_sw_desc);
159 dev_err(hsotg->dev,
164 hsotg->role_sw = role_sw;
167 dwc2_ovr_init(hsotg);
172 void dwc2_drd_suspend(struct dwc2_hsotg *hsotg)
176 if (hsotg->role_sw && !hsotg->params.external_id_pin_ctl) {
177 gintmsk = dwc2_readl(hsotg, GINTMSK);
179 dwc2_writel(hsotg, gintmsk, GINTMSK);
180 gintsts = dwc2_readl(hsotg, GINTSTS);
181 dwc2_writel(hsotg, gintsts | GINTSTS_CONIDSTSCHNG, GINTSTS);
185 void dwc2_drd_resume(struct dwc2_hsotg *hsotg)
189 if (hsotg->role_sw && !hsotg->params.external_id_pin_ctl) {
190 gintsts = dwc2_readl(hsotg, GINTSTS);
191 dwc2_writel(hsotg, gintsts | GINTSTS_CONIDSTSCHNG, GINTSTS);
192 gintmsk = dwc2_readl(hsotg, GINTMSK);
194 dwc2_writel(hsotg, gintmsk, GINTMSK);
198 void dwc2_drd_exit(struct dwc2_hsotg *hsotg)
200 if (hsotg->role_sw)
201 usb_role_switch_unregister(hsotg->role_sw);