Lines Matching +full:usb +full:- +full:glue

1 // SPDX-License-Identifier: GPL-2.0+
3 * dwc3-st.c Support for dwc3 platform devices on ST Microelectronics platforms
5 * This is a small driver for the dwc3 to provide the glue logic
14 * Inspired by dwc3-omap.c and dwc3-exynos.c.
31 #include <linux/usb/of.h>
36 /* glue registers */
78 * struct st_dwc3 - dwc3-st driver private structure
80 * @glue_base: ioaddr for the glue registers
82 * @syscfg_reg_off: usb syscfg control offset
120 err = regmap_read(dwc3_data->regmap, dwc3_data->syscfg_reg_off, &val); in st_dwc3_drd_init()
126 switch (dwc3_data->dr_mode) { in st_dwc3_drd_init()
161 dev_err(dwc3_data->dev, "Unsupported mode of operation %d\n", in st_dwc3_drd_init()
162 dwc3_data->dr_mode); in st_dwc3_drd_init()
163 return -EINVAL; in st_dwc3_drd_init()
166 return regmap_write(dwc3_data->regmap, dwc3_data->syscfg_reg_off, val); in st_dwc3_drd_init()
170 * st_dwc3_init: init the controller via glue logic
175 u32 reg = st_dwc3_readl(dwc3_data->glue_base, CLKRST_CTRL); in st_dwc3_init()
179 st_dwc3_writel(dwc3_data->glue_base, CLKRST_CTRL, reg); in st_dwc3_init()
182 reg = st_dwc3_readl(dwc3_data->glue_base, USB2_VBUS_MNGMNT_SEL1); in st_dwc3_init()
188 st_dwc3_writel(dwc3_data->glue_base, USB2_VBUS_MNGMNT_SEL1, reg); in st_dwc3_init()
190 reg = st_dwc3_readl(dwc3_data->glue_base, CLKRST_CTRL); in st_dwc3_init()
192 st_dwc3_writel(dwc3_data->glue_base, CLKRST_CTRL, reg); in st_dwc3_init()
199 struct device *dev = &pdev->dev; in st_dwc3_probe()
200 struct device_node *node = dev->of_node, *child; in st_dwc3_probe()
207 return -ENOMEM; in st_dwc3_probe()
209 dwc3_data->glue_base = in st_dwc3_probe()
210 devm_platform_ioremap_resource_byname(pdev, "reg-glue"); in st_dwc3_probe()
211 if (IS_ERR(dwc3_data->glue_base)) in st_dwc3_probe()
212 return PTR_ERR(dwc3_data->glue_base); in st_dwc3_probe()
218 dwc3_data->dev = dev; in st_dwc3_probe()
219 dwc3_data->regmap = regmap; in st_dwc3_probe()
221 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "syscfg-reg"); in st_dwc3_probe()
223 ret = -ENXIO; in st_dwc3_probe()
227 dwc3_data->syscfg_reg_off = res->start; in st_dwc3_probe()
229 dev_vdbg(&pdev->dev, "glue-logic addr 0x%pK, syscfg-reg offset 0x%x\n", in st_dwc3_probe()
230 dwc3_data->glue_base, dwc3_data->syscfg_reg_off); in st_dwc3_probe()
232 dwc3_data->rstc_pwrdn = in st_dwc3_probe()
234 if (IS_ERR(dwc3_data->rstc_pwrdn)) { in st_dwc3_probe()
235 dev_err(&pdev->dev, "could not get power controller\n"); in st_dwc3_probe()
236 ret = PTR_ERR(dwc3_data->rstc_pwrdn); in st_dwc3_probe()
241 reset_control_deassert(dwc3_data->rstc_pwrdn); in st_dwc3_probe()
243 dwc3_data->rstc_rst = in st_dwc3_probe()
245 if (IS_ERR(dwc3_data->rstc_rst)) { in st_dwc3_probe()
246 dev_err(&pdev->dev, "could not get reset controller\n"); in st_dwc3_probe()
247 ret = PTR_ERR(dwc3_data->rstc_rst); in st_dwc3_probe()
252 reset_control_deassert(dwc3_data->rstc_rst); in st_dwc3_probe()
256 dev_err(&pdev->dev, "failed to find dwc3 core node\n"); in st_dwc3_probe()
257 ret = -ENODEV; in st_dwc3_probe()
271 ret = -ENODEV; in st_dwc3_probe()
275 dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev); in st_dwc3_probe()
280 * Configure the USB port as device or host according to the static in st_dwc3_probe()
291 /* ST glue logic init */ in st_dwc3_probe()
300 reset_control_assert(dwc3_data->rstc_rst); in st_dwc3_probe()
302 reset_control_assert(dwc3_data->rstc_pwrdn); in st_dwc3_probe()
312 of_platform_depopulate(&pdev->dev); in st_dwc3_remove()
314 reset_control_assert(dwc3_data->rstc_pwrdn); in st_dwc3_remove()
315 reset_control_assert(dwc3_data->rstc_rst); in st_dwc3_remove()
325 reset_control_assert(dwc3_data->rstc_pwrdn); in st_dwc3_suspend()
326 reset_control_assert(dwc3_data->rstc_rst); in st_dwc3_suspend()
340 reset_control_deassert(dwc3_data->rstc_pwrdn); in st_dwc3_resume()
341 reset_control_deassert(dwc3_data->rstc_rst); in st_dwc3_resume()
349 /* ST glue logic init */ in st_dwc3_resume()
359 { .compatible = "st,stih407-dwc3" },
369 .name = "usb-st-dwc3",
378 MODULE_DESCRIPTION("DesignWare USB3 STi Glue Layer");