Lines Matching +full:syscon +full:- +full:wakeup

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
12 #include <linux/mfd/syscon.h>
57 /* WAKEUP CONFIG register bits */
70 /* WAKEUP STAT register bits */
119 struct regmap *syscon; member
144 return readl((am62->usbss) + offset); in dwc3_ti_readl()
149 writel(value, (am62->usbss) + offset); in dwc3_ti_writel()
154 struct device *dev = am62->dev; in phy_syscon_pll_refclk()
155 struct device_node *node = dev->of_node; in phy_syscon_pll_refclk()
157 struct regmap *syscon; in phy_syscon_pll_refclk() local
160 syscon = syscon_regmap_lookup_by_phandle(node, "ti,syscon-phy-pll-refclk"); in phy_syscon_pll_refclk()
161 if (IS_ERR(syscon)) { in phy_syscon_pll_refclk()
162 dev_err(dev, "unable to get ti,syscon-phy-pll-refclk regmap\n"); in phy_syscon_pll_refclk()
163 return PTR_ERR(syscon); in phy_syscon_pll_refclk()
166 am62->syscon = syscon; in phy_syscon_pll_refclk()
168 ret = of_parse_phandle_with_fixed_args(node, "ti,syscon-phy-pll-refclk", 1, in phy_syscon_pll_refclk()
174 am62->offset = args.args[0]; in phy_syscon_pll_refclk()
177 ret = regmap_update_bits(am62->syscon, am62->offset, PHY_CORE_VOLTAGE_MASK, 0); in phy_syscon_pll_refclk()
183 ret = regmap_update_bits(am62->syscon, am62->offset, PHY_PLL_REFCLK_MASK, am62->rate_code); in phy_syscon_pll_refclk()
197 /* Read the syscon property and set the rate code */ in dwc3_ti_init()
203 if (am62->phy_regs) { in dwc3_ti_init()
204 reg = readl(am62->phy_regs + USB_PHY_PLL_REG12); in dwc3_ti_init()
206 writel(reg, am62->phy_regs + USB_PHY_PLL_REG12); in dwc3_ti_init()
211 if (am62->vbus_divider) in dwc3_ti_init()
216 clk_prepare_enable(am62->usb2_refclk); in dwc3_ti_init()
228 struct device *dev = &pdev->dev; in dwc3_ti_probe()
229 struct device_node *node = pdev->dev.of_node; in dwc3_ti_probe()
236 return -ENOMEM; in dwc3_ti_probe()
238 am62->dev = dev; in dwc3_ti_probe()
241 am62->usbss = devm_platform_ioremap_resource(pdev, 0); in dwc3_ti_probe()
242 if (IS_ERR(am62->usbss)) { in dwc3_ti_probe()
244 return PTR_ERR(am62->usbss); in dwc3_ti_probe()
247 am62->usb2_refclk = devm_clk_get(dev, "ref"); in dwc3_ti_probe()
248 if (IS_ERR(am62->usb2_refclk)) { in dwc3_ti_probe()
250 return PTR_ERR(am62->usb2_refclk); in dwc3_ti_probe()
254 rate = clk_get_rate(am62->usb2_refclk); in dwc3_ti_probe()
263 return -EINVAL; in dwc3_ti_probe()
266 am62->rate_code = i; in dwc3_ti_probe()
268 am62->phy_regs = devm_platform_ioremap_resource(pdev, 1); in dwc3_ti_probe()
269 if (IS_ERR(am62->phy_regs)) { in dwc3_ti_probe()
271 am62->phy_regs = NULL; in dwc3_ti_probe()
274 am62->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); in dwc3_ti_probe()
294 /* Device has capability to wakeup system from sleep */ in dwc3_ti_probe()
298 dev_err(dev, "couldn't enable device as a wakeup source: %d\n", ret); in dwc3_ti_probe()
308 clk_disable_unprepare(am62->usb2_refclk); in dwc3_ti_probe()
316 struct device *dev = &pdev->dev; in dwc3_ti_remove()
345 /* Set wakeup config enable bits */ in dwc3_ti_suspend_common()
353 * and in U2/L3 state else it causes spurious wake-up. in dwc3_ti_suspend_common()
357 /* clear wakeup status so we know what caused the wake up */ in dwc3_ti_suspend_common()
364 clk_disable_unprepare(am62->usb2_refclk); in dwc3_ti_suspend_common()
380 clk_prepare_enable(am62->usb2_refclk); in dwc3_ti_resume_common()
384 /* Clear wakeup config enable bits */ in dwc3_ti_resume_common()
389 am62->wakeup_stat = reg; in dwc3_ti_resume_common()
403 { .compatible = "ti,am62-usb"},
412 .name = "dwc3-am62",
420 MODULE_ALIAS("platform:dwc3-am62");
421 MODULE_AUTHOR("Aswath Govindraju <a-[email protected]>");