Lines Matching +full:am62 +full:- +full:usb
1 // SPDX-License-Identifier: GPL-2.0
3 * dwc3-am62.c - TI specific Glue layer for AM62 DWC3 USB Controller
5 * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com
22 /* USB WRAPPER register offsets */
132 static inline u32 dwc3_ti_readl(struct dwc3_am62 *am62, u32 offset) in dwc3_ti_readl() argument
134 return readl((am62->usbss) + offset); in dwc3_ti_readl()
137 static inline void dwc3_ti_writel(struct dwc3_am62 *am62, u32 offset, u32 value) in dwc3_ti_writel() argument
139 writel(value, (am62->usbss) + offset); in dwc3_ti_writel()
142 static int phy_syscon_pll_refclk(struct dwc3_am62 *am62) in phy_syscon_pll_refclk() argument
144 struct device *dev = am62->dev; in phy_syscon_pll_refclk()
145 struct device_node *node = dev->of_node; in phy_syscon_pll_refclk()
150 syscon = syscon_regmap_lookup_by_phandle(node, "ti,syscon-phy-pll-refclk"); in phy_syscon_pll_refclk()
152 dev_err(dev, "unable to get ti,syscon-phy-pll-refclk regmap\n"); in phy_syscon_pll_refclk()
156 am62->syscon = syscon; in phy_syscon_pll_refclk()
158 ret = of_parse_phandle_with_fixed_args(node, "ti,syscon-phy-pll-refclk", 1, in phy_syscon_pll_refclk()
164 am62->offset = args.args[0]; in phy_syscon_pll_refclk()
166 ret = regmap_update_bits(am62->syscon, am62->offset, PHY_PLL_REFCLK_MASK, am62->rate_code); in phy_syscon_pll_refclk()
177 struct device *dev = &pdev->dev; in dwc3_ti_probe()
178 struct device_node *node = pdev->dev.of_node; in dwc3_ti_probe()
179 struct dwc3_am62 *am62; in dwc3_ti_probe() local
184 am62 = devm_kzalloc(dev, sizeof(*am62), GFP_KERNEL); in dwc3_ti_probe()
185 if (!am62) in dwc3_ti_probe()
186 return -ENOMEM; in dwc3_ti_probe()
188 am62->dev = dev; in dwc3_ti_probe()
189 platform_set_drvdata(pdev, am62); in dwc3_ti_probe()
191 am62->usbss = devm_platform_ioremap_resource(pdev, 0); in dwc3_ti_probe()
192 if (IS_ERR(am62->usbss)) { in dwc3_ti_probe()
194 return PTR_ERR(am62->usbss); in dwc3_ti_probe()
197 am62->usb2_refclk = devm_clk_get(dev, "ref"); in dwc3_ti_probe()
198 if (IS_ERR(am62->usb2_refclk)) { in dwc3_ti_probe()
200 return PTR_ERR(am62->usb2_refclk); in dwc3_ti_probe()
204 rate = clk_get_rate(am62->usb2_refclk); in dwc3_ti_probe()
213 return -EINVAL; in dwc3_ti_probe()
216 am62->rate_code = i; in dwc3_ti_probe()
219 ret = phy_syscon_pll_refclk(am62); in dwc3_ti_probe()
224 am62->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); in dwc3_ti_probe()
225 reg = dwc3_ti_readl(am62, USBSS_PHY_CONFIG); in dwc3_ti_probe()
226 if (am62->vbus_divider) in dwc3_ti_probe()
229 dwc3_ti_writel(am62, USBSS_PHY_CONFIG, reg); in dwc3_ti_probe()
237 clk_prepare_enable(am62->usb2_refclk); in dwc3_ti_probe()
247 reg = dwc3_ti_readl(am62, USBSS_MODE_CONTROL); in dwc3_ti_probe()
249 dwc3_ti_writel(am62, USBSS_MODE_CONTROL, reg); in dwc3_ti_probe()
265 clk_disable_unprepare(am62->usb2_refclk); in dwc3_ti_probe()
273 struct device *dev = &pdev->dev; in dwc3_ti_remove()
274 struct dwc3_am62 *am62 = platform_get_drvdata(pdev); in dwc3_ti_remove() local
282 reg = dwc3_ti_readl(am62, USBSS_MODE_CONTROL); in dwc3_ti_remove()
284 dwc3_ti_writel(am62, USBSS_MODE_CONTROL, reg); in dwc3_ti_remove()
295 struct dwc3_am62 *am62 = dev_get_drvdata(dev); in dwc3_ti_suspend_common() local
299 reg = dwc3_ti_readl(am62, USBSS_CORE_STAT); in dwc3_ti_suspend_common()
303 reg = dwc3_ti_readl(am62, USBSS_WAKEUP_CONFIG); in dwc3_ti_suspend_common()
310 * and in U2/L3 state else it causes spurious wake-up. in dwc3_ti_suspend_common()
313 dwc3_ti_writel(am62, USBSS_WAKEUP_CONFIG, reg); in dwc3_ti_suspend_common()
315 dwc3_ti_writel(am62, USBSS_WAKEUP_STAT, USBSS_WAKEUP_STAT_CLR); in dwc3_ti_suspend_common()
318 clk_disable_unprepare(am62->usb2_refclk); in dwc3_ti_suspend_common()
325 struct dwc3_am62 *am62 = dev_get_drvdata(dev); in dwc3_ti_resume_common() local
328 clk_prepare_enable(am62->usb2_refclk); in dwc3_ti_resume_common()
332 dwc3_ti_writel(am62, USBSS_WAKEUP_CONFIG, USBSS_WAKEUP_CFG_NONE); in dwc3_ti_resume_common()
335 reg = dwc3_ti_readl(am62, USBSS_WAKEUP_STAT); in dwc3_ti_resume_common()
336 am62->wakeup_stat = reg; in dwc3_ti_resume_common()
350 { .compatible = "ti,am62-usb"},
359 .name = "dwc3-am62",
367 MODULE_ALIAS("platform:dwc3-am62");
368 MODULE_AUTHOR("Aswath Govindraju <a-govindraju@ti.com>");