Skip to content

Commit 6f51be3

Browse files
notaztorvalds
authored andcommitted
sdio: allow non-standard SDIO cards
There are some chips (like TI WL12xx series) that can be interfaced over SDIO but don't support the SDIO specification, meaning that they are missing CIA (Common I/O Area) with all it's registers. Current Linux SDIO implementation relies on those registers to identify and configure the card, so non-standard cards can not function and cause lots of warnings from the core when it reads invalid data from non-existent registers. After this patch, init_card() host callback can now set new quirk MMC_QUIRK_NONSTD_SDIO, which means that SDIO core should not try to access any standard SDIO registers and rely on init_card() to fill all SDIO structures instead. As those cards are usually embedded chips, all the required information can be obtained from machine board files by the host driver when it's called through init_card() callback. Signed-off-by: Grazvydas Ignotas <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Tony Lindgren <[email protected]> Cc: Bob Copeland <[email protected]> Cc: Kalle Valo <[email protected]> Cc: Madhusudhan Chikkature <[email protected]> Cc: Kishore Kadiyala <[email protected]> Cc: Russell King <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 20b1597 commit 6f51be3

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

drivers/mmc/core/sdio.c

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,19 @@ static int sdio_init_func(struct mmc_card *card, unsigned int fn)
6363

6464
func->num = fn;
6565

66-
ret = sdio_read_fbr(func);
67-
if (ret)
68-
goto fail;
66+
if (!(card->quirks & MMC_QUIRK_NONSTD_SDIO)) {
67+
ret = sdio_read_fbr(func);
68+
if (ret)
69+
goto fail;
6970

70-
ret = sdio_read_func_cis(func);
71-
if (ret)
72-
goto fail;
71+
ret = sdio_read_func_cis(func);
72+
if (ret)
73+
goto fail;
74+
} else {
75+
func->vendor = func->card->cis.vendor;
76+
func->device = func->card->cis.device;
77+
func->max_blksize = func->card->cis.blksize;
78+
}
7379

7480
card->sdio_func[fn - 1] = func;
7581

@@ -412,6 +418,23 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
412418
goto remove;
413419
}
414420

421+
if (card->quirks & MMC_QUIRK_NONSTD_SDIO) {
422+
/*
423+
* This is non-standard SDIO device, meaning it doesn't
424+
* have any CIA (Common I/O area) registers present.
425+
* It's host's responsibility to fill cccr and cis
426+
* structures in init_card().
427+
*/
428+
mmc_set_clock(host, card->cis.max_dtr);
429+
430+
if (card->cccr.high_speed) {
431+
mmc_card_set_highspeed(card);
432+
mmc_set_timing(card->host, MMC_TIMING_SD_HS);
433+
}
434+
435+
goto finish;
436+
}
437+
415438
/*
416439
* Read the common registers.
417440
*/
@@ -480,6 +503,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
480503
else if (err)
481504
goto remove;
482505

506+
finish:
483507
if (!oldcard)
484508
host->card = card;
485509
return 0;

include/linux/mmc/card.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ struct mmc_card {
103103
#define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */
104104
#define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */
105105
/* for byte mode */
106+
#define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */
107+
/* (missing CIA registers) */
106108

107109
u32 raw_cid[4]; /* raw card CID */
108110
u32 raw_csd[4]; /* raw card CSD */

0 commit comments

Comments
 (0)