Lines Matching +full:otg +full:- +full:rev

1 // SPDX-License-Identifier: GPL-2.0-only
22 * phy as being SR70LX Synopsys USB 2.0 OTG nanoPHY. It also seems at
23 * least dm816x rev c ignores writes to USB_CTRL register, but the TI
52 static int dm816x_usb_phy_set_host(struct usb_otg *otg, struct usb_bus *host) in dm816x_usb_phy_set_host() argument
54 otg->host = host; in dm816x_usb_phy_set_host()
56 otg->state = OTG_STATE_UNDEFINED; in dm816x_usb_phy_set_host()
61 static int dm816x_usb_phy_set_peripheral(struct usb_otg *otg, in dm816x_usb_phy_set_peripheral() argument
64 otg->gadget = gadget; in dm816x_usb_phy_set_peripheral()
66 otg->state = OTG_STATE_UNDEFINED; in dm816x_usb_phy_set_peripheral()
76 if (clk_get_rate(phy->refclk) != 24000000) in dm816x_usb_phy_init()
77 dev_warn(phy->dev, "nonstandard phy refclk\n"); in dm816x_usb_phy_init()
80 regmap_update_bits(phy->syscon, phy->usb_ctrl, in dm816x_usb_phy_init()
85 regmap_read(phy->syscon, phy->usb_ctrl, &val); in dm816x_usb_phy_init()
87 dev_info(phy->dev, in dm816x_usb_phy_init()
96 regmap_read(phy->syscon, phy->usbphy_ctrl, &val); in dm816x_usb_phy_init()
100 regmap_write(phy->syscon, phy->usbphy_ctrl, val); in dm816x_usb_phy_init()
116 mask = BIT(phy->instance); in dm816x_usb_phy_runtime_suspend()
117 val = ~BIT(phy->instance); in dm816x_usb_phy_runtime_suspend()
118 error = regmap_update_bits(phy->syscon, phy->usb_ctrl, in dm816x_usb_phy_runtime_suspend()
121 dev_err(phy->dev, "phy%i failed to power off\n", in dm816x_usb_phy_runtime_suspend()
122 phy->instance); in dm816x_usb_phy_runtime_suspend()
123 clk_disable(phy->refclk); in dm816x_usb_phy_runtime_suspend()
134 error = clk_enable(phy->refclk); in dm816x_usb_phy_runtime_resume()
139 * Note that at least dm816x rev c does not seem to do in dm816x_usb_phy_runtime_resume()
144 mask = BIT(phy->instance); in dm816x_usb_phy_runtime_resume()
145 val = BIT(phy->instance); in dm816x_usb_phy_runtime_resume()
146 error = regmap_update_bits(phy->syscon, phy->usb_ctrl, in dm816x_usb_phy_runtime_resume()
149 dev_err(phy->dev, "phy%i failed to power on\n", in dm816x_usb_phy_runtime_resume()
150 phy->instance); in dm816x_usb_phy_runtime_resume()
151 clk_disable(phy->refclk); in dm816x_usb_phy_runtime_resume()
165 .compatible = "ti,dm8168-usb-phy",
177 struct usb_otg *otg; in dm816x_usb_phy_probe() local
180 phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); in dm816x_usb_phy_probe()
182 return -ENOMEM; in dm816x_usb_phy_probe()
186 return -ENOENT; in dm816x_usb_phy_probe()
188 phy->syscon = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in dm816x_usb_phy_probe()
190 if (IS_ERR(phy->syscon)) in dm816x_usb_phy_probe()
191 return PTR_ERR(phy->syscon); in dm816x_usb_phy_probe()
198 phy->usb_ctrl = 0x20; in dm816x_usb_phy_probe()
199 phy->usbphy_ctrl = (res->start & 0xff) + 4; in dm816x_usb_phy_probe()
200 if (phy->usbphy_ctrl == 0x2c) in dm816x_usb_phy_probe()
201 phy->instance = 1; in dm816x_usb_phy_probe()
203 otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL); in dm816x_usb_phy_probe()
204 if (!otg) in dm816x_usb_phy_probe()
205 return -ENOMEM; in dm816x_usb_phy_probe()
207 phy->dev = &pdev->dev; in dm816x_usb_phy_probe()
208 phy->phy.dev = phy->dev; in dm816x_usb_phy_probe()
209 phy->phy.label = "dm8168_usb_phy"; in dm816x_usb_phy_probe()
210 phy->phy.otg = otg; in dm816x_usb_phy_probe()
211 phy->phy.type = USB_PHY_TYPE_USB2; in dm816x_usb_phy_probe()
212 otg->set_host = dm816x_usb_phy_set_host; in dm816x_usb_phy_probe()
213 otg->set_peripheral = dm816x_usb_phy_set_peripheral; in dm816x_usb_phy_probe()
214 otg->usb_phy = &phy->phy; in dm816x_usb_phy_probe()
218 phy->refclk = devm_clk_get(phy->dev, "refclk"); in dm816x_usb_phy_probe()
219 if (IS_ERR(phy->refclk)) in dm816x_usb_phy_probe()
220 return PTR_ERR(phy->refclk); in dm816x_usb_phy_probe()
221 error = clk_prepare(phy->refclk); in dm816x_usb_phy_probe()
225 pm_runtime_enable(phy->dev); in dm816x_usb_phy_probe()
226 generic_phy = devm_phy_create(phy->dev, NULL, &ops); in dm816x_usb_phy_probe()
234 phy_provider = devm_of_phy_provider_register(phy->dev, in dm816x_usb_phy_probe()
241 usb_add_phy_dev(&phy->phy); in dm816x_usb_phy_probe()
246 pm_runtime_disable(phy->dev); in dm816x_usb_phy_probe()
247 clk_unprepare(phy->refclk); in dm816x_usb_phy_probe()
255 usb_remove_phy(&phy->phy); in dm816x_usb_phy_remove()
256 pm_runtime_disable(phy->dev); in dm816x_usb_phy_remove()
257 clk_unprepare(phy->refclk); in dm816x_usb_phy_remove()
264 .name = "dm816x-usb-phy",