]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
xhci: tegra: Add flexibility to enable ports
authorJoy Wang <joyw@nvidia.com>
Mon, 13 Jan 2014 05:42:57 +0000 (13:42 +0800)
committerBharat Nihalani <bnihalani@nvidia.com>
Tue, 18 Feb 2014 09:53:38 +0000 (01:53 -0800)
Let xusb can own ports with any combination.

Bug 1345723

Change-Id: I6532a44150bea1113ebee1483263158fb3c04117
Signed-off-by: Joy Wang <joyw@nvidia.com>
Reviewed-on: http://git-master/r/354888
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/platform/tegra/tegra_usb_pad_ctrl.c
drivers/usb/host/xhci-tegra.c

index 34ac67c448fce29194576700391b59f0f704099c..e9cc08d58374ee476752d92a01ea6a665d77b7ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -142,15 +142,11 @@ void tegra_xhci_ss_wake_signal(u32 portmap, bool enable)
        /* Assert/Deassert clamp_en_early signals to SSP0/1 */
        elpg_program0 = readl(pad_base + XUSB_PADCTL_ELPG_PROGRAM_0);
        if (enable) {
-               if (portmap & TEGRA_XUSB_SS_P0)
-                       elpg_program0 |= SSP0_ELPG_CLAMP_EN_EARLY;
-               if (portmap & TEGRA_XUSB_SS_P1)
-                       elpg_program0 |= SSP1_ELPG_CLAMP_EN_EARLY;
+               elpg_program0 |= SSP0_ELPG_CLAMP_EN_EARLY;
+               elpg_program0 |= SSP1_ELPG_CLAMP_EN_EARLY;
        } else {
-               if (portmap & TEGRA_XUSB_SS_P0)
-                       elpg_program0 &= ~SSP0_ELPG_CLAMP_EN_EARLY;
-               if (portmap & TEGRA_XUSB_SS_P1)
-                       elpg_program0 &= ~SSP1_ELPG_CLAMP_EN_EARLY;
+               elpg_program0 &= ~SSP0_ELPG_CLAMP_EN_EARLY;
+               elpg_program0 &= ~SSP1_ELPG_CLAMP_EN_EARLY;
        }
        writel(elpg_program0, pad_base + XUSB_PADCTL_ELPG_PROGRAM_0);
 
@@ -164,15 +160,11 @@ void tegra_xhci_ss_wake_signal(u32 portmap, bool enable)
        elpg_program0 = readl(pad_base + XUSB_PADCTL_ELPG_PROGRAM_0);
 
        if (enable) {
-               if (portmap & TEGRA_XUSB_SS_P0)
-                       elpg_program0 |= SSP0_ELPG_CLAMP_EN;
-               if (portmap & TEGRA_XUSB_SS_P1)
-                       elpg_program0 |= SSP1_ELPG_CLAMP_EN;
+               elpg_program0 |= SSP0_ELPG_CLAMP_EN;
+               elpg_program0 |= SSP1_ELPG_CLAMP_EN;
        } else {
-               if (portmap & TEGRA_XUSB_SS_P0)
-                       elpg_program0 &= ~SSP0_ELPG_CLAMP_EN;
-               if (portmap & TEGRA_XUSB_SS_P1)
-                       elpg_program0 &= ~SSP1_ELPG_CLAMP_EN;
+               elpg_program0 &= ~SSP0_ELPG_CLAMP_EN;
+               elpg_program0 &= ~SSP1_ELPG_CLAMP_EN;
        }
 
        writel(elpg_program0, pad_base + XUSB_PADCTL_ELPG_PROGRAM_0);
