Skip to content

Commit 9817638

Browse files
committed
thunderbolt: Convert DP adapter register names to follow the USB4 spec
Now that USB4 spec has names for these DP adapter registers we can use them instead. This makes it easier to match certain register to the spec. No functional changes. Signed-off-by: Mika Westerberg <[email protected]>
1 parent 778bfca commit 9817638

File tree

3 files changed

+46
-44
lines changed

3 files changed

+46
-44
lines changed

drivers/thunderbolt/switch.c

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -835,11 +835,12 @@ int tb_dp_port_hpd_is_active(struct tb_port *port)
835835
u32 data;
836836
int ret;
837837

838-
ret = tb_port_read(port, &data, TB_CFG_PORT, port->cap_adap + 2, 1);
838+
ret = tb_port_read(port, &data, TB_CFG_PORT,
839+
port->cap_adap + ADP_DP_CS_2, 1);
839840
if (ret)
840841
return ret;
841842

842-
return !!(data & TB_DP_HDP);
843+
return !!(data & ADP_DP_CS_2_HDP);
843844
}
844845

845846
/**
@@ -853,12 +854,14 @@ int tb_dp_port_hpd_clear(struct tb_port *port)
853854
u32 data;
854855
int ret;
855856

856-
ret = tb_port_read(port, &data, TB_CFG_PORT, port->cap_adap + 3, 1);
857+
ret = tb_port_read(port, &data, TB_CFG_PORT,
858+
port->cap_adap + ADP_DP_CS_3, 1);
857859
if (ret)
858860
return ret;
859861

860-
data |= TB_DP_HPDC;
861-
return tb_port_write(port, &data, TB_CFG_PORT, port->cap_adap + 3, 1);
862+
data |= ADP_DP_CS_3_HDPC;
863+
return tb_port_write(port, &data, TB_CFG_PORT,
864+
port->cap_adap + ADP_DP_CS_3, 1);
862865
}
863866

864867
/**
@@ -876,20 +879,23 @@ int tb_dp_port_set_hops(struct tb_port *port, unsigned int video,
876879
u32 data[2];
877880
int ret;
878881

879-
ret = tb_port_read(port, data, TB_CFG_PORT, port->cap_adap,
880-
ARRAY_SIZE(data));
882+
ret = tb_port_read(port, data, TB_CFG_PORT,
883+
port->cap_adap + ADP_DP_CS_0, ARRAY_SIZE(data));
881884
if (ret)
882885
return ret;
883886

884-
data[0] &= ~TB_DP_VIDEO_HOPID_MASK;
885-
data[1] &= ~(TB_DP_AUX_RX_HOPID_MASK | TB_DP_AUX_TX_HOPID_MASK);
887+
data[0] &= ~ADP_DP_CS_0_VIDEO_HOPID_MASK;
888+
data[1] &= ~ADP_DP_CS_1_AUX_RX_HOPID_MASK;
889+
data[1] &= ~ADP_DP_CS_1_AUX_RX_HOPID_MASK;
886890

887-
data[0] |= (video << TB_DP_VIDEO_HOPID_SHIFT) & TB_DP_VIDEO_HOPID_MASK;
888-
data[1] |= aux_tx & TB_DP_AUX_TX_HOPID_MASK;
889-
data[1] |= (aux_rx << TB_DP_AUX_RX_HOPID_SHIFT) & TB_DP_AUX_RX_HOPID_MASK;
891+
data[0] |= (video << ADP_DP_CS_0_VIDEO_HOPID_SHIFT) &
892+
ADP_DP_CS_0_VIDEO_HOPID_MASK;
893+
data[1] |= aux_tx & ADP_DP_CS_1_AUX_TX_HOPID_MASK;
894+
data[1] |= (aux_rx << ADP_DP_CS_1_AUX_RX_HOPID_SHIFT) &
895+
ADP_DP_CS_1_AUX_RX_HOPID_MASK;
890896

891-
return tb_port_write(port, data, TB_CFG_PORT, port->cap_adap,
892-
ARRAY_SIZE(data));
897+
return tb_port_write(port, data, TB_CFG_PORT,
898+
port->cap_adap + ADP_DP_CS_0, ARRAY_SIZE(data));
893899
}
894900

895901
/**
@@ -900,11 +906,11 @@ bool tb_dp_port_is_enabled(struct tb_port *port)
900906
{
901907
u32 data[2];
902908

903-
if (tb_port_read(port, data, TB_CFG_PORT, port->cap_adap,
909+
if (tb_port_read(port, data, TB_CFG_PORT, port->cap_adap + ADP_DP_CS_0,
904910
ARRAY_SIZE(data)))
905911
return false;
906912

907-
return !!(data[0] & (TB_DP_VIDEO_EN | TB_DP_AUX_EN));
913+
return !!(data[0] & (ADP_DP_CS_0_VE | ADP_DP_CS_0_AE));
908914
}
909915

910916
/**
@@ -920,18 +926,18 @@ int tb_dp_port_enable(struct tb_port *port, bool enable)
920926
u32 data[2];
921927
int ret;
922928

923-
ret = tb_port_read(port, data, TB_CFG_PORT, port->cap_adap,
924-
ARRAY_SIZE(data));
929+
ret = tb_port_read(port, data, TB_CFG_PORT,
930+
port->cap_adap + ADP_DP_CS_0, ARRAY_SIZE(data));
925931
if (ret)
926932
return ret;
927933

928934
if (enable)
929-
data[0] |= TB_DP_VIDEO_EN | TB_DP_AUX_EN;
935+
data[0] |= ADP_DP_CS_0_VE | ADP_DP_CS_0_AE;
930936
else
931-
data[0] &= ~(TB_DP_VIDEO_EN | TB_DP_AUX_EN);
937+
data[0] &= ~(ADP_DP_CS_0_VE | ADP_DP_CS_0_AE);
932938

933-
return tb_port_write(port, data, TB_CFG_PORT, port->cap_adap,
934-
ARRAY_SIZE(data));
939+
return tb_port_write(port, data, TB_CFG_PORT,
940+
port->cap_adap + ADP_DP_CS_0, ARRAY_SIZE(data));
935941
}
936942

937943
/* switch utility functions */

