50
50
/* called during probe() after chip reset completes */
51
51
static int xhci_pci_setup(struct usb_hcd *hcd)
53
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
53
struct xhci_hcd *xhci;
54
54
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
58
58
hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2;
60
if (usb_hcd_is_primary_hcd(hcd)) {
61
xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL);
64
*((struct xhci_hcd **) hcd->hcd_priv) = xhci;
66
/* Mark the first roothub as being USB 2.0.
67
* The xHCI driver will register the USB 3.0 roothub.
69
hcd->speed = HCD_USB2;
70
hcd->self.root_hub->speed = USB_SPEED_HIGH;
72
* USB 2.0 roothub under xHCI has an integrated TT,
73
* (rate matching hub) as opposed to having an OHCI/UHCI
74
* companion controller.
78
/* xHCI private pointer was set in xhci_pci_probe for the second
81
xhci = hcd_to_xhci(hcd);
82
temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
83
if (HCC_64BIT_ADDR(temp)) {
84
xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
85
dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64));
87
dma_set_mask(hcd->self.controller, DMA_BIT_MASK(32));
60
92
xhci->cap_regs = hcd->regs;
61
93
xhci->op_regs = hcd->regs +
62
94
HC_LENGTH(xhci_readl(xhci, &xhci->cap_regs->hc_capbase));
82
114
if (pdev->vendor == PCI_VENDOR_ID_NEC)
83
115
xhci->quirks |= XHCI_NEC_HOST;
118
if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
119
xhci->quirks |= XHCI_AMD_PLL_FIX;
85
121
/* Make sure the HC is halted. */
86
122
retval = xhci_halt(xhci);
90
126
xhci_dbg(xhci, "Resetting HCD\n");
91
127
/* Reset the internal HC memory state and registers. */
92
128
retval = xhci_reset(xhci);
95
131
xhci_dbg(xhci, "Reset complete\n");
97
133
temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
106
142
/* Initialize HCD and host controller data structures. */
107
143
retval = xhci_init(hcd);
110
146
xhci_dbg(xhci, "Called HCD init\n");
112
148
pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn);
113
149
xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn);
115
151
/* Find any debug ports */
116
return xhci_pci_reinit(xhci, pdev);
152
retval = xhci_pci_reinit(xhci, pdev);
162
* We need to register our own PCI probe function (instead of the USB core's
163
* function) in order to create a second roothub under xHCI.
165
static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
168
struct xhci_hcd *xhci;
169
struct hc_driver *driver;
172
driver = (struct hc_driver *)id->driver_data;
173
/* Register the USB 2.0 roothub.
174
* FIXME: USB core must know to register the USB 2.0 roothub first.
175
* This is sort of silly, because we could just set the HCD driver flags
176
* to say USB 2.0, but I'm not sure what the implications would be in
177
* the other parts of the HCD code.
179
retval = usb_hcd_pci_probe(dev, id);
184
/* USB 2.0 roothub is stored in the PCI device now. */
185
hcd = dev_get_drvdata(&dev->dev);
186
xhci = hcd_to_xhci(hcd);
187
xhci->shared_hcd = usb_create_shared_hcd(driver, &dev->dev,
189
if (!xhci->shared_hcd) {
191
goto dealloc_usb2_hcd;
194
/* Set the xHCI pointer before xhci_pci_setup() (aka hcd_driver.reset)
195
* is called by usb_add_hcd().
197
*((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci;
199
retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
200
IRQF_DISABLED | IRQF_SHARED);
203
/* Roothub already marked as USB 3.0 speed */
207
usb_put_hcd(xhci->shared_hcd);
209
usb_hcd_pci_remove(dev);
213
static void xhci_pci_remove(struct pci_dev *dev)
215
struct xhci_hcd *xhci;
217
xhci = hcd_to_xhci(pci_get_drvdata(dev));
218
if (xhci->shared_hcd) {
219
usb_remove_hcd(xhci->shared_hcd);
220
usb_put_hcd(xhci->shared_hcd);
222
usb_hcd_pci_remove(dev);
122
229
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
125
if (hcd->state != HC_STATE_SUSPENDED)
232
if (hcd->state != HC_STATE_SUSPENDED ||
233
xhci->shared_hcd->state != HC_STATE_SUSPENDED)
128
236
retval = xhci_suspend(xhci);
143
251
static const struct hc_driver xhci_pci_hc_driver = {
144
252
.description = hcd_name,
145
253
.product_desc = "xHCI Host Controller",
146
.hcd_priv_size = sizeof(struct xhci_hcd),
254
.hcd_priv_size = sizeof(struct xhci_hcd *),
149
257
* generic hardware linkage
152
.flags = HCD_MEMORY | HCD_USB3,
260
.flags = HCD_MEMORY | HCD_USB3 | HCD_SHARED,
155
263
* basic lifecycle operations
210
318
.name = (char *) hcd_name,
211
319
.id_table = pci_ids,
213
.probe = usb_hcd_pci_probe,
214
.remove = usb_hcd_pci_remove,
321
.probe = xhci_pci_probe,
322
.remove = xhci_pci_remove,
215
323
/* suspend and resume implemented later */
217
325
.shutdown = usb_hcd_pci_shutdown,