2 * linux/drivers/net/wireless/libertas/if_sdio.c
4 * Copyright 2007-2008 Pierre Ossman
6 * Inspired by if_cs.c, Copyright 2007 Holger Schurig
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This hardware has more or less no CMD53 support, so all registers
14 * must be accessed using sdio_readb()/sdio_writeb().
16 * Transfers must be in one transaction or the firmware goes bonkers.
17 * This means that the transfer must either be small enough to do a
18 * byte based transfer or it must be padded to a multiple of the
21 * As SDIO is still new to the kernel, it is unfortunately common with
22 * bugs in the host controllers related to that. One such bug is that
23 * controllers cannot do transfers that aren't a multiple of 4 bytes.
24 * If you don't have time to fix the host controller driver, you can
25 * work around the problem by modifying if_sdio_host_to_card() and
26 * if_sdio_card_to_host() to pad the data.
29 #include <linux/kernel.h>
30 #include <linux/moduleparam.h>
31 #include <linux/firmware.h>
32 #include <linux/netdevice.h>
33 #include <linux/delay.h>
34 #include <linux/mmc/card.h>
35 #include <linux/mmc/sdio_func.h>
36 #include <linux/mmc/sdio_ids.h>
45 /* The if_sdio_remove() callback function is called when
46 * user removes this module from kernel space or ejects
47 * the card from the slot. The driver handles these 2 cases
48 * differently for SD8688 combo chip.
49 * If the user is removing the module, the FUNC_SHUTDOWN
50 * command for SD8688 is sent to the firmware.
51 * If the card is removed, there is no need to send this command.
53 * The variable 'user_rmmod' is used to distinguish these two
54 * scenarios. This flag is initialized as FALSE in case the card
55 * is removed, and will be set to TRUE for module removal when
56 * module_exit function is called.
60 static char *lbs_helper_name
= NULL
;
61 module_param_named(helper_name
, lbs_helper_name
, charp
, 0644);
63 static char *lbs_fw_name
= NULL
;
64 module_param_named(fw_name
, lbs_fw_name
, charp
, 0644);
66 static const struct sdio_device_id if_sdio_ids
[] = {
67 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
,
68 SDIO_DEVICE_ID_MARVELL_LIBERTAS
) },
69 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
,
70 SDIO_DEVICE_ID_MARVELL_8688WLAN
) },
71 { /* end: all zeroes */ },
74 MODULE_DEVICE_TABLE(sdio
, if_sdio_ids
);
76 struct if_sdio_model
{
82 static struct if_sdio_model if_sdio_models
[] = {
85 .model
= IF_SDIO_MODEL_8385
,
86 .helper
= "sd8385_helper.bin",
87 .firmware
= "sd8385.bin",
91 .model
= IF_SDIO_MODEL_8686
,
92 .helper
= "sd8686_helper.bin",
93 .firmware
= "sd8686.bin",
97 .model
= IF_SDIO_MODEL_8688
,
98 .helper
= "sd8688_helper.bin",
99 .firmware
= "sd8688.bin",
103 struct if_sdio_packet
{
104 struct if_sdio_packet
*next
;
106 u8 buffer
[0] __attribute__((aligned(4)));
109 struct if_sdio_card
{
110 struct sdio_func
*func
;
111 struct lbs_private
*priv
;
114 unsigned long ioport
;
115 unsigned int scratch_reg
;
118 const char *firmware
;
123 struct if_sdio_packet
*packets
;
125 struct workqueue_struct
*workqueue
;
126 struct work_struct packet_worker
;
131 /********************************************************************/
133 /********************************************************************/
136 * For SD8385/SD8686, this function reads firmware status after
137 * the image is downloaded, or reads RX packet length when
138 * interrupt (with IF_SDIO_H_INT_UPLD bit set) is received.
139 * For SD8688, this function reads firmware status only.
141 static u16
if_sdio_read_scratch(struct if_sdio_card
*card
, int *err
)
146 scratch
= sdio_readb(card
->func
, card
->scratch_reg
, &ret
);
148 scratch
|= sdio_readb(card
->func
, card
->scratch_reg
+ 1,
160 static u8
if_sdio_read_rx_unit(struct if_sdio_card
*card
)
165 rx_unit
= sdio_readb(card
->func
, IF_SDIO_RX_UNIT
, &ret
);
173 static u16
if_sdio_read_rx_len(struct if_sdio_card
*card
, int *err
)
178 switch (card
->model
) {
179 case IF_SDIO_MODEL_8385
:
180 case IF_SDIO_MODEL_8686
:
181 rx_len
= if_sdio_read_scratch(card
, &ret
);
183 case IF_SDIO_MODEL_8688
:
184 default: /* for newer chipsets */
185 rx_len
= sdio_readb(card
->func
, IF_SDIO_RX_LEN
, &ret
);
187 rx_len
<<= card
->rx_unit
;
189 rx_len
= 0xffff; /* invalid length */
200 static int if_sdio_handle_cmd(struct if_sdio_card
*card
,
201 u8
*buffer
, unsigned size
)
203 struct lbs_private
*priv
= card
->priv
;
208 lbs_deb_enter(LBS_DEB_SDIO
);
210 if (size
> LBS_CMD_BUFFER_SIZE
) {
211 lbs_deb_sdio("response packet too large (%d bytes)\n",
217 spin_lock_irqsave(&priv
->driver_lock
, flags
);
219 i
= (priv
->resp_idx
== 0) ? 1 : 0;
220 BUG_ON(priv
->resp_len
[i
]);
221 priv
->resp_len
[i
] = size
;
222 memcpy(priv
->resp_buf
[i
], buffer
, size
);
223 lbs_notify_command_response(priv
, i
);
225 spin_unlock_irqrestore(&card
->priv
->driver_lock
, flags
);
230 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
234 static int if_sdio_handle_data(struct if_sdio_card
*card
,
235 u8
*buffer
, unsigned size
)
241 lbs_deb_enter(LBS_DEB_SDIO
);
243 if (size
> MRVDRV_ETH_RX_PACKET_BUFFER_SIZE
) {
244 lbs_deb_sdio("response packet too large (%d bytes)\n",
250 skb
= dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE
+ NET_IP_ALIGN
);
256 skb_reserve(skb
, NET_IP_ALIGN
);
258 data
= skb_put(skb
, size
);
260 memcpy(data
, buffer
, size
);
262 lbs_process_rxed_packet(card
->priv
, skb
);
267 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
272 static int if_sdio_handle_event(struct if_sdio_card
*card
,
273 u8
*buffer
, unsigned size
)
278 lbs_deb_enter(LBS_DEB_SDIO
);
280 if (card
->model
== IF_SDIO_MODEL_8385
) {
281 event
= sdio_readb(card
->func
, IF_SDIO_EVENT
, &ret
);
285 /* right shift 3 bits to get the event id */
289 lbs_deb_sdio("event packet too small (%d bytes)\n",
294 event
= buffer
[3] << 24;
295 event
|= buffer
[2] << 16;
296 event
|= buffer
[1] << 8;
297 event
|= buffer
[0] << 0;
300 lbs_queue_event(card
->priv
, event
& 0xFF);
304 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
309 static int if_sdio_card_to_host(struct if_sdio_card
*card
)
313 u16 size
, type
, chunk
;
314 unsigned long timeout
;
316 lbs_deb_enter(LBS_DEB_SDIO
);
318 size
= if_sdio_read_rx_len(card
, &ret
);
323 lbs_deb_sdio("invalid packet size (%d bytes) from firmware\n",
329 timeout
= jiffies
+ HZ
;
331 status
= sdio_readb(card
->func
, IF_SDIO_STATUS
, &ret
);
334 if (status
& IF_SDIO_IO_RDY
)
336 if (time_after(jiffies
, timeout
)) {
344 * The transfer must be in one transaction or the firmware
345 * goes suicidal. There's no way to guarantee that for all
346 * controllers, but we can at least try.
348 chunk
= sdio_align_size(card
->func
, size
);
350 ret
= sdio_readsb(card
->func
, card
->buffer
, card
->ioport
, chunk
);
354 chunk
= card
->buffer
[0] | (card
->buffer
[1] << 8);
355 type
= card
->buffer
[2] | (card
->buffer
[3] << 8);
357 lbs_deb_sdio("packet of type %d and size %d bytes\n",
358 (int)type
, (int)chunk
);
361 lbs_deb_sdio("packet fragment (%d > %d)\n",
362 (int)chunk
, (int)size
);
368 lbs_deb_sdio("packet fragment (%d < %d)\n",
369 (int)chunk
, (int)size
);
374 ret
= if_sdio_handle_cmd(card
, card
->buffer
+ 4, chunk
- 4);
379 ret
= if_sdio_handle_data(card
, card
->buffer
+ 4, chunk
- 4);
384 ret
= if_sdio_handle_event(card
, card
->buffer
+ 4, chunk
- 4);
389 lbs_deb_sdio("invalid type (%d) from firmware\n",
397 lbs_pr_err("problem fetching packet from firmware\n");
399 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
404 static void if_sdio_host_to_card_worker(struct work_struct
*work
)
406 struct if_sdio_card
*card
;
407 struct if_sdio_packet
*packet
;
408 unsigned long timeout
;
413 lbs_deb_enter(LBS_DEB_SDIO
);
415 card
= container_of(work
, struct if_sdio_card
, packet_worker
);
418 spin_lock_irqsave(&card
->lock
, flags
);
419 packet
= card
->packets
;
421 card
->packets
= packet
->next
;
422 spin_unlock_irqrestore(&card
->lock
, flags
);
427 sdio_claim_host(card
->func
);
429 timeout
= jiffies
+ HZ
;
431 status
= sdio_readb(card
->func
, IF_SDIO_STATUS
, &ret
);
434 if (status
& IF_SDIO_IO_RDY
)
436 if (time_after(jiffies
, timeout
)) {
443 ret
= sdio_writesb(card
->func
, card
->ioport
,
444 packet
->buffer
, packet
->nb
);
448 sdio_release_host(card
->func
);
453 lbs_deb_leave(LBS_DEB_SDIO
);
456 /********************************************************************/
458 /********************************************************************/
460 static int if_sdio_prog_helper(struct if_sdio_card
*card
)
464 const struct firmware
*fw
;
465 unsigned long timeout
;
471 lbs_deb_enter(LBS_DEB_SDIO
);
473 ret
= request_firmware(&fw
, card
->helper
, &card
->func
->dev
);
475 lbs_pr_err("can't load helper firmware\n");
479 chunk_buffer
= kzalloc(64, GFP_KERNEL
);
485 sdio_claim_host(card
->func
);
487 ret
= sdio_set_block_size(card
->func
, 32);
495 timeout
= jiffies
+ HZ
;
497 status
= sdio_readb(card
->func
, IF_SDIO_STATUS
, &ret
);
500 if ((status
& IF_SDIO_IO_RDY
) &&
501 (status
& IF_SDIO_DL_RDY
))
503 if (time_after(jiffies
, timeout
)) {
510 chunk_size
= min(size
, (size_t)60);
512 *((__le32
*)chunk_buffer
) = cpu_to_le32(chunk_size
);
513 memcpy(chunk_buffer
+ 4, firmware
, chunk_size
);
515 lbs_deb_sdio("sending %d bytes chunk\n", chunk_size);
517 ret
= sdio_writesb(card
->func
, card
->ioport
,
522 firmware
+= chunk_size
;
526 /* an empty block marks the end of the transfer */
527 memset(chunk_buffer
, 0, 4);
528 ret
= sdio_writesb(card
->func
, card
->ioport
, chunk_buffer
, 64);
532 lbs_deb_sdio("waiting for helper to boot...\n");
534 /* wait for the helper to boot by looking at the size register */
535 timeout
= jiffies
+ HZ
;
539 req_size
= sdio_readb(card
->func
, IF_SDIO_RD_BASE
, &ret
);
543 req_size
|= sdio_readb(card
->func
, IF_SDIO_RD_BASE
+ 1, &ret
) << 8;
550 if (time_after(jiffies
, timeout
)) {
561 sdio_release_host(card
->func
);
564 release_firmware(fw
);
568 lbs_pr_err("failed to load helper firmware\n");
570 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
575 static int if_sdio_prog_real(struct if_sdio_card
*card
)
579 const struct firmware
*fw
;
580 unsigned long timeout
;
584 size_t size
, req_size
;
586 lbs_deb_enter(LBS_DEB_SDIO
);
588 ret
= request_firmware(&fw
, card
->firmware
, &card
->func
->dev
);
590 lbs_pr_err("can't load firmware\n");
594 chunk_buffer
= kzalloc(512, GFP_KERNEL
);
600 sdio_claim_host(card
->func
);
602 ret
= sdio_set_block_size(card
->func
, 32);
610 timeout
= jiffies
+ HZ
;
612 status
= sdio_readb(card
->func
, IF_SDIO_STATUS
, &ret
);
615 if ((status
& IF_SDIO_IO_RDY
) &&
616 (status
& IF_SDIO_DL_RDY
))
618 if (time_after(jiffies
, timeout
)) {
625 req_size
= sdio_readb(card
->func
, IF_SDIO_RD_BASE
, &ret
);
629 req_size
|= sdio_readb(card
->func
, IF_SDIO_RD_BASE
+ 1, &ret
) << 8;
633 lbs_deb_sdio("firmware wants %d bytes\n", (int)req_size);
636 lbs_deb_sdio("firmware helper gave up early\n");
641 if (req_size
& 0x01) {
642 lbs_deb_sdio("firmware helper signalled error\n");
651 chunk_size
= min(req_size
, (size_t)512);
653 memcpy(chunk_buffer
, firmware
, chunk_size
);
655 lbs_deb_sdio("sending %d bytes (%d bytes) chunk\n",
656 chunk_size, (chunk_size + 31) / 32 * 32);
658 ret
= sdio_writesb(card
->func
, card
->ioport
,
659 chunk_buffer
, roundup(chunk_size
, 32));
663 firmware
+= chunk_size
;
665 req_size
-= chunk_size
;
671 lbs_deb_sdio("waiting for firmware to boot...\n");
673 /* wait for the firmware to boot */
674 timeout
= jiffies
+ HZ
;
678 scratch
= if_sdio_read_scratch(card
, &ret
);
682 if (scratch
== IF_SDIO_FIRMWARE_OK
)
685 if (time_after(jiffies
, timeout
)) {
696 sdio_release_host(card
->func
);
699 release_firmware(fw
);
703 lbs_pr_err("failed to load firmware\n");
705 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
710 static int if_sdio_prog_firmware(struct if_sdio_card
*card
)
715 lbs_deb_enter(LBS_DEB_SDIO
);
717 sdio_claim_host(card
->func
);
718 scratch
= if_sdio_read_scratch(card
, &ret
);
719 sdio_release_host(card
->func
);
724 lbs_deb_sdio("firmware status = %#x\n", scratch
);
726 if (scratch
== IF_SDIO_FIRMWARE_OK
) {
727 lbs_deb_sdio("firmware already loaded\n");
731 ret
= if_sdio_prog_helper(card
);
735 ret
= if_sdio_prog_real(card
);
740 sdio_claim_host(card
->func
);
741 sdio_set_block_size(card
->func
, IF_SDIO_BLOCK_SIZE
);
742 sdio_release_host(card
->func
);
746 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
751 /*******************************************************************/
752 /* Libertas callbacks */
753 /*******************************************************************/
755 static int if_sdio_host_to_card(struct lbs_private
*priv
,
756 u8 type
, u8
*buf
, u16 nb
)
759 struct if_sdio_card
*card
;
760 struct if_sdio_packet
*packet
, *cur
;
764 lbs_deb_enter_args(LBS_DEB_SDIO
, "type %d, bytes %d", type
, nb
);
768 if (nb
> (65536 - sizeof(struct if_sdio_packet
) - 4)) {
774 * The transfer must be in one transaction or the firmware
775 * goes suicidal. There's no way to guarantee that for all
776 * controllers, but we can at least try.
778 size
= sdio_align_size(card
->func
, nb
+ 4);
780 packet
= kzalloc(sizeof(struct if_sdio_packet
) + size
,
791 * SDIO specific header.
793 packet
->buffer
[0] = (nb
+ 4) & 0xff;
794 packet
->buffer
[1] = ((nb
+ 4) >> 8) & 0xff;
795 packet
->buffer
[2] = type
;
796 packet
->buffer
[3] = 0;
798 memcpy(packet
->buffer
+ 4, buf
, nb
);
800 spin_lock_irqsave(&card
->lock
, flags
);
803 card
->packets
= packet
;
813 priv
->dnld_sent
= DNLD_CMD_SENT
;
816 priv
->dnld_sent
= DNLD_DATA_SENT
;
819 lbs_deb_sdio("unknown packet type %d\n", (int)type
);
822 spin_unlock_irqrestore(&card
->lock
, flags
);
824 queue_work(card
->workqueue
, &card
->packet_worker
);
829 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
834 /*******************************************************************/
836 /*******************************************************************/
838 static void if_sdio_interrupt(struct sdio_func
*func
)
841 struct if_sdio_card
*card
;
844 lbs_deb_enter(LBS_DEB_SDIO
);
846 card
= sdio_get_drvdata(func
);
848 cause
= sdio_readb(card
->func
, IF_SDIO_H_INT_STATUS
, &ret
);
852 lbs_deb_sdio("interrupt: 0x%X\n", (unsigned)cause
);
854 sdio_writeb(card
->func
, ~cause
, IF_SDIO_H_INT_STATUS
, &ret
);
859 * Ignore the define name, this really means the card has
860 * successfully received the command.
862 if (cause
& IF_SDIO_H_INT_DNLD
)
863 lbs_host_to_card_done(card
->priv
);
866 if (cause
& IF_SDIO_H_INT_UPLD
) {
867 ret
= if_sdio_card_to_host(card
);
875 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
878 static int if_sdio_probe(struct sdio_func
*func
,
879 const struct sdio_device_id
*id
)
881 struct if_sdio_card
*card
;
882 struct lbs_private
*priv
;
885 struct if_sdio_packet
*packet
;
887 lbs_deb_enter(LBS_DEB_SDIO
);
889 for (i
= 0;i
< func
->card
->num_info
;i
++) {
890 if (sscanf(func
->card
->info
[i
],
891 "802.11 SDIO ID: %x", &model
) == 1)
893 if (sscanf(func
->card
->info
[i
],
894 "ID: %x", &model
) == 1)
896 if (!strcmp(func
->card
->info
[i
], "IBIS Wireless SDIO Card")) {
897 model
= IF_SDIO_MODEL_8385
;
902 if (i
== func
->card
->num_info
) {
903 lbs_pr_err("unable to identify card model\n");
907 card
= kzalloc(sizeof(struct if_sdio_card
), GFP_KERNEL
);
914 switch (card
->model
) {
915 case IF_SDIO_MODEL_8385
:
916 card
->scratch_reg
= IF_SDIO_SCRATCH_OLD
;
918 case IF_SDIO_MODEL_8686
:
919 card
->scratch_reg
= IF_SDIO_SCRATCH
;
921 case IF_SDIO_MODEL_8688
:
922 default: /* for newer chipsets */
923 card
->scratch_reg
= IF_SDIO_FW_STATUS
;
927 spin_lock_init(&card
->lock
);
928 card
->workqueue
= create_workqueue("libertas_sdio");
929 INIT_WORK(&card
->packet_worker
, if_sdio_host_to_card_worker
);
931 for (i
= 0;i
< ARRAY_SIZE(if_sdio_models
);i
++) {
932 if (card
->model
== if_sdio_models
[i
].model
)
936 if (i
== ARRAY_SIZE(if_sdio_models
)) {
937 lbs_pr_err("unkown card model 0x%x\n", card
->model
);
942 card
->helper
= if_sdio_models
[i
].helper
;
943 card
->firmware
= if_sdio_models
[i
].firmware
;
945 if (lbs_helper_name
) {
946 lbs_deb_sdio("overriding helper firmware: %s\n",
948 card
->helper
= lbs_helper_name
;
952 lbs_deb_sdio("overriding firmware: %s\n", lbs_fw_name
);
953 card
->firmware
= lbs_fw_name
;
956 sdio_claim_host(func
);
958 ret
= sdio_enable_func(func
);
962 ret
= sdio_claim_irq(func
, if_sdio_interrupt
);
966 card
->ioport
= sdio_readb(func
, IF_SDIO_IOPORT
, &ret
);
970 card
->ioport
|= sdio_readb(func
, IF_SDIO_IOPORT
+ 1, &ret
) << 8;
974 card
->ioport
|= sdio_readb(func
, IF_SDIO_IOPORT
+ 2, &ret
) << 16;
978 sdio_release_host(func
);
980 sdio_set_drvdata(func
, card
);
982 lbs_deb_sdio("class = 0x%X, vendor = 0x%X, "
983 "device = 0x%X, model = 0x%X, ioport = 0x%X\n",
984 func
->class, func
->vendor
, func
->device
,
985 model
, (unsigned)card
->ioport
);
987 ret
= if_sdio_prog_firmware(card
);
991 priv
= lbs_add_card(card
, &func
->dev
);
1000 priv
->hw_host_to_card
= if_sdio_host_to_card
;
1004 sdio_claim_host(func
);
1007 * Get rx_unit if the chip is SD8688 or newer.
1008 * SD8385 & SD8686 do not have rx_unit.
1010 if ((card
->model
!= IF_SDIO_MODEL_8385
)
1011 && (card
->model
!= IF_SDIO_MODEL_8686
))
1012 card
->rx_unit
= if_sdio_read_rx_unit(card
);
1017 * Enable interrupts now that everything is set up
1019 sdio_writeb(func
, 0x0f, IF_SDIO_H_INT_MASK
, &ret
);
1020 sdio_release_host(func
);
1025 * FUNC_INIT is required for SD8688 WLAN/BT multiple functions
1027 if (card
->model
== IF_SDIO_MODEL_8688
) {
1028 struct cmd_header cmd
;
1030 memset(&cmd
, 0, sizeof(cmd
));
1032 lbs_deb_sdio("send function INIT command\n");
1033 if (__lbs_cmd(priv
, CMD_FUNC_INIT
, &cmd
, sizeof(cmd
),
1034 lbs_cmd_copyback
, (unsigned long) &cmd
))
1035 lbs_pr_alert("CMD_FUNC_INIT cmd failed\n");
1038 ret
= lbs_start_card(priv
);
1040 goto err_activate_card
;
1043 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
1048 flush_workqueue(card
->workqueue
);
1049 lbs_remove_card(priv
);
1051 sdio_claim_host(func
);
1053 sdio_release_irq(func
);
1055 sdio_disable_func(func
);
1057 sdio_release_host(func
);
1059 destroy_workqueue(card
->workqueue
);
1060 while (card
->packets
) {
1061 packet
= card
->packets
;
1062 card
->packets
= card
->packets
->next
;
1071 static void if_sdio_remove(struct sdio_func
*func
)
1073 struct if_sdio_card
*card
;
1074 struct if_sdio_packet
*packet
;
1076 lbs_deb_enter(LBS_DEB_SDIO
);
1078 card
= sdio_get_drvdata(func
);
1080 if (user_rmmod
&& (card
->model
== IF_SDIO_MODEL_8688
)) {
1082 * FUNC_SHUTDOWN is required for SD8688 WLAN/BT
1083 * multiple functions
1085 struct cmd_header cmd
;
1087 memset(&cmd
, 0, sizeof(cmd
));
1089 lbs_deb_sdio("send function SHUTDOWN command\n");
1090 if (__lbs_cmd(card
->priv
, CMD_FUNC_SHUTDOWN
,
1091 &cmd
, sizeof(cmd
), lbs_cmd_copyback
,
1092 (unsigned long) &cmd
))
1093 lbs_pr_alert("CMD_FUNC_SHUTDOWN cmd failed\n");
1097 lbs_deb_sdio("call remove card\n");
1098 lbs_stop_card(card
->priv
);
1099 lbs_remove_card(card
->priv
);
1100 card
->priv
->surpriseremoved
= 1;
1102 flush_workqueue(card
->workqueue
);
1103 destroy_workqueue(card
->workqueue
);
1105 sdio_claim_host(func
);
1106 sdio_release_irq(func
);
1107 sdio_disable_func(func
);
1108 sdio_release_host(func
);
1110 while (card
->packets
) {
1111 packet
= card
->packets
;
1112 card
->packets
= card
->packets
->next
;
1118 lbs_deb_leave(LBS_DEB_SDIO
);
1121 static struct sdio_driver if_sdio_driver
= {
1122 .name
= "libertas_sdio",
1123 .id_table
= if_sdio_ids
,
1124 .probe
= if_sdio_probe
,
1125 .remove
= if_sdio_remove
,
1128 /*******************************************************************/
1129 /* Module functions */
1130 /*******************************************************************/
1132 static int __init
if_sdio_init_module(void)
1136 lbs_deb_enter(LBS_DEB_SDIO
);
1138 printk(KERN_INFO
"libertas_sdio: Libertas SDIO driver\n");
1139 printk(KERN_INFO
"libertas_sdio: Copyright Pierre Ossman\n");
1141 ret
= sdio_register_driver(&if_sdio_driver
);
1143 /* Clear the flag in case user removes the card. */
1146 lbs_deb_leave_args(LBS_DEB_SDIO
, "ret %d", ret
);
1151 static void __exit
if_sdio_exit_module(void)
1153 lbs_deb_enter(LBS_DEB_SDIO
);
1155 /* Set the flag as user is removing this module. */
1158 sdio_unregister_driver(&if_sdio_driver
);
1160 lbs_deb_leave(LBS_DEB_SDIO
);
1163 module_init(if_sdio_init_module
);
1164 module_exit(if_sdio_exit_module
);
1166 MODULE_DESCRIPTION("Libertas SDIO WLAN Driver");
1167 MODULE_AUTHOR("Pierre Ossman");
1168 MODULE_LICENSE("GPL");