Lines Matching refs:port
14 static const char *tb_port_type(struct tb_regs_port_header *port) in tb_port_type() argument
16 switch (port->type >> 16) { in tb_port_type()
18 switch ((u8) port->type) { in tb_port_type()
43 static void tb_dump_port(struct tb *tb, struct tb_regs_port_header *port) in tb_dump_port() argument
47 port->port_number, port->vendor_id, port->device_id, in tb_dump_port()
48 port->revision, port->thunderbolt_version, tb_port_type(port), in tb_dump_port()
49 port->type); in tb_dump_port()
51 port->max_in_hop_id, port->max_out_hop_id); in tb_dump_port()
52 tb_info(tb, " Max counters: %d\n", port->max_counters); in tb_dump_port()
53 tb_info(tb, " NFC Credits: %#x\n", port->nfc_credits); in tb_dump_port()
63 static int tb_port_state(struct tb_port *port) in tb_port_state() argument
67 if (port->cap_phy == 0) { in tb_port_state()
68 tb_port_WARN(port, "does not have a PHY\n"); in tb_port_state()
71 res = tb_port_read(port, &phy, TB_CFG_PORT, port->cap_phy, 2); in tb_port_state()
90 int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged) in tb_wait_for_port() argument
94 if (!port->cap_phy) { in tb_wait_for_port()
95 tb_port_WARN(port, "does not have PHY\n"); in tb_wait_for_port()
98 if (tb_is_upstream_port(port)) { in tb_wait_for_port()
99 tb_port_WARN(port, "is the upstream port\n"); in tb_wait_for_port()
104 state = tb_port_state(port); in tb_wait_for_port()
108 tb_port_info(port, "is disabled (state: 0)\n"); in tb_wait_for_port()
114 tb_port_info(port, in tb_wait_for_port()
119 tb_port_info(port, "is unplugged (state: 7)\n"); in tb_wait_for_port()
123 tb_port_info(port, in tb_wait_for_port()
132 tb_port_info(port, in tb_wait_for_port()
137 tb_port_warn(port, in tb_wait_for_port()
150 int tb_port_add_nfc_credits(struct tb_port *port, int credits) in tb_port_add_nfc_credits() argument
154 tb_port_info(port, in tb_port_add_nfc_credits()
157 port->config.nfc_credits, in tb_port_add_nfc_credits()
158 port->config.nfc_credits + credits); in tb_port_add_nfc_credits()
159 port->config.nfc_credits += credits; in tb_port_add_nfc_credits()
160 return tb_port_write(port, &port->config.nfc_credits, in tb_port_add_nfc_credits()
169 int tb_port_clear_counter(struct tb_port *port, int counter) in tb_port_clear_counter() argument
172 tb_port_info(port, "clearing counter %d\n", counter); in tb_port_clear_counter()
173 return tb_port_write(port, zero, TB_CFG_COUNTERS, 3 * counter, 3); in tb_port_clear_counter()
184 static int tb_init_port(struct tb_port *port) in tb_init_port() argument
189 res = tb_port_read(port, &port->config, TB_CFG_PORT, 0, 8); in tb_init_port()
194 if (port->config.type == TB_TYPE_PORT && port->port != 0) { in tb_init_port()
195 cap = tb_find_cap(port, TB_CFG_PORT, TB_CAP_PHY); in tb_init_port()
198 port->cap_phy = cap; in tb_init_port()
200 tb_port_WARN(port, "non switch port without a PHY\n"); in tb_init_port()
203 tb_dump_port(port->sw->tb, &port->config); in tb_init_port()
390 sw->ports[i].port = i; in tb_switch_alloc()
477 struct tb_port *port = &sw->ports[i]; in tb_switch_resume() local
478 if (tb_is_upstream_port(port)) in tb_switch_resume()
480 if (!port->remote) in tb_switch_resume()
482 if (tb_wait_for_port(port, true) <= 0 in tb_switch_resume()
483 || tb_switch_resume(port->remote->sw)) { in tb_switch_resume()
484 tb_port_warn(port, in tb_switch_resume()
486 tb_sw_set_unpplugged(port->remote->sw); in tb_switch_resume()