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