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)
81 return readl(data->usbss + offset);
84 static inline void cdns_ti_writel(struct cdns_ti *data, u32 offset, u32 value)
86 writel(value, data->usbss + offset);
103 struct device *dev = &pdev->dev;
104 struct device_node *node = pdev->dev.of_node;
105 struct cdns_ti *data;
107 u32 reg;
111 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
112 if (!data)
113 return -ENOMEM;
115 platform_set_drvdata(pdev, data);
117 data->dev = dev;
119 data->usbss = devm_platform_ioremap_resource(pdev, 0);
120 if (IS_ERR(data->usbss)) {
122 return PTR_ERR(data->usbss);
125 data->usb2_refclk = devm_clk_get(dev, "ref");
126 if (IS_ERR(data->usb2_refclk)) {
128 return PTR_ERR(data->usb2_refclk);
131 data->lpm_clk = devm_clk_get(dev, "lpm");
132 if (IS_ERR(data->lpm_clk)) {
134 return PTR_ERR(data->lpm_clk);
137 rate = clk_get_rate(data->usb2_refclk);
146 return -EINVAL;
159 reg = cdns_ti_readl(data, USBSS_W1);
160 reg &= ~USBSS_W1_PWRUP_RST;
161 cdns_ti_writel(data, USBSS_W1, reg);
164 reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG);
165 reg &= ~USBSS1_STATIC_PLL_REF_SEL_MASK;
166 reg |= rate_code << USBSS1_STATIC_PLL_REF_SEL_SHIFT;
168 reg &= ~USBSS1_STATIC_VBUS_SEL_MASK;
169 data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider");
170 if (data->vbus_divider)
171 reg |= 1 << USBSS1_STATIC_VBUS_SEL_SHIFT;
173 cdns_ti_writel(data, USBSS_STATIC_CONFIG, reg);
174 reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG);
177 reg = cdns_ti_readl(data, USBSS_W1);
178 data->usb2_only = device_property_read_bool(dev, "ti,usb2-only");
179 if (data->usb2_only)
180 reg |= USBSS_W1_USB2_ONLY;
183 reg |= USBSS_W1_MODESTRAP_SEL;
184 reg &= ~USBSS_W1_MODESTRAP_MASK;
185 reg |= USBSS_MODESTRAP_MODE_NONE << USBSS_W1_MODESTRAP_SHIFT;
186 cdns_ti_writel(data, USBSS_W1, reg);
188 /* de-assert RESET */
189 reg |= USBSS_W1_PWRUP_RST;
190 cdns_ti_writel(data, USBSS_W1, reg);
201 pm_runtime_put_sync(data->dev);
202 pm_runtime_disable(data->dev);
218 struct device *dev = &pdev->dev;
228 { .compatible = "ti,j721e-usb", },
229 { .compatible = "ti,am64-usb", },
238 .name = "cdns3-ti",
245 MODULE_ALIAS("platform:cdns3-ti");