1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
8 #include <linux/mmc/sdio_func.h>
9 #include <linux/mmc/sdio_ids.h>
10 #include <linux/mmc/host.h>
11 #include <linux/mmc/sdio.h>
12 #include <linux/of_irq.h>
17 #define SDIO_MODALIAS "wilc1000_sdio"
19 static const struct sdio_device_id wilc_sdio_ids
[] = {
20 { SDIO_DEVICE(SDIO_VENDOR_ID_MICROCHIP_WILC
, SDIO_DEVICE_ID_MICROCHIP_WILC1000
) },
23 MODULE_DEVICE_TABLE(sdio
, wilc_sdio_ids
);
25 #define WILC_SDIO_BLOCK_SIZE 512
27 static int wilc_sdio_init(struct wilc
*wilc
, bool resume
);
28 static int wilc_sdio_deinit(struct wilc
*wilc
);
57 static const struct wilc_hif_func wilc_hif_sdio
;
59 static void wilc_sdio_interrupt(struct sdio_func
*func
)
61 sdio_release_host(func
);
62 wilc_handle_isr(sdio_get_drvdata(func
));
63 sdio_claim_host(func
);
66 static int wilc_sdio_cmd52(struct wilc
*wilc
, struct sdio_cmd52
*cmd
)
68 struct sdio_func
*func
= container_of(wilc
->dev
, struct sdio_func
, dev
);
72 sdio_claim_host(func
);
74 func
->num
= cmd
->function
;
75 if (cmd
->read_write
) { /* write */
77 sdio_writeb(func
, cmd
->data
, cmd
->address
, &ret
);
78 data
= sdio_readb(func
, cmd
->address
, &ret
);
81 sdio_writeb(func
, cmd
->data
, cmd
->address
, &ret
);
84 data
= sdio_readb(func
, cmd
->address
, &ret
);
88 sdio_release_host(func
);
91 dev_err(&func
->dev
, "%s..failed, err(%d)\n", __func__
, ret
);
95 static int wilc_sdio_cmd53(struct wilc
*wilc
, struct sdio_cmd53
*cmd
)
97 struct sdio_func
*func
= container_of(wilc
->dev
, struct sdio_func
, dev
);
99 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
100 u8
*buf
= cmd
->buffer
;
102 sdio_claim_host(func
);
104 func
->num
= cmd
->function
;
105 func
->cur_blksize
= cmd
->block_size
;
107 size
= cmd
->count
* cmd
->block_size
;
111 if (cmd
->use_global_buf
) {
112 if (size
> sizeof(u32
)) {
116 buf
= sdio_priv
->cmd53_buf
;
119 if (cmd
->read_write
) { /* write */
120 if (cmd
->use_global_buf
)
121 memcpy(buf
, cmd
->buffer
, size
);
123 ret
= sdio_memcpy_toio(func
, cmd
->address
, buf
, size
);
125 ret
= sdio_memcpy_fromio(func
, buf
, cmd
->address
, size
);
127 if (cmd
->use_global_buf
)
128 memcpy(cmd
->buffer
, buf
, size
);
131 sdio_release_host(func
);
134 dev_err(&func
->dev
, "%s..failed, err(%d)\n", __func__
, ret
);
139 static int wilc_sdio_probe(struct sdio_func
*func
,
140 const struct sdio_device_id
*id
)
142 struct wilc_sdio
*sdio_priv
;
143 struct wilc_vif
*vif
;
148 sdio_priv
= kzalloc(sizeof(*sdio_priv
), GFP_KERNEL
);
152 sdio_priv
->cmd53_buf
= kzalloc(sizeof(u32
), GFP_KERNEL
);
153 if (!sdio_priv
->cmd53_buf
) {
158 ret
= wilc_cfg80211_init(&wilc
, &func
->dev
, WILC_HIF_SDIO
,
163 if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR
)) {
164 struct device_node
*np
= func
->card
->dev
.of_node
;
165 int irq_num
= of_irq_get(np
, 0);
168 wilc
->dev_irq_num
= irq_num
;
169 sdio_priv
->irq_gpio
= true;
173 sdio_set_drvdata(func
, wilc
);
174 wilc
->bus_data
= sdio_priv
;
175 wilc
->dev
= &func
->dev
;
177 wilc
->rtc_clk
= devm_clk_get_optional_enabled(&func
->card
->dev
, "rtc");
178 if (IS_ERR(wilc
->rtc_clk
)) {
179 ret
= PTR_ERR(wilc
->rtc_clk
);
183 wilc_sdio_init(wilc
, false);
185 ret
= wilc_get_chipid(wilc
);
189 ret
= wilc_cfg80211_register(wilc
);
193 ret
= wilc_load_mac_from_nv(wilc
);
195 pr_err("Can not retrieve MAC address from chip\n");
199 wilc_sdio_deinit(wilc
);
201 vif
= wilc_netdev_ifc_init(wilc
, "wlan%d", WILC_STATION_MODE
,
202 NL80211_IFTYPE_STATION
, false);
208 dev_info(&func
->dev
, "Driver Initializing success\n");
212 irq_dispose_mapping(wilc
->dev_irq_num
);
213 wilc_netdev_cleanup(wilc
);
215 kfree(sdio_priv
->cmd53_buf
);
220 static void wilc_sdio_remove(struct sdio_func
*func
)
222 struct wilc
*wilc
= sdio_get_drvdata(func
);
223 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
225 wilc_netdev_cleanup(wilc
);
226 kfree(sdio_priv
->cmd53_buf
);
230 static int wilc_sdio_reset(struct wilc
*wilc
)
232 struct sdio_cmd52 cmd
;
234 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
239 cmd
.address
= SDIO_CCCR_ABORT
;
240 cmd
.data
= WILC_SDIO_CCCR_ABORT_RESET
;
241 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
243 dev_err(&func
->dev
, "Fail cmd 52, reset cmd ...\n");
249 static bool wilc_sdio_is_init(struct wilc
*wilc
)
251 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
253 return sdio_priv
->isinit
;
256 static int wilc_sdio_enable_interrupt(struct wilc
*dev
)
258 struct sdio_func
*func
= container_of(dev
->dev
, struct sdio_func
, dev
);
261 sdio_claim_host(func
);
262 ret
= sdio_claim_irq(func
, wilc_sdio_interrupt
);
263 sdio_release_host(func
);
266 dev_err(&func
->dev
, "can't claim sdio_irq, err(%d)\n", ret
);
272 static void wilc_sdio_disable_interrupt(struct wilc
*dev
)
274 struct sdio_func
*func
= container_of(dev
->dev
, struct sdio_func
, dev
);
277 sdio_claim_host(func
);
278 ret
= sdio_release_irq(func
);
280 dev_err(&func
->dev
, "can't release sdio_irq, err(%d)\n", ret
);
281 sdio_release_host(func
);
284 /********************************************
288 ********************************************/
290 static int wilc_sdio_set_func0_csa_address(struct wilc
*wilc
, u32 adr
)
292 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
293 struct sdio_cmd52 cmd
;
302 cmd
.address
= WILC_SDIO_FBR_CSA_REG
;
304 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
306 dev_err(&func
->dev
, "Failed cmd52, set %04x data...\n",
311 cmd
.address
= WILC_SDIO_FBR_CSA_REG
+ 1;
312 cmd
.data
= (u8
)(adr
>> 8);
313 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
315 dev_err(&func
->dev
, "Failed cmd52, set %04x data...\n",
320 cmd
.address
= WILC_SDIO_FBR_CSA_REG
+ 2;
321 cmd
.data
= (u8
)(adr
>> 16);
322 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
324 dev_err(&func
->dev
, "Failed cmd52, set %04x data...\n",
332 static int wilc_sdio_set_block_size(struct wilc
*wilc
, u8 func_num
,
335 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
336 struct sdio_cmd52 cmd
;
342 cmd
.address
= SDIO_FBR_BASE(func_num
) + SDIO_CCCR_BLKSIZE
;
343 cmd
.data
= (u8
)block_size
;
344 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
346 dev_err(&func
->dev
, "Failed cmd52, set %04x data...\n",
351 cmd
.address
= SDIO_FBR_BASE(func_num
) + SDIO_CCCR_BLKSIZE
+ 1;
352 cmd
.data
= (u8
)(block_size
>> 8);
353 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
355 dev_err(&func
->dev
, "Failed cmd52, set %04x data...\n",
363 /********************************************
367 ********************************************/
368 static int wilc_sdio_write_reg(struct wilc
*wilc
, u32 addr
, u32 data
)
370 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
371 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
376 if (addr
>= 0xf0 && addr
<= 0xff) { /* only vendor specific registers */
377 struct sdio_cmd52 cmd
;
384 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
387 "Failed cmd 52, read reg (%08x) ...\n", addr
);
389 struct sdio_cmd53 cmd
;
392 * set the AHB address
394 ret
= wilc_sdio_set_func0_csa_address(wilc
, addr
);
400 cmd
.address
= WILC_SDIO_FBR_DATA_REG
;
403 cmd
.count
= sizeof(u32
);
404 cmd
.buffer
= (u8
*)&data
;
405 cmd
.use_global_buf
= true;
406 cmd
.block_size
= sdio_priv
->block_size
;
407 ret
= wilc_sdio_cmd53(wilc
, &cmd
);
410 "Failed cmd53, write reg (%08x)...\n", addr
);
416 static int wilc_sdio_write(struct wilc
*wilc
, u32 addr
, u8
*buf
, u32 size
)
418 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
419 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
420 u32 block_size
= sdio_priv
->block_size
;
421 struct sdio_cmd53 cmd
;
422 int nblk
, nleft
, ret
;
430 cmd
.address
= WILC_SDIO_FBR_DATA_REG
;
436 cmd
.address
= WILC_SDIO_F1_DATA_REG
;
439 size
= ALIGN(size
, 4);
440 nblk
= size
/ block_size
;
441 nleft
= size
% block_size
;
443 cmd
.use_global_buf
= false;
449 cmd
.block_size
= block_size
;
451 ret
= wilc_sdio_set_func0_csa_address(wilc
, addr
);
455 ret
= wilc_sdio_cmd53(wilc
, &cmd
);
458 "Failed cmd53 [%x], block send...\n", addr
);
462 addr
+= nblk
* block_size
;
463 buf
+= nblk
* block_size
;
472 cmd
.block_size
= block_size
;
475 ret
= wilc_sdio_set_func0_csa_address(wilc
, addr
);
479 ret
= wilc_sdio_cmd53(wilc
, &cmd
);
482 "Failed cmd53 [%x], bytes send...\n", addr
);
490 static int wilc_sdio_read_reg(struct wilc
*wilc
, u32 addr
, u32
*data
)
492 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
493 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
496 if (addr
>= 0xf0 && addr
<= 0xff) { /* only vendor specific registers */
497 struct sdio_cmd52 cmd
;
503 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
506 "Failed cmd 52, read reg (%08x) ...\n", addr
);
511 struct sdio_cmd53 cmd
;
513 ret
= wilc_sdio_set_func0_csa_address(wilc
, addr
);
519 cmd
.address
= WILC_SDIO_FBR_DATA_REG
;
522 cmd
.count
= sizeof(u32
);
523 cmd
.buffer
= (u8
*)data
;
524 cmd
.use_global_buf
= true;
526 cmd
.block_size
= sdio_priv
->block_size
;
527 ret
= wilc_sdio_cmd53(wilc
, &cmd
);
530 "Failed cmd53, read reg (%08x)...\n", addr
);
539 static int wilc_sdio_read(struct wilc
*wilc
, u32 addr
, u8
*buf
, u32 size
)
541 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
542 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
543 u32 block_size
= sdio_priv
->block_size
;
544 struct sdio_cmd53 cmd
;
545 int nblk
, nleft
, ret
;
553 cmd
.address
= WILC_SDIO_FBR_DATA_REG
;
559 cmd
.address
= WILC_SDIO_F1_DATA_REG
;
562 size
= ALIGN(size
, 4);
563 nblk
= size
/ block_size
;
564 nleft
= size
% block_size
;
566 cmd
.use_global_buf
= false;
572 cmd
.block_size
= block_size
;
574 ret
= wilc_sdio_set_func0_csa_address(wilc
, addr
);
578 ret
= wilc_sdio_cmd53(wilc
, &cmd
);
581 "Failed cmd53 [%x], block read...\n", addr
);
585 addr
+= nblk
* block_size
;
586 buf
+= nblk
* block_size
;
587 } /* if (nblk > 0) */
595 cmd
.block_size
= block_size
;
598 ret
= wilc_sdio_set_func0_csa_address(wilc
, addr
);
602 ret
= wilc_sdio_cmd53(wilc
, &cmd
);
605 "Failed cmd53 [%x], bytes read...\n", addr
);
613 /********************************************
617 ********************************************/
619 static int wilc_sdio_deinit(struct wilc
*wilc
)
621 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
622 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
623 struct sdio_cmd52 cmd
;
630 /* Disable all functions interrupts */
631 cmd
.address
= SDIO_CCCR_IENx
;
633 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
635 dev_err(&func
->dev
, "Failed to disable functions interrupts\n");
639 /* Disable all functions */
640 cmd
.address
= SDIO_CCCR_IOEx
;
642 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
645 "Failed to reset all functions\n");
651 cmd
.address
= SDIO_FBR_BASE(1);
652 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
655 "Failed to read CSA for function 1\n");
659 cmd
.address
= SDIO_FBR_BASE(1);
660 cmd
.data
&= ~SDIO_FBR_ENABLE_CSA
;
661 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
664 "Failed to disable CSA for function 1\n");
668 sdio_priv
->isinit
= false;
672 static int wilc_sdio_init(struct wilc
*wilc
, bool resume
)
674 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
675 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
676 struct sdio_cmd52 cmd
;
680 * function 0 csa enable
685 cmd
.address
= SDIO_FBR_BASE(1);
686 cmd
.data
= SDIO_FBR_ENABLE_CSA
;
687 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
689 dev_err(&func
->dev
, "Fail cmd 52, enable csa...\n");
694 * function 0 block size
696 ret
= wilc_sdio_set_block_size(wilc
, 0, WILC_SDIO_BLOCK_SIZE
);
698 dev_err(&func
->dev
, "Fail cmd 52, set func 0 block size...\n");
701 sdio_priv
->block_size
= WILC_SDIO_BLOCK_SIZE
;
709 cmd
.address
= SDIO_CCCR_IOEx
;
710 cmd
.data
= WILC_SDIO_CCCR_IO_EN_FUNC1
;
711 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
714 "Fail cmd 52, set IOE register...\n");
719 * make sure func 1 is up
724 cmd
.address
= SDIO_CCCR_IORx
;
728 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
731 "Fail cmd 52, get IOR register...\n");
734 if (cmd
.data
== WILC_SDIO_CCCR_IO_EN_FUNC1
)
739 dev_err(&func
->dev
, "Fail func 1 is not ready...\n");
744 * func 1 is ready, set func 1 block size
746 ret
= wilc_sdio_set_block_size(wilc
, 1, WILC_SDIO_BLOCK_SIZE
);
748 dev_err(&func
->dev
, "Fail set func 1 block size...\n");
753 * func 1 interrupt enable
758 cmd
.address
= SDIO_CCCR_IENx
;
759 cmd
.data
= WILC_SDIO_CCCR_IEN_MASTER
| WILC_SDIO_CCCR_IEN_FUNC1
;
760 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
762 dev_err(&func
->dev
, "Fail cmd 52, set IEN register...\n");
766 sdio_priv
->isinit
= true;
770 static int wilc_sdio_read_size(struct wilc
*wilc
, u32
*size
)
773 struct sdio_cmd52 cmd
;
776 * Read DMA count in words
781 cmd
.address
= WILC_SDIO_INTERRUPT_DATA_SZ_REG
;
783 wilc_sdio_cmd52(wilc
, &cmd
);
786 cmd
.address
= WILC_SDIO_INTERRUPT_DATA_SZ_REG
+ 1;
788 wilc_sdio_cmd52(wilc
, &cmd
);
789 tmp
|= (cmd
.data
<< 8);
795 static int wilc_sdio_read_int(struct wilc
*wilc
, u32
*int_status
)
797 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
798 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
801 struct sdio_cmd52 cmd
;
803 wilc_sdio_read_size(wilc
, &tmp
);
808 if (!sdio_priv
->irq_gpio
) {
810 cmd
.address
= WILC_SDIO_EXT_IRQ_FLAG_REG
;
813 cmd
.address
= is_wilc1000(wilc
->chipid
) ?
814 WILC1000_SDIO_IRQ_FLAG_REG
:
815 WILC3000_SDIO_IRQ_FLAG_REG
;
820 wilc_sdio_cmd52(wilc
, &cmd
);
821 irq_flags
= cmd
.data
;
823 if (sdio_priv
->irq_gpio
)
824 irq_flags
&= is_wilc1000(wilc
->chipid
) ? 0x1f : 0x0f;
826 tmp
|= FIELD_PREP(IRG_FLAGS_MASK
, cmd
.data
);
828 if (FIELD_GET(UNHANDLED_IRQ_MASK
, irq_flags
))
829 dev_err(&func
->dev
, "Unexpected interrupt (1) int=%lx\n",
830 FIELD_GET(UNHANDLED_IRQ_MASK
, irq_flags
));
837 static int wilc_sdio_clear_int_ext(struct wilc
*wilc
, u32 val
)
839 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
840 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
844 if (sdio_priv
->irq_gpio
)
845 reg
= val
& (BIT(MAX_NUM_INT
) - 1);
847 if (is_wilc1000(wilc
->chipid
)) {
848 /* select VMM table 0 */
849 if (val
& SEL_VMM_TBL0
)
851 /* select VMM table 1 */
852 if (val
& SEL_VMM_TBL1
)
858 if (sdio_priv
->irq_gpio
&& reg
) {
859 struct sdio_cmd52 cmd
;
864 cmd
.address
= WILC3000_SDIO_IRQ_FLAG_REG
;
867 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
870 "Failed cmd52, set 0xfe data (%d) ...\n",
877 /* select VMM table 0 */
878 if (val
& SEL_VMM_TBL0
)
880 /* select VMM table 1 */
881 if (val
& SEL_VMM_TBL1
)
889 struct sdio_cmd52 cmd
;
894 cmd
.address
= is_wilc1000(wilc
->chipid
) ?
895 WILC1000_SDIO_IRQ_CLEAR_FLAG_REG
:
896 WILC3000_SDIO_VMM_TBL_CTRL_REG
;
899 ret
= wilc_sdio_cmd52(wilc
, &cmd
);
902 "Failed cmd52, set (%02x) data (%d) ...\n",
903 cmd
.address
, __LINE__
);
910 static int wilc_sdio_sync_ext(struct wilc
*wilc
, int nint
)
912 struct sdio_func
*func
= dev_to_sdio_func(wilc
->dev
);
913 struct wilc_sdio
*sdio_priv
= wilc
->bus_data
;
915 if (nint
> MAX_NUM_INT
) {
916 dev_err(&func
->dev
, "Too many interrupts (%d)...\n", nint
);
920 if (sdio_priv
->irq_gpio
) {
925 * interrupt pin mux select
927 ret
= wilc_sdio_read_reg(wilc
, WILC_PIN_MUX_0
, ®
);
929 dev_err(&func
->dev
, "Failed read reg (%08x)...\n",
934 ret
= wilc_sdio_write_reg(wilc
, WILC_PIN_MUX_0
, reg
);
936 dev_err(&func
->dev
, "Failed write reg (%08x)...\n",
944 ret
= wilc_sdio_read_reg(wilc
, WILC_INTR_ENABLE
, ®
);
946 dev_err(&func
->dev
, "Failed read reg (%08x)...\n",
951 for (i
= 0; (i
< 5) && (nint
> 0); i
++, nint
--)
952 reg
|= BIT((27 + i
));
953 ret
= wilc_sdio_write_reg(wilc
, WILC_INTR_ENABLE
, reg
);
955 dev_err(&func
->dev
, "Failed write reg (%08x)...\n",
960 ret
= wilc_sdio_read_reg(wilc
, WILC_INTR2_ENABLE
, ®
);
963 "Failed read reg (%08x)...\n",
968 for (i
= 0; (i
< 3) && (nint
> 0); i
++, nint
--)
971 ret
= wilc_sdio_write_reg(wilc
, WILC_INTR2_ENABLE
, reg
);
974 "Failed write reg (%08x)...\n",
983 /* Global sdio HIF function table */
984 static const struct wilc_hif_func wilc_hif_sdio
= {
985 .hif_init
= wilc_sdio_init
,
986 .hif_deinit
= wilc_sdio_deinit
,
987 .hif_read_reg
= wilc_sdio_read_reg
,
988 .hif_write_reg
= wilc_sdio_write_reg
,
989 .hif_block_rx
= wilc_sdio_read
,
990 .hif_block_tx
= wilc_sdio_write
,
991 .hif_read_int
= wilc_sdio_read_int
,
992 .hif_clear_int_ext
= wilc_sdio_clear_int_ext
,
993 .hif_read_size
= wilc_sdio_read_size
,
994 .hif_block_tx_ext
= wilc_sdio_write
,
995 .hif_block_rx_ext
= wilc_sdio_read
,
996 .hif_sync_ext
= wilc_sdio_sync_ext
,
997 .enable_interrupt
= wilc_sdio_enable_interrupt
,
998 .disable_interrupt
= wilc_sdio_disable_interrupt
,
999 .hif_reset
= wilc_sdio_reset
,
1000 .hif_is_init
= wilc_sdio_is_init
,
1003 static int wilc_sdio_suspend(struct device
*dev
)
1005 struct sdio_func
*func
= dev_to_sdio_func(dev
);
1006 struct wilc
*wilc
= sdio_get_drvdata(func
);
1009 dev_info(dev
, "sdio suspend\n");
1011 if (!wilc
->initialized
)
1014 if (!IS_ERR(wilc
->rtc_clk
))
1015 clk_disable_unprepare(wilc
->rtc_clk
);
1017 ret
= host_sleep_notify(wilc
);
1019 clk_prepare_enable(wilc
->rtc_clk
);
1023 wilc_sdio_disable_interrupt(wilc
);
1025 return sdio_set_host_pm_flags(func
, MMC_PM_KEEP_POWER
);
1028 static int wilc_sdio_resume(struct device
*dev
)
1030 struct sdio_func
*func
= dev_to_sdio_func(dev
);
1031 struct wilc
*wilc
= sdio_get_drvdata(func
);
1033 dev_info(dev
, "sdio resume\n");
1035 if (!wilc
->initialized
)
1038 if (!IS_ERR(wilc
->rtc_clk
))
1039 clk_prepare_enable(wilc
->rtc_clk
);
1041 wilc_sdio_init(wilc
, true);
1042 wilc_sdio_enable_interrupt(wilc
);
1044 return host_wakeup_notify(wilc
);
1047 static const struct of_device_id wilc_of_match
[] = {
1048 { .compatible
= "microchip,wilc1000", },
1051 MODULE_DEVICE_TABLE(of
, wilc_of_match
);
1053 static const struct dev_pm_ops wilc_sdio_pm_ops
= {
1054 .suspend
= wilc_sdio_suspend
,
1055 .resume
= wilc_sdio_resume
,
1058 static struct sdio_driver wilc_sdio_driver
= {
1059 .name
= SDIO_MODALIAS
,
1060 .id_table
= wilc_sdio_ids
,
1061 .probe
= wilc_sdio_probe
,
1062 .remove
= wilc_sdio_remove
,
1064 .pm
= &wilc_sdio_pm_ops
,
1065 .of_match_table
= wilc_of_match
,
1068 module_sdio_driver(wilc_sdio_driver
);
1070 MODULE_DESCRIPTION("Atmel WILC1000 SDIO wireless driver");
1071 MODULE_LICENSE("GPL");