Lines Matching full:usbh
3 * BCM6328 USBH PHY Controller Driver
25 /* USBH control register offsets */
225 static inline bool usbh_has_reg(struct bcm63xx_usbh_phy *usbh, int reg) in usbh_has_reg() argument
227 return (usbh->variant->regs[reg] >= 0); in usbh_has_reg()
230 static inline u32 usbh_readl(struct bcm63xx_usbh_phy *usbh, int reg) in usbh_readl() argument
232 return __raw_readl(usbh->base + usbh->variant->regs[reg]); in usbh_readl()
235 static inline void usbh_writel(struct bcm63xx_usbh_phy *usbh, int reg, in usbh_writel() argument
238 __raw_writel(value, usbh->base + usbh->variant->regs[reg]); in usbh_writel()
243 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_init() local
246 ret = clk_prepare_enable(usbh->usbh_clk); in bcm63xx_usbh_phy_init()
248 dev_err(&phy->dev, "unable to enable usbh clock: %d\n", ret); in bcm63xx_usbh_phy_init()
252 ret = clk_prepare_enable(usbh->usb_ref_clk); in bcm63xx_usbh_phy_init()
255 clk_disable_unprepare(usbh->usbh_clk); in bcm63xx_usbh_phy_init()
259 ret = reset_control_reset(usbh->reset); in bcm63xx_usbh_phy_init()
262 clk_disable_unprepare(usbh->usb_ref_clk); in bcm63xx_usbh_phy_init()
263 clk_disable_unprepare(usbh->usbh_clk); in bcm63xx_usbh_phy_init()
268 if (usbh_has_reg(usbh, USBH_SWAP_CONTROL)) { in bcm63xx_usbh_phy_init()
269 u32 val = usbh_readl(usbh, USBH_SWAP_CONTROL); in bcm63xx_usbh_phy_init()
277 if (usbh->device_mode && usbh->variant->swapctl_dev_set) in bcm63xx_usbh_phy_init()
278 val |= usbh->variant->swapctl_dev_set; in bcm63xx_usbh_phy_init()
280 usbh_writel(usbh, USBH_SWAP_CONTROL, val); in bcm63xx_usbh_phy_init()
283 if (usbh_has_reg(usbh, USBH_SETUP)) { in bcm63xx_usbh_phy_init()
284 u32 val = usbh_readl(usbh, USBH_SETUP); in bcm63xx_usbh_phy_init()
286 val |= usbh->variant->setup_set; in bcm63xx_usbh_phy_init()
287 val &= ~usbh->variant->setup_clr; in bcm63xx_usbh_phy_init()
289 usbh_writel(usbh, USBH_SETUP, val); in bcm63xx_usbh_phy_init()
292 if (usbh_has_reg(usbh, USBH_USB_SIM_CONTROL)) { in bcm63xx_usbh_phy_init()
293 u32 val = usbh_readl(usbh, USBH_USB_SIM_CONTROL); in bcm63xx_usbh_phy_init()
295 val |= usbh->variant->usc_set; in bcm63xx_usbh_phy_init()
297 usbh_writel(usbh, USBH_USB_SIM_CONTROL, val); in bcm63xx_usbh_phy_init()
300 if (usbh->variant->tpc_val && in bcm63xx_usbh_phy_init()
301 usbh_has_reg(usbh, USBH_TEST_PORT_CONTROL)) in bcm63xx_usbh_phy_init()
302 usbh_writel(usbh, USBH_TEST_PORT_CONTROL, in bcm63xx_usbh_phy_init()
303 usbh->variant->tpc_val); in bcm63xx_usbh_phy_init()
305 if (usbh->device_mode && in bcm63xx_usbh_phy_init()
306 usbh_has_reg(usbh, USBH_UTMI_CONTROL1) && in bcm63xx_usbh_phy_init()
307 usbh->variant->utmictl1_dev_set) { in bcm63xx_usbh_phy_init()
308 u32 val = usbh_readl(usbh, USBH_UTMI_CONTROL1); in bcm63xx_usbh_phy_init()
310 val |= usbh->variant->utmictl1_dev_set; in bcm63xx_usbh_phy_init()
312 usbh_writel(usbh, USBH_UTMI_CONTROL1, val); in bcm63xx_usbh_phy_init()
320 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_power_on() local
322 if (usbh_has_reg(usbh, USBH_PLL_CONTROL1)) { in bcm63xx_usbh_phy_power_on()
323 u32 val = usbh_readl(usbh, USBH_PLL_CONTROL1); in bcm63xx_usbh_phy_power_on()
325 val |= usbh->variant->power_pllc_set; in bcm63xx_usbh_phy_power_on()
326 val &= ~usbh->variant->power_pllc_clr; in bcm63xx_usbh_phy_power_on()
328 usbh_writel(usbh, USBH_PLL_CONTROL1, val); in bcm63xx_usbh_phy_power_on()
336 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_power_off() local
338 if (usbh_has_reg(usbh, USBH_PLL_CONTROL1)) { in bcm63xx_usbh_phy_power_off()
339 u32 val = usbh_readl(usbh, USBH_PLL_CONTROL1); in bcm63xx_usbh_phy_power_off()
341 val &= ~usbh->variant->power_pllc_set; in bcm63xx_usbh_phy_power_off()
342 val |= usbh->variant->power_pllc_clr; in bcm63xx_usbh_phy_power_off()
344 usbh_writel(usbh, USBH_PLL_CONTROL1, val); in bcm63xx_usbh_phy_power_off()
352 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_exit() local
354 clk_disable_unprepare(usbh->usbh_clk); in bcm63xx_usbh_phy_exit()
355 clk_disable_unprepare(usbh->usb_ref_clk); in bcm63xx_usbh_phy_exit()
371 struct bcm63xx_usbh_phy *usbh = dev_get_drvdata(dev); in bcm63xx_usbh_phy_xlate() local
373 usbh->device_mode = !!args->args[0]; in bcm63xx_usbh_phy_xlate()
381 struct bcm63xx_usbh_phy *usbh; in bcm63xx_usbh_phy_probe() local
386 usbh = devm_kzalloc(dev, sizeof(*usbh), GFP_KERNEL); in bcm63xx_usbh_phy_probe()
387 if (!usbh) in bcm63xx_usbh_phy_probe()
393 usbh->variant = variant; in bcm63xx_usbh_phy_probe()
395 usbh->base = devm_platform_ioremap_resource(pdev, 0); in bcm63xx_usbh_phy_probe()
396 if (IS_ERR(usbh->base)) in bcm63xx_usbh_phy_probe()
397 return PTR_ERR(usbh->base); in bcm63xx_usbh_phy_probe()
399 usbh->reset = devm_reset_control_get_exclusive(dev, NULL); in bcm63xx_usbh_phy_probe()
400 if (IS_ERR(usbh->reset)) { in bcm63xx_usbh_phy_probe()
401 if (PTR_ERR(usbh->reset) != -EPROBE_DEFER) in bcm63xx_usbh_phy_probe()
403 return PTR_ERR(usbh->reset); in bcm63xx_usbh_phy_probe()
406 usbh->usbh_clk = devm_clk_get_optional(dev, "usbh"); in bcm63xx_usbh_phy_probe()
407 if (IS_ERR(usbh->usbh_clk)) in bcm63xx_usbh_phy_probe()
408 return PTR_ERR(usbh->usbh_clk); in bcm63xx_usbh_phy_probe()
410 usbh->usb_ref_clk = devm_clk_get_optional(dev, "usb_ref"); in bcm63xx_usbh_phy_probe()
411 if (IS_ERR(usbh->usb_ref_clk)) in bcm63xx_usbh_phy_probe()
412 return PTR_ERR(usbh->usb_ref_clk); in bcm63xx_usbh_phy_probe()
420 platform_set_drvdata(pdev, usbh); in bcm63xx_usbh_phy_probe()
421 phy_set_drvdata(phy, usbh); in bcm63xx_usbh_phy_probe()
436 { .compatible = "brcm,bcm6318-usbh-phy", .data = &usbh_bcm6318 },
437 { .compatible = "brcm,bcm6328-usbh-phy", .data = &usbh_bcm6328 },
438 { .compatible = "brcm,bcm6358-usbh-phy", .data = &usbh_bcm6358 },
439 { .compatible = "brcm,bcm6362-usbh-phy", .data = &usbh_bcm6368 },
440 { .compatible = "brcm,bcm6368-usbh-phy", .data = &usbh_bcm6368 },
441 { .compatible = "brcm,bcm63268-usbh-phy", .data = &usbh_bcm63268 },
448 .name = "bcm63xx-usbh-phy",
455 MODULE_DESCRIPTION("BCM63xx USBH PHY driver");