Linux Audio

Check our new training course

Loading...
v6.2
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 * Synopsys DesignWare Multimedia Card PCI Interface driver
  4 *
  5 * Copyright (C) 2012 Vayavya Labs Pvt. Ltd.
 
 
 
 
 
  6 */
  7
  8#include <linux/interrupt.h>
  9#include <linux/module.h>
 10#include <linux/io.h>
 11#include <linux/irq.h>
 12#include <linux/pci.h>
 13#include <linux/pm_runtime.h>
 14#include <linux/slab.h>
 15#include <linux/mmc/host.h>
 16#include <linux/mmc/mmc.h>
 
 17#include "dw_mmc.h"
 18
 19#define PCI_BAR_NO 2
 
 20#define SYNOPSYS_DW_MCI_VENDOR_ID 0x700
 21#define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
 22/* Defining the Capabilities */
 23#define DW_MCI_CAPABILITIES (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |\
 24				MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\
 25				MMC_CAP_SDIO_IRQ)
 26
 27static struct dw_mci_board pci_board_data = {
 
 28	.caps				= DW_MCI_CAPABILITIES,
 29	.bus_hz				= 33 * 1000 * 1000,
 30	.detect_delay_ms		= 200,
 31	.fifo_depth			= 32,
 32};
 33
 34static int dw_mci_pci_probe(struct pci_dev *pdev,
 35			    const struct pci_device_id *entries)
 36{
 37	struct dw_mci *host;
 38	int ret;
 39
 40	ret = pcim_enable_device(pdev);
 41	if (ret)
 42		return ret;
 43
 44	host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
 45	if (!host)
 46		return -ENOMEM;
 
 
 
 
 
 
 47
 48	host->irq = pdev->irq;
 49	host->irq_flags = IRQF_SHARED;
 50	host->dev = &pdev->dev;
 51	host->pdata = &pci_board_data;
 52
 53	ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev));
 
 
 
 
 
 
 
 54	if (ret)
 55		return ret;
 
 56
 57	host->regs = pcim_iomap_table(pdev)[PCI_BAR_NO];
 
 
 
 
 
 
 
 
 
 58
 59	pci_set_master(pdev);
 
 
 60
 61	ret = dw_mci_probe(host);
 62	if (ret)
 63		return ret;
 
 
 
 
 64
 65	pci_set_drvdata(pdev, host);
 
 
 
 
 
 66
 67	return 0;
 
 68}
 69
 70static void dw_mci_pci_remove(struct pci_dev *pdev)
 71{
 
 
 72	struct dw_mci *host = pci_get_drvdata(pdev);
 73
 74	dw_mci_remove(host);
 
 75}
 
 
 
 
 76
 77static const struct dev_pm_ops dw_mci_pci_dev_pm_ops = {
 78	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
 79				pm_runtime_force_resume)
 80	SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend,
 81			   dw_mci_runtime_resume,
 82			   NULL)
 83};
 84
 85static const struct pci_device_id dw_mci_pci_id[] = {
 86	{ PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) },
 87	{}
 88};
 89MODULE_DEVICE_TABLE(pci, dw_mci_pci_id);
 90
 91static struct pci_driver dw_mci_pci_driver = {
 92	.name		= "dw_mmc_pci",
 93	.id_table	= dw_mci_pci_id,
 94	.probe		= dw_mci_pci_probe,
 95	.remove		= dw_mci_pci_remove,
 96	.driver		=	{
 97		.pm =   &dw_mci_pci_dev_pm_ops,
 98	},
 99};
100
101module_pci_driver(dw_mci_pci_driver);
 
 
 
 
 
 
 
 
 
 
 
