2 * This file contains work-arounds for many known SD/MMC
3 * and SDIO hardware bugs.
5 * Copyright (c) 2011 Andrei Warkentin <andreiw@motorola.com>
6 * Copyright (c) 2011 Pierre Tardy <tardyp@gmail.com>
7 * Inspired from pci fixup code:
8 * Copyright (c) 1999 Martin Mares <mj@ucw.cz>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/export.h>
15 #include <linux/mmc/card.h>
16 #include <linux/mmc/sdio_ids.h>
18 #ifndef SDIO_VENDOR_ID_TI
19 #define SDIO_VENDOR_ID_TI 0x0097
22 #ifndef SDIO_DEVICE_ID_TI_WL1271
23 #define SDIO_DEVICE_ID_TI_WL1271 0x4076
26 #ifndef SDIO_VENDOR_ID_STE
27 #define SDIO_VENDOR_ID_STE 0x0020
30 #ifndef SDIO_DEVICE_ID_STE_CW1200
31 #define SDIO_DEVICE_ID_STE_CW1200 0x2280
34 #ifndef SDIO_DEVICE_ID_MARVELL_8797_F0
35 #define SDIO_DEVICE_ID_MARVELL_8797_F0 0x9128
38 static const struct mmc_fixup mmc_fixup_methods
[] = {
39 SDIO_FIXUP(SDIO_VENDOR_ID_TI
, SDIO_DEVICE_ID_TI_WL1271
,
40 add_quirk
, MMC_QUIRK_NONSTD_FUNC_IF
),
42 SDIO_FIXUP(SDIO_VENDOR_ID_TI
, SDIO_DEVICE_ID_TI_WL1271
,
43 add_quirk
, MMC_QUIRK_DISABLE_CD
),
45 SDIO_FIXUP(SDIO_VENDOR_ID_STE
, SDIO_DEVICE_ID_STE_CW1200
,
46 add_quirk
, MMC_QUIRK_BROKEN_BYTE_MODE_512
),
48 SDIO_FIXUP(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8797_F0
,
49 add_quirk
, MMC_QUIRK_BROKEN_IRQ_POLLING
),
54 void mmc_fixup_device(struct mmc_card
*card
, const struct mmc_fixup
*table
)
56 const struct mmc_fixup
*f
;
57 u64 rev
= cid_rev_card(card
);
59 /* Non-core specific workarounds. */
61 table
= mmc_fixup_methods
;
63 for (f
= table
; f
->vendor_fixup
; f
++) {
64 if ((f
->manfid
== CID_MANFID_ANY
||
65 f
->manfid
== card
->cid
.manfid
) &&
66 (f
->oemid
== CID_OEMID_ANY
||
67 f
->oemid
== card
->cid
.oemid
) &&
68 (f
->name
== CID_NAME_ANY
||
69 !strncmp(f
->name
, card
->cid
.prod_name
,
70 sizeof(card
->cid
.prod_name
))) &&
71 (f
->cis_vendor
== card
->cis
.vendor
||
72 f
->cis_vendor
== (u16
) SDIO_ANY_ID
) &&
73 (f
->cis_device
== card
->cis
.device
||
74 f
->cis_device
== (u16
) SDIO_ANY_ID
) &&
75 rev
>= f
->rev_start
&& rev
<= f
->rev_end
) {
76 dev_dbg(&card
->dev
, "calling %pf\n", f
->vendor_fixup
);
77 f
->vendor_fixup(card
, f
->data
);
81 EXPORT_SYMBOL(mmc_fixup_device
);