Lines Matching +full:c +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * BCM6328 USBH PHY Controller Driver
5 * Copyright (C) 2020 Álvaro Fernández Rojas <noltari@gmail.com>
6 * Copyright (C) 2015 Simon Arlott
8 * Derived from bcm963xx_4.12L.06B_consumer/kernel/linux/arch/mips/bcm963xx/setup.c:
9 * Copyright (C) 2002 Broadcom Corporation
12 * Copyright (C) 2013 Jonas Gorski <jonas.gorski@gmail.com>
13 * Copyright (C) 2013 Florian Fainelli <f.fainelli@gmail.com>
14 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
21 #include <linux/phy/phy.h>
87 /* Test Port Control value to set if non-zero */
108 [USBH_BRT_CONTROL1] = -1,
109 [USBH_BRT_CONTROL2] = -1,
110 [USBH_BRT_STATUS1] = -1,
111 [USBH_BRT_STATUS2] = -1,
116 [USBH_GENERIC_CONTROL] = -1,
155 [USBH_BRT_CONTROL1] = -1,
156 [USBH_BRT_CONTROL2] = -1,
157 [USBH_BRT_STATUS1] = -1,
158 [USBH_BRT_STATUS2] = -1,
159 [USBH_UTMI_CONTROL1] = -1,
161 [USBH_PLL_CONTROL1] = -1,
163 [USBH_GENERIC_CONTROL] = -1,
164 [USBH_FRAME_ADJUST_VALUE] = -1,
165 [USBH_SETUP] = -1,
166 [USBH_MDIO] = -1,
167 [USBH_MDIO32] = -1,
168 [USBH_USB_SIM_CONTROL] = -1,
173 * help, so the magic value is used as-is.
188 [USBH_GENERIC_CONTROL] = -1,
227 return (usbh->variant->regs[reg] >= 0); in usbh_has_reg()
232 return __raw_readl(usbh->base + usbh->variant->regs[reg]); in usbh_readl()
238 __raw_writel(value, usbh->base + usbh->variant->regs[reg]); in usbh_writel()
241 static int bcm63xx_usbh_phy_init(struct phy *phy) in bcm63xx_usbh_phy_init() argument
243 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_init()
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()
254 dev_err(&phy->dev, "unable to enable usb_ref clock: %d\n", ret); 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()
261 dev_err(&phy->dev, "unable to reset device: %d\n", ret); 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()
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()
286 val |= usbh->variant->setup_set; in bcm63xx_usbh_phy_init()
287 val &= ~usbh->variant->setup_clr; in bcm63xx_usbh_phy_init()
295 val |= usbh->variant->usc_set; in bcm63xx_usbh_phy_init()
300 if (usbh->variant->tpc_val && 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()
307 usbh->variant->utmictl1_dev_set) { in bcm63xx_usbh_phy_init()
310 val |= usbh->variant->utmictl1_dev_set; in bcm63xx_usbh_phy_init()
318 static int bcm63xx_usbh_phy_power_on(struct phy *phy) in bcm63xx_usbh_phy_power_on() argument
320 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); 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()
334 static int bcm63xx_usbh_phy_power_off(struct phy *phy) in bcm63xx_usbh_phy_power_off() argument
336 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); 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()
350 static int bcm63xx_usbh_phy_exit(struct phy *phy) in bcm63xx_usbh_phy_exit() argument
352 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_exit()
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()
368 static struct phy *bcm63xx_usbh_phy_xlate(struct device *dev, in bcm63xx_usbh_phy_xlate()
373 usbh->device_mode = !!args->args[0]; in bcm63xx_usbh_phy_xlate()
380 struct device *dev = &pdev->dev; in bcm63xx_usbh_phy_probe()
383 struct phy *phy; in bcm63xx_usbh_phy_probe() local
388 return -ENOMEM; in bcm63xx_usbh_phy_probe()
392 return -EINVAL; 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()
414 phy = devm_phy_create(dev, NULL, &bcm63xx_usbh_phy_ops); in bcm63xx_usbh_phy_probe()
415 if (IS_ERR(phy)) { in bcm63xx_usbh_phy_probe()
416 dev_err(dev, "failed to create PHY\n"); in bcm63xx_usbh_phy_probe()
417 return PTR_ERR(phy); in bcm63xx_usbh_phy_probe()
421 phy_set_drvdata(phy, usbh); in bcm63xx_usbh_phy_probe()
426 dev_err(dev, "failed to register PHY provider\n"); in bcm63xx_usbh_phy_probe()
430 dev_dbg(dev, "Registered BCM63xx USB PHY driver\n"); 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");