aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci-hcd.c
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2009-09-04 13:53:20 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-23 09:46:40 -0400
commitac1c1b7f16ed287fcec5bcfae06d0165c3941ec3 (patch)
tree977be3ee0c12da25d453b35a419151eafcd19406 /drivers/usb/host/xhci-hcd.c
parent07b6de102843b717ecd962cf35ec4ad9b1fbed9d (diff)
USB: xhci: Support USB hubs.
For a USB hub to work under an xHCI host controller, the xHC's internal scheduler must be made aware of the hub's characteristics. Add an xHCI hook that the USB core will call after it fetches the hub descriptor. This hook will add hub information to the slot context for that device, including whether it has multiple TTs or a single TT, the number of ports on the hub, and TT think time. Setting up the slot context for the device is different for 0.95 and 0.96 xHCI host controllers. Some of the slot context reserved fields in the 0.95 specification were changed into hub fields in the 0.96 specification. Don't set the TT think time or number of ports for a hub if we're dealing with a 0.95-compliant xHCI host controller. The 0.95 xHCI specification says that to modify the hub flag, we need to issue an evaluate context command. The 0.96 specification says that flag can be set with a configure endpoint command. Issue the correct command based on the version reported by the hardware. This patch does not add support for multi-TT hubs. Multi-TT hubs expose a single TT on alt setting 0, and multi-TT on alt setting 1. The xHCI driver can't handle setting alternate interfaces yet. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/xhci-hcd.c')
-rw-r--r--drivers/usb/host/xhci-hcd.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index 2fcc360f0648..99911e727e0b 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -1594,6 +1594,88 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
1594 return 0; 1594 return 0;
1595} 1595}
1596 1596
1597/* Once a hub descriptor is fetched for a device, we need to update the xHC's
1598 * internal data structures for the device.
1599 */
1600int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
1601 struct usb_tt *tt, gfp_t mem_flags)
1602{
1603 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
1604 struct xhci_virt_device *vdev;
1605 struct xhci_command *config_cmd;
1606 struct xhci_input_control_ctx *ctrl_ctx;
1607 struct xhci_slot_ctx *slot_ctx;
1608 unsigned long flags;
1609 unsigned think_time;
1610 int ret;
1611
1612 /* Ignore root hubs */
1613 if (!hdev->parent)
1614 return 0;
1615
1616 vdev = xhci->devs[hdev->slot_id];
1617 if (!vdev) {
1618 xhci_warn(xhci, "Cannot update hub desc for unknown device.\n");
1619 return -EINVAL;
1620 }
1621 config_cmd = xhci_alloc_command(xhci, true, mem_flags);
1622 if (!config_cmd) {
1623 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n");
1624 return -ENOMEM;
1625 }
1626
1627 spin_lock_irqsave(&xhci->lock, flags);
1628 xhci_slot_copy(xhci, config_cmd->in_ctx, vdev->out_ctx);
1629 ctrl_ctx = xhci_get_input_control_ctx(xhci, config_cmd->in_ctx);
1630 ctrl_ctx->add_flags |= SLOT_FLAG;
1631 slot_ctx = xhci_get_slot_ctx(xhci, config_cmd->in_ctx);
1632 slot_ctx->dev_info |= DEV_HUB;
1633 if (tt->multi)
1634 slot_ctx->dev_info |= DEV_MTT;
1635 if (xhci->hci_version > 0x95) {
1636 xhci_dbg(xhci, "xHCI version %x needs hub "
1637 "TT think time and number of ports\n",
1638 (unsigned int) xhci->hci_version);
1639 slot_ctx->dev_info2 |= XHCI_MAX_PORTS(hdev->maxchild);
1640 /* Set TT think time - convert from ns to FS bit times.
1641 * 0 = 8 FS bit times, 1 = 16 FS bit times,
1642 * 2 = 24 FS bit times, 3 = 32 FS bit times.
1643 */
1644 think_time = tt->think_time;
1645 if (think_time != 0)
1646 think_time = (think_time / 666) - 1;
1647 slot_ctx->tt_info |= TT_THINK_TIME(think_time);
1648 } else {
1649 xhci_dbg(xhci, "xHCI version %x doesn't need hub "
1650 "TT think time or number of ports\n",
1651 (unsigned int) xhci->hci_version);
1652 }
1653 slot_ctx->dev_state = 0;
1654 spin_unlock_irqrestore(&xhci->lock, flags);
1655
1656 xhci_dbg(xhci, "Set up %s for hub device.\n",
1657 (xhci->hci_version > 0x95) ?
1658 "configure endpoint" : "evaluate context");
1659 xhci_dbg(xhci, "Slot %u Input Context:\n", hdev->slot_id);
1660 xhci_dbg_ctx(xhci, config_cmd->in_ctx, 0);
1661
1662 /* Issue and wait for the configure endpoint or
1663 * evaluate context command.
1664 */
1665 if (xhci->hci_version > 0x95)
1666 ret = xhci_configure_endpoint(xhci, hdev, config_cmd,
1667 false, false);
1668 else
1669 ret = xhci_configure_endpoint(xhci, hdev, config_cmd,
1670 true, false);
1671
1672 xhci_dbg(xhci, "Slot %u Output Context:\n", hdev->slot_id);
1673 xhci_dbg_ctx(xhci, vdev->out_ctx, 0);
1674
1675 xhci_free_command(xhci, config_cmd);
1676 return ret;
1677}
1678
1597int xhci_get_frame(struct usb_hcd *hcd) 1679int xhci_get_frame(struct usb_hcd *hcd)
1598{ 1680{
1599 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 1681 struct xhci_hcd *xhci = hcd_to_xhci(hcd);