Skip to content

Commit 04abb6d

Browse files
LuBaolugregkh
authored andcommitted
xhci: Read and parse new xhci 1.1 capability register
xhci 1.1 capable controllers have a new HCCPARAMS2 registers with bits indicating support for new xhci 1.1 capabilities. Also add support for the new xhci 1.1 bits in the config operational opertational register that used to be reserved Signed-off-by: Lu Baolu <[email protected]> [modified and left out parts not related to HCCPARAMS2 -Mathias] Signed-off-by: Mathias Nyman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 07294cc commit 04abb6d

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

drivers/usb/host/xhci-dbg.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,17 @@ void xhci_dbg_regs(struct xhci_hcd *xhci)
5858
static void xhci_print_cap_regs(struct xhci_hcd *xhci)
5959
{
6060
u32 temp;
61+
u32 hci_version;
6162

6263
xhci_dbg(xhci, "xHCI capability registers at %p:\n", xhci->cap_regs);
6364

6465
temp = readl(&xhci->cap_regs->hc_capbase);
66+
hci_version = HC_VERSION(temp);
6567
xhci_dbg(xhci, "CAPLENGTH AND HCIVERSION 0x%x:\n",
6668
(unsigned int) temp);
6769
xhci_dbg(xhci, "CAPLENGTH: 0x%x\n",
6870
(unsigned int) HC_LENGTH(temp));
69-
xhci_dbg(xhci, "HCIVERSION: 0x%x\n",
70-
(unsigned int) HC_VERSION(temp));
71+
xhci_dbg(xhci, "HCIVERSION: 0x%x\n", hci_version);
7172

7273
temp = readl(&xhci->cap_regs->hcs_params1);
7374
xhci_dbg(xhci, "HCSPARAMS 1: 0x%x\n",
@@ -108,6 +109,18 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
108109

109110
temp = readl(&xhci->cap_regs->run_regs_off);
110111
xhci_dbg(xhci, "RTSOFF 0x%x:\n", temp & RTSOFF_MASK);
112+
113+
/* xhci 1.1 controllers have the HCCPARAMS2 register */
114+
if (hci_version > 100) {
115+
temp = readl(&xhci->cap_regs->hcc_params2);
116+
xhci_dbg(xhci, "HCC PARAMS2 0x%x:\n", (unsigned int) temp);
117+
xhci_dbg(xhci, " HC %s Force save context capability",
118+
HCC2_FSC(temp) ? "supports" : "doesn't support");
119+
xhci_dbg(xhci, " HC %s Large ESIT Payload Capability",
120+
HCC2_LEC(temp) ? "supports" : "doesn't support");
121+
xhci_dbg(xhci, " HC %s Extended TBC capability",
122+
HCC2_ETC(temp) ? "supports" : "doesn't support");
123+
}
111124
}
112125

113126
static void xhci_print_command_reg(struct xhci_hcd *xhci)

drivers/usb/host/xhci.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4875,6 +4875,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
48754875
xhci->hcc_params = readl(&xhci->cap_regs->hc_capbase);
48764876
xhci->hci_version = HC_VERSION(xhci->hcc_params);
48774877
xhci->hcc_params = readl(&xhci->cap_regs->hcc_params);
4878+
if (xhci->hci_version > 0x100)
4879+
xhci->hcc_params2 = readl(&xhci->cap_regs->hcc_params2);
48784880
xhci_print_registers(xhci);
48794881

48804882
xhci->quirks = quirks;
@@ -5020,7 +5022,7 @@ static int __init xhci_hcd_init(void)
50205022
BUILD_BUG_ON(sizeof(struct xhci_stream_ctx) != 4*32/8);
50215023
BUILD_BUG_ON(sizeof(union xhci_trb) != 4*32/8);
50225024
BUILD_BUG_ON(sizeof(struct xhci_erst_entry) != 4*32/8);
5023-
BUILD_BUG_ON(sizeof(struct xhci_cap_regs) != 7*32/8);
5025+
BUILD_BUG_ON(sizeof(struct xhci_cap_regs) != 8*32/8);
50245026
BUILD_BUG_ON(sizeof(struct xhci_intr_reg) != 8*32/8);
50255027
/* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */
50265028
BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);

drivers/usb/host/xhci.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
* @hcc_params: HCCPARAMS - Capability Parameters
5757
* @db_off: DBOFF - Doorbell array offset
5858
* @run_regs_off: RTSOFF - Runtime register space offset
59+
* @hcc_params2: HCCPARAMS2 Capability Parameters 2, xhci 1.1 only
5960
*/
6061
struct xhci_cap_regs {
6162
__le32 hc_capbase;
@@ -65,6 +66,7 @@ struct xhci_cap_regs {
6566
__le32 hcc_params;
6667
__le32 db_off;
6768
__le32 run_regs_off;
69+
__le32 hcc_params2; /* xhci 1.1 */
6870
/* Reserved up to (CAPLENGTH - 0x1C) */
6971
};
7072

@@ -134,6 +136,21 @@ struct xhci_cap_regs {
134136
/* run_regs_off bitmask - bits 0:4 reserved */
135137
#define RTSOFF_MASK (~0x1f)
136138

139+
/* HCCPARAMS2 - hcc_params2 - bitmasks */
140+
/* true: HC supports U3 entry Capability */
141+
#define HCC2_U3C(p) ((p) & (1 << 0))
142+
/* true: HC supports Configure endpoint command Max exit latency too large */
143+
#define HCC2_CMC(p) ((p) & (1 << 1))
144+
/* true: HC supports Force Save context Capability */
145+
#define HCC2_FSC(p) ((p) & (1 << 2))
146+
/* true: HC supports Compliance Transition Capability */
147+
#define HCC2_CTC(p) ((p) & (1 << 3))
148+
/* true: HC support Large ESIT payload Capability > 48k */
149+
#define HCC2_LEC(p) ((p) & (1 << 4))
150+
/* true: HC support Configuration Information Capability */
151+
#define HCC2_CIC(p) ((p) & (1 << 5))
152+
/* true: HC support Extended TBC Capability, Isoc burst count > 65535 */
153+
#define HCC2_ETC(p) ((p) & (1 << 6))
137154

138155
/* Number of registers per port */
139156
#define NUM_PORT_REGS 4
@@ -269,7 +286,11 @@ struct xhci_op_regs {
269286
/* CONFIG - Configure Register - config_reg bitmasks */
270287
/* bits 0:7 - maximum number of device slots enabled (NumSlotsEn) */
271288
#define MAX_DEVS(p) ((p) & 0xff)
272-
/* bits 8:31 - reserved and should be preserved */
289+
/* bit 8: U3 Entry Enabled, assert PLC when root port enters U3, xhci 1.1 */
290+
#define CONFIG_U3E (1 << 8)
291+
/* bit 9: Configuration Information Enable, xhci 1.1 */
292+
#define CONFIG_CIE (1 << 9)
293+
/* bits 10:31 - reserved and should be preserved */
273294

274295
/* PORTSC - Port Status and Control Register - port_status_base bitmasks */
275296
/* true: device connected */
@@ -1465,6 +1486,7 @@ struct xhci_hcd {
14651486
__u32 hcs_params2;
14661487
__u32 hcs_params3;
14671488
__u32 hcc_params;
1489+
__u32 hcc_params2;
14681490

14691491
spinlock_t lock;
14701492

0 commit comments

Comments
 (0)