drivers/thunderbolt/tb_regs.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -221,24 +221,20 @@ struct tb_regs_port_header {
221221
#define ADP_CS_5_LCA_SHIFT 22
222222

223223
/* Display Port adapter registers */
224-
225-
/* DWORD 0 */
226-
#define TB_DP_VIDEO_HOPID_SHIFT 16
227-
#define TB_DP_VIDEO_HOPID_MASK GENMASK(26, 16)
228-
#define TB_DP_AUX_EN BIT(30)
229-
#define TB_DP_VIDEO_EN BIT(31)
230-
/* DWORD 1 */
231-
#define TB_DP_AUX_TX_HOPID_MASK GENMASK(10, 0)
232-
#define TB_DP_AUX_RX_HOPID_SHIFT 11
233-
#define TB_DP_AUX_RX_HOPID_MASK GENMASK(21, 11)
234-
/* DWORD 2 */
235-
#define TB_DP_HDP BIT(6)
236-
/* DWORD 3 */
237-
#define TB_DP_HPDC BIT(9)
238-
/* DWORD 4 */
239-
#define TB_DP_LOCAL_CAP 0x4
240-
/* DWORD 5 */
241-
#define TB_DP_REMOTE_CAP 0x5
224+
#define ADP_DP_CS_0 0x00
225+
#define ADP_DP_CS_0_VIDEO_HOPID_MASK GENMASK(26, 16)
226+
#define ADP_DP_CS_0_VIDEO_HOPID_SHIFT 16
227+
#define ADP_DP_CS_0_AE BIT(30)
228+
#define ADP_DP_CS_0_VE BIT(31)
229+
#define ADP_DP_CS_1_AUX_TX_HOPID_MASK GENMASK(10, 0)
230+
#define ADP_DP_CS_1_AUX_RX_HOPID_MASK GENMASK(21, 11)
231+
#define ADP_DP_CS_1_AUX_RX_HOPID_SHIFT 11
232+
#define ADP_DP_CS_2 0x02
233+
#define ADP_DP_CS_2_HDP BIT(6)
234+
#define ADP_DP_CS_3 0x03
235+
#define ADP_DP_CS_3_HDPC BIT(9)
236+
#define DP_LOCAL_CAP 0x04
237+
#define DP_REMOTE_CAP 0x05
242238

243239
/* PCIe adapter registers */
244240
#define ADP_PCIE_CS_0 0x00

drivers/thunderbolt/tunnel.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,23 +241,23 @@ static int tb_dp_xchg_caps(struct tb_tunnel *tunnel)
241241

242242
/* Read both DP_LOCAL_CAP registers */
243243
ret = tb_port_read(in, &in_dp_cap, TB_CFG_PORT,
244-
in->cap_adap + TB_DP_LOCAL_CAP, 1);
244+
in->cap_adap + DP_LOCAL_CAP, 1);
245245
if (ret)
246246
return ret;
247247

248248
ret = tb_port_read(out, &out_dp_cap, TB_CFG_PORT,
249-
out->cap_adap + TB_DP_LOCAL_CAP, 1);
249+
out->cap_adap + DP_LOCAL_CAP, 1);
250250
if (ret)
251251
return ret;
252252

253253
/* Write IN local caps to OUT remote caps */
254254
ret = tb_port_write(out, &in_dp_cap, TB_CFG_PORT,
255-
out->cap_adap + TB_DP_REMOTE_CAP, 1);
255+
out->cap_adap + DP_REMOTE_CAP, 1);
256256
if (ret)
257257
return ret;
258258

259259
return tb_port_write(in, &out_dp_cap, TB_CFG_PORT,
260-
in->cap_adap + TB_DP_REMOTE_CAP, 1);
260+
in->cap_adap + DP_REMOTE_CAP, 1);
261261
}
262262

263263
static int tb_dp_activate(struct tb_tunnel *tunnel, bool active)

0 commit comments

Comments
 (0)