2 * ci_hdrc_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/platform_device.h>
14 #include <linux/module.h>
15 #include <linux/pci.h>
16 #include <linux/interrupt.h>
17 #include <linux/usb/gadget.h>
18 #include <linux/usb/chipidea.h>
21 #define UDC_DRIVER_NAME "ci_hdrc_pci"
23 /******************************************************************************
25 *****************************************************************************/
26 static struct ci_hdrc_platform_data pci_platdata
= {
27 .name
= UDC_DRIVER_NAME
,
28 .capoffset
= DEF_CAPOFFSET
,
31 static struct ci_hdrc_platform_data langwell_pci_platdata
= {
32 .name
= UDC_DRIVER_NAME
,
36 static struct ci_hdrc_platform_data penwell_pci_platdata
= {
37 .name
= UDC_DRIVER_NAME
,
43 * ci_hdrc_pci_probe: PCI probe
44 * @pdev: USB device controller being probed
45 * @id: PCI hotplug ID connecting controller to UDC framework
47 * This function returns an error code
48 * Allocates basic PCI resources for this USB device controller, and then
49 * invokes the udc_probe() method to start the UDC associated with it
51 static int ci_hdrc_pci_probe(struct pci_dev
*pdev
,
52 const struct pci_device_id
*id
)
54 struct ci_hdrc_platform_data
*platdata
= (void *)id
->driver_data
;
55 struct platform_device
*plat_ci
;
56 struct resource res
[3];
57 int retval
= 0, nres
= 2;
60 dev_err(&pdev
->dev
, "device doesn't provide driver data\n");
64 retval
= pcim_enable_device(pdev
);
69 dev_err(&pdev
->dev
, "No IRQ, check BIOS/PCI setup!");
74 pci_try_set_mwi(pdev
);
76 memset(res
, 0, sizeof(res
));
77 res
[0].start
= pci_resource_start(pdev
, 0);
78 res
[0].end
= pci_resource_end(pdev
, 0);
79 res
[0].flags
= IORESOURCE_MEM
;
80 res
[1].start
= pdev
->irq
;
81 res
[1].flags
= IORESOURCE_IRQ
;
83 plat_ci
= ci_hdrc_add_device(&pdev
->dev
, res
, nres
, platdata
);
84 if (IS_ERR(plat_ci
)) {
85 dev_err(&pdev
->dev
, "ci_hdrc_add_device failed!\n");
86 return PTR_ERR(plat_ci
);
89 pci_set_drvdata(pdev
, plat_ci
);
95 * ci_hdrc_pci_remove: PCI remove
96 * @pdev: USB Device Controller being removed
98 * Reverses the effect of ci_hdrc_pci_probe(),
99 * first invoking the udc_remove() and then releases
100 * all PCI resources allocated for this USB device controller
102 static void ci_hdrc_pci_remove(struct pci_dev
*pdev
)
104 struct platform_device
*plat_ci
= pci_get_drvdata(pdev
);
106 ci_hdrc_remove_device(plat_ci
);
111 * PCI device structure
113 * Check "pci.h" for details
115 static DEFINE_PCI_DEVICE_TABLE(ci_hdrc_pci_id_table
) = {
117 PCI_DEVICE(0x153F, 0x1004),
118 .driver_data
= (kernel_ulong_t
)&pci_platdata
,
121 PCI_DEVICE(0x153F, 0x1006),
122 .driver_data
= (kernel_ulong_t
)&pci_platdata
,
125 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x0811),
126 .driver_data
= (kernel_ulong_t
)&langwell_pci_platdata
,
129 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x0829),
130 .driver_data
= (kernel_ulong_t
)&penwell_pci_platdata
,
133 /* Intel Clovertrail */
134 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0xe006),
135 .driver_data
= (kernel_ulong_t
)&penwell_pci_platdata
,
137 { 0 } /* end: all zeroes */
139 MODULE_DEVICE_TABLE(pci
, ci_hdrc_pci_id_table
);
141 static struct pci_driver ci_hdrc_pci_driver
= {
142 .name
= UDC_DRIVER_NAME
,
143 .id_table
= ci_hdrc_pci_id_table
,
144 .probe
= ci_hdrc_pci_probe
,
145 .remove
= ci_hdrc_pci_remove
,
148 module_pci_driver(ci_hdrc_pci_driver
);
150 MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
151 MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
152 MODULE_LICENSE("GPL");
153 MODULE_VERSION("June 2008");
154 MODULE_ALIAS("platform:ci13xxx_pci");