102
103MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver");
104MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>");
105MODULE_LICENSE("GPL v2");
v3.5.6
 
  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
 24#define COMPLETE_BAR 0
 25#define SYNOPSYS_DW_MCI_VENDOR_ID 0x700
 26#define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
 27/* Defining the Capabilities */
 28#define DW_MCI_CAPABILITIES (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |\
 29				MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\
 30				MMC_CAP_SDIO_IRQ)
 31
 32static struct dw_mci_board pci_board_data = {
 33	.num_slots			= 1,
 34	.caps				= DW_MCI_CAPABILITIES,
 35	.bus_hz				= 33 * 1000 * 1000,
 36	.detect_delay_ms		= 200,
 37	.fifo_depth			= 32,
 38};
 39
 40static int __devinit dw_mci_pci_probe(struct pci_dev *pdev,
 41				  const struct pci_device_id *entries)
 42{
 43	struct dw_mci *host;
 44	int ret;
 45
 46	ret = pci_enable_device(pdev);
 47	if (ret)
 48		return ret;
 49	if (pci_request_regions(pdev, "dw_mmc_pci")) {
 50		ret = -ENODEV;
 51		goto err_disable_dev;
 52	}
 53
 54	host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL);
 55	if (!host) {
 56		ret = -ENOMEM;
 57		goto err_release;
 58	}
 59
 60	host->irq = pdev->irq;
 61	host->irq_flags = IRQF_SHARED;
 62	host->dev = pdev->dev;
 63	host->pdata = &pci_board_data;
 64
 65	host->regs = pci_iomap(pdev, PCI_BAR_NO, COMPLETE_BAR);
 66	if (!host->regs) {
 67		ret = -EIO;
 68		goto err_unmap;
 69	}
 70
 71	pci_set_drvdata(pdev, host);
 72	ret = dw_mci_probe(host);
 73	if (ret)
 74		goto err_probe_failed;
 75	return ret;
 76
 77err_probe_failed:
 78	pci_iounmap(pdev, host->regs);
 79err_unmap:
 80	kfree(host);
 81err_release:
 82	pci_release_regions(pdev);
 83err_disable_dev:
 84	pci_disable_device(pdev);
 85	return ret;
 86}
 87
 88static void __devexit dw_mci_pci_remove(struct pci_dev *pdev)
 89{
 90	struct dw_mci *host = pci_get_drvdata(pdev);
 91
 92	dw_mci_remove(host);
 93	pci_set_drvdata(pdev, NULL);
 94	pci_release_regions(pdev);
 95	pci_iounmap(pdev, host->regs);
 96	kfree(host);
 97	pci_disable_device(pdev);
 98}
 99
100#ifdef CONFIG_PM_SLEEP
101static int dw_mci_pci_suspend(struct device *dev)
102{
103	int ret;
104	struct pci_dev *pdev = to_pci_dev(dev);
105	struct dw_mci *host = pci_get_drvdata(pdev);
106
107	ret = dw_mci_suspend(host);
108	return ret;
109}
110
111static int dw_mci_pci_resume(struct device *dev)
112{
113	int ret;
114	struct pci_dev *pdev = to_pci_dev(dev);
115	struct dw_mci *host = pci_get_drvdata(pdev);
116
117	ret = dw_mci_resume(host);
118	return ret;
119}
120#else
121#define dw_mci_pci_suspend	NULL
122#define dw_mci_pci_resume	NULL
123#endif /* CONFIG_PM_SLEEP */
124
125static SIMPLE_DEV_PM_OPS(dw_mci_pci_pmops, dw_mci_pci_suspend, dw_mci_pci_resume);
 
 
 
 
 
 
126
127static DEFINE_PCI_DEVICE_TABLE(dw_mci_pci_id) = {
128	{ PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) },
129	{}
130};
131MODULE_DEVICE_TABLE(pci, dw_mci_pci_id);
132
133static struct pci_driver dw_mci_pci_driver = {
134	.name		= "dw_mmc_pci",
135	.id_table	= dw_mci_pci_id,
136	.probe		= dw_mci_pci_probe,
137	.remove		= dw_mci_pci_remove,
138	.driver		=	{
139		.pm =   &dw_mci_pci_pmops
140	},
141};
142
143static int __init dw_mci_init(void)
144{
145	return pci_register_driver(&dw_mci_pci_driver);
146}
147
148static void __exit dw_mci_exit(void)
149{
150	pci_unregister_driver(&dw_mci_pci_driver);
151}
152
153module_init(dw_mci_init);
154module_exit(dw_mci_exit);
155
156MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver");
157MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>");
158MODULE_LICENSE("GPL v2");