1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41#include <linux/kernel.h>
42#include <linux/module.h>
43#include <linux/moduleparam.h>
44#include <linux/spinlock.h>
45#include <linux/interrupt.h>
46#include <linux/io.h>
47#include <linux/slab.h>
48#include <linux/pci.h>
49#include <linux/usb.h>
50
51#include <linux/usb/hcd.h>
52#include <linux/usb/ch11.h>
53
54#include "core.h"
55#include "hcd.h"
56
57#define PCI_VENDOR_ID_SYNOPSYS 0x16c3
58#define PCI_PRODUCT_ID_HAPS_HSOTG 0xabc0
59
60static const char dwc2_driver_name[] = "dwc2";
61
62static const struct dwc2_core_params dwc2_module_params = {
63 .otg_cap = -1,
64 .otg_ver = -1,
65 .dma_enable = -1,
66 .dma_desc_enable = 0,
67 .speed = -1,
68 .enable_dynamic_fifo = -1,
69 .en_multiple_tx_fifo = -1,
70 .host_rx_fifo_size = 1024,
71 .host_nperio_tx_fifo_size = 256,
72 .host_perio_tx_fifo_size = 1024,
73 .max_transfer_size = 65535,
74 .max_packet_count = 511,
75 .host_channels = -1,
76 .phy_type = -1,
77 .phy_utmi_width = -1,
78 .phy_ulpi_ddr = -1,
79 .phy_ulpi_ext_vbus = -1,
80 .i2c_enable = -1,
81 .ulpi_fs_ls = -1,
82 .host_support_fs_ls_low_power = -1,
83 .host_ls_low_power_phy_clk = -1,
84 .ts_dline = -1,
85 .reload_ctl = -1,
86 .ahbcfg = -1,
87 .uframe_sched = -1,
88};
89
90
91
92
93
94
95
96
97
98
99
100
101static void dwc2_driver_remove(struct pci_dev *dev)
102{
103 struct dwc2_hsotg *hsotg = pci_get_drvdata(dev);
104
105 dwc2_hcd_remove(hsotg);
106 pci_disable_device(dev);
107}
108
109
110
111
112
113
114
115
116
117
118
119
120
121static int dwc2_driver_probe(struct pci_dev *dev,
122 const struct pci_device_id *id)
123{
124 struct dwc2_hsotg *hsotg;
125 int retval;
126
127 hsotg = devm_kzalloc(&dev->dev, sizeof(*hsotg), GFP_KERNEL);
128 if (!hsotg)
129 return -ENOMEM;
130
131 hsotg->dev = &dev->dev;
132 hsotg->regs = devm_ioremap_resource(&dev->dev, &dev->resource[0]);
133 if (IS_ERR(hsotg->regs))
134 return PTR_ERR(hsotg->regs);
135
136 dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
137 (unsigned long)pci_resource_start(dev, 0), hsotg->regs);
138
139 if (pci_enable_device(dev) < 0)
140 return -ENODEV;
141
142 pci_set_master(dev);
143
144 retval = devm_request_irq(hsotg->dev, dev->irq,
145 dwc2_handle_common_intr, IRQF_SHARED,
146 dev_name(hsotg->dev), hsotg);
147 if (retval)
148 return retval;
149
150 spin_lock_init(&hsotg->lock);
151 retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
152 if (retval) {
153 pci_disable_device(dev);
154 return retval;
155 }
156
157 pci_set_drvdata(dev, hsotg);
158
159 return retval;
160}
161
162static const struct pci_device_id dwc2_pci_ids[] = {
163 {
164 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, PCI_PRODUCT_ID_HAPS_HSOTG),
165 },
166 {
167 PCI_DEVICE(PCI_VENDOR_ID_STMICRO,
168 PCI_DEVICE_ID_STMICRO_USB_OTG),
169 },
170 { }
171};
172MODULE_DEVICE_TABLE(pci, dwc2_pci_ids);
173
174static struct pci_driver dwc2_pci_driver = {
175 .name = dwc2_driver_name,
176 .id_table = dwc2_pci_ids,
177 .probe = dwc2_driver_probe,
178 .remove = dwc2_driver_remove,
179};
180
181module_pci_driver(dwc2_pci_driver);
182
183MODULE_DESCRIPTION("DESIGNWARE HS OTG PCI Bus Glue");
184MODULE_AUTHOR("Synopsys, Inc.");
185MODULE_LICENSE("Dual BSD/GPL");
186