Lines Matching +full:usb3 +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0
3 * phy-uniphier-usb3ss.c - SS-PHY driver for Socionext UniPhier USB3 controller
4 * Copyright 2015-2018 Socionext Inc.
19 #include <linux/phy/phy.h>
73 writel(data, priv->base + SSPHY_TESTI); in uniphier_u3ssphy_testio_write()
74 readl(priv->base + SSPHY_TESTO); in uniphier_u3ssphy_testio_write()
75 readl(priv->base + SSPHY_TESTO); in uniphier_u3ssphy_testio_write()
82 u8 field_mask = GENMASK(p->field.msb, p->field.lsb); in uniphier_u3ssphy_set_param()
87 val |= FIELD_PREP(TESTI_ADR_MASK, p->field.reg_no); in uniphier_u3ssphy_set_param()
89 val = readl(priv->base + SSPHY_TESTO) & TESTO_DAT_MASK; in uniphier_u3ssphy_set_param()
93 data = field_mask & (p->value << p->field.lsb); in uniphier_u3ssphy_set_param()
95 val |= FIELD_PREP(TESTI_ADR_MASK, p->field.reg_no); in uniphier_u3ssphy_set_param()
102 val |= FIELD_PREP(TESTI_ADR_MASK, p->field.reg_no); in uniphier_u3ssphy_set_param()
104 readl(priv->base + SSPHY_TESTO); in uniphier_u3ssphy_set_param()
107 static int uniphier_u3ssphy_power_on(struct phy *phy) in uniphier_u3ssphy_power_on() argument
109 struct uniphier_u3ssphy_priv *priv = phy_get_drvdata(phy); in uniphier_u3ssphy_power_on()
112 ret = clk_prepare_enable(priv->clk_ext); in uniphier_u3ssphy_power_on()
116 ret = clk_prepare_enable(priv->clk); in uniphier_u3ssphy_power_on()
120 ret = reset_control_deassert(priv->rst); in uniphier_u3ssphy_power_on()
124 if (priv->vbus) { in uniphier_u3ssphy_power_on()
125 ret = regulator_enable(priv->vbus); in uniphier_u3ssphy_power_on()
133 reset_control_assert(priv->rst); in uniphier_u3ssphy_power_on()
135 clk_disable_unprepare(priv->clk); in uniphier_u3ssphy_power_on()
137 clk_disable_unprepare(priv->clk_ext); in uniphier_u3ssphy_power_on()
142 static int uniphier_u3ssphy_power_off(struct phy *phy) in uniphier_u3ssphy_power_off() argument
144 struct uniphier_u3ssphy_priv *priv = phy_get_drvdata(phy); in uniphier_u3ssphy_power_off()
146 if (priv->vbus) in uniphier_u3ssphy_power_off()
147 regulator_disable(priv->vbus); in uniphier_u3ssphy_power_off()
149 reset_control_assert(priv->rst); in uniphier_u3ssphy_power_off()
150 clk_disable_unprepare(priv->clk); in uniphier_u3ssphy_power_off()
151 clk_disable_unprepare(priv->clk_ext); in uniphier_u3ssphy_power_off()
156 static int uniphier_u3ssphy_init(struct phy *phy) in uniphier_u3ssphy_init() argument
158 struct uniphier_u3ssphy_priv *priv = phy_get_drvdata(phy); in uniphier_u3ssphy_init()
161 ret = clk_prepare_enable(priv->clk_parent); in uniphier_u3ssphy_init()
165 ret = clk_prepare_enable(priv->clk_parent_gio); in uniphier_u3ssphy_init()
169 ret = reset_control_deassert(priv->rst_parent); in uniphier_u3ssphy_init()
173 ret = reset_control_deassert(priv->rst_parent_gio); in uniphier_u3ssphy_init()
177 if (priv->data->is_legacy) in uniphier_u3ssphy_init()
180 for (i = 0; i < priv->data->nparams; i++) in uniphier_u3ssphy_init()
181 uniphier_u3ssphy_set_param(priv, &priv->data->param[i]); in uniphier_u3ssphy_init()
186 reset_control_assert(priv->rst_parent); in uniphier_u3ssphy_init()
188 clk_disable_unprepare(priv->clk_parent_gio); in uniphier_u3ssphy_init()
190 clk_disable_unprepare(priv->clk_parent); in uniphier_u3ssphy_init()
195 static int uniphier_u3ssphy_exit(struct phy *phy) in uniphier_u3ssphy_exit() argument
197 struct uniphier_u3ssphy_priv *priv = phy_get_drvdata(phy); in uniphier_u3ssphy_exit()
199 reset_control_assert(priv->rst_parent_gio); in uniphier_u3ssphy_exit()
200 reset_control_assert(priv->rst_parent); in uniphier_u3ssphy_exit()
201 clk_disable_unprepare(priv->clk_parent_gio); in uniphier_u3ssphy_exit()
202 clk_disable_unprepare(priv->clk_parent); in uniphier_u3ssphy_exit()
217 struct device *dev = &pdev->dev; in uniphier_u3ssphy_probe()
220 struct phy *phy; in uniphier_u3ssphy_probe() local
224 return -ENOMEM; in uniphier_u3ssphy_probe()
226 priv->dev = dev; in uniphier_u3ssphy_probe()
227 priv->data = of_device_get_match_data(dev); in uniphier_u3ssphy_probe()
228 if (WARN_ON(!priv->data || in uniphier_u3ssphy_probe()
229 priv->data->nparams > MAX_PHY_PARAMS)) in uniphier_u3ssphy_probe()
230 return -EINVAL; in uniphier_u3ssphy_probe()
232 priv->base = devm_platform_ioremap_resource(pdev, 0); in uniphier_u3ssphy_probe()
233 if (IS_ERR(priv->base)) in uniphier_u3ssphy_probe()
234 return PTR_ERR(priv->base); in uniphier_u3ssphy_probe()
236 if (!priv->data->is_legacy) { in uniphier_u3ssphy_probe()
237 priv->clk = devm_clk_get(dev, "phy"); in uniphier_u3ssphy_probe()
238 if (IS_ERR(priv->clk)) in uniphier_u3ssphy_probe()
239 return PTR_ERR(priv->clk); in uniphier_u3ssphy_probe()
241 priv->clk_ext = devm_clk_get_optional(dev, "phy-ext"); in uniphier_u3ssphy_probe()
242 if (IS_ERR(priv->clk_ext)) in uniphier_u3ssphy_probe()
243 return PTR_ERR(priv->clk_ext); in uniphier_u3ssphy_probe()
245 priv->rst = devm_reset_control_get_shared(dev, "phy"); in uniphier_u3ssphy_probe()
246 if (IS_ERR(priv->rst)) in uniphier_u3ssphy_probe()
247 return PTR_ERR(priv->rst); in uniphier_u3ssphy_probe()
249 priv->clk_parent_gio = devm_clk_get(dev, "gio"); in uniphier_u3ssphy_probe()
250 if (IS_ERR(priv->clk_parent_gio)) in uniphier_u3ssphy_probe()
251 return PTR_ERR(priv->clk_parent_gio); in uniphier_u3ssphy_probe()
253 priv->rst_parent_gio = in uniphier_u3ssphy_probe()
255 if (IS_ERR(priv->rst_parent_gio)) in uniphier_u3ssphy_probe()
256 return PTR_ERR(priv->rst_parent_gio); in uniphier_u3ssphy_probe()
259 priv->clk_parent = devm_clk_get(dev, "link"); in uniphier_u3ssphy_probe()
260 if (IS_ERR(priv->clk_parent)) in uniphier_u3ssphy_probe()
261 return PTR_ERR(priv->clk_parent); in uniphier_u3ssphy_probe()
263 priv->rst_parent = devm_reset_control_get_shared(dev, "link"); in uniphier_u3ssphy_probe()
264 if (IS_ERR(priv->rst_parent)) in uniphier_u3ssphy_probe()
265 return PTR_ERR(priv->rst_parent); in uniphier_u3ssphy_probe()
267 priv->vbus = devm_regulator_get_optional(dev, "vbus"); in uniphier_u3ssphy_probe()
268 if (IS_ERR(priv->vbus)) { in uniphier_u3ssphy_probe()
269 if (PTR_ERR(priv->vbus) == -EPROBE_DEFER) in uniphier_u3ssphy_probe()
270 return PTR_ERR(priv->vbus); in uniphier_u3ssphy_probe()
271 priv->vbus = NULL; in uniphier_u3ssphy_probe()
274 phy = devm_phy_create(dev, dev->of_node, &uniphier_u3ssphy_ops); in uniphier_u3ssphy_probe()
275 if (IS_ERR(phy)) in uniphier_u3ssphy_probe()
276 return PTR_ERR(phy); in uniphier_u3ssphy_probe()
278 phy_set_drvdata(phy, priv); in uniphier_u3ssphy_probe()
314 .compatible = "socionext,uniphier-pro4-usb3-ssphy",
318 .compatible = "socionext,uniphier-pro5-usb3-ssphy",
322 .compatible = "socionext,uniphier-pxs2-usb3-ssphy",
326 .compatible = "socionext,uniphier-ld20-usb3-ssphy",
330 .compatible = "socionext,uniphier-pxs3-usb3-ssphy",
334 .compatible = "socionext,uniphier-nx1-usb3-ssphy",
344 .name = "uniphier-usb3-ssphy",
352 MODULE_DESCRIPTION("UniPhier SS-PHY driver for USB3 controller");