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 | |
Bing Zhao | e562405 | 2013-11-26 15:39:20 -0800 | [diff] [blame] | 12 | #include <linux/mmc/sdio_ids.h> |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 13 | |
Ulf Hansson | 4facdde | 2017-01-13 14:14:14 +0100 | [diff] [blame] | 14 | #include "card.h" |
| 15 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 16 | #ifndef SDIO_VENDOR_ID_TI |
| 17 | #define SDIO_VENDOR_ID_TI 0x0097 |
| 18 | #endif |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 19 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 20 | #ifndef SDIO_DEVICE_ID_TI_WL1271 |
| 21 | #define SDIO_DEVICE_ID_TI_WL1271 0x4076 |
| 22 | #endif |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 23 | |
Stefan Nilsson XK | 9a0da64 | 2011-09-15 17:43:04 +0200 | [diff] [blame] | 24 | #ifndef SDIO_VENDOR_ID_STE |
| 25 | #define SDIO_VENDOR_ID_STE 0x0020 |
| 26 | #endif |
| 27 | |
| 28 | #ifndef SDIO_DEVICE_ID_STE_CW1200 |
| 29 | #define SDIO_DEVICE_ID_STE_CW1200 0x2280 |
| 30 | #endif |
| 31 | |
Bing Zhao | e562405 | 2013-11-26 15:39:20 -0800 | [diff] [blame] | 32 | #ifndef SDIO_DEVICE_ID_MARVELL_8797_F0 |
| 33 | #define SDIO_DEVICE_ID_MARVELL_8797_F0 0x9128 |
| 34 | #endif |
| 35 | |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 36 | static const struct mmc_fixup mmc_fixup_methods[] = { |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 37 | SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, |
| 38 | add_quirk, MMC_QUIRK_NONSTD_FUNC_IF), |
| 39 | |
| 40 | SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, |
| 41 | add_quirk, MMC_QUIRK_DISABLE_CD), |
| 42 | |
Stefan Nilsson XK | 9a0da64 | 2011-09-15 17:43:04 +0200 | [diff] [blame] | 43 | SDIO_FIXUP(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_CW1200, |
| 44 | add_quirk, MMC_QUIRK_BROKEN_BYTE_MODE_512), |
| 45 | |
Bing Zhao | e562405 | 2013-11-26 15:39:20 -0800 | [diff] [blame] | 46 | SDIO_FIXUP(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8797_F0, |
| 47 | add_quirk, MMC_QUIRK_BROKEN_IRQ_POLLING), |
| 48 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 49 | END_FIXUP |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 50 | }; |
| 51 | |
Shawn Lin | 28fc64a | 2017-02-15 16:35:28 +0800 | [diff] [blame^] | 52 | static inline void mmc_fixup_device(struct mmc_card *card, |
| 53 | const struct mmc_fixup *table) |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 54 | { |
| 55 | const struct mmc_fixup *f; |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 56 | u64 rev = cid_rev_card(card); |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 57 | |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 58 | /* Non-core specific workarounds. */ |
| 59 | if (!table) |
| 60 | table = mmc_fixup_methods; |
| 61 | |
| 62 | for (f = table; f->vendor_fixup; f++) { |
| 63 | if ((f->manfid == CID_MANFID_ANY || |
| 64 | f->manfid == card->cid.manfid) && |
| 65 | (f->oemid == CID_OEMID_ANY || |
| 66 | f->oemid == card->cid.oemid) && |
| 67 | (f->name == CID_NAME_ANY || |
| 68 | !strncmp(f->name, card->cid.prod_name, |
| 69 | sizeof(card->cid.prod_name))) && |
| 70 | (f->cis_vendor == card->cis.vendor || |
| 71 | f->cis_vendor == (u16) SDIO_ANY_ID) && |
| 72 | (f->cis_device == card->cis.device || |
| 73 | f->cis_device == (u16) SDIO_ANY_ID) && |
Pratibhasagar V | 5320226 | 2016-06-09 18:09:31 -0400 | [diff] [blame] | 74 | (f->ext_csd_rev == EXT_CSD_REV_ANY || |
| 75 | f->ext_csd_rev == card->ext_csd.rev) && |
Andrei Warkentin | 32780cd | 2011-04-11 17:02:15 -0500 | [diff] [blame] | 76 | rev >= f->rev_start && rev <= f->rev_end) { |
Alexander Stein | be19c40 | 2014-05-20 13:29:21 +0200 | [diff] [blame] | 77 | dev_dbg(&card->dev, "calling %pf\n", f->vendor_fixup); |
Pierre Tardy | 57f0adc | 2011-02-06 19:03:46 +0100 | [diff] [blame] | 78 | f->vendor_fixup(card, f->data); |
| 79 | } |
| 80 | } |
| 81 | } |