2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2012-01-13 18:34:57 +08:00
|
|
|
/*
|
|
|
|
* Synopsys DesignWare Multimedia Card PCI Interface driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Vayavya Labs Pvt. Ltd.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/pci.h>
|
2016-10-12 10:56:34 +08:00
|
|
|
#include <linux/pm_runtime.h>
|
2012-01-13 18:34:57 +08:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/mmc/host.h>
|
|
|
|
#include <linux/mmc/mmc.h>
|
|
|
|
#include "dw_mmc.h"
|
|
|
|
|
|
|
|
#define PCI_BAR_NO 2
|
|
|
|
#define SYNOPSYS_DW_MCI_VENDOR_ID 0x700
|
|
|
|
#define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
|
|
|
|
/* Defining the Capabilities */
|
|
|
|
#define DW_MCI_CAPABILITIES (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |\
|
|
|
|
MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\
|
|
|
|
MMC_CAP_SDIO_IRQ)
|
|
|
|
|
|
|
|
static struct dw_mci_board pci_board_data = {
|
|
|
|
.caps = DW_MCI_CAPABILITIES,
|
|
|
|
.bus_hz = 33 * 1000 * 1000,
|
|
|
|
.detect_delay_ms = 200,
|
|
|
|
.fifo_depth = 32,
|
|
|
|
};
|
|
|
|
|
2012-11-20 02:23:06 +08:00
|
|
|
static int dw_mci_pci_probe(struct pci_dev *pdev,
|
2013-06-05 17:24:12 +08:00
|
|
|
const struct pci_device_id *entries)
|
2012-01-13 18:34:57 +08:00
|
|
|
{
|
|
|
|
struct dw_mci *host;
|
|
|
|
int ret;
|
|
|
|
|
2013-06-05 17:24:12 +08:00
|
|
|
ret = pcim_enable_device(pdev);
|
2012-01-13 18:34:57 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2013-06-05 17:24:12 +08:00
|
|
|
host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
|
|
|
|
if (!host)
|
|
|
|
return -ENOMEM;
|
2012-01-13 18:34:57 +08:00
|
|
|
|
|
|
|
host->irq = pdev->irq;
|
|
|
|
host->irq_flags = IRQF_SHARED;
|
2012-09-18 02:16:35 +08:00
|
|
|
host->dev = &pdev->dev;
|
2012-01-13 18:34:57 +08:00
|
|
|
host->pdata = &pci_board_data;
|
|
|
|
|
2013-06-05 17:24:12 +08:00
|
|
|
ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev));
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2013-08-08 18:44:57 +08:00
|
|
|
host->regs = pcim_iomap_table(pdev)[PCI_BAR_NO];
|
2012-01-13 18:34:57 +08:00
|
|
|
|
2013-08-08 18:44:58 +08:00
|
|
|
pci_set_master(pdev);
|
|
|
|
|
2012-01-13 18:34:57 +08:00
|
|
|
ret = dw_mci_probe(host);
|
|
|
|
if (ret)
|
2013-06-05 17:24:12 +08:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
pci_set_drvdata(pdev, host);
|
2012-01-13 18:34:57 +08:00
|
|
|
|
2013-06-05 17:24:12 +08:00
|
|
|
return 0;
|
2012-01-13 18:34:57 +08:00
|
|
|
}
|
|
|
|
|
2012-11-20 02:26:03 +08:00
|
|
|
static void dw_mci_pci_remove(struct pci_dev *pdev)
|
2012-01-13 18:34:57 +08:00
|
|
|
{
|
|
|
|
struct dw_mci *host = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
dw_mci_remove(host);
|
|
|
|
}
|
|
|
|
|
2016-10-12 10:56:34 +08:00
|
|
|
static const struct dev_pm_ops dw_mci_pci_dev_pm_ops = {
|
|
|
|
SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
|
|
|
|
pm_runtime_force_resume)
|
|
|
|
SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend,
|
|
|
|
dw_mci_runtime_resume,
|
|
|
|
NULL)
|
|
|
|
};
|
2012-01-13 18:34:57 +08:00
|
|
|
|
2014-08-08 21:56:03 +08:00
|
|
|
static const struct pci_device_id dw_mci_pci_id[] = {
|
2012-01-13 18:34:57 +08:00
|
|
|
{ PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, dw_mci_pci_id);
|
|
|
|
|
|
|
|
static struct pci_driver dw_mci_pci_driver = {
|
|
|
|
.name = "dw_mmc_pci",
|
|
|
|
.id_table = dw_mci_pci_id,
|
|
|
|
.probe = dw_mci_pci_probe,
|
2012-12-22 07:05:47 +08:00
|
|
|
.remove = dw_mci_pci_remove,
|
2012-01-13 18:34:57 +08:00
|
|
|
.driver = {
|
2016-10-12 10:56:34 +08:00
|
|
|
.pm = &dw_mci_pci_dev_pm_ops,
|
2012-01-13 18:34:57 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-08-27 14:29:17 +08:00
|
|
|
module_pci_driver(dw_mci_pci_driver);
|
2012-01-13 18:34:57 +08:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver");
|
|
|
|
MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>");
|
|
|
|
MODULE_LICENSE("GPL v2");
|