Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 1 | /* |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 2 | * This file contains work-arounds for many known SD/MMC |
| 3 | * and SDIO hardware bugs. |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 4 | * |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 5 | * Copyright (c) 2011 Andrei Warkentin <andreiw@motorola.com> |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 6 | * Copyright (c) 2011 Pierre Tardy <tardyp@gmail.com> |
| 7 | * Inspired from pci fixup code: |
| 8 | * Copyright (c) 1999 Martin Mares <mj@ucw.cz> |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #include <linux/types.h> |
| 13 | #include <linux/kernel.h> |
Paul Gortmaker | 3ef77af | 2011-07-10 12:42:00 -0400 | [diff] [blame] | 14 | #include <linux/export.h> |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 15 | #include <linux/mmc/card.h> |
Bing Zhao | e562405 | 2013-11-26 15:39:20 -0800 | [diff] [blame] | 16 | #include <linux/mmc/sdio_ids.h> |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 17 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 18 | #ifndef SDIO_VENDOR_ID_TI |
| 19 | #define SDIO_VENDOR_ID_TI 0x0097 |
| 20 | #endif |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 21 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 22 | #ifndef SDIO_DEVICE_ID_TI_WL1271 |
| 23 | #define SDIO_DEVICE_ID_TI_WL1271 0x4076 |
| 24 | #endif |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 25 | |
Stefan Nilsson XK | 9a0da64 | 2011-09-15 17:43:04 +0200 | [diff] [blame] | 26 | #ifndef SDIO_VENDOR_ID_STE |
| 27 | #define SDIO_VENDOR_ID_STE 0x0020 |
| 28 | #endif |
| 29 | |
| 30 | #ifndef SDIO_DEVICE_ID_STE_CW1200 |
| 31 | #define SDIO_DEVICE_ID_STE_CW1200 0x2280 |
| 32 | #endif |
| 33 | |
Bing Zhao | e562405 | 2013-11-26 15:39:20 -0800 | [diff] [blame] | 34 | #ifndef SDIO_DEVICE_ID_MARVELL_8797_F0 |
| 35 | #define SDIO_DEVICE_ID_MARVELL_8797_F0 0x9128 |
| 36 | #endif |
| 37 | |
Pierre Tardy | db99350 | 2011-02-06 19:03:47 +0100 | [diff] [blame] | 38 | /* |
| 39 | * This hook just adds a quirk for all sdio devices |
| 40 | */ |
| 41 | static void add_quirk_for_sdio_devices(struct mmc_card *card, int data) |
| 42 | { |
| 43 | if (mmc_card_sdio(card)) |
| 44 | card->quirks |= data; |
| 45 | } |
| 46 | |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 47 | static const struct mmc_fixup mmc_fixup_methods[] = { |
Pierre Tardy | db99350 | 2011-02-06 19:03:47 +0100 | [diff] [blame] | 48 | /* by default sdio devices are considered CLK_GATING broken */ |
| 49 | /* good cards will be whitelisted as they are tested */ |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 50 | SDIO_FIXUP(SDIO_ANY_ID, SDIO_ANY_ID, |
| 51 | add_quirk_for_sdio_devices, |
| 52 | MMC_QUIRK_BROKEN_CLK_GATING), |
| 53 | |
| 54 | SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, |
| 55 | remove_quirk, MMC_QUIRK_BROKEN_CLK_GATING), |
| 56 | |
| 57 | SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, |
| 58 | add_quirk, MMC_QUIRK_NONSTD_FUNC_IF), |
| 59 | |
| 60 | SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, |
| 61 | add_quirk, MMC_QUIRK_DISABLE_CD), |
| 62 | |
Stefan Nilsson XK | 9a0da64 | 2011-09-15 17:43:04 +0200 | [diff] [blame] | 63 | SDIO_FIXUP(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_CW1200, |
| 64 | add_quirk, MMC_QUIRK_BROKEN_BYTE_MODE_512), |
| 65 | |
Bing Zhao | e562405 | 2013-11-26 15:39:20 -0800 | [diff] [blame] | 66 | SDIO_FIXUP(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8797_F0, |
| 67 | add_quirk, MMC_QUIRK_BROKEN_IRQ_POLLING), |
| 68 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 69 | END_FIXUP |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 70 | }; |
| 71 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 72 | void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table) |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 73 | { |
| 74 | const struct mmc_fixup *f; |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 75 | u64 rev = cid_rev_card(card); |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 76 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 77 | /* Non-core specific workarounds. */ |
| 78 | if (!table) |
| 79 | table = mmc_fixup_methods; |
| 80 | |
| 81 | for (f = table; f->vendor_fixup; f++) { |
| 82 | if ((f->manfid == CID_MANFID_ANY || |
| 83 | f->manfid == card->cid.manfid) && |
| 84 | (f->oemid == CID_OEMID_ANY || |
| 85 | f->oemid == card->cid.oemid) && |
| 86 | (f->name == CID_NAME_ANY || |
| 87 | !strncmp(f->name, card->cid.prod_name, |
| 88 | sizeof(card->cid.prod_name))) && |
| 89 | (f->cis_vendor == card->cis.vendor || |
| 90 | f->cis_vendor == (u16) SDIO_ANY_ID) && |
| 91 | (f->cis_device == card->cis.device || |
| 92 | f->cis_device == (u16) SDIO_ANY_ID) && |
| 93 | rev >= f->rev_start && rev <= f->rev_end) { |
Alexander Stein | be19c40 | 2014-05-20 13:29:21 +0200 | [diff] [blame] | 94 | dev_dbg(&card->dev, "calling %pf\n", f->vendor_fixup); |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 95 | f->vendor_fixup(card, f->data); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | EXPORT_SYMBOL(mmc_fixup_device); |