Linux 4.19.133
[linux/fpc-iii.git] / drivers / usb / chipidea / usbmisc_imx.c
blob424ecb1f003feb1f8e6cdc01b12d6277f85326f7
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright 2012 Freescale Semiconductor, Inc.
4 */
6 #include <linux/module.h>
7 #include <linux/of_platform.h>
8 #include <linux/err.h>
9 #include <linux/io.h>
10 #include <linux/delay.h>
12 #include "ci_hdrc_imx.h"
14 #define MX25_USB_PHY_CTRL_OFFSET 0x08
15 #define MX25_BM_EXTERNAL_VBUS_DIVIDER BIT(23)
17 #define MX25_EHCI_INTERFACE_SINGLE_UNI (2 << 0)
18 #define MX25_EHCI_INTERFACE_DIFF_UNI (0 << 0)
19 #define MX25_EHCI_INTERFACE_MASK (0xf)
21 #define MX25_OTG_SIC_SHIFT 29
22 #define MX25_OTG_SIC_MASK (0x3 << MX25_OTG_SIC_SHIFT)
23 #define MX25_OTG_PM_BIT BIT(24)
24 #define MX25_OTG_PP_BIT BIT(11)
25 #define MX25_OTG_OCPOL_BIT BIT(3)
27 #define MX25_H1_SIC_SHIFT 21
28 #define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT)
29 #define MX25_H1_PP_BIT BIT(18)
30 #define MX25_H1_PM_BIT BIT(16)
31 #define MX25_H1_IPPUE_UP_BIT BIT(7)
32 #define MX25_H1_IPPUE_DOWN_BIT BIT(6)
33 #define MX25_H1_TLL_BIT BIT(5)
34 #define MX25_H1_USBTE_BIT BIT(4)
35 #define MX25_H1_OCPOL_BIT BIT(2)
37 #define MX27_H1_PM_BIT BIT(8)
38 #define MX27_H2_PM_BIT BIT(16)
39 #define MX27_OTG_PM_BIT BIT(24)
41 #define MX53_USB_OTG_PHY_CTRL_0_OFFSET 0x08
42 #define MX53_USB_OTG_PHY_CTRL_1_OFFSET 0x0c
43 #define MX53_USB_CTRL_1_OFFSET 0x10
44 #define MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_MASK (0x11 << 2)
45 #define MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_ULPI BIT(2)
46 #define MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_MASK (0x11 << 6)
47 #define MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_ULPI BIT(6)
48 #define MX53_USB_UH2_CTRL_OFFSET 0x14
49 #define MX53_USB_UH3_CTRL_OFFSET 0x18
50 #define MX53_USB_CLKONOFF_CTRL_OFFSET 0x24
51 #define MX53_USB_CLKONOFF_CTRL_H2_INT60CKOFF BIT(21)
52 #define MX53_USB_CLKONOFF_CTRL_H3_INT60CKOFF BIT(22)
53 #define MX53_BM_OVER_CUR_DIS_H1 BIT(5)
54 #define MX53_BM_OVER_CUR_DIS_OTG BIT(8)
55 #define MX53_BM_OVER_CUR_DIS_UHx BIT(30)
56 #define MX53_USB_CTRL_1_UH2_ULPI_EN BIT(26)
57 #define MX53_USB_CTRL_1_UH3_ULPI_EN BIT(27)
58 #define MX53_USB_UHx_CTRL_WAKE_UP_EN BIT(7)
59 #define MX53_USB_UHx_CTRL_ULPI_INT_EN BIT(8)
60 #define MX53_USB_PHYCTRL1_PLLDIV_MASK 0x3
61 #define MX53_USB_PLL_DIV_24_MHZ 0x01
63 #define MX6_BM_NON_BURST_SETTING BIT(1)
64 #define MX6_BM_OVER_CUR_DIS BIT(7)
65 #define MX6_BM_OVER_CUR_POLARITY BIT(8)
66 #define MX6_BM_WAKEUP_ENABLE BIT(10)
67 #define MX6_BM_ID_WAKEUP BIT(16)
68 #define MX6_BM_VBUS_WAKEUP BIT(17)
69 #define MX6SX_BM_DPDM_WAKEUP_EN BIT(29)
70 #define MX6_BM_WAKEUP_INTR BIT(31)
71 #define MX6_USB_OTG1_PHY_CTRL 0x18
72 /* For imx6dql, it is host-only controller, for later imx6, it is otg's */
73 #define MX6_USB_OTG2_PHY_CTRL 0x1c
74 #define MX6SX_USB_VBUS_WAKEUP_SOURCE(v) (v << 8)
75 #define MX6SX_USB_VBUS_WAKEUP_SOURCE_VBUS MX6SX_USB_VBUS_WAKEUP_SOURCE(0)
76 #define MX6SX_USB_VBUS_WAKEUP_SOURCE_AVALID MX6SX_USB_VBUS_WAKEUP_SOURCE(1)
77 #define MX6SX_USB_VBUS_WAKEUP_SOURCE_BVALID MX6SX_USB_VBUS_WAKEUP_SOURCE(2)
78 #define MX6SX_USB_VBUS_WAKEUP_SOURCE_SESS_END MX6SX_USB_VBUS_WAKEUP_SOURCE(3)
80 #define VF610_OVER_CUR_DIS BIT(7)
82 #define MX7D_USBNC_USB_CTRL2 0x4
83 #define MX7D_USB_VBUS_WAKEUP_SOURCE_MASK 0x3
84 #define MX7D_USB_VBUS_WAKEUP_SOURCE(v) (v << 0)
85 #define MX7D_USB_VBUS_WAKEUP_SOURCE_VBUS MX7D_USB_VBUS_WAKEUP_SOURCE(0)
86 #define MX7D_USB_VBUS_WAKEUP_SOURCE_AVALID MX7D_USB_VBUS_WAKEUP_SOURCE(1)
87 #define MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID MX7D_USB_VBUS_WAKEUP_SOURCE(2)
88 #define MX7D_USB_VBUS_WAKEUP_SOURCE_SESS_END MX7D_USB_VBUS_WAKEUP_SOURCE(3)
90 struct usbmisc_ops {
91 /* It's called once when probe a usb device */
92 int (*init)(struct imx_usbmisc_data *data);
93 /* It's called once after adding a usb device */
94 int (*post)(struct imx_usbmisc_data *data);
95 /* It's called when we need to enable/disable usb wakeup */
96 int (*set_wakeup)(struct imx_usbmisc_data *data, bool enabled);
99 struct imx_usbmisc {
100 void __iomem *base;
101 spinlock_t lock;
102 const struct usbmisc_ops *ops;
105 static inline bool is_imx53_usbmisc(struct imx_usbmisc_data *data);
107 static int usbmisc_imx25_init(struct imx_usbmisc_data *data)
109 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
110 unsigned long flags;
111 u32 val = 0;
113 if (data->index > 1)
114 return -EINVAL;
116 spin_lock_irqsave(&usbmisc->lock, flags);
117 switch (data->index) {
118 case 0:
119 val = readl(usbmisc->base);
120 val &= ~(MX25_OTG_SIC_MASK | MX25_OTG_PP_BIT);
121 val |= (MX25_EHCI_INTERFACE_DIFF_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_OTG_SIC_SHIFT;
122 val |= (MX25_OTG_PM_BIT | MX25_OTG_OCPOL_BIT);
123 writel(val, usbmisc->base);
124 break;
125 case 1:
126 val = readl(usbmisc->base);
127 val &= ~(MX25_H1_SIC_MASK | MX25_H1_PP_BIT | MX25_H1_IPPUE_UP_BIT);
128 val |= (MX25_EHCI_INTERFACE_SINGLE_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_H1_SIC_SHIFT;
129 val |= (MX25_H1_PM_BIT | MX25_H1_OCPOL_BIT | MX25_H1_TLL_BIT |
130 MX25_H1_USBTE_BIT | MX25_H1_IPPUE_DOWN_BIT);
132 writel(val, usbmisc->base);
134 break;
136 spin_unlock_irqrestore(&usbmisc->lock, flags);
138 return 0;
141 static int usbmisc_imx25_post(struct imx_usbmisc_data *data)
143 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
144 void __iomem *reg;
145 unsigned long flags;
146 u32 val;
148 if (data->index > 2)
149 return -EINVAL;
151 if (data->index)
152 return 0;
154 spin_lock_irqsave(&usbmisc->lock, flags);
155 reg = usbmisc->base + MX25_USB_PHY_CTRL_OFFSET;
156 val = readl(reg);
158 if (data->evdo)
159 val |= MX25_BM_EXTERNAL_VBUS_DIVIDER;
160 else
161 val &= ~MX25_BM_EXTERNAL_VBUS_DIVIDER;
163 writel(val, reg);
164 spin_unlock_irqrestore(&usbmisc->lock, flags);
165 usleep_range(5000, 10000); /* needed to stabilize voltage */
167 return 0;
170 static int usbmisc_imx27_init(struct imx_usbmisc_data *data)
172 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
173 unsigned long flags;
174 u32 val;
176 switch (data->index) {
177 case 0:
178 val = MX27_OTG_PM_BIT;
179 break;
180 case 1:
181 val = MX27_H1_PM_BIT;
182 break;
183 case 2:
184 val = MX27_H2_PM_BIT;
185 break;
186 default:
187 return -EINVAL;
190 spin_lock_irqsave(&usbmisc->lock, flags);
191 if (data->disable_oc)
192 val = readl(usbmisc->base) | val;
193 else
194 val = readl(usbmisc->base) & ~val;
195 writel(val, usbmisc->base);
196 spin_unlock_irqrestore(&usbmisc->lock, flags);
198 return 0;
201 static int usbmisc_imx53_init(struct imx_usbmisc_data *data)
203 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
204 void __iomem *reg = NULL;
205 unsigned long flags;
206 u32 val = 0;
208 if (data->index > 3)
209 return -EINVAL;
211 /* Select a 24 MHz reference clock for the PHY */
212 val = readl(usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET);
213 val &= ~MX53_USB_PHYCTRL1_PLLDIV_MASK;
214 val |= MX53_USB_PLL_DIV_24_MHZ;
215 writel(val, usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET);
217 spin_lock_irqsave(&usbmisc->lock, flags);
219 switch (data->index) {
220 case 0:
221 if (data->disable_oc) {
222 reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
223 val = readl(reg) | MX53_BM_OVER_CUR_DIS_OTG;
224 writel(val, reg);
226 break;
227 case 1:
228 if (data->disable_oc) {
229 reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
230 val = readl(reg) | MX53_BM_OVER_CUR_DIS_H1;
231 writel(val, reg);
233 break;
234 case 2:
235 if (data->ulpi) {
236 /* set USBH2 into ULPI-mode. */
237 reg = usbmisc->base + MX53_USB_CTRL_1_OFFSET;
238 val = readl(reg) | MX53_USB_CTRL_1_UH2_ULPI_EN;
239 /* select ULPI clock */
240 val &= ~MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_MASK;
241 val |= MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_ULPI;
242 writel(val, reg);
243 /* Set interrupt wake up enable */
244 reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
245 val = readl(reg) | MX53_USB_UHx_CTRL_WAKE_UP_EN
246 | MX53_USB_UHx_CTRL_ULPI_INT_EN;
247 writel(val, reg);
248 if (is_imx53_usbmisc(data)) {
249 /* Disable internal 60Mhz clock */
250 reg = usbmisc->base +
251 MX53_USB_CLKONOFF_CTRL_OFFSET;
252 val = readl(reg) |
253 MX53_USB_CLKONOFF_CTRL_H2_INT60CKOFF;
254 writel(val, reg);
258 if (data->disable_oc) {
259 reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
260 val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
261 writel(val, reg);
263 break;
264 case 3:
265 if (data->ulpi) {
266 /* set USBH3 into ULPI-mode. */
267 reg = usbmisc->base + MX53_USB_CTRL_1_OFFSET;
268 val = readl(reg) | MX53_USB_CTRL_1_UH3_ULPI_EN;
269 /* select ULPI clock */
270 val &= ~MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_MASK;
271 val |= MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_ULPI;
272 writel(val, reg);
273 /* Set interrupt wake up enable */
274 reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
275 val = readl(reg) | MX53_USB_UHx_CTRL_WAKE_UP_EN
276 | MX53_USB_UHx_CTRL_ULPI_INT_EN;
277 writel(val, reg);
279 if (is_imx53_usbmisc(data)) {
280 /* Disable internal 60Mhz clock */
281 reg = usbmisc->base +
282 MX53_USB_CLKONOFF_CTRL_OFFSET;
283 val = readl(reg) |
284 MX53_USB_CLKONOFF_CTRL_H3_INT60CKOFF;
285 writel(val, reg);
288 if (data->disable_oc) {
289 reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
290 val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
291 writel(val, reg);
293 break;
296 spin_unlock_irqrestore(&usbmisc->lock, flags);
298 return 0;
301 static int usbmisc_imx6q_set_wakeup
302 (struct imx_usbmisc_data *data, bool enabled)
304 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
305 unsigned long flags;
306 u32 val;
307 u32 wakeup_setting = (MX6_BM_WAKEUP_ENABLE |
308 MX6_BM_VBUS_WAKEUP | MX6_BM_ID_WAKEUP);
309 int ret = 0;
311 if (data->index > 3)
312 return -EINVAL;
314 spin_lock_irqsave(&usbmisc->lock, flags);
315 val = readl(usbmisc->base + data->index * 4);
316 if (enabled) {
317 val |= wakeup_setting;
318 } else {
319 if (val & MX6_BM_WAKEUP_INTR)
320 pr_debug("wakeup int at ci_hdrc.%d\n", data->index);
321 val &= ~wakeup_setting;
323 writel(val, usbmisc->base + data->index * 4);
324 spin_unlock_irqrestore(&usbmisc->lock, flags);
326 return ret;
329 static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
331 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
332 unsigned long flags;
333 u32 reg;
335 if (data->index > 3)
336 return -EINVAL;
338 spin_lock_irqsave(&usbmisc->lock, flags);
340 reg = readl(usbmisc->base + data->index * 4);
341 if (data->disable_oc) {
342 reg |= MX6_BM_OVER_CUR_DIS;
343 } else if (data->oc_polarity == 1) {
344 /* High active */
345 reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY);
346 } else {
347 reg &= ~(MX6_BM_OVER_CUR_DIS);
349 writel(reg, usbmisc->base + data->index * 4);
351 /* SoC non-burst setting */
352 reg = readl(usbmisc->base + data->index * 4);
353 writel(reg | MX6_BM_NON_BURST_SETTING,
354 usbmisc->base + data->index * 4);
356 spin_unlock_irqrestore(&usbmisc->lock, flags);
358 usbmisc_imx6q_set_wakeup(data, false);
360 return 0;
363 static int usbmisc_imx6sx_init(struct imx_usbmisc_data *data)
365 void __iomem *reg = NULL;
366 unsigned long flags;
367 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
368 u32 val;
370 usbmisc_imx6q_init(data);
372 if (data->index == 0 || data->index == 1) {
373 reg = usbmisc->base + MX6_USB_OTG1_PHY_CTRL + data->index * 4;
374 spin_lock_irqsave(&usbmisc->lock, flags);
375 /* Set vbus wakeup source as bvalid */
376 val = readl(reg);
377 writel(val | MX6SX_USB_VBUS_WAKEUP_SOURCE_BVALID, reg);
379 * Disable dp/dm wakeup in device mode when vbus is
380 * not there.
382 val = readl(usbmisc->base + data->index * 4);
383 writel(val & ~MX6SX_BM_DPDM_WAKEUP_EN,
384 usbmisc->base + data->index * 4);
385 spin_unlock_irqrestore(&usbmisc->lock, flags);
388 return 0;
391 static int usbmisc_vf610_init(struct imx_usbmisc_data *data)
393 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
394 u32 reg;
397 * Vybrid only has one misc register set, but in two different
398 * areas. These is reflected in two instances of this driver.
400 if (data->index >= 1)
401 return -EINVAL;
403 if (data->disable_oc) {
404 reg = readl(usbmisc->base);
405 writel(reg | VF610_OVER_CUR_DIS, usbmisc->base);
408 return 0;
411 static int usbmisc_imx7d_set_wakeup
412 (struct imx_usbmisc_data *data, bool enabled)
414 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
415 unsigned long flags;
416 u32 val;
417 u32 wakeup_setting = (MX6_BM_WAKEUP_ENABLE |
418 MX6_BM_VBUS_WAKEUP | MX6_BM_ID_WAKEUP);
420 spin_lock_irqsave(&usbmisc->lock, flags);
421 val = readl(usbmisc->base);
422 if (enabled) {
423 writel(val | wakeup_setting, usbmisc->base);
424 } else {
425 if (val & MX6_BM_WAKEUP_INTR)
426 dev_dbg(data->dev, "wakeup int\n");
427 writel(val & ~wakeup_setting, usbmisc->base);
429 spin_unlock_irqrestore(&usbmisc->lock, flags);
431 return 0;
434 static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)
436 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
437 unsigned long flags;
438 u32 reg;
440 if (data->index >= 1)
441 return -EINVAL;
443 spin_lock_irqsave(&usbmisc->lock, flags);
444 reg = readl(usbmisc->base);
445 if (data->disable_oc) {
446 reg |= MX6_BM_OVER_CUR_DIS;
447 } else if (data->oc_polarity == 1) {
448 /* High active */
449 reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY);
451 writel(reg, usbmisc->base);
453 reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
454 reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK;
455 writel(reg | MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID,
456 usbmisc->base + MX7D_USBNC_USB_CTRL2);
457 spin_unlock_irqrestore(&usbmisc->lock, flags);
459 usbmisc_imx7d_set_wakeup(data, false);
461 return 0;
464 static const struct usbmisc_ops imx25_usbmisc_ops = {
465 .init = usbmisc_imx25_init,
466 .post = usbmisc_imx25_post,
469 static const struct usbmisc_ops imx27_usbmisc_ops = {
470 .init = usbmisc_imx27_init,
473 static const struct usbmisc_ops imx51_usbmisc_ops = {
474 .init = usbmisc_imx53_init,
477 static const struct usbmisc_ops imx53_usbmisc_ops = {
478 .init = usbmisc_imx53_init,
481 static const struct usbmisc_ops imx6q_usbmisc_ops = {
482 .set_wakeup = usbmisc_imx6q_set_wakeup,
483 .init = usbmisc_imx6q_init,
486 static const struct usbmisc_ops vf610_usbmisc_ops = {
487 .init = usbmisc_vf610_init,
490 static const struct usbmisc_ops imx6sx_usbmisc_ops = {
491 .set_wakeup = usbmisc_imx6q_set_wakeup,
492 .init = usbmisc_imx6sx_init,
495 static const struct usbmisc_ops imx7d_usbmisc_ops = {
496 .init = usbmisc_imx7d_init,
497 .set_wakeup = usbmisc_imx7d_set_wakeup,
500 static inline bool is_imx53_usbmisc(struct imx_usbmisc_data *data)
502 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
504 return usbmisc->ops == &imx53_usbmisc_ops;
507 int imx_usbmisc_init(struct imx_usbmisc_data *data)
509 struct imx_usbmisc *usbmisc;
511 if (!data)
512 return 0;
514 usbmisc = dev_get_drvdata(data->dev);
515 if (!usbmisc->ops->init)
516 return 0;
517 return usbmisc->ops->init(data);
519 EXPORT_SYMBOL_GPL(imx_usbmisc_init);
521 int imx_usbmisc_init_post(struct imx_usbmisc_data *data)
523 struct imx_usbmisc *usbmisc;
525 if (!data)
526 return 0;
528 usbmisc = dev_get_drvdata(data->dev);
529 if (!usbmisc->ops->post)
530 return 0;
531 return usbmisc->ops->post(data);
533 EXPORT_SYMBOL_GPL(imx_usbmisc_init_post);
535 int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *data, bool enabled)
537 struct imx_usbmisc *usbmisc;
539 if (!data)
540 return 0;
542 usbmisc = dev_get_drvdata(data->dev);
543 if (!usbmisc->ops->set_wakeup)
544 return 0;
545 return usbmisc->ops->set_wakeup(data, enabled);
547 EXPORT_SYMBOL_GPL(imx_usbmisc_set_wakeup);
549 static const struct of_device_id usbmisc_imx_dt_ids[] = {
551 .compatible = "fsl,imx25-usbmisc",
552 .data = &imx25_usbmisc_ops,
555 .compatible = "fsl,imx35-usbmisc",
556 .data = &imx25_usbmisc_ops,
559 .compatible = "fsl,imx27-usbmisc",
560 .data = &imx27_usbmisc_ops,
563 .compatible = "fsl,imx51-usbmisc",
564 .data = &imx51_usbmisc_ops,
567 .compatible = "fsl,imx53-usbmisc",
568 .data = &imx53_usbmisc_ops,
571 .compatible = "fsl,imx6q-usbmisc",
572 .data = &imx6q_usbmisc_ops,
575 .compatible = "fsl,vf610-usbmisc",
576 .data = &vf610_usbmisc_ops,
579 .compatible = "fsl,imx6sx-usbmisc",
580 .data = &imx6sx_usbmisc_ops,
583 .compatible = "fsl,imx6ul-usbmisc",
584 .data = &imx6sx_usbmisc_ops,
587 .compatible = "fsl,imx7d-usbmisc",
588 .data = &imx7d_usbmisc_ops,
590 { /* sentinel */ }
592 MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
594 static int usbmisc_imx_probe(struct platform_device *pdev)
596 struct resource *res;
597 struct imx_usbmisc *data;
598 const struct of_device_id *of_id;
600 of_id = of_match_device(usbmisc_imx_dt_ids, &pdev->dev);
601 if (!of_id)
602 return -ENODEV;
604 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
605 if (!data)
606 return -ENOMEM;
608 spin_lock_init(&data->lock);
610 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
611 data->base = devm_ioremap_resource(&pdev->dev, res);
612 if (IS_ERR(data->base))
613 return PTR_ERR(data->base);
615 data->ops = (const struct usbmisc_ops *)of_id->data;
616 platform_set_drvdata(pdev, data);
618 return 0;
621 static int usbmisc_imx_remove(struct platform_device *pdev)
623 return 0;
626 static struct platform_driver usbmisc_imx_driver = {
627 .probe = usbmisc_imx_probe,
628 .remove = usbmisc_imx_remove,
629 .driver = {
630 .name = "usbmisc_imx",
631 .of_match_table = usbmisc_imx_dt_ids,
635 module_platform_driver(usbmisc_imx_driver);
637 MODULE_ALIAS("platform:usbmisc-imx");
638 MODULE_LICENSE("GPL v2");
639 MODULE_DESCRIPTION("driver for imx usb non-core registers");
640 MODULE_AUTHOR("Richard Zhao <richard.zhao@freescale.com>");