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>
20 #include <linux/phy/phy.h>
86 /* Test Port Control value to set if non-zero */
107 [USBH_BRT_CONTROL1] = -1,
108 [USBH_BRT_CONTROL2] = -1,
109 [USBH_BRT_STATUS1] = -1,
110 [USBH_BRT_STATUS2] = -1,
115 [USBH_GENERIC_CONTROL] = -1,
154 [USBH_BRT_CONTROL1] = -1,
155 [USBH_BRT_CONTROL2] = -1,
156 [USBH_BRT_STATUS1] = -1,
157 [USBH_BRT_STATUS2] = -1,
158 [USBH_UTMI_CONTROL1] = -1,
160 [USBH_PLL_CONTROL1] = -1,
162 [USBH_GENERIC_CONTROL] = -1,
163 [USBH_FRAME_ADJUST_VALUE] = -1,
164 [USBH_SETUP] = -1,
165 [USBH_MDIO] = -1,
166 [USBH_MDIO32] = -1,
167 [USBH_USB_SIM_CONTROL] = -1,
172 * help, so the magic value is used as-is.
187 [USBH_GENERIC_CONTROL] = -1,
226 return (usbh->variant->regs[reg] >= 0); in usbh_has_reg()
231 return __raw_readl(usbh->base + usbh->variant->regs[reg]); in usbh_readl()
237 __raw_writel(value, usbh->base + usbh->variant->regs[reg]); in usbh_writel()
240 static int bcm63xx_usbh_phy_init(struct phy *phy) in bcm63xx_usbh_phy_init() argument
242 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_init()
245 ret = clk_prepare_enable(usbh->usbh_clk); in bcm63xx_usbh_phy_init()
247 dev_err(&phy->dev, "unable to enable usbh clock: %d\n", ret); in bcm63xx_usbh_phy_init()
251 ret = clk_prepare_enable(usbh->usb_ref_clk); in bcm63xx_usbh_phy_init()
253 dev_err(&phy->dev, "unable to enable usb_ref clock: %d\n", ret); in bcm63xx_usbh_phy_init()
254 clk_disable_unprepare(usbh->usbh_clk); in bcm63xx_usbh_phy_init()
258 ret = reset_control_reset(usbh->reset); in bcm63xx_usbh_phy_init()
260 dev_err(&phy->dev, "unable to reset device: %d\n", ret); in bcm63xx_usbh_phy_init()
261 clk_disable_unprepare(usbh->usb_ref_clk); in bcm63xx_usbh_phy_init()
262 clk_disable_unprepare(usbh->usbh_clk); in bcm63xx_usbh_phy_init()
276 if (usbh->device_mode && usbh->variant->swapctl_dev_set) in bcm63xx_usbh_phy_init()
277 val |= usbh->variant->swapctl_dev_set; in bcm63xx_usbh_phy_init()
285 val |= usbh->variant->setup_set; in bcm63xx_usbh_phy_init()
286 val &= ~usbh->variant->setup_clr; in bcm63xx_usbh_phy_init()
294 val |= usbh->variant->usc_set; in bcm63xx_usbh_phy_init()
299 if (usbh->variant->tpc_val && in bcm63xx_usbh_phy_init()
302 usbh->variant->tpc_val); in bcm63xx_usbh_phy_init()
304 if (usbh->device_mode && in bcm63xx_usbh_phy_init()
306 usbh->variant->utmictl1_dev_set) { in bcm63xx_usbh_phy_init()
309 val |= usbh->variant->utmictl1_dev_set; in bcm63xx_usbh_phy_init()
317 static int bcm63xx_usbh_phy_power_on(struct phy *phy) in bcm63xx_usbh_phy_power_on() argument
319 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_power_on()
324 val |= usbh->variant->power_pllc_set; in bcm63xx_usbh_phy_power_on()
325 val &= ~usbh->variant->power_pllc_clr; in bcm63xx_usbh_phy_power_on()
333 static int bcm63xx_usbh_phy_power_off(struct phy *phy) in bcm63xx_usbh_phy_power_off() argument
335 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_power_off()
340 val &= ~usbh->variant->power_pllc_set; in bcm63xx_usbh_phy_power_off()
341 val |= usbh->variant->power_pllc_clr; in bcm63xx_usbh_phy_power_off()
349 static int bcm63xx_usbh_phy_exit(struct phy *phy) in bcm63xx_usbh_phy_exit() argument
351 struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); in bcm63xx_usbh_phy_exit()
353 clk_disable_unprepare(usbh->usbh_clk); in bcm63xx_usbh_phy_exit()
354 clk_disable_unprepare(usbh->usb_ref_clk); in bcm63xx_usbh_phy_exit()
367 static struct phy *bcm63xx_usbh_phy_xlate(struct device *dev, in bcm63xx_usbh_phy_xlate()
372 usbh->device_mode = !!args->args[0]; in bcm63xx_usbh_phy_xlate()
379 struct device *dev = &pdev->dev; in bcm63xx_usbh_phy_probe()
382 struct phy *phy; in bcm63xx_usbh_phy_probe() local
387 return -ENOMEM; in bcm63xx_usbh_phy_probe()
391 return -EINVAL; in bcm63xx_usbh_phy_probe()
392 usbh->variant = variant; in bcm63xx_usbh_phy_probe()
394 usbh->base = devm_platform_ioremap_resource(pdev, 0); in bcm63xx_usbh_phy_probe()
395 if (IS_ERR(usbh->base)) in bcm63xx_usbh_phy_probe()
396 return PTR_ERR(usbh->base); in bcm63xx_usbh_phy_probe()
398 usbh->reset = devm_reset_control_get_exclusive(dev, NULL); in bcm63xx_usbh_phy_probe()
399 if (IS_ERR(usbh->reset)) { in bcm63xx_usbh_phy_probe()
400 if (PTR_ERR(usbh->reset) != -EPROBE_DEFER) in bcm63xx_usbh_phy_probe()
402 return PTR_ERR(usbh->reset); in bcm63xx_usbh_phy_probe()
405 usbh->usbh_clk = devm_clk_get_optional(dev, "usbh"); in bcm63xx_usbh_phy_probe()
406 if (IS_ERR(usbh->usbh_clk)) in bcm63xx_usbh_phy_probe()
407 return PTR_ERR(usbh->usbh_clk); in bcm63xx_usbh_phy_probe()
409 usbh->usb_ref_clk = devm_clk_get_optional(dev, "usb_ref"); in bcm63xx_usbh_phy_probe()
410 if (IS_ERR(usbh->usb_ref_clk)) in bcm63xx_usbh_phy_probe()
411 return PTR_ERR(usbh->usb_ref_clk); in bcm63xx_usbh_phy_probe()
413 phy = devm_phy_create(dev, NULL, &bcm63xx_usbh_phy_ops); in bcm63xx_usbh_phy_probe()
414 if (IS_ERR(phy)) { in bcm63xx_usbh_phy_probe()
415 dev_err(dev, "failed to create PHY\n"); in bcm63xx_usbh_phy_probe()
416 return PTR_ERR(phy); in bcm63xx_usbh_phy_probe()
420 phy_set_drvdata(phy, usbh); in bcm63xx_usbh_phy_probe()
425 dev_err(dev, "failed to register PHY provider\n"); in bcm63xx_usbh_phy_probe()
429 dev_dbg(dev, "Registered BCM63xx USB PHY driver\n"); in bcm63xx_usbh_phy_probe()
435 { .compatible = "brcm,bcm6318-usbh-phy", .data = &usbh_bcm6318 },
436 { .compatible = "brcm,bcm6328-usbh-phy", .data = &usbh_bcm6328 },
437 { .compatible = "brcm,bcm6358-usbh-phy", .data = &usbh_bcm6358 },
438 { .compatible = "brcm,bcm6362-usbh-phy", .data = &usbh_bcm6368 },
439 { .compatible = "brcm,bcm6368-usbh-phy", .data = &usbh_bcm6368 },
440 { .compatible = "brcm,bcm63268-usbh-phy", .data = &usbh_bcm63268 },
447 .name = "bcm63xx-usbh-phy",
454 MODULE_DESCRIPTION("BCM63xx USBH PHY driver");