summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt/switch.c
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2019-01-09 09:42:12 -0500
committerMika Westerberg <mika.westerberg@linux.intel.com>2019-04-18 04:18:51 -0400
commita9be55824a10653d0247de12dc6b9a741ce3fc98 (patch)
treea2d8b835041d68b65e0222331d36021d8ed55727 /drivers/thunderbolt/switch.c
parentffd003b2f8cba8dde0f7259e2207d63f75691096 (diff)
thunderbolt: Move LC specific functionality into a separate file
We will be adding more link controller functionality in subsequent patches and it does not make sense to keep all that in switch.c, so separate LC functionality into its own file. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt/switch.c')
-rw-r--r--drivers/thunderbolt/switch.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 1e29c06947af..63ff4c753d89 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -1182,6 +1182,10 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,
1182 } 1182 }
1183 sw->cap_plug_events = cap; 1183 sw->cap_plug_events = cap;
1184 1184
1185 cap = tb_switch_find_vse_cap(sw, TB_VSE_CAP_LINK_CONTROLLER);
1186 if (cap > 0)
1187 sw->cap_lc = cap;
1188
1185 /* Root switch is always authorized */ 1189 /* Root switch is always authorized */
1186 if (!route) 1190 if (!route)
1187 sw->authorized = true; 1191 sw->authorized = true;
@@ -1278,22 +1282,17 @@ int tb_switch_configure(struct tb_switch *sw)
1278static int tb_switch_set_uuid(struct tb_switch *sw) 1282static int tb_switch_set_uuid(struct tb_switch *sw)
1279{ 1283{
1280 u32 uuid[4]; 1284 u32 uuid[4];
1281 int cap, ret; 1285 int ret;
1282 1286
1283 ret = 0;
1284 if (sw->uuid) 1287 if (sw->uuid)
1285 return ret; 1288 return 0;
1286 1289
1287 /* 1290 /*
1288 * The newer controllers include fused UUID as part of link 1291 * The newer controllers include fused UUID as part of link
1289 * controller specific registers 1292 * controller specific registers
1290 */ 1293 */
1291 cap = tb_switch_find_vse_cap(sw, TB_VSE_CAP_LINK_CONTROLLER); 1294 ret = tb_lc_read_uuid(sw, uuid);
1292 if (cap > 0) { 1295 if (ret) {
1293 ret = tb_sw_read(sw, uuid, TB_CFG_SWITCH, cap + 3, 4);
1294 if (ret)
1295 return ret;
1296 } else {
1297 /* 1296 /*
1298 * ICM generates UUID based on UID and fills the upper 1297 * ICM generates UUID based on UID and fills the upper
1299 * two words with ones. This is not strictly following 1298 * two words with ones. This is not strictly following
@@ -1308,8 +1307,8 @@ static int tb_switch_set_uuid(struct tb_switch *sw)
1308 1307
1309 sw->uuid = kmemdup(uuid, sizeof(uuid), GFP_KERNEL); 1308 sw->uuid = kmemdup(uuid, sizeof(uuid), GFP_KERNEL);
1310 if (!sw->uuid) 1309 if (!sw->uuid)
1311 ret = -ENOMEM; 1310 return -ENOMEM;
1312 return ret; 1311 return 0;
1313} 1312}
1314 1313
1315static int tb_switch_add_dma_port(struct tb_switch *sw) 1314static int tb_switch_add_dma_port(struct tb_switch *sw)