dm: core: Create a new header file for 'compat' features
[oweals/u-boot.git] / drivers / usb / musb-new / am35x.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Texas Instruments AM35x "glue layer"
4  *
5  * Copyright (c) 2010, by Texas Instruments
6  *
7  * Based on the DA8xx "glue layer" code.
8  * Copyright (c) 2008-2009, MontaVista Software, Inc. <source@mvista.com>
9  *
10  * This file is part of the Inventra Controller Driver for Linux.
11  *
12  */
13
14 #ifndef __UBOOT__
15 #include <dm/device_compat.h>
16 #include <dm/devres.h>
17 #include <linux/init.h>
18 #include <linux/module.h>
19 #include <linux/clk.h>
20 #include <linux/err.h>
21 #include <linux/io.h>
22 #include <linux/platform_device.h>
23 #include <linux/dma-mapping.h>
24
25 #include <plat/usb.h>
26 #else
27 #include <common.h>
28 #include <asm/omap_musb.h>
29 #include "linux-compat.h"
30 #endif
31
32 #include "musb_core.h"
33
34 /*
35  * AM35x specific definitions
36  */
37 /* USB 2.0 OTG module registers */
38 #define USB_REVISION_REG        0x00
39 #define USB_CTRL_REG            0x04
40 #define USB_STAT_REG            0x08
41 #define USB_EMULATION_REG       0x0c
42 /* 0x10 Reserved */
43 #define USB_AUTOREQ_REG         0x14
44 #define USB_SRP_FIX_TIME_REG    0x18
45 #define USB_TEARDOWN_REG        0x1c
46 #define EP_INTR_SRC_REG         0x20
47 #define EP_INTR_SRC_SET_REG     0x24
48 #define EP_INTR_SRC_CLEAR_REG   0x28
49 #define EP_INTR_MASK_REG        0x2c
50 #define EP_INTR_MASK_SET_REG    0x30
51 #define EP_INTR_MASK_CLEAR_REG  0x34
52 #define EP_INTR_SRC_MASKED_REG  0x38
53 #define CORE_INTR_SRC_REG       0x40
54 #define CORE_INTR_SRC_SET_REG   0x44
55 #define CORE_INTR_SRC_CLEAR_REG 0x48
56 #define CORE_INTR_MASK_REG      0x4c
57 #define CORE_INTR_MASK_SET_REG  0x50
58 #define CORE_INTR_MASK_CLEAR_REG 0x54
59 #define CORE_INTR_SRC_MASKED_REG 0x58
60 /* 0x5c Reserved */
61 #define USB_END_OF_INTR_REG     0x60
62
63 /* Control register bits */
64 #define AM35X_SOFT_RESET_MASK   1
65
66 /* USB interrupt register bits */
67 #define AM35X_INTR_USB_SHIFT    16
68 #define AM35X_INTR_USB_MASK     (0x1ff << AM35X_INTR_USB_SHIFT)
69 #define AM35X_INTR_DRVVBUS      0x100
70 #define AM35X_INTR_RX_SHIFT     16
71 #define AM35X_INTR_TX_SHIFT     0
72 #define AM35X_TX_EP_MASK        0xffff          /* EP0 + 15 Tx EPs */
73 #define AM35X_RX_EP_MASK        0xfffe          /* 15 Rx EPs */
74 #define AM35X_TX_INTR_MASK      (AM35X_TX_EP_MASK << AM35X_INTR_TX_SHIFT)
75 #define AM35X_RX_INTR_MASK      (AM35X_RX_EP_MASK << AM35X_INTR_RX_SHIFT)
76
77 #define USB_MENTOR_CORE_OFFSET  0x400
78
79 struct am35x_glue {
80         struct device           *dev;
81         struct platform_device  *musb;
82         struct clk              *phy_clk;
83         struct clk              *clk;
84 };
85 #define glue_to_musb(g)         platform_get_drvdata(g->musb)
86
87 /*
88  * am35x_musb_enable - enable interrupts
89  */
90 #ifndef __UBOOT__
91 static void am35x_musb_enable(struct musb *musb)
92 #else
93 static int am35x_musb_enable(struct musb *musb)
94 #endif
95 {
96         void __iomem *reg_base = musb->ctrl_base;
97         u32 epmask;
98
99         /* Workaround: setup IRQs through both register sets. */
100         epmask = ((musb->epmask & AM35X_TX_EP_MASK) << AM35X_INTR_TX_SHIFT) |
101                ((musb->epmask & AM35X_RX_EP_MASK) << AM35X_INTR_RX_SHIFT);
102
103         musb_writel(reg_base, EP_INTR_MASK_SET_REG, epmask);
104         musb_writel(reg_base, CORE_INTR_MASK_SET_REG, AM35X_INTR_USB_MASK);
105
106         /* Force the DRVVBUS IRQ so we can start polling for ID change. */
107         if (is_otg_enabled(musb))
108                 musb_writel(reg_base, CORE_INTR_SRC_SET_REG,
109                             AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT);
110 #ifdef __UBOOT__
111         return 0;
112 #endif
113 }
114
115 /*
116  * am35x_musb_disable - disable HDRC and flush interrupts
117  */
118 static void am35x_musb_disable(struct musb *musb)
119 {
120         void __iomem *reg_base = musb->ctrl_base;
121
122         musb_writel(reg_base, CORE_INTR_MASK_CLEAR_REG, AM35X_INTR_USB_MASK);
123         musb_writel(reg_base, EP_INTR_MASK_CLEAR_REG,
124                          AM35X_TX_INTR_MASK | AM35X_RX_INTR_MASK);
125         musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
126         musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
127 }
128
129 #ifndef __UBOOT__
130 #define portstate(stmt)         stmt
131
132 static void am35x_musb_set_vbus(struct musb *musb, int is_on)
133 {
134         WARN_ON(is_on && is_peripheral_active(musb));
135 }
136
137 #define POLL_SECONDS    2
138
139 static struct timer_list otg_workaround;
140
141 static void otg_timer(unsigned long _musb)
142 {
143         struct musb             *musb = (void *)_musb;
144         void __iomem            *mregs = musb->mregs;
145         u8                      devctl;
146         unsigned long           flags;
147
148         /*
149          * We poll because AM35x's won't expose several OTG-critical
150          * status change events (from the transceiver) otherwise.
151          */
152         devctl = musb_readb(mregs, MUSB_DEVCTL);
153         dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
154                 otg_state_string(musb->xceiv->state));
155
156         spin_lock_irqsave(&musb->lock, flags);
157         switch (musb->xceiv->state) {
158         case OTG_STATE_A_WAIT_BCON:
159                 devctl &= ~MUSB_DEVCTL_SESSION;
160                 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
161
162                 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
163                 if (devctl & MUSB_DEVCTL_BDEVICE) {
164                         musb->xceiv->state = OTG_STATE_B_IDLE;
165                         MUSB_DEV_MODE(musb);
166                 } else {
167                         musb->xceiv->state = OTG_STATE_A_IDLE;
168                         MUSB_HST_MODE(musb);
169                 }
170                 break;
171         case OTG_STATE_A_WAIT_VFALL:
172                 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
173                 musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
174                             MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
175                 break;
176         case OTG_STATE_B_IDLE:
177                 if (!is_peripheral_enabled(musb))
178                         break;
179
180                 devctl = musb_readb(mregs, MUSB_DEVCTL);
181                 if (devctl & MUSB_DEVCTL_BDEVICE)
182                         mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
183                 else
184                         musb->xceiv->state = OTG_STATE_A_IDLE;
185                 break;
186         default:
187                 break;
188         }
189         spin_unlock_irqrestore(&musb->lock, flags);
190 }
191
192 static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
193 {
194         static unsigned long last_timer;
195
196         if (!is_otg_enabled(musb))
197                 return;
198
199         if (timeout == 0)
200                 timeout = jiffies + msecs_to_jiffies(3);
201
202         /* Never idle if active, or when VBUS timeout is not set as host */
203         if (musb->is_active || (musb->a_wait_bcon == 0 &&
204                                 musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
205                 dev_dbg(musb->controller, "%s active, deleting timer\n",
206                         otg_state_string(musb->xceiv->state));
207                 del_timer(&otg_workaround);
208                 last_timer = jiffies;
209                 return;
210         }
211
212         if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) {
213                 dev_dbg(musb->controller, "Longer idle timer already pending, ignoring...\n");
214                 return;
215         }
216         last_timer = timeout;
217
218         dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
219                 otg_state_string(musb->xceiv->state),
220                 jiffies_to_msecs(timeout - jiffies));
221         mod_timer(&otg_workaround, timeout);
222 }
223 #endif
224
225 static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
226 {
227         struct musb  *musb = hci;
228         void __iomem *reg_base = musb->ctrl_base;
229 #ifndef __UBOOT__
230         struct device *dev = musb->controller;
231         struct musb_hdrc_platform_data *plat = dev->platform_data;
232         struct omap_musb_board_data *data = plat->board_data;
233         struct usb_otg *otg = musb->xceiv->otg;
234 #else
235         struct omap_musb_board_data *data =
236                 (struct omap_musb_board_data *)musb->controller;
237 #endif
238         unsigned long flags;
239         irqreturn_t ret = IRQ_NONE;
240         u32 epintr, usbintr;
241
242 #ifdef __UBOOT__
243         /*
244          * It seems that on AM35X interrupt registers can be updated
245          * before core registers. This confuses the code.
246          * As a workaround add a small delay here.
247          */
248         udelay(10);
249 #endif
250         spin_lock_irqsave(&musb->lock, flags);
251
252         /* Get endpoint interrupts */
253         epintr = musb_readl(reg_base, EP_INTR_SRC_MASKED_REG);
254
255         if (epintr) {
256                 musb_writel(reg_base, EP_INTR_SRC_CLEAR_REG, epintr);
257
258                 musb->int_rx =
259                         (epintr & AM35X_RX_INTR_MASK) >> AM35X_INTR_RX_SHIFT;
260                 musb->int_tx =
261                         (epintr & AM35X_TX_INTR_MASK) >> AM35X_INTR_TX_SHIFT;
262         }
263
264         /* Get usb core interrupts */
265         usbintr = musb_readl(reg_base, CORE_INTR_SRC_MASKED_REG);
266         if (!usbintr && !epintr)
267                 goto eoi;
268
269         if (usbintr) {
270                 musb_writel(reg_base, CORE_INTR_SRC_CLEAR_REG, usbintr);
271
272                 musb->int_usb =
273                         (usbintr & AM35X_INTR_USB_MASK) >> AM35X_INTR_USB_SHIFT;
274         }
275 #ifndef __UBOOT__
276         /*
277          * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
278          * AM35x's missing ID change IRQ.  We need an ID change IRQ to
279          * switch appropriately between halves of the OTG state machine.
280          * Managing DEVCTL.SESSION per Mentor docs requires that we know its
281          * value but DEVCTL.BDEVICE is invalid without DEVCTL.SESSION set.
282          * Also, DRVVBUS pulses for SRP (but not at 5V) ...
283          */
284         if (usbintr & (AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT)) {
285                 int drvvbus = musb_readl(reg_base, USB_STAT_REG);
286                 void __iomem *mregs = musb->mregs;
287                 u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
288                 int err;
289
290                 err = is_host_enabled(musb) && (musb->int_usb &
291                                                 MUSB_INTR_VBUSERROR);
292                 if (err) {
293                         /*
294                          * The Mentor core doesn't debounce VBUS as needed
295                          * to cope with device connect current spikes. This
296                          * means it's not uncommon for bus-powered devices
297                          * to get VBUS errors during enumeration.
298                          *
299                          * This is a workaround, but newer RTL from Mentor
300                          * seems to allow a better one: "re"-starting sessions
301                          * without waiting for VBUS to stop registering in
302                          * devctl.
303                          */
304                         musb->int_usb &= ~MUSB_INTR_VBUSERROR;
305                         musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
306                         mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
307                         WARNING("VBUS error workaround (delay coming)\n");
308                 } else if (is_host_enabled(musb) && drvvbus) {
309                         MUSB_HST_MODE(musb);
310                         otg->default_a = 1;
311                         musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
312                         portstate(musb->port1_status |= USB_PORT_STAT_POWER);
313                         del_timer(&otg_workaround);
314                 } else {
315                         musb->is_active = 0;
316                         MUSB_DEV_MODE(musb);
317                         otg->default_a = 0;
318                         musb->xceiv->state = OTG_STATE_B_IDLE;
319                         portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
320                 }
321
322                 /* NOTE: this must complete power-on within 100 ms. */
323                 dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
324                                 drvvbus ? "on" : "off",
325                                 otg_state_string(musb->xceiv->state),
326                                 err ? " ERROR" : "",
327                                 devctl);
328                 ret = IRQ_HANDLED;
329         }
330 #endif
331
332         if (musb->int_tx || musb->int_rx || musb->int_usb)
333                 ret |= musb_interrupt(musb);
334
335 eoi:
336         /* EOI needs to be written for the IRQ to be re-asserted. */
337         if (ret == IRQ_HANDLED || epintr || usbintr) {
338                 /* clear level interrupt */
339                 if (data->clear_irq)
340                         data->clear_irq(data->dev);
341                 /* write EOI */
342                 musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
343         }
344
345 #ifndef __UBOOT__
346         /* Poll for ID change */
347         if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE)
348                 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
349 #endif
350
351         spin_unlock_irqrestore(&musb->lock, flags);
352
353         return ret;
354 }
355
356 #ifndef __UBOOT__
357 static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode)
358 {
359         struct device *dev = musb->controller;
360         struct musb_hdrc_platform_data *plat = dev->platform_data;
361         struct omap_musb_board_data *data = plat->board_data;
362         int     retval = 0;
363
364         if (data->set_mode)
365                 data->set_mode(musb_mode);
366         else
367                 retval = -EIO;
368
369         return retval;
370 }
371 #endif
372
373 static int am35x_musb_init(struct musb *musb)
374 {
375 #ifndef __UBOOT__
376         struct device *dev = musb->controller;
377         struct musb_hdrc_platform_data *plat = dev->platform_data;
378         struct omap_musb_board_data *data = plat->board_data;
379 #else
380         struct omap_musb_board_data *data =
381                 (struct omap_musb_board_data *)musb->controller;
382 #endif
383         void __iomem *reg_base = musb->ctrl_base;
384         u32 rev;
385
386         musb->mregs += USB_MENTOR_CORE_OFFSET;
387
388         /* Returns zero if e.g. not clocked */
389         rev = musb_readl(reg_base, USB_REVISION_REG);
390         if (!rev)
391                 return -ENODEV;
392
393 #ifndef __UBOOT__
394         usb_nop_xceiv_register();
395         musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
396         if (IS_ERR_OR_NULL(musb->xceiv))
397                 return -ENODEV;
398
399         if (is_host_enabled(musb))
400                 setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);
401 #endif
402
403         /* Reset the musb */
404         if (data->reset)
405                 data->reset(data->dev);
406
407         /* Reset the controller */
408         musb_writel(reg_base, USB_CTRL_REG, AM35X_SOFT_RESET_MASK);
409
410         /* Start the on-chip PHY and its PLL. */
411         if (data && data->set_phy_power)
412                 data->set_phy_power(data->dev, 1);
413
414         msleep(5);
415
416         musb->isr = am35x_musb_interrupt;
417
418         /* clear level interrupt */
419         if (data->clear_irq)
420                 data->clear_irq(data->dev);
421
422         return 0;
423 }
424
425 static int am35x_musb_exit(struct musb *musb)
426 {
427 #ifndef __UBOOT__
428         struct device *dev = musb->controller;
429         struct musb_hdrc_platform_data *plat = dev->platform_data;
430         struct omap_musb_board_data *data = plat->board_data;
431 #else
432         struct omap_musb_board_data *data =
433                 (struct omap_musb_board_data *)musb->controller;
434 #endif
435
436 #ifndef __UBOOT__
437         if (is_host_enabled(musb))
438                 del_timer_sync(&otg_workaround);
439 #endif
440
441         /* Shutdown the on-chip PHY and its PLL. */
442         if (data && data->set_phy_power)
443                 data->set_phy_power(data->dev, 0);
444
445 #ifndef __UBOOT__
446         usb_put_phy(musb->xceiv);
447         usb_nop_xceiv_unregister();
448 #endif
449
450         return 0;
451 }
452
453 /* AM35x supports only 32bit read operation */
454 void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
455 {
456         void __iomem *fifo = hw_ep->fifo;
457         u32             val;
458         int             i;
459
460         /* Read for 32bit-aligned destination address */
461         if (likely((0x03 & (unsigned long) dst) == 0) && len >= 4) {
462                 readsl(fifo, dst, len >> 2);
463                 dst += len & ~0x03;
464                 len &= 0x03;
465         }
466         /*
467          * Now read the remaining 1 to 3 byte or complete length if
468          * unaligned address.
469          */
470         if (len > 4) {
471                 for (i = 0; i < (len >> 2); i++) {
472                         *(u32 *) dst = musb_readl(fifo, 0);
473                         dst += 4;
474                 }
475                 len &= 0x03;
476         }
477         if (len > 0) {
478                 val = musb_readl(fifo, 0);
479                 memcpy(dst, &val, len);
480         }
481 }
482
483 #ifndef __UBOOT__
484 static const struct musb_platform_ops am35x_ops = {
485 #else
486 const struct musb_platform_ops am35x_ops = {
487 #endif
488         .init           = am35x_musb_init,
489         .exit           = am35x_musb_exit,
490
491         .enable         = am35x_musb_enable,
492         .disable        = am35x_musb_disable,
493
494 #ifndef __UBOOT__
495         .set_mode       = am35x_musb_set_mode,
496         .try_idle       = am35x_musb_try_idle,
497
498         .set_vbus       = am35x_musb_set_vbus,
499 #endif
500 };
501
502 #ifndef __UBOOT__
503 static u64 am35x_dmamask = DMA_BIT_MASK(32);
504
505 static int __devinit am35x_probe(struct platform_device *pdev)
506 {
507         struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
508         struct platform_device          *musb;
509         struct am35x_glue               *glue;
510
511         struct clk                      *phy_clk;
512         struct clk                      *clk;
513
514         int                             ret = -ENOMEM;
515
516         glue = kzalloc(sizeof(*glue), GFP_KERNEL);
517         if (!glue) {
518                 dev_err(&pdev->dev, "failed to allocate glue context\n");
519                 goto err0;
520         }
521
522         musb = platform_device_alloc("musb-hdrc", -1);
523         if (!musb) {
524                 dev_err(&pdev->dev, "failed to allocate musb device\n");
525                 goto err1;
526         }
527
528         phy_clk = clk_get(&pdev->dev, "fck");
529         if (IS_ERR(phy_clk)) {
530                 dev_err(&pdev->dev, "failed to get PHY clock\n");
531                 ret = PTR_ERR(phy_clk);
532                 goto err2;
533         }
534
535         clk = clk_get(&pdev->dev, "ick");
536         if (IS_ERR(clk)) {
537                 dev_err(&pdev->dev, "failed to get clock\n");
538                 ret = PTR_ERR(clk);
539                 goto err3;
540         }
541
542         ret = clk_enable(phy_clk);
543         if (ret) {
544                 dev_err(&pdev->dev, "failed to enable PHY clock\n");
545                 goto err4;
546         }
547
548         ret = clk_enable(clk);
549         if (ret) {
550                 dev_err(&pdev->dev, "failed to enable clock\n");
551                 goto err5;
552         }
553
554         musb->dev.parent                = &pdev->dev;
555         musb->dev.dma_mask              = &am35x_dmamask;
556         musb->dev.coherent_dma_mask     = am35x_dmamask;
557
558         glue->dev                       = &pdev->dev;
559         glue->musb                      = musb;
560         glue->phy_clk                   = phy_clk;
561         glue->clk                       = clk;
562
563         pdata->platform_ops             = &am35x_ops;
564
565         platform_set_drvdata(pdev, glue);
566
567         ret = platform_device_add_resources(musb, pdev->resource,
568                         pdev->num_resources);
569         if (ret) {
570                 dev_err(&pdev->dev, "failed to add resources\n");
571                 goto err6;
572         }
573
574         ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
575         if (ret) {
576                 dev_err(&pdev->dev, "failed to add platform_data\n");
577                 goto err6;
578         }
579
580         ret = platform_device_add(musb);
581         if (ret) {
582                 dev_err(&pdev->dev, "failed to register musb device\n");
583                 goto err6;
584         }
585
586         return 0;
587
588 err6:
589         clk_disable(clk);
590
591 err5:
592         clk_disable(phy_clk);
593
594 err4:
595         clk_put(clk);
596
597 err3:
598         clk_put(phy_clk);
599
600 err2:
601         platform_device_put(musb);
602
603 err1:
604         kfree(glue);
605
606 err0:
607         return ret;
608 }
609
610 static int __devexit am35x_remove(struct platform_device *pdev)
611 {
612         struct am35x_glue       *glue = platform_get_drvdata(pdev);
613
614         platform_device_del(glue->musb);
615         platform_device_put(glue->musb);
616         clk_disable(glue->clk);
617         clk_disable(glue->phy_clk);
618         clk_put(glue->clk);
619         clk_put(glue->phy_clk);
620         kfree(glue);
621
622         return 0;
623 }
624
625 #ifdef CONFIG_PM
626 static int am35x_suspend(struct device *dev)
627 {
628         struct am35x_glue       *glue = dev_get_drvdata(dev);
629         struct musb_hdrc_platform_data *plat = dev->platform_data;
630         struct omap_musb_board_data *data = plat->board_data;
631
632         /* Shutdown the on-chip PHY and its PLL. */
633         if (data && data->set_phy_power)
634                 data->set_phy_power(data->dev, 0);
635
636         clk_disable(glue->phy_clk);
637         clk_disable(glue->clk);
638
639         return 0;
640 }
641
642 static int am35x_resume(struct device *dev)
643 {
644         struct am35x_glue       *glue = dev_get_drvdata(dev);
645         struct musb_hdrc_platform_data *plat = dev->platform_data;
646         struct omap_musb_board_data *data = plat->board_data;
647         int                     ret;
648
649         /* Start the on-chip PHY and its PLL. */
650         if (data && data->set_phy_power)
651                 data->set_phy_power(data->dev, 1);
652
653         ret = clk_enable(glue->phy_clk);
654         if (ret) {
655                 dev_err(dev, "failed to enable PHY clock\n");
656                 return ret;
657         }
658
659         ret = clk_enable(glue->clk);
660         if (ret) {
661                 dev_err(dev, "failed to enable clock\n");
662                 return ret;
663         }
664
665         return 0;
666 }
667
668 static struct dev_pm_ops am35x_pm_ops = {
669         .suspend        = am35x_suspend,
670         .resume         = am35x_resume,
671 };
672
673 #define DEV_PM_OPS      &am35x_pm_ops
674 #else
675 #define DEV_PM_OPS      NULL
676 #endif
677
678 static struct platform_driver am35x_driver = {
679         .probe          = am35x_probe,
680         .remove         = __devexit_p(am35x_remove),
681         .driver         = {
682                 .name   = "musb-am35x",
683                 .pm     = DEV_PM_OPS,
684         },
685 };
686
687 MODULE_DESCRIPTION("AM35x MUSB Glue Layer");
688 MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>");
689 MODULE_LICENSE("GPL v2");
690
691 static int __init am35x_init(void)
692 {
693         return platform_driver_register(&am35x_driver);
694 }
695 module_init(am35x_init);
696
697 static void __exit am35x_exit(void)
698 {
699         platform_driver_unregister(&am35x_driver);
700 }
701 module_exit(am35x_exit);
702 #endif