Merge tag 'regulator-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[linux-2.6-block.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>
53b27288 17#include <linux/pm_runtime.h>
62ca8034
SH
18#include <linux/slab.h>
19#include <linux/mmc/host.h>
20#include <linux/mmc/mmc.h>
62ca8034
SH
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 = {
62ca8034
SH
32 .caps = DW_MCI_CAPABILITIES,
33 .bus_hz = 33 * 1000 * 1000,
34 .detect_delay_ms = 200,
35 .fifo_depth = 32,
36};
37
c3be1efd 38static int dw_mci_pci_probe(struct pci_dev *pdev,
13959741 39 const struct pci_device_id *entries)
62ca8034
SH
40{
41 struct dw_mci *host;
42 int ret;
43
13959741 44 ret = pcim_enable_device(pdev);
62ca8034
SH
45 if (ret)
46 return ret;
62ca8034 47
13959741
AS
48 host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
49 if (!host)
50 return -ENOMEM;
62ca8034
SH
51
52 host->irq = pdev->irq;
53 host->irq_flags = IRQF_SHARED;
4a90920c 54 host->dev = &pdev->dev;
62ca8034
SH
55 host->pdata = &pci_board_data;
56
13959741
AS
57 ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev));
58 if (ret)
59 return ret;
60
afeb52d6 61 host->regs = pcim_iomap_table(pdev)[PCI_BAR_NO];
62ca8034 62
638585f6
AS
63 pci_set_master(pdev);
64
62ca8034
SH
65 ret = dw_mci_probe(host);
66 if (ret)
13959741
AS
67 return ret;
68
69 pci_set_drvdata(pdev, host);
62ca8034 70
13959741 71 return 0;
62ca8034
SH
72}
73
6e0ee714 74static void dw_mci_pci_remove(struct pci_dev *pdev)
62ca8034
SH
75{
76 struct dw_mci *host = pci_get_drvdata(pdev);
77
78 dw_mci_remove(host);
62ca8034
SH
79}
80
53b27288
SL
81static const struct dev_pm_ops dw_mci_pci_dev_pm_ops = {
82 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
83 pm_runtime_force_resume)
84 SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend,
85 dw_mci_runtime_resume,
86 NULL)
87};
62ca8034 88
9baa3c34 89static const struct pci_device_id dw_mci_pci_id[] = {
62ca8034
SH
90 { PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) },
91 {}
92};
93MODULE_DEVICE_TABLE(pci, dw_mci_pci_id);
94
95static struct pci_driver dw_mci_pci_driver = {
96 .name = "dw_mmc_pci",
97 .id_table = dw_mci_pci_id,
98 .probe = dw_mci_pci_probe,
4e608e4e 99 .remove = dw_mci_pci_remove,
62ca8034 100 .driver = {
53b27288 101 .pm = &dw_mci_pci_dev_pm_ops,
62ca8034
SH
102 },
103};
104
350e3e00 105module_pci_driver(dw_mci_pci_driver);
62ca8034
SH
106
107MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver");
108MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>");
109MODULE_LICENSE("GPL v2");