~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/usb/host/xhci-pci.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
/* called during probe() after chip reset completes */
51
51
static int xhci_pci_setup(struct usb_hcd *hcd)
52
52
{
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);
55
55
        int                     retval;
56
56
        u32                     temp;
57
57
 
58
58
        hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2;
59
59
 
 
60
        if (usb_hcd_is_primary_hcd(hcd)) {
 
61
                xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL);
 
62
                if (!xhci)
 
63
                        return -ENOMEM;
 
64
                *((struct xhci_hcd **) hcd->hcd_priv) = xhci;
 
65
                xhci->main_hcd = hcd;
 
66
                /* Mark the first roothub as being USB 2.0.
 
67
                 * The xHCI driver will register the USB 3.0 roothub.
 
68
                 */
 
69
                hcd->speed = HCD_USB2;
 
70
                hcd->self.root_hub->speed = USB_SPEED_HIGH;
 
71
                /*
 
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.
 
75
                 */
 
76
                hcd->has_tt = 1;
 
77
        } else {
 
78
                /* xHCI private pointer was set in xhci_pci_probe for the second
 
79
                 * registered roothub.
 
80
                 */
 
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));
 
86
                } else {
 
87
                        dma_set_mask(hcd->self.controller, DMA_BIT_MASK(32));
 
88
                }
 
89
                return 0;
 
90
        }
 
91
 
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;
84
116
 
 
117
        /* AMD PLL quirk */
 
118
        if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
 
119
                xhci->quirks |= XHCI_AMD_PLL_FIX;
 
120
 
85
121
        /* Make sure the HC is halted. */
86
122
        retval = xhci_halt(xhci);
87
123
        if (retval)
88
 
                return retval;
 
124
                goto error;
89
125
 
90
126
        xhci_dbg(xhci, "Resetting HCD\n");
91
127
        /* Reset the internal HC memory state and registers. */
92
128
        retval = xhci_reset(xhci);
93
129
        if (retval)
94
 
                return retval;
 
130
                goto error;
95
131
        xhci_dbg(xhci, "Reset complete\n");
96
132
 
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);
108
144
        if (retval)
109
 
                return retval;
 
145
                goto error;
110
146
        xhci_dbg(xhci, "Called HCD init\n");
111
147
 
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);
114
150
 
115
151
        /* Find any debug ports */
116
 
        return xhci_pci_reinit(xhci, pdev);
 
152
        retval = xhci_pci_reinit(xhci, pdev);
 
153
        if (!retval)
 
154
                return retval;
 
155
 
 
156
error:
 
157
        kfree(xhci);
 
158
        return retval;
 
159
}
 
160
 
 
161
/*
 
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.
 
164
 */
 
165
static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
166
{
 
167
        int retval;
 
168
        struct xhci_hcd *xhci;
 
169
        struct hc_driver *driver;
 
170
        struct usb_hcd *hcd;
 
171
 
 
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.
 
178
         */
 
179
        retval = usb_hcd_pci_probe(dev, id);
 
180
 
 
181
        if (retval)
 
182
                return retval;
 
183
 
 
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,
 
188
                                pci_name(dev), hcd);
 
189
        if (!xhci->shared_hcd) {
 
190
                retval = -ENOMEM;
 
191
                goto dealloc_usb2_hcd;
 
192
        }
 
193
 
 
194
        /* Set the xHCI pointer before xhci_pci_setup() (aka hcd_driver.reset)
 
195
         * is called by usb_add_hcd().
 
196
         */
 
197
        *((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci;
 
198
 
 
199
        retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
 
200
                        IRQF_DISABLED | IRQF_SHARED);
 
201
        if (retval)
 
202
                goto put_usb3_hcd;
 
203
        /* Roothub already marked as USB 3.0 speed */
 
204
        return 0;
 
205
 
 
206
put_usb3_hcd:
 
207
        usb_put_hcd(xhci->shared_hcd);
 
208
dealloc_usb2_hcd:
 
209
        usb_hcd_pci_remove(dev);
 
210
        return retval;
 
211
}
 
212
 
 
213
static void xhci_pci_remove(struct pci_dev *dev)
 
214
{
 
215
        struct xhci_hcd *xhci;
 
216
 
 
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);
 
221
        }
 
222
        usb_hcd_pci_remove(dev);
 
223
        kfree(xhci);
117
224
}
118
225
 
119
226
#ifdef CONFIG_PM
122
229
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
123
230
        int     retval = 0;
124
231
 
125
 
        if (hcd->state != HC_STATE_SUSPENDED)
 
232
        if (hcd->state != HC_STATE_SUSPENDED ||
 
233
                        xhci->shared_hcd->state != HC_STATE_SUSPENDED)
126
234
                return -EINVAL;
127
235
 
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 *),
147
255
 
148
256
        /*
149
257
         * generic hardware linkage
150
258
         */
151
259
        .irq =                  xhci_irq,
152
 
        .flags =                HCD_MEMORY | HCD_USB3,
 
260
        .flags =                HCD_MEMORY | HCD_USB3 | HCD_SHARED,
153
261
 
154
262
        /*
155
263
         * basic lifecycle operations
210
318
        .name =         (char *) hcd_name,
211
319
        .id_table =     pci_ids,
212
320
 
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 */
216
324
 
217
325
        .shutdown =     usb_hcd_pci_shutdown,