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