Merge remote-tracking branch 'upstream' into next
[cascardo/linux.git] / drivers / staging / gdm72xx / gdm_sdio.c
1 /*
2  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
3  *
4  * This software is licensed under the terms of the GNU General Public
5  * License version 2, as published by the Free Software Foundation, and
6  * may be copied, distributed, and modified under those terms.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  */
13
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17
18 #include <linux/mmc/core.h>
19 #include <linux/mmc/card.h>
20 #include <linux/mmc/sdio_func.h>
21 #include <linux/mmc/sdio_ids.h>
22
23 #include "gdm_sdio.h"
24 #include "gdm_wimax.h"
25 #include "sdio_boot.h"
26 #include "hci.h"
27
28 #define TYPE_A_HEADER_SIZE      4
29 #define TYPE_A_LOOKAHEAD_SIZE   16
30
31 #define MAX_NR_RX_BUF   4
32
33 #define SDU_TX_BUF_SIZE 2048
34 #define TX_BUF_SIZE             2048
35 #define TX_CHUNK_SIZE   (2048 - TYPE_A_HEADER_SIZE)
36 #define RX_BUF_SIZE             (25*1024)
37
38 #define TX_HZ   2000
39 #define TX_INTERVAL     (1000000/TX_HZ)
40
41 /*#define DEBUG*/
42
43 static int init_sdio(struct sdiowm_dev *sdev);
44 static void release_sdio(struct sdiowm_dev *sdev);
45
46 #ifdef DEBUG
47 static void hexdump(char *title, u8 *data, int len)
48 {
49         int i;
50
51         printk(KERN_DEBUG "%s: length = %d\n", title, len);
52         for (i = 0; i < len; i++) {
53                 printk(KERN_DEBUG "%02x ", data[i]);
54                 if ((i & 0xf) == 0xf)
55                         printk(KERN_DEBUG "\n");
56         }
57         printk(KERN_DEBUG "\n");
58 }
59 #endif
60
61 static struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx)
62 {
63         struct sdio_tx *t = NULL;
64
65         t = kmalloc(sizeof(*t), GFP_ATOMIC);
66         if (t == NULL)
67                 goto out;
68
69         memset(t, 0, sizeof(*t));
70
71         t->buf = kmalloc(TX_BUF_SIZE, GFP_ATOMIC);
72         if (t->buf == NULL)
73                 goto out;
74
75         t->tx_cxt = tx;
76
77         return t;
78 out:
79         if (t) {
80                 kfree(t->buf);
81                 kfree(t);
82         }
83         return NULL;
84 }
85
86 static void free_tx_struct(struct sdio_tx *t)
87 {
88         if (t) {
89                 kfree(t->buf);
90                 kfree(t);
91         }
92 }
93
94 static struct sdio_rx *alloc_rx_struct(struct rx_cxt *rx)
95 {
96         struct sdio_rx *r = NULL;
97
98         r = kmalloc(sizeof(*r), GFP_ATOMIC);
99         if (r == NULL)
100                 goto out;
101
102         memset(r, 0, sizeof(*r));
103
104         r->rx_cxt = rx;
105
106         return r;
107 out:
108         kfree(r);
109         return NULL;
110 }
111
112 static void free_rx_struct(struct sdio_rx *r)
113 {
114         kfree(r);
115 }
116
117 /* Before this function is called, spin lock should be locked. */
118 static struct sdio_tx *get_tx_struct(struct tx_cxt *tx, int *no_spc)
119 {
120         struct sdio_tx *t;
121
122         if (list_empty(&tx->free_list))
123                 return NULL;
124
125         t = list_entry(tx->free_list.prev, struct sdio_tx, list);
126         list_del(&t->list);
127
128         *no_spc = list_empty(&tx->free_list) ? 1 : 0;
129
130         return t;
131 }
132
133 /* Before this function is called, spin lock should be locked. */
134 static void put_tx_struct(struct tx_cxt *tx, struct sdio_tx *t)
135 {
136         list_add_tail(&t->list, &tx->free_list);
137 }
138
139 /* Before this function is called, spin lock should be locked. */
140 static struct sdio_rx *get_rx_struct(struct rx_cxt *rx)
141 {
142         struct sdio_rx *r;
143
144         if (list_empty(&rx->free_list))
145                 return NULL;
146
147         r = list_entry(rx->free_list.prev, struct sdio_rx, list);
148         list_del(&r->list);
149
150         return r;
151 }
152
153 /* Before this function is called, spin lock should be locked. */
154 static void put_rx_struct(struct rx_cxt *rx, struct sdio_rx *r)
155 {
156         list_add_tail(&r->list, &rx->free_list);
157 }
158
159 static int init_sdio(struct sdiowm_dev *sdev)
160 {
161         int ret = 0, i;
162         struct tx_cxt   *tx = &sdev->tx;
163         struct rx_cxt   *rx = &sdev->rx;
164         struct sdio_tx  *t;
165         struct sdio_rx  *r;
166
167         INIT_LIST_HEAD(&tx->free_list);
168         INIT_LIST_HEAD(&tx->sdu_list);
169         INIT_LIST_HEAD(&tx->hci_list);
170
171         spin_lock_init(&tx->lock);
172
173         tx->sdu_buf = kmalloc(SDU_TX_BUF_SIZE, GFP_KERNEL);
174         if (tx->sdu_buf == NULL) {
175                 printk(KERN_ERR "Failed to allocate SDU tx buffer.\n");
176                 goto fail;
177         }
178
179         for (i = 0; i < MAX_NR_SDU_BUF; i++) {
180                 t = alloc_tx_struct(tx);
181                 if (t == NULL) {
182                         ret = -ENOMEM;
183                         goto fail;
184                 }
185                 list_add(&t->list, &tx->free_list);
186         }
187
188         INIT_LIST_HEAD(&rx->free_list);
189         INIT_LIST_HEAD(&rx->req_list);
190
191         spin_lock_init(&rx->lock);
192
193         for (i = 0; i < MAX_NR_RX_BUF; i++) {
194                 r = alloc_rx_struct(rx);
195                 if (r == NULL) {
196                         ret = -ENOMEM;
197                         goto fail;
198                 }
199                 list_add(&r->list, &rx->free_list);
200         }
201
202         rx->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
203         if (rx->rx_buf == NULL) {
204                 printk(KERN_ERR "Failed to allocate rx buffer.\n");
205                 goto fail;
206         }
207
208         return 0;
209
210 fail:
211         release_sdio(sdev);
212         return ret;
213 }
214
215 static void release_sdio(struct sdiowm_dev *sdev)
216 {
217         struct tx_cxt   *tx = &sdev->tx;
218         struct rx_cxt   *rx = &sdev->rx;
219         struct sdio_tx  *t, *t_next;
220         struct sdio_rx  *r, *r_next;
221
222         kfree(tx->sdu_buf);
223
224         list_for_each_entry_safe(t, t_next, &tx->free_list, list) {
225                 list_del(&t->list);
226                 free_tx_struct(t);
227         }
228
229         list_for_each_entry_safe(t, t_next, &tx->sdu_list, list) {
230                 list_del(&t->list);
231                 free_tx_struct(t);
232         }
233
234         list_for_each_entry_safe(t, t_next, &tx->hci_list, list) {
235                 list_del(&t->list);
236                 free_tx_struct(t);
237         }
238
239         kfree(rx->rx_buf);
240
241         list_for_each_entry_safe(r, r_next, &rx->free_list, list) {
242                 list_del(&r->list);
243                 free_rx_struct(r);
244         }
245
246         list_for_each_entry_safe(r, r_next, &rx->req_list, list) {
247                 list_del(&r->list);
248                 free_rx_struct(r);
249         }
250 }
251
252 static void send_sdio_pkt(struct sdio_func *func, u8 *data, int len)
253 {
254         int n, blocks, ret, remain;
255
256         sdio_claim_host(func);
257
258         blocks = len / func->cur_blksize;
259         n = blocks * func->cur_blksize;
260         if (blocks) {
261                 ret = sdio_memcpy_toio(func, 0, data, n);
262                 if (ret < 0) {
263                         if (ret != -ENOMEDIUM)
264                                 printk(KERN_ERR "gdmwms: %s error: ret = %d\n",
265                                         __func__, ret);
266                         goto end_io;
267                 }
268         }
269
270         remain = len - n;
271         remain = (remain + 3) & ~3;
272
273         if (remain) {
274                 ret = sdio_memcpy_toio(func, 0, data + n, remain);
275                 if (ret < 0) {
276                         if (ret != -ENOMEDIUM)
277                                 printk(KERN_ERR "gdmwms: %s error: ret = %d\n",
278                                         __func__, ret);
279                         goto end_io;
280                 }
281         }
282
283 end_io:
284         sdio_release_host(func);
285 }
286
287 static void send_sdu(struct sdio_func *func, struct tx_cxt *tx)
288 {
289         struct list_head *l, *next;
290         struct hci_s *hci;
291         struct sdio_tx *t;
292         int pos, len, i, estlen, aggr_num = 0, aggr_len;
293         u8 *buf;
294         unsigned long flags;
295
296         spin_lock_irqsave(&tx->lock, flags);
297
298         pos = TYPE_A_HEADER_SIZE + HCI_HEADER_SIZE;
299         list_for_each_entry(t, &tx->sdu_list, list) {
300                 estlen = ((t->len + 3) & ~3) + 4;
301                 if ((pos + estlen) > SDU_TX_BUF_SIZE)
302                         break;
303
304                 aggr_num++;
305                 memcpy(tx->sdu_buf + pos, t->buf, t->len);
306                 memset(tx->sdu_buf + pos + t->len, 0, estlen - t->len);
307                 pos += estlen;
308         }
309         aggr_len = pos;
310
311         hci = (struct hci_s *)(tx->sdu_buf + TYPE_A_HEADER_SIZE);
312         hci->cmd_evt = H2B(WIMAX_TX_SDU_AGGR);
313         hci->length = H2B(aggr_len - TYPE_A_HEADER_SIZE - HCI_HEADER_SIZE);
314
315         spin_unlock_irqrestore(&tx->lock, flags);
316
317 #ifdef DEBUG
318         hexdump("sdio_send", tx->sdu_buf + TYPE_A_HEADER_SIZE,
319                 aggr_len - TYPE_A_HEADER_SIZE);
320 #endif
321
322         for (pos = TYPE_A_HEADER_SIZE; pos < aggr_len; pos += TX_CHUNK_SIZE) {
323                 len = aggr_len - pos;
324                 len = len > TX_CHUNK_SIZE ? TX_CHUNK_SIZE : len;
325                 buf = tx->sdu_buf + pos - TYPE_A_HEADER_SIZE;
326
327                 buf[0] = len & 0xff;
328                 buf[1] = (len >> 8) & 0xff;
329                 buf[2] = (len >> 16) & 0xff;
330                 buf[3] = (pos + len) >= aggr_len ? 0 : 1;
331                 send_sdio_pkt(func, buf, len + TYPE_A_HEADER_SIZE);
332         }
333
334         spin_lock_irqsave(&tx->lock, flags);
335
336         for (l = tx->sdu_list.next, i = 0; i < aggr_num; i++, l = next) {
337                 next = l->next;
338                 t = list_entry(l, struct sdio_tx, list);
339                 if (t->callback)
340                         t->callback(t->cb_data);
341
342                 list_del(l);
343                 put_tx_struct(t->tx_cxt, t);
344         }
345
346         do_gettimeofday(&tx->sdu_stamp);
347         spin_unlock_irqrestore(&tx->lock, flags);
348 }
349
350 static void send_hci(struct sdio_func *func, struct tx_cxt *tx,
351                         struct sdio_tx *t)
352 {
353         unsigned long flags;
354
355 #ifdef DEBUG
356         hexdump("sdio_send", t->buf + TYPE_A_HEADER_SIZE,
357                 t->len - TYPE_A_HEADER_SIZE);
358 #endif
359         send_sdio_pkt(func, t->buf, t->len);
360
361         spin_lock_irqsave(&tx->lock, flags);
362         if (t->callback)
363                 t->callback(t->cb_data);
364         free_tx_struct(t);
365         spin_unlock_irqrestore(&tx->lock, flags);
366 }
367
368 static void do_tx(struct work_struct *work)
369 {
370         struct sdiowm_dev *sdev = container_of(work, struct sdiowm_dev, ws);
371         struct sdio_func *func = sdev->func;
372         struct tx_cxt *tx = &sdev->tx;
373         struct sdio_tx *t = NULL;
374         struct timeval now, *before;
375         int is_sdu = 0;
376         long diff;
377         unsigned long flags;
378
379         spin_lock_irqsave(&tx->lock, flags);
380         if (!tx->can_send) {
381                 spin_unlock_irqrestore(&tx->lock, flags);
382                 return;
383         }
384
385         if (!list_empty(&tx->hci_list)) {
386                 t = list_entry(tx->hci_list.next, struct sdio_tx, list);
387                 list_del(&t->list);
388                 is_sdu = 0;
389         } else if (!tx->stop_sdu_tx && !list_empty(&tx->sdu_list)) {
390                 do_gettimeofday(&now);
391                 before = &tx->sdu_stamp;
392
393                 diff = (now.tv_sec - before->tv_sec) * 1000000 +
394                         (now.tv_usec - before->tv_usec);
395                 if (diff >= 0 && diff < TX_INTERVAL) {
396                         schedule_work(&sdev->ws);
397                         spin_unlock_irqrestore(&tx->lock, flags);
398                         return;
399                 }
400                 is_sdu = 1;
401         }
402
403         if (!is_sdu && t == NULL) {
404                 spin_unlock_irqrestore(&tx->lock, flags);
405                 return;
406         }
407
408         tx->can_send = 0;
409
410         spin_unlock_irqrestore(&tx->lock, flags);
411
412         if (is_sdu)
413                 send_sdu(func, tx);
414         else
415                 send_hci(func, tx, t);
416 }
417
418 static int gdm_sdio_send(void *priv_dev, void *data, int len,
419                         void (*cb)(void *data), void *cb_data)
420 {
421         struct sdiowm_dev *sdev = priv_dev;
422         struct tx_cxt *tx = &sdev->tx;
423         struct sdio_tx *t;
424         u8 *pkt = data;
425         int no_spc = 0;
426         u16 cmd_evt;
427         unsigned long flags;
428
429         BUG_ON(len > TX_BUF_SIZE - TYPE_A_HEADER_SIZE);
430
431         spin_lock_irqsave(&tx->lock, flags);
432
433         cmd_evt = (pkt[0] << 8) | pkt[1];
434         if (cmd_evt == WIMAX_TX_SDU) {
435                 t = get_tx_struct(tx, &no_spc);
436                 if (t == NULL) {
437                         /* This case must not happen. */
438                         spin_unlock_irqrestore(&tx->lock, flags);
439                         return -ENOSPC;
440                 }
441                 list_add_tail(&t->list, &tx->sdu_list);
442
443                 memcpy(t->buf, data, len);
444
445                 t->len = len;
446                 t->callback = cb;
447                 t->cb_data = cb_data;
448         } else {
449                 t = alloc_tx_struct(tx);
450                 if (t == NULL) {
451                         spin_unlock_irqrestore(&tx->lock, flags);
452                         return -ENOMEM;
453                 }
454                 list_add_tail(&t->list, &tx->hci_list);
455
456                 t->buf[0] = len & 0xff;
457                 t->buf[1] = (len >> 8) & 0xff;
458                 t->buf[2] = (len >> 16) & 0xff;
459                 t->buf[3] = 2;
460                 memcpy(t->buf + TYPE_A_HEADER_SIZE, data, len);
461
462                 t->len = len + TYPE_A_HEADER_SIZE;
463                 t->callback = cb;
464                 t->cb_data = cb_data;
465         }
466
467         if (tx->can_send)
468                 schedule_work(&sdev->ws);
469
470         spin_unlock_irqrestore(&tx->lock, flags);
471
472         if (no_spc)
473                 return -ENOSPC;
474
475         return 0;
476 }
477
478 /*
479  * Handle the HCI, WIMAX_SDU_TX_FLOW.
480  */
481 static int control_sdu_tx_flow(struct sdiowm_dev *sdev, u8 *hci_data, int len)
482 {
483         struct tx_cxt *tx = &sdev->tx;
484         u16 cmd_evt;
485         unsigned long flags;
486
487         spin_lock_irqsave(&tx->lock, flags);
488
489         cmd_evt = (hci_data[0] << 8) | (hci_data[1]);
490         if (cmd_evt != WIMAX_SDU_TX_FLOW)
491                 goto out;
492
493         if (hci_data[4] == 0) {
494 #ifdef DEBUG
495                 printk(KERN_DEBUG "WIMAX ==> STOP SDU TX\n");
496 #endif
497                 tx->stop_sdu_tx = 1;
498         } else if (hci_data[4] == 1) {
499 #ifdef DEBUG
500                 printk(KERN_DEBUG "WIMAX ==> START SDU TX\n");
501 #endif
502                 tx->stop_sdu_tx = 0;
503                 if (tx->can_send)
504                         schedule_work(&sdev->ws);
505                 /*
506                  * If free buffer for sdu tx doesn't exist, then tx queue
507                  * should not be woken. For this reason, don't pass the command,
508                  * START_SDU_TX.
509                  */
510                 if (list_empty(&tx->free_list))
511                         len = 0;
512         }
513
514 out:
515         spin_unlock_irqrestore(&tx->lock, flags);
516         return len;
517 }
518
519 static void gdm_sdio_irq(struct sdio_func *func)
520 {
521         struct phy_dev *phy_dev = sdio_get_drvdata(func);
522         struct sdiowm_dev *sdev = phy_dev->priv_dev;
523         struct tx_cxt *tx = &sdev->tx;
524         struct rx_cxt *rx = &sdev->rx;
525         struct sdio_rx *r;
526         unsigned long flags;
527         u8 val, hdr[TYPE_A_LOOKAHEAD_SIZE], *buf;
528         u32 len, blocks, n;
529         int ret, remain;
530
531         /* Check interrupt */
532         val = sdio_readb(func, 0x13, &ret);
533         if (val & 0x01)
534                 sdio_writeb(func, 0x01, 0x13, &ret);    /* clear interrupt */
535         else
536                 return;
537
538         ret = sdio_memcpy_fromio(func, hdr, 0x0, TYPE_A_LOOKAHEAD_SIZE);
539         if (ret) {
540                 printk(KERN_ERR "Cannot read from function %d\n", func->num);
541                 goto done;
542         }
543
544         len = (hdr[2] << 16) | (hdr[1] << 8) | hdr[0];
545         if (len > (RX_BUF_SIZE - TYPE_A_HEADER_SIZE)) {
546                 printk(KERN_ERR "Too big Type-A size: %d\n", len);
547                 goto done;
548         }
549
550         if (hdr[3] == 1) {      /* Ack */
551 #ifdef DEBUG
552                 u32 *ack_seq = (u32 *)&hdr[4];
553 #endif
554                 spin_lock_irqsave(&tx->lock, flags);
555                 tx->can_send = 1;
556
557                 if (!list_empty(&tx->sdu_list) || !list_empty(&tx->hci_list))
558                         schedule_work(&sdev->ws);
559                 spin_unlock_irqrestore(&tx->lock, flags);
560 #ifdef DEBUG
561                 printk(KERN_DEBUG "Ack... %0x\n", ntohl(*ack_seq));
562 #endif
563                 goto done;
564         }
565
566         memcpy(rx->rx_buf, hdr + TYPE_A_HEADER_SIZE,
567                         TYPE_A_LOOKAHEAD_SIZE - TYPE_A_HEADER_SIZE);
568
569         buf = rx->rx_buf + TYPE_A_LOOKAHEAD_SIZE - TYPE_A_HEADER_SIZE;
570         remain = len - TYPE_A_LOOKAHEAD_SIZE + TYPE_A_HEADER_SIZE;
571         if (remain <= 0)
572                 goto end_io;
573
574         blocks = remain / func->cur_blksize;
575
576         if (blocks) {
577                 n = blocks * func->cur_blksize;
578                 ret = sdio_memcpy_fromio(func, buf, 0x0, n);
579                 if (ret) {
580                         printk(KERN_ERR "Cannot read from function %d\n",
581                                 func->num);
582                         goto done;
583                 }
584                 buf += n;
585                 remain -= n;
586         }
587
588         if (remain) {
589                 ret = sdio_memcpy_fromio(func, buf, 0x0, remain);
590                 if (ret) {
591                         printk(KERN_ERR "Cannot read from function %d\n",
592                                 func->num);
593                         goto done;
594                 }
595         }
596
597 end_io:
598 #ifdef DEBUG
599         hexdump("sdio_receive", rx->rx_buf, len);
600 #endif
601         len = control_sdu_tx_flow(sdev, rx->rx_buf, len);
602
603         spin_lock_irqsave(&rx->lock, flags);
604
605         if (!list_empty(&rx->req_list)) {
606                 r = list_entry(rx->req_list.next, struct sdio_rx, list);
607                 spin_unlock_irqrestore(&rx->lock, flags);
608                 if (r->callback)
609                         r->callback(r->cb_data, rx->rx_buf, len);
610                 spin_lock_irqsave(&rx->lock, flags);
611                 list_del(&r->list);
612                 put_rx_struct(rx, r);
613         }
614
615         spin_unlock_irqrestore(&rx->lock, flags);
616
617 done:
618         sdio_writeb(func, 0x00, 0x10, &ret);    /* PCRRT */
619         if (!phy_dev->netdev)
620                 register_wimax_device(phy_dev, &func->dev);
621 }
622
623 static int gdm_sdio_receive(void *priv_dev,
624                                 void (*cb)(void *cb_data, void *data, int len),
625                                 void *cb_data)
626 {
627         struct sdiowm_dev *sdev = priv_dev;
628         struct rx_cxt *rx = &sdev->rx;
629         struct sdio_rx *r;
630         unsigned long flags;
631
632         spin_lock_irqsave(&rx->lock, flags);
633         r = get_rx_struct(rx);
634         if (r == NULL) {
635                 spin_unlock_irqrestore(&rx->lock, flags);
636                 return -ENOMEM;
637         }
638
639         r->callback = cb;
640         r->cb_data = cb_data;
641
642         list_add_tail(&r->list, &rx->req_list);
643         spin_unlock_irqrestore(&rx->lock, flags);
644
645         return 0;
646 }
647
648 static int sdio_wimax_probe(struct sdio_func *func,
649                                 const struct sdio_device_id *id)
650 {
651         int ret;
652         struct phy_dev *phy_dev = NULL;
653         struct sdiowm_dev *sdev = NULL;
654
655         printk(KERN_INFO "Found GDM SDIO VID = 0x%04x PID = 0x%04x...\n",
656                         func->vendor, func->device);
657         printk(KERN_INFO "GCT WiMax driver version %s\n", DRIVER_VERSION);
658
659         sdio_claim_host(func);
660         sdio_enable_func(func);
661         sdio_claim_irq(func, gdm_sdio_irq);
662
663         ret = sdio_boot(func);
664         if (ret)
665                 return ret;
666
667         phy_dev = kzalloc(sizeof(*phy_dev), GFP_KERNEL);
668         if (phy_dev == NULL) {
669                 ret = -ENOMEM;
670                 goto out;
671         }
672         sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
673         if (sdev == NULL) {
674                 ret = -ENOMEM;
675                 goto out;
676         }
677
678         phy_dev->priv_dev = (void *)sdev;
679         phy_dev->send_func = gdm_sdio_send;
680         phy_dev->rcv_func = gdm_sdio_receive;
681
682         ret = init_sdio(sdev);
683         if (sdev < 0)
684                 goto out;
685
686         sdev->func = func;
687
688         sdio_writeb(func, 1, 0x14, &ret);       /* Enable interrupt */
689         sdio_release_host(func);
690
691         INIT_WORK(&sdev->ws, do_tx);
692
693         sdio_set_drvdata(func, phy_dev);
694 out:
695         if (ret) {
696                 kfree(phy_dev);
697                 kfree(sdev);
698         }
699
700         return ret;
701 }
702
703 static void sdio_wimax_remove(struct sdio_func *func)
704 {
705         struct phy_dev *phy_dev = sdio_get_drvdata(func);
706         struct sdiowm_dev *sdev = phy_dev->priv_dev;
707
708         if (phy_dev->netdev)
709                 unregister_wimax_device(phy_dev);
710         sdio_claim_host(func);
711         sdio_release_irq(func);
712         sdio_disable_func(func);
713         sdio_release_host(func);
714         release_sdio(sdev);
715
716         kfree(sdev);
717         kfree(phy_dev);
718 }
719
720 static const struct sdio_device_id sdio_wimax_ids[] = {
721         { SDIO_DEVICE(0x0296, 0x5347) },
722         {0}
723 };
724
725 MODULE_DEVICE_TABLE(sdio, sdio_wimax_ids);
726
727 static struct sdio_driver sdio_wimax_driver = {
728         .probe          = sdio_wimax_probe,
729         .remove         = sdio_wimax_remove,
730         .name           = "sdio_wimax",
731         .id_table       = sdio_wimax_ids,
732 };
733
734 static int __init sdio_gdm_wimax_init(void)
735 {
736         return sdio_register_driver(&sdio_wimax_driver);
737 }
738
739 static void __exit sdio_gdm_wimax_exit(void)
740 {
741         sdio_unregister_driver(&sdio_wimax_driver);
742 }
743
744 module_init(sdio_gdm_wimax_init);
745 module_exit(sdio_gdm_wimax_exit);
746
747 MODULE_VERSION(DRIVER_VERSION);
748 MODULE_DESCRIPTION("GCT WiMax SDIO Device Driver");
749 MODULE_AUTHOR("Ethan Park");
750 MODULE_LICENSE("GPL");