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

« back to all changes in this revision

Viewing changes to drivers/usb/host/xhci-mem.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:
814
814
        ep0_ctx->deq |= ep_ring->cycle_state;
815
815
}
816
816
 
 
817
/*
 
818
 * The xHCI roothub may have ports of differing speeds in any order in the port
 
819
 * status registers.  xhci->port_array provides an array of the port speed for
 
820
 * each offset into the port status registers.
 
821
 *
 
822
 * The xHCI hardware wants to know the roothub port number that the USB device
 
823
 * is attached to (or the roothub port its ancestor hub is attached to).  All we
 
824
 * know is the index of that port under either the USB 2.0 or the USB 3.0
 
825
 * roothub, but that doesn't give us the real index into the HW port status
 
826
 * registers.  Scan through the xHCI roothub port array, looking for the Nth
 
827
 * entry of the correct port speed.  Return the port number of that entry.
 
828
 */
 
829
static u32 xhci_find_real_port_number(struct xhci_hcd *xhci,
 
830
                struct usb_device *udev)
 
831
{
 
832
        struct usb_device *top_dev;
 
833
        unsigned int num_similar_speed_ports;
 
834
        unsigned int faked_port_num;
 
835
        int i;
 
836
 
 
837
        for (top_dev = udev; top_dev->parent && top_dev->parent->parent;
 
838
                        top_dev = top_dev->parent)
 
839
                /* Found device below root hub */;
 
840
        faked_port_num = top_dev->portnum;
 
841
        for (i = 0, num_similar_speed_ports = 0;
 
842
                        i < HCS_MAX_PORTS(xhci->hcs_params1); i++) {
 
843
                u8 port_speed = xhci->port_array[i];
 
844
 
 
845
                /*
 
846
                 * Skip ports that don't have known speeds, or have duplicate
 
847
                 * Extended Capabilities port speed entries.
 
848
                 */
 
849
                if (port_speed == 0 || port_speed == -1)
 
850
                        continue;
 
851
 
 
852
                /*
 
853
                 * USB 3.0 ports are always under a USB 3.0 hub.  USB 2.0 and
 
854
                 * 1.1 ports are under the USB 2.0 hub.  If the port speed
 
855
                 * matches the device speed, it's a similar speed port.
 
856
                 */
 
857
                if ((port_speed == 0x03) == (udev->speed == USB_SPEED_SUPER))
 
858
                        num_similar_speed_ports++;
 
859
                if (num_similar_speed_ports == faked_port_num)
 
860
                        /* Roothub ports are numbered from 1 to N */
 
861
                        return i+1;
 
862
        }
 
863
        return 0;
 
864
}
 
865
 
817
866
/* Setup an xHCI virtual device for a Set Address command */
818
867
int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev)
819
868
{
820
869
        struct xhci_virt_device *dev;
821
870
        struct xhci_ep_ctx      *ep0_ctx;
822
 
        struct usb_device       *top_dev;
823
871
        struct xhci_slot_ctx    *slot_ctx;
824
872
        struct xhci_input_control_ctx *ctrl_ctx;
 
873
        u32                     port_num;
 
874
        struct usb_device *top_dev;
825
875
 
826
876
        dev = xhci->devs[udev->slot_id];
827
877
        /* Slot ID 0 is reserved */
863
913
                BUG();
864
914
        }
865
915
        /* Find the root hub port this device is under */
 
916
        port_num = xhci_find_real_port_number(xhci, udev);
 
917
        if (!port_num)
 
918
                return -EINVAL;
 
919
        slot_ctx->dev_info2 |= (u32) ROOT_HUB_PORT(port_num);
 
920
        /* Set the port number in the virtual_device to the faked port number */
866
921
        for (top_dev = udev; top_dev->parent && top_dev->parent->parent;
867
922
                        top_dev = top_dev->parent)
868
923
                /* Found device below root hub */;
869
 
        slot_ctx->dev_info2 |= (u32) ROOT_HUB_PORT(top_dev->portnum);
