Lines Matching +full:exynos5250 +full:- +full:pmu
1 // SPDX-License-Identifier: GPL-2.0-only
16 #include "phy-samsung-usb2.h"
21 struct samsung_usb2_phy_driver *drv = inst->drv; in samsung_usb2_phy_power_on()
24 dev_dbg(drv->dev, "Request to power_on \"%s\" usb phy\n", in samsung_usb2_phy_power_on()
25 inst->cfg->label); in samsung_usb2_phy_power_on()
27 if (drv->vbus) { in samsung_usb2_phy_power_on()
28 ret = regulator_enable(drv->vbus); in samsung_usb2_phy_power_on()
33 ret = clk_prepare_enable(drv->clk); in samsung_usb2_phy_power_on()
36 ret = clk_prepare_enable(drv->ref_clk); in samsung_usb2_phy_power_on()
39 if (inst->cfg->power_on) { in samsung_usb2_phy_power_on()
40 spin_lock(&drv->lock); in samsung_usb2_phy_power_on()
41 ret = inst->cfg->power_on(inst); in samsung_usb2_phy_power_on()
42 spin_unlock(&drv->lock); in samsung_usb2_phy_power_on()
50 clk_disable_unprepare(drv->ref_clk); in samsung_usb2_phy_power_on()
52 clk_disable_unprepare(drv->clk); in samsung_usb2_phy_power_on()
54 if (drv->vbus) in samsung_usb2_phy_power_on()
55 regulator_disable(drv->vbus); in samsung_usb2_phy_power_on()
63 struct samsung_usb2_phy_driver *drv = inst->drv; in samsung_usb2_phy_power_off()
66 dev_dbg(drv->dev, "Request to power_off \"%s\" usb phy\n", in samsung_usb2_phy_power_off()
67 inst->cfg->label); in samsung_usb2_phy_power_off()
68 if (inst->cfg->power_off) { in samsung_usb2_phy_power_off()
69 spin_lock(&drv->lock); in samsung_usb2_phy_power_off()
70 ret = inst->cfg->power_off(inst); in samsung_usb2_phy_power_off()
71 spin_unlock(&drv->lock); in samsung_usb2_phy_power_off()
75 clk_disable_unprepare(drv->ref_clk); in samsung_usb2_phy_power_off()
76 clk_disable_unprepare(drv->clk); in samsung_usb2_phy_power_off()
77 if (drv->vbus) in samsung_usb2_phy_power_off()
78 ret = regulator_disable(drv->vbus); in samsung_usb2_phy_power_off()
96 return ERR_PTR(-EINVAL); in samsung_usb2_phy_xlate()
98 if (WARN_ON(args->args[0] >= drv->cfg->num_phys)) in samsung_usb2_phy_xlate()
99 return ERR_PTR(-ENODEV); in samsung_usb2_phy_xlate()
101 return drv->instances[args->args[0]].phy; in samsung_usb2_phy_xlate()
107 .compatible = "samsung,exynos3250-usb2-phy",
113 .compatible = "samsung,exynos4210-usb2-phy",
119 .compatible = "samsung,exynos4x12-usb2-phy",
125 .compatible = "samsung,exynos5250-usb2-phy",
129 .compatible = "samsung,exynos5420-usb2-phy",
135 .compatible = "samsung,s5pv210-usb2-phy",
146 struct device *dev = &pdev->dev; in samsung_usb2_phy_probe()
151 if (!pdev->dev.of_node) { in samsung_usb2_phy_probe()
153 return -EINVAL; in samsung_usb2_phy_probe()
158 return -EINVAL; in samsung_usb2_phy_probe()
160 drv = devm_kzalloc(dev, struct_size(drv, instances, cfg->num_phys), in samsung_usb2_phy_probe()
163 return -ENOMEM; in samsung_usb2_phy_probe()
166 spin_lock_init(&drv->lock); in samsung_usb2_phy_probe()
168 drv->cfg = cfg; in samsung_usb2_phy_probe()
169 drv->dev = dev; in samsung_usb2_phy_probe()
171 drv->reg_phy = devm_platform_ioremap_resource(pdev, 0); in samsung_usb2_phy_probe()
172 if (IS_ERR(drv->reg_phy)) { in samsung_usb2_phy_probe()
174 return PTR_ERR(drv->reg_phy); in samsung_usb2_phy_probe()
177 drv->reg_pmu = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in samsung_usb2_phy_probe()
178 "samsung,pmureg-phandle"); in samsung_usb2_phy_probe()
179 if (IS_ERR(drv->reg_pmu)) { in samsung_usb2_phy_probe()
180 dev_err(dev, "Failed to map PMU registers (via syscon)\n"); in samsung_usb2_phy_probe()
181 return PTR_ERR(drv->reg_pmu); in samsung_usb2_phy_probe()
184 if (drv->cfg->has_mode_switch) { in samsung_usb2_phy_probe()
185 drv->reg_sys = syscon_regmap_lookup_by_phandle( in samsung_usb2_phy_probe()
186 pdev->dev.of_node, "samsung,sysreg-phandle"); in samsung_usb2_phy_probe()
187 if (IS_ERR(drv->reg_sys)) { in samsung_usb2_phy_probe()
189 return PTR_ERR(drv->reg_sys); in samsung_usb2_phy_probe()
193 drv->clk = devm_clk_get(dev, "phy"); in samsung_usb2_phy_probe()
194 if (IS_ERR(drv->clk)) { in samsung_usb2_phy_probe()
196 return PTR_ERR(drv->clk); in samsung_usb2_phy_probe()
199 drv->ref_clk = devm_clk_get(dev, "ref"); in samsung_usb2_phy_probe()
200 if (IS_ERR(drv->ref_clk)) { in samsung_usb2_phy_probe()
202 return PTR_ERR(drv->ref_clk); in samsung_usb2_phy_probe()
205 drv->ref_rate = clk_get_rate(drv->ref_clk); in samsung_usb2_phy_probe()
206 if (drv->cfg->rate_to_clk) { in samsung_usb2_phy_probe()
207 ret = drv->cfg->rate_to_clk(drv->ref_rate, &drv->ref_reg_val); in samsung_usb2_phy_probe()
212 drv->vbus = devm_regulator_get(dev, "vbus"); in samsung_usb2_phy_probe()
213 if (IS_ERR(drv->vbus)) { in samsung_usb2_phy_probe()
214 ret = PTR_ERR(drv->vbus); in samsung_usb2_phy_probe()
215 if (ret == -EPROBE_DEFER) in samsung_usb2_phy_probe()
217 drv->vbus = NULL; in samsung_usb2_phy_probe()
220 for (i = 0; i < drv->cfg->num_phys; i++) { in samsung_usb2_phy_probe()
221 char *label = drv->cfg->phys[i].label; in samsung_usb2_phy_probe()
222 struct samsung_usb2_phy_instance *p = &drv->instances[i]; in samsung_usb2_phy_probe()
225 p->phy = devm_phy_create(dev, NULL, &samsung_usb2_phy_ops); in samsung_usb2_phy_probe()
226 if (IS_ERR(p->phy)) { in samsung_usb2_phy_probe()
227 dev_err(drv->dev, "Failed to create usb2_phy \"%s\"\n", in samsung_usb2_phy_probe()
229 return PTR_ERR(p->phy); in samsung_usb2_phy_probe()
232 p->cfg = &drv->cfg->phys[i]; in samsung_usb2_phy_probe()
233 p->drv = drv; in samsung_usb2_phy_probe()
234 phy_set_bus_width(p->phy, 8); in samsung_usb2_phy_probe()
235 phy_set_drvdata(p->phy, p); in samsung_usb2_phy_probe()
241 dev_err(drv->dev, "Failed to register phy provider\n"); in samsung_usb2_phy_probe()
252 .name = "samsung-usb2-phy",
261 MODULE_ALIAS("platform:samsung-usb2-phy");