Lines Matching +full:- +full:refclk
1 // SPDX-License-Identifier: GPL-2.0-only
47 struct clk *refclk; member
55 otg->host = host; in dm816x_usb_phy_set_host()
57 otg->state = OTG_STATE_UNDEFINED; in dm816x_usb_phy_set_host()
65 otg->gadget = gadget; in dm816x_usb_phy_set_peripheral()
67 otg->state = OTG_STATE_UNDEFINED; in dm816x_usb_phy_set_peripheral()
77 if (clk_get_rate(phy->refclk) != 24000000) in dm816x_usb_phy_init()
78 dev_warn(phy->dev, "nonstandard phy refclk\n"); in dm816x_usb_phy_init()
81 regmap_update_bits(phy->syscon, phy->usb_ctrl, in dm816x_usb_phy_init()
86 regmap_read(phy->syscon, phy->usb_ctrl, &val); in dm816x_usb_phy_init()
88 dev_info(phy->dev, in dm816x_usb_phy_init()
97 regmap_read(phy->syscon, phy->usbphy_ctrl, &val); in dm816x_usb_phy_init()
101 regmap_write(phy->syscon, phy->usbphy_ctrl, val); in dm816x_usb_phy_init()
117 mask = BIT(phy->instance); in dm816x_usb_phy_runtime_suspend()
118 val = ~BIT(phy->instance); in dm816x_usb_phy_runtime_suspend()
119 error = regmap_update_bits(phy->syscon, phy->usb_ctrl, in dm816x_usb_phy_runtime_suspend()
122 dev_err(phy->dev, "phy%i failed to power off\n", in dm816x_usb_phy_runtime_suspend()
123 phy->instance); in dm816x_usb_phy_runtime_suspend()
124 clk_disable(phy->refclk); in dm816x_usb_phy_runtime_suspend()
135 error = clk_enable(phy->refclk); in dm816x_usb_phy_runtime_resume()
145 mask = BIT(phy->instance); in dm816x_usb_phy_runtime_resume()
146 val = BIT(phy->instance); in dm816x_usb_phy_runtime_resume()
147 error = regmap_update_bits(phy->syscon, phy->usb_ctrl, in dm816x_usb_phy_runtime_resume()
150 dev_err(phy->dev, "phy%i failed to power on\n", in dm816x_usb_phy_runtime_resume()
151 phy->instance); in dm816x_usb_phy_runtime_resume()
152 clk_disable(phy->refclk); in dm816x_usb_phy_runtime_resume()
167 .compatible = "ti,dm8168-usb-phy",
185 &pdev->dev); in dm816x_usb_phy_probe()
187 return -EINVAL; in dm816x_usb_phy_probe()
189 phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); in dm816x_usb_phy_probe()
191 return -ENOMEM; in dm816x_usb_phy_probe()
195 return -ENOENT; in dm816x_usb_phy_probe()
197 phy->syscon = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in dm816x_usb_phy_probe()
199 if (IS_ERR(phy->syscon)) in dm816x_usb_phy_probe()
200 return PTR_ERR(phy->syscon); in dm816x_usb_phy_probe()
207 phy->usb_ctrl = 0x20; in dm816x_usb_phy_probe()
208 phy->usbphy_ctrl = (res->start & 0xff) + 4; in dm816x_usb_phy_probe()
209 if (phy->usbphy_ctrl == 0x2c) in dm816x_usb_phy_probe()
210 phy->instance = 1; in dm816x_usb_phy_probe()
212 otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL); in dm816x_usb_phy_probe()
214 return -ENOMEM; in dm816x_usb_phy_probe()
216 phy->dev = &pdev->dev; in dm816x_usb_phy_probe()
217 phy->phy.dev = phy->dev; in dm816x_usb_phy_probe()
218 phy->phy.label = "dm8168_usb_phy"; in dm816x_usb_phy_probe()
219 phy->phy.otg = otg; in dm816x_usb_phy_probe()
220 phy->phy.type = USB_PHY_TYPE_USB2; in dm816x_usb_phy_probe()
221 otg->set_host = dm816x_usb_phy_set_host; in dm816x_usb_phy_probe()
222 otg->set_peripheral = dm816x_usb_phy_set_peripheral; in dm816x_usb_phy_probe()
223 otg->usb_phy = &phy->phy; in dm816x_usb_phy_probe()
227 phy->refclk = devm_clk_get(phy->dev, "refclk"); in dm816x_usb_phy_probe()
228 if (IS_ERR(phy->refclk)) in dm816x_usb_phy_probe()
229 return PTR_ERR(phy->refclk); in dm816x_usb_phy_probe()
230 error = clk_prepare(phy->refclk); in dm816x_usb_phy_probe()
234 pm_runtime_enable(phy->dev); in dm816x_usb_phy_probe()
235 generic_phy = devm_phy_create(phy->dev, NULL, &ops); in dm816x_usb_phy_probe()
243 phy_provider = devm_of_phy_provider_register(phy->dev, in dm816x_usb_phy_probe()
250 usb_add_phy_dev(&phy->phy); in dm816x_usb_phy_probe()
255 pm_runtime_disable(phy->dev); in dm816x_usb_phy_probe()
256 clk_unprepare(phy->refclk); in dm816x_usb_phy_probe()
264 usb_remove_phy(&phy->phy); in dm816x_usb_phy_remove()
265 pm_runtime_disable(phy->dev); in dm816x_usb_phy_remove()
266 clk_unprepare(phy->refclk); in dm816x_usb_phy_remove()
275 .name = "dm816x-usb-phy",