@@ -195,15 +187,11 @@ void tegra_xhci_ss_vcore(u32 portmap, bool enable)
        elpg_program0 = readl(pad_base + XUSB_PADCTL_ELPG_PROGRAM_0);
 
        if (enable) {
-               if (portmap & TEGRA_XUSB_SS_P0)
-                       elpg_program0 |= SSP0_ELPG_VCORE_DOWN;
-               if (portmap & TEGRA_XUSB_SS_P1)
-                       elpg_program0 |= SSP1_ELPG_VCORE_DOWN;
+               elpg_program0 |= SSP0_ELPG_VCORE_DOWN;
+               elpg_program0 |= SSP1_ELPG_VCORE_DOWN;
        } else {
-               if (portmap & TEGRA_XUSB_SS_P0)
-                       elpg_program0 &= ~SSP0_ELPG_VCORE_DOWN;
-               if (portmap & TEGRA_XUSB_SS_P1)
-                       elpg_program0 &= ~SSP1_ELPG_VCORE_DOWN;
+               elpg_program0 &= ~SSP0_ELPG_VCORE_DOWN;
+               elpg_program0 &= ~SSP1_ELPG_VCORE_DOWN;
        }
        writel(elpg_program0, pad_base + XUSB_PADCTL_ELPG_PROGRAM_0);
        spin_unlock_irqrestore(&xusb_padctl_lock, flags);
index c83c0267d4370ec337f80933160feb96590f3fd5..ddc1f3b8dde9e73ce62992e4bcc398b021056dc6 100644 (file)
@@ -90,6 +90,7 @@
                _reg, readl(_base + _reg))
 
 #define PMC_PORTMAP_MASK(map, pad)     (((map) >> 4*(pad)) & 0xF)
+#define GET_SS_PORTMAP(map, p)         (((map) >> 4*(p)) & 0xF)
 
 #define PMC_USB_DEBOUNCE_DEL_0                 0xec
 #define   UTMIP_LINE_DEB_CNT(x)                (((x) & 0xf) << 16)
@@ -179,7 +180,8 @@ struct cfgtbl {
        u8 magic[8];
        u32 SS_low_power_entry_timeout;
        u8 num_hsic_port;
-       u8 padding[139]; /* padding bytes to makeup 256-bytes cfgtbl */
+       u8 ss_portmap;
+       u8 padding[138]; /* padding bytes to makeup 256-bytes cfgtbl */
 };
 
 struct xusb_save_regs {
@@ -2189,6 +2191,14 @@ static void tegra_xhci_program_ss_pad(struct tegra_xhci_hcd *tegra,
                (port ? TEGRA_XUSB_SS1_PORT_MAP : TEGRA_XUSB_SS0_PORT_MAP));
        writel(reg, tegra->padctl_base + padregs->ss_port_map_0);
 
+       /* Make sure the SS port capability set correctly */
+       reg = readl(tegra->padctl_base + padregs->usb2_port_cap_0);
+       reg &= ~USB2_PORT_CAP_MASK(
+                       GET_SS_PORTMAP(tegra->bdata->ss_portmap, port));
+       reg |= USB2_PORT_CAP_HOST(
+                       GET_SS_PORTMAP(tegra->bdata->ss_portmap, port));
+       writel(reg, tegra->padctl_base + padregs->usb2_port_cap_0);
+
        tegra_xhci_restore_dfe_context(tegra, port);
        tegra_xhci_restore_ctle_context(tegra, port);
 }
@@ -2450,6 +2460,11 @@ static int load_firmware(struct tegra_xhci_hcd *tegra, bool resetARU)
        struct xhci_op_regs __iomem *op_regs;
        int pad;
 
+       /* Program SS port map config */
+       cfg_tbl->ss_portmap = 0x0;
+       cfg_tbl->ss_portmap |=
+               (tegra->bdata->portmap & ((1 << XUSB_SS_PORT_COUNT) - 1));
+
        /* enable mbox interrupt */
        writel(readl(tegra->fpci_base + XUSB_CFG_ARU_MBOX_CMD) | MBOX_INT_EN,
                tegra->fpci_base + XUSB_CFG_ARU_MBOX_CMD);
@@ -4532,7 +4547,7 @@ static int tegra_xhci_probe2(struct tegra_xhci_hcd *tegra)
        unsigned port;
 
 
-       ret = load_firmware(tegra, true /* do reset ARU */);
+       ret = load_firmware(tegra, false /* do reset ARU */);
        if (ret < 0) {
                dev_err(&pdev->dev, "failed to load firmware\n");
                return -ENODEV;