Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1 | /* linux/drivers/mmc/host/sdhci-pci.c - SDHCI on PCI bus interface |
| 2 | * |
| 3 | * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * Thanks to the following companies for their support: |
| 11 | * |
| 12 | * - JMicron (hardware and technical support) |
| 13 | */ |
| 14 | |
| 15 | #include <linux/delay.h> |
| 16 | #include <linux/highmem.h> |
Paul Gortmaker | 88b4767 | 2011-07-03 15:15:51 -0400 | [diff] [blame] | 17 | #include <linux/module.h> |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 18 | #include <linux/pci.h> |
| 19 | #include <linux/dma-mapping.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 20 | #include <linux/slab.h> |
Maxim Levitsky | ccc92c2 | 2010-08-10 18:01:42 -0700 | [diff] [blame] | 21 | #include <linux/device.h> |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 22 | #include <linux/mmc/host.h> |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 23 | #include <linux/scatterlist.h> |
| 24 | #include <linux/io.h> |
Adrian Hunter | 0f20165 | 2011-08-29 16:42:13 +0300 | [diff] [blame] | 25 | #include <linux/gpio.h> |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 26 | #include <linux/pm_runtime.h> |
Adrian Hunter | ff59c52 | 2014-09-24 10:27:31 +0300 | [diff] [blame] | 27 | #include <linux/mmc/slot-gpio.h> |
Adrian Hunter | 52c506f | 2011-12-27 15:48:43 +0200 | [diff] [blame] | 28 | #include <linux/mmc/sdhci-pci-data.h> |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 29 | |
| 30 | #include "sdhci.h" |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 31 | #include "sdhci-pci.h" |
Adam Lee | 01acf69 | 2013-12-19 00:01:26 +0800 | [diff] [blame] | 32 | #include "sdhci-pci-o2micro.h" |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 33 | |
| 34 | /*****************************************************************************\ |
| 35 | * * |
| 36 | * Hardware specific quirk handling * |
| 37 | * * |
| 38 | \*****************************************************************************/ |
| 39 | |
| 40 | static int ricoh_probe(struct sdhci_pci_chip *chip) |
| 41 | { |
Chris Ball | c99436f | 2009-09-22 16:45:22 -0700 | [diff] [blame] | 42 | if (chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG || |
| 43 | chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SONY) |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 44 | chip->quirks |= SDHCI_QUIRK_NO_CARD_NO_RESET; |
Maxim Levitsky | ccc92c2 | 2010-08-10 18:01:42 -0700 | [diff] [blame] | 45 | return 0; |
| 46 | } |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 47 | |
Maxim Levitsky | ccc92c2 | 2010-08-10 18:01:42 -0700 | [diff] [blame] | 48 | static int ricoh_mmc_probe_slot(struct sdhci_pci_slot *slot) |
| 49 | { |
| 50 | slot->host->caps = |
| 51 | ((0x21 << SDHCI_TIMEOUT_CLK_SHIFT) |
| 52 | & SDHCI_TIMEOUT_CLK_MASK) | |
| 53 | |
| 54 | ((0x21 << SDHCI_CLOCK_BASE_SHIFT) |
| 55 | & SDHCI_CLOCK_BASE_MASK) | |
| 56 | |
| 57 | SDHCI_TIMEOUT_CLK_UNIT | |
| 58 | SDHCI_CAN_VDD_330 | |
Madhvapathi Sriram | 1a1f1f0 | 2012-10-15 04:47:30 +0000 | [diff] [blame] | 59 | SDHCI_CAN_DO_HISPD | |
Maxim Levitsky | ccc92c2 | 2010-08-10 18:01:42 -0700 | [diff] [blame] | 60 | SDHCI_CAN_DO_SDMA; |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | static int ricoh_mmc_resume(struct sdhci_pci_chip *chip) |
| 65 | { |
| 66 | /* Apply a delay to allow controller to settle */ |
| 67 | /* Otherwise it becomes confused if card state changed |
| 68 | during suspend */ |
| 69 | msleep(500); |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static const struct sdhci_pci_fixes sdhci_ricoh = { |
| 74 | .probe = ricoh_probe, |
Vasily Khoruzhick | 8493829 | 2010-03-05 13:43:46 -0800 | [diff] [blame] | 75 | .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | |
| 76 | SDHCI_QUIRK_FORCE_DMA | |
| 77 | SDHCI_QUIRK_CLOCK_BEFORE_RESET, |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 78 | }; |
| 79 | |
Maxim Levitsky | ccc92c2 | 2010-08-10 18:01:42 -0700 | [diff] [blame] | 80 | static const struct sdhci_pci_fixes sdhci_ricoh_mmc = { |
| 81 | .probe_slot = ricoh_mmc_probe_slot, |
| 82 | .resume = ricoh_mmc_resume, |
| 83 | .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | |
| 84 | SDHCI_QUIRK_CLOCK_BEFORE_RESET | |
| 85 | SDHCI_QUIRK_NO_CARD_NO_RESET | |
| 86 | SDHCI_QUIRK_MISSING_CAPS |
| 87 | }; |
| 88 | |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 89 | static const struct sdhci_pci_fixes sdhci_ene_712 = { |
| 90 | .quirks = SDHCI_QUIRK_SINGLE_POWER_WRITE | |
| 91 | SDHCI_QUIRK_BROKEN_DMA, |
| 92 | }; |
| 93 | |
| 94 | static const struct sdhci_pci_fixes sdhci_ene_714 = { |
| 95 | .quirks = SDHCI_QUIRK_SINGLE_POWER_WRITE | |
| 96 | SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS | |
| 97 | SDHCI_QUIRK_BROKEN_DMA, |
| 98 | }; |
| 99 | |
| 100 | static const struct sdhci_pci_fixes sdhci_cafe = { |
| 101 | .quirks = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER | |
Andres Salomon | a087489 | 2009-03-02 21:48:20 +0100 | [diff] [blame] | 102 | SDHCI_QUIRK_NO_BUSY_IRQ | |
Daniel Drake | 55fc05b | 2012-07-03 23:13:39 +0100 | [diff] [blame] | 103 | SDHCI_QUIRK_BROKEN_CARD_DETECTION | |
Pierre Ossman | ee53ab5 | 2008-07-05 00:25:15 +0200 | [diff] [blame] | 104 | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL, |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 105 | }; |
| 106 | |
Derek Browne | 43e968c | 2014-06-24 06:56:36 -0700 | [diff] [blame] | 107 | static const struct sdhci_pci_fixes sdhci_intel_qrk = { |
| 108 | .quirks = SDHCI_QUIRK_NO_HISPD_BIT, |
| 109 | }; |
| 110 | |
Major Lee | 68077b0 | 2011-06-29 14:23:46 +0300 | [diff] [blame] | 111 | static int mrst_hc_probe_slot(struct sdhci_pci_slot *slot) |
| 112 | { |
| 113 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA; |
| 114 | return 0; |
| 115 | } |
| 116 | |
Alan Cox | f9ee3ea | 2010-10-04 15:25:11 +0100 | [diff] [blame] | 117 | /* |
| 118 | * ADMA operation is disabled for Moorestown platform due to |
| 119 | * hardware bugs. |
| 120 | */ |
Jacob Pan | 35ac6f0 | 2010-11-09 13:57:29 +0000 | [diff] [blame] | 121 | static int mrst_hc_probe(struct sdhci_pci_chip *chip) |
Alan Cox | f9ee3ea | 2010-10-04 15:25:11 +0100 | [diff] [blame] | 122 | { |
| 123 | /* |
Jacob Pan | 35ac6f0 | 2010-11-09 13:57:29 +0000 | [diff] [blame] | 124 | * slots number is fixed here for MRST as SDIO3/5 are never used and |
| 125 | * have hardware bugs. |
Alan Cox | f9ee3ea | 2010-10-04 15:25:11 +0100 | [diff] [blame] | 126 | */ |
| 127 | chip->num_slots = 1; |
| 128 | return 0; |
| 129 | } |
| 130 | |
Alexander Stein | 296e0b0 | 2012-03-14 08:38:58 +0100 | [diff] [blame] | 131 | static int pch_hc_probe_slot(struct sdhci_pci_slot *slot) |
| 132 | { |
| 133 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA; |
| 134 | return 0; |
| 135 | } |
| 136 | |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 137 | #ifdef CONFIG_PM_RUNTIME |
| 138 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 139 | static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id) |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 140 | { |
| 141 | struct sdhci_pci_slot *slot = dev_id; |
| 142 | struct sdhci_host *host = slot->host; |
| 143 | |
| 144 | mmc_detect_change(host->mmc, msecs_to_jiffies(200)); |
| 145 | return IRQ_HANDLED; |
| 146 | } |
| 147 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 148 | static void sdhci_pci_add_own_cd(struct sdhci_pci_slot *slot) |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 149 | { |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 150 | int err, irq, gpio = slot->cd_gpio; |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 151 | |
| 152 | slot->cd_gpio = -EINVAL; |
| 153 | slot->cd_irq = -EINVAL; |
| 154 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 155 | if (!gpio_is_valid(gpio)) |
| 156 | return; |
| 157 | |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 158 | err = gpio_request(gpio, "sd_cd"); |
| 159 | if (err < 0) |
| 160 | goto out; |
| 161 | |
| 162 | err = gpio_direction_input(gpio); |
| 163 | if (err < 0) |
| 164 | goto out_free; |
| 165 | |
| 166 | irq = gpio_to_irq(gpio); |
| 167 | if (irq < 0) |
| 168 | goto out_free; |
| 169 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 170 | err = request_irq(irq, sdhci_pci_sd_cd, IRQF_TRIGGER_RISING | |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 171 | IRQF_TRIGGER_FALLING, "sd_cd", slot); |
| 172 | if (err) |
| 173 | goto out_free; |
| 174 | |
| 175 | slot->cd_gpio = gpio; |
| 176 | slot->cd_irq = irq; |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 177 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 178 | return; |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 179 | |
| 180 | out_free: |
| 181 | gpio_free(gpio); |
| 182 | out: |
| 183 | dev_warn(&slot->chip->pdev->dev, "failed to setup card detect wake up\n"); |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 184 | } |
| 185 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 186 | static void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot) |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 187 | { |
| 188 | if (slot->cd_irq >= 0) |
| 189 | free_irq(slot->cd_irq, slot); |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 190 | if (gpio_is_valid(slot->cd_gpio)) |
| 191 | gpio_free(slot->cd_gpio); |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | #else |
| 195 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 196 | static inline void sdhci_pci_add_own_cd(struct sdhci_pci_slot *slot) |
| 197 | { |
| 198 | } |
| 199 | |
| 200 | static inline void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot) |
| 201 | { |
| 202 | } |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 203 | |
| 204 | #endif |
| 205 | |
Adrian Hunter | 0d013bc | 2011-06-29 14:23:47 +0300 | [diff] [blame] | 206 | static int mfd_emmc_probe_slot(struct sdhci_pci_slot *slot) |
| 207 | { |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 208 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE; |
Adrian Hunter | da721cf | 2012-02-07 14:48:53 +0200 | [diff] [blame] | 209 | slot->host->mmc->caps2 |= MMC_CAP2_BOOTPART_NOACC | |
| 210 | MMC_CAP2_HC_ERASE_SZ; |
Adrian Hunter | 0d013bc | 2011-06-29 14:23:47 +0300 | [diff] [blame] | 211 | return 0; |
| 212 | } |
| 213 | |
Adrian Hunter | 9393350 | 2011-12-27 15:48:47 +0200 | [diff] [blame] | 214 | static int mfd_sdio_probe_slot(struct sdhci_pci_slot *slot) |
| 215 | { |
Adrian Hunter | 012e467 | 2012-01-30 14:27:18 +0200 | [diff] [blame] | 216 | slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE; |
Adrian Hunter | 9393350 | 2011-12-27 15:48:47 +0200 | [diff] [blame] | 217 | return 0; |
| 218 | } |
| 219 | |
Alan Cox | f9ee3ea | 2010-10-04 15:25:11 +0100 | [diff] [blame] | 220 | static const struct sdhci_pci_fixes sdhci_intel_mrst_hc0 = { |
| 221 | .quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_NO_HISPD_BIT, |
Major Lee | 68077b0 | 2011-06-29 14:23:46 +0300 | [diff] [blame] | 222 | .probe_slot = mrst_hc_probe_slot, |
Alan Cox | f9ee3ea | 2010-10-04 15:25:11 +0100 | [diff] [blame] | 223 | }; |
| 224 | |
Jacob Pan | 35ac6f0 | 2010-11-09 13:57:29 +0000 | [diff] [blame] | 225 | static const struct sdhci_pci_fixes sdhci_intel_mrst_hc1_hc2 = { |
Alan Cox | f9ee3ea | 2010-10-04 15:25:11 +0100 | [diff] [blame] | 226 | .quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_NO_HISPD_BIT, |
Jacob Pan | 35ac6f0 | 2010-11-09 13:57:29 +0000 | [diff] [blame] | 227 | .probe = mrst_hc_probe, |
Alan Cox | f9ee3ea | 2010-10-04 15:25:11 +0100 | [diff] [blame] | 228 | }; |
| 229 | |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 230 | static const struct sdhci_pci_fixes sdhci_intel_mfd_sd = { |
| 231 | .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, |
Adrian Hunter | c43fd77 | 2011-10-17 10:52:44 +0300 | [diff] [blame] | 232 | .allow_runtime_pm = true, |
Adrian Hunter | 77a0122 | 2014-01-13 09:49:16 +0200 | [diff] [blame] | 233 | .own_cd_for_runtime_pm = true, |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 234 | }; |
| 235 | |
Adrian Hunter | 0d013bc | 2011-06-29 14:23:47 +0300 | [diff] [blame] | 236 | static const struct sdhci_pci_fixes sdhci_intel_mfd_sdio = { |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 237 | .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, |
Adrian Hunter | f3c55a7 | 2012-02-07 14:48:55 +0200 | [diff] [blame] | 238 | .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON, |
Adrian Hunter | c43fd77 | 2011-10-17 10:52:44 +0300 | [diff] [blame] | 239 | .allow_runtime_pm = true, |
Adrian Hunter | 9393350 | 2011-12-27 15:48:47 +0200 | [diff] [blame] | 240 | .probe_slot = mfd_sdio_probe_slot, |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 241 | }; |
| 242 | |
Adrian Hunter | 0d013bc | 2011-06-29 14:23:47 +0300 | [diff] [blame] | 243 | static const struct sdhci_pci_fixes sdhci_intel_mfd_emmc = { |
| 244 | .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, |
Adrian Hunter | c43fd77 | 2011-10-17 10:52:44 +0300 | [diff] [blame] | 245 | .allow_runtime_pm = true, |
Adrian Hunter | 0d013bc | 2011-06-29 14:23:47 +0300 | [diff] [blame] | 246 | .probe_slot = mfd_emmc_probe_slot, |
| 247 | }; |
| 248 | |
Alexander Stein | 296e0b0 | 2012-03-14 08:38:58 +0100 | [diff] [blame] | 249 | static const struct sdhci_pci_fixes sdhci_intel_pch_sdio = { |
| 250 | .quirks = SDHCI_QUIRK_BROKEN_ADMA, |
| 251 | .probe_slot = pch_hc_probe_slot, |
| 252 | }; |
| 253 | |
Adrian Hunter | c9faff6 | 2013-06-13 11:50:26 +0300 | [diff] [blame] | 254 | static void sdhci_pci_int_hw_reset(struct sdhci_host *host) |
| 255 | { |
| 256 | u8 reg; |
| 257 | |
| 258 | reg = sdhci_readb(host, SDHCI_POWER_CONTROL); |
| 259 | reg |= 0x10; |
| 260 | sdhci_writeb(host, reg, SDHCI_POWER_CONTROL); |
| 261 | /* For eMMC, minimum is 1us but give it 9us for good measure */ |
| 262 | udelay(9); |
| 263 | reg &= ~0x10; |
| 264 | sdhci_writeb(host, reg, SDHCI_POWER_CONTROL); |
| 265 | /* For eMMC, minimum is 200us but give it 300us for good measure */ |
| 266 | usleep_range(300, 1000); |
| 267 | } |
| 268 | |
Adrian Hunter | 728ef3d | 2013-04-26 11:27:23 +0300 | [diff] [blame] | 269 | static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot) |
| 270 | { |
Adrian Hunter | c9faff6 | 2013-06-13 11:50:26 +0300 | [diff] [blame] | 271 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE | |
Maurice Petallo | f25c337 | 2014-07-08 19:11:01 +0800 | [diff] [blame] | 272 | MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR; |
Adrian Hunter | 728ef3d | 2013-04-26 11:27:23 +0300 | [diff] [blame] | 273 | slot->host->mmc->caps2 |= MMC_CAP2_HC_ERASE_SZ; |
Adrian Hunter | c9faff6 | 2013-06-13 11:50:26 +0300 | [diff] [blame] | 274 | slot->hw_reset = sdhci_pci_int_hw_reset; |
Adrian Hunter | 728ef3d | 2013-04-26 11:27:23 +0300 | [diff] [blame] | 275 | return 0; |
| 276 | } |
| 277 | |
| 278 | static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot) |
| 279 | { |
| 280 | slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE; |
| 281 | return 0; |
| 282 | } |
| 283 | |
Adrian Hunter | ff59c52 | 2014-09-24 10:27:31 +0300 | [diff] [blame] | 284 | static int byt_sd_probe_slot(struct sdhci_pci_slot *slot) |
| 285 | { |
| 286 | slot->cd_con_id = NULL; |
| 287 | slot->cd_idx = 0; |
| 288 | slot->cd_override_level = true; |
| 289 | return 0; |
| 290 | } |
| 291 | |
Adrian Hunter | 728ef3d | 2013-04-26 11:27:23 +0300 | [diff] [blame] | 292 | static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = { |
| 293 | .allow_runtime_pm = true, |
| 294 | .probe_slot = byt_emmc_probe_slot, |
Adrian Hunter | e58e4a0 | 2014-09-24 10:27:30 +0300 | [diff] [blame] | 295 | .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | |
| 296 | SDHCI_QUIRK2_STOP_WITH_TC, |
Adrian Hunter | 728ef3d | 2013-04-26 11:27:23 +0300 | [diff] [blame] | 297 | }; |
| 298 | |
| 299 | static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = { |
Gao, Yunpeng | b7574ba | 2014-09-04 15:18:05 +0800 | [diff] [blame] | 300 | .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON | |
| 301 | SDHCI_QUIRK2_PRESET_VALUE_BROKEN, |
Adrian Hunter | 728ef3d | 2013-04-26 11:27:23 +0300 | [diff] [blame] | 302 | .allow_runtime_pm = true, |
| 303 | .probe_slot = byt_sdio_probe_slot, |
| 304 | }; |
| 305 | |
| 306 | static const struct sdhci_pci_fixes sdhci_intel_byt_sd = { |
Gao, Yunpeng | b7574ba | 2014-09-04 15:18:05 +0800 | [diff] [blame] | 307 | .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON | |
Adrian Hunter | e58e4a0 | 2014-09-24 10:27:30 +0300 | [diff] [blame] | 308 | SDHCI_QUIRK2_PRESET_VALUE_BROKEN | |
| 309 | SDHCI_QUIRK2_STOP_WITH_TC, |
Adrian Hunter | 7396e31 | 2013-05-06 12:17:34 +0300 | [diff] [blame] | 310 | .allow_runtime_pm = true, |
Adrian Hunter | 77a0122 | 2014-01-13 09:49:16 +0200 | [diff] [blame] | 311 | .own_cd_for_runtime_pm = true, |
Adrian Hunter | ff59c52 | 2014-09-24 10:27:31 +0300 | [diff] [blame] | 312 | .probe_slot = byt_sd_probe_slot, |
Adrian Hunter | 728ef3d | 2013-04-26 11:27:23 +0300 | [diff] [blame] | 313 | }; |
| 314 | |
David Cohen | 8776a16 | 2013-10-01 13:18:15 -0700 | [diff] [blame] | 315 | /* Define Host controllers for Intel Merrifield platform */ |
| 316 | #define INTEL_MRFL_EMMC_0 0 |
| 317 | #define INTEL_MRFL_EMMC_1 1 |
| 318 | |
| 319 | static int intel_mrfl_mmc_probe_slot(struct sdhci_pci_slot *slot) |
| 320 | { |
| 321 | if ((PCI_FUNC(slot->chip->pdev->devfn) != INTEL_MRFL_EMMC_0) && |
| 322 | (PCI_FUNC(slot->chip->pdev->devfn) != INTEL_MRFL_EMMC_1)) |
| 323 | /* SD support is not ready yet */ |
| 324 | return -ENODEV; |
| 325 | |
| 326 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE | |
| 327 | MMC_CAP_1_8V_DDR; |
| 328 | |
| 329 | return 0; |
| 330 | } |
| 331 | |
| 332 | static const struct sdhci_pci_fixes sdhci_intel_mrfl_mmc = { |
| 333 | .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, |
Gao, Yunpeng | b7574ba | 2014-09-04 15:18:05 +0800 | [diff] [blame] | 334 | .quirks2 = SDHCI_QUIRK2_BROKEN_HS200 | |
| 335 | SDHCI_QUIRK2_PRESET_VALUE_BROKEN, |
Gao, Yunpeng | f1b55a5 | 2014-08-18 15:05:52 +0800 | [diff] [blame] | 336 | .allow_runtime_pm = true, |
David Cohen | 8776a16 | 2013-10-01 13:18:15 -0700 | [diff] [blame] | 337 | .probe_slot = intel_mrfl_mmc_probe_slot, |
| 338 | }; |
| 339 | |
Jennifer Li | 26daa1e | 2010-11-17 23:01:59 -0500 | [diff] [blame] | 340 | /* O2Micro extra registers */ |
| 341 | #define O2_SD_LOCK_WP 0xD3 |
| 342 | #define O2_SD_MULTI_VCC3V 0xEE |
| 343 | #define O2_SD_CLKREQ 0xEC |
| 344 | #define O2_SD_CAPS 0xE0 |
| 345 | #define O2_SD_ADMA1 0xE2 |
| 346 | #define O2_SD_ADMA2 0xE7 |
| 347 | #define O2_SD_INF_MOD 0xF1 |
| 348 | |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 349 | static int jmicron_pmos(struct sdhci_pci_chip *chip, int on) |
| 350 | { |
| 351 | u8 scratch; |
| 352 | int ret; |
| 353 | |
| 354 | ret = pci_read_config_byte(chip->pdev, 0xAE, &scratch); |
| 355 | if (ret) |
| 356 | return ret; |
| 357 | |
| 358 | /* |
| 359 | * Turn PMOS on [bit 0], set over current detection to 2.4 V |
| 360 | * [bit 1:2] and enable over current debouncing [bit 6]. |
| 361 | */ |
| 362 | if (on) |
| 363 | scratch |= 0x47; |
| 364 | else |
| 365 | scratch &= ~0x47; |
| 366 | |
| 367 | ret = pci_write_config_byte(chip->pdev, 0xAE, scratch); |
| 368 | if (ret) |
| 369 | return ret; |
| 370 | |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | static int jmicron_probe(struct sdhci_pci_chip *chip) |
| 375 | { |
| 376 | int ret; |
Takashi Iwai | 8f230f4 | 2010-12-08 10:04:30 +0100 | [diff] [blame] | 377 | u16 mmcdev = 0; |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 378 | |
Pierre Ossman | 93fc48c | 2008-06-28 18:21:41 +0200 | [diff] [blame] | 379 | if (chip->pdev->revision == 0) { |
| 380 | chip->quirks |= SDHCI_QUIRK_32BIT_DMA_ADDR | |
| 381 | SDHCI_QUIRK_32BIT_DMA_SIZE | |
Pierre Ossman | 2134a92 | 2008-06-28 18:28:51 +0200 | [diff] [blame] | 382 | SDHCI_QUIRK_32BIT_ADMA_SIZE | |
Pierre Ossman | 4a3cba3 | 2008-07-29 00:11:16 +0200 | [diff] [blame] | 383 | SDHCI_QUIRK_RESET_AFTER_REQUEST | |
Pierre Ossman | 86a6a87 | 2009-02-02 21:13:49 +0100 | [diff] [blame] | 384 | SDHCI_QUIRK_BROKEN_SMALL_PIO; |
Pierre Ossman | 93fc48c | 2008-06-28 18:21:41 +0200 | [diff] [blame] | 385 | } |
| 386 | |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 387 | /* |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 388 | * JMicron chips can have two interfaces to the same hardware |
| 389 | * in order to work around limitations in Microsoft's driver. |
| 390 | * We need to make sure we only bind to one of them. |
| 391 | * |
| 392 | * This code assumes two things: |
| 393 | * |
| 394 | * 1. The PCI code adds subfunctions in order. |
| 395 | * |
| 396 | * 2. The MMC interface has a lower subfunction number |
| 397 | * than the SD interface. |
| 398 | */ |
Takashi Iwai | 8f230f4 | 2010-12-08 10:04:30 +0100 | [diff] [blame] | 399 | if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_SD) |
| 400 | mmcdev = PCI_DEVICE_ID_JMICRON_JMB38X_MMC; |
| 401 | else if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_SD) |
| 402 | mmcdev = PCI_DEVICE_ID_JMICRON_JMB388_ESD; |
| 403 | |
| 404 | if (mmcdev) { |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 405 | struct pci_dev *sd_dev; |
| 406 | |
| 407 | sd_dev = NULL; |
| 408 | while ((sd_dev = pci_get_device(PCI_VENDOR_ID_JMICRON, |
Takashi Iwai | 8f230f4 | 2010-12-08 10:04:30 +0100 | [diff] [blame] | 409 | mmcdev, sd_dev)) != NULL) { |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 410 | if ((PCI_SLOT(chip->pdev->devfn) == |
| 411 | PCI_SLOT(sd_dev->devfn)) && |
| 412 | (chip->pdev->bus == sd_dev->bus)) |
| 413 | break; |
| 414 | } |
| 415 | |
| 416 | if (sd_dev) { |
| 417 | pci_dev_put(sd_dev); |
| 418 | dev_info(&chip->pdev->dev, "Refusing to bind to " |
| 419 | "secondary interface.\n"); |
| 420 | return -ENODEV; |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | /* |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 425 | * JMicron chips need a bit of a nudge to enable the power |
| 426 | * output pins. |
| 427 | */ |
| 428 | ret = jmicron_pmos(chip, 1); |
| 429 | if (ret) { |
| 430 | dev_err(&chip->pdev->dev, "Failure enabling card power\n"); |
| 431 | return ret; |
| 432 | } |
| 433 | |
Takashi Iwai | 82b0e23 | 2011-04-21 20:26:38 +0200 | [diff] [blame] | 434 | /* quirk for unsable RO-detection on JM388 chips */ |
| 435 | if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_SD || |
| 436 | chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) |
| 437 | chip->quirks |= SDHCI_QUIRK_UNSTABLE_RO_DETECT; |
| 438 | |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 439 | return 0; |
| 440 | } |
| 441 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 442 | static void jmicron_enable_mmc(struct sdhci_host *host, int on) |
| 443 | { |
| 444 | u8 scratch; |
| 445 | |
| 446 | scratch = readb(host->ioaddr + 0xC0); |
| 447 | |
| 448 | if (on) |
| 449 | scratch |= 0x01; |
| 450 | else |
| 451 | scratch &= ~0x01; |
| 452 | |
| 453 | writeb(scratch, host->ioaddr + 0xC0); |
| 454 | } |
| 455 | |
| 456 | static int jmicron_probe_slot(struct sdhci_pci_slot *slot) |
| 457 | { |
Pierre Ossman | 2134a92 | 2008-06-28 18:28:51 +0200 | [diff] [blame] | 458 | if (slot->chip->pdev->revision == 0) { |
| 459 | u16 version; |
| 460 | |
| 461 | version = readl(slot->host->ioaddr + SDHCI_HOST_VERSION); |
| 462 | version = (version & SDHCI_VENDOR_VER_MASK) >> |
| 463 | SDHCI_VENDOR_VER_SHIFT; |
| 464 | |
| 465 | /* |
| 466 | * Older versions of the chip have lots of nasty glitches |
| 467 | * in the ADMA engine. It's best just to avoid it |
| 468 | * completely. |
| 469 | */ |
| 470 | if (version < 0xAC) |
| 471 | slot->host->quirks |= SDHCI_QUIRK_BROKEN_ADMA; |
| 472 | } |
| 473 | |
Takashi Iwai | 8f230f4 | 2010-12-08 10:04:30 +0100 | [diff] [blame] | 474 | /* JM388 MMC doesn't support 1.8V while SD supports it */ |
| 475 | if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) { |
| 476 | slot->host->ocr_avail_sd = MMC_VDD_32_33 | MMC_VDD_33_34 | |
| 477 | MMC_VDD_29_30 | MMC_VDD_30_31 | |
| 478 | MMC_VDD_165_195; /* allow 1.8V */ |
| 479 | slot->host->ocr_avail_mmc = MMC_VDD_32_33 | MMC_VDD_33_34 | |
| 480 | MMC_VDD_29_30 | MMC_VDD_30_31; /* no 1.8V for MMC */ |
| 481 | } |
| 482 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 483 | /* |
| 484 | * The secondary interface requires a bit set to get the |
| 485 | * interrupts. |
| 486 | */ |
Takashi Iwai | 8f230f4 | 2010-12-08 10:04:30 +0100 | [diff] [blame] | 487 | if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || |
| 488 | slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 489 | jmicron_enable_mmc(slot->host, 1); |
| 490 | |
Takashi Iwai | d75c108 | 2010-12-16 17:54:14 +0100 | [diff] [blame] | 491 | slot->host->mmc->caps |= MMC_CAP_BUS_WIDTH_TEST; |
| 492 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 493 | return 0; |
| 494 | } |
| 495 | |
Pierre Ossman | 1e72859 | 2008-04-16 19:13:13 +0200 | [diff] [blame] | 496 | static void jmicron_remove_slot(struct sdhci_pci_slot *slot, int dead) |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 497 | { |
Pierre Ossman | 1e72859 | 2008-04-16 19:13:13 +0200 | [diff] [blame] | 498 | if (dead) |
| 499 | return; |
| 500 | |
Takashi Iwai | 8f230f4 | 2010-12-08 10:04:30 +0100 | [diff] [blame] | 501 | if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || |
| 502 | slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 503 | jmicron_enable_mmc(slot->host, 0); |
| 504 | } |
| 505 | |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 506 | static int jmicron_suspend(struct sdhci_pci_chip *chip) |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 507 | { |
| 508 | int i; |
| 509 | |
Takashi Iwai | 8f230f4 | 2010-12-08 10:04:30 +0100 | [diff] [blame] | 510 | if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || |
| 511 | chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) { |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 512 | for (i = 0; i < chip->num_slots; i++) |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 513 | jmicron_enable_mmc(chip->slots[i]->host, 0); |
| 514 | } |
| 515 | |
| 516 | return 0; |
| 517 | } |
| 518 | |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 519 | static int jmicron_resume(struct sdhci_pci_chip *chip) |
| 520 | { |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 521 | int ret, i; |
| 522 | |
Takashi Iwai | 8f230f4 | 2010-12-08 10:04:30 +0100 | [diff] [blame] | 523 | if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || |
| 524 | chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) { |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 525 | for (i = 0; i < chip->num_slots; i++) |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 526 | jmicron_enable_mmc(chip->slots[i]->host, 1); |
| 527 | } |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 528 | |
| 529 | ret = jmicron_pmos(chip, 1); |
| 530 | if (ret) { |
| 531 | dev_err(&chip->pdev->dev, "Failure enabling card power\n"); |
| 532 | return ret; |
| 533 | } |
| 534 | |
| 535 | return 0; |
| 536 | } |
| 537 | |
Jennifer Li | 26daa1e | 2010-11-17 23:01:59 -0500 | [diff] [blame] | 538 | static const struct sdhci_pci_fixes sdhci_o2 = { |
Adam Lee | 01acf69 | 2013-12-19 00:01:26 +0800 | [diff] [blame] | 539 | .probe = sdhci_pci_o2_probe, |
| 540 | .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, |
| 541 | .probe_slot = sdhci_pci_o2_probe_slot, |
| 542 | .resume = sdhci_pci_o2_resume, |
Jennifer Li | 26daa1e | 2010-11-17 23:01:59 -0500 | [diff] [blame] | 543 | }; |
| 544 | |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 545 | static const struct sdhci_pci_fixes sdhci_jmicron = { |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 546 | .probe = jmicron_probe, |
| 547 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 548 | .probe_slot = jmicron_probe_slot, |
| 549 | .remove_slot = jmicron_remove_slot, |
| 550 | |
| 551 | .suspend = jmicron_suspend, |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 552 | .resume = jmicron_resume, |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 553 | }; |
| 554 | |
Nicolas Pitre | a7a6186 | 2009-12-14 18:01:26 -0800 | [diff] [blame] | 555 | /* SysKonnect CardBus2SDIO extra registers */ |
| 556 | #define SYSKT_CTRL 0x200 |
| 557 | #define SYSKT_RDFIFO_STAT 0x204 |
| 558 | #define SYSKT_WRFIFO_STAT 0x208 |
| 559 | #define SYSKT_POWER_DATA 0x20c |
| 560 | #define SYSKT_POWER_330 0xef |
| 561 | #define SYSKT_POWER_300 0xf8 |
| 562 | #define SYSKT_POWER_184 0xcc |
| 563 | #define SYSKT_POWER_CMD 0x20d |
| 564 | #define SYSKT_POWER_START (1 << 7) |
| 565 | #define SYSKT_POWER_STATUS 0x20e |
| 566 | #define SYSKT_POWER_STATUS_OK (1 << 0) |
| 567 | #define SYSKT_BOARD_REV 0x210 |
| 568 | #define SYSKT_CHIP_REV 0x211 |
| 569 | #define SYSKT_CONF_DATA 0x212 |
| 570 | #define SYSKT_CONF_DATA_1V8 (1 << 2) |
| 571 | #define SYSKT_CONF_DATA_2V5 (1 << 1) |
| 572 | #define SYSKT_CONF_DATA_3V3 (1 << 0) |
| 573 | |
| 574 | static int syskt_probe(struct sdhci_pci_chip *chip) |
| 575 | { |
| 576 | if ((chip->pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) { |
| 577 | chip->pdev->class &= ~0x0000FF; |
| 578 | chip->pdev->class |= PCI_SDHCI_IFDMA; |
| 579 | } |
| 580 | return 0; |
| 581 | } |
| 582 | |
| 583 | static int syskt_probe_slot(struct sdhci_pci_slot *slot) |
| 584 | { |
| 585 | int tm, ps; |
| 586 | |
| 587 | u8 board_rev = readb(slot->host->ioaddr + SYSKT_BOARD_REV); |
| 588 | u8 chip_rev = readb(slot->host->ioaddr + SYSKT_CHIP_REV); |
| 589 | dev_info(&slot->chip->pdev->dev, "SysKonnect CardBus2SDIO, " |
| 590 | "board rev %d.%d, chip rev %d.%d\n", |
| 591 | board_rev >> 4, board_rev & 0xf, |
| 592 | chip_rev >> 4, chip_rev & 0xf); |
| 593 | if (chip_rev >= 0x20) |
| 594 | slot->host->quirks |= SDHCI_QUIRK_FORCE_DMA; |
| 595 | |
| 596 | writeb(SYSKT_POWER_330, slot->host->ioaddr + SYSKT_POWER_DATA); |
| 597 | writeb(SYSKT_POWER_START, slot->host->ioaddr + SYSKT_POWER_CMD); |
| 598 | udelay(50); |
| 599 | tm = 10; /* Wait max 1 ms */ |
| 600 | do { |
| 601 | ps = readw(slot->host->ioaddr + SYSKT_POWER_STATUS); |
| 602 | if (ps & SYSKT_POWER_STATUS_OK) |
| 603 | break; |
| 604 | udelay(100); |
| 605 | } while (--tm); |
| 606 | if (!tm) { |
| 607 | dev_err(&slot->chip->pdev->dev, |
| 608 | "power regulator never stabilized"); |
| 609 | writeb(0, slot->host->ioaddr + SYSKT_POWER_CMD); |
| 610 | return -ENODEV; |
| 611 | } |
| 612 | |
| 613 | return 0; |
| 614 | } |
| 615 | |
| 616 | static const struct sdhci_pci_fixes sdhci_syskt = { |
| 617 | .quirks = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER, |
| 618 | .probe = syskt_probe, |
| 619 | .probe_slot = syskt_probe_slot, |
| 620 | }; |
| 621 | |
Harald Welte | 557b069 | 2009-06-18 16:53:38 +0200 | [diff] [blame] | 622 | static int via_probe(struct sdhci_pci_chip *chip) |
| 623 | { |
| 624 | if (chip->pdev->revision == 0x10) |
| 625 | chip->quirks |= SDHCI_QUIRK_DELAY_AFTER_POWER; |
| 626 | |
| 627 | return 0; |
| 628 | } |
| 629 | |
| 630 | static const struct sdhci_pci_fixes sdhci_via = { |
| 631 | .probe = via_probe, |
| 632 | }; |
| 633 | |
Micky Ching | 9107ebb | 2014-02-21 18:40:35 +0800 | [diff] [blame] | 634 | static int rtsx_probe_slot(struct sdhci_pci_slot *slot) |
| 635 | { |
| 636 | slot->host->mmc->caps2 |= MMC_CAP2_HS200; |
| 637 | return 0; |
| 638 | } |
| 639 | |
| 640 | static const struct sdhci_pci_fixes sdhci_rtsx = { |
| 641 | .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | |
| 642 | SDHCI_QUIRK2_BROKEN_DDR50, |
| 643 | .probe_slot = rtsx_probe_slot, |
| 644 | }; |
| 645 | |
Bill Pemberton | 9647f84 | 2012-11-19 13:25:11 -0500 | [diff] [blame] | 646 | static const struct pci_device_id pci_ids[] = { |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 647 | { |
| 648 | .vendor = PCI_VENDOR_ID_RICOH, |
| 649 | .device = PCI_DEVICE_ID_RICOH_R5C822, |
| 650 | .subvendor = PCI_ANY_ID, |
| 651 | .subdevice = PCI_ANY_ID, |
| 652 | .driver_data = (kernel_ulong_t)&sdhci_ricoh, |
| 653 | }, |
| 654 | |
| 655 | { |
Maxim Levitsky | ccc92c2 | 2010-08-10 18:01:42 -0700 | [diff] [blame] | 656 | .vendor = PCI_VENDOR_ID_RICOH, |
| 657 | .device = 0x843, |
| 658 | .subvendor = PCI_ANY_ID, |
| 659 | .subdevice = PCI_ANY_ID, |
| 660 | .driver_data = (kernel_ulong_t)&sdhci_ricoh_mmc, |
| 661 | }, |
| 662 | |
| 663 | { |
Pablo Castillo | 568133e | 2010-08-10 18:02:01 -0700 | [diff] [blame] | 664 | .vendor = PCI_VENDOR_ID_RICOH, |
| 665 | .device = 0xe822, |
| 666 | .subvendor = PCI_ANY_ID, |
| 667 | .subdevice = PCI_ANY_ID, |
| 668 | .driver_data = (kernel_ulong_t)&sdhci_ricoh_mmc, |
| 669 | }, |
| 670 | |
| 671 | { |
Manoj Iyer | 5fd11c0 | 2011-02-11 16:25:31 -0600 | [diff] [blame] | 672 | .vendor = PCI_VENDOR_ID_RICOH, |
| 673 | .device = 0xe823, |
| 674 | .subvendor = PCI_ANY_ID, |
| 675 | .subdevice = PCI_ANY_ID, |
| 676 | .driver_data = (kernel_ulong_t)&sdhci_ricoh_mmc, |
| 677 | }, |
| 678 | |
| 679 | { |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 680 | .vendor = PCI_VENDOR_ID_ENE, |
| 681 | .device = PCI_DEVICE_ID_ENE_CB712_SD, |
| 682 | .subvendor = PCI_ANY_ID, |
| 683 | .subdevice = PCI_ANY_ID, |
| 684 | .driver_data = (kernel_ulong_t)&sdhci_ene_712, |
| 685 | }, |
| 686 | |
| 687 | { |
| 688 | .vendor = PCI_VENDOR_ID_ENE, |
| 689 | .device = PCI_DEVICE_ID_ENE_CB712_SD_2, |
| 690 | .subvendor = PCI_ANY_ID, |
| 691 | .subdevice = PCI_ANY_ID, |
| 692 | .driver_data = (kernel_ulong_t)&sdhci_ene_712, |
| 693 | }, |
| 694 | |
| 695 | { |
| 696 | .vendor = PCI_VENDOR_ID_ENE, |
| 697 | .device = PCI_DEVICE_ID_ENE_CB714_SD, |
| 698 | .subvendor = PCI_ANY_ID, |
| 699 | .subdevice = PCI_ANY_ID, |
| 700 | .driver_data = (kernel_ulong_t)&sdhci_ene_714, |
| 701 | }, |
| 702 | |
| 703 | { |
| 704 | .vendor = PCI_VENDOR_ID_ENE, |
| 705 | .device = PCI_DEVICE_ID_ENE_CB714_SD_2, |
| 706 | .subvendor = PCI_ANY_ID, |
| 707 | .subdevice = PCI_ANY_ID, |
| 708 | .driver_data = (kernel_ulong_t)&sdhci_ene_714, |
| 709 | }, |
| 710 | |
| 711 | { |
| 712 | .vendor = PCI_VENDOR_ID_MARVELL, |
David Woodhouse | 8c5eb88 | 2008-09-03 09:45:57 +0100 | [diff] [blame] | 713 | .device = PCI_DEVICE_ID_MARVELL_88ALP01_SD, |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 714 | .subvendor = PCI_ANY_ID, |
| 715 | .subdevice = PCI_ANY_ID, |
| 716 | .driver_data = (kernel_ulong_t)&sdhci_cafe, |
| 717 | }, |
| 718 | |
| 719 | { |
| 720 | .vendor = PCI_VENDOR_ID_JMICRON, |
| 721 | .device = PCI_DEVICE_ID_JMICRON_JMB38X_SD, |
| 722 | .subvendor = PCI_ANY_ID, |
| 723 | .subdevice = PCI_ANY_ID, |
| 724 | .driver_data = (kernel_ulong_t)&sdhci_jmicron, |
| 725 | }, |
| 726 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 727 | { |
| 728 | .vendor = PCI_VENDOR_ID_JMICRON, |
| 729 | .device = PCI_DEVICE_ID_JMICRON_JMB38X_MMC, |
| 730 | .subvendor = PCI_ANY_ID, |
| 731 | .subdevice = PCI_ANY_ID, |
| 732 | .driver_data = (kernel_ulong_t)&sdhci_jmicron, |
| 733 | }, |
| 734 | |
Harald Welte | 557b069 | 2009-06-18 16:53:38 +0200 | [diff] [blame] | 735 | { |
Takashi Iwai | 8f230f4 | 2010-12-08 10:04:30 +0100 | [diff] [blame] | 736 | .vendor = PCI_VENDOR_ID_JMICRON, |
| 737 | .device = PCI_DEVICE_ID_JMICRON_JMB388_SD, |
| 738 | .subvendor = PCI_ANY_ID, |
| 739 | .subdevice = PCI_ANY_ID, |
| 740 | .driver_data = (kernel_ulong_t)&sdhci_jmicron, |
| 741 | }, |
| 742 | |
| 743 | { |
| 744 | .vendor = PCI_VENDOR_ID_JMICRON, |
| 745 | .device = PCI_DEVICE_ID_JMICRON_JMB388_ESD, |
| 746 | .subvendor = PCI_ANY_ID, |
| 747 | .subdevice = PCI_ANY_ID, |
| 748 | .driver_data = (kernel_ulong_t)&sdhci_jmicron, |
| 749 | }, |
| 750 | |
| 751 | { |
Nicolas Pitre | a7a6186 | 2009-12-14 18:01:26 -0800 | [diff] [blame] | 752 | .vendor = PCI_VENDOR_ID_SYSKONNECT, |
| 753 | .device = 0x8000, |
| 754 | .subvendor = PCI_ANY_ID, |
| 755 | .subdevice = PCI_ANY_ID, |
| 756 | .driver_data = (kernel_ulong_t)&sdhci_syskt, |
| 757 | }, |
| 758 | |
| 759 | { |
Harald Welte | 557b069 | 2009-06-18 16:53:38 +0200 | [diff] [blame] | 760 | .vendor = PCI_VENDOR_ID_VIA, |
| 761 | .device = 0x95d0, |
| 762 | .subvendor = PCI_ANY_ID, |
| 763 | .subdevice = PCI_ANY_ID, |
| 764 | .driver_data = (kernel_ulong_t)&sdhci_via, |
| 765 | }, |
| 766 | |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 767 | { |
Micky Ching | 9107ebb | 2014-02-21 18:40:35 +0800 | [diff] [blame] | 768 | .vendor = PCI_VENDOR_ID_REALTEK, |
| 769 | .device = 0x5250, |
| 770 | .subvendor = PCI_ANY_ID, |
| 771 | .subdevice = PCI_ANY_ID, |
| 772 | .driver_data = (kernel_ulong_t)&sdhci_rtsx, |
| 773 | }, |
| 774 | |
| 775 | { |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 776 | .vendor = PCI_VENDOR_ID_INTEL, |
Derek Browne | 43e968c | 2014-06-24 06:56:36 -0700 | [diff] [blame] | 777 | .device = PCI_DEVICE_ID_INTEL_QRK_SD, |
| 778 | .subvendor = PCI_ANY_ID, |
| 779 | .subdevice = PCI_ANY_ID, |
| 780 | .driver_data = (kernel_ulong_t)&sdhci_intel_qrk, |
| 781 | }, |
| 782 | |
| 783 | { |
| 784 | .vendor = PCI_VENDOR_ID_INTEL, |
Alan Cox | f9ee3ea | 2010-10-04 15:25:11 +0100 | [diff] [blame] | 785 | .device = PCI_DEVICE_ID_INTEL_MRST_SD0, |
| 786 | .subvendor = PCI_ANY_ID, |
| 787 | .subdevice = PCI_ANY_ID, |
| 788 | .driver_data = (kernel_ulong_t)&sdhci_intel_mrst_hc0, |
| 789 | }, |
| 790 | |
| 791 | { |
| 792 | .vendor = PCI_VENDOR_ID_INTEL, |
| 793 | .device = PCI_DEVICE_ID_INTEL_MRST_SD1, |
| 794 | .subvendor = PCI_ANY_ID, |
| 795 | .subdevice = PCI_ANY_ID, |
Jacob Pan | 35ac6f0 | 2010-11-09 13:57:29 +0000 | [diff] [blame] | 796 | .driver_data = (kernel_ulong_t)&sdhci_intel_mrst_hc1_hc2, |
| 797 | }, |
| 798 | |
| 799 | { |
| 800 | .vendor = PCI_VENDOR_ID_INTEL, |
| 801 | .device = PCI_DEVICE_ID_INTEL_MRST_SD2, |
| 802 | .subvendor = PCI_ANY_ID, |
| 803 | .subdevice = PCI_ANY_ID, |
| 804 | .driver_data = (kernel_ulong_t)&sdhci_intel_mrst_hc1_hc2, |
Alan Cox | f9ee3ea | 2010-10-04 15:25:11 +0100 | [diff] [blame] | 805 | }, |
| 806 | |
| 807 | { |
| 808 | .vendor = PCI_VENDOR_ID_INTEL, |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 809 | .device = PCI_DEVICE_ID_INTEL_MFD_SD, |
| 810 | .subvendor = PCI_ANY_ID, |
| 811 | .subdevice = PCI_ANY_ID, |
| 812 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_sd, |
| 813 | }, |
| 814 | |
| 815 | { |
| 816 | .vendor = PCI_VENDOR_ID_INTEL, |
| 817 | .device = PCI_DEVICE_ID_INTEL_MFD_SDIO1, |
| 818 | .subvendor = PCI_ANY_ID, |
| 819 | .subdevice = PCI_ANY_ID, |
Adrian Hunter | 0d013bc | 2011-06-29 14:23:47 +0300 | [diff] [blame] | 820 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_sdio, |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 821 | }, |
| 822 | |
| 823 | { |
| 824 | .vendor = PCI_VENDOR_ID_INTEL, |
| 825 | .device = PCI_DEVICE_ID_INTEL_MFD_SDIO2, |
| 826 | .subvendor = PCI_ANY_ID, |
| 827 | .subdevice = PCI_ANY_ID, |
Adrian Hunter | 0d013bc | 2011-06-29 14:23:47 +0300 | [diff] [blame] | 828 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_sdio, |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 829 | }, |
| 830 | |
| 831 | { |
| 832 | .vendor = PCI_VENDOR_ID_INTEL, |
| 833 | .device = PCI_DEVICE_ID_INTEL_MFD_EMMC0, |
| 834 | .subvendor = PCI_ANY_ID, |
| 835 | .subdevice = PCI_ANY_ID, |
Adrian Hunter | 0d013bc | 2011-06-29 14:23:47 +0300 | [diff] [blame] | 836 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_emmc, |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 837 | }, |
| 838 | |
| 839 | { |
| 840 | .vendor = PCI_VENDOR_ID_INTEL, |
| 841 | .device = PCI_DEVICE_ID_INTEL_MFD_EMMC1, |
| 842 | .subvendor = PCI_ANY_ID, |
| 843 | .subdevice = PCI_ANY_ID, |
Adrian Hunter | 0d013bc | 2011-06-29 14:23:47 +0300 | [diff] [blame] | 844 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_emmc, |
Xiaochen Shen | 2922905 | 2010-10-04 15:24:52 +0100 | [diff] [blame] | 845 | }, |
| 846 | |
Jennifer Li | 26daa1e | 2010-11-17 23:01:59 -0500 | [diff] [blame] | 847 | { |
Alexander Stein | 296e0b0 | 2012-03-14 08:38:58 +0100 | [diff] [blame] | 848 | .vendor = PCI_VENDOR_ID_INTEL, |
| 849 | .device = PCI_DEVICE_ID_INTEL_PCH_SDIO0, |
| 850 | .subvendor = PCI_ANY_ID, |
| 851 | .subdevice = PCI_ANY_ID, |
| 852 | .driver_data = (kernel_ulong_t)&sdhci_intel_pch_sdio, |
| 853 | }, |
| 854 | |
| 855 | { |
| 856 | .vendor = PCI_VENDOR_ID_INTEL, |
| 857 | .device = PCI_DEVICE_ID_INTEL_PCH_SDIO1, |
| 858 | .subvendor = PCI_ANY_ID, |
| 859 | .subdevice = PCI_ANY_ID, |
| 860 | .driver_data = (kernel_ulong_t)&sdhci_intel_pch_sdio, |
| 861 | }, |
| 862 | |
| 863 | { |
Adrian Hunter | 728ef3d | 2013-04-26 11:27:23 +0300 | [diff] [blame] | 864 | .vendor = PCI_VENDOR_ID_INTEL, |
| 865 | .device = PCI_DEVICE_ID_INTEL_BYT_EMMC, |
| 866 | .subvendor = PCI_ANY_ID, |
| 867 | .subdevice = PCI_ANY_ID, |
| 868 | .driver_data = (kernel_ulong_t)&sdhci_intel_byt_emmc, |
| 869 | }, |
| 870 | |
| 871 | { |
| 872 | .vendor = PCI_VENDOR_ID_INTEL, |
| 873 | .device = PCI_DEVICE_ID_INTEL_BYT_SDIO, |
| 874 | .subvendor = PCI_ANY_ID, |
| 875 | .subdevice = PCI_ANY_ID, |
| 876 | .driver_data = (kernel_ulong_t)&sdhci_intel_byt_sdio, |
| 877 | }, |
| 878 | |
| 879 | { |
| 880 | .vendor = PCI_VENDOR_ID_INTEL, |
| 881 | .device = PCI_DEVICE_ID_INTEL_BYT_SD, |
| 882 | .subvendor = PCI_ANY_ID, |
| 883 | .subdevice = PCI_ANY_ID, |
| 884 | .driver_data = (kernel_ulong_t)&sdhci_intel_byt_sd, |
| 885 | }, |
| 886 | |
| 887 | { |
Adrian Hunter | 30d025c | 2013-06-20 12:57:59 +0300 | [diff] [blame] | 888 | .vendor = PCI_VENDOR_ID_INTEL, |
| 889 | .device = PCI_DEVICE_ID_INTEL_BYT_EMMC2, |
| 890 | .subvendor = PCI_ANY_ID, |
| 891 | .subdevice = PCI_ANY_ID, |
| 892 | .driver_data = (kernel_ulong_t)&sdhci_intel_byt_emmc, |
| 893 | }, |
| 894 | |
Alan Cox | 066173b | 2014-08-20 13:27:44 +0300 | [diff] [blame] | 895 | { |
| 896 | .vendor = PCI_VENDOR_ID_INTEL, |
| 897 | .device = PCI_DEVICE_ID_INTEL_BSW_EMMC, |
| 898 | .subvendor = PCI_ANY_ID, |
| 899 | .subdevice = PCI_ANY_ID, |
| 900 | .driver_data = (kernel_ulong_t)&sdhci_intel_byt_emmc, |
| 901 | }, |
| 902 | |
| 903 | { |
| 904 | .vendor = PCI_VENDOR_ID_INTEL, |
| 905 | .device = PCI_DEVICE_ID_INTEL_BSW_SDIO, |
| 906 | .subvendor = PCI_ANY_ID, |
| 907 | .subdevice = PCI_ANY_ID, |
| 908 | .driver_data = (kernel_ulong_t)&sdhci_intel_byt_sdio, |
| 909 | }, |
| 910 | |
| 911 | { |
| 912 | .vendor = PCI_VENDOR_ID_INTEL, |
| 913 | .device = PCI_DEVICE_ID_INTEL_BSW_SD, |
| 914 | .subvendor = PCI_ANY_ID, |
| 915 | .subdevice = PCI_ANY_ID, |
| 916 | .driver_data = (kernel_ulong_t)&sdhci_intel_byt_sd, |
| 917 | }, |
Eric Ernst | d052068 | 2013-10-21 09:54:41 -0700 | [diff] [blame] | 918 | |
| 919 | { |
| 920 | .vendor = PCI_VENDOR_ID_INTEL, |
| 921 | .device = PCI_DEVICE_ID_INTEL_CLV_SDIO0, |
| 922 | .subvendor = PCI_ANY_ID, |
| 923 | .subdevice = PCI_ANY_ID, |
| 924 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_sd, |
| 925 | }, |
| 926 | |
| 927 | { |
| 928 | .vendor = PCI_VENDOR_ID_INTEL, |
| 929 | .device = PCI_DEVICE_ID_INTEL_CLV_SDIO1, |
| 930 | .subvendor = PCI_ANY_ID, |
| 931 | .subdevice = PCI_ANY_ID, |
| 932 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_sdio, |
| 933 | }, |
| 934 | |
| 935 | { |
| 936 | .vendor = PCI_VENDOR_ID_INTEL, |
| 937 | .device = PCI_DEVICE_ID_INTEL_CLV_SDIO2, |
| 938 | .subvendor = PCI_ANY_ID, |
| 939 | .subdevice = PCI_ANY_ID, |
| 940 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_sdio, |
| 941 | }, |
| 942 | |
| 943 | { |
| 944 | .vendor = PCI_VENDOR_ID_INTEL, |
| 945 | .device = PCI_DEVICE_ID_INTEL_CLV_EMMC0, |
| 946 | .subvendor = PCI_ANY_ID, |
| 947 | .subdevice = PCI_ANY_ID, |
| 948 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_emmc, |
| 949 | }, |
| 950 | |
| 951 | { |
| 952 | .vendor = PCI_VENDOR_ID_INTEL, |
| 953 | .device = PCI_DEVICE_ID_INTEL_CLV_EMMC1, |
| 954 | .subvendor = PCI_ANY_ID, |
| 955 | .subdevice = PCI_ANY_ID, |
| 956 | .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_emmc, |
| 957 | }, |
| 958 | |
Adrian Hunter | 30d025c | 2013-06-20 12:57:59 +0300 | [diff] [blame] | 959 | { |
David Cohen | 8776a16 | 2013-10-01 13:18:15 -0700 | [diff] [blame] | 960 | .vendor = PCI_VENDOR_ID_INTEL, |
| 961 | .device = PCI_DEVICE_ID_INTEL_MRFL_MMC, |
| 962 | .subvendor = PCI_ANY_ID, |
| 963 | .subdevice = PCI_ANY_ID, |
| 964 | .driver_data = (kernel_ulong_t)&sdhci_intel_mrfl_mmc, |
| 965 | }, |
| 966 | { |
Jennifer Li | 26daa1e | 2010-11-17 23:01:59 -0500 | [diff] [blame] | 967 | .vendor = PCI_VENDOR_ID_O2, |
| 968 | .device = PCI_DEVICE_ID_O2_8120, |
| 969 | .subvendor = PCI_ANY_ID, |
| 970 | .subdevice = PCI_ANY_ID, |
| 971 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 972 | }, |
| 973 | |
| 974 | { |
| 975 | .vendor = PCI_VENDOR_ID_O2, |
| 976 | .device = PCI_DEVICE_ID_O2_8220, |
| 977 | .subvendor = PCI_ANY_ID, |
| 978 | .subdevice = PCI_ANY_ID, |
| 979 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 980 | }, |
| 981 | |
| 982 | { |
| 983 | .vendor = PCI_VENDOR_ID_O2, |
| 984 | .device = PCI_DEVICE_ID_O2_8221, |
| 985 | .subvendor = PCI_ANY_ID, |
| 986 | .subdevice = PCI_ANY_ID, |
| 987 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 988 | }, |
| 989 | |
| 990 | { |
| 991 | .vendor = PCI_VENDOR_ID_O2, |
| 992 | .device = PCI_DEVICE_ID_O2_8320, |
| 993 | .subvendor = PCI_ANY_ID, |
| 994 | .subdevice = PCI_ANY_ID, |
| 995 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 996 | }, |
| 997 | |
| 998 | { |
| 999 | .vendor = PCI_VENDOR_ID_O2, |
| 1000 | .device = PCI_DEVICE_ID_O2_8321, |
| 1001 | .subvendor = PCI_ANY_ID, |
| 1002 | .subdevice = PCI_ANY_ID, |
| 1003 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 1004 | }, |
| 1005 | |
Adam Lee | 01acf69 | 2013-12-19 00:01:26 +0800 | [diff] [blame] | 1006 | { |
| 1007 | .vendor = PCI_VENDOR_ID_O2, |
| 1008 | .device = PCI_DEVICE_ID_O2_FUJIN2, |
| 1009 | .subvendor = PCI_ANY_ID, |
| 1010 | .subdevice = PCI_ANY_ID, |
| 1011 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 1012 | }, |
| 1013 | |
| 1014 | { |
| 1015 | .vendor = PCI_VENDOR_ID_O2, |
| 1016 | .device = PCI_DEVICE_ID_O2_SDS0, |
| 1017 | .subvendor = PCI_ANY_ID, |
| 1018 | .subdevice = PCI_ANY_ID, |
| 1019 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 1020 | }, |
| 1021 | |
| 1022 | { |
| 1023 | .vendor = PCI_VENDOR_ID_O2, |
| 1024 | .device = PCI_DEVICE_ID_O2_SDS1, |
| 1025 | .subvendor = PCI_ANY_ID, |
| 1026 | .subdevice = PCI_ANY_ID, |
| 1027 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 1028 | }, |
| 1029 | |
| 1030 | { |
| 1031 | .vendor = PCI_VENDOR_ID_O2, |
| 1032 | .device = PCI_DEVICE_ID_O2_SEABIRD0, |
| 1033 | .subvendor = PCI_ANY_ID, |
| 1034 | .subdevice = PCI_ANY_ID, |
| 1035 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 1036 | }, |
| 1037 | |
| 1038 | { |
| 1039 | .vendor = PCI_VENDOR_ID_O2, |
| 1040 | .device = PCI_DEVICE_ID_O2_SEABIRD1, |
| 1041 | .subvendor = PCI_ANY_ID, |
| 1042 | .subdevice = PCI_ANY_ID, |
| 1043 | .driver_data = (kernel_ulong_t)&sdhci_o2, |
| 1044 | }, |
| 1045 | |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 1046 | { /* Generic SD host controller */ |
| 1047 | PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00) |
| 1048 | }, |
| 1049 | |
| 1050 | { /* end: all zeroes */ }, |
| 1051 | }; |
| 1052 | |
| 1053 | MODULE_DEVICE_TABLE(pci, pci_ids); |
| 1054 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1055 | /*****************************************************************************\ |
| 1056 | * * |
| 1057 | * SDHCI core callbacks * |
| 1058 | * * |
| 1059 | \*****************************************************************************/ |
| 1060 | |
| 1061 | static int sdhci_pci_enable_dma(struct sdhci_host *host) |
| 1062 | { |
| 1063 | struct sdhci_pci_slot *slot; |
| 1064 | struct pci_dev *pdev; |
| 1065 | int ret; |
| 1066 | |
| 1067 | slot = sdhci_priv(host); |
| 1068 | pdev = slot->chip->pdev; |
| 1069 | |
| 1070 | if (((pdev->class & 0xFFFF00) == (PCI_CLASS_SYSTEM_SDHCI << 8)) && |
| 1071 | ((pdev->class & 0x0000FF) != PCI_SDHCI_IFDMA) && |
Richard Röjfors | a13abc7 | 2009-09-22 16:45:30 -0700 | [diff] [blame] | 1072 | (host->flags & SDHCI_USE_SDMA)) { |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1073 | dev_warn(&pdev->dev, "Will use DMA mode even though HW " |
| 1074 | "doesn't fully claim to support it.\n"); |
| 1075 | } |
| 1076 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1077 | ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1078 | if (ret) |
| 1079 | return ret; |
| 1080 | |
| 1081 | pci_set_master(pdev); |
| 1082 | |
| 1083 | return 0; |
| 1084 | } |
| 1085 | |
Russell King | 2317f56 | 2014-04-25 12:57:07 +0100 | [diff] [blame] | 1086 | static void sdhci_pci_set_bus_width(struct sdhci_host *host, int width) |
Major Lee | 68077b0 | 2011-06-29 14:23:46 +0300 | [diff] [blame] | 1087 | { |
| 1088 | u8 ctrl; |
| 1089 | |
| 1090 | ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); |
| 1091 | |
| 1092 | switch (width) { |
| 1093 | case MMC_BUS_WIDTH_8: |
| 1094 | ctrl |= SDHCI_CTRL_8BITBUS; |
| 1095 | ctrl &= ~SDHCI_CTRL_4BITBUS; |
| 1096 | break; |
| 1097 | case MMC_BUS_WIDTH_4: |
| 1098 | ctrl |= SDHCI_CTRL_4BITBUS; |
| 1099 | ctrl &= ~SDHCI_CTRL_8BITBUS; |
| 1100 | break; |
| 1101 | default: |
| 1102 | ctrl &= ~(SDHCI_CTRL_8BITBUS | SDHCI_CTRL_4BITBUS); |
| 1103 | break; |
| 1104 | } |
| 1105 | |
| 1106 | sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); |
Major Lee | 68077b0 | 2011-06-29 14:23:46 +0300 | [diff] [blame] | 1107 | } |
| 1108 | |
Adrian Hunter | c9faff6 | 2013-06-13 11:50:26 +0300 | [diff] [blame] | 1109 | static void sdhci_pci_gpio_hw_reset(struct sdhci_host *host) |
Adrian Hunter | 0f20165 | 2011-08-29 16:42:13 +0300 | [diff] [blame] | 1110 | { |
| 1111 | struct sdhci_pci_slot *slot = sdhci_priv(host); |
| 1112 | int rst_n_gpio = slot->rst_n_gpio; |
| 1113 | |
| 1114 | if (!gpio_is_valid(rst_n_gpio)) |
| 1115 | return; |
| 1116 | gpio_set_value_cansleep(rst_n_gpio, 0); |
| 1117 | /* For eMMC, minimum is 1us but give it 10us for good measure */ |
| 1118 | udelay(10); |
| 1119 | gpio_set_value_cansleep(rst_n_gpio, 1); |
| 1120 | /* For eMMC, minimum is 200us but give it 300us for good measure */ |
| 1121 | usleep_range(300, 1000); |
| 1122 | } |
| 1123 | |
Adrian Hunter | c9faff6 | 2013-06-13 11:50:26 +0300 | [diff] [blame] | 1124 | static void sdhci_pci_hw_reset(struct sdhci_host *host) |
| 1125 | { |
| 1126 | struct sdhci_pci_slot *slot = sdhci_priv(host); |
| 1127 | |
| 1128 | if (slot->hw_reset) |
| 1129 | slot->hw_reset(host); |
| 1130 | } |
| 1131 | |
Lars-Peter Clausen | c915568 | 2013-03-13 19:26:05 +0100 | [diff] [blame] | 1132 | static const struct sdhci_ops sdhci_pci_ops = { |
Russell King | 1771059 | 2014-04-25 12:58:55 +0100 | [diff] [blame] | 1133 | .set_clock = sdhci_set_clock, |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1134 | .enable_dma = sdhci_pci_enable_dma, |
Russell King | 2317f56 | 2014-04-25 12:57:07 +0100 | [diff] [blame] | 1135 | .set_bus_width = sdhci_pci_set_bus_width, |
Russell King | 03231f9 | 2014-04-25 12:57:12 +0100 | [diff] [blame] | 1136 | .reset = sdhci_reset, |
Russell King | 96d7b78 | 2014-04-25 12:59:26 +0100 | [diff] [blame] | 1137 | .set_uhs_signaling = sdhci_set_uhs_signaling, |
Adrian Hunter | 0f20165 | 2011-08-29 16:42:13 +0300 | [diff] [blame] | 1138 | .hw_reset = sdhci_pci_hw_reset, |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1139 | }; |
| 1140 | |
| 1141 | /*****************************************************************************\ |
| 1142 | * * |
| 1143 | * Suspend/resume * |
| 1144 | * * |
| 1145 | \*****************************************************************************/ |
| 1146 | |
| 1147 | #ifdef CONFIG_PM |
| 1148 | |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 1149 | static int sdhci_pci_suspend(struct device *dev) |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1150 | { |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 1151 | struct pci_dev *pdev = to_pci_dev(dev); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1152 | struct sdhci_pci_chip *chip; |
| 1153 | struct sdhci_pci_slot *slot; |
Daniel Drake | 5f61970 | 2010-11-04 22:20:39 +0000 | [diff] [blame] | 1154 | mmc_pm_flag_t slot_pm_flags; |
Nicolas Pitre | 2f4cbb3 | 2010-03-05 13:43:32 -0800 | [diff] [blame] | 1155 | mmc_pm_flag_t pm_flags = 0; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1156 | int i, ret; |
| 1157 | |
| 1158 | chip = pci_get_drvdata(pdev); |
| 1159 | if (!chip) |
| 1160 | return 0; |
| 1161 | |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 1162 | for (i = 0; i < chip->num_slots; i++) { |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1163 | slot = chip->slots[i]; |
| 1164 | if (!slot) |
| 1165 | continue; |
| 1166 | |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 1167 | ret = sdhci_suspend_host(slot->host); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1168 | |
Axel Lin | b678b91 | 2011-12-03 15:28:05 +0800 | [diff] [blame] | 1169 | if (ret) |
| 1170 | goto err_pci_suspend; |
Nicolas Pitre | 2f4cbb3 | 2010-03-05 13:43:32 -0800 | [diff] [blame] | 1171 | |
Daniel Drake | 5f61970 | 2010-11-04 22:20:39 +0000 | [diff] [blame] | 1172 | slot_pm_flags = slot->host->mmc->pm_flags; |
| 1173 | if (slot_pm_flags & MMC_PM_WAKE_SDIO_IRQ) |
| 1174 | sdhci_enable_irq_wakeups(slot->host); |
| 1175 | |
| 1176 | pm_flags |= slot_pm_flags; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1177 | } |
| 1178 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1179 | if (chip->fixes && chip->fixes->suspend) { |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 1180 | ret = chip->fixes->suspend(chip); |
Axel Lin | b678b91 | 2011-12-03 15:28:05 +0800 | [diff] [blame] | 1181 | if (ret) |
| 1182 | goto err_pci_suspend; |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1183 | } |
| 1184 | |
Nicolas Pitre | 2f4cbb3 | 2010-03-05 13:43:32 -0800 | [diff] [blame] | 1185 | if (pm_flags & MMC_PM_KEEP_POWER) { |
Chuanxiao.Dong | 6b91f2d | 2014-07-15 17:28:05 +0800 | [diff] [blame] | 1186 | if (pm_flags & MMC_PM_WAKE_SDIO_IRQ) |
| 1187 | device_init_wakeup(dev, true); |
| 1188 | else |
| 1189 | device_init_wakeup(dev, false); |
| 1190 | } else |
| 1191 | device_init_wakeup(dev, false); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1192 | |
| 1193 | return 0; |
Axel Lin | b678b91 | 2011-12-03 15:28:05 +0800 | [diff] [blame] | 1194 | |
| 1195 | err_pci_suspend: |
| 1196 | while (--i >= 0) |
| 1197 | sdhci_resume_host(chip->slots[i]->host); |
| 1198 | return ret; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1199 | } |
| 1200 | |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 1201 | static int sdhci_pci_resume(struct device *dev) |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1202 | { |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 1203 | struct pci_dev *pdev = to_pci_dev(dev); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1204 | struct sdhci_pci_chip *chip; |
| 1205 | struct sdhci_pci_slot *slot; |
| 1206 | int i, ret; |
| 1207 | |
| 1208 | chip = pci_get_drvdata(pdev); |
| 1209 | if (!chip) |
| 1210 | return 0; |
| 1211 | |
Pierre Ossman | 45211e2 | 2008-03-24 13:09:09 +0100 | [diff] [blame] | 1212 | if (chip->fixes && chip->fixes->resume) { |
| 1213 | ret = chip->fixes->resume(chip); |
| 1214 | if (ret) |
| 1215 | return ret; |
| 1216 | } |
| 1217 | |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 1218 | for (i = 0; i < chip->num_slots; i++) { |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1219 | slot = chip->slots[i]; |
| 1220 | if (!slot) |
| 1221 | continue; |
| 1222 | |
| 1223 | ret = sdhci_resume_host(slot->host); |
| 1224 | if (ret) |
| 1225 | return ret; |
| 1226 | } |
| 1227 | |
| 1228 | return 0; |
| 1229 | } |
| 1230 | |
| 1231 | #else /* CONFIG_PM */ |
| 1232 | |
| 1233 | #define sdhci_pci_suspend NULL |
| 1234 | #define sdhci_pci_resume NULL |
| 1235 | |
| 1236 | #endif /* CONFIG_PM */ |
| 1237 | |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1238 | #ifdef CONFIG_PM_RUNTIME |
| 1239 | |
| 1240 | static int sdhci_pci_runtime_suspend(struct device *dev) |
| 1241 | { |
| 1242 | struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); |
| 1243 | struct sdhci_pci_chip *chip; |
| 1244 | struct sdhci_pci_slot *slot; |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1245 | int i, ret; |
| 1246 | |
| 1247 | chip = pci_get_drvdata(pdev); |
| 1248 | if (!chip) |
| 1249 | return 0; |
| 1250 | |
| 1251 | for (i = 0; i < chip->num_slots; i++) { |
| 1252 | slot = chip->slots[i]; |
| 1253 | if (!slot) |
| 1254 | continue; |
| 1255 | |
| 1256 | ret = sdhci_runtime_suspend_host(slot->host); |
| 1257 | |
Axel Lin | b678b91 | 2011-12-03 15:28:05 +0800 | [diff] [blame] | 1258 | if (ret) |
| 1259 | goto err_pci_runtime_suspend; |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | if (chip->fixes && chip->fixes->suspend) { |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 1263 | ret = chip->fixes->suspend(chip); |
Axel Lin | b678b91 | 2011-12-03 15:28:05 +0800 | [diff] [blame] | 1264 | if (ret) |
| 1265 | goto err_pci_runtime_suspend; |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1266 | } |
| 1267 | |
| 1268 | return 0; |
Axel Lin | b678b91 | 2011-12-03 15:28:05 +0800 | [diff] [blame] | 1269 | |
| 1270 | err_pci_runtime_suspend: |
| 1271 | while (--i >= 0) |
| 1272 | sdhci_runtime_resume_host(chip->slots[i]->host); |
| 1273 | return ret; |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1274 | } |
| 1275 | |
| 1276 | static int sdhci_pci_runtime_resume(struct device *dev) |
| 1277 | { |
| 1278 | struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); |
| 1279 | struct sdhci_pci_chip *chip; |
| 1280 | struct sdhci_pci_slot *slot; |
| 1281 | int i, ret; |
| 1282 | |
| 1283 | chip = pci_get_drvdata(pdev); |
| 1284 | if (!chip) |
| 1285 | return 0; |
| 1286 | |
| 1287 | if (chip->fixes && chip->fixes->resume) { |
| 1288 | ret = chip->fixes->resume(chip); |
| 1289 | if (ret) |
| 1290 | return ret; |
| 1291 | } |
| 1292 | |
| 1293 | for (i = 0; i < chip->num_slots; i++) { |
| 1294 | slot = chip->slots[i]; |
| 1295 | if (!slot) |
| 1296 | continue; |
| 1297 | |
| 1298 | ret = sdhci_runtime_resume_host(slot->host); |
| 1299 | if (ret) |
| 1300 | return ret; |
| 1301 | } |
| 1302 | |
| 1303 | return 0; |
| 1304 | } |
| 1305 | |
| 1306 | static int sdhci_pci_runtime_idle(struct device *dev) |
| 1307 | { |
| 1308 | return 0; |
| 1309 | } |
| 1310 | |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1311 | #endif |
| 1312 | |
| 1313 | static const struct dev_pm_ops sdhci_pci_pm_ops = { |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 1314 | .suspend = sdhci_pci_suspend, |
| 1315 | .resume = sdhci_pci_resume, |
Peter Griffin | f3a92b1 | 2014-08-12 17:14:28 +0100 | [diff] [blame] | 1316 | SET_RUNTIME_PM_OPS(sdhci_pci_runtime_suspend, |
| 1317 | sdhci_pci_runtime_resume, sdhci_pci_runtime_idle) |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1318 | }; |
| 1319 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1320 | /*****************************************************************************\ |
| 1321 | * * |
| 1322 | * Device probing/removal * |
| 1323 | * * |
| 1324 | \*****************************************************************************/ |
| 1325 | |
Bill Pemberton | c3be1ef | 2012-11-19 13:23:06 -0500 | [diff] [blame] | 1326 | static struct sdhci_pci_slot *sdhci_pci_probe_slot( |
Adrian Hunter | 52c506f | 2011-12-27 15:48:43 +0200 | [diff] [blame] | 1327 | struct pci_dev *pdev, struct sdhci_pci_chip *chip, int first_bar, |
| 1328 | int slotno) |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1329 | { |
| 1330 | struct sdhci_pci_slot *slot; |
| 1331 | struct sdhci_host *host; |
Adrian Hunter | 52c506f | 2011-12-27 15:48:43 +0200 | [diff] [blame] | 1332 | int ret, bar = first_bar + slotno; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1333 | |
| 1334 | if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { |
| 1335 | dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar); |
| 1336 | return ERR_PTR(-ENODEV); |
| 1337 | } |
| 1338 | |
Adrian Hunter | 90b3e6c | 2012-10-18 09:54:31 +0300 | [diff] [blame] | 1339 | if (pci_resource_len(pdev, bar) < 0x100) { |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1340 | dev_err(&pdev->dev, "Invalid iomem size. You may " |
| 1341 | "experience problems.\n"); |
| 1342 | } |
| 1343 | |
| 1344 | if ((pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) { |
| 1345 | dev_err(&pdev->dev, "Vendor specific interface. Aborting.\n"); |
| 1346 | return ERR_PTR(-ENODEV); |
| 1347 | } |
| 1348 | |
| 1349 | if ((pdev->class & 0x0000FF) > PCI_SDHCI_IFVENDOR) { |
| 1350 | dev_err(&pdev->dev, "Unknown interface. Aborting.\n"); |
| 1351 | return ERR_PTR(-ENODEV); |
| 1352 | } |
| 1353 | |
| 1354 | host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pci_slot)); |
| 1355 | if (IS_ERR(host)) { |
Dan Carpenter | c60a32c | 2009-04-10 23:31:10 +0200 | [diff] [blame] | 1356 | dev_err(&pdev->dev, "cannot allocate host\n"); |
Julia Lawall | dc0fd7b | 2010-05-26 14:42:11 -0700 | [diff] [blame] | 1357 | return ERR_CAST(host); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | slot = sdhci_priv(host); |
| 1361 | |
| 1362 | slot->chip = chip; |
| 1363 | slot->host = host; |
| 1364 | slot->pci_bar = bar; |
Adrian Hunter | 0f20165 | 2011-08-29 16:42:13 +0300 | [diff] [blame] | 1365 | slot->rst_n_gpio = -EINVAL; |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 1366 | slot->cd_gpio = -EINVAL; |
Adrian Hunter | ff59c52 | 2014-09-24 10:27:31 +0300 | [diff] [blame] | 1367 | slot->cd_idx = -1; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1368 | |
Adrian Hunter | 52c506f | 2011-12-27 15:48:43 +0200 | [diff] [blame] | 1369 | /* Retrieve platform data if there is any */ |
| 1370 | if (*sdhci_pci_get_data) |
| 1371 | slot->data = sdhci_pci_get_data(pdev, slotno); |
| 1372 | |
| 1373 | if (slot->data) { |
| 1374 | if (slot->data->setup) { |
| 1375 | ret = slot->data->setup(slot->data); |
| 1376 | if (ret) { |
| 1377 | dev_err(&pdev->dev, "platform setup failed\n"); |
| 1378 | goto free; |
| 1379 | } |
| 1380 | } |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 1381 | slot->rst_n_gpio = slot->data->rst_n_gpio; |
| 1382 | slot->cd_gpio = slot->data->cd_gpio; |
Adrian Hunter | 52c506f | 2011-12-27 15:48:43 +0200 | [diff] [blame] | 1383 | } |
| 1384 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1385 | host->hw_name = "PCI"; |
| 1386 | host->ops = &sdhci_pci_ops; |
| 1387 | host->quirks = chip->quirks; |
Adrian Hunter | f3c55a7 | 2012-02-07 14:48:55 +0200 | [diff] [blame] | 1388 | host->quirks2 = chip->quirks2; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1389 | |
| 1390 | host->irq = pdev->irq; |
| 1391 | |
| 1392 | ret = pci_request_region(pdev, bar, mmc_hostname(host->mmc)); |
| 1393 | if (ret) { |
| 1394 | dev_err(&pdev->dev, "cannot request region\n"); |
Adrian Hunter | 52c506f | 2011-12-27 15:48:43 +0200 | [diff] [blame] | 1395 | goto cleanup; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1396 | } |
| 1397 | |
Arjan van de Ven | 092f82e | 2008-09-28 16:15:56 -0700 | [diff] [blame] | 1398 | host->ioaddr = pci_ioremap_bar(pdev, bar); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1399 | if (!host->ioaddr) { |
| 1400 | dev_err(&pdev->dev, "failed to remap registers\n"); |
Chris Ball | 9fdcdbb | 2011-03-29 00:46:12 -0400 | [diff] [blame] | 1401 | ret = -ENOMEM; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1402 | goto release; |
| 1403 | } |
| 1404 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1405 | if (chip->fixes && chip->fixes->probe_slot) { |
| 1406 | ret = chip->fixes->probe_slot(slot); |
| 1407 | if (ret) |
| 1408 | goto unmap; |
| 1409 | } |
| 1410 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 1411 | if (gpio_is_valid(slot->rst_n_gpio)) { |
| 1412 | if (!gpio_request(slot->rst_n_gpio, "eMMC_reset")) { |
| 1413 | gpio_direction_output(slot->rst_n_gpio, 1); |
| 1414 | slot->host->mmc->caps |= MMC_CAP_HW_RESET; |
Adrian Hunter | c9faff6 | 2013-06-13 11:50:26 +0300 | [diff] [blame] | 1415 | slot->hw_reset = sdhci_pci_gpio_hw_reset; |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 1416 | } else { |
| 1417 | dev_warn(&pdev->dev, "failed to request rst_n_gpio\n"); |
| 1418 | slot->rst_n_gpio = -EINVAL; |
| 1419 | } |
| 1420 | } |
| 1421 | |
Nicolas Pitre | 2f4cbb3 | 2010-03-05 13:43:32 -0800 | [diff] [blame] | 1422 | host->mmc->pm_caps = MMC_PM_KEEP_POWER | MMC_PM_WAKE_SDIO_IRQ; |
Aaron Lu | eed222a | 2013-03-05 11:24:52 +0800 | [diff] [blame] | 1423 | host->mmc->slotno = slotno; |
Adrian Hunter | a08b17b | 2013-04-15 11:27:25 -0400 | [diff] [blame] | 1424 | host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP; |
Nicolas Pitre | 2f4cbb3 | 2010-03-05 13:43:32 -0800 | [diff] [blame] | 1425 | |
Adrian Hunter | ff59c52 | 2014-09-24 10:27:31 +0300 | [diff] [blame] | 1426 | if (slot->cd_idx >= 0 && |
| 1427 | mmc_gpiod_request_cd(host->mmc, slot->cd_con_id, slot->cd_idx, |
| 1428 | slot->cd_override_level, 0, NULL)) { |
| 1429 | dev_warn(&pdev->dev, "failed to setup card detect gpio\n"); |
| 1430 | slot->cd_idx = -1; |
| 1431 | } |
| 1432 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1433 | ret = sdhci_add_host(host); |
| 1434 | if (ret) |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1435 | goto remove; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1436 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 1437 | sdhci_pci_add_own_cd(slot); |
| 1438 | |
Adrian Hunter | 77a0122 | 2014-01-13 09:49:16 +0200 | [diff] [blame] | 1439 | /* |
| 1440 | * Check if the chip needs a separate GPIO for card detect to wake up |
| 1441 | * from runtime suspend. If it is not there, don't allow runtime PM. |
| 1442 | * Note sdhci_pci_add_own_cd() sets slot->cd_gpio to -EINVAL on failure. |
| 1443 | */ |
Adrian Hunter | 945be38 | 2014-01-21 09:52:39 +0200 | [diff] [blame] | 1444 | if (chip->fixes && chip->fixes->own_cd_for_runtime_pm && |
Adrian Hunter | ff59c52 | 2014-09-24 10:27:31 +0300 | [diff] [blame] | 1445 | !gpio_is_valid(slot->cd_gpio) && slot->cd_idx < 0) |
Adrian Hunter | 77a0122 | 2014-01-13 09:49:16 +0200 | [diff] [blame] | 1446 | chip->allow_runtime_pm = false; |
| 1447 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1448 | return slot; |
| 1449 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1450 | remove: |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 1451 | if (gpio_is_valid(slot->rst_n_gpio)) |
| 1452 | gpio_free(slot->rst_n_gpio); |
| 1453 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1454 | if (chip->fixes && chip->fixes->remove_slot) |
Pierre Ossman | 1e72859 | 2008-04-16 19:13:13 +0200 | [diff] [blame] | 1455 | chip->fixes->remove_slot(slot, 0); |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1456 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1457 | unmap: |
| 1458 | iounmap(host->ioaddr); |
| 1459 | |
| 1460 | release: |
| 1461 | pci_release_region(pdev, bar); |
Dan Carpenter | c60a32c | 2009-04-10 23:31:10 +0200 | [diff] [blame] | 1462 | |
Adrian Hunter | 52c506f | 2011-12-27 15:48:43 +0200 | [diff] [blame] | 1463 | cleanup: |
| 1464 | if (slot->data && slot->data->cleanup) |
| 1465 | slot->data->cleanup(slot->data); |
| 1466 | |
Dan Carpenter | c60a32c | 2009-04-10 23:31:10 +0200 | [diff] [blame] | 1467 | free: |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1468 | sdhci_free_host(host); |
| 1469 | |
| 1470 | return ERR_PTR(ret); |
| 1471 | } |
| 1472 | |
| 1473 | static void sdhci_pci_remove_slot(struct sdhci_pci_slot *slot) |
| 1474 | { |
Pierre Ossman | 1e72859 | 2008-04-16 19:13:13 +0200 | [diff] [blame] | 1475 | int dead; |
| 1476 | u32 scratch; |
| 1477 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 1478 | sdhci_pci_remove_own_cd(slot); |
| 1479 | |
Pierre Ossman | 1e72859 | 2008-04-16 19:13:13 +0200 | [diff] [blame] | 1480 | dead = 0; |
| 1481 | scratch = readl(slot->host->ioaddr + SDHCI_INT_STATUS); |
| 1482 | if (scratch == (u32)-1) |
| 1483 | dead = 1; |
| 1484 | |
| 1485 | sdhci_remove_host(slot->host, dead); |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1486 | |
Adrian Hunter | c5e027a | 2011-12-27 15:48:44 +0200 | [diff] [blame] | 1487 | if (gpio_is_valid(slot->rst_n_gpio)) |
| 1488 | gpio_free(slot->rst_n_gpio); |
| 1489 | |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1490 | if (slot->chip->fixes && slot->chip->fixes->remove_slot) |
Pierre Ossman | 1e72859 | 2008-04-16 19:13:13 +0200 | [diff] [blame] | 1491 | slot->chip->fixes->remove_slot(slot, dead); |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1492 | |
Adrian Hunter | 52c506f | 2011-12-27 15:48:43 +0200 | [diff] [blame] | 1493 | if (slot->data && slot->data->cleanup) |
| 1494 | slot->data->cleanup(slot->data); |
| 1495 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1496 | pci_release_region(slot->chip->pdev, slot->pci_bar); |
Pierre Ossman | 4489428 | 2008-04-04 19:36:59 +0200 | [diff] [blame] | 1497 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1498 | sdhci_free_host(slot->host); |
| 1499 | } |
| 1500 | |
Bill Pemberton | c3be1ef | 2012-11-19 13:23:06 -0500 | [diff] [blame] | 1501 | static void sdhci_pci_runtime_pm_allow(struct device *dev) |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1502 | { |
| 1503 | pm_runtime_put_noidle(dev); |
| 1504 | pm_runtime_allow(dev); |
| 1505 | pm_runtime_set_autosuspend_delay(dev, 50); |
| 1506 | pm_runtime_use_autosuspend(dev); |
| 1507 | pm_suspend_ignore_children(dev, 1); |
| 1508 | } |
| 1509 | |
Bill Pemberton | 6e0ee71 | 2012-11-19 13:26:03 -0500 | [diff] [blame] | 1510 | static void sdhci_pci_runtime_pm_forbid(struct device *dev) |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1511 | { |
| 1512 | pm_runtime_forbid(dev); |
| 1513 | pm_runtime_get_noresume(dev); |
| 1514 | } |
| 1515 | |
Bill Pemberton | c3be1ef | 2012-11-19 13:23:06 -0500 | [diff] [blame] | 1516 | static int sdhci_pci_probe(struct pci_dev *pdev, |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1517 | const struct pci_device_id *ent) |
| 1518 | { |
| 1519 | struct sdhci_pci_chip *chip; |
| 1520 | struct sdhci_pci_slot *slot; |
| 1521 | |
Sergei Shtylyov | cf5e23e | 2011-03-17 16:46:17 -0400 | [diff] [blame] | 1522 | u8 slots, first_bar; |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1523 | int ret, i; |
| 1524 | |
| 1525 | BUG_ON(pdev == NULL); |
| 1526 | BUG_ON(ent == NULL); |
| 1527 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1528 | dev_info(&pdev->dev, "SDHCI controller found [%04x:%04x] (rev %x)\n", |
Sergei Shtylyov | cf5e23e | 2011-03-17 16:46:17 -0400 | [diff] [blame] | 1529 | (int)pdev->vendor, (int)pdev->device, (int)pdev->revision); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1530 | |
| 1531 | ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots); |
| 1532 | if (ret) |
| 1533 | return ret; |
| 1534 | |
| 1535 | slots = PCI_SLOT_INFO_SLOTS(slots) + 1; |
| 1536 | dev_dbg(&pdev->dev, "found %d slot(s)\n", slots); |
| 1537 | if (slots == 0) |
| 1538 | return -ENODEV; |
| 1539 | |
| 1540 | BUG_ON(slots > MAX_SLOTS); |
| 1541 | |
| 1542 | ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &first_bar); |
| 1543 | if (ret) |
| 1544 | return ret; |
| 1545 | |
| 1546 | first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK; |
| 1547 | |
| 1548 | if (first_bar > 5) { |
| 1549 | dev_err(&pdev->dev, "Invalid first BAR. Aborting.\n"); |
| 1550 | return -ENODEV; |
| 1551 | } |
| 1552 | |
| 1553 | ret = pci_enable_device(pdev); |
| 1554 | if (ret) |
| 1555 | return ret; |
| 1556 | |
| 1557 | chip = kzalloc(sizeof(struct sdhci_pci_chip), GFP_KERNEL); |
| 1558 | if (!chip) { |
| 1559 | ret = -ENOMEM; |
| 1560 | goto err; |
| 1561 | } |
| 1562 | |
| 1563 | chip->pdev = pdev; |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 1564 | chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data; |
Adrian Hunter | c43fd77 | 2011-10-17 10:52:44 +0300 | [diff] [blame] | 1565 | if (chip->fixes) { |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 1566 | chip->quirks = chip->fixes->quirks; |
Adrian Hunter | f3c55a7 | 2012-02-07 14:48:55 +0200 | [diff] [blame] | 1567 | chip->quirks2 = chip->fixes->quirks2; |
Adrian Hunter | c43fd77 | 2011-10-17 10:52:44 +0300 | [diff] [blame] | 1568 | chip->allow_runtime_pm = chip->fixes->allow_runtime_pm; |
| 1569 | } |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1570 | chip->num_slots = slots; |
| 1571 | |
| 1572 | pci_set_drvdata(pdev, chip); |
| 1573 | |
Pierre Ossman | 2260640 | 2008-03-23 19:33:23 +0100 | [diff] [blame] | 1574 | if (chip->fixes && chip->fixes->probe) { |
| 1575 | ret = chip->fixes->probe(chip); |
| 1576 | if (ret) |
| 1577 | goto free; |
| 1578 | } |
| 1579 | |
Alan Cox | 225d85f | 2010-10-04 15:24:21 +0100 | [diff] [blame] | 1580 | slots = chip->num_slots; /* Quirk may have changed this */ |
| 1581 | |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 1582 | for (i = 0; i < slots; i++) { |
Adrian Hunter | 52c506f | 2011-12-27 15:48:43 +0200 | [diff] [blame] | 1583 | slot = sdhci_pci_probe_slot(pdev, chip, first_bar, i); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1584 | if (IS_ERR(slot)) { |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 1585 | for (i--; i >= 0; i--) |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1586 | sdhci_pci_remove_slot(chip->slots[i]); |
| 1587 | ret = PTR_ERR(slot); |
| 1588 | goto free; |
| 1589 | } |
| 1590 | |
| 1591 | chip->slots[i] = slot; |
| 1592 | } |
| 1593 | |
Adrian Hunter | c43fd77 | 2011-10-17 10:52:44 +0300 | [diff] [blame] | 1594 | if (chip->allow_runtime_pm) |
| 1595 | sdhci_pci_runtime_pm_allow(&pdev->dev); |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1596 | |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1597 | return 0; |
| 1598 | |
| 1599 | free: |
| 1600 | pci_set_drvdata(pdev, NULL); |
| 1601 | kfree(chip); |
| 1602 | |
| 1603 | err: |
| 1604 | pci_disable_device(pdev); |
| 1605 | return ret; |
| 1606 | } |
| 1607 | |
Bill Pemberton | 6e0ee71 | 2012-11-19 13:26:03 -0500 | [diff] [blame] | 1608 | static void sdhci_pci_remove(struct pci_dev *pdev) |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1609 | { |
| 1610 | int i; |
| 1611 | struct sdhci_pci_chip *chip; |
| 1612 | |
| 1613 | chip = pci_get_drvdata(pdev); |
| 1614 | |
| 1615 | if (chip) { |
Adrian Hunter | c43fd77 | 2011-10-17 10:52:44 +0300 | [diff] [blame] | 1616 | if (chip->allow_runtime_pm) |
| 1617 | sdhci_pci_runtime_pm_forbid(&pdev->dev); |
| 1618 | |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 1619 | for (i = 0; i < chip->num_slots; i++) |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1620 | sdhci_pci_remove_slot(chip->slots[i]); |
| 1621 | |
| 1622 | pci_set_drvdata(pdev, NULL); |
| 1623 | kfree(chip); |
| 1624 | } |
| 1625 | |
| 1626 | pci_disable_device(pdev); |
| 1627 | } |
| 1628 | |
| 1629 | static struct pci_driver sdhci_driver = { |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 1630 | .name = "sdhci-pci", |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1631 | .id_table = pci_ids, |
Ameya Palande | b177bc9 | 2011-04-05 21:13:13 +0300 | [diff] [blame] | 1632 | .probe = sdhci_pci_probe, |
Bill Pemberton | 0433c14 | 2012-11-19 13:20:26 -0500 | [diff] [blame] | 1633 | .remove = sdhci_pci_remove, |
Adrian Hunter | 66fd8ad | 2011-10-03 15:33:34 +0300 | [diff] [blame] | 1634 | .driver = { |
| 1635 | .pm = &sdhci_pci_pm_ops |
| 1636 | }, |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1637 | }; |
| 1638 | |
Sachin Kamat | acc6964 | 2012-08-27 11:57:02 +0530 | [diff] [blame] | 1639 | module_pci_driver(sdhci_driver); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1640 | |
Pierre Ossman | 32710e8 | 2009-04-08 20:14:54 +0200 | [diff] [blame] | 1641 | MODULE_AUTHOR("Pierre Ossman <pierre@ossman.eu>"); |
Pierre Ossman | b8c86fc | 2008-03-18 17:35:49 +0100 | [diff] [blame] | 1642 | MODULE_DESCRIPTION("Secure Digital Host Controller Interface PCI driver"); |
| 1643 | MODULE_LICENSE("GPL"); |