Lines Matching +full:reg +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0
3 * cdns3-ti.c - TI specific Glue layer for Cadence USB Controller
5 * Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com
14 #include <linux/dma-mapping.h>
79 static inline u32 cdns_ti_readl(struct cdns_ti *data, u32 offset) in cdns_ti_readl() argument
81 return readl(data->usbss + offset); in cdns_ti_readl()
84 static inline void cdns_ti_writel(struct cdns_ti *data, u32 offset, u32 value) in cdns_ti_writel() argument
86 writel(value, data->usbss + offset); in cdns_ti_writel()
103 struct device *dev = &pdev->dev; in cdns_ti_probe()
104 struct device_node *node = pdev->dev.of_node; in cdns_ti_probe()
105 struct cdns_ti *data; in cdns_ti_probe() local
107 u32 reg; in cdns_ti_probe() local
111 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); in cdns_ti_probe()
112 if (!data) in cdns_ti_probe()
113 return -ENOMEM; in cdns_ti_probe()
115 platform_set_drvdata(pdev, data); in cdns_ti_probe()
117 data->dev = dev; in cdns_ti_probe()
119 data->usbss = devm_platform_ioremap_resource(pdev, 0); in cdns_ti_probe()
120 if (IS_ERR(data->usbss)) { in cdns_ti_probe()
122 return PTR_ERR(data->usbss); in cdns_ti_probe()
125 data->usb2_refclk = devm_clk_get(dev, "ref"); in cdns_ti_probe()
126 if (IS_ERR(data->usb2_refclk)) { in cdns_ti_probe()
128 return PTR_ERR(data->usb2_refclk); in cdns_ti_probe()
131 data->lpm_clk = devm_clk_get(dev, "lpm"); in cdns_ti_probe()
132 if (IS_ERR(data->lpm_clk)) { in cdns_ti_probe()
134 return PTR_ERR(data->lpm_clk); in cdns_ti_probe()
137 rate = clk_get_rate(data->usb2_refclk); in cdns_ti_probe()
146 return -EINVAL; in cdns_ti_probe()
159 reg = cdns_ti_readl(data, USBSS_W1); in cdns_ti_probe()
160 reg &= ~USBSS_W1_PWRUP_RST; in cdns_ti_probe()
161 cdns_ti_writel(data, USBSS_W1, reg); in cdns_ti_probe()
164 reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG); in cdns_ti_probe()
165 reg &= ~USBSS1_STATIC_PLL_REF_SEL_MASK; in cdns_ti_probe()
166 reg |= rate_code << USBSS1_STATIC_PLL_REF_SEL_SHIFT; in cdns_ti_probe()
168 reg &= ~USBSS1_STATIC_VBUS_SEL_MASK; in cdns_ti_probe()
169 data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); in cdns_ti_probe()
170 if (data->vbus_divider) in cdns_ti_probe()
171 reg |= 1 << USBSS1_STATIC_VBUS_SEL_SHIFT; in cdns_ti_probe()
173 cdns_ti_writel(data, USBSS_STATIC_CONFIG, reg); in cdns_ti_probe()
174 reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG); in cdns_ti_probe()
177 reg = cdns_ti_readl(data, USBSS_W1); in cdns_ti_probe()
178 data->usb2_only = device_property_read_bool(dev, "ti,usb2-only"); in cdns_ti_probe()
179 if (data->usb2_only) in cdns_ti_probe()
180 reg |= USBSS_W1_USB2_ONLY; in cdns_ti_probe()
183 reg |= USBSS_W1_MODESTRAP_SEL; in cdns_ti_probe()
184 reg &= ~USBSS_W1_MODESTRAP_MASK; in cdns_ti_probe()
185 reg |= USBSS_MODESTRAP_MODE_NONE << USBSS_W1_MODESTRAP_SHIFT; in cdns_ti_probe()
186 cdns_ti_writel(data, USBSS_W1, reg); in cdns_ti_probe()
188 /* de-assert RESET */ in cdns_ti_probe()
189 reg |= USBSS_W1_PWRUP_RST; in cdns_ti_probe()
190 cdns_ti_writel(data, USBSS_W1, reg); in cdns_ti_probe()
201 pm_runtime_put_sync(data->dev); in cdns_ti_probe()
202 pm_runtime_disable(data->dev); in cdns_ti_probe()
218 struct device *dev = &pdev->dev; in cdns_ti_remove()
228 { .compatible = "ti,j721e-usb", },
229 { .compatible = "ti,am64-usb", },
238 .name = "cdns3-ti",
245 MODULE_ALIAS("platform:cdns3-ti");