~ubuntu-branches/ubuntu/precise/linux-linaro-u8500/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): John Rigby, Upstream Fixes, Andy Green, John Rigby
  • Date: 2011-04-14 12:16:06 UTC
  • Revision ID: james.westby@ubuntu.com-20110414121606-b77podkyqgr2oix7
Tags: 2.6.38-1002.3
[ Upstream Fixes ]

* MUSB: shutdown: Make sure block is awake before doing shutdown
  - LP: #745737
* Fixed gpio polarity of gpio USB-phy reset.
  - LP: #747639

[ Andy Green ]

* LINARO: SAUCE: disable CONFIG_OMAP_RESET_CLOCKS
  - LP: #752900

[ John Rigby ]

* Rebase to new upstreams:
  Linux v2.6.38.1
  linaro-linux-2.6.38-upstream-29Mar2011
  Ubuntu-2.6.38-7.35
* SAUCE: OMAP4: clock: wait for module to become accessible on
  a clk enable
  - LP: #745737
* Rebase to new upstreams:
  Linux v2.6.38.2
  linaro-linux-2.6.38-upstream-5Apr2011
  Ubuntu-2.6.38-8.41
  - LP: #732842
* Update configs for device tree, dvfs and lttng
* LINARO: add building of dtb's
* LINARO: SAUCE: Disable lowest operating freqs on omap34xx
  - LP: #732912

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));
85
117
        /* Make sure the HC is halted. */
86
118
        retval = xhci_halt(xhci);
87
119
        if (retval)
88
 
                return retval;
 
120
                goto error;
89
121
 
90
122
        xhci_dbg(xhci, "Resetting HCD\n");
91
123
        /* Reset the internal HC memory state and registers. */
92
124
        retval = xhci_reset(xhci);
93
125
        if (retval)
94
 
                return retval;
 
126
                goto error;
95
127
        xhci_dbg(xhci, "Reset complete\n");
96
128
 
97
129
        temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
106
138
        /* Initialize HCD and host controller data structures. */
107
139
        retval = xhci_init(hcd);
108
140
        if (retval)
109
 
                return retval;
 
141
                goto error;
110
142
        xhci_dbg(xhci, "Called HCD init\n");
111
143
 
112
144
        pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn);
113
145
        xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn);
114
146
 
115
147
        /* Find any debug ports */
116
 
        return xhci_pci_reinit(xhci, pdev);
 
148
        retval = xhci_pci_reinit(xhci, pdev);
 
149
        if (!retval)
 
150
                return retval;
 
151
 
 
152
error:
 
153
        kfree(xhci);
 
154
        return retval;
 
155
}
 
156
 
 
157
/*
 
158
 * We need to register our own PCI probe function (instead of the USB core's
 
159
 * function) in order to create a second roothub under xHCI.
 
160
 */
 
161
static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
162
{
 
163
        int retval;
 
164
        struct xhci_hcd *xhci;
 
165
        struct hc_driver *driver;
 
166
        struct usb_hcd *hcd;
 
167
 
 
168
        driver = (struct hc_driver *)id->driver_data;
 
169
        /* Register the USB 2.0 roothub.
 
170
         * FIXME: USB core must know to register the USB 2.0 roothub first.
 
171
         * This is sort of silly, because we could just set the HCD driver flags
 
172
         * to say USB 2.0, but I'm not sure what the implications would be in
 
173
         * the other parts of the HCD code.
 
174
         */
 
175
        retval = usb_hcd_pci_probe(dev, id);
 
176
 
 
177
        if (retval)
 
178
                return retval;
 
179
 
 
180
        /* USB 2.0 roothub is stored in the PCI device now. */
 
181
        hcd = dev_get_drvdata(&dev->dev);
 
182
        xhci = hcd_to_xhci(hcd);
 
183
        xhci->shared_hcd = usb_create_shared_hcd(driver, &dev->dev,
 
184
                                pci_name(dev), hcd);
 
185
        if (!xhci->shared_hcd) {
 
186
                retval = -ENOMEM;
 
187
                goto dealloc_usb2_hcd;
 
188
        }
 
189
 
 
190
        /* Set the xHCI pointer before xhci_pci_setup() (aka hcd_driver.reset)
 
191
         * is called by usb_add_hcd().
 
192
         */
 
193
        *((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci;
 
194
 
 
195
        retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
 
196
                        IRQF_DISABLED | IRQF_SHARED);
 
197
        if (retval)
 
198
                goto put_usb3_hcd;
 
199
        /* Roothub already marked as USB 3.0 speed */
 
200
        return 0;
 
201
 
 
202
put_usb3_hcd:
 
203
        usb_put_hcd(xhci->shared_hcd);
 
204
dealloc_usb2_hcd:
 
205
        usb_hcd_pci_remove(dev);
 
206
        return retval;
 
207
}
 
208
 
 
209
static void xhci_pci_remove(struct pci_dev *dev)
 
210
{
 
211
        struct xhci_hcd *xhci;
 
212
 
 
213
        xhci = hcd_to_xhci(pci_get_drvdata(dev));
 
214
        if (xhci->shared_hcd) {
 
215
                usb_remove_hcd(xhci->shared_hcd);
 
216
                usb_put_hcd(xhci->shared_hcd);
 
217
        }
 
218
        usb_hcd_pci_remove(dev);
 
219
        kfree(xhci);
117
220
}
118
221
 
119
222
#ifdef CONFIG_PM
122
225
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
123
226
        int     retval = 0;
124
227
 
125
 
        if (hcd->state != HC_STATE_SUSPENDED)
 
228
        if (hcd->state != HC_STATE_SUSPENDED ||
 
229
                        xhci->shared_hcd->state != HC_STATE_SUSPENDED)
126
230
                return -EINVAL;
127
231
 
128
232
        retval = xhci_suspend(xhci);
143
247
static const struct hc_driver xhci_pci_hc_driver = {
144
248
        .description =          hcd_name,
145
249
        .product_desc =         "xHCI Host Controller",
146
 
        .hcd_priv_size =        sizeof(struct xhci_hcd),
 
250
        .hcd_priv_size =        sizeof(struct xhci_hcd *),
147
251
 
148
252
        /*
149
253
         * generic hardware linkage
150
254
         */
151
255
        .irq =                  xhci_irq,
152
 
        .flags =                HCD_MEMORY | HCD_USB3,
 
256
        .flags =                HCD_MEMORY | HCD_USB3 | HCD_SHARED,
153
257
 
154
258
        /*
155
259
         * basic lifecycle operations
210
314
        .name =         (char *) hcd_name,
211
315
        .id_table =     pci_ids,
212
316
 
213
 
        .probe =        usb_hcd_pci_probe,
214
 
        .remove =       usb_hcd_pci_remove,
 
317
        .probe =        xhci_pci_probe,
 
318
        .remove =       xhci_pci_remove,
215
319
        /* suspend and resume implemented later */
216
320
 
217
321
        .shutdown =     usb_hcd_pci_shutdown,