870
924
        dev->port = top_dev->portnum;
871
 
        xhci_dbg(xhci, "Set root hub portnum to %d\n", top_dev->portnum);
 
925
        xhci_dbg(xhci, "Set root hub portnum to %d\n", port_num);
 
926
        xhci_dbg(xhci, "Set fake root hub portnum to %d\n", dev->port);
872
927
 
873
 
        /* Is this a LS/FS device under a HS hub? */
874
 
        if ((udev->speed == USB_SPEED_LOW || udev->speed == USB_SPEED_FULL) &&
875
 
                        udev->tt) {
 
928
        /* Is this a LS/FS device under an external HS hub? */
 
929
        if (udev->tt && udev->tt->hub->parent) {
876
930
                slot_ctx->tt_info = udev->tt->hub->slot_id;
877
931
                slot_ctx->tt_info |= udev->ttport << 8;
878
932
                if (udev->tt->multi)
1452
1506
 
1453
1507
        xhci->page_size = 0;
1454
1508
        xhci->page_shift = 0;
1455
 
        xhci->bus_suspended = 0;
 
1509
        xhci->bus_state[0].bus_suspended = 0;
 
1510
        xhci->bus_state[1].bus_suspended = 0;
1456
1511
}
1457
1512
 
1458
1513
static int xhci_test_trb_in_td(struct xhci_hcd *xhci,
1748
1803
        }
1749
1804
        xhci_dbg(xhci, "Found %u USB 2.0 ports and %u USB 3.0 ports.\n",
1750
1805
                        xhci->num_usb2_ports, xhci->num_usb3_ports);
 
1806
 
 
1807
        /* Place limits on the number of roothub ports so that the hub
 
1808
         * descriptors aren't longer than the USB core will allocate.
 
1809
         */
 
1810
        if (xhci->num_usb3_ports > 15) {
 
1811
                xhci_dbg(xhci, "Limiting USB 3.0 roothub ports to 15.\n");
 
1812
                xhci->num_usb3_ports = 15;
 
1813
        }
 
1814
        if (xhci->num_usb2_ports > USB_MAXCHILDREN) {
 
1815
                xhci_dbg(xhci, "Limiting USB 2.0 roothub ports to %u.\n",
 
1816
                                USB_MAXCHILDREN);
 
1817
                xhci->num_usb2_ports = USB_MAXCHILDREN;
 
1818
        }
 
1819
 
1751
1820
        /*
1752
1821
         * Note we could have all USB 3.0 ports, or all USB 2.0 ports.
1753
1822
         * Not sure how the USB core will handle a hub with no ports...
1772
1841
                                        "addr = %p\n", i,
1773
1842
                                        xhci->usb2_ports[port_index]);
1774
1843
                        port_index++;
 
1844
                        if (port_index == xhci->num_usb2_ports)
 
1845
                                break;
1775
1846
                }
1776
1847
        }
1777
1848
        if (xhci->num_usb3_ports) {
1790
1861
                                                "addr = %p\n", i,
1791
1862
                                                xhci->usb3_ports[port_index]);
1792
1863
                                port_index++;
 
1864
                                if (port_index == xhci->num_usb3_ports)
 
1865
                                        break;
1793
1866
                        }
1794
1867
        }
1795
1868
        return 0;
1971
2044
        init_completion(&xhci->addr_dev);
1972
2045
        for (i = 0; i < MAX_HC_SLOTS; ++i)
1973
2046
                xhci->devs[i] = NULL;
1974
 
        for (i = 0; i < MAX_HC_PORTS; ++i)
1975
 
                xhci->resume_done[i] = 0;
 
2047
        for (i = 0; i < USB_MAXCHILDREN; ++i) {
 
2048
                xhci->bus_state[0].resume_done[i] = 0;
 
2049
                xhci->bus_state[1].resume_done[i] = 0;
 
2050
        }
1976
2051
 
1977
2052
        if (scratchpad_alloc(xhci, flags))
1978
2053
                goto fail;