blob: 6ebdc4010e7ccb46e6f1052357fcdaca5dc3ecc9 [file] [log] [blame]
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001/* 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 Gortmaker88b47672011-07-03 15:15:51 -040017#include <linux/module.h>
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +010018#include <linux/pci.h>
19#include <linux/dma-mapping.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090020#include <linux/slab.h>
Maxim Levitskyccc92c22010-08-10 18:01:42 -070021#include <linux/device.h>
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +010022#include <linux/mmc/host.h>
Ameya Palandeb177bc92011-04-05 21:13:13 +030023#include <linux/scatterlist.h>
24#include <linux/io.h>
Adrian Hunter0f201652011-08-29 16:42:13 +030025#include <linux/gpio.h>
Adrian Hunter66fd8ad2011-10-03 15:33:34 +030026#include <linux/pm_runtime.h>
Adrian Hunter52c506f2011-12-27 15:48:43 +020027#include <linux/mmc/sdhci-pci-data.h>
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +010028
29#include "sdhci.h"
30
31/*
32 * PCI registers
33 */
34
35#define PCI_SDHCI_IFPIO 0x00
36#define PCI_SDHCI_IFDMA 0x01
37#define PCI_SDHCI_IFVENDOR 0x02
38
39#define PCI_SLOT_INFO 0x40 /* 8 bits */
40#define PCI_SLOT_INFO_SLOTS(x) ((x >> 4) & 7)
41#define PCI_SLOT_INFO_FIRST_BAR_MASK 0x07
42
43#define MAX_SLOTS 8
44
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +010045struct sdhci_pci_chip;
Pierre Ossman44894282008-04-04 19:36:59 +020046struct sdhci_pci_slot;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +010047
Pierre Ossman22606402008-03-23 19:33:23 +010048struct sdhci_pci_fixes {
49 unsigned int quirks;
Adrian Hunterc43fd772011-10-17 10:52:44 +030050 bool allow_runtime_pm;
Pierre Ossman22606402008-03-23 19:33:23 +010051
Ameya Palandeb177bc92011-04-05 21:13:13 +030052 int (*probe) (struct sdhci_pci_chip *);
Pierre Ossman45211e22008-03-24 13:09:09 +010053
Ameya Palandeb177bc92011-04-05 21:13:13 +030054 int (*probe_slot) (struct sdhci_pci_slot *);
55 void (*remove_slot) (struct sdhci_pci_slot *, int);
Pierre Ossman44894282008-04-04 19:36:59 +020056
Manuel Lauss29495aa2011-11-03 11:09:45 +010057 int (*suspend) (struct sdhci_pci_chip *);
Ameya Palandeb177bc92011-04-05 21:13:13 +030058 int (*resume) (struct sdhci_pci_chip *);
Pierre Ossman22606402008-03-23 19:33:23 +010059};
60
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +010061struct sdhci_pci_slot {
62 struct sdhci_pci_chip *chip;
63 struct sdhci_host *host;
Adrian Hunter52c506f2011-12-27 15:48:43 +020064 struct sdhci_pci_data *data;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +010065
66 int pci_bar;
Adrian Hunter0f201652011-08-29 16:42:13 +030067 int rst_n_gpio;
Adrian Hunter66fd8ad2011-10-03 15:33:34 +030068 int cd_gpio;
69 int cd_irq;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +010070};
71
72struct sdhci_pci_chip {
73 struct pci_dev *pdev;
Pierre Ossman22606402008-03-23 19:33:23 +010074
75 unsigned int quirks;
Adrian Hunterc43fd772011-10-17 10:52:44 +030076 bool allow_runtime_pm;
Pierre Ossman22606402008-03-23 19:33:23 +010077 const struct sdhci_pci_fixes *fixes;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +010078
79 int num_slots; /* Slots on controller */
80 struct sdhci_pci_slot *slots[MAX_SLOTS]; /* Pointers to host slots */
81};
82
Pierre Ossman22606402008-03-23 19:33:23 +010083
84/*****************************************************************************\
85 * *
86 * Hardware specific quirk handling *
87 * *
88\*****************************************************************************/
89
90static int ricoh_probe(struct sdhci_pci_chip *chip)
91{
Chris Ballc99436f2009-09-22 16:45:22 -070092 if (chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG ||
93 chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SONY)
Pierre Ossman22606402008-03-23 19:33:23 +010094 chip->quirks |= SDHCI_QUIRK_NO_CARD_NO_RESET;
Maxim Levitskyccc92c22010-08-10 18:01:42 -070095 return 0;
96}
Pierre Ossman22606402008-03-23 19:33:23 +010097
Maxim Levitskyccc92c22010-08-10 18:01:42 -070098static int ricoh_mmc_probe_slot(struct sdhci_pci_slot *slot)
99{
100 slot->host->caps =
101 ((0x21 << SDHCI_TIMEOUT_CLK_SHIFT)
102 & SDHCI_TIMEOUT_CLK_MASK) |
103
104 ((0x21 << SDHCI_CLOCK_BASE_SHIFT)
105 & SDHCI_CLOCK_BASE_MASK) |
106
107 SDHCI_TIMEOUT_CLK_UNIT |
108 SDHCI_CAN_VDD_330 |
109 SDHCI_CAN_DO_SDMA;
110 return 0;
111}
112
113static int ricoh_mmc_resume(struct sdhci_pci_chip *chip)
114{
115 /* Apply a delay to allow controller to settle */
116 /* Otherwise it becomes confused if card state changed
117 during suspend */
118 msleep(500);
Pierre Ossman22606402008-03-23 19:33:23 +0100119 return 0;
120}
121
122static const struct sdhci_pci_fixes sdhci_ricoh = {
123 .probe = ricoh_probe,
Vasily Khoruzhick84938292010-03-05 13:43:46 -0800124 .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR |
125 SDHCI_QUIRK_FORCE_DMA |
126 SDHCI_QUIRK_CLOCK_BEFORE_RESET,
Pierre Ossman22606402008-03-23 19:33:23 +0100127};
128
Maxim Levitskyccc92c22010-08-10 18:01:42 -0700129static const struct sdhci_pci_fixes sdhci_ricoh_mmc = {
130 .probe_slot = ricoh_mmc_probe_slot,
131 .resume = ricoh_mmc_resume,
132 .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR |
133 SDHCI_QUIRK_CLOCK_BEFORE_RESET |
134 SDHCI_QUIRK_NO_CARD_NO_RESET |
135 SDHCI_QUIRK_MISSING_CAPS
136};
137
Pierre Ossman22606402008-03-23 19:33:23 +0100138static const struct sdhci_pci_fixes sdhci_ene_712 = {
139 .quirks = SDHCI_QUIRK_SINGLE_POWER_WRITE |
140 SDHCI_QUIRK_BROKEN_DMA,
141};
142
143static const struct sdhci_pci_fixes sdhci_ene_714 = {
144 .quirks = SDHCI_QUIRK_SINGLE_POWER_WRITE |
145 SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS |
146 SDHCI_QUIRK_BROKEN_DMA,
147};
148
149static const struct sdhci_pci_fixes sdhci_cafe = {
150 .quirks = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER |
Andres Salomona0874892009-03-02 21:48:20 +0100151 SDHCI_QUIRK_NO_BUSY_IRQ |
Pierre Ossmanee53ab52008-07-05 00:25:15 +0200152 SDHCI_QUIRK_BROKEN_TIMEOUT_VAL,
Pierre Ossman22606402008-03-23 19:33:23 +0100153};
154
Major Lee68077b02011-06-29 14:23:46 +0300155static int mrst_hc_probe_slot(struct sdhci_pci_slot *slot)
156{
157 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA;
158 return 0;
159}
160
Alan Coxf9ee3ea2010-10-04 15:25:11 +0100161/*
162 * ADMA operation is disabled for Moorestown platform due to
163 * hardware bugs.
164 */
Jacob Pan35ac6f02010-11-09 13:57:29 +0000165static int mrst_hc_probe(struct sdhci_pci_chip *chip)
Alan Coxf9ee3ea2010-10-04 15:25:11 +0100166{
167 /*
Jacob Pan35ac6f02010-11-09 13:57:29 +0000168 * slots number is fixed here for MRST as SDIO3/5 are never used and
169 * have hardware bugs.
Alan Coxf9ee3ea2010-10-04 15:25:11 +0100170 */
171 chip->num_slots = 1;
172 return 0;
173}
174
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300175#ifdef CONFIG_PM_RUNTIME
176
Adrian Hunterc5e027a2011-12-27 15:48:44 +0200177static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id)
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300178{
179 struct sdhci_pci_slot *slot = dev_id;
180 struct sdhci_host *host = slot->host;
181
182 mmc_detect_change(host->mmc, msecs_to_jiffies(200));
183 return IRQ_HANDLED;
184}
185
Adrian Hunterc5e027a2011-12-27 15:48:44 +0200186static void sdhci_pci_add_own_cd(struct sdhci_pci_slot *slot)
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300187{
Adrian Hunterc5e027a2011-12-27 15:48:44 +0200188 int err, irq, gpio = slot->cd_gpio;
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300189
190 slot->cd_gpio = -EINVAL;
191 slot->cd_irq = -EINVAL;
192
Adrian Hunterc5e027a2011-12-27 15:48:44 +0200193 if (!gpio_is_valid(gpio))
194 return;
195
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300196 err = gpio_request(gpio, "sd_cd");
197 if (err < 0)
198 goto out;
199
200 err = gpio_direction_input(gpio);
201 if (err < 0)
202 goto out_free;
203
204 irq = gpio_to_irq(gpio);
205 if (irq < 0)
206 goto out_free;
207
Adrian Hunterc5e027a2011-12-27 15:48:44 +0200208 err = request_irq(irq, sdhci_pci_sd_cd, IRQF_TRIGGER_RISING |
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300209 IRQF_TRIGGER_FALLING, "sd_cd", slot);
210 if (err)
211 goto out_free;
212
213 slot->cd_gpio = gpio;
214 slot->cd_irq = irq;
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300215
Adrian Hunterc5e027a2011-12-27 15:48:44 +0200216 return;
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300217
218out_free:
219 gpio_free(gpio);
220out:
221 dev_warn(&slot->chip->pdev->dev, "failed to setup card detect wake up\n");
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300222}
223
Adrian Hunterc5e027a2011-12-27 15:48:44 +0200224static void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot)
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300225{
226 if (slot->cd_irq >= 0)
227 free_irq(slot->cd_irq, slot);
Adrian Hunterc5e027a2011-12-27 15:48:44 +0200228 if (gpio_is_valid(slot->cd_gpio))
229 gpio_free(slot->cd_gpio);
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300230}
231
232#else
233
Adrian Hunterc5e027a2011-12-27 15:48:44 +0200234static inline void sdhci_pci_add_own_cd(struct sdhci_pci_slot *slot)
235{
236}
237
238static inline void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot)
239{
240}
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300241
242#endif
243
Adrian Hunter0d013bc2011-06-29 14:23:47 +0300244static int mfd_emmc_probe_slot(struct sdhci_pci_slot *slot)
245{
Adrian Hunter66fd8ad2011-10-03 15:33:34 +0300246 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE;
Adrian Hunterf7c56ef2011-09-23 12:48:21 +0300247 slot->host->mmc->caps2 = MMC_CAP2_BOOTPART_NOACC;
Adrian Hunter0d013bc2011-06-29 14:23:47 +0300248 return 0;
249}
250
Adrian Hunter93933502011-12-27 15:48:47 +0200251static int mfd_sdio_probe_slot(struct sdhci_pci_slot *slot)
252{
Adrian Hunter012e4672012-01-30 14:27:18 +0200253 slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE;
Adrian Hunter93933502011-12-27 15:48:47 +0200254 return 0;
255}
256
Alan Coxf9ee3ea2010-10-04 15:25:11 +0100257static const struct sdhci_pci_fixes sdhci_intel_mrst_hc0 = {
258 .quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_NO_HISPD_BIT,
Major Lee68077b02011-06-29 14:23:46 +0300259 .probe_slot = mrst_hc_probe_slot,
Alan Coxf9ee3ea2010-10-04 15:25:11 +0100260};
261
Jacob Pan35ac6f02010-11-09 13:57:29 +0000262static const struct sdhci_pci_fixes sdhci_intel_mrst_hc1_hc2 = {
Alan Coxf9ee3ea2010-10-04 15:25:11 +0100263 .quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_NO_HISPD_BIT,
Jacob Pan35ac6f02010-11-09 13:57:29 +0000264 .probe = mrst_hc_probe,
Alan Coxf9ee3ea2010-10-04 15:25:11 +0100265};
266
Xiaochen Shen29229052010-10-04 15:24:52 +0100267static const struct sdhci_pci_fixes sdhci_intel_mfd_sd = {
268 .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
Adrian Hunterc43fd772011-10-17 10:52:44 +0300269 .allow_runtime_pm = true,
Xiaochen Shen29229052010-10-04 15:24:52 +0100270};
271
Adrian Hunter0d013bc2011-06-29 14:23:47 +0300272static const struct sdhci_pci_fixes sdhci_intel_mfd_sdio = {
Xiaochen Shen29229052010-10-04 15:24:52 +0100273 .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
Adrian Hunterc43fd772011-10-17 10:52:44 +0300274 .allow_runtime_pm = true,
Adrian Hunter93933502011-12-27 15:48:47 +0200275 .probe_slot = mfd_sdio_probe_slot,
Xiaochen Shen29229052010-10-04 15:24:52 +0100276};
277
Adrian Hunter0d013bc2011-06-29 14:23:47 +0300278static const struct sdhci_pci_fixes sdhci_intel_mfd_emmc = {
279 .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
Adrian Hunterc43fd772011-10-17 10:52:44 +0300280 .allow_runtime_pm = true,
Adrian Hunter0d013bc2011-06-29 14:23:47 +0300281 .probe_slot = mfd_emmc_probe_slot,
282};
283
Jennifer Li26daa1e2010-11-17 23:01:59 -0500284/* O2Micro extra registers */
285#define O2_SD_LOCK_WP 0xD3
286#define O2_SD_MULTI_VCC3V 0xEE
287#define O2_SD_CLKREQ 0xEC
288#define O2_SD_CAPS 0xE0
289#define O2_SD_ADMA1 0xE2
290#define O2_SD_ADMA2 0xE7
291#define O2_SD_INF_MOD 0xF1
292
293static int o2_probe(struct sdhci_pci_chip *chip)
294{
295 int ret;
296 u8 scratch;
297
298 switch (chip->pdev->device) {
299 case PCI_DEVICE_ID_O2_8220:
300 case PCI_DEVICE_ID_O2_8221:
301 case PCI_DEVICE_ID_O2_8320:
302 case PCI_DEVICE_ID_O2_8321:
303 /* This extra setup is required due to broken ADMA. */
304 ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch);
305 if (ret)
306 return ret;
307 scratch &= 0x7f;
308 pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
309
310 /* Set Multi 3 to VCC3V# */
311 pci_write_config_byte(chip->pdev, O2_SD_MULTI_VCC3V, 0x08);
312
313 /* Disable CLK_REQ# support after media DET */
314 ret = pci_read_config_byte(chip->pdev, O2_SD_CLKREQ, &scratch);
315 if (ret)
316 return ret;
317 scratch |= 0x20;
318 pci_write_config_byte(chip->pdev, O2_SD_CLKREQ, scratch);
319
320 /* Choose capabilities, enable SDMA. We have to write 0x01
321 * to the capabilities register first to unlock it.
322 */
323 ret = pci_read_config_byte(chip->pdev, O2_SD_CAPS, &scratch);
324 if (ret)
325 return ret;
326 scratch |= 0x01;
327 pci_write_config_byte(chip->pdev, O2_SD_CAPS, scratch);
328 pci_write_config_byte(chip->pdev, O2_SD_CAPS, 0x73);
329
330 /* Disable ADMA1/2 */
331 pci_write_config_byte(chip->pdev, O2_SD_ADMA1, 0x39);
332 pci_write_config_byte(chip->pdev, O2_SD_ADMA2, 0x08);
333
334 /* Disable the infinite transfer mode */
335 ret = pci_read_config_byte(chip->pdev, O2_SD_INF_MOD, &scratch);
336 if (ret)
337 return ret;
338 scratch |= 0x08;
339 pci_write_config_byte(chip->pdev, O2_SD_INF_MOD, scratch);
340
341 /* Lock WP */
342 ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch);
343 if (ret)
344 return ret;
345 scratch |= 0x80;
346 pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
347 }
348
349 return 0;
350}
351
Pierre Ossman45211e22008-03-24 13:09:09 +0100352static int jmicron_pmos(struct sdhci_pci_chip *chip, int on)
353{
354 u8 scratch;
355 int ret;
356
357 ret = pci_read_config_byte(chip->pdev, 0xAE, &scratch);
358 if (ret)
359 return ret;
360
361 /*
362 * Turn PMOS on [bit 0], set over current detection to 2.4 V
363 * [bit 1:2] and enable over current debouncing [bit 6].
364 */
365 if (on)
366 scratch |= 0x47;
367 else
368 scratch &= ~0x47;
369
370 ret = pci_write_config_byte(chip->pdev, 0xAE, scratch);
371 if (ret)
372 return ret;
373
374 return 0;
375}
376
377static int jmicron_probe(struct sdhci_pci_chip *chip)
378{
379 int ret;
Takashi Iwai8f230f42010-12-08 10:04:30 +0100380 u16 mmcdev = 0;
Pierre Ossman45211e22008-03-24 13:09:09 +0100381
Pierre Ossman93fc48c2008-06-28 18:21:41 +0200382 if (chip->pdev->revision == 0) {
383 chip->quirks |= SDHCI_QUIRK_32BIT_DMA_ADDR |
384 SDHCI_QUIRK_32BIT_DMA_SIZE |
Pierre Ossman2134a922008-06-28 18:28:51 +0200385 SDHCI_QUIRK_32BIT_ADMA_SIZE |
Pierre Ossman4a3cba32008-07-29 00:11:16 +0200386 SDHCI_QUIRK_RESET_AFTER_REQUEST |
Pierre Ossman86a6a872009-02-02 21:13:49 +0100387 SDHCI_QUIRK_BROKEN_SMALL_PIO;
Pierre Ossman93fc48c2008-06-28 18:21:41 +0200388 }
389
Pierre Ossman45211e22008-03-24 13:09:09 +0100390 /*
Pierre Ossman44894282008-04-04 19:36:59 +0200391 * JMicron chips can have two interfaces to the same hardware
392 * in order to work around limitations in Microsoft's driver.
393 * We need to make sure we only bind to one of them.
394 *
395 * This code assumes two things:
396 *
397 * 1. The PCI code adds subfunctions in order.
398 *
399 * 2. The MMC interface has a lower subfunction number
400 * than the SD interface.
401 */
Takashi Iwai8f230f42010-12-08 10:04:30 +0100402 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_SD)
403 mmcdev = PCI_DEVICE_ID_JMICRON_JMB38X_MMC;
404 else if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_SD)
405 mmcdev = PCI_DEVICE_ID_JMICRON_JMB388_ESD;
406
407 if (mmcdev) {
Pierre Ossman44894282008-04-04 19:36:59 +0200408 struct pci_dev *sd_dev;
409
410 sd_dev = NULL;
411 while ((sd_dev = pci_get_device(PCI_VENDOR_ID_JMICRON,
Takashi Iwai8f230f42010-12-08 10:04:30 +0100412 mmcdev, sd_dev)) != NULL) {
Pierre Ossman44894282008-04-04 19:36:59 +0200413 if ((PCI_SLOT(chip->pdev->devfn) ==
414 PCI_SLOT(sd_dev->devfn)) &&
415 (chip->pdev->bus == sd_dev->bus))
416 break;
417 }
418
419 if (sd_dev) {
420 pci_dev_put(sd_dev);
421 dev_info(&chip->pdev->dev, "Refusing to bind to "
422 "secondary interface.\n");
423 return -ENODEV;
424 }
425 }
426
427 /*
Pierre Ossman45211e22008-03-24 13:09:09 +0100428 * JMicron chips need a bit of a nudge to enable the power
429 * output pins.
430 */
431 ret = jmicron_pmos(chip, 1);
432 if (ret) {
433 dev_err(&chip->pdev->dev, "Failure enabling card power\n");
434 return ret;
435 }
436
Takashi Iwai82b0e232011-04-21 20:26:38 +0200437 /* quirk for unsable RO-detection on JM388 chips */
438 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_SD ||
439 chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD)
440 chip->quirks |= SDHCI_QUIRK_UNSTABLE_RO_DETECT;
441
Pierre Ossman45211e22008-03-24 13:09:09 +0100442 return 0;
443}
444
Pierre Ossman44894282008-04-04 19:36:59 +0200445static void jmicron_enable_mmc(struct sdhci_host *host, int on)
446{
447 u8 scratch;
448
449 scratch = readb(host->ioaddr + 0xC0);
450
451 if (on)
452 scratch |= 0x01;
453 else
454 scratch &= ~0x01;
455
456 writeb(scratch, host->ioaddr + 0xC0);
457}
458
459static int jmicron_probe_slot(struct sdhci_pci_slot *slot)
460{
Pierre Ossman2134a922008-06-28 18:28:51 +0200461 if (slot->chip->pdev->revision == 0) {
462 u16 version;
463
464 version = readl(slot->host->ioaddr + SDHCI_HOST_VERSION);
465 version = (version & SDHCI_VENDOR_VER_MASK) >>
466 SDHCI_VENDOR_VER_SHIFT;
467
468 /*
469 * Older versions of the chip have lots of nasty glitches
470 * in the ADMA engine. It's best just to avoid it
471 * completely.
472 */
473 if (version < 0xAC)
474 slot->host->quirks |= SDHCI_QUIRK_BROKEN_ADMA;
475 }
476
Takashi Iwai8f230f42010-12-08 10:04:30 +0100477 /* JM388 MMC doesn't support 1.8V while SD supports it */
478 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) {
479 slot->host->ocr_avail_sd = MMC_VDD_32_33 | MMC_VDD_33_34 |
480 MMC_VDD_29_30 | MMC_VDD_30_31 |
481 MMC_VDD_165_195; /* allow 1.8V */
482 slot->host->ocr_avail_mmc = MMC_VDD_32_33 | MMC_VDD_33_34 |
483 MMC_VDD_29_30 | MMC_VDD_30_31; /* no 1.8V for MMC */
484 }
485
Pierre Ossman44894282008-04-04 19:36:59 +0200486 /*
487 * The secondary interface requires a bit set to get the
488 * interrupts.
489 */
Takashi Iwai8f230f42010-12-08 10:04:30 +0100490 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC ||
491 slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD)
Pierre Ossman44894282008-04-04 19:36:59 +0200492 jmicron_enable_mmc(slot->host, 1);
493
Takashi Iwaid75c1082010-12-16 17:54:14 +0100494 slot->host->mmc->caps |= MMC_CAP_BUS_WIDTH_TEST;
495
Pierre Ossman44894282008-04-04 19:36:59 +0200496 return 0;
497}
498
Pierre Ossman1e728592008-04-16 19:13:13 +0200499static void jmicron_remove_slot(struct sdhci_pci_slot *slot, int dead)
Pierre Ossman44894282008-04-04 19:36:59 +0200500{
Pierre Ossman1e728592008-04-16 19:13:13 +0200501 if (dead)
502 return;
503
Takashi Iwai8f230f42010-12-08 10:04:30 +0100504 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC ||
505 slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD)
Pierre Ossman44894282008-04-04 19:36:59 +0200506 jmicron_enable_mmc(slot->host, 0);
507}
508
Manuel Lauss29495aa2011-11-03 11:09:45 +0100509static int jmicron_suspend(struct sdhci_pci_chip *chip)
Pierre Ossman44894282008-04-04 19:36:59 +0200510{
511 int i;
512
Takashi Iwai8f230f42010-12-08 10:04:30 +0100513 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC ||
514 chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) {
Ameya Palandeb177bc92011-04-05 21:13:13 +0300515 for (i = 0; i < chip->num_slots; i++)
Pierre Ossman44894282008-04-04 19:36:59 +0200516 jmicron_enable_mmc(chip->slots[i]->host, 0);
517 }
518
519 return 0;
520}
521
Pierre Ossman45211e22008-03-24 13:09:09 +0100522static int jmicron_resume(struct sdhci_pci_chip *chip)
523{
Pierre Ossman44894282008-04-04 19:36:59 +0200524 int ret, i;
525
Takashi Iwai8f230f42010-12-08 10:04:30 +0100526 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC ||
527 chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) {
Ameya Palandeb177bc92011-04-05 21:13:13 +0300528 for (i = 0; i < chip->num_slots; i++)
Pierre Ossman44894282008-04-04 19:36:59 +0200529 jmicron_enable_mmc(chip->slots[i]->host, 1);
530 }
Pierre Ossman45211e22008-03-24 13:09:09 +0100531
532 ret = jmicron_pmos(chip, 1);
533 if (ret) {
534 dev_err(&chip->pdev->dev, "Failure enabling card power\n");
535 return ret;
536 }
537
538 return 0;
539}
540
Jennifer Li26daa1e2010-11-17 23:01:59 -0500541static const struct sdhci_pci_fixes sdhci_o2 = {
542 .probe = o2_probe,
543};
544
Pierre Ossman22606402008-03-23 19:33:23 +0100545static const struct sdhci_pci_fixes sdhci_jmicron = {
Pierre Ossman45211e22008-03-24 13:09:09 +0100546 .probe = jmicron_probe,
547
Pierre Ossman44894282008-04-04 19:36:59 +0200548 .probe_slot = jmicron_probe_slot,
549 .remove_slot = jmicron_remove_slot,
550
551 .suspend = jmicron_suspend,
Pierre Ossman45211e22008-03-24 13:09:09 +0100552 .resume = jmicron_resume,
Pierre Ossman22606402008-03-23 19:33:23 +0100553};
554
Nicolas Pitrea7a61862009-12-14 18:01:26 -0800555/* 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
574static 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
583static 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
616static 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 Welte557b0692009-06-18 16:53:38 +0200622static 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
630static const struct sdhci_pci_fixes sdhci_via = {
631 .probe = via_probe,
632};
633
Pierre Ossman22606402008-03-23 19:33:23 +0100634static const struct pci_device_id pci_ids[] __devinitdata = {
635 {
636 .vendor = PCI_VENDOR_ID_RICOH,
637 .device = PCI_DEVICE_ID_RICOH_R5C822,
638 .subvendor = PCI_ANY_ID,
639 .subdevice = PCI_ANY_ID,
640 .driver_data = (kernel_ulong_t)&sdhci_ricoh,
641 },
642
643 {
Maxim Levitskyccc92c22010-08-10 18:01:42 -0700644 .vendor = PCI_VENDOR_ID_RICOH,
645 .device = 0x843,
646 .subvendor = PCI_ANY_ID,
647 .subdevice = PCI_ANY_ID,
648 .driver_data = (kernel_ulong_t)&sdhci_ricoh_mmc,
649 },
650
651 {
Pablo Castillo568133e2010-08-10 18:02:01 -0700652 .vendor = PCI_VENDOR_ID_RICOH,
653 .device = 0xe822,
654 .subvendor = PCI_ANY_ID,
655 .subdevice = PCI_ANY_ID,
656 .driver_data = (kernel_ulong_t)&sdhci_ricoh_mmc,
657 },
658
659 {
Manoj Iyer5fd11c02011-02-11 16:25:31 -0600660 .vendor = PCI_VENDOR_ID_RICOH,
661 .device = 0xe823,
662 .subvendor = PCI_ANY_ID,
663 .subdevice = PCI_ANY_ID,
664 .driver_data = (kernel_ulong_t)&sdhci_ricoh_mmc,
665 },
666
667 {
Pierre Ossman22606402008-03-23 19:33:23 +0100668 .vendor = PCI_VENDOR_ID_ENE,
669 .device = PCI_DEVICE_ID_ENE_CB712_SD,
670 .subvendor = PCI_ANY_ID,
671 .subdevice = PCI_ANY_ID,
672 .driver_data = (kernel_ulong_t)&sdhci_ene_712,
673 },
674
675 {
676 .vendor = PCI_VENDOR_ID_ENE,
677 .device = PCI_DEVICE_ID_ENE_CB712_SD_2,
678 .subvendor = PCI_ANY_ID,
679 .subdevice = PCI_ANY_ID,
680 .driver_data = (kernel_ulong_t)&sdhci_ene_712,
681 },
682
683 {
684 .vendor = PCI_VENDOR_ID_ENE,
685 .device = PCI_DEVICE_ID_ENE_CB714_SD,
686 .subvendor = PCI_ANY_ID,
687 .subdevice = PCI_ANY_ID,
688 .driver_data = (kernel_ulong_t)&sdhci_ene_714,
689 },
690
691 {
692 .vendor = PCI_VENDOR_ID_ENE,
693 .device = PCI_DEVICE_ID_ENE_CB714_SD_2,
694 .subvendor = PCI_ANY_ID,
695 .subdevice = PCI_ANY_ID,
696 .driver_data = (kernel_ulong_t)&sdhci_ene_714,
697 },
698
699 {
700 .vendor = PCI_VENDOR_ID_MARVELL,
David Woodhouse8c5eb882008-09-03 09:45:57 +0100701 .device = PCI_DEVICE_ID_MARVELL_88ALP01_SD,
Pierre Ossman22606402008-03-23 19:33:23 +0100702 .subvendor = PCI_ANY_ID,
703 .subdevice = PCI_ANY_ID,
704 .driver_data = (kernel_ulong_t)&sdhci_cafe,
705 },
706
707 {
708 .vendor = PCI_VENDOR_ID_JMICRON,
709 .device = PCI_DEVICE_ID_JMICRON_JMB38X_SD,
710 .subvendor = PCI_ANY_ID,
711 .subdevice = PCI_ANY_ID,
712 .driver_data = (kernel_ulong_t)&sdhci_jmicron,
713 },
714
Pierre Ossman44894282008-04-04 19:36:59 +0200715 {
716 .vendor = PCI_VENDOR_ID_JMICRON,
717 .device = PCI_DEVICE_ID_JMICRON_JMB38X_MMC,
718 .subvendor = PCI_ANY_ID,
719 .subdevice = PCI_ANY_ID,
720 .driver_data = (kernel_ulong_t)&sdhci_jmicron,
721 },
722
Harald Welte557b0692009-06-18 16:53:38 +0200723 {
Takashi Iwai8f230f42010-12-08 10:04:30 +0100724 .vendor = PCI_VENDOR_ID_JMICRON,
725 .device = PCI_DEVICE_ID_JMICRON_JMB388_SD,
726 .subvendor = PCI_ANY_ID,
727 .subdevice = PCI_ANY_ID,
728 .driver_data = (kernel_ulong_t)&sdhci_jmicron,
729 },
730
731 {
732 .vendor = PCI_VENDOR_ID_JMICRON,
733 .device = PCI_DEVICE_ID_JMICRON_JMB388_ESD,
734 .subvendor = PCI_ANY_ID,
735 .subdevice = PCI_ANY_ID,
736 .driver_data = (kernel_ulong_t)&sdhci_jmicron,
737 },
738
739 {
Nicolas Pitrea7a61862009-12-14 18:01:26 -0800740 .vendor = PCI_VENDOR_ID_SYSKONNECT,
741 .device = 0x8000,
742 .subvendor = PCI_ANY_ID,
743 .subdevice = PCI_ANY_ID,
744 .driver_data = (kernel_ulong_t)&sdhci_syskt,
745 },
746
747 {
Harald Welte557b0692009-06-18 16:53:38 +0200748 .vendor = PCI_VENDOR_ID_VIA,
749 .device = 0x95d0,
750 .subvendor = PCI_ANY_ID,
751 .subdevice = PCI_ANY_ID,
752 .driver_data = (kernel_ulong_t)&sdhci_via,
753 },
754
Xiaochen Shen29229052010-10-04 15:24:52 +0100755 {
756 .vendor = PCI_VENDOR_ID_INTEL,
Alan Coxf9ee3ea2010-10-04 15:25:11 +0100757 .device = PCI_DEVICE_ID_INTEL_MRST_SD0,
758 .subvendor = PCI_ANY_ID,
759 .subdevice = PCI_ANY_ID,
760 .driver_data = (kernel_ulong_t)&sdhci_intel_mrst_hc0,
761 },
762
763 {
764 .vendor = PCI_VENDOR_ID_INTEL,
765 .device = PCI_DEVICE_ID_INTEL_MRST_SD1,
766 .subvendor = PCI_ANY_ID,
767 .subdevice = PCI_ANY_ID,
Jacob Pan35ac6f02010-11-09 13:57:29 +0000768 .driver_data = (kernel_ulong_t)&sdhci_intel_mrst_hc1_hc2,
769 },
770
771 {
772 .vendor = PCI_VENDOR_ID_INTEL,
773 .device = PCI_DEVICE_ID_INTEL_MRST_SD2,
774 .subvendor = PCI_ANY_ID,
775 .subdevice = PCI_ANY_ID,
776 .driver_data = (kernel_ulong_t)&sdhci_intel_mrst_hc1_hc2,
Alan Coxf9ee3ea2010-10-04 15:25:11 +0100777 },
778
779 {
780 .vendor = PCI_VENDOR_ID_INTEL,
Xiaochen Shen29229052010-10-04 15:24:52 +0100781 .device = PCI_DEVICE_ID_INTEL_MFD_SD,
782 .subvendor = PCI_ANY_ID,
783 .subdevice = PCI_ANY_ID,
784 .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_sd,
785 },
786
787 {
788 .vendor = PCI_VENDOR_ID_INTEL,
789 .device = PCI_DEVICE_ID_INTEL_MFD_SDIO1,
790 .subvendor = PCI_ANY_ID,
791 .subdevice = PCI_ANY_ID,
Adrian Hunter0d013bc2011-06-29 14:23:47 +0300792 .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_sdio,
Xiaochen Shen29229052010-10-04 15:24:52 +0100793 },
794
795 {
796 .vendor = PCI_VENDOR_ID_INTEL,
797 .device = PCI_DEVICE_ID_INTEL_MFD_SDIO2,
798 .subvendor = PCI_ANY_ID,
799 .subdevice = PCI_ANY_ID,
Adrian Hunter0d013bc2011-06-29 14:23:47 +0300800 .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_sdio,
Xiaochen Shen29229052010-10-04 15:24:52 +0100801 },
802
803 {
804 .vendor = PCI_VENDOR_ID_INTEL,
805 .device = PCI_DEVICE_ID_INTEL_MFD_EMMC0,
806 .subvendor = PCI_ANY_ID,
807 .subdevice = PCI_ANY_ID,
Adrian Hunter0d013bc2011-06-29 14:23:47 +0300808 .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_emmc,
Xiaochen Shen29229052010-10-04 15:24:52 +0100809 },
810
811 {
812 .vendor = PCI_VENDOR_ID_INTEL,
813 .device = PCI_DEVICE_ID_INTEL_MFD_EMMC1,
814 .subvendor = PCI_ANY_ID,
815 .subdevice = PCI_ANY_ID,
Adrian Hunter0d013bc2011-06-29 14:23:47 +0300816 .driver_data = (kernel_ulong_t)&sdhci_intel_mfd_emmc,
Xiaochen Shen29229052010-10-04 15:24:52 +0100817 },
818
Jennifer Li26daa1e2010-11-17 23:01:59 -0500819 {
820 .vendor = PCI_VENDOR_ID_O2,
821 .device = PCI_DEVICE_ID_O2_8120,
822 .subvendor = PCI_ANY_ID,
823 .subdevice = PCI_ANY_ID,
824 .driver_data = (kernel_ulong_t)&sdhci_o2,
825 },
826
827 {
828 .vendor = PCI_VENDOR_ID_O2,
829 .device = PCI_DEVICE_ID_O2_8220,
830 .subvendor = PCI_ANY_ID,
831 .subdevice = PCI_ANY_ID,
832 .driver_data = (kernel_ulong_t)&sdhci_o2,
833 },
834
835 {
836 .vendor = PCI_VENDOR_ID_O2,
837 .device = PCI_DEVICE_ID_O2_8221,
838 .subvendor = PCI_ANY_ID,
839 .subdevice = PCI_ANY_ID,
840 .driver_data = (kernel_ulong_t)&sdhci_o2,
841 },
842
843 {
844 .vendor = PCI_VENDOR_ID_O2,
845 .device = PCI_DEVICE_ID_O2_8320,
846 .subvendor = PCI_ANY_ID,
847 .subdevice = PCI_ANY_ID,
848 .driver_data = (kernel_ulong_t)&sdhci_o2,
849 },
850
851 {
852 .vendor = PCI_VENDOR_ID_O2,
853 .device = PCI_DEVICE_ID_O2_8321,
854 .subvendor = PCI_ANY_ID,
855 .subdevice = PCI_ANY_ID,
856 .driver_data = (kernel_ulong_t)&sdhci_o2,
857 },
858
Pierre Ossman22606402008-03-23 19:33:23 +0100859 { /* Generic SD host controller */
860 PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)
861 },
862
863 { /* end: all zeroes */ },
864};
865
866MODULE_DEVICE_TABLE(pci, pci_ids);
867
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100868/*****************************************************************************\
869 * *
870 * SDHCI core callbacks *
871 * *
872\*****************************************************************************/
873
874static int sdhci_pci_enable_dma(struct sdhci_host *host)
875{
876 struct sdhci_pci_slot *slot;
877 struct pci_dev *pdev;
878 int ret;
879
880 slot = sdhci_priv(host);
881 pdev = slot->chip->pdev;
882
883 if (((pdev->class & 0xFFFF00) == (PCI_CLASS_SYSTEM_SDHCI << 8)) &&
884 ((pdev->class & 0x0000FF) != PCI_SDHCI_IFDMA) &&
Richard Röjforsa13abc72009-09-22 16:45:30 -0700885 (host->flags & SDHCI_USE_SDMA)) {
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100886 dev_warn(&pdev->dev, "Will use DMA mode even though HW "
887 "doesn't fully claim to support it.\n");
888 }
889
Yang Hongyang284901a2009-04-06 19:01:15 -0700890 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100891 if (ret)
892 return ret;
893
894 pci_set_master(pdev);
895
896 return 0;
897}
898
Major Lee68077b02011-06-29 14:23:46 +0300899static int sdhci_pci_8bit_width(struct sdhci_host *host, int width)
900{
901 u8 ctrl;
902
903 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
904
905 switch (width) {
906 case MMC_BUS_WIDTH_8:
907 ctrl |= SDHCI_CTRL_8BITBUS;
908 ctrl &= ~SDHCI_CTRL_4BITBUS;
909 break;
910 case MMC_BUS_WIDTH_4:
911 ctrl |= SDHCI_CTRL_4BITBUS;
912 ctrl &= ~SDHCI_CTRL_8BITBUS;
913 break;
914 default:
915 ctrl &= ~(SDHCI_CTRL_8BITBUS | SDHCI_CTRL_4BITBUS);
916 break;
917 }
918
919 sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
920
921 return 0;
922}
923
Adrian Hunter0f201652011-08-29 16:42:13 +0300924static void sdhci_pci_hw_reset(struct sdhci_host *host)
925{
926 struct sdhci_pci_slot *slot = sdhci_priv(host);
927 int rst_n_gpio = slot->rst_n_gpio;
928
929 if (!gpio_is_valid(rst_n_gpio))
930 return;
931 gpio_set_value_cansleep(rst_n_gpio, 0);
932 /* For eMMC, minimum is 1us but give it 10us for good measure */
933 udelay(10);
934 gpio_set_value_cansleep(rst_n_gpio, 1);
935 /* For eMMC, minimum is 200us but give it 300us for good measure */
936 usleep_range(300, 1000);
937}
938
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100939static struct sdhci_ops sdhci_pci_ops = {
940 .enable_dma = sdhci_pci_enable_dma,
Major Lee68077b02011-06-29 14:23:46 +0300941 .platform_8bit_width = sdhci_pci_8bit_width,
Adrian Hunter0f201652011-08-29 16:42:13 +0300942 .hw_reset = sdhci_pci_hw_reset,
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100943};
944
945/*****************************************************************************\
946 * *
947 * Suspend/resume *
948 * *
949\*****************************************************************************/
950
951#ifdef CONFIG_PM
952
Manuel Lauss29495aa2011-11-03 11:09:45 +0100953static int sdhci_pci_suspend(struct device *dev)
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100954{
Manuel Lauss29495aa2011-11-03 11:09:45 +0100955 struct pci_dev *pdev = to_pci_dev(dev);
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100956 struct sdhci_pci_chip *chip;
957 struct sdhci_pci_slot *slot;
Daniel Drake5f619702010-11-04 22:20:39 +0000958 mmc_pm_flag_t slot_pm_flags;
Nicolas Pitre2f4cbb32010-03-05 13:43:32 -0800959 mmc_pm_flag_t pm_flags = 0;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100960 int i, ret;
961
962 chip = pci_get_drvdata(pdev);
963 if (!chip)
964 return 0;
965
Ameya Palandeb177bc92011-04-05 21:13:13 +0300966 for (i = 0; i < chip->num_slots; i++) {
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100967 slot = chip->slots[i];
968 if (!slot)
969 continue;
970
Manuel Lauss29495aa2011-11-03 11:09:45 +0100971 ret = sdhci_suspend_host(slot->host);
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100972
Axel Linb678b912011-12-03 15:28:05 +0800973 if (ret)
974 goto err_pci_suspend;
Nicolas Pitre2f4cbb32010-03-05 13:43:32 -0800975
Daniel Drake5f619702010-11-04 22:20:39 +0000976 slot_pm_flags = slot->host->mmc->pm_flags;
977 if (slot_pm_flags & MMC_PM_WAKE_SDIO_IRQ)
978 sdhci_enable_irq_wakeups(slot->host);
979
980 pm_flags |= slot_pm_flags;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100981 }
982
Pierre Ossman44894282008-04-04 19:36:59 +0200983 if (chip->fixes && chip->fixes->suspend) {
Manuel Lauss29495aa2011-11-03 11:09:45 +0100984 ret = chip->fixes->suspend(chip);
Axel Linb678b912011-12-03 15:28:05 +0800985 if (ret)
986 goto err_pci_suspend;
Pierre Ossman44894282008-04-04 19:36:59 +0200987 }
988
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +0100989 pci_save_state(pdev);
Nicolas Pitre2f4cbb32010-03-05 13:43:32 -0800990 if (pm_flags & MMC_PM_KEEP_POWER) {
Daniel Drake5f619702010-11-04 22:20:39 +0000991 if (pm_flags & MMC_PM_WAKE_SDIO_IRQ) {
992 pci_pme_active(pdev, true);
Nicolas Pitre2f4cbb32010-03-05 13:43:32 -0800993 pci_enable_wake(pdev, PCI_D3hot, 1);
Daniel Drake5f619702010-11-04 22:20:39 +0000994 }
Nicolas Pitre2f4cbb32010-03-05 13:43:32 -0800995 pci_set_power_state(pdev, PCI_D3hot);
996 } else {
Manuel Lauss29495aa2011-11-03 11:09:45 +0100997 pci_enable_wake(pdev, PCI_D3hot, 0);
Nicolas Pitre2f4cbb32010-03-05 13:43:32 -0800998 pci_disable_device(pdev);
Manuel Lauss29495aa2011-11-03 11:09:45 +0100999 pci_set_power_state(pdev, PCI_D3hot);
Nicolas Pitre2f4cbb32010-03-05 13:43:32 -08001000 }
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001001
1002 return 0;
Axel Linb678b912011-12-03 15:28:05 +08001003
1004err_pci_suspend:
1005 while (--i >= 0)
1006 sdhci_resume_host(chip->slots[i]->host);
1007 return ret;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001008}
1009
Manuel Lauss29495aa2011-11-03 11:09:45 +01001010static int sdhci_pci_resume(struct device *dev)
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001011{
Manuel Lauss29495aa2011-11-03 11:09:45 +01001012 struct pci_dev *pdev = to_pci_dev(dev);
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001013 struct sdhci_pci_chip *chip;
1014 struct sdhci_pci_slot *slot;
1015 int i, ret;
1016
1017 chip = pci_get_drvdata(pdev);
1018 if (!chip)
1019 return 0;
1020
1021 pci_set_power_state(pdev, PCI_D0);
1022 pci_restore_state(pdev);
1023 ret = pci_enable_device(pdev);
1024 if (ret)
1025 return ret;
1026
Pierre Ossman45211e22008-03-24 13:09:09 +01001027 if (chip->fixes && chip->fixes->resume) {
1028 ret = chip->fixes->resume(chip);
1029 if (ret)
1030 return ret;
1031 }
1032
Ameya Palandeb177bc92011-04-05 21:13:13 +03001033 for (i = 0; i < chip->num_slots; i++) {
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001034 slot = chip->slots[i];
1035 if (!slot)
1036 continue;
1037
1038 ret = sdhci_resume_host(slot->host);
1039 if (ret)
1040 return ret;
1041 }
1042
1043 return 0;
1044}
1045
1046#else /* CONFIG_PM */
1047
1048#define sdhci_pci_suspend NULL
1049#define sdhci_pci_resume NULL
1050
1051#endif /* CONFIG_PM */
1052
Adrian Hunter66fd8ad2011-10-03 15:33:34 +03001053#ifdef CONFIG_PM_RUNTIME
1054
1055static int sdhci_pci_runtime_suspend(struct device *dev)
1056{
1057 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
1058 struct sdhci_pci_chip *chip;
1059 struct sdhci_pci_slot *slot;
Adrian Hunter66fd8ad2011-10-03 15:33:34 +03001060 int i, ret;
1061
1062 chip = pci_get_drvdata(pdev);
1063 if (!chip)
1064 return 0;
1065
1066 for (i = 0; i < chip->num_slots; i++) {
1067 slot = chip->slots[i];
1068 if (!slot)
1069 continue;
1070
1071 ret = sdhci_runtime_suspend_host(slot->host);
1072
Axel Linb678b912011-12-03 15:28:05 +08001073 if (ret)
1074 goto err_pci_runtime_suspend;
Adrian Hunter66fd8ad2011-10-03 15:33:34 +03001075 }
1076
1077 if (chip->fixes && chip->fixes->suspend) {
Manuel Lauss29495aa2011-11-03 11:09:45 +01001078 ret = chip->fixes->suspend(chip);
Axel Linb678b912011-12-03 15:28:05 +08001079 if (ret)
1080 goto err_pci_runtime_suspend;
Adrian Hunter66fd8ad2011-10-03 15:33:34 +03001081 }
1082
1083 return 0;
Axel Linb678b912011-12-03 15:28:05 +08001084
1085err_pci_runtime_suspend:
1086 while (--i >= 0)
1087 sdhci_runtime_resume_host(chip->slots[i]->host);
1088 return ret;
Adrian Hunter66fd8ad2011-10-03 15:33:34 +03001089}
1090
1091static int sdhci_pci_runtime_resume(struct device *dev)
1092{
1093 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
1094 struct sdhci_pci_chip *chip;
1095 struct sdhci_pci_slot *slot;
1096 int i, ret;
1097
1098 chip = pci_get_drvdata(pdev);
1099 if (!chip)
1100 return 0;
1101
1102 if (chip->fixes && chip->fixes->resume) {
1103 ret = chip->fixes->resume(chip);
1104 if (ret)
1105 return ret;
1106 }
1107
1108 for (i = 0; i < chip->num_slots; i++) {
1109 slot = chip->slots[i];
1110 if (!slot)
1111 continue;
1112
1113 ret = sdhci_runtime_resume_host(slot->host);
1114 if (ret)
1115 return ret;
1116 }
1117
1118 return 0;
1119}
1120
1121static int sdhci_pci_runtime_idle(struct device *dev)
1122{
1123 return 0;
1124}
1125
1126#else
1127
1128#define sdhci_pci_runtime_suspend NULL
1129#define sdhci_pci_runtime_resume NULL
1130#define sdhci_pci_runtime_idle NULL
1131
1132#endif
1133
1134static const struct dev_pm_ops sdhci_pci_pm_ops = {
Manuel Lauss29495aa2011-11-03 11:09:45 +01001135 .suspend = sdhci_pci_suspend,
1136 .resume = sdhci_pci_resume,
Adrian Hunter66fd8ad2011-10-03 15:33:34 +03001137 .runtime_suspend = sdhci_pci_runtime_suspend,
1138 .runtime_resume = sdhci_pci_runtime_resume,
1139 .runtime_idle = sdhci_pci_runtime_idle,
1140};
1141
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001142/*****************************************************************************\
1143 * *
1144 * Device probing/removal *
1145 * *
1146\*****************************************************************************/
1147
1148static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot(
Adrian Hunter52c506f2011-12-27 15:48:43 +02001149 struct pci_dev *pdev, struct sdhci_pci_chip *chip, int first_bar,
1150 int slotno)
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001151{
1152 struct sdhci_pci_slot *slot;
1153 struct sdhci_host *host;
Adrian Hunter52c506f2011-12-27 15:48:43 +02001154 int ret, bar = first_bar + slotno;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001155
1156 if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
1157 dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
1158 return ERR_PTR(-ENODEV);
1159 }
1160
1161 if (pci_resource_len(pdev, bar) != 0x100) {
1162 dev_err(&pdev->dev, "Invalid iomem size. You may "
1163 "experience problems.\n");
1164 }
1165
1166 if ((pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) {
1167 dev_err(&pdev->dev, "Vendor specific interface. Aborting.\n");
1168 return ERR_PTR(-ENODEV);
1169 }
1170
1171 if ((pdev->class & 0x0000FF) > PCI_SDHCI_IFVENDOR) {
1172 dev_err(&pdev->dev, "Unknown interface. Aborting.\n");
1173 return ERR_PTR(-ENODEV);
1174 }
1175
1176 host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pci_slot));
1177 if (IS_ERR(host)) {
Dan Carpenterc60a32c2009-04-10 23:31:10 +02001178 dev_err(&pdev->dev, "cannot allocate host\n");
Julia Lawalldc0fd7b2010-05-26 14:42:11 -07001179 return ERR_CAST(host);
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001180 }
1181
1182 slot = sdhci_priv(host);
1183
1184 slot->chip = chip;
1185 slot->host = host;
1186 slot->pci_bar = bar;
Adrian Hunter0f201652011-08-29 16:42:13 +03001187 slot->rst_n_gpio = -EINVAL;
Adrian Hunterc5e027a2011-12-27 15:48:44 +02001188 slot->cd_gpio = -EINVAL;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001189
Adrian Hunter52c506f2011-12-27 15:48:43 +02001190 /* Retrieve platform data if there is any */
1191 if (*sdhci_pci_get_data)
1192 slot->data = sdhci_pci_get_data(pdev, slotno);
1193
1194 if (slot->data) {
1195 if (slot->data->setup) {
1196 ret = slot->data->setup(slot->data);
1197 if (ret) {
1198 dev_err(&pdev->dev, "platform setup failed\n");
1199 goto free;
1200 }
1201 }
Adrian Hunterc5e027a2011-12-27 15:48:44 +02001202 slot->rst_n_gpio = slot->data->rst_n_gpio;
1203 slot->cd_gpio = slot->data->cd_gpio;
Adrian Hunter52c506f2011-12-27 15:48:43 +02001204 }
1205
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001206 host->hw_name = "PCI";
1207 host->ops = &sdhci_pci_ops;
1208 host->quirks = chip->quirks;
1209
1210 host->irq = pdev->irq;
1211
1212 ret = pci_request_region(pdev, bar, mmc_hostname(host->mmc));
1213 if (ret) {
1214 dev_err(&pdev->dev, "cannot request region\n");
Adrian Hunter52c506f2011-12-27 15:48:43 +02001215 goto cleanup;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001216 }
1217
Arjan van de Ven092f82e2008-09-28 16:15:56 -07001218 host->ioaddr = pci_ioremap_bar(pdev, bar);
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001219 if (!host->ioaddr) {
1220 dev_err(&pdev->dev, "failed to remap registers\n");
Chris Ball9fdcdbb2011-03-29 00:46:12 -04001221 ret = -ENOMEM;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001222 goto release;
1223 }
1224
Pierre Ossman44894282008-04-04 19:36:59 +02001225 if (chip->fixes && chip->fixes->probe_slot) {
1226 ret = chip->fixes->probe_slot(slot);
1227 if (ret)
1228 goto unmap;
1229 }
1230
Adrian Hunterc5e027a2011-12-27 15:48:44 +02001231 if (gpio_is_valid(slot->rst_n_gpio)) {
1232 if (!gpio_request(slot->rst_n_gpio, "eMMC_reset")) {
1233 gpio_direction_output(slot->rst_n_gpio, 1);
1234 slot->host->mmc->caps |= MMC_CAP_HW_RESET;
1235 } else {
1236 dev_warn(&pdev->dev, "failed to request rst_n_gpio\n");
1237 slot->rst_n_gpio = -EINVAL;
1238 }
1239 }
1240
Nicolas Pitre2f4cbb32010-03-05 13:43:32 -08001241 host->mmc->pm_caps = MMC_PM_KEEP_POWER | MMC_PM_WAKE_SDIO_IRQ;
1242
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001243 ret = sdhci_add_host(host);
1244 if (ret)
Pierre Ossman44894282008-04-04 19:36:59 +02001245 goto remove;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001246
Adrian Hunterc5e027a2011-12-27 15:48:44 +02001247 sdhci_pci_add_own_cd(slot);
1248
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001249 return slot;
1250
Pierre Ossman44894282008-04-04 19:36:59 +02001251remove:
Adrian Hunterc5e027a2011-12-27 15:48:44 +02001252 if (gpio_is_valid(slot->rst_n_gpio))
1253 gpio_free(slot->rst_n_gpio);
1254
Pierre Ossman44894282008-04-04 19:36:59 +02001255 if (chip->fixes && chip->fixes->remove_slot)
Pierre Ossman1e728592008-04-16 19:13:13 +02001256 chip->fixes->remove_slot(slot, 0);
Pierre Ossman44894282008-04-04 19:36:59 +02001257
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001258unmap:
1259 iounmap(host->ioaddr);
1260
1261release:
1262 pci_release_region(pdev, bar);
Dan Carpenterc60a32c2009-04-10 23:31:10 +02001263
Adrian Hunter52c506f2011-12-27 15:48:43 +02001264cleanup:
1265 if (slot->data && slot->data->cleanup)
1266 slot->data->cleanup(slot->data);
1267
Dan Carpenterc60a32c2009-04-10 23:31:10 +02001268free:
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001269 sdhci_free_host(host);
1270
1271 return ERR_PTR(ret);
1272}
1273
1274static void sdhci_pci_remove_slot(struct sdhci_pci_slot *slot)
1275{
Pierre Ossman1e728592008-04-16 19:13:13 +02001276 int dead;
1277 u32 scratch;
1278
Adrian Hunterc5e027a2011-12-27 15:48:44 +02001279 sdhci_pci_remove_own_cd(slot);
1280
Pierre Ossman1e728592008-04-16 19:13:13 +02001281 dead = 0;
1282 scratch = readl(slot->host->ioaddr + SDHCI_INT_STATUS);
1283 if (scratch == (u32)-1)
1284 dead = 1;
1285
1286 sdhci_remove_host(slot->host, dead);
Pierre Ossman44894282008-04-04 19:36:59 +02001287
Adrian Hunterc5e027a2011-12-27 15:48:44 +02001288 if (gpio_is_valid(slot->rst_n_gpio))
1289 gpio_free(slot->rst_n_gpio);
1290
Pierre Ossman44894282008-04-04 19:36:59 +02001291 if (slot->chip->fixes && slot->chip->fixes->remove_slot)
Pierre Ossman1e728592008-04-16 19:13:13 +02001292 slot->chip->fixes->remove_slot(slot, dead);
Pierre Ossman44894282008-04-04 19:36:59 +02001293
Adrian Hunter52c506f2011-12-27 15:48:43 +02001294 if (slot->data && slot->data->cleanup)
1295 slot->data->cleanup(slot->data);
1296
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001297 pci_release_region(slot->chip->pdev, slot->pci_bar);
Pierre Ossman44894282008-04-04 19:36:59 +02001298
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001299 sdhci_free_host(slot->host);
1300}
1301
Adrian Hunter66fd8ad2011-10-03 15:33:34 +03001302static void __devinit sdhci_pci_runtime_pm_allow(struct device *dev)
1303{
1304 pm_runtime_put_noidle(dev);
1305 pm_runtime_allow(dev);
1306 pm_runtime_set_autosuspend_delay(dev, 50);
1307 pm_runtime_use_autosuspend(dev);
1308 pm_suspend_ignore_children(dev, 1);
1309}
1310
1311static void __devexit sdhci_pci_runtime_pm_forbid(struct device *dev)
1312{
1313 pm_runtime_forbid(dev);
1314 pm_runtime_get_noresume(dev);
1315}
1316
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001317static int __devinit sdhci_pci_probe(struct pci_dev *pdev,
1318 const struct pci_device_id *ent)
1319{
1320 struct sdhci_pci_chip *chip;
1321 struct sdhci_pci_slot *slot;
1322
Sergei Shtylyovcf5e23e2011-03-17 16:46:17 -04001323 u8 slots, first_bar;
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001324 int ret, i;
1325
1326 BUG_ON(pdev == NULL);
1327 BUG_ON(ent == NULL);
1328
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001329 dev_info(&pdev->dev, "SDHCI controller found [%04x:%04x] (rev %x)\n",
Sergei Shtylyovcf5e23e2011-03-17 16:46:17 -04001330 (int)pdev->vendor, (int)pdev->device, (int)pdev->revision);
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001331
1332 ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots);
1333 if (ret)
1334 return ret;
1335
1336 slots = PCI_SLOT_INFO_SLOTS(slots) + 1;
1337 dev_dbg(&pdev->dev, "found %d slot(s)\n", slots);
1338 if (slots == 0)
1339 return -ENODEV;
1340
1341 BUG_ON(slots > MAX_SLOTS);
1342
1343 ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &first_bar);
1344 if (ret)
1345 return ret;
1346
1347 first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK;
1348
1349 if (first_bar > 5) {
1350 dev_err(&pdev->dev, "Invalid first BAR. Aborting.\n");
1351 return -ENODEV;
1352 }
1353
1354 ret = pci_enable_device(pdev);
1355 if (ret)
1356 return ret;
1357
1358 chip = kzalloc(sizeof(struct sdhci_pci_chip), GFP_KERNEL);
1359 if (!chip) {
1360 ret = -ENOMEM;
1361 goto err;
1362 }
1363
1364 chip->pdev = pdev;
Ameya Palandeb177bc92011-04-05 21:13:13 +03001365 chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data;
Adrian Hunterc43fd772011-10-17 10:52:44 +03001366 if (chip->fixes) {
Pierre Ossman22606402008-03-23 19:33:23 +01001367 chip->quirks = chip->fixes->quirks;
Adrian Hunterc43fd772011-10-17 10:52:44 +03001368 chip->allow_runtime_pm = chip->fixes->allow_runtime_pm;
1369 }
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001370 chip->num_slots = slots;
1371
1372 pci_set_drvdata(pdev, chip);
1373
Pierre Ossman22606402008-03-23 19:33:23 +01001374 if (chip->fixes && chip->fixes->probe) {
1375 ret = chip->fixes->probe(chip);
1376 if (ret)
1377 goto free;
1378 }
1379
Alan Cox225d85f2010-10-04 15:24:21 +01001380 slots = chip->num_slots; /* Quirk may have changed this */
1381
Ameya Palandeb177bc92011-04-05 21:13:13 +03001382 for (i = 0; i < slots; i++) {
Adrian Hunter52c506f2011-12-27 15:48:43 +02001383 slot = sdhci_pci_probe_slot(pdev, chip, first_bar, i);
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001384 if (IS_ERR(slot)) {
Ameya Palandeb177bc92011-04-05 21:13:13 +03001385 for (i--; i >= 0; i--)
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001386 sdhci_pci_remove_slot(chip->slots[i]);
1387 ret = PTR_ERR(slot);
1388 goto free;
1389 }
1390
1391 chip->slots[i] = slot;
1392 }
1393
Adrian Hunterc43fd772011-10-17 10:52:44 +03001394 if (chip->allow_runtime_pm)
1395 sdhci_pci_runtime_pm_allow(&pdev->dev);
Adrian Hunter66fd8ad2011-10-03 15:33:34 +03001396
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001397 return 0;
1398
1399free:
1400 pci_set_drvdata(pdev, NULL);
1401 kfree(chip);
1402
1403err:
1404 pci_disable_device(pdev);
1405 return ret;
1406}
1407
1408static void __devexit sdhci_pci_remove(struct pci_dev *pdev)
1409{
1410 int i;
1411 struct sdhci_pci_chip *chip;
1412
1413 chip = pci_get_drvdata(pdev);
1414
1415 if (chip) {
Adrian Hunterc43fd772011-10-17 10:52:44 +03001416 if (chip->allow_runtime_pm)
1417 sdhci_pci_runtime_pm_forbid(&pdev->dev);
1418
Ameya Palandeb177bc92011-04-05 21:13:13 +03001419 for (i = 0; i < chip->num_slots; i++)
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001420 sdhci_pci_remove_slot(chip->slots[i]);
1421
1422 pci_set_drvdata(pdev, NULL);
1423 kfree(chip);
1424 }
1425
1426 pci_disable_device(pdev);
1427}
1428
1429static struct pci_driver sdhci_driver = {
Ameya Palandeb177bc92011-04-05 21:13:13 +03001430 .name = "sdhci-pci",
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001431 .id_table = pci_ids,
Ameya Palandeb177bc92011-04-05 21:13:13 +03001432 .probe = sdhci_pci_probe,
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001433 .remove = __devexit_p(sdhci_pci_remove),
Adrian Hunter66fd8ad2011-10-03 15:33:34 +03001434 .driver = {
1435 .pm = &sdhci_pci_pm_ops
1436 },
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001437};
1438
1439/*****************************************************************************\
1440 * *
1441 * Driver init/exit *
1442 * *
1443\*****************************************************************************/
1444
1445static int __init sdhci_drv_init(void)
1446{
1447 return pci_register_driver(&sdhci_driver);
1448}
1449
1450static void __exit sdhci_drv_exit(void)
1451{
1452 pci_unregister_driver(&sdhci_driver);
1453}
1454
1455module_init(sdhci_drv_init);
1456module_exit(sdhci_drv_exit);
1457
Pierre Ossman32710e82009-04-08 20:14:54 +02001458MODULE_AUTHOR("Pierre Ossman <pierre@ossman.eu>");
Pierre Ossmanb8c86fc2008-03-18 17:35:49 +01001459MODULE_DESCRIPTION("Secure Digital Host Controller Interface PCI driver");
1460MODULE_LICENSE("GPL");