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>
77 static inline u32 cdns_ti_readl(struct cdns_ti *data, u32 offset) in cdns_ti_readl() argument
79 return readl(data->usbss + offset); in cdns_ti_readl()
82 static inline void cdns_ti_writel(struct cdns_ti *data, u32 offset, u32 value) in cdns_ti_writel() argument
84 writel(value, data->usbss + offset); in cdns_ti_writel()
89 struct device *dev = &pdev->dev; in cdns_ti_probe()
90 struct device_node *node = pdev->dev.of_node; in cdns_ti_probe()
91 struct cdns_ti *data; in cdns_ti_probe() local
93 u32 reg; in cdns_ti_probe() local
97 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); in cdns_ti_probe()
98 if (!data) in cdns_ti_probe()
99 return -ENOMEM; in cdns_ti_probe()
101 platform_set_drvdata(pdev, data); in cdns_ti_probe()
103 data->dev = dev; in cdns_ti_probe()
105 data->usbss = devm_platform_ioremap_resource(pdev, 0); in cdns_ti_probe()
106 if (IS_ERR(data->usbss)) { in cdns_ti_probe()
108 return PTR_ERR(data->usbss); in cdns_ti_probe()
111 data->usb2_refclk = devm_clk_get(dev, "ref"); in cdns_ti_probe()
112 if (IS_ERR(data->usb2_refclk)) { in cdns_ti_probe()
114 return PTR_ERR(data->usb2_refclk); in cdns_ti_probe()
117 data->lpm_clk = devm_clk_get(dev, "lpm"); in cdns_ti_probe()
118 if (IS_ERR(data->lpm_clk)) { in cdns_ti_probe()
120 return PTR_ERR(data->lpm_clk); in cdns_ti_probe()
123 rate = clk_get_rate(data->usb2_refclk); in cdns_ti_probe()
132 return -EINVAL; in cdns_ti_probe()
145 reg = cdns_ti_readl(data, USBSS_W1); in cdns_ti_probe()
146 reg &= ~USBSS_W1_PWRUP_RST; in cdns_ti_probe()
147 cdns_ti_writel(data, USBSS_W1, reg); in cdns_ti_probe()
150 reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG); in cdns_ti_probe()
151 reg &= ~USBSS1_STATIC_PLL_REF_SEL_MASK; in cdns_ti_probe()
152 reg |= rate_code << USBSS1_STATIC_PLL_REF_SEL_SHIFT; in cdns_ti_probe()
154 reg &= ~USBSS1_STATIC_VBUS_SEL_MASK; in cdns_ti_probe()
155 data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); in cdns_ti_probe()
156 if (data->vbus_divider) in cdns_ti_probe()
157 reg |= 1 << USBSS1_STATIC_VBUS_SEL_SHIFT; in cdns_ti_probe()
159 cdns_ti_writel(data, USBSS_STATIC_CONFIG, reg); in cdns_ti_probe()
160 reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG); in cdns_ti_probe()
163 reg = cdns_ti_readl(data, USBSS_W1); in cdns_ti_probe()
164 data->usb2_only = device_property_read_bool(dev, "ti,usb2-only"); in cdns_ti_probe()
165 if (data->usb2_only) in cdns_ti_probe()
166 reg |= USBSS_W1_USB2_ONLY; in cdns_ti_probe()
169 reg |= USBSS_W1_MODESTRAP_SEL; in cdns_ti_probe()
170 reg &= ~USBSS_W1_MODESTRAP_MASK; in cdns_ti_probe()
171 reg |= USBSS_MODESTRAP_MODE_NONE << USBSS_W1_MODESTRAP_SHIFT; in cdns_ti_probe()
172 cdns_ti_writel(data, USBSS_W1, reg); in cdns_ti_probe()
174 /* de-assert RESET */ in cdns_ti_probe()
175 reg |= USBSS_W1_PWRUP_RST; in cdns_ti_probe()
176 cdns_ti_writel(data, USBSS_W1, reg); in cdns_ti_probe()
187 pm_runtime_put_sync(data->dev); in cdns_ti_probe()
188 pm_runtime_disable(data->dev); in cdns_ti_probe()
204 struct device *dev = &pdev->dev; in cdns_ti_remove()
216 { .compatible = "ti,j721e-usb", },
217 { .compatible = "ti,am64-usb", },
226 .name = "cdns3-ti",
233 MODULE_ALIAS("platform:cdns3-ti");