Merge remote-tracking branch 'asoc/topic/mc13783' into asoc-next
[deliverable/linux.git] / drivers / usb / chipidea / ci_hdrc_pci.c
CommitLineData
409a15da 1/*
8e22978c 2 * ci_hdrc_pci.c - MIPS USB IP core family device controller
409a15da
PK
3 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 *
6 * Author: David Lopo
7 *
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.
11 */
12
62bb84ed 13#include <linux/platform_device.h>
409a15da
PK
14#include <linux/module.h>
15#include <linux/pci.h>
62bb84ed
AS
16#include <linux/interrupt.h>
17#include <linux/usb/gadget.h>
e443b333 18#include <linux/usb/chipidea.h>
409a15da
PK
19
20/* driver name */
8e22978c 21#define UDC_DRIVER_NAME "ci_hdrc_pci"
409a15da
PK
22
23/******************************************************************************
24 * PCI block
25 *****************************************************************************/
8e22978c 26static struct ci_hdrc_platform_data pci_platdata = {
62bb84ed
AS
27 .name = UDC_DRIVER_NAME,
28 .capoffset = DEF_CAPOFFSET,
29};
409a15da 30
8e22978c 31static struct ci_hdrc_platform_data langwell_pci_platdata = {
f01ef574 32 .name = UDC_DRIVER_NAME,
62bb84ed 33 .capoffset = 0,
f01ef574
PK
34};
35
8e22978c 36static struct ci_hdrc_platform_data penwell_pci_platdata = {
bd841986
AS
37 .name = UDC_DRIVER_NAME,
38 .capoffset = 0,
39 .power_budget = 200,
40};
41
409a15da 42/**
8e22978c 43 * ci_hdrc_pci_probe: PCI probe
409a15da
PK
44 * @pdev: USB device controller being probed
45 * @id: PCI hotplug ID connecting controller to UDC framework
46 *
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
50 */
8e22978c 51static int ci_hdrc_pci_probe(struct pci_dev *pdev,
409a15da
PK
52 const struct pci_device_id *id)
53{
8e22978c 54 struct ci_hdrc_platform_data *platdata = (void *)id->driver_data;
62bb84ed
AS
55 struct platform_device *plat_ci;
56 struct resource res[3];
57 int retval = 0, nres = 2;
409a15da 58
77c4400f 59 if (!platdata) {
1989b5ce
AS
60 dev_err(&pdev->dev, "device doesn't provide driver data\n");
61 return -ENODEV;
62 }
63
8b2379b4 64 retval = pcim_enable_device(pdev);
409a15da 65 if (retval)
8b2379b4 66 return retval;
409a15da
PK
67
68 if (!pdev->irq) {
69 dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!");
8b2379b4 70 return -ENODEV;
409a15da
PK
71 }
72
409a15da
PK
73 pci_set_master(pdev);
74 pci_try_set_mwi(pdev);
75
62bb84ed
AS
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;
82
8e22978c 83 plat_ci = ci_hdrc_add_device(&pdev->dev, res, nres, platdata);
cbc6dc2a 84 if (IS_ERR(plat_ci)) {
8e22978c 85 dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n");
8b2379b4 86 return PTR_ERR(plat_ci);
62bb84ed
AS
87 }
88
62bb84ed
AS
89 pci_set_drvdata(pdev, plat_ci);
90
409a15da 91 return 0;
409a15da
PK
92}
93
94/**
8e22978c 95 * ci_hdrc_pci_remove: PCI remove
409a15da
PK
96 * @pdev: USB Device Controller being removed
97 *
8e22978c 98 * Reverses the effect of ci_hdrc_pci_probe(),
409a15da
PK
99 * first invoking the udc_remove() and then releases
100 * all PCI resources allocated for this USB device controller
101 */
8e22978c 102static void ci_hdrc_pci_remove(struct pci_dev *pdev)
409a15da 103{
62bb84ed
AS
104 struct platform_device *plat_ci = pci_get_drvdata(pdev);
105
8e22978c 106 ci_hdrc_remove_device(plat_ci);
409a15da
PK
107}
108
109/**
110 * PCI device table
111 * PCI device structure
112 *
113 * Check "pci.h" for details
114 */
8e22978c 115static DEFINE_PCI_DEVICE_TABLE(ci_hdrc_pci_id_table) = {
62bb84ed
AS
116 {
117 PCI_DEVICE(0x153F, 0x1004),
77c4400f 118 .driver_data = (kernel_ulong_t)&pci_platdata,
62bb84ed
AS
119 },
120 {
121 PCI_DEVICE(0x153F, 0x1006),
77c4400f 122 .driver_data = (kernel_ulong_t)&pci_platdata,
62bb84ed
AS
123 },
124 {
125 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811),
77c4400f 126 .driver_data = (kernel_ulong_t)&langwell_pci_platdata,
62bb84ed
AS
127 },
128 {
129 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829),
77c4400f 130 .driver_data = (kernel_ulong_t)&penwell_pci_platdata,
62bb84ed 131 },
a214339d
DC
132 {
133 /* Intel Clovertrail */
134 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe006),
135 .driver_data = (kernel_ulong_t)&penwell_pci_platdata,
136 },
137 { 0 } /* end: all zeroes */
409a15da 138};
8e22978c 139MODULE_DEVICE_TABLE(pci, ci_hdrc_pci_id_table);
409a15da 140
8e22978c 141static struct pci_driver ci_hdrc_pci_driver = {
409a15da 142 .name = UDC_DRIVER_NAME,
8e22978c
AS
143 .id_table = ci_hdrc_pci_id_table,
144 .probe = ci_hdrc_pci_probe,
145 .remove = ci_hdrc_pci_remove,
409a15da
PK
146};
147
8e22978c 148module_pci_driver(ci_hdrc_pci_driver);
409a15da
PK
149
150MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
151MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
152MODULE_LICENSE("GPL");
153MODULE_VERSION("June 2008");
8e22978c 154MODULE_ALIAS("platform:ci13xxx_pci");
This page took 0.205942 seconds and 5 git commands to generate.