pd.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __DT_POWER_DELIVERY_H
  3. #define __DT_POWER_DELIVERY_H
  4. /* Power delivery Power Data Object definitions */
  5. #define PDO_TYPE_FIXED 0
  6. #define PDO_TYPE_BATT 1
  7. #define PDO_TYPE_VAR 2
  8. #define PDO_TYPE_APDO 3
  9. #define PDO_TYPE_SHIFT 30
  10. #define PDO_TYPE_MASK 0x3
  11. #define PDO_TYPE(t) ((t) << PDO_TYPE_SHIFT)
  12. #define PDO_VOLT_MASK 0x3ff
  13. #define PDO_CURR_MASK 0x3ff
  14. #define PDO_PWR_MASK 0x3ff
  15. #define PDO_FIXED_DUAL_ROLE (1 << 29) /* Power role swap supported */
  16. #define PDO_FIXED_SUSPEND (1 << 28) /* USB Suspend supported (Source) */
  17. #define PDO_FIXED_HIGHER_CAP (1 << 28) /* Requires more than vSafe5V (Sink) */
  18. #define PDO_FIXED_EXTPOWER (1 << 27) /* Externally powered */
  19. #define PDO_FIXED_USB_COMM (1 << 26) /* USB communications capable */
  20. #define PDO_FIXED_DATA_SWAP (1 << 25) /* Data role swap supported */
  21. #define PDO_FIXED_VOLT_SHIFT 10 /* 50mV units */
  22. #define PDO_FIXED_CURR_SHIFT 0 /* 10mA units */
  23. #define PDO_FIXED_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_FIXED_VOLT_SHIFT)
  24. #define PDO_FIXED_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_FIXED_CURR_SHIFT)
  25. #define PDO_FIXED(mv, ma, flags) \
  26. (PDO_TYPE(PDO_TYPE_FIXED) | (flags) | \
  27. PDO_FIXED_VOLT(mv) | PDO_FIXED_CURR(ma))
  28. #define VSAFE5V 5000 /* mv units */
  29. #define PDO_BATT_MAX_VOLT_SHIFT 20 /* 50mV units */
  30. #define PDO_BATT_MIN_VOLT_SHIFT 10 /* 50mV units */
  31. #define PDO_BATT_MAX_PWR_SHIFT 0 /* 250mW units */
  32. #define PDO_BATT_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MIN_VOLT_SHIFT)
  33. #define PDO_BATT_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MAX_VOLT_SHIFT)
  34. #define PDO_BATT_MAX_POWER(mw) ((((mw) / 250) & PDO_PWR_MASK) << PDO_BATT_MAX_PWR_SHIFT)
  35. #define PDO_BATT(min_mv, max_mv, max_mw) \
  36. (PDO_TYPE(PDO_TYPE_BATT) | PDO_BATT_MIN_VOLT(min_mv) | \
  37. PDO_BATT_MAX_VOLT(max_mv) | PDO_BATT_MAX_POWER(max_mw))
  38. #define PDO_VAR_MAX_VOLT_SHIFT 20 /* 50mV units */
  39. #define PDO_VAR_MIN_VOLT_SHIFT 10 /* 50mV units */
  40. #define PDO_VAR_MAX_CURR_SHIFT 0 /* 10mA units */
  41. #define PDO_VAR_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT)
  42. #define PDO_VAR_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT)
  43. #define PDO_VAR_MAX_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT)
  44. #define PDO_VAR(min_mv, max_mv, max_ma) \
  45. (PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) | \
  46. PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma))
  47. #define APDO_TYPE_PPS 0
  48. #define PDO_APDO_TYPE_SHIFT 28 /* Only valid value currently is 0x0 - PPS */
  49. #define PDO_APDO_TYPE_MASK 0x3
  50. #define PDO_APDO_TYPE(t) ((t) << PDO_APDO_TYPE_SHIFT)
  51. #define PDO_PPS_APDO_MAX_VOLT_SHIFT 17 /* 100mV units */
  52. #define PDO_PPS_APDO_MIN_VOLT_SHIFT 8 /* 100mV units */
  53. #define PDO_PPS_APDO_MAX_CURR_SHIFT 0 /* 50mA units */
  54. #define PDO_PPS_APDO_VOLT_MASK 0xff
  55. #define PDO_PPS_APDO_CURR_MASK 0x7f
  56. #define PDO_PPS_APDO_MIN_VOLT(mv) \
  57. ((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MIN_VOLT_SHIFT)
  58. #define PDO_PPS_APDO_MAX_VOLT(mv) \
  59. ((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MAX_VOLT_SHIFT)
  60. #define PDO_PPS_APDO_MAX_CURR(ma) \
  61. ((((ma) / 50) & PDO_PPS_APDO_CURR_MASK) << PDO_PPS_APDO_MAX_CURR_SHIFT)
  62. #define PDO_PPS_APDO(min_mv, max_mv, max_ma) \
  63. (PDO_TYPE(PDO_TYPE_APDO) | PDO_APDO_TYPE(APDO_TYPE_PPS) | \
  64. PDO_PPS_APDO_MIN_VOLT(min_mv) | PDO_PPS_APDO_MAX_VOLT(max_mv) | \
  65. PDO_PPS_APDO_MAX_CURR(max_ma))
  66. /*
  67. * Based on "Table 6-14 Fixed Supply PDO - Sink" of "USB Power Delivery Specification Revision 3.0,
  68. * Version 1.2"
  69. * Initial current capability of the new source when vSafe5V is applied.
  70. */
  71. #define FRS_DEFAULT_POWER 1
  72. #define FRS_5V_1P5A 2
  73. #define FRS_5V_3A 3
  74. /*
  75. * SVDM Identity Header
  76. * --------------------
  77. * <31> :: data capable as a USB host
  78. * <30> :: data capable as a USB device
  79. * <29:27> :: product type (UFP / Cable / VPD)
  80. * <26> :: modal operation supported (1b == yes)
  81. * <25:23> :: product type (DFP) (SVDM version 2.0+ only; set to zero in version 1.0)
  82. * <22:21> :: connector type (SVDM version 2.0+ only; set to zero in version 1.0)
  83. * <20:16> :: Reserved, Shall be set to zero
  84. * <15:0> :: USB-IF assigned VID for this cable vendor
  85. */
  86. /* PD Rev2.0 definition */
  87. #define IDH_PTYPE_UNDEF 0
  88. /* SOP Product Type (UFP) */
  89. #define IDH_PTYPE_NOT_UFP 0
  90. #define IDH_PTYPE_HUB 1
  91. #define IDH_PTYPE_PERIPH 2
  92. #define IDH_PTYPE_PSD 3
  93. #define IDH_PTYPE_AMA 5
  94. /* SOP' Product Type (Cable Plug / VPD) */
  95. #define IDH_PTYPE_NOT_CABLE 0
  96. #define IDH_PTYPE_PCABLE 3
  97. #define IDH_PTYPE_ACABLE 4
  98. #define IDH_PTYPE_VPD 6
  99. /* SOP Product Type (DFP) */
  100. #define IDH_PTYPE_NOT_DFP 0
  101. #define IDH_PTYPE_DFP_HUB 1
  102. #define IDH_PTYPE_DFP_HOST 2
  103. #define IDH_PTYPE_DFP_PB 3
  104. #define VDO_IDH(usbh, usbd, ufp_cable, is_modal, dfp, conn, vid) \
  105. ((usbh) << 31 | (usbd) << 30 | ((ufp_cable) & 0x7) << 27 \
  106. | (is_modal) << 26 | ((dfp) & 0x7) << 23 | ((conn) & 0x3) << 21 \
  107. | ((vid) & 0xffff))
  108. /*
  109. * Cert Stat VDO
  110. * -------------
  111. * <31:0> : USB-IF assigned XID for this cable
  112. */
  113. #define VDO_CERT(xid) ((xid) & 0xffffffff)
  114. /*
  115. * Product VDO
  116. * -----------
  117. * <31:16> : USB Product ID
  118. * <15:0> : USB bcdDevice
  119. */
  120. #define VDO_PRODUCT(pid, bcd) (((pid) & 0xffff) << 16 | ((bcd) & 0xffff))
  121. /*
  122. * UFP VDO (PD Revision 3.0+ only)
  123. * --------
  124. * <31:29> :: UFP VDO version
  125. * <28> :: Reserved
  126. * <27:24> :: Device capability
  127. * <23:22> :: Connector type (10b == receptacle, 11b == captive plug)
  128. * <21:11> :: Reserved
  129. * <10:8> :: Vconn power (AMA only)
  130. * <7> :: Vconn required (AMA only, 0b == no, 1b == yes)
  131. * <6> :: Vbus required (AMA only, 0b == yes, 1b == no)
  132. * <5:3> :: Alternate modes
  133. * <2:0> :: USB highest speed
  134. */
  135. /* UFP VDO Version */
  136. #define UFP_VDO_VER1_2 2
  137. /* Device Capability */
  138. #define DEV_USB2_CAPABLE (1 << 0)
  139. #define DEV_USB2_BILLBOARD (1 << 1)
  140. #define DEV_USB3_CAPABLE (1 << 2)
  141. #define DEV_USB4_CAPABLE (1 << 3)
  142. /* Connector Type */
  143. #define UFP_RECEPTACLE 2
  144. #define UFP_CAPTIVE 3
  145. /* Vconn Power (AMA only, set to AMA_VCONN_NOT_REQ if Vconn is not required) */
  146. #define AMA_VCONN_PWR_1W 0
  147. #define AMA_VCONN_PWR_1W5 1
  148. #define AMA_VCONN_PWR_2W 2
  149. #define AMA_VCONN_PWR_3W 3
  150. #define AMA_VCONN_PWR_4W 4
  151. #define AMA_VCONN_PWR_5W 5
  152. #define AMA_VCONN_PWR_6W 6
  153. /* Vconn Required (AMA only) */
  154. #define AMA_VCONN_NOT_REQ 0
  155. #define AMA_VCONN_REQ 1
  156. /* Vbus Required (AMA only) */
  157. #define AMA_VBUS_REQ 0
  158. #define AMA_VBUS_NOT_REQ 1
  159. /* Alternate Modes */
  160. #define UFP_ALTMODE_NOT_SUPP 0
  161. #define UFP_ALTMODE_TBT3 (1 << 0)
  162. #define UFP_ALTMODE_RECFG (1 << 1)
  163. #define UFP_ALTMODE_NO_RECFG (1 << 2)
  164. /* USB Highest Speed */
  165. #define UFP_USB2_ONLY 0
  166. #define UFP_USB32_GEN1 1
  167. #define UFP_USB32_4_GEN2 2
  168. #define UFP_USB4_GEN3 3
  169. #define VDO_UFP(ver, cap, conn, vcpwr, vcr, vbr, alt, spd) \
  170. (((ver) & 0x7) << 29 | ((cap) & 0xf) << 24 | ((conn) & 0x3) << 22 \
  171. | ((vcpwr) & 0x7) << 8 | (vcr) << 7 | (vbr) << 6 | ((alt) & 0x7) << 3 \
  172. | ((spd) & 0x7))
  173. /*
  174. * DFP VDO (PD Revision 3.0+ only)
  175. * --------
  176. * <31:29> :: DFP VDO version
  177. * <28:27> :: Reserved
  178. * <26:24> :: Host capability
  179. * <23:22> :: Connector type (10b == receptacle, 11b == captive plug)
  180. * <21:5> :: Reserved
  181. * <4:0> :: Port number
  182. */
  183. #define DFP_VDO_VER1_1 1
  184. #define HOST_USB2_CAPABLE (1 << 0)
  185. #define HOST_USB3_CAPABLE (1 << 1)
  186. #define HOST_USB4_CAPABLE (1 << 2)
  187. #define DFP_RECEPTACLE 2
  188. #define DFP_CAPTIVE 3
  189. #define VDO_DFP(ver, cap, conn, pnum) \
  190. (((ver) & 0x7) << 29 | ((cap) & 0x7) << 24 | ((conn) & 0x3) << 22 \
  191. | ((pnum) & 0x1f))
  192. /*
  193. * Cable VDO (for both Passive and Active Cable VDO in PD Rev2.0)
  194. * ---------
  195. * <31:28> :: Cable HW version
  196. * <27:24> :: Cable FW version
  197. * <23:20> :: Reserved, Shall be set to zero
  198. * <19:18> :: type-C to Type-A/B/C/Captive (00b == A, 01 == B, 10 == C, 11 == Captive)
  199. * <17> :: Reserved, Shall be set to zero
  200. * <16:13> :: cable latency (0001 == <10ns(~1m length))
  201. * <12:11> :: cable termination type (11b == both ends active VCONN req)
  202. * <10> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable)
  203. * <9> :: SSTX2 Directionality support
  204. * <8> :: SSRX1 Directionality support
  205. * <7> :: SSRX2 Directionality support
  206. * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A)
  207. * <4> :: Vbus through cable (0b == no, 1b == yes)
  208. * <3> :: SOP" controller present? (0b == no, 1b == yes)
  209. * <2:0> :: USB SS Signaling support
  210. *
  211. * Passive Cable VDO (PD Rev3.0+)
  212. * ---------
  213. * <31:28> :: Cable HW version
  214. * <27:24> :: Cable FW version
  215. * <23:21> :: VDO version
  216. * <20> :: Reserved, Shall be set to zero
  217. * <19:18> :: Type-C to Type-C/Captive (10b == C, 11b == Captive)
  218. * <17> :: Reserved, Shall be set to zero
  219. * <16:13> :: cable latency (0001 == <10ns(~1m length))
  220. * <12:11> :: cable termination type (10b == Vconn not req, 01b == Vconn req)
  221. * <10:9> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V)
  222. * <8:7> :: Reserved, Shall be set to zero
  223. * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A)
  224. * <4:3> :: Reserved, Shall be set to zero
  225. * <2:0> :: USB highest speed
  226. *
  227. * Active Cable VDO 1 (PD Rev3.0+)
  228. * ---------
  229. * <31:28> :: Cable HW version
  230. * <27:24> :: Cable FW version
  231. * <23:21> :: VDO version
  232. * <20> :: Reserved, Shall be set to zero
  233. * <19:18> :: Connector type (10b == C, 11b == Captive)
  234. * <17> :: Reserved, Shall be set to zero
  235. * <16:13> :: cable latency (0001 == <10ns(~1m length))
  236. * <12:11> :: cable termination type (10b == one end active, 11b == both ends active VCONN req)
  237. * <10:9> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V)
  238. * <8> :: SBU supported (0b == supported, 1b == not supported)
  239. * <7> :: SBU type (0b == passive, 1b == active)
  240. * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A)
  241. * <4> :: Vbus through cable (0b == no, 1b == yes)
  242. * <3> :: SOP" controller present? (0b == no, 1b == yes)
  243. * <2:0> :: USB highest speed
  244. */
  245. /* Cable VDO Version */
  246. #define CABLE_VDO_VER1_0 0
  247. #define CABLE_VDO_VER1_3 3
  248. /* Connector Type (_ATYPE and _BTYPE are for PD Rev2.0 only) */
  249. #define CABLE_ATYPE 0
  250. #define CABLE_BTYPE 1
  251. #define CABLE_CTYPE 2
  252. #define CABLE_CAPTIVE 3
  253. /* Cable Latency */
  254. #define CABLE_LATENCY_1M 1
  255. #define CABLE_LATENCY_2M 2
  256. #define CABLE_LATENCY_3M 3
  257. #define CABLE_LATENCY_4M 4
  258. #define CABLE_LATENCY_5M 5
  259. #define CABLE_LATENCY_6M 6
  260. #define CABLE_LATENCY_7M 7
  261. #define CABLE_LATENCY_7M_PLUS 8
  262. /* Cable Termination Type */
  263. #define PCABLE_VCONN_NOT_REQ 0
  264. #define PCABLE_VCONN_REQ 1
  265. #define ACABLE_ONE_END 2
  266. #define ACABLE_BOTH_END 3
  267. /* Maximum Vbus Voltage */
  268. #define CABLE_MAX_VBUS_20V 0
  269. #define CABLE_MAX_VBUS_30V 1
  270. #define CABLE_MAX_VBUS_40V 2
  271. #define CABLE_MAX_VBUS_50V 3
  272. /* Active Cable SBU Supported/Type */
  273. #define ACABLE_SBU_SUPP 0
  274. #define ACABLE_SBU_NOT_SUPP 1
  275. #define ACABLE_SBU_PASSIVE 0
  276. #define ACABLE_SBU_ACTIVE 1
  277. /* Vbus Current Handling Capability */
  278. #define CABLE_CURR_DEF 0
  279. #define CABLE_CURR_3A 1
  280. #define CABLE_CURR_5A 2
  281. /* USB SuperSpeed Signaling Support (PD Rev2.0) */
  282. #define CABLE_USBSS_U2_ONLY 0
  283. #define CABLE_USBSS_U31_GEN1 1
  284. #define CABLE_USBSS_U31_GEN2 2
  285. /* USB Highest Speed */
  286. #define CABLE_USB2_ONLY 0
  287. #define CABLE_USB32_GEN1 1
  288. #define CABLE_USB32_4_GEN2 2
  289. #define CABLE_USB4_GEN3 3
  290. #define VDO_CABLE(hw, fw, cbl, lat, term, tx1d, tx2d, rx1d, rx2d, cur, vps, sopp, usbss) \
  291. (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 | ((cbl) & 0x3) << 18 \
  292. | ((lat) & 0x7) << 13 | ((term) & 0x3) << 11 | (tx1d) << 10 \
  293. | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7 | ((cur) & 0x3) << 5 \
  294. | (vps) << 4 | (sopp) << 3 | ((usbss) & 0x7))
  295. #define VDO_PCABLE(hw, fw, ver, conn, lat, term, vbm, cur, spd) \
  296. (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \
  297. | ((conn) & 0x3) << 18 | ((lat) & 0xf) << 13 | ((term) & 0x3) << 11 \
  298. | ((vbm) & 0x3) << 9 | ((cur) & 0x3) << 5 | ((spd) & 0x7))
  299. #define VDO_ACABLE1(hw, fw, ver, conn, lat, term, vbm, sbu, sbut, cur, vbt, sopp, spd) \
  300. (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \
  301. | ((conn) & 0x3) << 18 | ((lat) & 0xf) << 13 | ((term) & 0x3) << 11 \
  302. | ((vbm) & 0x3) << 9 | (sbu) << 8 | (sbut) << 7 | ((cur) & 0x3) << 5 \
  303. | (vbt) << 4 | (sopp) << 3 | ((spd) & 0x7))
  304. /*
  305. * Active Cable VDO 2
  306. * ---------
  307. * <31:24> :: Maximum operating temperature
  308. * <23:16> :: Shutdown temperature
  309. * <15> :: Reserved, Shall be set to zero
  310. * <14:12> :: U3/CLd power
  311. * <11> :: U3 to U0 transition mode (0b == direct, 1b == through U3S)
  312. * <10> :: Physical connection (0b == copper, 1b == optical)
  313. * <9> :: Active element (0b == redriver, 1b == retimer)
  314. * <8> :: USB4 supported (0b == yes, 1b == no)
  315. * <7:6> :: USB2 hub hops consumed
  316. * <5> :: USB2 supported (0b == yes, 1b == no)
  317. * <4> :: USB3.2 supported (0b == yes, 1b == no)
  318. * <3> :: USB lanes supported (0b == one lane, 1b == two lanes)
  319. * <2> :: Optically isolated active cable (0b == no, 1b == yes)
  320. * <1> :: Reserved, Shall be set to zero
  321. * <0> :: USB gen (0b == gen1, 1b == gen2+)
  322. */
  323. /* U3/CLd Power*/
  324. #define ACAB2_U3_CLD_10MW_PLUS 0
  325. #define ACAB2_U3_CLD_10MW 1
  326. #define ACAB2_U3_CLD_5MW 2
  327. #define ACAB2_U3_CLD_1MW 3
  328. #define ACAB2_U3_CLD_500UW 4
  329. #define ACAB2_U3_CLD_200UW 5
  330. #define ACAB2_U3_CLD_50UW 6
  331. /* Other Active Cable VDO 2 Fields */
  332. #define ACAB2_U3U0_DIRECT 0
  333. #define ACAB2_U3U0_U3S 1
  334. #define ACAB2_PHY_COPPER 0
  335. #define ACAB2_PHY_OPTICAL 1
  336. #define ACAB2_REDRIVER 0
  337. #define ACAB2_RETIMER 1
  338. #define ACAB2_USB4_SUPP 0
  339. #define ACAB2_USB4_NOT_SUPP 1
  340. #define ACAB2_USB2_SUPP 0
  341. #define ACAB2_USB2_NOT_SUPP 1
  342. #define ACAB2_USB32_SUPP 0
  343. #define ACAB2_USB32_NOT_SUPP 1
  344. #define ACAB2_LANES_ONE 0
  345. #define ACAB2_LANES_TWO 1
  346. #define ACAB2_OPT_ISO_NO 0
  347. #define ACAB2_OPT_ISO_YES 1
  348. #define ACAB2_GEN_1 0
  349. #define ACAB2_GEN_2_PLUS 1
  350. #define VDO_ACABLE2(mtemp, stemp, u3p, trans, phy, ele, u4, hops, u2, u32, lane, iso, gen) \
  351. (((mtemp) & 0xff) << 24 | ((stemp) & 0xff) << 16 | ((u3p) & 0x7) << 12 \
  352. | (trans) << 11 | (phy) << 10 | (ele) << 9 | (u4) << 8 \
  353. | ((hops) & 0x3) << 6 | (u2) << 5 | (u32) << 4 | (lane) << 3 \
  354. | (iso) << 2 | (gen))
  355. /*
  356. * AMA VDO (PD Rev2.0)
  357. * ---------
  358. * <31:28> :: Cable HW version
  359. * <27:24> :: Cable FW version
  360. * <23:12> :: Reserved, Shall be set to zero
  361. * <11> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable)
  362. * <10> :: SSTX2 Directionality support
  363. * <9> :: SSRX1 Directionality support
  364. * <8> :: SSRX2 Directionality support
  365. * <7:5> :: Vconn power
  366. * <4> :: Vconn power required
  367. * <3> :: Vbus power required
  368. * <2:0> :: USB SS Signaling support
  369. */
  370. #define VDO_AMA(hw, fw, tx1d, tx2d, rx1d, rx2d, vcpwr, vcr, vbr, usbss) \
  371. (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 \
  372. | (tx1d) << 11 | (tx2d) << 10 | (rx1d) << 9 | (rx2d) << 8 \
  373. | ((vcpwr) & 0x7) << 5 | (vcr) << 4 | (vbr) << 3 \
  374. | ((usbss) & 0x7))
  375. #define PD_VDO_AMA_VCONN_REQ(vdo) (((vdo) >> 4) & 1)
  376. #define PD_VDO_AMA_VBUS_REQ(vdo) (((vdo) >> 3) & 1)
  377. #define AMA_USBSS_U2_ONLY 0
  378. #define AMA_USBSS_U31_GEN1 1
  379. #define AMA_USBSS_U31_GEN2 2
  380. #define AMA_USBSS_BBONLY 3
  381. /*
  382. * VPD VDO
  383. * ---------
  384. * <31:28> :: HW version
  385. * <27:24> :: FW version
  386. * <23:21> :: VDO version
  387. * <20:17> :: Reserved, Shall be set to zero
  388. * <16:15> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V)
  389. * <14> :: Charge through current support (0b == 3A, 1b == 5A)
  390. * <13> :: Reserved, Shall be set to zero
  391. * <12:7> :: Vbus impedance
  392. * <6:1> :: Ground impedance
  393. * <0> :: Charge through support (0b == no, 1b == yes)
  394. */
  395. #define VPD_VDO_VER1_0 0
  396. #define VPD_MAX_VBUS_20V 0
  397. #define VPD_MAX_VBUS_30V 1
  398. #define VPD_MAX_VBUS_40V 2
  399. #define VPD_MAX_VBUS_50V 3
  400. #define VPDCT_CURR_3A 0
  401. #define VPDCT_CURR_5A 1
  402. #define VPDCT_NOT_SUPP 0
  403. #define VPDCT_SUPP 1
  404. #define VDO_VPD(hw, fw, ver, vbm, curr, vbi, gi, ct) \
  405. (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \
  406. | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \
  407. | ((gi) & 0x3f) << 1 | (ct))
  408. #endif /* __DT_POWER_DELIVERY_H */