mmc: dw_mmc-pci: get resources from a proper BAR
[deliverable/linux.git] / drivers / mmc / host / dw_mmc-pci.c
CommitLineData
62ca8034
SH
1/*
2 * Synopsys DesignWare Multimedia Card PCI Interface driver
3 *
4 * Copyright (C) 2012 Vayavya Labs Pvt. Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/interrupt.h>
13#include <linux/module.h>
14#include <linux/io.h>
15#include <linux/irq.h>
16#include <linux/pci.h>
17#include <linux/slab.h>
18#include <linux/mmc/host.h>
19#include <linux/mmc/mmc.h>
20#include <linux/mmc/dw_mmc.h>
21#include "dw_mmc.h"
22
23#define PCI_BAR_NO 2
62ca8034
SH
24#define SYNOPSYS_DW_MCI_VENDOR_ID 0x700
25#define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
26/* Defining the Capabilities */
27#define DW_MCI_CAPABILITIES (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |\
28 MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\
29 MMC_CAP_SDIO_IRQ)
30
31static struct dw_mci_board pci_board_data = {
32 .num_slots = 1,
33 .caps = DW_MCI_CAPABILITIES,
34 .bus_hz = 33 * 1000 * 1000,
35 .detect_delay_ms = 200,
36 .fifo_depth = 32,
37};
38
c3be1efd 39static int dw_mci_pci_probe(struct pci_dev *pdev,
13959741 40 const struct pci_device_id *entries)
62ca8034
SH
41{
42 struct dw_mci *host;
43 int ret;
44
13959741 45 ret = pcim_enable_device(pdev);
62ca8034
SH
46 if (ret)
47 return ret;
62ca8034 48
13959741
AS
49 host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
50 if (!host)
51 return -ENOMEM;
62ca8034
SH
52
53 host->irq = pdev->irq;
54 host->irq_flags = IRQF_SHARED;
4a90920c 55 host->dev = &pdev->dev;
62ca8034
SH
56 host->pdata = &pci_board_data;
57
13959741
AS
58 ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev));
59 if (ret)
60 return ret;
61
afeb52d6 62 host->regs = pcim_iomap_table(pdev)[PCI_BAR_NO];
62ca8034 63
62ca8034
SH
64 ret = dw_mci_probe(host);
65 if (ret)
13959741
AS
66 return ret;
67
68 pci_set_drvdata(pdev, host);
62ca8034 69
13959741 70 return 0;
62ca8034
SH
71}
72
6e0ee714 73static void dw_mci_pci_remove(struct pci_dev *pdev)
62ca8034
SH
74{
75 struct dw_mci *host = pci_get_drvdata(pdev);
76
77 dw_mci_remove(host);
62ca8034
SH
78}
79
80#ifdef CONFIG_PM_SLEEP
81static int dw_mci_pci_suspend(struct device *dev)
82{
62ca8034
SH
83 struct pci_dev *pdev = to_pci_dev(dev);
84 struct dw_mci *host = pci_get_drvdata(pdev);
85
dd369800 86 return dw_mci_suspend(host);
62ca8034
SH
87}
88
89static int dw_mci_pci_resume(struct device *dev)
90{
62ca8034
SH
91 struct pci_dev *pdev = to_pci_dev(dev);
92 struct dw_mci *host = pci_get_drvdata(pdev);
93
dd369800 94 return dw_mci_resume(host);
62ca8034
SH
95}
96#else
97#define dw_mci_pci_suspend NULL
98#define dw_mci_pci_resume NULL
99#endif /* CONFIG_PM_SLEEP */
100
101static SIMPLE_DEV_PM_OPS(dw_mci_pci_pmops, dw_mci_pci_suspend, dw_mci_pci_resume);
102
103static DEFINE_PCI_DEVICE_TABLE(dw_mci_pci_id) = {
104 { PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) },
105 {}
106};
107MODULE_DEVICE_TABLE(pci, dw_mci_pci_id);
108
109static struct pci_driver dw_mci_pci_driver = {
110 .name = "dw_mmc_pci",
111 .id_table = dw_mci_pci_id,
112 .probe = dw_mci_pci_probe,
4e608e4e 113 .remove = dw_mci_pci_remove,
62ca8034
SH
114 .driver = {
115 .pm = &dw_mci_pci_pmops
116 },
117};
118
350e3e00 119module_pci_driver(dw_mci_pci_driver);
62ca8034
SH
120
121MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver");
122MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>");
123MODULE_LICENSE("GPL v2");
This page took 0.095577 seconds and 5 git commands to generate.