Lines Matching +full:- +full:refclk

1 // SPDX-License-Identifier: GPL-2.0-only
19 #include <dt-bindings/phy/phy-pistachio-usb.h>
38 unsigned int refclk; member
59 ret = clk_prepare_enable(p_phy->phy_clk); in pistachio_usb_phy_power_on()
61 dev_err(p_phy->dev, "Failed to enable PHY clock: %d\n", ret); in pistachio_usb_phy_power_on()
65 regmap_update_bits(p_phy->cr_top, USB_PHY_STRAP_CONTROL, in pistachio_usb_phy_power_on()
68 p_phy->refclk << USB_PHY_STRAP_CONTROL_REFCLK_SHIFT); in pistachio_usb_phy_power_on()
70 rate = clk_get_rate(p_phy->phy_clk); in pistachio_usb_phy_power_on()
71 if (p_phy->refclk == REFCLK_XO_CRYSTAL && rate != 12000000) { in pistachio_usb_phy_power_on()
72 dev_err(p_phy->dev, "Unsupported rate for XO crystal: %ld\n", in pistachio_usb_phy_power_on()
74 ret = -EINVAL; in pistachio_usb_phy_power_on()
83 dev_err(p_phy->dev, "Unsupported clock rate: %lu\n", rate); in pistachio_usb_phy_power_on()
84 ret = -EINVAL; in pistachio_usb_phy_power_on()
88 regmap_update_bits(p_phy->cr_top, USB_PHY_CONTROL1, in pistachio_usb_phy_power_on()
97 regmap_read(p_phy->cr_top, USB_PHY_STATUS, &val); in pistachio_usb_phy_power_on()
99 dev_err(p_phy->dev, "VBUS fault detected\n"); in pistachio_usb_phy_power_on()
100 ret = -EIO; in pistachio_usb_phy_power_on()
109 dev_err(p_phy->dev, "Timed out waiting for PHY to power on\n"); in pistachio_usb_phy_power_on()
110 ret = -ETIMEDOUT; in pistachio_usb_phy_power_on()
113 clk_disable_unprepare(p_phy->phy_clk); in pistachio_usb_phy_power_on()
121 clk_disable_unprepare(p_phy->phy_clk); in pistachio_usb_phy_power_off()
139 p_phy = devm_kzalloc(&pdev->dev, sizeof(*p_phy), GFP_KERNEL); in pistachio_usb_phy_probe()
141 return -ENOMEM; in pistachio_usb_phy_probe()
142 p_phy->dev = &pdev->dev; in pistachio_usb_phy_probe()
145 p_phy->cr_top = syscon_regmap_lookup_by_phandle(p_phy->dev->of_node, in pistachio_usb_phy_probe()
146 "img,cr-top"); in pistachio_usb_phy_probe()
147 if (IS_ERR(p_phy->cr_top)) { in pistachio_usb_phy_probe()
148 dev_err(p_phy->dev, "Failed to get CR_TOP registers: %ld\n", in pistachio_usb_phy_probe()
149 PTR_ERR(p_phy->cr_top)); in pistachio_usb_phy_probe()
150 return PTR_ERR(p_phy->cr_top); in pistachio_usb_phy_probe()
153 p_phy->phy_clk = devm_clk_get(p_phy->dev, "usb_phy"); in pistachio_usb_phy_probe()
154 if (IS_ERR(p_phy->phy_clk)) { in pistachio_usb_phy_probe()
155 dev_err(p_phy->dev, "Failed to get usb_phy clock: %ld\n", in pistachio_usb_phy_probe()
156 PTR_ERR(p_phy->phy_clk)); in pistachio_usb_phy_probe()
157 return PTR_ERR(p_phy->phy_clk); in pistachio_usb_phy_probe()
160 ret = of_property_read_u32(p_phy->dev->of_node, "img,refclk", in pistachio_usb_phy_probe()
161 &p_phy->refclk); in pistachio_usb_phy_probe()
163 dev_err(p_phy->dev, "No reference clock selector specified\n"); in pistachio_usb_phy_probe()
167 phy = devm_phy_create(p_phy->dev, NULL, &pistachio_usb_phy_ops); in pistachio_usb_phy_probe()
169 dev_err(p_phy->dev, "Failed to create PHY: %ld\n", in pistachio_usb_phy_probe()
175 provider = devm_of_phy_provider_register(p_phy->dev, in pistachio_usb_phy_probe()
178 dev_err(p_phy->dev, "Failed to register PHY provider: %ld\n", in pistachio_usb_phy_probe()
187 { .compatible = "img,pistachio-usb-phy", },
195 .name = "pistachio-usb-phy",