Lines Matching +full:data +full:- +full:bits

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
43 /* PHY CONFIG register bits */
48 /* MODE CONTROL register bits */
51 /* WAKEUP CONFIG register bits */
57 /* WAKEUP STAT register bits */
64 /* IRQ_MISC_STATUS_RAW register bits */
68 /* IRQ_MISC_STATUS register bits */
72 /* IRQ_MISC_ENABLE_SET register bits */
76 /* IRQ_MISC_ENABLE_CLR register bits */
80 /* IRQ_MISC_EOI register bits */
83 /* VBUS_STAT register bits */
118 static inline u32 dwc3_ti_readl(struct dwc3_data *data, u32 offset) in dwc3_ti_readl() argument
120 return readl((data->usbss) + offset); in dwc3_ti_readl()
123 static inline void dwc3_ti_writel(struct dwc3_data *data, u32 offset, u32 value) in dwc3_ti_writel() argument
125 writel(value, (data->usbss) + offset); in dwc3_ti_writel()
128 static int phy_syscon_pll_refclk(struct dwc3_data *data) in phy_syscon_pll_refclk() argument
130 struct device *dev = data->dev; in phy_syscon_pll_refclk()
131 struct device_node *node = dev->of_node; in phy_syscon_pll_refclk()
136 syscon = syscon_regmap_lookup_by_phandle(node, "ti,syscon-phy-pll-refclk"); in phy_syscon_pll_refclk()
138 dev_err(dev, "unable to get ti,syscon-phy-pll-refclk regmap\n"); in phy_syscon_pll_refclk()
142 data->syscon = syscon; in phy_syscon_pll_refclk()
144 ret = of_parse_phandle_with_fixed_args(node, "ti,syscon-phy-pll-refclk", 1, in phy_syscon_pll_refclk()
149 data->offset = args.args[0]; in phy_syscon_pll_refclk()
151 ret = regmap_update_bits(data->syscon, data->offset, PHY_PLL_REFCLK_MASK, data->rate_code); in phy_syscon_pll_refclk()
162 struct device *dev = &pdev->dev; in dwc3_ti_probe()
163 struct device_node *node = pdev->dev.of_node; in dwc3_ti_probe()
164 struct dwc3_data *data; in dwc3_ti_probe() local
169 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); in dwc3_ti_probe()
170 if (!data) in dwc3_ti_probe()
171 return -ENOMEM; in dwc3_ti_probe()
173 data->dev = dev; in dwc3_ti_probe()
174 platform_set_drvdata(pdev, data); in dwc3_ti_probe()
176 data->usbss = devm_platform_ioremap_resource(pdev, 0); in dwc3_ti_probe()
177 if (IS_ERR(data->usbss)) { in dwc3_ti_probe()
179 return PTR_ERR(data->usbss); in dwc3_ti_probe()
182 data->usb2_refclk = devm_clk_get(dev, "ref"); in dwc3_ti_probe()
183 if (IS_ERR(data->usb2_refclk)) { in dwc3_ti_probe()
185 return PTR_ERR(data->usb2_refclk); in dwc3_ti_probe()
189 rate = clk_get_rate(data->usb2_refclk); in dwc3_ti_probe()
198 return -EINVAL; in dwc3_ti_probe()
201 data->rate_code = i; in dwc3_ti_probe()
204 ret = phy_syscon_pll_refclk(data); in dwc3_ti_probe()
209 data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); in dwc3_ti_probe()
210 reg = dwc3_ti_readl(data, USBSS_PHY_CONFIG); in dwc3_ti_probe()
211 if (data->vbus_divider) in dwc3_ti_probe()
214 dwc3_ti_writel(data, USBSS_PHY_CONFIG, reg); in dwc3_ti_probe()
222 clk_prepare_enable(data->usb2_refclk); in dwc3_ti_probe()
232 reg = dwc3_ti_readl(data, USBSS_MODE_CONTROL); in dwc3_ti_probe()
234 dwc3_ti_writel(data, USBSS_MODE_CONTROL, reg); in dwc3_ti_probe()
244 clk_disable_unprepare(data->usb2_refclk); in dwc3_ti_probe()
260 struct device *dev = &pdev->dev; in dwc3_ti_remove()
261 struct dwc3_data *data = platform_get_drvdata(pdev); in dwc3_ti_remove() local
267 reg = dwc3_ti_readl(data, USBSS_MODE_CONTROL); in dwc3_ti_remove()
269 dwc3_ti_writel(data, USBSS_MODE_CONTROL, reg); in dwc3_ti_remove()
272 clk_disable_unprepare(data->usb2_refclk); in dwc3_ti_remove()
283 struct dwc3_data *data = dev_get_drvdata(dev); in dwc3_ti_suspend_common() local
285 clk_disable_unprepare(data->usb2_refclk); in dwc3_ti_suspend_common()
292 struct dwc3_data *data = dev_get_drvdata(dev); in dwc3_ti_resume_common() local
294 clk_prepare_enable(data->usb2_refclk); in dwc3_ti_resume_common()
308 { .compatible = "ti,am62-usb"},
317 .name = "dwc3-am62",
325 MODULE_ALIAS("platform:dwc3-am62");
326 MODULE_AUTHOR("Aswath Govindraju <a-govindraju@ti.com>");