blob: 7a2325b2a564502a29b541476d5a89f25ab2c141 [file] [log] [blame]
Arend van Spriel5b435de2011-10-05 13:19:03 +02001/*
2 * Copyright (c) 2010 Broadcom Corporation
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16#include <linux/types.h>
17#include <linux/netdevice.h>
18#include <linux/mmc/sdio.h>
19#include <linux/mmc/core.h>
20#include <linux/mmc/sdio_func.h>
21#include <linux/mmc/sdio_ids.h>
22#include <linux/mmc/card.h>
23#include <linux/suspend.h>
24#include <linux/errno.h>
25#include <linux/sched.h> /* request_irq() */
Stephen Rothwellb7a57e72011-10-12 21:35:07 +020026#include <linux/module.h>
Arend van Spriel5b435de2011-10-05 13:19:03 +020027#include <net/cfg80211.h>
28
29#include <defs.h>
30#include <brcm_hw_ids.h>
31#include <brcmu_utils.h>
32#include <brcmu_wifi.h>
33#include "sdio_host.h"
34#include "dhd.h"
35#include "dhd_dbg.h"
36#include "wl_cfg80211.h"
37
38#define SDIO_VENDOR_ID_BROADCOM 0x02d0
39
40#define DMA_ALIGN_MASK 0x03
41
42#define SDIO_DEVICE_ID_BROADCOM_4329 0x4329
43
44#define SDIO_FUNC1_BLOCKSIZE 64
45#define SDIO_FUNC2_BLOCKSIZE 512
46
47/* devices we support, null terminated */
48static const struct sdio_device_id brcmf_sdmmc_ids[] = {
49 {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)},
50 { /* end: all zeroes */ },
51};
52MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
53
54static bool
55brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev)
56{
57 bool is_err = false;
58#ifdef CONFIG_PM_SLEEP
59 is_err = atomic_read(&sdiodev->suspend);
60#endif
61 return is_err;
62}
63
64static void
65brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev, wait_queue_head_t *wq)
66{
67#ifdef CONFIG_PM_SLEEP
68 int retry = 0;
69 while (atomic_read(&sdiodev->suspend) && retry++ != 30)
70 wait_event_timeout(*wq, false, HZ/100);
71#endif
72}
73
74static inline int brcmf_sdioh_f0_write_byte(struct brcmf_sdio_dev *sdiodev,
75 uint regaddr, u8 *byte)
76{
77 struct sdio_func *sdfunc = sdiodev->func[0];
78 int err_ret;
79
80 /*
81 * Can only directly write to some F0 registers.
82 * Handle F2 enable/disable and Abort command
83 * as a special case.
84 */
85 if (regaddr == SDIO_CCCR_IOEx) {
86 sdfunc = sdiodev->func[2];
87 if (sdfunc) {
88 sdio_claim_host(sdfunc);
89 if (*byte & SDIO_FUNC_ENABLE_2) {
90 /* Enable Function 2 */
91 err_ret = sdio_enable_func(sdfunc);
92 if (err_ret)
93 brcmf_dbg(ERROR,
94 "enable F2 failed:%d\n",
95 err_ret);
96 } else {
97 /* Disable Function 2 */
98 err_ret = sdio_disable_func(sdfunc);
99 if (err_ret)
100 brcmf_dbg(ERROR,
101 "Disable F2 failed:%d\n",
102 err_ret);
103 }
104 sdio_release_host(sdfunc);
105 }
106 } else if (regaddr == SDIO_CCCR_ABORT) {
107 sdio_claim_host(sdfunc);
108 sdio_writeb(sdfunc, *byte, regaddr, &err_ret);
109 sdio_release_host(sdfunc);
110 } else if (regaddr < 0xF0) {
111 brcmf_dbg(ERROR, "F0 Wr:0x%02x: write disallowed\n", regaddr);
112 err_ret = -EPERM;
113 } else {
114 sdio_claim_host(sdfunc);
115 sdio_f0_writeb(sdfunc, *byte, regaddr, &err_ret);
116 sdio_release_host(sdfunc);
117 }
118
119 return err_ret;
120}
121
122int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func,
123 uint regaddr, u8 *byte)
124{
125 int err_ret;
126
127 brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x\n", rw, func, regaddr);
128
129 brcmf_pm_resume_wait(sdiodev, &sdiodev->request_byte_wait);
130 if (brcmf_pm_resume_error(sdiodev))
131 return -EIO;
132
133 if (rw && func == 0) {
134 /* handle F0 separately */
135 err_ret = brcmf_sdioh_f0_write_byte(sdiodev, regaddr, byte);
136 } else {
137 sdio_claim_host(sdiodev->func[func]);
138 if (rw) /* CMD52 Write */
139 sdio_writeb(sdiodev->func[func], *byte, regaddr,
140 &err_ret);
141 else if (func == 0) {
142 *byte = sdio_f0_readb(sdiodev->func[func], regaddr,
143 &err_ret);
144 } else {
145 *byte = sdio_readb(sdiodev->func[func], regaddr,
146 &err_ret);
147 }
148 sdio_release_host(sdiodev->func[func]);
149 }
150
151 if (err_ret)
152 brcmf_dbg(ERROR, "Failed to %s byte F%d:@0x%05x=%02x, Err: %d\n",
153 rw ? "write" : "read", func, regaddr, *byte, err_ret);
154
155 return err_ret;
156}
157
158int brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev,
159 uint rw, uint func, uint addr, u32 *word,
160 uint nbytes)
161{
162 int err_ret = -EIO;
163
164 if (func == 0) {
165 brcmf_dbg(ERROR, "Only CMD52 allowed to F0\n");
166 return -EINVAL;
167 }
168
169 brcmf_dbg(INFO, "rw=%d, func=%d, addr=0x%05x, nbytes=%d\n",
170 rw, func, addr, nbytes);
171
172 brcmf_pm_resume_wait(sdiodev, &sdiodev->request_word_wait);
173 if (brcmf_pm_resume_error(sdiodev))
174 return -EIO;
175 /* Claim host controller */
176 sdio_claim_host(sdiodev->func[func]);
177
178 if (rw) { /* CMD52 Write */
179 if (nbytes == 4)
180 sdio_writel(sdiodev->func[func], *word, addr,
181 &err_ret);
182 else if (nbytes == 2)
183 sdio_writew(sdiodev->func[func], (*word & 0xFFFF),
184 addr, &err_ret);
185 else
186 brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes);
187 } else { /* CMD52 Read */
188 if (nbytes == 4)
189 *word = sdio_readl(sdiodev->func[func], addr, &err_ret);
190 else if (nbytes == 2)
191 *word = sdio_readw(sdiodev->func[func], addr,
192 &err_ret) & 0xFFFF;
193 else
194 brcmf_dbg(ERROR, "Invalid nbytes: %d\n", nbytes);
195 }
196
197 /* Release host controller */
198 sdio_release_host(sdiodev->func[func]);
199
200 if (err_ret)
201 brcmf_dbg(ERROR, "Failed to %s word, Err: 0x%08x\n",
202 rw ? "write" : "read", err_ret);
203
204 return err_ret;
205}
206
Arend van Spriel5adfeb62011-11-22 17:21:38 -0800207/* precondition: host controller is claimed */
208static int
209brcmf_sdioh_request_data(struct brcmf_sdio_dev *sdiodev, uint write, bool fifo,
210 uint func, uint addr, struct sk_buff *pkt, uint pktlen)
211{
212 int err_ret = 0;
213
214 if ((write) && (!fifo)) {
215 err_ret = sdio_memcpy_toio(sdiodev->func[func], addr,
216 ((u8 *) (pkt->data)), pktlen);
217 } else if (write) {
218 err_ret = sdio_memcpy_toio(sdiodev->func[func], addr,
219 ((u8 *) (pkt->data)), pktlen);
220 } else if (fifo) {
221 err_ret = sdio_readsb(sdiodev->func[func],
222 ((u8 *) (pkt->data)), addr, pktlen);
223 } else {
224 err_ret = sdio_memcpy_fromio(sdiodev->func[func],
225 ((u8 *) (pkt->data)),
226 addr, pktlen);
227 }
228
229 return err_ret;
230}
231
Arend van Spriela52dd172011-11-22 17:21:45 -0800232/*
233 * This function takes a queue of packets. The packets on the queue
234 * are assumed to be properly aligned by the caller.
235 */
Arend van Spriel5adfeb62011-11-22 17:21:38 -0800236int
237brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc,
238 uint write, uint func, uint addr,
239 struct sk_buff_head *pktq)
240{
241 bool fifo = (fix_inc == SDIOH_DATA_FIX);
242 u32 SGCount = 0;
243 int err_ret = 0;
244
245 struct sk_buff *pkt;
246
247 brcmf_dbg(TRACE, "Enter\n");
248
Arend van Spriela52dd172011-11-22 17:21:45 -0800249 brcmf_pm_resume_wait(sdiodev, &sdiodev->request_chain_wait);
Arend van Spriel5adfeb62011-11-22 17:21:38 -0800250 if (brcmf_pm_resume_error(sdiodev))
251 return -EIO;
252
253 /* Claim host controller */
254 sdio_claim_host(sdiodev->func[func]);
255
256 skb_queue_walk(pktq, pkt) {
257 uint pkt_len = pkt->len;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200258 pkt_len += 3;
259 pkt_len &= 0xFFFFFFFC;
260
Arend van Spriel5adfeb62011-11-22 17:21:38 -0800261 err_ret = brcmf_sdioh_request_data(sdiodev, write, fifo, func,
262 addr, pkt, pkt_len);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200263 if (err_ret) {
264 brcmf_dbg(ERROR, "%s FAILED %p[%d], addr=0x%05x, pkt_len=%d, ERR=0x%08x\n",
Arend van Spriel5adfeb62011-11-22 17:21:38 -0800265 write ? "TX" : "RX", pkt, SGCount, addr,
Arend van Spriel5b435de2011-10-05 13:19:03 +0200266 pkt_len, err_ret);
267 } else {
268 brcmf_dbg(TRACE, "%s xfr'd %p[%d], addr=0x%05x, len=%d\n",
Arend van Spriel5adfeb62011-11-22 17:21:38 -0800269 write ? "TX" : "RX", pkt, SGCount, addr,
Arend van Spriel5b435de2011-10-05 13:19:03 +0200270 pkt_len);
271 }
Arend van Spriel5b435de2011-10-05 13:19:03 +0200272 if (!fifo)
273 addr += pkt_len;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200274
Arend van Spriel5adfeb62011-11-22 17:21:38 -0800275 SGCount++;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200276 }
277
278 /* Release host controller */
279 sdio_release_host(sdiodev->func[func]);
280
281 brcmf_dbg(TRACE, "Exit\n");
282 return err_ret;
283}
284
285/*
Arend van Spriel80543212011-11-22 17:21:44 -0800286 * This function takes a single DMA-able packet.
Arend van Spriel5b435de2011-10-05 13:19:03 +0200287 */
288int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev,
289 uint fix_inc, uint write, uint func, uint addr,
Arend van Spriel4c6e8692011-11-22 17:21:40 -0800290 struct sk_buff *pkt)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200291{
Arend van Spriel4c6e8692011-11-22 17:21:40 -0800292 int status;
Arend van Spriel80543212011-11-22 17:21:44 -0800293 uint pkt_len = pkt->len;
294 bool fifo = (fix_inc == SDIOH_DATA_FIX);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200295
296 brcmf_dbg(TRACE, "Enter\n");
297
Arend van Spriel4c6e8692011-11-22 17:21:40 -0800298 if (pkt == NULL)
299 return -EINVAL;
300
Arend van Spriel5b435de2011-10-05 13:19:03 +0200301 brcmf_pm_resume_wait(sdiodev, &sdiodev->request_buffer_wait);
302 if (brcmf_pm_resume_error(sdiodev))
303 return -EIO;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200304
Arend van Spriel80543212011-11-22 17:21:44 -0800305 /* Claim host controller */
306 sdio_claim_host(sdiodev->func[func]);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200307
Arend van Spriel80543212011-11-22 17:21:44 -0800308 pkt_len += 3;
309 pkt_len &= (uint)~3;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200310
Arend van Spriel80543212011-11-22 17:21:44 -0800311 status = brcmf_sdioh_request_data(sdiodev, write, fifo, func,
312 addr, pkt, pkt_len);
313 if (status) {
314 brcmf_dbg(ERROR, "%s FAILED %p, addr=0x%05x, pkt_len=%d, ERR=0x%08x\n",
315 write ? "TX" : "RX", pkt, addr, pkt_len, status);
316 } else {
317 brcmf_dbg(TRACE, "%s xfr'd %p, addr=0x%05x, len=%d\n",
318 write ? "TX" : "RX", pkt, addr, pkt_len);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200319 }
320
Arend van Spriel80543212011-11-22 17:21:44 -0800321 /* Release host controller */
322 sdio_release_host(sdiodev->func[func]);
323
Arend van Spriel4c6e8692011-11-22 17:21:40 -0800324 return status;
Arend van Spriel5b435de2011-10-05 13:19:03 +0200325}
326
327/* Read client card reg */
328static int
329brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr,
330 int regsize, u32 *data)
331{
332
333 if ((func == 0) || (regsize == 1)) {
334 u8 temp = 0;
335
336 brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, func, regaddr,
337 &temp);
338 *data = temp;
339 *data &= 0xff;
340 brcmf_dbg(DATA, "byte read data=0x%02x\n", *data);
341 } else {
342 brcmf_sdioh_request_word(sdiodev, SDIOH_READ, func, regaddr,
343 data, regsize);
344 if (regsize == 2)
345 *data &= 0xffff;
346
347 brcmf_dbg(DATA, "word read data=0x%08x\n", *data);
348 }
349
350 return SUCCESS;
351}
352
353static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr)
354{
355 /* read 24 bits and return valid 17 bit addr */
356 int i;
357 u32 scratch, regdata;
358 __le32 scratch_le;
359 u8 *ptr = (u8 *)&scratch_le;
360
361 for (i = 0; i < 3; i++) {
362 if ((brcmf_sdioh_card_regread(sdiodev, 0, regaddr, 1,
363 &regdata)) != SUCCESS)
364 brcmf_dbg(ERROR, "Can't read!\n");
365
366 *ptr++ = (u8) regdata;
367 regaddr++;
368 }
369
370 /* Only the lower 17-bits are valid */
371 scratch = le32_to_cpu(scratch_le);
372 scratch &= 0x0001FFFF;
373 return scratch;
374}
375
376static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev)
377{
378 int err_ret;
379 u32 fbraddr;
380 u8 func;
381
382 brcmf_dbg(TRACE, "\n");
383
384 /* Get the Card's common CIS address */
385 sdiodev->func_cis_ptr[0] = brcmf_sdioh_get_cisaddr(sdiodev,
386 SDIO_CCCR_CIS);
387 brcmf_dbg(INFO, "Card's Common CIS Ptr = 0x%x\n",
388 sdiodev->func_cis_ptr[0]);
389
390 /* Get the Card's function CIS (for each function) */
391 for (fbraddr = SDIO_FBR_BASE(1), func = 1;
392 func <= sdiodev->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) {
393 sdiodev->func_cis_ptr[func] =
394 brcmf_sdioh_get_cisaddr(sdiodev, SDIO_FBR_CIS + fbraddr);
395 brcmf_dbg(INFO, "Function %d CIS Ptr = 0x%x\n",
396 func, sdiodev->func_cis_ptr[func]);
397 }
398
399 /* Enable Function 1 */
400 sdio_claim_host(sdiodev->func[1]);
401 err_ret = sdio_enable_func(sdiodev->func[1]);
402 sdio_release_host(sdiodev->func[1]);
403 if (err_ret)
404 brcmf_dbg(ERROR, "Failed to enable F1 Err: 0x%08x\n", err_ret);
405
406 return false;
407}
408
409/*
410 * Public entry points & extern's
411 */
412int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev)
413{
414 int err_ret = 0;
415
416 brcmf_dbg(TRACE, "\n");
417
418 sdiodev->num_funcs = 2;
419
420 sdio_claim_host(sdiodev->func[1]);
421 err_ret = sdio_set_block_size(sdiodev->func[1], SDIO_FUNC1_BLOCKSIZE);
422 sdio_release_host(sdiodev->func[1]);
423 if (err_ret) {
424 brcmf_dbg(ERROR, "Failed to set F1 blocksize\n");
425 goto out;
426 }
427
428 sdio_claim_host(sdiodev->func[2]);
429 err_ret = sdio_set_block_size(sdiodev->func[2], SDIO_FUNC2_BLOCKSIZE);
430 sdio_release_host(sdiodev->func[2]);
431 if (err_ret) {
432 brcmf_dbg(ERROR, "Failed to set F2 blocksize\n");
433 goto out;
434 }
435
436 brcmf_sdioh_enablefuncs(sdiodev);
437
438out:
439 brcmf_dbg(TRACE, "Done\n");
440 return err_ret;
441}
442
443void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev)
444{
445 brcmf_dbg(TRACE, "\n");
446
447 /* Disable Function 2 */
448 sdio_claim_host(sdiodev->func[2]);
449 sdio_disable_func(sdiodev->func[2]);
450 sdio_release_host(sdiodev->func[2]);
451
452 /* Disable Function 1 */
453 sdio_claim_host(sdiodev->func[1]);
454 sdio_disable_func(sdiodev->func[1]);
455 sdio_release_host(sdiodev->func[1]);
456
457}
458
459static int brcmf_ops_sdio_probe(struct sdio_func *func,
460 const struct sdio_device_id *id)
461{
462 int ret = 0;
463 struct brcmf_sdio_dev *sdiodev;
464 brcmf_dbg(TRACE, "Enter\n");
465 brcmf_dbg(TRACE, "func->class=%x\n", func->class);
466 brcmf_dbg(TRACE, "sdio_vendor: 0x%04x\n", func->vendor);
467 brcmf_dbg(TRACE, "sdio_device: 0x%04x\n", func->device);
468 brcmf_dbg(TRACE, "Function#: 0x%04x\n", func->num);
469
470 if (func->num == 1) {
471 if (dev_get_drvdata(&func->card->dev)) {
472 brcmf_dbg(ERROR, "card private drvdata occupied\n");
473 return -ENXIO;
474 }
475 sdiodev = kzalloc(sizeof(struct brcmf_sdio_dev), GFP_KERNEL);
476 if (!sdiodev)
477 return -ENOMEM;
478 sdiodev->func[0] = func->card->sdio_func[0];
479 sdiodev->func[1] = func;
480 dev_set_drvdata(&func->card->dev, sdiodev);
481
482 atomic_set(&sdiodev->suspend, false);
483 init_waitqueue_head(&sdiodev->request_byte_wait);
484 init_waitqueue_head(&sdiodev->request_word_wait);
Arend van Spriela52dd172011-11-22 17:21:45 -0800485 init_waitqueue_head(&sdiodev->request_chain_wait);
Arend van Spriel5b435de2011-10-05 13:19:03 +0200486 init_waitqueue_head(&sdiodev->request_buffer_wait);
487 }
488
489 if (func->num == 2) {
490 sdiodev = dev_get_drvdata(&func->card->dev);
491 if ((!sdiodev) || (sdiodev->func[1]->card != func->card))
492 return -ENODEV;
493 sdiodev->func[2] = func;
494
495 brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_probe...\n");
496 ret = brcmf_sdio_probe(sdiodev);
497 }
498
499 return ret;
500}
501
502static void brcmf_ops_sdio_remove(struct sdio_func *func)
503{
504 struct brcmf_sdio_dev *sdiodev;
505 brcmf_dbg(TRACE, "Enter\n");
506 brcmf_dbg(INFO, "func->class=%x\n", func->class);
507 brcmf_dbg(INFO, "sdio_vendor: 0x%04x\n", func->vendor);
508 brcmf_dbg(INFO, "sdio_device: 0x%04x\n", func->device);
509 brcmf_dbg(INFO, "Function#: 0x%04x\n", func->num);
510
511 if (func->num == 2) {
512 sdiodev = dev_get_drvdata(&func->card->dev);
513 brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_remove...\n");
514 brcmf_sdio_remove(sdiodev);
515 dev_set_drvdata(&func->card->dev, NULL);
516 kfree(sdiodev);
517 }
518}
519
520#ifdef CONFIG_PM_SLEEP
521static int brcmf_sdio_suspend(struct device *dev)
522{
523 mmc_pm_flag_t sdio_flags;
524 struct brcmf_sdio_dev *sdiodev;
525 struct sdio_func *func = dev_to_sdio_func(dev);
526 int ret = 0;
527
528 brcmf_dbg(TRACE, "\n");
529
530 sdiodev = dev_get_drvdata(&func->card->dev);
531
532 atomic_set(&sdiodev->suspend, true);
533
534 sdio_flags = sdio_get_host_pm_caps(sdiodev->func[1]);
535 if (!(sdio_flags & MMC_PM_KEEP_POWER)) {
536 brcmf_dbg(ERROR, "Host can't keep power while suspended\n");
537 return -EINVAL;
538 }
539
540 ret = sdio_set_host_pm_flags(sdiodev->func[1], MMC_PM_KEEP_POWER);
541 if (ret) {
542 brcmf_dbg(ERROR, "Failed to set pm_flags\n");
543 return ret;
544 }
545
546 brcmf_sdio_wdtmr_enable(sdiodev, false);
547
548 return ret;
549}
550
551static int brcmf_sdio_resume(struct device *dev)
552{
553 struct brcmf_sdio_dev *sdiodev;
554 struct sdio_func *func = dev_to_sdio_func(dev);
555
556 sdiodev = dev_get_drvdata(&func->card->dev);
557 brcmf_sdio_wdtmr_enable(sdiodev, true);
558 atomic_set(&sdiodev->suspend, false);
559 return 0;
560}
561
562static const struct dev_pm_ops brcmf_sdio_pm_ops = {
563 .suspend = brcmf_sdio_suspend,
564 .resume = brcmf_sdio_resume,
565};
566#endif /* CONFIG_PM_SLEEP */
567
568static struct sdio_driver brcmf_sdmmc_driver = {
569 .probe = brcmf_ops_sdio_probe,
570 .remove = brcmf_ops_sdio_remove,
571 .name = "brcmfmac",
572 .id_table = brcmf_sdmmc_ids,
573#ifdef CONFIG_PM_SLEEP
574 .drv = {
575 .pm = &brcmf_sdio_pm_ops,
576 },
577#endif /* CONFIG_PM_SLEEP */
578};
579
Franky Lin3392c882011-11-22 17:21:47 -0800580static void __exit brcmf_sdio_exit(void)
Arend van Spriel5b435de2011-10-05 13:19:03 +0200581{
582 brcmf_dbg(TRACE, "Enter\n");
583
584 sdio_unregister_driver(&brcmf_sdmmc_driver);
585}
Franky Lin3392c882011-11-22 17:21:47 -0800586
587static int __init brcmf_sdio_init(void)
588{
589 int ret;
590
591 brcmf_dbg(TRACE, "Enter\n");
592
593 ret = sdio_register_driver(&brcmf_sdmmc_driver);
594
595 if (ret)
596 brcmf_dbg(ERROR, "sdio_register_driver failed: %d\n", ret);
597
598 return ret;
599}
600
601module_init(brcmf_sdio_init);
602module_exit(brcmf_sdio_exit);