xref: /linux/drivers/usb/dwc3/dwc3-st.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0+
2c9714d65SAditya Srivastava /*
3f83fca07SPeter Griffin  * dwc3-st.c Support for dwc3 platform devices on ST Microelectronics platforms
4f83fca07SPeter Griffin  *
5f83fca07SPeter Griffin  * This is a small driver for the dwc3 to provide the glue logic
6f83fca07SPeter Griffin  * to configure the controller. Tested on STi platforms.
7f83fca07SPeter Griffin  *
8f83fca07SPeter Griffin  * Copyright (C) 2014 Stmicroelectronics
9f83fca07SPeter Griffin  *
10f83fca07SPeter Griffin  * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
11f83fca07SPeter Griffin  * Contributors: Aymen Bouattay <aymen.bouattay@st.com>
12f83fca07SPeter Griffin  *               Peter Griffin <peter.griffin@linaro.org>
13f83fca07SPeter Griffin  *
14f83fca07SPeter Griffin  * Inspired by dwc3-omap.c and dwc3-exynos.c.
15f83fca07SPeter Griffin  */
16f83fca07SPeter Griffin 
17bde05325SKrzysztof Kozlowski #include <linux/cleanup.h>
18f83fca07SPeter Griffin #include <linux/delay.h>
19f83fca07SPeter Griffin #include <linux/interrupt.h>
20f83fca07SPeter Griffin #include <linux/io.h>
21f83fca07SPeter Griffin #include <linux/ioport.h>
22f83fca07SPeter Griffin #include <linux/kernel.h>
23f83fca07SPeter Griffin #include <linux/mfd/syscon.h>
24f83fca07SPeter Griffin #include <linux/module.h>
25f83fca07SPeter Griffin #include <linux/of.h>
26f83fca07SPeter Griffin #include <linux/of_platform.h>
27f83fca07SPeter Griffin #include <linux/platform_device.h>
28f83fca07SPeter Griffin #include <linux/slab.h>
29f83fca07SPeter Griffin #include <linux/regmap.h>
30f83fca07SPeter Griffin #include <linux/reset.h>
314accb8a1SFelipe Balbi #include <linux/pinctrl/consumer.h>
32f83fca07SPeter Griffin #include <linux/usb/of.h>
33f83fca07SPeter Griffin 
34f83fca07SPeter Griffin #include "core.h"
35f83fca07SPeter Griffin #include "io.h"
36f83fca07SPeter Griffin 
37f83fca07SPeter Griffin /* glue registers */
38f83fca07SPeter Griffin #define CLKRST_CTRL		0x00
39f83fca07SPeter Griffin #define AUX_CLK_EN		BIT(0)
40f83fca07SPeter Griffin #define SW_PIPEW_RESET_N	BIT(4)
41f83fca07SPeter Griffin #define EXT_CFG_RESET_N		BIT(8)
42f83fca07SPeter Griffin /*
43f83fca07SPeter Griffin  * 1'b0 : The host controller complies with the xHCI revision 0.96
44f83fca07SPeter Griffin  * 1'b1 : The host controller complies with the xHCI revision 1.0
45f83fca07SPeter Griffin  */
46f83fca07SPeter Griffin #define XHCI_REVISION		BIT(12)
47f83fca07SPeter Griffin 
48f83fca07SPeter Griffin #define USB2_VBUS_MNGMNT_SEL1	0x2C
49f83fca07SPeter Griffin /*
50f83fca07SPeter Griffin  * For all fields in USB2_VBUS_MNGMNT_SEL1
51f83fca07SPeter Griffin  * 2’b00 : Override value from Reg 0x30 is selected
52f83fca07SPeter Griffin  * 2’b01 : utmiotg_<signal_name> from usb3_top is selected
53f83fca07SPeter Griffin  * 2’b10 : pipew_<signal_name> from PIPEW instance is selected
54f83fca07SPeter Griffin  * 2’b11 : value is 1'b0
55f83fca07SPeter Griffin  */
56f83fca07SPeter Griffin #define USB2_VBUS_REG30		0x0
57f83fca07SPeter Griffin #define USB2_VBUS_UTMIOTG	0x1
58f83fca07SPeter Griffin #define USB2_VBUS_PIPEW		0x2
59f83fca07SPeter Griffin #define USB2_VBUS_ZERO		0x3
60f83fca07SPeter Griffin 
61f83fca07SPeter Griffin #define SEL_OVERRIDE_VBUSVALID(n)	(n << 0)
62f83fca07SPeter Griffin #define SEL_OVERRIDE_POWERPRESENT(n)	(n << 4)
63f83fca07SPeter Griffin #define SEL_OVERRIDE_BVALID(n)		(n << 8)
64f83fca07SPeter Griffin 
65f83fca07SPeter Griffin /* Static DRD configuration */
66f83fca07SPeter Griffin #define USB3_CONTROL_MASK		0xf77
67f83fca07SPeter Griffin 
68f83fca07SPeter Griffin #define USB3_DEVICE_NOT_HOST		BIT(0)
69f83fca07SPeter Griffin #define USB3_FORCE_VBUSVALID		BIT(1)
70f83fca07SPeter Griffin #define USB3_DELAY_VBUSVALID		BIT(2)
71f83fca07SPeter Griffin #define USB3_SEL_FORCE_OPMODE		BIT(4)
72f83fca07SPeter Griffin #define USB3_FORCE_OPMODE(n)		(n << 5)
73f83fca07SPeter Griffin #define USB3_SEL_FORCE_DPPULLDOWN2	BIT(8)
74f83fca07SPeter Griffin #define USB3_FORCE_DPPULLDOWN2		BIT(9)
75f83fca07SPeter Griffin #define USB3_SEL_FORCE_DMPULLDOWN2	BIT(10)
76f83fca07SPeter Griffin #define USB3_FORCE_DMPULLDOWN2		BIT(11)
77f83fca07SPeter Griffin 
78f83fca07SPeter Griffin /**
79f83fca07SPeter Griffin  * struct st_dwc3 - dwc3-st driver private structure
80f83fca07SPeter Griffin  * @dev:		device pointer
81f83fca07SPeter Griffin  * @glue_base:		ioaddr for the glue registers
82f83fca07SPeter Griffin  * @regmap:		regmap pointer for getting syscfg
83f83fca07SPeter Griffin  * @syscfg_reg_off:	usb syscfg control offset
84f83fca07SPeter Griffin  * @dr_mode:		drd static host/device config
85f83fca07SPeter Griffin  * @rstc_pwrdn:		rest controller for powerdown signal
86f83fca07SPeter Griffin  * @rstc_rst:		reset controller for softreset signal
87f83fca07SPeter Griffin  */
88f83fca07SPeter Griffin 
89f83fca07SPeter Griffin struct st_dwc3 {
90f83fca07SPeter Griffin 	struct device *dev;
91f83fca07SPeter Griffin 	void __iomem *glue_base;
92f83fca07SPeter Griffin 	struct regmap *regmap;
93f83fca07SPeter Griffin 	int syscfg_reg_off;
94f83fca07SPeter Griffin 	enum usb_dr_mode dr_mode;
95f83fca07SPeter Griffin 	struct reset_control *rstc_pwrdn;
96f83fca07SPeter Griffin 	struct reset_control *rstc_rst;
97f83fca07SPeter Griffin };
98f83fca07SPeter Griffin 
st_dwc3_readl(void __iomem * base,u32 offset)99f83fca07SPeter Griffin static inline u32 st_dwc3_readl(void __iomem *base, u32 offset)
100f83fca07SPeter Griffin {
101f83fca07SPeter Griffin 	return readl_relaxed(base + offset);
102f83fca07SPeter Griffin }
103f83fca07SPeter Griffin 
st_dwc3_writel(void __iomem * base,u32 offset,u32 value)104f83fca07SPeter Griffin static inline void st_dwc3_writel(void __iomem *base, u32 offset, u32 value)
105f83fca07SPeter Griffin {
106f83fca07SPeter Griffin 	writel_relaxed(value, base + offset);
107f83fca07SPeter Griffin }
108f83fca07SPeter Griffin 
109f83fca07SPeter Griffin /**
110f83fca07SPeter Griffin  * st_dwc3_drd_init: program the port
111f83fca07SPeter Griffin  * @dwc3_data: driver private structure
112f83fca07SPeter Griffin  * Description: this function is to program the port as either host or device
113f83fca07SPeter Griffin  * according to the static configuration passed from devicetree.
114f83fca07SPeter Griffin  * OTG and dual role are not yet supported!
115f83fca07SPeter Griffin  */
st_dwc3_drd_init(struct st_dwc3 * dwc3_data)116f83fca07SPeter Griffin static int st_dwc3_drd_init(struct st_dwc3 *dwc3_data)
117f83fca07SPeter Griffin {
118f83fca07SPeter Griffin 	u32 val;
119f83fca07SPeter Griffin 	int err;
120f83fca07SPeter Griffin 
121f83fca07SPeter Griffin 	err = regmap_read(dwc3_data->regmap, dwc3_data->syscfg_reg_off, &val);
122f83fca07SPeter Griffin 	if (err)
123f83fca07SPeter Griffin 		return err;
124f83fca07SPeter Griffin 
125f83fca07SPeter Griffin 	val &= USB3_CONTROL_MASK;
126f83fca07SPeter Griffin 
127f83fca07SPeter Griffin 	switch (dwc3_data->dr_mode) {
128f83fca07SPeter Griffin 	case USB_DR_MODE_PERIPHERAL:
129f83fca07SPeter Griffin 
13027a0faafSPeter Griffin 		val &= ~(USB3_DELAY_VBUSVALID
131f83fca07SPeter Griffin 			| USB3_SEL_FORCE_OPMODE | USB3_FORCE_OPMODE(0x3)
132f83fca07SPeter Griffin 			| USB3_SEL_FORCE_DPPULLDOWN2 | USB3_FORCE_DPPULLDOWN2
133f83fca07SPeter Griffin 			| USB3_SEL_FORCE_DMPULLDOWN2 | USB3_FORCE_DMPULLDOWN2);
134f83fca07SPeter Griffin 
13527a0faafSPeter Griffin 		/*
13627a0faafSPeter Griffin 		 * USB3_PORT2_FORCE_VBUSVALID When '1' and when
13727a0faafSPeter Griffin 		 * USB3_PORT2_DEVICE_NOT_HOST = 1, forces VBUSVLDEXT2 input
13827a0faafSPeter Griffin 		 * of the pico PHY to 1.
13927a0faafSPeter Griffin 		 */
14027a0faafSPeter Griffin 
14127a0faafSPeter Griffin 		val |= USB3_DEVICE_NOT_HOST | USB3_FORCE_VBUSVALID;
142f83fca07SPeter Griffin 		break;
143f83fca07SPeter Griffin 
144f83fca07SPeter Griffin 	case USB_DR_MODE_HOST:
145f83fca07SPeter Griffin 
146f83fca07SPeter Griffin 		val &= ~(USB3_DEVICE_NOT_HOST | USB3_FORCE_VBUSVALID
147f83fca07SPeter Griffin 			| USB3_SEL_FORCE_OPMODE	| USB3_FORCE_OPMODE(0x3)
148f83fca07SPeter Griffin 			| USB3_SEL_FORCE_DPPULLDOWN2 | USB3_FORCE_DPPULLDOWN2
149f83fca07SPeter Griffin 			| USB3_SEL_FORCE_DMPULLDOWN2 | USB3_FORCE_DMPULLDOWN2);
150f83fca07SPeter Griffin 
151f83fca07SPeter Griffin 		/*
152f83fca07SPeter Griffin 		 * USB3_DELAY_VBUSVALID is ANDed with USB_C_VBUSVALID. Thus,
153f83fca07SPeter Griffin 		 * when set to ‘0‘, it can delay the arrival of VBUSVALID
154f83fca07SPeter Griffin 		 * information to VBUSVLDEXT2 input of the pico PHY.
155f83fca07SPeter Griffin 		 * We don't want to do that so we set the bit to '1'.
156f83fca07SPeter Griffin 		 */
157f83fca07SPeter Griffin 
158f83fca07SPeter Griffin 		val |= USB3_DELAY_VBUSVALID;
159f83fca07SPeter Griffin 		break;
160f83fca07SPeter Griffin 
161f83fca07SPeter Griffin 	default:
162f83fca07SPeter Griffin 		dev_err(dwc3_data->dev, "Unsupported mode of operation %d\n",
163f83fca07SPeter Griffin 			dwc3_data->dr_mode);
164f83fca07SPeter Griffin 		return -EINVAL;
165f83fca07SPeter Griffin 	}
166f83fca07SPeter Griffin 
167f83fca07SPeter Griffin 	return regmap_write(dwc3_data->regmap, dwc3_data->syscfg_reg_off, val);
168f83fca07SPeter Griffin }
169f83fca07SPeter Griffin 
170f83fca07SPeter Griffin /**
171f83fca07SPeter Griffin  * st_dwc3_init: init the controller via glue logic
172f83fca07SPeter Griffin  * @dwc3_data: driver private structure
173f83fca07SPeter Griffin  */
st_dwc3_init(struct st_dwc3 * dwc3_data)174f83fca07SPeter Griffin static void st_dwc3_init(struct st_dwc3 *dwc3_data)
175f83fca07SPeter Griffin {
176f83fca07SPeter Griffin 	u32 reg = st_dwc3_readl(dwc3_data->glue_base, CLKRST_CTRL);
177f83fca07SPeter Griffin 
178f83fca07SPeter Griffin 	reg |= AUX_CLK_EN | EXT_CFG_RESET_N | XHCI_REVISION;
179f83fca07SPeter Griffin 	reg &= ~SW_PIPEW_RESET_N;
180f83fca07SPeter Griffin 	st_dwc3_writel(dwc3_data->glue_base, CLKRST_CTRL, reg);
181f83fca07SPeter Griffin 
182f83fca07SPeter Griffin 	/* configure mux for vbus, powerpresent and bvalid signals */
183f83fca07SPeter Griffin 	reg = st_dwc3_readl(dwc3_data->glue_base, USB2_VBUS_MNGMNT_SEL1);
184f83fca07SPeter Griffin 
185f83fca07SPeter Griffin 	reg |= SEL_OVERRIDE_VBUSVALID(USB2_VBUS_UTMIOTG) |
186f83fca07SPeter Griffin 		SEL_OVERRIDE_POWERPRESENT(USB2_VBUS_UTMIOTG) |
187f83fca07SPeter Griffin 		SEL_OVERRIDE_BVALID(USB2_VBUS_UTMIOTG);
188f83fca07SPeter Griffin 
189f83fca07SPeter Griffin 	st_dwc3_writel(dwc3_data->glue_base, USB2_VBUS_MNGMNT_SEL1, reg);
190f83fca07SPeter Griffin 
191f83fca07SPeter Griffin 	reg = st_dwc3_readl(dwc3_data->glue_base, CLKRST_CTRL);
192f83fca07SPeter Griffin 	reg |= SW_PIPEW_RESET_N;
193f83fca07SPeter Griffin 	st_dwc3_writel(dwc3_data->glue_base, CLKRST_CTRL, reg);
194f83fca07SPeter Griffin }
195f83fca07SPeter Griffin 
st_dwc3_probe(struct platform_device * pdev)196f83fca07SPeter Griffin static int st_dwc3_probe(struct platform_device *pdev)
197f83fca07SPeter Griffin {
198f83fca07SPeter Griffin 	struct st_dwc3 *dwc3_data;
199f83fca07SPeter Griffin 	struct resource *res;
200f83fca07SPeter Griffin 	struct device *dev = &pdev->dev;
201bde05325SKrzysztof Kozlowski 	struct device_node *node = dev->of_node;
20266647273SHeikki Krogerus 	struct platform_device *child_pdev;
203f83fca07SPeter Griffin 	struct regmap *regmap;
204f83fca07SPeter Griffin 	int ret;
205f83fca07SPeter Griffin 
206f83fca07SPeter Griffin 	dwc3_data = devm_kzalloc(dev, sizeof(*dwc3_data), GFP_KERNEL);
207f83fca07SPeter Griffin 	if (!dwc3_data)
208f83fca07SPeter Griffin 		return -ENOMEM;
209f83fca07SPeter Griffin 
210db123beaSChunfeng Yun 	dwc3_data->glue_base =
211db123beaSChunfeng Yun 		devm_platform_ioremap_resource_byname(pdev, "reg-glue");
212f83fca07SPeter Griffin 	if (IS_ERR(dwc3_data->glue_base))
213f83fca07SPeter Griffin 		return PTR_ERR(dwc3_data->glue_base);
214f83fca07SPeter Griffin 
215f83fca07SPeter Griffin 	regmap = syscon_regmap_lookup_by_phandle(node, "st,syscfg");
216f83fca07SPeter Griffin 	if (IS_ERR(regmap))
217f83fca07SPeter Griffin 		return PTR_ERR(regmap);
218f83fca07SPeter Griffin 
219f83fca07SPeter Griffin 	dwc3_data->dev = dev;
220f83fca07SPeter Griffin 	dwc3_data->regmap = regmap;
221f83fca07SPeter Griffin 
222f83fca07SPeter Griffin 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "syscfg-reg");
223ddfcfebaSKrzysztof Kozlowski 	if (!res)
224ddfcfebaSKrzysztof Kozlowski 		return -ENXIO;
225f83fca07SPeter Griffin 
226f83fca07SPeter Griffin 	dwc3_data->syscfg_reg_off = res->start;
227f83fca07SPeter Griffin 
228*fcc78cceSKrzysztof Kozlowski 	dev_vdbg(dev, "glue-logic addr 0x%pK, syscfg-reg offset 0x%x\n",
229f83fca07SPeter Griffin 		 dwc3_data->glue_base, dwc3_data->syscfg_reg_off);
230f83fca07SPeter Griffin 
231bde05325SKrzysztof Kozlowski 	struct device_node *child __free(device_node) = of_get_compatible_child(node,
232bde05325SKrzysztof Kozlowski 										"snps,dwc3");
233bde05325SKrzysztof Kozlowski 	if (!child) {
234*fcc78cceSKrzysztof Kozlowski 		dev_err(dev, "failed to find dwc3 core node\n");
235bde05325SKrzysztof Kozlowski 		return -ENODEV;
236bde05325SKrzysztof Kozlowski 	}
237bde05325SKrzysztof Kozlowski 
2385baaf3b9SLee Jones 	dwc3_data->rstc_pwrdn =
2395baaf3b9SLee Jones 		devm_reset_control_get_exclusive(dev, "powerdown");
240a93c3ad6SKrzysztof Kozlowski 	if (IS_ERR(dwc3_data->rstc_pwrdn))
241a93c3ad6SKrzysztof Kozlowski 		return dev_err_probe(dev, PTR_ERR(dwc3_data->rstc_pwrdn),
242a93c3ad6SKrzysztof Kozlowski 				     "could not get power controller\n");
243f83fca07SPeter Griffin 
244f83fca07SPeter Griffin 	/* Manage PowerDown */
245f83fca07SPeter Griffin 	reset_control_deassert(dwc3_data->rstc_pwrdn);
246f83fca07SPeter Griffin 
247002f17bcSLee Jones 	dwc3_data->rstc_rst =
248002f17bcSLee Jones 		devm_reset_control_get_shared(dev, "softreset");
249f83fca07SPeter Griffin 	if (IS_ERR(dwc3_data->rstc_rst)) {
250a93c3ad6SKrzysztof Kozlowski 		ret = dev_err_probe(dev, PTR_ERR(dwc3_data->rstc_rst),
251a93c3ad6SKrzysztof Kozlowski 				    "could not get reset controller\n");
252f83fca07SPeter Griffin 		goto undo_powerdown;
253f83fca07SPeter Griffin 	}
254f83fca07SPeter Griffin 
255f83fca07SPeter Griffin 	/* Manage SoftReset */
256f83fca07SPeter Griffin 	reset_control_deassert(dwc3_data->rstc_rst);
257f83fca07SPeter Griffin 
258f83fca07SPeter Griffin 	/* Allocate and initialize the core */
259f83fca07SPeter Griffin 	ret = of_platform_populate(node, NULL, NULL, dev);
260f83fca07SPeter Griffin 	if (ret) {
261f83fca07SPeter Griffin 		dev_err(dev, "failed to add dwc3 core\n");
262bde05325SKrzysztof Kozlowski 		goto undo_softreset;
263f83fca07SPeter Griffin 	}
264f83fca07SPeter Griffin 
26566647273SHeikki Krogerus 	child_pdev = of_find_device_by_node(child);
26666647273SHeikki Krogerus 	if (!child_pdev) {
26766647273SHeikki Krogerus 		dev_err(dev, "failed to find dwc3 core device\n");
26866647273SHeikki Krogerus 		ret = -ENODEV;
269cd4897bfSKrzysztof Kozlowski 		goto depopulate;
27066647273SHeikki Krogerus 	}
27166647273SHeikki Krogerus 
27206e7114fSHeikki Krogerus 	dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
27383c4a4eeSRob Herring 	platform_device_put(child_pdev);
27466647273SHeikki Krogerus 
275f83fca07SPeter Griffin 	/*
276f83fca07SPeter Griffin 	 * Configure the USB port as device or host according to the static
277f83fca07SPeter Griffin 	 * configuration passed from DT.
278f83fca07SPeter Griffin 	 * DRD is the only mode currently supported so this will be enhanced
279f83fca07SPeter Griffin 	 * as soon as OTG is available.
280f83fca07SPeter Griffin 	 */
281f83fca07SPeter Griffin 	ret = st_dwc3_drd_init(dwc3_data);
282f83fca07SPeter Griffin 	if (ret) {
283f83fca07SPeter Griffin 		dev_err(dev, "drd initialisation failed\n");
284bde05325SKrzysztof Kozlowski 		goto depopulate;
285f83fca07SPeter Griffin 	}
286f83fca07SPeter Griffin 
287f83fca07SPeter Griffin 	/* ST glue logic init */
288f83fca07SPeter Griffin 	st_dwc3_init(dwc3_data);
289f83fca07SPeter Griffin 
290f83fca07SPeter Griffin 	platform_set_drvdata(pdev, dwc3_data);
291f83fca07SPeter Griffin 	return 0;
292f83fca07SPeter Griffin 
293cd4897bfSKrzysztof Kozlowski depopulate:
294cd4897bfSKrzysztof Kozlowski 	of_platform_depopulate(dev);
295f83fca07SPeter Griffin undo_softreset:
296f83fca07SPeter Griffin 	reset_control_assert(dwc3_data->rstc_rst);
297f83fca07SPeter Griffin undo_powerdown:
298f83fca07SPeter Griffin 	reset_control_assert(dwc3_data->rstc_pwrdn);
299f83fca07SPeter Griffin 	return ret;
300f83fca07SPeter Griffin }
301f83fca07SPeter Griffin 
st_dwc3_remove(struct platform_device * pdev)3022f645376SUwe Kleine-König static void st_dwc3_remove(struct platform_device *pdev)
303f83fca07SPeter Griffin {
304f83fca07SPeter Griffin 	struct st_dwc3 *dwc3_data = platform_get_drvdata(pdev);
305f83fca07SPeter Griffin 
306f83fca07SPeter Griffin 	of_platform_depopulate(&pdev->dev);
307f83fca07SPeter Griffin 
308f83fca07SPeter Griffin 	reset_control_assert(dwc3_data->rstc_pwrdn);
309f83fca07SPeter Griffin 	reset_control_assert(dwc3_data->rstc_rst);
310f83fca07SPeter Griffin }
311f83fca07SPeter Griffin 
312f83fca07SPeter Griffin #ifdef CONFIG_PM_SLEEP
st_dwc3_suspend(struct device * dev)313f83fca07SPeter Griffin static int st_dwc3_suspend(struct device *dev)
314f83fca07SPeter Griffin {
315f83fca07SPeter Griffin 	struct st_dwc3 *dwc3_data = dev_get_drvdata(dev);
316f83fca07SPeter Griffin 
317f83fca07SPeter Griffin 	reset_control_assert(dwc3_data->rstc_pwrdn);
318f83fca07SPeter Griffin 	reset_control_assert(dwc3_data->rstc_rst);
319f83fca07SPeter Griffin 
320f83fca07SPeter Griffin 	pinctrl_pm_select_sleep_state(dev);
321f83fca07SPeter Griffin 
322f83fca07SPeter Griffin 	return 0;
323f83fca07SPeter Griffin }
324f83fca07SPeter Griffin 
st_dwc3_resume(struct device * dev)325f83fca07SPeter Griffin static int st_dwc3_resume(struct device *dev)
326f83fca07SPeter Griffin {
327f83fca07SPeter Griffin 	struct st_dwc3 *dwc3_data = dev_get_drvdata(dev);
328f83fca07SPeter Griffin 	int ret;
329f83fca07SPeter Griffin 
330f83fca07SPeter Griffin 	pinctrl_pm_select_default_state(dev);
331f83fca07SPeter Griffin 
332f83fca07SPeter Griffin 	reset_control_deassert(dwc3_data->rstc_pwrdn);
333f83fca07SPeter Griffin 	reset_control_deassert(dwc3_data->rstc_rst);
334f83fca07SPeter Griffin 
335f83fca07SPeter Griffin 	ret = st_dwc3_drd_init(dwc3_data);
336f83fca07SPeter Griffin 	if (ret) {
337f83fca07SPeter Griffin 		dev_err(dev, "drd initialisation failed\n");
338f83fca07SPeter Griffin 		return ret;
339f83fca07SPeter Griffin 	}
340f83fca07SPeter Griffin 
341f83fca07SPeter Griffin 	/* ST glue logic init */
342f83fca07SPeter Griffin 	st_dwc3_init(dwc3_data);
343f83fca07SPeter Griffin 
344f83fca07SPeter Griffin 	return 0;
345f83fca07SPeter Griffin }
346f83fca07SPeter Griffin #endif /* CONFIG_PM_SLEEP */
347f83fca07SPeter Griffin 
348f83fca07SPeter Griffin static SIMPLE_DEV_PM_OPS(st_dwc3_dev_pm_ops, st_dwc3_suspend, st_dwc3_resume);
349f83fca07SPeter Griffin 
350f83fca07SPeter Griffin static const struct of_device_id st_dwc3_match[] = {
351f83fca07SPeter Griffin 	{ .compatible = "st,stih407-dwc3" },
352f83fca07SPeter Griffin 	{ /* sentinel */ },
353f83fca07SPeter Griffin };
354f83fca07SPeter Griffin 
355f83fca07SPeter Griffin MODULE_DEVICE_TABLE(of, st_dwc3_match);
356f83fca07SPeter Griffin 
357f83fca07SPeter Griffin static struct platform_driver st_dwc3_driver = {
358f83fca07SPeter Griffin 	.probe = st_dwc3_probe,
3592f645376SUwe Kleine-König 	.remove_new = st_dwc3_remove,
360f83fca07SPeter Griffin 	.driver = {
361f83fca07SPeter Griffin 		.name = "usb-st-dwc3",
362f83fca07SPeter Griffin 		.of_match_table = st_dwc3_match,
363f83fca07SPeter Griffin 		.pm = &st_dwc3_dev_pm_ops,
364f83fca07SPeter Griffin 	},
365f83fca07SPeter Griffin };
366f83fca07SPeter Griffin 
367f83fca07SPeter Griffin module_platform_driver(st_dwc3_driver);
368f83fca07SPeter Griffin 
369f83fca07SPeter Griffin MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
370f83fca07SPeter Griffin MODULE_DESCRIPTION("DesignWare USB3 STi Glue Layer");
371f83fca07SPeter Griffin MODULE_LICENSE("GPL v2");
372