Skip to content

Commit 3846d01

Browse files
committed
thunderbolt: Pass CL state bitmask to tb_port_clx_supported()
Instead of testing just a single CL state we can pass a bitmask of states to check. This makes it simpler for callers of the function. We also add a check for CL2 even though not fully supported by the driver yet. Suggested-by: Lukas Wunner <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
1 parent 95f8f1c commit 3846d01

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

drivers/thunderbolt/switch.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,9 +1259,9 @@ static int tb_port_pm_secondary_disable(struct tb_port *port)
12591259
}
12601260

12611261
/* Called for USB4 or Titan Ridge routers only */
1262-
static bool tb_port_clx_supported(struct tb_port *port, enum tb_clx clx)
1262+
static bool tb_port_clx_supported(struct tb_port *port, unsigned int clx_mask)
12631263
{
1264-
u32 mask, val;
1264+
u32 val, mask = 0;
12651265
bool ret;
12661266

12671267
/* Don't enable CLx in case of two single-lane links */
@@ -1279,17 +1279,12 @@ static bool tb_port_clx_supported(struct tb_port *port, enum tb_clx clx)
12791279
return false;
12801280
}
12811281

1282-
switch (clx) {
1283-
case TB_CL1:
1282+
if (clx_mask & TB_CL1) {
12841283
/* CL0s and CL1 are enabled and supported together */
1285-
mask = LANE_ADP_CS_0_CL0S_SUPPORT | LANE_ADP_CS_0_CL1_SUPPORT;
1286-
break;
1287-
1288-
/* For now we support only CL0s and CL1. Not CL2 */
1289-
case TB_CL2:
1290-
default:
1291-
return false;
1284+
mask |= LANE_ADP_CS_0_CL0S_SUPPORT | LANE_ADP_CS_0_CL1_SUPPORT;
12921285
}
1286+
if (clx_mask & TB_CL2)
1287+
mask |= LANE_ADP_CS_0_CL2_SUPPORT;
12931288

12941289
ret = tb_port_read(port, &val, TB_CFG_PORT,
12951290
port->cap_phy + LANE_ADP_CS_0, 1);

drivers/thunderbolt/tb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ struct tb_switch_tmu {
113113
enum tb_clx {
114114
TB_CLX_DISABLE,
115115
/* CL0s and CL1 are enabled and supported together */
116-
TB_CL1,
117-
TB_CL2,
116+
TB_CL1 = BIT(0),
117+
TB_CL2 = BIT(1),
118118
};
119119

120120
/**

drivers/thunderbolt/tb_regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ struct tb_regs_port_header {
324324
#define LANE_ADP_CS_0_SUPPORTED_WIDTH_DUAL 0x2
325325
#define LANE_ADP_CS_0_CL0S_SUPPORT BIT(26)
326326
#define LANE_ADP_CS_0_CL1_SUPPORT BIT(27)
327+
#define LANE_ADP_CS_0_CL2_SUPPORT BIT(28)
327328
#define LANE_ADP_CS_1 0x01
328329
#define LANE_ADP_CS_1_TARGET_SPEED_MASK GENMASK(3, 0)
329330
#define LANE_ADP_CS_1_TARGET_SPEED_GEN3 0xc

0 commit comments

Comments
 (0)