Lines Matching +full:meson +full:- +full:gxbb +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Meson8, Meson8b and GXBB USB2 PHY driver
15 #include <linux/reset.h>
50 /* bits [31:26], [24:21] and [15:3] seem to be read-only */
129 struct reset_control *reset; member
146 if (!IS_ERR_OR_NULL(priv->reset)) { in phy_meson8b_usb2_power_on()
147 ret = reset_control_reset(priv->reset); in phy_meson8b_usb2_power_on()
149 dev_err(&phy->dev, "Failed to trigger USB reset\n"); in phy_meson8b_usb2_power_on()
154 ret = clk_prepare_enable(priv->clk_usb_general); in phy_meson8b_usb2_power_on()
156 dev_err(&phy->dev, "Failed to enable USB general clock\n"); in phy_meson8b_usb2_power_on()
160 ret = clk_prepare_enable(priv->clk_usb); in phy_meson8b_usb2_power_on()
162 dev_err(&phy->dev, "Failed to enable USB DDR clock\n"); in phy_meson8b_usb2_power_on()
163 clk_disable_unprepare(priv->clk_usb_general); in phy_meson8b_usb2_power_on()
167 regmap_update_bits(priv->regmap, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL, in phy_meson8b_usb2_power_on()
170 regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK, in phy_meson8b_usb2_power_on()
173 regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_FSEL_MASK, in phy_meson8b_usb2_power_on()
176 /* reset the PHY */ in phy_meson8b_usb2_power_on()
177 regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET, in phy_meson8b_usb2_power_on()
180 regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET, 0); in phy_meson8b_usb2_power_on()
183 regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT, in phy_meson8b_usb2_power_on()
186 if (priv->dr_mode == USB_DR_MODE_HOST) { in phy_meson8b_usb2_power_on()
187 regmap_update_bits(priv->regmap, REG_DBG_UART, in phy_meson8b_usb2_power_on()
190 if (priv->match->host_enable_aca) { in phy_meson8b_usb2_power_on()
191 regmap_update_bits(priv->regmap, REG_ADP_BC, in phy_meson8b_usb2_power_on()
197 regmap_read(priv->regmap, REG_ADP_BC, &reg); in phy_meson8b_usb2_power_on()
199 dev_warn(&phy->dev, "USB ID detect failed!\n"); in phy_meson8b_usb2_power_on()
200 clk_disable_unprepare(priv->clk_usb); in phy_meson8b_usb2_power_on()
201 clk_disable_unprepare(priv->clk_usb_general); in phy_meson8b_usb2_power_on()
202 return -EINVAL; in phy_meson8b_usb2_power_on()
214 if (priv->dr_mode == USB_DR_MODE_HOST) in phy_meson8b_usb2_power_off()
215 regmap_update_bits(priv->regmap, REG_DBG_UART, in phy_meson8b_usb2_power_off()
219 clk_disable_unprepare(priv->clk_usb); in phy_meson8b_usb2_power_off()
220 clk_disable_unprepare(priv->clk_usb_general); in phy_meson8b_usb2_power_off()
238 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in phy_meson8b_usb2_probe()
240 return -ENOMEM; in phy_meson8b_usb2_probe()
246 priv->match = device_get_match_data(&pdev->dev); in phy_meson8b_usb2_probe()
247 if (!priv->match) in phy_meson8b_usb2_probe()
248 return -ENODEV; in phy_meson8b_usb2_probe()
250 priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, in phy_meson8b_usb2_probe()
252 if (IS_ERR(priv->regmap)) in phy_meson8b_usb2_probe()
253 return PTR_ERR(priv->regmap); in phy_meson8b_usb2_probe()
255 priv->clk_usb_general = devm_clk_get(&pdev->dev, "usb_general"); in phy_meson8b_usb2_probe()
256 if (IS_ERR(priv->clk_usb_general)) in phy_meson8b_usb2_probe()
257 return PTR_ERR(priv->clk_usb_general); in phy_meson8b_usb2_probe()
259 priv->clk_usb = devm_clk_get(&pdev->dev, "usb"); in phy_meson8b_usb2_probe()
260 if (IS_ERR(priv->clk_usb)) in phy_meson8b_usb2_probe()
261 return PTR_ERR(priv->clk_usb); in phy_meson8b_usb2_probe()
263 priv->reset = devm_reset_control_get_optional_shared(&pdev->dev, NULL); in phy_meson8b_usb2_probe()
264 if (PTR_ERR(priv->reset) == -EPROBE_DEFER) in phy_meson8b_usb2_probe()
265 return PTR_ERR(priv->reset); in phy_meson8b_usb2_probe()
267 priv->dr_mode = of_usb_get_dr_mode_by_phy(pdev->dev.of_node, -1); in phy_meson8b_usb2_probe()
268 if (priv->dr_mode == USB_DR_MODE_UNKNOWN) { in phy_meson8b_usb2_probe()
269 dev_err(&pdev->dev, in phy_meson8b_usb2_probe()
271 return -EINVAL; in phy_meson8b_usb2_probe()
274 phy = devm_phy_create(&pdev->dev, NULL, &phy_meson8b_usb2_ops); in phy_meson8b_usb2_probe()
276 dev_err(&pdev->dev, "failed to create PHY\n"); in phy_meson8b_usb2_probe()
283 devm_of_phy_provider_register(&pdev->dev, of_phy_simple_xlate); in phy_meson8b_usb2_probe()
298 .compatible = "amlogic,meson8-usb2-phy",
302 .compatible = "amlogic,meson8b-usb2-phy",
306 .compatible = "amlogic,meson8m2-usb2-phy",
310 .compatible = "amlogic,meson-gxbb-usb2-phy",
320 .name = "phy-meson-usb2",
327 MODULE_DESCRIPTION("Meson8, Meson8b, Meson8m2 and GXBB USB2 PHY driver");