Lines Matching refs:rtk
65 static void switch_usb2_role(struct dwc3_rtk *rtk, enum usb_role role) in switch_usb2_role() argument
70 reg = rtk->regs + WRAP_USB2_PHY_REG; in switch_usb2_role()
81 dev_dbg(rtk->dev, "%s: role=%d\n", __func__, role); in switch_usb2_role()
86 static void switch_dwc3_role(struct dwc3_rtk *rtk, enum usb_role role) in switch_dwc3_role() argument
88 if (!rtk->dwc->role_sw) in switch_dwc3_role()
91 usb_role_switch_set_role(rtk->dwc->role_sw, role); in switch_dwc3_role()
94 static enum usb_role dwc3_rtk_get_role(struct dwc3_rtk *rtk) in dwc3_rtk_get_role() argument
98 role = rtk->cur_role; in dwc3_rtk_get_role()
100 if (rtk->dwc && rtk->dwc->role_sw) in dwc3_rtk_get_role()
101 role = usb_role_switch_get_role(rtk->dwc->role_sw); in dwc3_rtk_get_role()
103 dev_dbg(rtk->dev, "%s not usb_role_switch role=%d\n", __func__, role); in dwc3_rtk_get_role()
108 static void dwc3_rtk_set_role(struct dwc3_rtk *rtk, enum usb_role role) in dwc3_rtk_set_role() argument
110 rtk->cur_role = role; in dwc3_rtk_set_role()
112 switch_dwc3_role(rtk, role); in dwc3_rtk_set_role()
114 switch_usb2_role(rtk, role); in dwc3_rtk_set_role()
120 struct dwc3_rtk *rtk = usb_role_switch_get_drvdata(sw); in dwc3_usb_role_switch_set() local
122 dwc3_rtk_set_role(rtk, role); in dwc3_usb_role_switch_set()
129 struct dwc3_rtk *rtk = usb_role_switch_get_drvdata(sw); in dwc3_usb_role_switch_get() local
131 return dwc3_rtk_get_role(rtk); in dwc3_usb_role_switch_get()
134 static int dwc3_rtk_setup_role_switch(struct dwc3_rtk *rtk) in dwc3_rtk_setup_role_switch() argument
138 dwc3_role_switch.name = dev_name(rtk->dev); in dwc3_rtk_setup_role_switch()
139 dwc3_role_switch.driver_data = rtk; in dwc3_rtk_setup_role_switch()
141 dwc3_role_switch.fwnode = dev_fwnode(rtk->dev); in dwc3_rtk_setup_role_switch()
144 rtk->role_switch = usb_role_switch_register(rtk->dev, &dwc3_role_switch); in dwc3_rtk_setup_role_switch()
145 if (IS_ERR(rtk->role_switch)) in dwc3_rtk_setup_role_switch()
146 return PTR_ERR(rtk->role_switch); in dwc3_rtk_setup_role_switch()
151 static int dwc3_rtk_remove_role_switch(struct dwc3_rtk *rtk) in dwc3_rtk_remove_role_switch() argument
153 if (rtk->role_switch) in dwc3_rtk_remove_role_switch()
154 usb_role_switch_unregister(rtk->role_switch); in dwc3_rtk_remove_role_switch()
156 rtk->role_switch = NULL; in dwc3_rtk_remove_role_switch()
194 static int dwc3_rtk_init(struct dwc3_rtk *rtk) in dwc3_rtk_init() argument
196 struct device *dev = rtk->dev; in dwc3_rtk_init()
209 reg = rtk->regs + WRAP_CTR_REG; in dwc3_rtk_init()
216 reg = rtk->regs + WRAP_USB2_PHY_REG; in dwc3_rtk_init()
222 reg = rtk->regs + WRAP_USB2_PHY_UTMI_REG; in dwc3_rtk_init()
229 reg = rtk->regs + WRAP_USB_HMAC_CTR0_REG; in dwc3_rtk_init()
233 reg = rtk->regs + WRAP_CTR_REG; in dwc3_rtk_init()
237 reg = rtk->regs + WRAP_PHY_PIPE_REG; in dwc3_rtk_init()
241 reg = rtk->regs + WRAP_USB_HMAC_CTR0_REG; in dwc3_rtk_init()
245 reg = rtk->regs + WRAP_APHY_REG; in dwc3_rtk_init()
249 dev_dbg(rtk->dev, "%s: disable usb 3.0 phy\n", __func__); in dwc3_rtk_init()
253 reg = rtk->regs + WRAP_CTR_REG; in dwc3_rtk_init()
258 reg = rtk->regs + WRAP_USB2_PHY_REG; in dwc3_rtk_init()
262 if (rtk->pm_base) { in dwc3_rtk_init()
263 reg = rtk->pm_base + USB_DBUS_PWR_CTRL_REG; in dwc3_rtk_init()
271 static int dwc3_rtk_probe_dwc3_core(struct dwc3_rtk *rtk) in dwc3_rtk_probe_dwc3_core() argument
273 struct device *dev = rtk->dev; in dwc3_rtk_probe_dwc3_core()
280 ret = dwc3_rtk_init(rtk); in dwc3_rtk_probe_dwc3_core()
306 rtk->dwc = platform_get_drvdata(dwc3_pdev); in dwc3_rtk_probe_dwc3_core()
307 if (!rtk->dwc) { in dwc3_rtk_probe_dwc3_core()
314 if (dr_mode != rtk->dwc->dr_mode) { in dwc3_rtk_probe_dwc3_core()
316 dr_mode, rtk->dwc->dr_mode); in dwc3_rtk_probe_dwc3_core()
317 dr_mode = rtk->dwc->dr_mode; in dwc3_rtk_probe_dwc3_core()
322 rtk->cur_role = USB_ROLE_DEVICE; in dwc3_rtk_probe_dwc3_core()
325 rtk->cur_role = USB_ROLE_HOST; in dwc3_rtk_probe_dwc3_core()
328 dev_dbg(rtk->dev, "%s: dr_mode=%d\n", __func__, dr_mode); in dwc3_rtk_probe_dwc3_core()
333 ret = dwc3_rtk_setup_role_switch(rtk); in dwc3_rtk_probe_dwc3_core()
338 rtk->cur_role = dwc3_rtk_get_role(rtk); in dwc3_rtk_probe_dwc3_core()
341 switch_usb2_role(rtk, rtk->cur_role); in dwc3_rtk_probe_dwc3_core()
357 struct dwc3_rtk *rtk; in dwc3_rtk_probe() local
362 rtk = devm_kzalloc(dev, sizeof(*rtk), GFP_KERNEL); in dwc3_rtk_probe()
363 if (!rtk) in dwc3_rtk_probe()
366 platform_set_drvdata(pdev, rtk); in dwc3_rtk_probe()
368 rtk->dev = dev; in dwc3_rtk_probe()
374 rtk->regs = regs; in dwc3_rtk_probe()
375 rtk->regs_size = resource_size(res); in dwc3_rtk_probe()
379 rtk->pm_base = devm_ioremap_resource(dev, res); in dwc3_rtk_probe()
380 if (IS_ERR(rtk->pm_base)) in dwc3_rtk_probe()
381 return PTR_ERR(rtk->pm_base); in dwc3_rtk_probe()
384 return dwc3_rtk_probe_dwc3_core(rtk); in dwc3_rtk_probe()
389 struct dwc3_rtk *rtk = platform_get_drvdata(pdev); in dwc3_rtk_remove() local
391 rtk->dwc = NULL; in dwc3_rtk_remove()
393 dwc3_rtk_remove_role_switch(rtk); in dwc3_rtk_remove()
395 of_platform_depopulate(rtk->dev); in dwc3_rtk_remove()
400 struct dwc3_rtk *rtk = platform_get_drvdata(pdev); in dwc3_rtk_shutdown() local
402 of_platform_depopulate(rtk->dev); in dwc3_rtk_shutdown()
419 struct dwc3_rtk *rtk = dev_get_drvdata(dev); in dwc3_rtk_resume() local
421 dwc3_rtk_init(rtk); in dwc3_rtk_resume()
423 switch_usb2_role(rtk, rtk->cur_role); in dwc3_rtk_resume()