tb.h 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Thunderbolt driver - bus logic (NHI independent)
  4. *
  5. * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
  6. * Copyright (C) 2018, Intel Corporation
  7. */
  8. #ifndef TB_H_
  9. #define TB_H_
  10. #include <linux/nvmem-provider.h>
  11. #include <linux/pci.h>
  12. #include <linux/thunderbolt.h>
  13. #include <linux/uuid.h>
  14. #include <linux/bitfield.h>
  15. #include "tb_regs.h"
  16. #include "ctl.h"
  17. #include "dma_port.h"
  18. /* Keep link controller awake during update */
  19. #define QUIRK_FORCE_POWER_LINK_CONTROLLER BIT(0)
  20. /* Disable CLx if not supported */
  21. #define QUIRK_NO_CLX BIT(1)
  22. /* Need to keep power on while USB4 port is in redrive mode */
  23. #define QUIRK_KEEP_POWER_IN_DP_REDRIVE BIT(2)
  24. /**
  25. * struct tb_nvm - Structure holding NVM information
  26. * @dev: Owner of the NVM
  27. * @major: Major version number of the active NVM portion
  28. * @minor: Minor version number of the active NVM portion
  29. * @id: Identifier used with both NVM portions
  30. * @active: Active portion NVMem device
  31. * @active_size: Size in bytes of the active NVM
  32. * @non_active: Non-active portion NVMem device
  33. * @buf: Buffer where the NVM image is stored before it is written to
  34. * the actual NVM flash device
  35. * @buf_data_start: Where the actual image starts after skipping
  36. * possible headers
  37. * @buf_data_size: Number of bytes actually consumed by the new NVM
  38. * image
  39. * @authenticating: The device is authenticating the new NVM
  40. * @flushed: The image has been flushed to the storage area
  41. * @vops: Router vendor specific NVM operations (optional)
  42. *
  43. * The user of this structure needs to handle serialization of possible
  44. * concurrent access.
  45. */
  46. struct tb_nvm {
  47. struct device *dev;
  48. u32 major;
  49. u32 minor;
  50. int id;
  51. struct nvmem_device *active;
  52. size_t active_size;
  53. struct nvmem_device *non_active;
  54. void *buf;
  55. void *buf_data_start;
  56. size_t buf_data_size;
  57. bool authenticating;
  58. bool flushed;
  59. const struct tb_nvm_vendor_ops *vops;
  60. };
  61. enum tb_nvm_write_ops {
  62. WRITE_AND_AUTHENTICATE = 1,
  63. WRITE_ONLY = 2,
  64. AUTHENTICATE_ONLY = 3,
  65. };
  66. #define TB_SWITCH_KEY_SIZE 32
  67. #define TB_SWITCH_MAX_DEPTH 6
  68. #define USB4_SWITCH_MAX_DEPTH 5
  69. /**
  70. * enum tb_switch_tmu_mode - TMU mode
  71. * @TB_SWITCH_TMU_MODE_OFF: TMU is off
  72. * @TB_SWITCH_TMU_MODE_LOWRES: Uni-directional, normal mode
  73. * @TB_SWITCH_TMU_MODE_HIFI_UNI: Uni-directional, HiFi mode
  74. * @TB_SWITCH_TMU_MODE_HIFI_BI: Bi-directional, HiFi mode
  75. * @TB_SWITCH_TMU_MODE_MEDRES_ENHANCED_UNI: Enhanced Uni-directional, MedRes mode
  76. *
  77. * Ordering is based on TMU accuracy level (highest last).
  78. */
  79. enum tb_switch_tmu_mode {
  80. TB_SWITCH_TMU_MODE_OFF,
  81. TB_SWITCH_TMU_MODE_LOWRES,
  82. TB_SWITCH_TMU_MODE_HIFI_UNI,
  83. TB_SWITCH_TMU_MODE_HIFI_BI,
  84. TB_SWITCH_TMU_MODE_MEDRES_ENHANCED_UNI,
  85. };
  86. /**
  87. * struct tb_switch_tmu - Structure holding router TMU configuration
  88. * @cap: Offset to the TMU capability (%0 if not found)
  89. * @has_ucap: Does the switch support uni-directional mode
  90. * @mode: TMU mode related to the upstream router. Reflects the HW
  91. * setting. Don't care for host router.
  92. * @mode_request: TMU mode requested to set. Related to upstream router.
  93. * Don't care for host router.
  94. */
  95. struct tb_switch_tmu {
  96. int cap;
  97. bool has_ucap;
  98. enum tb_switch_tmu_mode mode;
  99. enum tb_switch_tmu_mode mode_request;
  100. };
  101. /**
  102. * struct tb_switch - a thunderbolt switch
  103. * @dev: Device for the switch
  104. * @config: Switch configuration
  105. * @ports: Ports in this switch
  106. * @dma_port: If the switch has port supporting DMA configuration based
  107. * mailbox this will hold the pointer to that (%NULL
  108. * otherwise). If set it also means the switch has
  109. * upgradeable NVM.
  110. * @tmu: The switch TMU configuration
  111. * @tb: Pointer to the domain the switch belongs to
  112. * @uid: Unique ID of the switch
  113. * @uuid: UUID of the switch (or %NULL if not supported)
  114. * @vendor: Vendor ID of the switch
  115. * @device: Device ID of the switch
  116. * @vendor_name: Name of the vendor (or %NULL if not known)
  117. * @device_name: Name of the device (or %NULL if not known)
  118. * @link_speed: Speed of the link in Gb/s
  119. * @link_width: Width of the upstream facing link
  120. * @preferred_link_width: Router preferred link width (only set for Gen 4 links)
  121. * @link_usb4: Upstream link is USB4
  122. * @generation: Switch Thunderbolt generation
  123. * @cap_plug_events: Offset to the plug events capability (%0 if not found)
  124. * @cap_vsec_tmu: Offset to the TMU vendor specific capability (%0 if not found)
  125. * @cap_lc: Offset to the link controller capability (%0 if not found)
  126. * @cap_lp: Offset to the low power (CLx for TBT) capability (%0 if not found)
  127. * @is_unplugged: The switch is going away
  128. * @drom: DROM of the switch (%NULL if not found)
  129. * @nvm: Pointer to the NVM if the switch has one (%NULL otherwise)
  130. * @no_nvm_upgrade: Prevent NVM upgrade of this switch
  131. * @safe_mode: The switch is in safe-mode
  132. * @boot: Whether the switch was already authorized on boot or not
  133. * @rpm: The switch supports runtime PM
  134. * @authorized: Whether the switch is authorized by user or policy
  135. * @security_level: Switch supported security level
  136. * @debugfs_dir: Pointer to the debugfs structure
  137. * @key: Contains the key used to challenge the device or %NULL if not
  138. * supported. Size of the key is %TB_SWITCH_KEY_SIZE.
  139. * @connection_id: Connection ID used with ICM messaging
  140. * @connection_key: Connection key used with ICM messaging
  141. * @link: Root switch link this switch is connected (ICM only)
  142. * @depth: Depth in the chain this switch is connected (ICM only)
  143. * @rpm_complete: Completion used to wait for runtime resume to
  144. * complete (ICM only)
  145. * @quirks: Quirks used for this Thunderbolt switch
  146. * @credit_allocation: Are the below buffer allocation parameters valid
  147. * @max_usb3_credits: Router preferred number of buffers for USB 3.x
  148. * @min_dp_aux_credits: Router preferred minimum number of buffers for DP AUX
  149. * @min_dp_main_credits: Router preferred minimum number of buffers for DP MAIN
  150. * @max_pcie_credits: Router preferred number of buffers for PCIe
  151. * @max_dma_credits: Router preferred number of buffers for DMA/P2P
  152. * @clx: CLx states on the upstream link of the router
  153. *
  154. * When the switch is being added or removed to the domain (other
  155. * switches) you need to have domain lock held.
  156. *
  157. * In USB4 terminology this structure represents a router.
  158. */
  159. struct tb_switch {
  160. struct device dev;
  161. struct tb_regs_switch_header config;
  162. struct tb_port *ports;
  163. struct tb_dma_port *dma_port;
  164. struct tb_switch_tmu tmu;
  165. struct tb *tb;
  166. u64 uid;
  167. uuid_t *uuid;
  168. u16 vendor;
  169. u16 device;
  170. const char *vendor_name;
  171. const char *device_name;
  172. unsigned int link_speed;
  173. enum tb_link_width link_width;
  174. enum tb_link_width preferred_link_width;
  175. bool link_usb4;
  176. unsigned int generation;
  177. int cap_plug_events;
  178. int cap_vsec_tmu;
  179. int cap_lc;
  180. int cap_lp;
  181. bool is_unplugged;
  182. u8 *drom;
  183. struct tb_nvm *nvm;
  184. bool no_nvm_upgrade;
  185. bool safe_mode;
  186. bool boot;
  187. bool rpm;
  188. unsigned int authorized;
  189. enum tb_security_level security_level;
  190. struct dentry *debugfs_dir;
  191. u8 *key;
  192. u8 connection_id;
  193. u8 connection_key;
  194. u8 link;
  195. u8 depth;
  196. struct completion rpm_complete;
  197. unsigned long quirks;
  198. bool credit_allocation;
  199. unsigned int max_usb3_credits;
  200. unsigned int min_dp_aux_credits;
  201. unsigned int min_dp_main_credits;
  202. unsigned int max_pcie_credits;
  203. unsigned int max_dma_credits;
  204. unsigned int clx;
  205. };
  206. /**
  207. * struct tb_bandwidth_group - Bandwidth management group
  208. * @tb: Pointer to the domain the group belongs to
  209. * @index: Index of the group (aka Group_ID). Valid values %1-%7
  210. * @ports: DP IN adapters belonging to this group are linked here
  211. * @reserved: Bandwidth released by one tunnel in the group, available
  212. * to others. This is reported as part of estimated_bw for
  213. * the group.
  214. * @release_work: Worker to release the @reserved if it is not used by
  215. * any of the tunnels.
  216. *
  217. * Any tunnel that requires isochronous bandwidth (that's DP for now) is
  218. * attached to a bandwidth group. All tunnels going through the same
  219. * USB4 links share the same group and can dynamically distribute the
  220. * bandwidth within the group.
  221. */
  222. struct tb_bandwidth_group {
  223. struct tb *tb;
  224. int index;
  225. struct list_head ports;
  226. int reserved;
  227. struct delayed_work release_work;
  228. };
  229. /**
  230. * struct tb_port - a thunderbolt port, part of a tb_switch
  231. * @config: Cached port configuration read from registers
  232. * @sw: Switch the port belongs to
  233. * @remote: Remote port (%NULL if not connected)
  234. * @xdomain: Remote host (%NULL if not connected)
  235. * @cap_phy: Offset, zero if not found
  236. * @cap_tmu: Offset of the adapter specific TMU capability (%0 if not present)
  237. * @cap_adap: Offset of the adapter specific capability (%0 if not present)
  238. * @cap_usb4: Offset to the USB4 port capability (%0 if not present)
  239. * @usb4: Pointer to the USB4 port structure (only if @cap_usb4 is != %0)
  240. * @port: Port number on switch
  241. * @disabled: Disabled by eeprom or enabled but not implemented
  242. * @bonded: true if the port is bonded (two lanes combined as one)
  243. * @dual_link_port: If the switch is connected using two ports, points
  244. * to the other port.
  245. * @link_nr: Is this primary or secondary port on the dual_link.
  246. * @in_hopids: Currently allocated input HopIDs
  247. * @out_hopids: Currently allocated output HopIDs
  248. * @list: Used to link ports to DP resources list
  249. * @total_credits: Total number of buffers available for this port
  250. * @ctl_credits: Buffers reserved for control path
  251. * @dma_credits: Number of credits allocated for DMA tunneling for all
  252. * DMA paths through this port.
  253. * @group: Bandwidth allocation group the adapter is assigned to. Only
  254. * used for DP IN adapters for now.
  255. * @group_list: The adapter is linked to the group's list of ports through this
  256. * @max_bw: Maximum possible bandwidth through this adapter if set to
  257. * non-zero.
  258. * @redrive: For DP IN, if true the adapter is in redrive mode.
  259. *
  260. * In USB4 terminology this structure represents an adapter (protocol or
  261. * lane adapter).
  262. */
  263. struct tb_port {
  264. struct tb_regs_port_header config;
  265. struct tb_switch *sw;
  266. struct tb_port *remote;
  267. struct tb_xdomain *xdomain;
  268. int cap_phy;
  269. int cap_tmu;
  270. int cap_adap;
  271. int cap_usb4;
  272. struct usb4_port *usb4;
  273. u8 port;
  274. bool disabled;
  275. bool bonded;
  276. struct tb_port *dual_link_port;
  277. u8 link_nr:1;
  278. struct ida in_hopids;
  279. struct ida out_hopids;
  280. struct list_head list;
  281. unsigned int total_credits;
  282. unsigned int ctl_credits;
  283. unsigned int dma_credits;
  284. struct tb_bandwidth_group *group;
  285. struct list_head group_list;
  286. unsigned int max_bw;
  287. bool redrive;
  288. };
  289. /**
  290. * struct usb4_port - USB4 port device
  291. * @dev: Device for the port
  292. * @port: Pointer to the lane 0 adapter
  293. * @can_offline: Does the port have necessary platform support to moved
  294. * it into offline mode and back
  295. * @offline: The port is currently in offline mode
  296. * @margining: Pointer to margining structure if enabled
  297. */
  298. struct usb4_port {
  299. struct device dev;
  300. struct tb_port *port;
  301. bool can_offline;
  302. bool offline;
  303. #ifdef CONFIG_USB4_DEBUGFS_MARGINING
  304. struct tb_margining *margining;
  305. #endif
  306. };
  307. /**
  308. * tb_retimer: Thunderbolt retimer
  309. * @dev: Device for the retimer
  310. * @tb: Pointer to the domain the retimer belongs to
  311. * @index: Retimer index facing the router USB4 port
  312. * @vendor: Vendor ID of the retimer
  313. * @device: Device ID of the retimer
  314. * @port: Pointer to the lane 0 adapter
  315. * @nvm: Pointer to the NVM if the retimer has one (%NULL otherwise)
  316. * @no_nvm_upgrade: Prevent NVM upgrade of this retimer
  317. * @auth_status: Status of last NVM authentication
  318. * @margining: Pointer to margining structure if enabled
  319. */
  320. struct tb_retimer {
  321. struct device dev;
  322. struct tb *tb;
  323. u8 index;
  324. u32 vendor;
  325. u32 device;
  326. struct tb_port *port;
  327. struct tb_nvm *nvm;
  328. bool no_nvm_upgrade;
  329. u32 auth_status;
  330. #ifdef CONFIG_USB4_DEBUGFS_MARGINING
  331. struct tb_margining *margining;
  332. #endif
  333. };
  334. /**
  335. * struct tb_path_hop - routing information for a tb_path
  336. * @in_port: Ingress port of a switch
  337. * @out_port: Egress port of a switch where the packet is routed out
  338. * (must be on the same switch than @in_port)
  339. * @in_hop_index: HopID where the path configuration entry is placed in
  340. * the path config space of @in_port.
  341. * @in_counter_index: Used counter index (not used in the driver
  342. * currently, %-1 to disable)
  343. * @next_hop_index: HopID of the packet when it is routed out from @out_port
  344. * @initial_credits: Number of initial flow control credits allocated for
  345. * the path
  346. * @nfc_credits: Number of non-flow controlled buffers allocated for the
  347. * @in_port.
  348. * @pm_support: Set path PM packet support bit to 1 (for USB4 v2 routers)
  349. *
  350. * Hop configuration is always done on the IN port of a switch.
  351. * in_port and out_port have to be on the same switch. Packets arriving on
  352. * in_port with "hop" = in_hop_index will get routed to through out_port. The
  353. * next hop to take (on out_port->remote) is determined by
  354. * next_hop_index. When routing packet to another switch (out->remote is
  355. * set) the @next_hop_index must match the @in_hop_index of that next
  356. * hop to make routing possible.
  357. *
  358. * in_counter_index is the index of a counter (in TB_CFG_COUNTERS) on the in
  359. * port.
  360. */
  361. struct tb_path_hop {
  362. struct tb_port *in_port;
  363. struct tb_port *out_port;
  364. int in_hop_index;
  365. int in_counter_index;
  366. int next_hop_index;
  367. unsigned int initial_credits;
  368. unsigned int nfc_credits;
  369. bool pm_support;
  370. };
  371. /**
  372. * enum tb_path_port - path options mask
  373. * @TB_PATH_NONE: Do not activate on any hop on path
  374. * @TB_PATH_SOURCE: Activate on the first hop (out of src)
  375. * @TB_PATH_INTERNAL: Activate on the intermediate hops (not the first/last)
  376. * @TB_PATH_DESTINATION: Activate on the last hop (into dst)
  377. * @TB_PATH_ALL: Activate on all hops on the path
  378. */
  379. enum tb_path_port {
  380. TB_PATH_NONE = 0,
  381. TB_PATH_SOURCE = 1,
  382. TB_PATH_INTERNAL = 2,
  383. TB_PATH_DESTINATION = 4,
  384. TB_PATH_ALL = 7,
  385. };
  386. /**
  387. * struct tb_path - a unidirectional path between two ports
  388. * @tb: Pointer to the domain structure
  389. * @name: Name of the path (used for debugging)
  390. * @ingress_shared_buffer: Shared buffering used for ingress ports on the path
  391. * @egress_shared_buffer: Shared buffering used for egress ports on the path
  392. * @ingress_fc_enable: Flow control for ingress ports on the path
  393. * @egress_fc_enable: Flow control for egress ports on the path
  394. * @priority: Priority group if the path
  395. * @weight: Weight of the path inside the priority group
  396. * @drop_packages: Drop packages from queue tail or head
  397. * @activated: Is the path active
  398. * @clear_fc: Clear all flow control from the path config space entries
  399. * when deactivating this path
  400. * @hops: Path hops
  401. * @path_length: How many hops the path uses
  402. * @alloc_hopid: Does this path consume port HopID
  403. *
  404. * A path consists of a number of hops (see &struct tb_path_hop). To
  405. * establish a PCIe tunnel two paths have to be created between the two
  406. * PCIe ports.
  407. */
  408. struct tb_path {
  409. struct tb *tb;
  410. const char *name;
  411. enum tb_path_port ingress_shared_buffer;
  412. enum tb_path_port egress_shared_buffer;
  413. enum tb_path_port ingress_fc_enable;
  414. enum tb_path_port egress_fc_enable;
  415. unsigned int priority:3;
  416. int weight:4;
  417. bool drop_packages;
  418. bool activated;
  419. bool clear_fc;
  420. struct tb_path_hop *hops;
  421. int path_length;
  422. bool alloc_hopid;
  423. };
  424. /* HopIDs 0-7 are reserved by the Thunderbolt protocol */
  425. #define TB_PATH_MIN_HOPID 8
  426. /*
  427. * Support paths from the farthest (depth 6) router to the host and back
  428. * to the same level (not necessarily to the same router).
  429. */
  430. #define TB_PATH_MAX_HOPS (7 * 2)
  431. /* Possible wake types */
  432. #define TB_WAKE_ON_CONNECT BIT(0)
  433. #define TB_WAKE_ON_DISCONNECT BIT(1)
  434. #define TB_WAKE_ON_USB4 BIT(2)
  435. #define TB_WAKE_ON_USB3 BIT(3)
  436. #define TB_WAKE_ON_PCIE BIT(4)
  437. #define TB_WAKE_ON_DP BIT(5)
  438. /* CL states */
  439. #define TB_CL0S BIT(0)
  440. #define TB_CL1 BIT(1)
  441. #define TB_CL2 BIT(2)
  442. /**
  443. * struct tb_cm_ops - Connection manager specific operations vector
  444. * @driver_ready: Called right after control channel is started. Used by
  445. * ICM to send driver ready message to the firmware.
  446. * @start: Starts the domain
  447. * @stop: Stops the domain
  448. * @deinit: Perform any cleanup after the domain is stopped but before
  449. * it is unregistered. Called without @tb->lock taken. Optional.
  450. * @suspend_noirq: Connection manager specific suspend_noirq
  451. * @resume_noirq: Connection manager specific resume_noirq
  452. * @suspend: Connection manager specific suspend
  453. * @freeze_noirq: Connection manager specific freeze_noirq
  454. * @thaw_noirq: Connection manager specific thaw_noirq
  455. * @complete: Connection manager specific complete
  456. * @runtime_suspend: Connection manager specific runtime_suspend
  457. * @runtime_resume: Connection manager specific runtime_resume
  458. * @runtime_suspend_switch: Runtime suspend a switch
  459. * @runtime_resume_switch: Runtime resume a switch
  460. * @handle_event: Handle thunderbolt event
  461. * @get_boot_acl: Get boot ACL list
  462. * @set_boot_acl: Set boot ACL list
  463. * @disapprove_switch: Disapprove switch (disconnect PCIe tunnel)
  464. * @approve_switch: Approve switch
  465. * @add_switch_key: Add key to switch
  466. * @challenge_switch_key: Challenge switch using key
  467. * @disconnect_pcie_paths: Disconnects PCIe paths before NVM update
  468. * @approve_xdomain_paths: Approve (establish) XDomain DMA paths
  469. * @disconnect_xdomain_paths: Disconnect XDomain DMA paths
  470. * @usb4_switch_op: Optional proxy for USB4 router operations. If set
  471. * this will be called whenever USB4 router operation is
  472. * performed. If this returns %-EOPNOTSUPP then the
  473. * native USB4 router operation is called.
  474. * @usb4_switch_nvm_authenticate_status: Optional callback that the CM
  475. * implementation can be used to
  476. * return status of USB4 NVM_AUTH
  477. * router operation.
  478. */
  479. struct tb_cm_ops {
  480. int (*driver_ready)(struct tb *tb);
  481. int (*start)(struct tb *tb, bool reset);
  482. void (*stop)(struct tb *tb);
  483. void (*deinit)(struct tb *tb);
  484. int (*suspend_noirq)(struct tb *tb);
  485. int (*resume_noirq)(struct tb *tb);
  486. int (*suspend)(struct tb *tb);
  487. int (*freeze_noirq)(struct tb *tb);
  488. int (*thaw_noirq)(struct tb *tb);
  489. void (*complete)(struct tb *tb);
  490. int (*runtime_suspend)(struct tb *tb);
  491. int (*runtime_resume)(struct tb *tb);
  492. int (*runtime_suspend_switch)(struct tb_switch *sw);
  493. int (*runtime_resume_switch)(struct tb_switch *sw);
  494. void (*handle_event)(struct tb *tb, enum tb_cfg_pkg_type,
  495. const void *buf, size_t size);
  496. int (*get_boot_acl)(struct tb *tb, uuid_t *uuids, size_t nuuids);
  497. int (*set_boot_acl)(struct tb *tb, const uuid_t *uuids, size_t nuuids);
  498. int (*disapprove_switch)(struct tb *tb, struct tb_switch *sw);
  499. int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
  500. int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
  501. int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
  502. const u8 *challenge, u8 *response);
  503. int (*disconnect_pcie_paths)(struct tb *tb);
  504. int (*approve_xdomain_paths)(struct tb *tb, struct tb_xdomain *xd,
  505. int transmit_path, int transmit_ring,
  506. int receive_path, int receive_ring);
  507. int (*disconnect_xdomain_paths)(struct tb *tb, struct tb_xdomain *xd,
  508. int transmit_path, int transmit_ring,
  509. int receive_path, int receive_ring);
  510. int (*usb4_switch_op)(struct tb_switch *sw, u16 opcode, u32 *metadata,
  511. u8 *status, const void *tx_data, size_t tx_data_len,
  512. void *rx_data, size_t rx_data_len);
  513. int (*usb4_switch_nvm_authenticate_status)(struct tb_switch *sw,
  514. u32 *status);
  515. };
  516. static inline void *tb_priv(struct tb *tb)
  517. {
  518. return (void *)tb->privdata;
  519. }
  520. #define TB_AUTOSUSPEND_DELAY 15000 /* ms */
  521. /* helper functions & macros */
  522. /**
  523. * tb_upstream_port() - return the upstream port of a switch
  524. *
  525. * Every switch has an upstream port (for the root switch it is the NHI).
  526. *
  527. * During switch alloc/init tb_upstream_port()->remote may be NULL, even for
  528. * non root switches (on the NHI port remote is always NULL).
  529. *
  530. * Return: Returns the upstream port of the switch.
  531. */
  532. static inline struct tb_port *tb_upstream_port(struct tb_switch *sw)
  533. {
  534. return &sw->ports[sw->config.upstream_port_number];
  535. }
  536. /**
  537. * tb_is_upstream_port() - Is the port upstream facing
  538. * @port: Port to check
  539. *
  540. * Returns true if @port is upstream facing port. In case of dual link
  541. * ports both return true.
  542. */
  543. static inline bool tb_is_upstream_port(const struct tb_port *port)
  544. {
  545. const struct tb_port *upstream_port = tb_upstream_port(port->sw);
  546. return port == upstream_port || port->dual_link_port == upstream_port;
  547. }
  548. static inline u64 tb_route(const struct tb_switch *sw)
  549. {
  550. return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo;
  551. }
  552. static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw)
  553. {
  554. u8 port;
  555. port = route >> (sw->config.depth * 8);
  556. if (WARN_ON(port > sw->config.max_port_number))
  557. return NULL;
  558. return &sw->ports[port];
  559. }
  560. static inline const char *tb_width_name(enum tb_link_width width)
  561. {
  562. switch (width) {
  563. case TB_LINK_WIDTH_SINGLE:
  564. return "symmetric, single lane";
  565. case TB_LINK_WIDTH_DUAL:
  566. return "symmetric, dual lanes";
  567. case TB_LINK_WIDTH_ASYM_TX:
  568. return "asymmetric, 3 transmitters, 1 receiver";
  569. case TB_LINK_WIDTH_ASYM_RX:
  570. return "asymmetric, 3 receivers, 1 transmitter";
  571. default:
  572. return "unknown";
  573. }
  574. }
  575. /**
  576. * tb_port_has_remote() - Does the port have switch connected downstream
  577. * @port: Port to check
  578. *
  579. * Returns true only when the port is primary port and has remote set.
  580. */
  581. static inline bool tb_port_has_remote(const struct tb_port *port)
  582. {
  583. if (tb_is_upstream_port(port))
  584. return false;
  585. if (!port->remote)
  586. return false;
  587. if (port->dual_link_port && port->link_nr)
  588. return false;
  589. return true;
  590. }
  591. static inline bool tb_port_is_null(const struct tb_port *port)
  592. {
  593. return port && port->port && port->config.type == TB_TYPE_PORT;
  594. }
  595. static inline bool tb_port_is_nhi(const struct tb_port *port)
  596. {
  597. return port && port->config.type == TB_TYPE_NHI;
  598. }
  599. static inline bool tb_port_is_pcie_down(const struct tb_port *port)
  600. {
  601. return port && port->config.type == TB_TYPE_PCIE_DOWN;
  602. }
  603. static inline bool tb_port_is_pcie_up(const struct tb_port *port)
  604. {
  605. return port && port->config.type == TB_TYPE_PCIE_UP;
  606. }
  607. static inline bool tb_port_is_dpin(const struct tb_port *port)
  608. {
  609. return port && port->config.type == TB_TYPE_DP_HDMI_IN;
  610. }
  611. static inline bool tb_port_is_dpout(const struct tb_port *port)
  612. {
  613. return port && port->config.type == TB_TYPE_DP_HDMI_OUT;
  614. }
  615. static inline bool tb_port_is_usb3_down(const struct tb_port *port)
  616. {
  617. return port && port->config.type == TB_TYPE_USB3_DOWN;
  618. }
  619. static inline bool tb_port_is_usb3_up(const struct tb_port *port)
  620. {
  621. return port && port->config.type == TB_TYPE_USB3_UP;
  622. }
  623. static inline int tb_sw_read(struct tb_switch *sw, void *buffer,
  624. enum tb_cfg_space space, u32 offset, u32 length)
  625. {
  626. if (sw->is_unplugged)
  627. return -ENODEV;
  628. return tb_cfg_read(sw->tb->ctl,
  629. buffer,
  630. tb_route(sw),
  631. 0,
  632. space,
  633. offset,
  634. length);
  635. }
  636. static inline int tb_sw_write(struct tb_switch *sw, const void *buffer,
  637. enum tb_cfg_space space, u32 offset, u32 length)
  638. {
  639. if (sw->is_unplugged)
  640. return -ENODEV;
  641. return tb_cfg_write(sw->tb->ctl,
  642. buffer,
  643. tb_route(sw),
  644. 0,
  645. space,
  646. offset,
  647. length);
  648. }
  649. static inline int tb_port_read(struct tb_port *port, void *buffer,
  650. enum tb_cfg_space space, u32 offset, u32 length)
  651. {
  652. if (port->sw->is_unplugged)
  653. return -ENODEV;
  654. return tb_cfg_read(port->sw->tb->ctl,
  655. buffer,
  656. tb_route(port->sw),
  657. port->port,
  658. space,
  659. offset,
  660. length);
  661. }
  662. static inline int tb_port_write(struct tb_port *port, const void *buffer,
  663. enum tb_cfg_space space, u32 offset, u32 length)
  664. {
  665. if (port->sw->is_unplugged)
  666. return -ENODEV;
  667. return tb_cfg_write(port->sw->tb->ctl,
  668. buffer,
  669. tb_route(port->sw),
  670. port->port,
  671. space,
  672. offset,
  673. length);
  674. }
  675. #define tb_err(tb, fmt, arg...) dev_err(&(tb)->nhi->pdev->dev, fmt, ## arg)
  676. #define tb_WARN(tb, fmt, arg...) dev_WARN(&(tb)->nhi->pdev->dev, fmt, ## arg)
  677. #define tb_warn(tb, fmt, arg...) dev_warn(&(tb)->nhi->pdev->dev, fmt, ## arg)
  678. #define tb_info(tb, fmt, arg...) dev_info(&(tb)->nhi->pdev->dev, fmt, ## arg)
  679. #define tb_dbg(tb, fmt, arg...) dev_dbg(&(tb)->nhi->pdev->dev, fmt, ## arg)
  680. #define __TB_SW_PRINT(level, sw, fmt, arg...) \
  681. do { \
  682. const struct tb_switch *__sw = (sw); \
  683. level(__sw->tb, "%llx: " fmt, \
  684. tb_route(__sw), ## arg); \
  685. } while (0)
  686. #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg)
  687. #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg)
  688. #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg)
  689. #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg)
  690. #define __TB_PORT_PRINT(level, _port, fmt, arg...) \
  691. do { \
  692. const struct tb_port *__port = (_port); \
  693. level(__port->sw->tb, "%llx:%u: " fmt, \
  694. tb_route(__port->sw), __port->port, ## arg); \
  695. } while (0)
  696. #define tb_port_WARN(port, fmt, arg...) \
  697. __TB_PORT_PRINT(tb_WARN, port, fmt, ##arg)
  698. #define tb_port_warn(port, fmt, arg...) \
  699. __TB_PORT_PRINT(tb_warn, port, fmt, ##arg)
  700. #define tb_port_info(port, fmt, arg...) \
  701. __TB_PORT_PRINT(tb_info, port, fmt, ##arg)
  702. #define tb_port_dbg(port, fmt, arg...) \
  703. __TB_PORT_PRINT(tb_dbg, port, fmt, ##arg)
  704. struct tb *icm_probe(struct tb_nhi *nhi);
  705. struct tb *tb_probe(struct tb_nhi *nhi);
  706. extern const struct device_type tb_domain_type;
  707. extern const struct device_type tb_retimer_type;
  708. extern const struct device_type tb_switch_type;
  709. extern const struct device_type usb4_port_device_type;
  710. int tb_domain_init(void);
  711. void tb_domain_exit(void);
  712. int tb_xdomain_init(void);
  713. void tb_xdomain_exit(void);
  714. struct tb *tb_domain_alloc(struct tb_nhi *nhi, int timeout_msec, size_t privsize);
  715. int tb_domain_add(struct tb *tb, bool reset);
  716. void tb_domain_remove(struct tb *tb);
  717. int tb_domain_suspend_noirq(struct tb *tb);
  718. int tb_domain_resume_noirq(struct tb *tb);
  719. int tb_domain_suspend(struct tb *tb);
  720. int tb_domain_freeze_noirq(struct tb *tb);
  721. int tb_domain_thaw_noirq(struct tb *tb);
  722. void tb_domain_complete(struct tb *tb);
  723. int tb_domain_runtime_suspend(struct tb *tb);
  724. int tb_domain_runtime_resume(struct tb *tb);
  725. int tb_domain_disapprove_switch(struct tb *tb, struct tb_switch *sw);
  726. int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
  727. int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
  728. int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
  729. int tb_domain_disconnect_pcie_paths(struct tb *tb);
  730. int tb_domain_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
  731. int transmit_path, int transmit_ring,
  732. int receive_path, int receive_ring);
  733. int tb_domain_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
  734. int transmit_path, int transmit_ring,
  735. int receive_path, int receive_ring);
  736. int tb_domain_disconnect_all_paths(struct tb *tb);
  737. static inline struct tb *tb_domain_get(struct tb *tb)
  738. {
  739. if (tb)
  740. get_device(&tb->dev);
  741. return tb;
  742. }
  743. static inline void tb_domain_put(struct tb *tb)
  744. {
  745. put_device(&tb->dev);
  746. }
  747. struct tb_nvm *tb_nvm_alloc(struct device *dev);
  748. int tb_nvm_read_version(struct tb_nvm *nvm);
  749. int tb_nvm_validate(struct tb_nvm *nvm);
  750. int tb_nvm_write_headers(struct tb_nvm *nvm);
  751. int tb_nvm_add_active(struct tb_nvm *nvm, nvmem_reg_read_t reg_read);
  752. int tb_nvm_write_buf(struct tb_nvm *nvm, unsigned int offset, void *val,
  753. size_t bytes);
  754. int tb_nvm_add_non_active(struct tb_nvm *nvm, nvmem_reg_write_t reg_write);
  755. void tb_nvm_free(struct tb_nvm *nvm);
  756. void tb_nvm_exit(void);
  757. typedef int (*read_block_fn)(void *, unsigned int, void *, size_t);
  758. typedef int (*write_block_fn)(void *, unsigned int, const void *, size_t);
  759. int tb_nvm_read_data(unsigned int address, void *buf, size_t size,
  760. unsigned int retries, read_block_fn read_block,
  761. void *read_block_data);
  762. int tb_nvm_write_data(unsigned int address, const void *buf, size_t size,
  763. unsigned int retries, write_block_fn write_next_block,
  764. void *write_block_data);
  765. int tb_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
  766. size_t size);
  767. struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,
  768. u64 route);
  769. struct tb_switch *tb_switch_alloc_safe_mode(struct tb *tb,
  770. struct device *parent, u64 route);
  771. int tb_switch_configure(struct tb_switch *sw);
  772. int tb_switch_configuration_valid(struct tb_switch *sw);
  773. int tb_switch_add(struct tb_switch *sw);
  774. void tb_switch_remove(struct tb_switch *sw);
  775. void tb_switch_suspend(struct tb_switch *sw, bool runtime);
  776. int tb_switch_resume(struct tb_switch *sw, bool runtime);
  777. int tb_switch_reset(struct tb_switch *sw);
  778. int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit,
  779. u32 value, int timeout_msec);
  780. void tb_sw_set_unplugged(struct tb_switch *sw);
  781. struct tb_port *tb_switch_find_port(struct tb_switch *sw,
  782. enum tb_port_type type);
  783. struct tb_switch *tb_switch_find_by_link_depth(struct tb *tb, u8 link,
  784. u8 depth);
  785. struct tb_switch *tb_switch_find_by_uuid(struct tb *tb, const uuid_t *uuid);
  786. struct tb_switch *tb_switch_find_by_route(struct tb *tb, u64 route);
  787. /**
  788. * tb_switch_for_each_port() - Iterate over each switch port
  789. * @sw: Switch whose ports to iterate
  790. * @p: Port used as iterator
  791. *
  792. * Iterates over each switch port skipping the control port (port %0).
  793. */
  794. #define tb_switch_for_each_port(sw, p) \
  795. for ((p) = &(sw)->ports[1]; \
  796. (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
  797. static inline struct tb_switch *tb_switch_get(struct tb_switch *sw)
  798. {
  799. if (sw)
  800. get_device(&sw->dev);
  801. return sw;
  802. }
  803. static inline void tb_switch_put(struct tb_switch *sw)
  804. {
  805. put_device(&sw->dev);
  806. }
  807. static inline bool tb_is_switch(const struct device *dev)
  808. {
  809. return dev->type == &tb_switch_type;
  810. }
  811. static inline struct tb_switch *tb_to_switch(const struct device *dev)
  812. {
  813. if (tb_is_switch(dev))
  814. return container_of(dev, struct tb_switch, dev);
  815. return NULL;
  816. }
  817. static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw)
  818. {
  819. return tb_to_switch(sw->dev.parent);
  820. }
  821. /**
  822. * tb_switch_downstream_port() - Return downstream facing port of parent router
  823. * @sw: Device router pointer
  824. *
  825. * Only call for device routers. Returns the downstream facing port of
  826. * the parent router.
  827. */
  828. static inline struct tb_port *tb_switch_downstream_port(struct tb_switch *sw)
  829. {
  830. if (WARN_ON(!tb_route(sw)))
  831. return NULL;
  832. return tb_port_at(tb_route(sw), tb_switch_parent(sw));
  833. }
  834. /**
  835. * tb_switch_depth() - Returns depth of the connected router
  836. * @sw: Router
  837. */
  838. static inline int tb_switch_depth(const struct tb_switch *sw)
  839. {
  840. return sw->config.depth;
  841. }
  842. static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw)
  843. {
  844. return sw->config.vendor_id == PCI_VENDOR_ID_INTEL &&
  845. sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE;
  846. }
  847. static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw)
  848. {
  849. return sw->config.vendor_id == PCI_VENDOR_ID_INTEL &&
  850. sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE;
  851. }
  852. static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw)
  853. {
  854. if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
  855. switch (sw->config.device_id) {
  856. case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_2C:
  857. case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C:
  858. return true;
  859. }
  860. }
  861. return false;
  862. }
  863. static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw)
  864. {
  865. if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
  866. switch (sw->config.device_id) {
  867. case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE:
  868. case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE:
  869. return true;
  870. }
  871. }
  872. return false;
  873. }
  874. static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw)
  875. {
  876. if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
  877. switch (sw->config.device_id) {
  878. case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_BRIDGE:
  879. case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_BRIDGE:
  880. case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_LP_BRIDGE:
  881. case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_BRIDGE:
  882. case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_BRIDGE:
  883. return true;
  884. }
  885. }
  886. return false;
  887. }
  888. static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw)
  889. {
  890. if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
  891. switch (sw->config.device_id) {
  892. case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_BRIDGE:
  893. case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_BRIDGE:
  894. case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_BRIDGE:
  895. return true;
  896. }
  897. }
  898. return false;
  899. }
  900. static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw)
  901. {
  902. if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
  903. switch (sw->config.device_id) {
  904. case PCI_DEVICE_ID_INTEL_TGL_NHI0:
  905. case PCI_DEVICE_ID_INTEL_TGL_NHI1:
  906. case PCI_DEVICE_ID_INTEL_TGL_H_NHI0:
  907. case PCI_DEVICE_ID_INTEL_TGL_H_NHI1:
  908. return true;
  909. }
  910. }
  911. return false;
  912. }
  913. /**
  914. * tb_switch_is_icm() - Is the switch handled by ICM firmware
  915. * @sw: Switch to check
  916. *
  917. * In case there is a need to differentiate whether ICM firmware or SW CM
  918. * is handling @sw this function can be called. It is valid to call this
  919. * after tb_switch_alloc() and tb_switch_configure() has been called
  920. * (latter only for SW CM case).
  921. */
  922. static inline bool tb_switch_is_icm(const struct tb_switch *sw)
  923. {
  924. return !sw->config.enabled;
  925. }
  926. int tb_switch_set_link_width(struct tb_switch *sw, enum tb_link_width width);
  927. int tb_switch_configure_link(struct tb_switch *sw);
  928. void tb_switch_unconfigure_link(struct tb_switch *sw);
  929. bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
  930. int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
  931. void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
  932. int tb_switch_tmu_init(struct tb_switch *sw);
  933. int tb_switch_tmu_post_time(struct tb_switch *sw);
  934. int tb_switch_tmu_disable(struct tb_switch *sw);
  935. int tb_switch_tmu_enable(struct tb_switch *sw);
  936. int tb_switch_tmu_configure(struct tb_switch *sw, enum tb_switch_tmu_mode mode);
  937. /**
  938. * tb_switch_tmu_is_configured() - Is given TMU mode configured
  939. * @sw: Router whose mode to check
  940. * @mode: Mode to check
  941. *
  942. * Checks if given router TMU mode is configured to @mode. Note the
  943. * router TMU might not be enabled to this mode.
  944. */
  945. static inline bool tb_switch_tmu_is_configured(const struct tb_switch *sw,
  946. enum tb_switch_tmu_mode mode)
  947. {
  948. return sw->tmu.mode_request == mode;
  949. }
  950. /**
  951. * tb_switch_tmu_is_enabled() - Checks if the specified TMU mode is enabled
  952. * @sw: Router whose TMU mode to check
  953. *
  954. * Return true if hardware TMU configuration matches the requested
  955. * configuration (and is not %TB_SWITCH_TMU_MODE_OFF).
  956. */
  957. static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw)
  958. {
  959. return sw->tmu.mode != TB_SWITCH_TMU_MODE_OFF &&
  960. sw->tmu.mode == sw->tmu.mode_request;
  961. }
  962. bool tb_port_clx_is_enabled(struct tb_port *port, unsigned int clx);
  963. int tb_switch_clx_init(struct tb_switch *sw);
  964. int tb_switch_clx_enable(struct tb_switch *sw, unsigned int clx);
  965. int tb_switch_clx_disable(struct tb_switch *sw);
  966. /**
  967. * tb_switch_clx_is_enabled() - Checks if the CLx is enabled
  968. * @sw: Router to check for the CLx
  969. * @clx: The CLx states to check for
  970. *
  971. * Checks if the specified CLx is enabled on the router upstream link.
  972. * Returns true if any of the given states is enabled.
  973. *
  974. * Not applicable for a host router.
  975. */
  976. static inline bool tb_switch_clx_is_enabled(const struct tb_switch *sw,
  977. unsigned int clx)
  978. {
  979. return sw->clx & clx;
  980. }
  981. int tb_switch_pcie_l1_enable(struct tb_switch *sw);
  982. int tb_switch_xhci_connect(struct tb_switch *sw);
  983. void tb_switch_xhci_disconnect(struct tb_switch *sw);
  984. int tb_port_state(struct tb_port *port);
  985. int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged);
  986. int tb_port_add_nfc_credits(struct tb_port *port, int credits);
  987. int tb_port_clear_counter(struct tb_port *port, int counter);
  988. int tb_port_unlock(struct tb_port *port);
  989. int tb_port_enable(struct tb_port *port);
  990. int tb_port_disable(struct tb_port *port);
  991. int tb_port_alloc_in_hopid(struct tb_port *port, int hopid, int max_hopid);
  992. void tb_port_release_in_hopid(struct tb_port *port, int hopid);
  993. int tb_port_alloc_out_hopid(struct tb_port *port, int hopid, int max_hopid);
  994. void tb_port_release_out_hopid(struct tb_port *port, int hopid);
  995. struct tb_port *tb_next_port_on_path(struct tb_port *start, struct tb_port *end,
  996. struct tb_port *prev);
  997. /**
  998. * tb_port_path_direction_downstream() - Checks if path directed downstream
  999. * @src: Source adapter
  1000. * @dst: Destination adapter
  1001. *
  1002. * Returns %true only if the specified path from source adapter (@src)
  1003. * to destination adapter (@dst) is directed downstream.
  1004. */
  1005. static inline bool
  1006. tb_port_path_direction_downstream(const struct tb_port *src,
  1007. const struct tb_port *dst)
  1008. {
  1009. return src->sw->config.depth < dst->sw->config.depth;
  1010. }
  1011. static inline bool tb_port_use_credit_allocation(const struct tb_port *port)
  1012. {
  1013. return tb_port_is_null(port) && port->sw->credit_allocation;
  1014. }
  1015. /**
  1016. * tb_for_each_port_on_path() - Iterate over each port on path
  1017. * @src: Source port
  1018. * @dst: Destination port
  1019. * @p: Port used as iterator
  1020. *
  1021. * Walks over each port on path from @src to @dst.
  1022. */
  1023. #define tb_for_each_port_on_path(src, dst, p) \
  1024. for ((p) = tb_next_port_on_path((src), (dst), NULL); (p); \
  1025. (p) = tb_next_port_on_path((src), (dst), (p)))
  1026. /**
  1027. * tb_for_each_upstream_port_on_path() - Iterate over each upstreamm port on path
  1028. * @src: Source port
  1029. * @dst: Destination port
  1030. * @p: Port used as iterator
  1031. *
  1032. * Walks over each upstream lane adapter on path from @src to @dst.
  1033. */
  1034. #define tb_for_each_upstream_port_on_path(src, dst, p) \
  1035. for ((p) = tb_next_port_on_path((src), (dst), NULL); (p); \
  1036. (p) = tb_next_port_on_path((src), (dst), (p))) \
  1037. if (!tb_port_is_null((p)) || !tb_is_upstream_port((p))) {\
  1038. continue; \
  1039. } else
  1040. int tb_port_get_link_speed(struct tb_port *port);
  1041. int tb_port_get_link_generation(struct tb_port *port);
  1042. int tb_port_get_link_width(struct tb_port *port);
  1043. bool tb_port_width_supported(struct tb_port *port, unsigned int width);
  1044. int tb_port_set_link_width(struct tb_port *port, enum tb_link_width width);
  1045. int tb_port_lane_bonding_enable(struct tb_port *port);
  1046. void tb_port_lane_bonding_disable(struct tb_port *port);
  1047. int tb_port_wait_for_link_width(struct tb_port *port, unsigned int width,
  1048. int timeout_msec);
  1049. int tb_port_update_credits(struct tb_port *port);
  1050. int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
  1051. int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
  1052. int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
  1053. int tb_port_find_cap(struct tb_port *port, enum tb_port_cap cap);
  1054. int tb_port_next_cap(struct tb_port *port, unsigned int offset);
  1055. bool tb_port_is_enabled(struct tb_port *port);
  1056. bool tb_usb3_port_is_enabled(struct tb_port *port);
  1057. int tb_usb3_port_enable(struct tb_port *port, bool enable);
  1058. bool tb_pci_port_is_enabled(struct tb_port *port);
  1059. int tb_pci_port_enable(struct tb_port *port, bool enable);
  1060. int tb_dp_port_hpd_is_active(struct tb_port *port);
  1061. int tb_dp_port_hpd_clear(struct tb_port *port);
  1062. int tb_dp_port_set_hops(struct tb_port *port, unsigned int video,
  1063. unsigned int aux_tx, unsigned int aux_rx);
  1064. bool tb_dp_port_is_enabled(struct tb_port *port);
  1065. int tb_dp_port_enable(struct tb_port *port, bool enable);
  1066. struct tb_path *tb_path_discover(struct tb_port *src, int src_hopid,
  1067. struct tb_port *dst, int dst_hopid,
  1068. struct tb_port **last, const char *name,
  1069. bool alloc_hopid);
  1070. struct tb_path *tb_path_alloc(struct tb *tb, struct tb_port *src, int src_hopid,
  1071. struct tb_port *dst, int dst_hopid, int link_nr,
  1072. const char *name);
  1073. void tb_path_free(struct tb_path *path);
  1074. int tb_path_activate(struct tb_path *path);
  1075. void tb_path_deactivate(struct tb_path *path);
  1076. int tb_path_deactivate_hop(struct tb_port *port, int hop_index);
  1077. bool tb_path_is_invalid(struct tb_path *path);
  1078. bool tb_path_port_on_path(const struct tb_path *path,
  1079. const struct tb_port *port);
  1080. /**
  1081. * tb_path_for_each_hop() - Iterate over each hop on path
  1082. * @path: Path whose hops to iterate
  1083. * @hop: Hop used as iterator
  1084. *
  1085. * Iterates over each hop on path.
  1086. */
  1087. #define tb_path_for_each_hop(path, hop) \
  1088. for ((hop) = &(path)->hops[0]; \
  1089. (hop) <= &(path)->hops[(path)->path_length - 1]; (hop)++)
  1090. int tb_drom_read(struct tb_switch *sw);
  1091. int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
  1092. int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
  1093. int tb_lc_reset_port(struct tb_port *port);
  1094. int tb_lc_configure_port(struct tb_port *port);
  1095. void tb_lc_unconfigure_port(struct tb_port *port);
  1096. int tb_lc_configure_xdomain(struct tb_port *port);
  1097. void tb_lc_unconfigure_xdomain(struct tb_port *port);
  1098. int tb_lc_start_lane_initialization(struct tb_port *port);
  1099. bool tb_lc_is_clx_supported(struct tb_port *port);
  1100. bool tb_lc_is_usb_plugged(struct tb_port *port);
  1101. bool tb_lc_is_xhci_connected(struct tb_port *port);
  1102. int tb_lc_xhci_connect(struct tb_port *port);
  1103. void tb_lc_xhci_disconnect(struct tb_port *port);
  1104. int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
  1105. int tb_lc_set_sleep(struct tb_switch *sw);
  1106. bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
  1107. bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
  1108. int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
  1109. int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
  1110. int tb_lc_force_power(struct tb_switch *sw);
  1111. static inline int tb_route_length(u64 route)
  1112. {
  1113. return (fls64(route) + TB_ROUTE_SHIFT - 1) / TB_ROUTE_SHIFT;
  1114. }
  1115. /**
  1116. * tb_downstream_route() - get route to downstream switch
  1117. *
  1118. * Port must not be the upstream port (otherwise a loop is created).
  1119. *
  1120. * Return: Returns a route to the switch behind @port.
  1121. */
  1122. static inline u64 tb_downstream_route(struct tb_port *port)
  1123. {
  1124. return tb_route(port->sw)
  1125. | ((u64) port->port << (port->sw->config.depth * 8));
  1126. }
  1127. bool tb_is_xdomain_enabled(void);
  1128. bool tb_xdomain_handle_request(struct tb *tb, enum tb_cfg_pkg_type type,
  1129. const void *buf, size_t size);
  1130. struct tb_xdomain *tb_xdomain_alloc(struct tb *tb, struct device *parent,
  1131. u64 route, const uuid_t *local_uuid,
  1132. const uuid_t *remote_uuid);
  1133. void tb_xdomain_add(struct tb_xdomain *xd);
  1134. void tb_xdomain_remove(struct tb_xdomain *xd);
  1135. struct tb_xdomain *tb_xdomain_find_by_link_depth(struct tb *tb, u8 link,
  1136. u8 depth);
  1137. static inline struct tb_switch *tb_xdomain_parent(struct tb_xdomain *xd)
  1138. {
  1139. return tb_to_switch(xd->dev.parent);
  1140. }
  1141. /**
  1142. * tb_xdomain_downstream_port() - Return downstream facing port of parent router
  1143. * @xd: Xdomain pointer
  1144. *
  1145. * Returns the downstream port the XDomain is connected to.
  1146. */
  1147. static inline struct tb_port *tb_xdomain_downstream_port(struct tb_xdomain *xd)
  1148. {
  1149. return tb_port_at(xd->route, tb_xdomain_parent(xd));
  1150. }
  1151. int tb_retimer_nvm_read(struct tb_retimer *rt, unsigned int address, void *buf,
  1152. size_t size);
  1153. int tb_retimer_scan(struct tb_port *port, bool add);
  1154. void tb_retimer_remove_all(struct tb_port *port);
  1155. static inline bool tb_is_retimer(const struct device *dev)
  1156. {
  1157. return dev->type == &tb_retimer_type;
  1158. }
  1159. static inline struct tb_retimer *tb_to_retimer(struct device *dev)
  1160. {
  1161. if (tb_is_retimer(dev))
  1162. return container_of(dev, struct tb_retimer, dev);
  1163. return NULL;
  1164. }
  1165. /**
  1166. * usb4_switch_version() - Returns USB4 version of the router
  1167. * @sw: Router to check
  1168. *
  1169. * Returns major version of USB4 router (%1 for v1, %2 for v2 and so
  1170. * on). Can be called to pre-USB4 router too and in that case returns %0.
  1171. */
  1172. static inline unsigned int usb4_switch_version(const struct tb_switch *sw)
  1173. {
  1174. return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version);
  1175. }
  1176. /**
  1177. * tb_switch_is_usb4() - Is the switch USB4 compliant
  1178. * @sw: Switch to check
  1179. *
  1180. * Returns true if the @sw is USB4 compliant router, false otherwise.
  1181. */
  1182. static inline bool tb_switch_is_usb4(const struct tb_switch *sw)
  1183. {
  1184. return usb4_switch_version(sw) > 0;
  1185. }
  1186. void usb4_switch_check_wakes(struct tb_switch *sw);
  1187. int usb4_switch_setup(struct tb_switch *sw);
  1188. int usb4_switch_configuration_valid(struct tb_switch *sw);
  1189. int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
  1190. int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
  1191. size_t size);
  1192. bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
  1193. int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
  1194. int usb4_switch_set_sleep(struct tb_switch *sw);
  1195. int usb4_switch_nvm_sector_size(struct tb_switch *sw);
  1196. int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
  1197. size_t size);
  1198. int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address);
  1199. int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
  1200. const void *buf, size_t size);
  1201. int usb4_switch_nvm_authenticate(struct tb_switch *sw);
  1202. int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status);
  1203. int usb4_switch_credits_init(struct tb_switch *sw);
  1204. bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
  1205. int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
  1206. int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
  1207. struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
  1208. const struct tb_port *port);
  1209. struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
  1210. const struct tb_port *port);
  1211. int usb4_switch_add_ports(struct tb_switch *sw);
  1212. void usb4_switch_remove_ports(struct tb_switch *sw);
  1213. int usb4_port_unlock(struct tb_port *port);
  1214. int usb4_port_hotplug_enable(struct tb_port *port);
  1215. int usb4_port_reset(struct tb_port *port);
  1216. int usb4_port_configure(struct tb_port *port);
  1217. void usb4_port_unconfigure(struct tb_port *port);
  1218. int usb4_port_configure_xdomain(struct tb_port *port, struct tb_xdomain *xd);
  1219. void usb4_port_unconfigure_xdomain(struct tb_port *port);
  1220. int usb4_port_router_offline(struct tb_port *port);
  1221. int usb4_port_router_online(struct tb_port *port);
  1222. int usb4_port_enumerate_retimers(struct tb_port *port);
  1223. bool usb4_port_clx_supported(struct tb_port *port);
  1224. bool usb4_port_asym_supported(struct tb_port *port);
  1225. int usb4_port_asym_set_link_width(struct tb_port *port, enum tb_link_width width);
  1226. int usb4_port_asym_start(struct tb_port *port);
  1227. /**
  1228. * enum tb_sb_target - Sideband transaction target
  1229. * @USB4_SB_TARGET_ROUTER: Target is the router itself
  1230. * @USB4_SB_TARGET_PARTNER: Target is partner
  1231. * @USB4_SB_TARGET_RETIMER: Target is retimer
  1232. */
  1233. enum usb4_sb_target {
  1234. USB4_SB_TARGET_ROUTER,
  1235. USB4_SB_TARGET_PARTNER,
  1236. USB4_SB_TARGET_RETIMER,
  1237. };
  1238. int usb4_port_sb_read(struct tb_port *port, enum usb4_sb_target target, u8 index,
  1239. u8 reg, void *buf, u8 size);
  1240. int usb4_port_sb_write(struct tb_port *port, enum usb4_sb_target target,
  1241. u8 index, u8 reg, const void *buf, u8 size);
  1242. /**
  1243. * enum usb4_margin_sw_error_counter - Software margining error counter operation
  1244. * @USB4_MARGIN_SW_ERROR_COUNTER_NOP: No change in counter setup
  1245. * @USB4_MARGIN_SW_ERROR_COUNTER_CLEAR: Set the error counter to 0, enable counter
  1246. * @USB4_MARGIN_SW_ERROR_COUNTER_START: Start counter, count from last value
  1247. * @USB4_MARGIN_SW_ERROR_COUNTER_STOP: Stop counter, do not clear value
  1248. */
  1249. enum usb4_margin_sw_error_counter {
  1250. USB4_MARGIN_SW_ERROR_COUNTER_NOP,
  1251. USB4_MARGIN_SW_ERROR_COUNTER_CLEAR,
  1252. USB4_MARGIN_SW_ERROR_COUNTER_START,
  1253. USB4_MARGIN_SW_ERROR_COUNTER_STOP,
  1254. };
  1255. /**
  1256. * struct usb4_port_margining_params - USB4 margining parameters
  1257. * @error_counter: Error counter operation for software margining
  1258. * @ber_level: Current BER level contour value
  1259. * @lanes: %0, %1 or %7 (all)
  1260. * @voltage_time_offset: Offset for voltage / time for software margining
  1261. * @optional_voltage_offset_range: Enable optional extended voltage range
  1262. * @right_high: %false if left/low margin test is performed, %true if right/high
  1263. * @time: %true if time margining is used instead of voltage
  1264. */
  1265. struct usb4_port_margining_params {
  1266. enum usb4_margin_sw_error_counter error_counter;
  1267. u32 ber_level;
  1268. u32 lanes;
  1269. u32 voltage_time_offset;
  1270. bool optional_voltage_offset_range;
  1271. bool right_high;
  1272. bool time;
  1273. };
  1274. int usb4_port_margining_caps(struct tb_port *port, enum usb4_sb_target target,
  1275. u8 index, u32 *caps);
  1276. int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
  1277. u8 index, const struct usb4_port_margining_params *params,
  1278. u32 *results);
  1279. int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target,
  1280. u8 index, const struct usb4_port_margining_params *params,
  1281. u32 *results);
  1282. int usb4_port_sw_margin_errors(struct tb_port *port, enum usb4_sb_target target,
  1283. u8 index, u32 *errors);
  1284. int usb4_port_retimer_set_inbound_sbtx(struct tb_port *port, u8 index);
  1285. int usb4_port_retimer_unset_inbound_sbtx(struct tb_port *port, u8 index);
  1286. int usb4_port_retimer_is_last(struct tb_port *port, u8 index);
  1287. int usb4_port_retimer_is_cable(struct tb_port *port, u8 index);
  1288. int usb4_port_retimer_nvm_sector_size(struct tb_port *port, u8 index);
  1289. int usb4_port_retimer_nvm_set_offset(struct tb_port *port, u8 index,
  1290. unsigned int address);
  1291. int usb4_port_retimer_nvm_write(struct tb_port *port, u8 index,
  1292. unsigned int address, const void *buf,
  1293. size_t size);
  1294. int usb4_port_retimer_nvm_authenticate(struct tb_port *port, u8 index);
  1295. int usb4_port_retimer_nvm_authenticate_status(struct tb_port *port, u8 index,
  1296. u32 *status);
  1297. int usb4_port_retimer_nvm_read(struct tb_port *port, u8 index,
  1298. unsigned int address, void *buf, size_t size);
  1299. int usb4_usb3_port_max_link_rate(struct tb_port *port);
  1300. int usb4_usb3_port_allocated_bandwidth(struct tb_port *port, int *upstream_bw,
  1301. int *downstream_bw);
  1302. int usb4_usb3_port_allocate_bandwidth(struct tb_port *port, int *upstream_bw,
  1303. int *downstream_bw);
  1304. int usb4_usb3_port_release_bandwidth(struct tb_port *port, int *upstream_bw,
  1305. int *downstream_bw);
  1306. int usb4_dp_port_set_cm_id(struct tb_port *port, int cm_id);
  1307. bool usb4_dp_port_bandwidth_mode_supported(struct tb_port *port);
  1308. bool usb4_dp_port_bandwidth_mode_enabled(struct tb_port *port);
  1309. int usb4_dp_port_set_cm_bandwidth_mode_supported(struct tb_port *port,
  1310. bool supported);
  1311. int usb4_dp_port_group_id(struct tb_port *port);
  1312. int usb4_dp_port_set_group_id(struct tb_port *port, int group_id);
  1313. int usb4_dp_port_nrd(struct tb_port *port, int *rate, int *lanes);
  1314. int usb4_dp_port_set_nrd(struct tb_port *port, int rate, int lanes);
  1315. int usb4_dp_port_granularity(struct tb_port *port);
  1316. int usb4_dp_port_set_granularity(struct tb_port *port, int granularity);
  1317. int usb4_dp_port_set_estimated_bandwidth(struct tb_port *port, int bw);
  1318. int usb4_dp_port_allocated_bandwidth(struct tb_port *port);
  1319. int usb4_dp_port_allocate_bandwidth(struct tb_port *port, int bw);
  1320. int usb4_dp_port_requested_bandwidth(struct tb_port *port);
  1321. int usb4_pci_port_set_ext_encapsulation(struct tb_port *port, bool enable);
  1322. static inline bool tb_is_usb4_port_device(const struct device *dev)
  1323. {
  1324. return dev->type == &usb4_port_device_type;
  1325. }
  1326. static inline struct usb4_port *tb_to_usb4_port_device(struct device *dev)
  1327. {
  1328. if (tb_is_usb4_port_device(dev))
  1329. return container_of(dev, struct usb4_port, dev);
  1330. return NULL;
  1331. }
  1332. struct usb4_port *usb4_port_device_add(struct tb_port *port);
  1333. void usb4_port_device_remove(struct usb4_port *usb4);
  1334. int usb4_port_device_resume(struct usb4_port *usb4);
  1335. static inline bool usb4_port_device_is_offline(const struct usb4_port *usb4)
  1336. {
  1337. return usb4->offline;
  1338. }
  1339. void tb_check_quirks(struct tb_switch *sw);
  1340. #ifdef CONFIG_ACPI
  1341. bool tb_acpi_add_links(struct tb_nhi *nhi);
  1342. bool tb_acpi_is_native(void);
  1343. bool tb_acpi_may_tunnel_usb3(void);
  1344. bool tb_acpi_may_tunnel_dp(void);
  1345. bool tb_acpi_may_tunnel_pcie(void);
  1346. bool tb_acpi_is_xdomain_allowed(void);
  1347. int tb_acpi_init(void);
  1348. void tb_acpi_exit(void);
  1349. int tb_acpi_power_on_retimers(struct tb_port *port);
  1350. int tb_acpi_power_off_retimers(struct tb_port *port);
  1351. #else
  1352. static inline bool tb_acpi_add_links(struct tb_nhi *nhi) { return false; }
  1353. static inline bool tb_acpi_is_native(void) { return true; }
  1354. static inline bool tb_acpi_may_tunnel_usb3(void) { return true; }
  1355. static inline bool tb_acpi_may_tunnel_dp(void) { return true; }
  1356. static inline bool tb_acpi_may_tunnel_pcie(void) { return true; }
  1357. static inline bool tb_acpi_is_xdomain_allowed(void) { return true; }
  1358. static inline int tb_acpi_init(void) { return 0; }
  1359. static inline void tb_acpi_exit(void) { }
  1360. static inline int tb_acpi_power_on_retimers(struct tb_port *port) { return 0; }
  1361. static inline int tb_acpi_power_off_retimers(struct tb_port *port) { return 0; }
  1362. #endif
  1363. #ifdef CONFIG_DEBUG_FS
  1364. void tb_debugfs_init(void);
  1365. void tb_debugfs_exit(void);
  1366. void tb_switch_debugfs_init(struct tb_switch *sw);
  1367. void tb_switch_debugfs_remove(struct tb_switch *sw);
  1368. void tb_xdomain_debugfs_init(struct tb_xdomain *xd);
  1369. void tb_xdomain_debugfs_remove(struct tb_xdomain *xd);
  1370. void tb_service_debugfs_init(struct tb_service *svc);
  1371. void tb_service_debugfs_remove(struct tb_service *svc);
  1372. void tb_retimer_debugfs_init(struct tb_retimer *rt);
  1373. void tb_retimer_debugfs_remove(struct tb_retimer *rt);
  1374. #else
  1375. static inline void tb_debugfs_init(void) { }
  1376. static inline void tb_debugfs_exit(void) { }
  1377. static inline void tb_switch_debugfs_init(struct tb_switch *sw) { }
  1378. static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { }
  1379. static inline void tb_xdomain_debugfs_init(struct tb_xdomain *xd) { }
  1380. static inline void tb_xdomain_debugfs_remove(struct tb_xdomain *xd) { }
  1381. static inline void tb_service_debugfs_init(struct tb_service *svc) { }
  1382. static inline void tb_service_debugfs_remove(struct tb_service *svc) { }
  1383. static inline void tb_retimer_debugfs_init(struct tb_retimer *rt) { }
  1384. static inline void tb_retimer_debugfs_remove(struct tb_retimer *rt) { }
  1385. #endif
  1386. #endif