USB: support DWC_OTG Driver Version3.10 and used by default
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc_otg_310 / common_port / dwc_common_linux.c
1 #include <linux/kernel.h>
2 #include <linux/init.h>
3 #include <linux/module.h>
4 #include <linux/kthread.h>
5
6 #ifdef DWC_CCLIB
7 # include "dwc_cc.h"
8 #endif
9
10 #ifdef DWC_CRYPTOLIB
11 # include "dwc_modpow.h"
12 # include "dwc_dh.h"
13 # include "dwc_crypto.h"
14 #endif
15
16 #ifdef DWC_NOTIFYLIB
17 # include "dwc_notifier.h"
18 #endif
19
20 /* OS-Level Implementations */
21
22 /* This is the Linux kernel implementation of the DWC platform library. */
23 #include <linux/moduleparam.h>
24 #include <linux/ctype.h>
25 #include <linux/crypto.h>
26 #include <linux/delay.h>
27 #include <linux/device.h>
28 #include <linux/dma-mapping.h>
29 #include <linux/cdev.h>
30 #include <linux/errno.h>
31 #include <linux/interrupt.h>
32 #include <linux/jiffies.h>
33 #include <linux/list.h>
34 #include <linux/pci.h>
35 #include <linux/random.h>
36 #include <linux/scatterlist.h>
37 #include <linux/slab.h>
38 #include <linux/stat.h>
39 #include <linux/string.h>
40 #include <linux/timer.h>
41 #include <linux/usb.h>
42
43 #include <linux/version.h>
44
45 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
46 # include <linux/usb/gadget.h>
47 #else
48 # include <linux/usb_gadget.h>
49 #endif
50
51 #include <asm/io.h>
52 #include <asm/page.h>
53 #include <asm/uaccess.h>
54 #include <asm/unaligned.h>
55
56 #include "dwc_os.h"
57 #include "dwc_list.h"
58
59 /** Prefix string for DWC_DEBUG print macros. */
60
61
62 /* MISC */
63
64 void *DWC_MEMSET(void *dest, uint8_t byte, uint32_t size)
65 {
66         return memset(dest, byte, size);
67 }
68
69 void *DWC_MEMCPY(void *dest, void const *src, uint32_t size)
70 {
71         return memcpy(dest, src, size);
72 }
73
74 void *DWC_MEMMOVE(void *dest, void *src, uint32_t size)
75 {
76         return memmove(dest, src, size);
77 }
78
79 int DWC_MEMCMP(void *m1, void *m2, uint32_t size)
80 {
81         return memcmp(m1, m2, size);
82 }
83
84 int DWC_STRNCMP(void *s1, void *s2, uint32_t size)
85 {
86         return strncmp(s1, s2, size);
87 }
88
89 int DWC_STRCMP(void *s1, void *s2)
90 {
91         return strcmp(s1, s2);
92 }
93
94 int DWC_STRLEN(char const *str)
95 {
96         return strlen(str);
97 }
98
99 char *DWC_STRCPY(char *to, char const *from)
100 {
101         return strcpy(to, from);
102 }
103
104 char *DWC_STRDUP(char const *str)
105 {
106         int len = DWC_STRLEN(str) + 1;
107         char *new = DWC_ALLOC_ATOMIC(len);
108
109         if (!new) {
110                 return NULL;
111         }
112
113         DWC_MEMCPY(new, str, len);
114         return new;
115 }
116
117 int DWC_ATOI(const char *str, int32_t *value)
118 {
119         char *end = NULL;
120
121         *value = simple_strtol(str, &end, 0);
122         if (*end == '\0') {
123                 return 0;
124         }
125
126         return -1;
127 }
128
129 int DWC_ATOUI(const char *str, uint32_t *value)
130 {
131         char *end = NULL;
132
133         *value = simple_strtoul(str, &end, 0);
134         if (*end == '\0') {
135                 return 0;
136         }
137
138         return -1;
139 }
140
141
142 #ifdef DWC_UTFLIB
143 /* From usbstring.c */
144
145 int DWC_UTF8_TO_UTF16LE(uint8_t const *s, uint16_t *cp, unsigned len)
146 {
147         int     count = 0;
148         u8      c;
149         u16     uchar;
150
151         /* this insists on correct encodings, though not minimal ones.
152          * BUT it currently rejects legit 4-byte UTF-8 code points,
153          * which need surrogate pairs.  (Unicode 3.1 can use them.)
154          */
155         while (len != 0 && (c = (u8) *s++) != 0) {
156                 if (unlikely(c & 0x80)) {
157                         // 2-byte sequence:
158                         // 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx
159                         if ((c & 0xe0) == 0xc0) {
160                                 uchar = (c & 0x1f) << 6;
161
162                                 c = (u8) *s++;
163                                 if ((c & 0xc0) != 0xc0)
164                                         goto fail;
165                                 c &= 0x3f;
166                                 uchar |= c;
167
168                         // 3-byte sequence (most CJKV characters):
169                         // zzzzyyyyyyxxxxxx = 1110zzzz 10yyyyyy 10xxxxxx
170                         } else if ((c & 0xf0) == 0xe0) {
171                                 uchar = (c & 0x0f) << 12;
172
173                                 c = (u8) *s++;
174                                 if ((c & 0xc0) != 0xc0)
175                                         goto fail;
176                                 c &= 0x3f;
177                                 uchar |= c << 6;
178
179                                 c = (u8) *s++;
180                                 if ((c & 0xc0) != 0xc0)
181                                         goto fail;
182                                 c &= 0x3f;
183                                 uchar |= c;
184
185                                 /* no bogus surrogates */
186                                 if (0xd800 <= uchar && uchar <= 0xdfff)
187                                         goto fail;
188
189                         // 4-byte sequence (surrogate pairs, currently rare):
190                         // 11101110wwwwzzzzyy + 110111yyyyxxxxxx
191                         //     = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx
192                         // (uuuuu = wwww + 1)
193                         // FIXME accept the surrogate code points (only)
194                         } else
195                                 goto fail;
196                 } else
197                         uchar = c;
198                 put_unaligned (cpu_to_le16 (uchar), cp++);
199                 count++;
200                 len--;
201         }
202         return count;
203 fail:
204         return -1;
205 }
206 #endif  /* DWC_UTFLIB */
207
208
209 /* dwc_debug.h */
210
211 dwc_bool_t DWC_IN_IRQ(void)
212 {
213         return in_irq();
214 }
215
216 dwc_bool_t DWC_IN_BH(void)
217 {
218         return in_softirq();
219 }
220
221 void DWC_VPRINTF(char *format, va_list args)
222 {
223         vprintk(format, args);
224 }
225
226 int DWC_VSNPRINTF(char *str, int size, char *format, va_list args)
227 {
228         return vsnprintf(str, size, format, args);
229 }
230
231 void DWC_PRINTF(char *format, ...)
232 {
233         va_list args;
234
235         va_start(args, format);
236         DWC_VPRINTF(format, args);
237         va_end(args);
238 }
239
240 int DWC_SPRINTF(char *buffer, char *format, ...)
241 {
242         int retval;
243         va_list args;
244
245         va_start(args, format);
246         retval = vsprintf(buffer, format, args);
247         va_end(args);
248         return retval;
249 }
250
251 int DWC_SNPRINTF(char *buffer, int size, char *format, ...)
252 {
253         int retval;
254         va_list args;
255
256         va_start(args, format);
257         retval = vsnprintf(buffer, size, format, args);
258         va_end(args);
259         return retval;
260 }
261
262 void __DWC_WARN(char *format, ...)
263 {
264         va_list args;
265
266         va_start(args, format);
267         DWC_PRINTF(KERN_WARNING);
268         DWC_VPRINTF(format, args);
269         va_end(args);
270 }
271
272 void __DWC_ERROR(char *format, ...)
273 {
274         va_list args;
275
276         va_start(args, format);
277         DWC_PRINTF(KERN_ERR);
278         DWC_VPRINTF(format, args);
279         va_end(args);
280 }
281
282 void DWC_EXCEPTION(char *format, ...)
283 {
284         va_list args;
285
286         va_start(args, format);
287         DWC_PRINTF(KERN_ERR);
288         DWC_VPRINTF(format, args);
289         va_end(args);
290         BUG_ON(1);
291 }
292
293 #ifdef DEBUG
294 void __DWC_DEBUG(char *format, ...)
295 {
296         va_list args;
297
298         va_start(args, format);
299         DWC_PRINTF(KERN_ERR);
300         DWC_VPRINTF(format, args);
301         va_end(args);
302 }
303 #else
304 void __DWC_DEBUG(char *format, ...)
305 {
306     ;
307 }
308 #endif
309
310
311
312 /* dwc_mem.h */
313
314 #if 0
315 dwc_pool_t *DWC_DMA_POOL_CREATE(uint32_t size,
316                                 uint32_t align,
317                                 uint32_t alloc)
318 {
319         struct dma_pool *pool = dma_pool_create("Pool", NULL,
320                                                 size, align, alloc);
321         return (dwc_pool_t *)pool;
322 }
323
324 void DWC_DMA_POOL_DESTROY(dwc_pool_t *pool)
325 {
326         dma_pool_destroy((struct dma_pool *)pool);
327 }
328
329 void *DWC_DMA_POOL_ALLOC(dwc_pool_t *pool, uint64_t *dma_addr)
330 {
331         return dma_pool_alloc((struct dma_pool *)pool, GFP_KERNEL, dma_addr);
332 }
333
334 void *DWC_DMA_POOL_ZALLOC(dwc_pool_t *pool, uint64_t *dma_addr)
335 {
336         void *vaddr = DWC_DMA_POOL_ALLOC(pool, dma_addr);
337         memset(..);
338 }
339
340 void DWC_DMA_POOL_FREE(dwc_pool_t *pool, void *vaddr, void *daddr)
341 {
342         dma_pool_free(pool, vaddr, daddr);
343 }
344 #endif
345
346 void *__DWC_DMA_ALLOC(void *dma_ctx, uint32_t size, dwc_dma_t *dma_addr)
347 {
348 #if 1 //def xxCOSIM /* Only works for 32-bit cosim */
349         void *buf = dma_alloc_coherent(dma_ctx, (size_t)size, dma_addr, GFP_KERNEL);
350 #else
351         void *buf = dma_alloc_coherent(dma_ctx, (size_t)size, dma_addr, GFP_KERNEL | GFP_DMA32);
352 #endif
353         if (!buf) {
354                 return NULL;
355         }
356
357         memset(buf, 0, (size_t)size);
358         return buf;
359 }
360
361 void *__DWC_DMA_ALLOC_ATOMIC(void *dma_ctx, uint32_t size, dwc_dma_t *dma_addr)
362 {
363         void *buf = dma_alloc_coherent(NULL, (size_t)size, dma_addr, GFP_ATOMIC);
364         if (!buf) {
365                 return NULL;
366         }
367         memset(buf, 0, (size_t)size);
368         return buf;
369 }
370
371 void __DWC_DMA_FREE(void *dma_ctx, uint32_t size, void *virt_addr, dwc_dma_t dma_addr)
372 {
373         dma_free_coherent(dma_ctx, size, virt_addr, dma_addr);
374 }
375
376 void *__DWC_ALLOC(void *mem_ctx, uint32_t size)
377 {
378         return kzalloc(size, GFP_KERNEL);
379 }
380
381 void *__DWC_ALLOC_ATOMIC(void *mem_ctx, uint32_t size)
382 {
383         return kzalloc(size, GFP_ATOMIC);
384 }
385
386 void __DWC_FREE(void *mem_ctx, void *addr)
387 {
388         kfree(addr);
389 }
390
391
392 #ifdef DWC_CRYPTOLIB
393 /* dwc_crypto.h */
394
395 void DWC_RANDOM_BYTES(uint8_t *buffer, uint32_t length)
396 {
397         get_random_bytes(buffer, length);
398 }
399
400 int DWC_AES_CBC(uint8_t *message, uint32_t messagelen, uint8_t *key, uint32_t keylen, uint8_t iv[16], uint8_t *out)
401 {
402         struct crypto_blkcipher *tfm;
403         struct blkcipher_desc desc;
404         struct scatterlist sgd;
405         struct scatterlist sgs;
406
407         tfm = crypto_alloc_blkcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC);
408         if (tfm == NULL) {
409                 printk("failed to load transform for aes CBC\n");
410                 return -1;
411         }
412
413         crypto_blkcipher_setkey(tfm, key, keylen);
414         crypto_blkcipher_set_iv(tfm, iv, 16);
415
416         sg_init_one(&sgd, out, messagelen);
417         sg_init_one(&sgs, message, messagelen);
418
419         desc.tfm = tfm;
420         desc.flags = 0;
421
422         if (crypto_blkcipher_encrypt(&desc, &sgd, &sgs, messagelen)) {
423                 crypto_free_blkcipher(tfm);
424                 DWC_ERROR("AES CBC encryption failed");
425                 return -1;
426         }
427
428         crypto_free_blkcipher(tfm);
429         return 0;
430 }
431
432 int DWC_SHA256(uint8_t *message, uint32_t len, uint8_t *out)
433 {
434         struct crypto_hash *tfm;
435         struct hash_desc desc;
436         struct scatterlist sg;
437
438         tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
439         if (IS_ERR(tfm)) {
440                 DWC_ERROR("Failed to load transform for sha256: %ld\n", PTR_ERR(tfm));
441                 return 0;
442         }
443         desc.tfm = tfm;
444         desc.flags = 0;
445
446         sg_init_one(&sg, message, len);
447         crypto_hash_digest(&desc, &sg, len, out);
448         crypto_free_hash(tfm);
449
450         return 1;
451 }
452
453 int DWC_HMAC_SHA256(uint8_t *message, uint32_t messagelen,
454                     uint8_t *key, uint32_t keylen, uint8_t *out)
455 {
456         struct crypto_hash *tfm;
457         struct hash_desc desc;
458         struct scatterlist sg;
459
460         tfm = crypto_alloc_hash("hmac(sha256)", 0, CRYPTO_ALG_ASYNC);
461         if (IS_ERR(tfm)) {
462                 DWC_ERROR("Failed to load transform for hmac(sha256): %ld\n", PTR_ERR(tfm));
463                 return 0;
464         }
465         desc.tfm = tfm;
466         desc.flags = 0;
467
468         sg_init_one(&sg, message, messagelen);
469         crypto_hash_setkey(tfm, key, keylen);
470         crypto_hash_digest(&desc, &sg, messagelen, out);
471         crypto_free_hash(tfm);
472
473         return 1;
474 }
475 #endif  /* DWC_CRYPTOLIB */
476
477
478 /* Byte Ordering Conversions */
479
480 uint32_t DWC_CPU_TO_LE32(uint32_t *p)
481 {
482 #ifdef __LITTLE_ENDIAN
483         return *p;
484 #else
485         uint8_t *u_p = (uint8_t *)p;
486
487         return (u_p[3] | (u_p[2] << 8) | (u_p[1] << 16) | (u_p[0] << 24));
488 #endif
489 }
490
491 uint32_t DWC_CPU_TO_BE32(uint32_t *p)
492 {
493 #ifdef __BIG_ENDIAN
494         return *p;
495 #else
496         uint8_t *u_p = (uint8_t *)p;
497
498         return (u_p[3] | (u_p[2] << 8) | (u_p[1] << 16) | (u_p[0] << 24));
499 #endif
500 }
501
502 uint32_t DWC_LE32_TO_CPU(uint32_t *p)
503 {
504 #ifdef __LITTLE_ENDIAN
505         return *p;
506 #else
507         uint8_t *u_p = (uint8_t *)p;
508
509         return (u_p[3] | (u_p[2] << 8) | (u_p[1] << 16) | (u_p[0] << 24));
510 #endif
511 }
512
513 uint32_t DWC_BE32_TO_CPU(uint32_t *p)
514 {
515 #ifdef __BIG_ENDIAN
516         return *p;
517 #else
518         uint8_t *u_p = (uint8_t *)p;
519
520         return (u_p[3] | (u_p[2] << 8) | (u_p[1] << 16) | (u_p[0] << 24));
521 #endif
522 }
523
524 uint16_t DWC_CPU_TO_LE16(uint16_t *p)
525 {
526 #ifdef __LITTLE_ENDIAN
527         return *p;
528 #else
529         uint8_t *u_p = (uint8_t *)p;
530         return (u_p[1] | (u_p[0] << 8));
531 #endif
532 }
533
534 uint16_t DWC_CPU_TO_BE16(uint16_t *p)
535 {
536 #ifdef __BIG_ENDIAN
537         return *p;
538 #else
539         uint8_t *u_p = (uint8_t *)p;
540         return (u_p[1] | (u_p[0] << 8));
541 #endif
542 }
543
544 uint16_t DWC_LE16_TO_CPU(uint16_t *p)
545 {
546 #ifdef __LITTLE_ENDIAN
547         return *p;
548 #else
549         uint8_t *u_p = (uint8_t *)p;
550         return (u_p[1] | (u_p[0] << 8));
551 #endif
552 }
553
554 uint16_t DWC_BE16_TO_CPU(uint16_t *p)
555 {
556 #ifdef __BIG_ENDIAN
557         return *p;
558 #else
559         uint8_t *u_p = (uint8_t *)p;
560         return (u_p[1] | (u_p[0] << 8));
561 #endif
562 }
563
564
565 /* Registers */
566
567 uint32_t DWC_READ_REG32(uint32_t volatile *reg)
568 {
569         return readl_relaxed(reg);
570 }
571
572 #if 0
573 uint64_t DWC_READ_REG64(uint64_t volatile *reg)
574 {
575 }
576 #endif
577
578 void DWC_WRITE_REG32(uint32_t volatile *reg, uint32_t value)
579 {
580         writel_relaxed(value, reg);
581         dsb();
582 }
583
584 #if 0
585 void DWC_WRITE_REG64(uint64_t volatile *reg, uint64_t value)
586 {
587 }
588 #endif
589
590 void DWC_MODIFY_REG32(uint32_t volatile *reg, uint32_t clear_mask, uint32_t set_mask)
591 {
592         writel_relaxed((readl_relaxed(reg) & ~clear_mask) | set_mask, reg);
593         dsb();
594 }
595
596 #if 0
597 void DWC_MODIFY_REG64(uint64_t volatile *reg, uint64_t clear_mask, uint64_t set_mask)
598 {
599 }
600 #endif
601
602
603 /* Locking */
604
605 dwc_spinlock_t *DWC_SPINLOCK_ALLOC(void)
606 {
607         spinlock_t *sl = (spinlock_t *)1;
608
609 #if defined(CONFIG_PREEMPT) || defined(CONFIG_SMP)
610         sl = DWC_ALLOC(sizeof(*sl));
611         if (!sl) {
612                 DWC_ERROR("Cannot allocate memory for spinlock\n");
613                 return NULL;
614         }
615
616         spin_lock_init(sl);
617 #endif
618         return (dwc_spinlock_t *)sl;
619 }
620
621 void DWC_SPINLOCK_FREE(dwc_spinlock_t *lock)
622 {
623 #if defined(CONFIG_PREEMPT) || defined(CONFIG_SMP)
624         DWC_FREE(lock);
625 #endif
626 }
627
628 void DWC_SPINLOCK(dwc_spinlock_t *lock)
629 {
630 #if defined(CONFIG_PREEMPT) || defined(CONFIG_SMP)
631         spin_lock((spinlock_t *)lock);
632 #endif
633 }
634
635 void DWC_SPINUNLOCK(dwc_spinlock_t *lock)
636 {
637 #if defined(CONFIG_PREEMPT) || defined(CONFIG_SMP)
638         spin_unlock((spinlock_t *)lock);
639 #endif
640 }
641
642 void DWC_SPINLOCK_IRQSAVE(dwc_spinlock_t *lock, dwc_irqflags_t *flags)
643 {
644         dwc_irqflags_t f;
645
646 #if defined(CONFIG_PREEMPT) || defined(CONFIG_SMP)
647         spin_lock_irqsave((spinlock_t *)lock, f);
648 #else
649         local_irq_save(f);
650 #endif
651         *flags = f;
652 }
653
654 void DWC_SPINUNLOCK_IRQRESTORE(dwc_spinlock_t *lock, dwc_irqflags_t flags)
655 {
656 #if defined(CONFIG_PREEMPT) || defined(CONFIG_SMP)
657         spin_unlock_irqrestore((spinlock_t *)lock, flags);
658 #else
659         local_irq_restore(flags);
660 #endif
661 }
662
663 dwc_mutex_t *DWC_MUTEX_ALLOC(void)
664 {
665         struct mutex *m;
666         dwc_mutex_t *mutex = (dwc_mutex_t *)DWC_ALLOC(sizeof(struct mutex));
667
668         if (!mutex) {
669                 DWC_ERROR("Cannot allocate memory for mutex\n");
670                 return NULL;
671         }
672
673         m = (struct mutex *)mutex;
674         mutex_init(m);
675         return mutex;
676 }
677
678 #if (defined(DWC_LINUX) && defined(CONFIG_DEBUG_MUTEXES))
679 #else
680 void DWC_MUTEX_FREE(dwc_mutex_t *mutex)
681 {
682         mutex_destroy((struct mutex *)mutex);
683         DWC_FREE(mutex);
684 }
685 #endif
686
687 void DWC_MUTEX_LOCK(dwc_mutex_t *mutex)
688 {
689         struct mutex *m = (struct mutex *)mutex;
690         mutex_lock(m);
691 }
692
693 int DWC_MUTEX_TRYLOCK(dwc_mutex_t *mutex)
694 {
695         struct mutex *m = (struct mutex *)mutex;
696         return mutex_trylock(m);
697 }
698
699 void DWC_MUTEX_UNLOCK(dwc_mutex_t *mutex)
700 {
701         struct mutex *m = (struct mutex *)mutex;
702         mutex_unlock(m);
703 }
704
705
706 /* Timing */
707
708 void DWC_UDELAY(uint32_t usecs)
709 {
710         udelay(usecs);
711 }
712
713 void DWC_MDELAY(uint32_t msecs)
714 {
715         mdelay(msecs);
716 }
717
718 void DWC_MSLEEP(uint32_t msecs)
719 {
720         msleep(msecs);
721 }
722
723 uint32_t DWC_TIME(void)
724 {
725         return jiffies_to_msecs(jiffies);
726 }
727
728
729 /* Timers */
730
731 struct dwc_timer {
732         struct timer_list *t;
733         char *name;
734         dwc_timer_callback_t cb;
735         void *data;
736         uint8_t scheduled;
737         dwc_spinlock_t *lock;
738 };
739
740 static void timer_callback(unsigned long data)
741 {
742         dwc_timer_t *timer = (dwc_timer_t *)data;
743         dwc_irqflags_t flags;
744
745         DWC_SPINLOCK_IRQSAVE(timer->lock, &flags);
746         timer->scheduled = 0;
747         DWC_SPINUNLOCK_IRQRESTORE(timer->lock, flags);
748         //DWC_DEBUG("Timer %s callback", timer->name);
749         timer->cb(timer->data);
750 }
751
752 dwc_timer_t *DWC_TIMER_ALLOC(char *name, dwc_timer_callback_t cb, void *data)
753 {
754         dwc_timer_t *t = DWC_ALLOC(sizeof(*t));
755
756         if (!t) {
757                 DWC_ERROR("Cannot allocate memory for timer");
758                 return NULL;
759         }
760
761         t->t = DWC_ALLOC(sizeof(*t->t));
762         if (!t->t) {
763                 DWC_ERROR("Cannot allocate memory for timer->t");
764                 goto no_timer;
765         }
766
767         t->name = DWC_STRDUP(name);
768         if (!t->name) {
769                 DWC_ERROR("Cannot allocate memory for timer->name");
770                 goto no_name;
771         }
772
773         t->lock = DWC_SPINLOCK_ALLOC();
774         if (!t->lock) {
775                 DWC_ERROR("Cannot allocate memory for lock");
776                 goto no_lock;
777         }
778
779         t->scheduled = 0;
780         t->t->base = &boot_tvec_bases;
781         t->t->expires = jiffies;
782         setup_timer(t->t, timer_callback, (unsigned long)t);
783
784         t->cb = cb;
785         t->data = data;
786
787         return t;
788
789  no_lock:
790         DWC_FREE(t->name);
791  no_name:
792         DWC_FREE(t->t);
793  no_timer:
794         DWC_FREE(t);
795         return NULL;
796 }
797
798 void DWC_TIMER_FREE(dwc_timer_t *timer)
799 {
800         dwc_irqflags_t flags;
801
802         DWC_SPINLOCK_IRQSAVE(timer->lock, &flags);
803
804         if (timer->scheduled) {
805                 del_timer(timer->t);
806                 timer->scheduled = 0;
807         }
808
809         DWC_SPINUNLOCK_IRQRESTORE(timer->lock, flags);
810         DWC_SPINLOCK_FREE(timer->lock);
811         DWC_FREE(timer->t);
812         DWC_FREE(timer->name);
813         DWC_FREE(timer);
814 }
815
816 void DWC_TIMER_SCHEDULE(dwc_timer_t *timer, uint32_t time)
817 {
818         dwc_irqflags_t flags;
819
820         DWC_SPINLOCK_IRQSAVE(timer->lock, &flags);
821
822         if (!timer->scheduled) {
823                 timer->scheduled = 1;
824                 //DWC_DEBUG("Scheduling timer %s to expire in +%d msec", timer->name, time);
825                 timer->t->expires = jiffies + msecs_to_jiffies(time);
826                 add_timer(timer->t);
827         } else {
828                 //DWC_DEBUG("Modifying timer %s to expire in +%d msec", timer->name, time);
829                 mod_timer(timer->t, jiffies + msecs_to_jiffies(time));
830         }
831
832         DWC_SPINUNLOCK_IRQRESTORE(timer->lock, flags);
833 }
834
835 void DWC_TIMER_CANCEL(dwc_timer_t *timer)
836 {
837         del_timer(timer->t);
838 }
839
840
841 /* Wait Queues */
842
843 struct dwc_waitq {
844         wait_queue_head_t queue;
845         int abort;
846 };
847
848 dwc_waitq_t *DWC_WAITQ_ALLOC(void)
849 {
850         dwc_waitq_t *wq = DWC_ALLOC(sizeof(*wq));
851
852         if (!wq) {
853                 DWC_ERROR("Cannot allocate memory for waitqueue\n");
854                 return NULL;
855         }
856
857         init_waitqueue_head(&wq->queue);
858         wq->abort = 0;
859         return wq;
860 }
861
862 void DWC_WAITQ_FREE(dwc_waitq_t *wq)
863 {
864         DWC_FREE(wq);
865 }
866
867 int32_t DWC_WAITQ_WAIT(dwc_waitq_t *wq, dwc_waitq_condition_t cond, void *data)
868 {
869         int result = wait_event_interruptible(wq->queue,
870                                               cond(data) || wq->abort);
871         if (result == -ERESTARTSYS) {
872                 wq->abort = 0;
873                 return -DWC_E_RESTART;
874         }
875
876         if (wq->abort == 1) {
877                 wq->abort = 0;
878                 return -DWC_E_ABORT;
879         }
880
881         wq->abort = 0;
882
883         if (result == 0) {
884                 return 0;
885         }
886
887         return -DWC_E_UNKNOWN;
888 }
889
890 int32_t DWC_WAITQ_WAIT_TIMEOUT(dwc_waitq_t *wq, dwc_waitq_condition_t cond,
891                                void *data, int32_t msecs)
892 {
893         int32_t tmsecs;
894         int result = wait_event_interruptible_timeout(wq->queue,
895                                                       cond(data) || wq->abort,
896                                                       msecs_to_jiffies(msecs));
897         if (result == -ERESTARTSYS) {
898                 wq->abort = 0;
899                 return -DWC_E_RESTART;
900         }
901
902         if (wq->abort == 1) {
903                 wq->abort = 0;
904                 return -DWC_E_ABORT;
905         }
906
907         wq->abort = 0;
908
909         if (result > 0) {
910                 tmsecs = jiffies_to_msecs(result);
911                 if (!tmsecs) {
912                         return 1;
913                 }
914
915                 return tmsecs;
916         }
917
918         if (result == 0) {
919                 return -DWC_E_TIMEOUT;
920         }
921
922         return -DWC_E_UNKNOWN;
923 }
924
925 void DWC_WAITQ_TRIGGER(dwc_waitq_t *wq)
926 {
927         wq->abort = 0;
928         wake_up_interruptible(&wq->queue);
929 }
930
931 void DWC_WAITQ_ABORT(dwc_waitq_t *wq)
932 {
933         wq->abort = 1;
934         wake_up_interruptible(&wq->queue);
935 }
936
937
938 /* Threading */
939
940 dwc_thread_t *DWC_THREAD_RUN(dwc_thread_function_t func, char *name, void *data)
941 {
942         struct task_struct *thread = kthread_run(func, data, name);
943
944         if (thread == ERR_PTR(-ENOMEM)) {
945                 return NULL;
946         }
947
948         return (dwc_thread_t *)thread;
949 }
950
951 int DWC_THREAD_STOP(dwc_thread_t *thread)
952 {
953         return kthread_stop((struct task_struct *)thread);
954 }
955
956 dwc_bool_t DWC_THREAD_SHOULD_STOP(void)
957 {
958         return kthread_should_stop();
959 }
960
961
962 /* tasklets
963  - run in interrupt context (cannot sleep)
964  - each tasklet runs on a single CPU
965  - different tasklets can be running simultaneously on different CPUs
966  */
967 struct dwc_tasklet {
968         struct tasklet_struct t;
969         dwc_tasklet_callback_t cb;
970         void *data;
971 };
972
973 static void tasklet_callback(unsigned long data)
974 {
975         dwc_tasklet_t *t = (dwc_tasklet_t *)data;
976         t->cb(t->data);
977 }
978
979 dwc_tasklet_t *DWC_TASK_ALLOC(char *name, dwc_tasklet_callback_t cb, void *data)
980 {
981         dwc_tasklet_t *t = DWC_ALLOC(sizeof(*t));
982
983         if (t) {
984                 t->cb = cb;
985                 t->data = data;
986                 tasklet_init(&t->t, tasklet_callback, (unsigned long)t);
987         } else {
988                 DWC_ERROR("Cannot allocate memory for tasklet\n");
989         }
990
991         return t;
992 }
993
994 void DWC_TASK_FREE(dwc_tasklet_t *task)
995 {
996         DWC_FREE(task);
997 }
998
999 void DWC_TASK_SCHEDULE(dwc_tasklet_t *task)
1000 {
1001         tasklet_schedule(&task->t);
1002 }
1003
1004
1005 /* workqueues
1006  - run in process context (can sleep)
1007  */
1008 typedef struct work_container {
1009         dwc_work_callback_t cb;
1010         void *data;
1011         dwc_workq_t *wq;
1012         char *name;
1013
1014 #ifdef DEBUG
1015         DWC_CIRCLEQ_ENTRY(work_container) entry;
1016 #endif
1017         struct delayed_work work;
1018 } work_container_t;
1019
1020 #ifdef DEBUG
1021 DWC_CIRCLEQ_HEAD(work_container_queue, work_container);
1022 #endif
1023
1024 struct dwc_workq {
1025         struct workqueue_struct *wq;
1026         dwc_spinlock_t *lock;
1027         dwc_waitq_t *waitq;
1028         int pending;
1029
1030 #ifdef DEBUG
1031         struct work_container_queue entries;
1032 #endif
1033 };
1034
1035 static void do_work(struct work_struct *work)
1036 {
1037         dwc_irqflags_t flags;
1038         struct delayed_work *dw = container_of(work, struct delayed_work, work);
1039         work_container_t *container = container_of(dw, struct work_container, work);
1040         dwc_workq_t *wq = container->wq;
1041
1042         container->cb(container->data);
1043
1044 #ifdef DEBUG
1045         DWC_CIRCLEQ_REMOVE(&wq->entries, container, entry);
1046 #endif
1047         //DWC_DEBUG("Work done: %s, container=%p", container->name, container);
1048         if (container->name) {
1049                 DWC_FREE(container->name);
1050         }
1051         DWC_FREE(container);
1052
1053         DWC_SPINLOCK_IRQSAVE(wq->lock, &flags);
1054         wq->pending--;
1055         DWC_SPINUNLOCK_IRQRESTORE(wq->lock, flags);
1056         DWC_WAITQ_TRIGGER(wq->waitq);
1057 }
1058
1059 static int work_done(void *data)
1060 {
1061         dwc_workq_t *workq = (dwc_workq_t *)data;
1062         return workq->pending == 0;
1063 }
1064
1065 int DWC_WORKQ_WAIT_WORK_DONE(dwc_workq_t *workq, int timeout)
1066 {
1067         return DWC_WAITQ_WAIT_TIMEOUT(workq->waitq, work_done, workq, timeout);
1068 }
1069
1070 dwc_workq_t *DWC_WORKQ_ALLOC(char *name)
1071 {
1072         dwc_workq_t *wq = DWC_ALLOC(sizeof(*wq));
1073
1074         if (!wq) {
1075                 return NULL;
1076         }
1077
1078         wq->wq = create_singlethread_workqueue(name);
1079         if (!wq->wq) {
1080                 goto no_wq;
1081         }
1082
1083         wq->pending = 0;
1084
1085         wq->lock = DWC_SPINLOCK_ALLOC();
1086         if (!wq->lock) {
1087                 goto no_lock;
1088         }
1089
1090         wq->waitq = DWC_WAITQ_ALLOC();
1091         if (!wq->waitq) {
1092                 goto no_waitq;
1093         }
1094
1095 #ifdef DEBUG
1096         DWC_CIRCLEQ_INIT(&wq->entries);
1097 #endif
1098         return wq;
1099
1100  no_waitq:
1101         DWC_SPINLOCK_FREE(wq->lock);
1102  no_lock:
1103         destroy_workqueue(wq->wq);
1104  no_wq:
1105         DWC_FREE(wq);
1106
1107         return NULL;
1108 }
1109
1110 void DWC_WORKQ_FREE(dwc_workq_t *wq)
1111 {
1112 #ifdef DEBUG
1113         if (wq->pending != 0) {
1114                 struct work_container *wc;
1115                 DWC_ERROR("Destroying work queue with pending work");
1116                 DWC_CIRCLEQ_FOREACH(wc, &wq->entries, entry) {
1117                         DWC_ERROR("Work %s still pending", wc->name);
1118                 }
1119         }
1120 #endif
1121         destroy_workqueue(wq->wq);
1122         DWC_SPINLOCK_FREE(wq->lock);
1123         DWC_WAITQ_FREE(wq->waitq);
1124         DWC_FREE(wq);
1125 }
1126
1127 void DWC_WORKQ_SCHEDULE(dwc_workq_t *wq, dwc_work_callback_t cb, void *data,
1128                         char *format, ...)
1129 {
1130         dwc_irqflags_t flags;
1131         work_container_t *container;
1132         static char name[128];
1133         va_list args;
1134
1135         va_start(args, format);
1136         DWC_VSNPRINTF(name, 128, format, args);
1137         va_end(args);
1138
1139         DWC_SPINLOCK_IRQSAVE(wq->lock, &flags);
1140         wq->pending++;
1141         DWC_SPINUNLOCK_IRQRESTORE(wq->lock, flags);
1142         DWC_WAITQ_TRIGGER(wq->waitq);
1143
1144         container = DWC_ALLOC_ATOMIC(sizeof(*container));
1145         if (!container) {
1146                 DWC_ERROR("Cannot allocate memory for container\n");
1147                 return;
1148         }
1149
1150         container->name = DWC_STRDUP(name);
1151         if (!container->name) {
1152                 DWC_ERROR("Cannot allocate memory for container->name\n");
1153                 DWC_FREE(container);
1154                 return;
1155         }
1156
1157         container->cb = cb;
1158         container->data = data;
1159         container->wq = wq;
1160         //DWC_DEBUG("Queueing work: %s, container=%p", container->name, container);
1161         INIT_WORK(&container->work.work, do_work);
1162
1163 #ifdef DEBUG
1164         DWC_CIRCLEQ_INSERT_TAIL(&wq->entries, container, entry);
1165 #endif
1166         queue_work(wq->wq, &container->work.work);
1167 }
1168
1169 void DWC_WORKQ_SCHEDULE_DELAYED(dwc_workq_t *wq, dwc_work_callback_t cb,
1170                                 void *data, uint32_t time, char *format, ...)
1171 {
1172         dwc_irqflags_t flags;
1173         work_container_t *container;
1174         static char name[128];
1175         va_list args;
1176
1177         va_start(args, format);
1178         DWC_VSNPRINTF(name, 128, format, args);
1179         va_end(args);
1180
1181         DWC_SPINLOCK_IRQSAVE(wq->lock, &flags);
1182         wq->pending++;
1183         DWC_SPINUNLOCK_IRQRESTORE(wq->lock, flags);
1184         DWC_WAITQ_TRIGGER(wq->waitq);
1185
1186         container = DWC_ALLOC_ATOMIC(sizeof(*container));
1187         if (!container) {
1188                 DWC_ERROR("Cannot allocate memory for container\n");
1189                 return;
1190         }
1191
1192         container->name = DWC_STRDUP(name);
1193         if (!container->name) {
1194                 DWC_ERROR("Cannot allocate memory for container->name\n");
1195                 DWC_FREE(container);
1196                 return;
1197         }
1198
1199         container->cb = cb;
1200         container->data = data;
1201         container->wq = wq;
1202         //DWC_DEBUG("Queueing work: %s, container=%p", container->name, container);
1203         INIT_DELAYED_WORK(&container->work, do_work);
1204
1205 #ifdef DEBUG
1206         DWC_CIRCLEQ_INSERT_TAIL(&wq->entries, container, entry);
1207 #endif
1208         queue_delayed_work(wq->wq, &container->work, msecs_to_jiffies(time));
1209 }
1210
1211 int DWC_WORKQ_PENDING(dwc_workq_t *wq)
1212 {
1213         return wq->pending;
1214 }
1215
1216
1217 #ifdef DWC_LIBMODULE
1218
1219 #ifdef DWC_CCLIB
1220 /* CC */
1221 EXPORT_SYMBOL(dwc_cc_if_alloc);
1222 EXPORT_SYMBOL(dwc_cc_if_free);
1223 EXPORT_SYMBOL(dwc_cc_clear);
1224 EXPORT_SYMBOL(dwc_cc_add);
1225 EXPORT_SYMBOL(dwc_cc_remove);
1226 EXPORT_SYMBOL(dwc_cc_change);
1227 EXPORT_SYMBOL(dwc_cc_data_for_save);
1228 EXPORT_SYMBOL(dwc_cc_restore_from_data);
1229 EXPORT_SYMBOL(dwc_cc_match_chid);
1230 EXPORT_SYMBOL(dwc_cc_match_cdid);
1231 EXPORT_SYMBOL(dwc_cc_ck);
1232 EXPORT_SYMBOL(dwc_cc_chid);
1233 EXPORT_SYMBOL(dwc_cc_cdid);
1234 EXPORT_SYMBOL(dwc_cc_name);
1235 #endif  /* DWC_CCLIB */
1236
1237 #ifdef DWC_CRYPTOLIB
1238 # ifndef CONFIG_MACH_IPMATE
1239 /* Modpow */
1240 EXPORT_SYMBOL(dwc_modpow);
1241
1242 /* DH */
1243 EXPORT_SYMBOL(dwc_dh_modpow);
1244 EXPORT_SYMBOL(dwc_dh_derive_keys);
1245 EXPORT_SYMBOL(dwc_dh_pk);
1246 # endif /* CONFIG_MACH_IPMATE */
1247
1248 /* Crypto */
1249 EXPORT_SYMBOL(dwc_wusb_aes_encrypt);
1250 EXPORT_SYMBOL(dwc_wusb_cmf);
1251 EXPORT_SYMBOL(dwc_wusb_prf);
1252 EXPORT_SYMBOL(dwc_wusb_fill_ccm_nonce);
1253 EXPORT_SYMBOL(dwc_wusb_gen_nonce);
1254 EXPORT_SYMBOL(dwc_wusb_gen_key);
1255 EXPORT_SYMBOL(dwc_wusb_gen_mic);
1256 #endif  /* DWC_CRYPTOLIB */
1257
1258 /* Notification */
1259 #ifdef DWC_NOTIFYLIB
1260 EXPORT_SYMBOL(dwc_alloc_notification_manager);
1261 EXPORT_SYMBOL(dwc_free_notification_manager);
1262 EXPORT_SYMBOL(dwc_register_notifier);
1263 EXPORT_SYMBOL(dwc_unregister_notifier);
1264 EXPORT_SYMBOL(dwc_add_observer);
1265 EXPORT_SYMBOL(dwc_remove_observer);
1266 EXPORT_SYMBOL(dwc_notify);
1267 #endif
1268
1269 /* Memory Debugging Routines */
1270 #ifdef DWC_DEBUG_MEMORY
1271 EXPORT_SYMBOL(dwc_alloc_debug);
1272 EXPORT_SYMBOL(dwc_alloc_atomic_debug);
1273 EXPORT_SYMBOL(dwc_free_debug);
1274 EXPORT_SYMBOL(dwc_dma_alloc_debug);
1275 EXPORT_SYMBOL(dwc_dma_free_debug);
1276 #endif
1277
1278 EXPORT_SYMBOL(DWC_MEMSET);
1279 EXPORT_SYMBOL(DWC_MEMCPY);
1280 EXPORT_SYMBOL(DWC_MEMMOVE);
1281 EXPORT_SYMBOL(DWC_MEMCMP);
1282 EXPORT_SYMBOL(DWC_STRNCMP);
1283 EXPORT_SYMBOL(DWC_STRCMP);
1284 EXPORT_SYMBOL(DWC_STRLEN);
1285 EXPORT_SYMBOL(DWC_STRCPY);
1286 EXPORT_SYMBOL(DWC_STRDUP);
1287 EXPORT_SYMBOL(DWC_ATOI);
1288 EXPORT_SYMBOL(DWC_ATOUI);
1289
1290 #ifdef DWC_UTFLIB
1291 EXPORT_SYMBOL(DWC_UTF8_TO_UTF16LE);
1292 #endif  /* DWC_UTFLIB */
1293
1294 EXPORT_SYMBOL(DWC_IN_IRQ);
1295 EXPORT_SYMBOL(DWC_IN_BH);
1296 EXPORT_SYMBOL(DWC_VPRINTF);
1297 EXPORT_SYMBOL(DWC_VSNPRINTF);
1298 EXPORT_SYMBOL(DWC_PRINTF);
1299 EXPORT_SYMBOL(DWC_SPRINTF);
1300 EXPORT_SYMBOL(DWC_SNPRINTF);
1301 EXPORT_SYMBOL(__DWC_WARN);
1302 EXPORT_SYMBOL(__DWC_ERROR);
1303 EXPORT_SYMBOL(DWC_EXCEPTION);
1304
1305 #ifdef DEBUG
1306 EXPORT_SYMBOL(__DWC_DEBUG);
1307 #endif
1308
1309 EXPORT_SYMBOL(__DWC_DMA_ALLOC);
1310 EXPORT_SYMBOL(__DWC_DMA_ALLOC_ATOMIC);
1311 EXPORT_SYMBOL(__DWC_DMA_FREE);
1312 EXPORT_SYMBOL(__DWC_ALLOC);
1313 EXPORT_SYMBOL(__DWC_ALLOC_ATOMIC);
1314 EXPORT_SYMBOL(__DWC_FREE);
1315
1316 #ifdef DWC_CRYPTOLIB
1317 EXPORT_SYMBOL(DWC_RANDOM_BYTES);
1318 EXPORT_SYMBOL(DWC_AES_CBC);
1319 EXPORT_SYMBOL(DWC_SHA256);
1320 EXPORT_SYMBOL(DWC_HMAC_SHA256);
1321 #endif
1322
1323 EXPORT_SYMBOL(DWC_CPU_TO_LE32);
1324 EXPORT_SYMBOL(DWC_CPU_TO_BE32);
1325 EXPORT_SYMBOL(DWC_LE32_TO_CPU);
1326 EXPORT_SYMBOL(DWC_BE32_TO_CPU);
1327 EXPORT_SYMBOL(DWC_CPU_TO_LE16);
1328 EXPORT_SYMBOL(DWC_CPU_TO_BE16);
1329 EXPORT_SYMBOL(DWC_LE16_TO_CPU);
1330 EXPORT_SYMBOL(DWC_BE16_TO_CPU);
1331 EXPORT_SYMBOL(DWC_READ_REG32);
1332 EXPORT_SYMBOL(DWC_WRITE_REG32);
1333 EXPORT_SYMBOL(DWC_MODIFY_REG32);
1334
1335 #if 0
1336 EXPORT_SYMBOL(DWC_READ_REG64);
1337 EXPORT_SYMBOL(DWC_WRITE_REG64);
1338 EXPORT_SYMBOL(DWC_MODIFY_REG64);
1339 #endif
1340
1341 EXPORT_SYMBOL(DWC_SPINLOCK_ALLOC);
1342 EXPORT_SYMBOL(DWC_SPINLOCK_FREE);
1343 EXPORT_SYMBOL(DWC_SPINLOCK);
1344 EXPORT_SYMBOL(DWC_SPINUNLOCK);
1345 EXPORT_SYMBOL(DWC_SPINLOCK_IRQSAVE);
1346 EXPORT_SYMBOL(DWC_SPINUNLOCK_IRQRESTORE);
1347 EXPORT_SYMBOL(DWC_MUTEX_ALLOC);
1348
1349 #if (!defined(DWC_LINUX) || !defined(CONFIG_DEBUG_MUTEXES))
1350 EXPORT_SYMBOL(DWC_MUTEX_FREE);
1351 #endif
1352
1353 EXPORT_SYMBOL(DWC_MUTEX_LOCK);
1354 EXPORT_SYMBOL(DWC_MUTEX_TRYLOCK);
1355 EXPORT_SYMBOL(DWC_MUTEX_UNLOCK);
1356 EXPORT_SYMBOL(DWC_UDELAY);
1357 EXPORT_SYMBOL(DWC_MDELAY);
1358 EXPORT_SYMBOL(DWC_MSLEEP);
1359 EXPORT_SYMBOL(DWC_TIME);
1360 EXPORT_SYMBOL(DWC_TIMER_ALLOC);
1361 EXPORT_SYMBOL(DWC_TIMER_FREE);
1362 EXPORT_SYMBOL(DWC_TIMER_SCHEDULE);
1363 EXPORT_SYMBOL(DWC_TIMER_CANCEL);
1364 EXPORT_SYMBOL(DWC_WAITQ_ALLOC);
1365 EXPORT_SYMBOL(DWC_WAITQ_FREE);
1366 EXPORT_SYMBOL(DWC_WAITQ_WAIT);
1367 EXPORT_SYMBOL(DWC_WAITQ_WAIT_TIMEOUT);
1368 EXPORT_SYMBOL(DWC_WAITQ_TRIGGER);
1369 EXPORT_SYMBOL(DWC_WAITQ_ABORT);
1370 EXPORT_SYMBOL(DWC_THREAD_RUN);
1371 EXPORT_SYMBOL(DWC_THREAD_STOP);
1372 EXPORT_SYMBOL(DWC_THREAD_SHOULD_STOP);
1373 EXPORT_SYMBOL(DWC_TASK_ALLOC);
1374 EXPORT_SYMBOL(DWC_TASK_FREE);
1375 EXPORT_SYMBOL(DWC_TASK_SCHEDULE);
1376 EXPORT_SYMBOL(DWC_WORKQ_WAIT_WORK_DONE);
1377 EXPORT_SYMBOL(DWC_WORKQ_ALLOC);
1378 EXPORT_SYMBOL(DWC_WORKQ_FREE);
1379 EXPORT_SYMBOL(DWC_WORKQ_SCHEDULE);
1380 EXPORT_SYMBOL(DWC_WORKQ_SCHEDULE_DELAYED);
1381 EXPORT_SYMBOL(DWC_WORKQ_PENDING);
1382
1383 static int dwc_common_port_init_module(void)
1384 {
1385         int result = 0;
1386
1387         printk(KERN_DEBUG "Module dwc_common_port init\n" );
1388
1389 #ifdef DWC_DEBUG_MEMORY
1390         result = dwc_memory_debug_start(NULL);
1391         if (result) {
1392                 printk(KERN_ERR
1393                        "dwc_memory_debug_start() failed with error %d\n",
1394                        result);
1395                 return result;
1396         }
1397 #endif
1398
1399 #ifdef DWC_NOTIFYLIB
1400         result = dwc_alloc_notification_manager(NULL, NULL);
1401         if (result) {
1402                 printk(KERN_ERR
1403                        "dwc_alloc_notification_manager() failed with error %d\n",
1404                        result);
1405                 return result;
1406         }
1407 #endif
1408         return result;
1409 }
1410
1411 static void dwc_common_port_exit_module(void)
1412 {
1413         printk(KERN_DEBUG "Module dwc_common_port exit\n" );
1414
1415 #ifdef DWC_NOTIFYLIB
1416         dwc_free_notification_manager();
1417 #endif
1418
1419 #ifdef DWC_DEBUG_MEMORY
1420         dwc_memory_debug_stop();
1421 #endif
1422 }
1423
1424 module_init(dwc_common_port_init_module);
1425 module_exit(dwc_common_port_exit_module);
1426
1427 MODULE_DESCRIPTION("DWC Common Library - Portable version");
1428 MODULE_AUTHOR("Synopsys Inc.");
1429 MODULE_LICENSE ("GPL");
1430
1431 #endif  /* DWC_LIBMODULE */