Lines Matching +full:usb2 +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Broadcom Northstar USB 2.0 PHY Driver
16 #include <linux/phy/phy.h>
24 struct phy *phy; member
29 static int bcm_ns_usb2_phy_init(struct phy *phy) in bcm_ns_usb2_phy_init() argument
31 struct bcm_ns_usb2 *usb2 = phy_get_drvdata(phy); in bcm_ns_usb2_phy_init() local
32 struct device *dev = usb2->dev; in bcm_ns_usb2_phy_init()
36 err = clk_prepare_enable(usb2->ref_clk); in bcm_ns_usb2_phy_init()
42 ref_clk_rate = clk_get_rate(usb2->ref_clk); in bcm_ns_usb2_phy_init()
45 err = -EINVAL; in bcm_ns_usb2_phy_init()
49 usb2ctl = readl(usb2->base); in bcm_ns_usb2_phy_init()
59 /* Calculate ndiv based on a solid 1920 MHz that is for USB2 PHY */ in bcm_ns_usb2_phy_init()
63 regmap_write(usb2->clkset, 0, 0x0000ea68); in bcm_ns_usb2_phy_init()
69 writel(usb2ctl, usb2->base); in bcm_ns_usb2_phy_init()
72 regmap_write(usb2->clkset, 0, 0x00000000); in bcm_ns_usb2_phy_init()
75 clk_disable_unprepare(usb2->ref_clk); in bcm_ns_usb2_phy_init()
87 struct device *dev = &pdev->dev; in bcm_ns_usb2_probe()
88 struct bcm_ns_usb2 *usb2; in bcm_ns_usb2_probe() local
91 usb2 = devm_kzalloc(&pdev->dev, sizeof(*usb2), GFP_KERNEL); in bcm_ns_usb2_probe()
92 if (!usb2) in bcm_ns_usb2_probe()
93 return -ENOMEM; in bcm_ns_usb2_probe()
94 usb2->dev = dev; in bcm_ns_usb2_probe()
96 usb2->base = devm_platform_ioremap_resource(pdev, 0); in bcm_ns_usb2_probe()
97 if (IS_ERR(usb2->base)) { in bcm_ns_usb2_probe()
99 return PTR_ERR(usb2->base); in bcm_ns_usb2_probe()
102 usb2->clkset = syscon_regmap_lookup_by_phandle(dev->of_node, in bcm_ns_usb2_probe()
103 "brcm,syscon-clkset"); in bcm_ns_usb2_probe()
104 if (IS_ERR(usb2->clkset)) { in bcm_ns_usb2_probe()
106 return PTR_ERR(usb2->clkset); in bcm_ns_usb2_probe()
109 usb2->ref_clk = devm_clk_get(dev, "phy-ref-clk"); in bcm_ns_usb2_probe()
110 if (IS_ERR(usb2->ref_clk)) { in bcm_ns_usb2_probe()
111 dev_err_probe(dev, PTR_ERR(usb2->ref_clk), "failed to get ref clk\n"); in bcm_ns_usb2_probe()
112 return PTR_ERR(usb2->ref_clk); in bcm_ns_usb2_probe()
115 usb2->phy = devm_phy_create(dev, NULL, &ops); in bcm_ns_usb2_probe()
116 if (IS_ERR(usb2->phy)) in bcm_ns_usb2_probe()
117 return PTR_ERR(usb2->phy); in bcm_ns_usb2_probe()
119 phy_set_drvdata(usb2->phy, usb2); in bcm_ns_usb2_probe()
120 platform_set_drvdata(pdev, usb2); in bcm_ns_usb2_probe()
127 { .compatible = "brcm,ns-usb2-phy", },
141 MODULE_DESCRIPTION("Broadcom Northstar USB 2.0 PHY Driver");