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> |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 16 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 17 | #ifndef SDIO_VENDOR_ID_TI |
| 18 | #define SDIO_VENDOR_ID_TI 0x0097 |
| 19 | #endif |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 20 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 21 | #ifndef SDIO_DEVICE_ID_TI_WL1271 |
| 22 | #define SDIO_DEVICE_ID_TI_WL1271 0x4076 |
| 23 | #endif |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 24 | |
Stefan Nilsson XK | 9a0da64 | 2011-09-15 17:43:04 +0200 | [diff] [blame] | 25 | #ifndef SDIO_VENDOR_ID_STE |
| 26 | #define SDIO_VENDOR_ID_STE 0x0020 |
| 27 | #endif |
| 28 | |
| 29 | #ifndef SDIO_DEVICE_ID_STE_CW1200 |
| 30 | #define SDIO_DEVICE_ID_STE_CW1200 0x2280 |
| 31 | #endif |
| 32 | |
Sujit Reddy Thumma | d9b4611 | 2012-01-24 10:46:33 +0530 | [diff] [blame] | 33 | #ifndef SDIO_VENDOR_ID_MSM |
| 34 | #define SDIO_VENDOR_ID_MSM 0x0070 |
| 35 | #endif |
| 36 | |
| 37 | #ifndef SDIO_DEVICE_ID_MSM_WCN1314 |
| 38 | #define SDIO_DEVICE_ID_MSM_WCN1314 0x2881 |
| 39 | #endif |
| 40 | |
Krishna Konda | e5c79d7 | 2012-05-14 16:19:31 -0700 | [diff] [blame] | 41 | #ifndef SDIO_VENDOR_ID_MSM_QCA |
| 42 | #define SDIO_VENDOR_ID_MSM_QCA 0x271 |
| 43 | #endif |
| 44 | |
| 45 | #ifndef SDIO_DEVICE_ID_MSM_QCA_AR6003_1 |
| 46 | #define SDIO_DEVICE_ID_MSM_QCA_AR6003_1 0x300 |
| 47 | #endif |
| 48 | |
| 49 | #ifndef SDIO_DEVICE_ID_MSM_QCA_AR6003_2 |
| 50 | #define SDIO_DEVICE_ID_MSM_QCA_AR6003_2 0x301 |
| 51 | #endif |
| 52 | |
Asutosh Das | 7b5d389 | 2013-04-24 15:22:05 +0530 | [diff] [blame] | 53 | #ifndef SDIO_DEVICE_ID_MSM_QCA_AR6004_1 |
| 54 | #define SDIO_DEVICE_ID_MSM_QCA_AR6004_1 0x400 |
| 55 | #endif |
| 56 | |
| 57 | #ifndef SDIO_DEVICE_ID_MSM_QCA_AR6004_2 |
| 58 | #define SDIO_DEVICE_ID_MSM_QCA_AR6004_2 0x401 |
| 59 | #endif |
| 60 | |
Pierre Tardy | db99350 | 2011-02-06 19:03:47 +0100 | [diff] [blame] | 61 | /* |
| 62 | * This hook just adds a quirk for all sdio devices |
| 63 | */ |
| 64 | static void add_quirk_for_sdio_devices(struct mmc_card *card, int data) |
| 65 | { |
| 66 | if (mmc_card_sdio(card)) |
| 67 | card->quirks |= data; |
| 68 | } |
| 69 | |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 70 | static const struct mmc_fixup mmc_fixup_methods[] = { |
Pierre Tardy | db99350 | 2011-02-06 19:03:47 +0100 | [diff] [blame] | 71 | /* by default sdio devices are considered CLK_GATING broken */ |
| 72 | /* good cards will be whitelisted as they are tested */ |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 73 | SDIO_FIXUP(SDIO_ANY_ID, SDIO_ANY_ID, |
| 74 | add_quirk_for_sdio_devices, |
| 75 | MMC_QUIRK_BROKEN_CLK_GATING), |
| 76 | |
| 77 | SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, |
| 78 | remove_quirk, MMC_QUIRK_BROKEN_CLK_GATING), |
| 79 | |
Sujit Reddy Thumma | d9b4611 | 2012-01-24 10:46:33 +0530 | [diff] [blame] | 80 | SDIO_FIXUP(SDIO_VENDOR_ID_MSM, SDIO_DEVICE_ID_MSM_WCN1314, |
| 81 | remove_quirk, MMC_QUIRK_BROKEN_CLK_GATING), |
| 82 | |
Krishna Konda | e5c79d7 | 2012-05-14 16:19:31 -0700 | [diff] [blame] | 83 | SDIO_FIXUP(SDIO_VENDOR_ID_MSM_QCA, SDIO_DEVICE_ID_MSM_QCA_AR6003_1, |
| 84 | remove_quirk, MMC_QUIRK_BROKEN_CLK_GATING), |
| 85 | |
| 86 | SDIO_FIXUP(SDIO_VENDOR_ID_MSM_QCA, SDIO_DEVICE_ID_MSM_QCA_AR6003_2, |
| 87 | remove_quirk, MMC_QUIRK_BROKEN_CLK_GATING), |
| 88 | |
Asutosh Das | 7b5d389 | 2013-04-24 15:22:05 +0530 | [diff] [blame] | 89 | SDIO_FIXUP(SDIO_VENDOR_ID_MSM_QCA, SDIO_DEVICE_ID_MSM_QCA_AR6004_1, |
| 90 | remove_quirk, MMC_QUIRK_BROKEN_CLK_GATING), |
| 91 | |
| 92 | SDIO_FIXUP(SDIO_VENDOR_ID_MSM_QCA, SDIO_DEVICE_ID_MSM_QCA_AR6004_2, |
| 93 | remove_quirk, MMC_QUIRK_BROKEN_CLK_GATING), |
| 94 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 95 | SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, |
| 96 | add_quirk, MMC_QUIRK_NONSTD_FUNC_IF), |
| 97 | |
| 98 | SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, |
| 99 | add_quirk, MMC_QUIRK_DISABLE_CD), |
| 100 | |
Stefan Nilsson XK | 9a0da64 | 2011-09-15 17:43:04 +0200 | [diff] [blame] | 101 | SDIO_FIXUP(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_CW1200, |
| 102 | add_quirk, MMC_QUIRK_BROKEN_BYTE_MODE_512), |
| 103 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 104 | END_FIXUP |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 105 | }; |
| 106 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 107 | 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] | 108 | { |
| 109 | const struct mmc_fixup *f; |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 110 | u64 rev = cid_rev_card(card); |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 111 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 112 | /* Non-core specific workarounds. */ |
| 113 | if (!table) |
| 114 | table = mmc_fixup_methods; |
| 115 | |
| 116 | for (f = table; f->vendor_fixup; f++) { |
| 117 | if ((f->manfid == CID_MANFID_ANY || |
| 118 | f->manfid == card->cid.manfid) && |
| 119 | (f->oemid == CID_OEMID_ANY || |
| 120 | f->oemid == card->cid.oemid) && |
| 121 | (f->name == CID_NAME_ANY || |
| 122 | !strncmp(f->name, card->cid.prod_name, |
| 123 | sizeof(card->cid.prod_name))) && |
Pratibhasagar V | 84af373 | 2013-08-22 13:23:55 +0530 | [diff] [blame] | 124 | (f->ext_csd_rev == EXT_CSD_REV_ANY || |
| 125 | f->ext_csd_rev == card->ext_csd.rev) && |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 126 | (f->cis_vendor == card->cis.vendor || |
| 127 | f->cis_vendor == (u16) SDIO_ANY_ID) && |
| 128 | (f->cis_device == card->cis.device || |
| 129 | f->cis_device == (u16) SDIO_ANY_ID) && |
| 130 | rev >= f->rev_start && rev <= f->rev_end) { |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 131 | dev_dbg(&card->dev, "calling %pF\n", f->vendor_fixup); |
| 132 | f->vendor_fixup(card, f->data); |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | EXPORT_SYMBOL(mmc_fixup_device); |