2 * ci13xxx_pci.c - MIPS USB IP core family device controller
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/module.h>
14 #include <linux/pci.h>
16 #include "ci13xxx_udc.c"
19 #define UDC_DRIVER_NAME "ci13xxx_pci"
21 /******************************************************************************
23 *****************************************************************************/
25 * ci13xxx_pci_irq: interrut handler
27 * @pdev: USB Device Controller interrupt source
29 * This function returns IRQ_HANDLED if the IRQ has been handled
30 * This is an ISR don't trace, use attribute interface instead
32 static irqreturn_t ci13xxx_pci_irq(int irq, void *pdev)
35 dev_err(&((struct pci_dev *)pdev)->dev, "Invalid IRQ0 usage!");
41 static struct ci13xxx_udc_driver ci13xxx_pci_udc_driver = {
42 .name = UDC_DRIVER_NAME,
46 * ci13xxx_pci_probe: PCI probe
47 * @pdev: USB device controller being probed
48 * @id: PCI hotplug ID connecting controller to UDC framework
50 * This function returns an error code
51 * Allocates basic PCI resources for this USB device controller, and then
52 * invokes the udc_probe() method to start the UDC associated with it
54 static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
55 const struct pci_device_id *id)
57 void __iomem *regs = NULL;
58 uintptr_t capoffset = DEF_CAPOFFSET;
64 retval = pci_enable_device(pdev);
69 dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!");
74 retval = pci_request_regions(pdev, UDC_DRIVER_NAME);
78 /* BAR 0 holds all the registers */
79 regs = pci_iomap(pdev, 0, 0);
81 dev_err(&pdev->dev, "Error mapping memory!");
85 pci_set_drvdata(pdev, (__force void *)regs);
88 pci_try_set_mwi(pdev);
90 if (pdev->vendor == PCI_VENDOR_ID_INTEL)
93 retval = udc_probe(&ci13xxx_pci_udc_driver, &pdev->dev, regs,
98 /* our device does not have MSI capability */
100 retval = request_irq(pdev->irq, ci13xxx_pci_irq, IRQF_SHARED,
101 UDC_DRIVER_NAME, pdev);
110 pci_iounmap(pdev, regs);
112 pci_release_regions(pdev);
114 pci_disable_device(pdev);
120 * ci13xxx_pci_remove: PCI remove
121 * @pdev: USB Device Controller being removed
123 * Reverses the effect of ci13xxx_pci_probe(),
124 * first invoking the udc_remove() and then releases
125 * all PCI resources allocated for this USB device controller
127 static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
129 free_irq(pdev->irq, pdev);
131 pci_iounmap(pdev, (__force void __iomem *)pci_get_drvdata(pdev));
132 pci_release_regions(pdev);
133 pci_disable_device(pdev);
138 * PCI device structure
140 * Check "pci.h" for details
142 static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
143 { PCI_DEVICE(0x153F, 0x1004) },
144 { PCI_DEVICE(0x153F, 0x1006) },
145 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811) },
146 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829) },
147 { 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
149 MODULE_DEVICE_TABLE(pci, ci13xxx_pci_id_table);
151 static struct pci_driver ci13xxx_pci_driver = {
152 .name = UDC_DRIVER_NAME,
153 .id_table = ci13xxx_pci_id_table,
154 .probe = ci13xxx_pci_probe,
155 .remove = __devexit_p(ci13xxx_pci_remove),
158 module_pci_driver(ci13xxx_pci_driver);
160 MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
161 MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
162 MODULE_LICENSE("GPL");
163 MODULE_VERSION("June 2008");