| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2015-2017 Google, Inc |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 6 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | | - * (at your option) any later version. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | | - * GNU General Public License for more details. |
|---|
| 13 | 4 | */ |
|---|
| 14 | 5 | |
|---|
| 15 | 6 | #ifndef __LINUX_USB_PD_VDO_H |
|---|
| .. | .. |
|---|
| 30 | 21 | * ---------- |
|---|
| 31 | 22 | * <31:16> :: SVID |
|---|
| 32 | 23 | * <15> :: VDM type ( 1b == structured, 0b == unstructured ) |
|---|
| 33 | | - * <14:13> :: Structured VDM version (can only be 00 == 1.0 currently) |
|---|
| 24 | + * <14:13> :: Structured VDM version |
|---|
| 34 | 25 | * <12:11> :: reserved |
|---|
| 35 | 26 | * <10:8> :: object position (1-7 valid ... used for enter/exit mode only) |
|---|
| 36 | 27 | * <7:6> :: command type (SVDM only?) |
|---|
| 37 | 28 | * <5> :: reserved (SVDM), command type (UVDM) |
|---|
| 38 | 29 | * <4:0> :: command |
|---|
| 39 | 30 | */ |
|---|
| 40 | | -#define VDO(vid, type, custom) \ |
|---|
| 31 | +#define VDO(vid, type, ver, custom) \ |
|---|
| 41 | 32 | (((vid) << 16) | \ |
|---|
| 42 | 33 | ((type) << 15) | \ |
|---|
| 34 | + ((ver) << 13) | \ |
|---|
| 43 | 35 | ((custom) & 0x7FFF)) |
|---|
| 44 | 36 | |
|---|
| 45 | 37 | #define VDO_SVDM_TYPE (1 << 15) |
|---|
| 46 | 38 | #define VDO_SVDM_VERS(x) ((x) << 13) |
|---|
| 47 | 39 | #define VDO_OPOS(x) ((x) << 8) |
|---|
| 48 | 40 | #define VDO_CMDT(x) ((x) << 6) |
|---|
| 41 | +#define VDO_SVDM_VERS_MASK VDO_SVDM_VERS(0x3) |
|---|
| 49 | 42 | #define VDO_OPOS_MASK VDO_OPOS(0x7) |
|---|
| 50 | 43 | #define VDO_CMDT_MASK VDO_CMDT(0x3) |
|---|
| 51 | 44 | |
|---|
| .. | .. |
|---|
| 83 | 76 | |
|---|
| 84 | 77 | #define PD_VDO_VID(vdo) ((vdo) >> 16) |
|---|
| 85 | 78 | #define PD_VDO_SVDM(vdo) (((vdo) >> 15) & 1) |
|---|
| 79 | +#define PD_VDO_SVDM_VER(vdo) (((vdo) >> 13) & 0x3) |
|---|
| 86 | 80 | #define PD_VDO_OPOS(vdo) (((vdo) >> 8) & 0x7) |
|---|
| 87 | 81 | #define PD_VDO_CMD(vdo) ((vdo) & 0x1f) |
|---|
| 88 | 82 | #define PD_VDO_CMDT(vdo) (((vdo) >> 6) & 0x3) |
|---|
| .. | .. |
|---|
| 112 | 106 | * -------------------- |
|---|
| 113 | 107 | * <31> :: data capable as a USB host |
|---|
| 114 | 108 | * <30> :: data capable as a USB device |
|---|
| 115 | | - * <29:27> :: product type |
|---|
| 109 | + * <29:27> :: product type (UFP / Cable / VPD) |
|---|
| 116 | 110 | * <26> :: modal operation supported (1b == yes) |
|---|
| 117 | | - * <25:16> :: Reserved, Shall be set to zero |
|---|
| 111 | + * <25:23> :: product type (DFP) (SVDM version 2.0+ only; set to zero in version 1.0) |
|---|
| 112 | + * <22:21> :: connector type (SVDM version 2.0+ only; set to zero in version 1.0) |
|---|
| 113 | + * <20:16> :: Reserved, Shall be set to zero |
|---|
| 118 | 114 | * <15:0> :: USB-IF assigned VID for this cable vendor |
|---|
| 119 | 115 | */ |
|---|
| 116 | + |
|---|
| 117 | +/* PD Rev2.0 definition */ |
|---|
| 120 | 118 | #define IDH_PTYPE_UNDEF 0 |
|---|
| 119 | + |
|---|
| 120 | +/* SOP Product Type (UFP) */ |
|---|
| 121 | +#define IDH_PTYPE_NOT_UFP 0 |
|---|
| 121 | 122 | #define IDH_PTYPE_HUB 1 |
|---|
| 122 | 123 | #define IDH_PTYPE_PERIPH 2 |
|---|
| 123 | | -#define IDH_PTYPE_PCABLE 3 |
|---|
| 124 | | -#define IDH_PTYPE_ACABLE 4 |
|---|
| 124 | +#define IDH_PTYPE_PSD 3 |
|---|
| 125 | 125 | #define IDH_PTYPE_AMA 5 |
|---|
| 126 | 126 | |
|---|
| 127 | | -#define VDO_IDH(usbh, usbd, ptype, is_modal, vid) \ |
|---|
| 128 | | - ((usbh) << 31 | (usbd) << 30 | ((ptype) & 0x7) << 27 \ |
|---|
| 129 | | - | (is_modal) << 26 | ((vid) & 0xffff)) |
|---|
| 127 | +/* SOP' Product Type (Cable Plug / VPD) */ |
|---|
| 128 | +#define IDH_PTYPE_NOT_CABLE 0 |
|---|
| 129 | +#define IDH_PTYPE_PCABLE 3 |
|---|
| 130 | +#define IDH_PTYPE_ACABLE 4 |
|---|
| 131 | +#define IDH_PTYPE_VPD 6 |
|---|
| 132 | + |
|---|
| 133 | +/* SOP Product Type (DFP) */ |
|---|
| 134 | +#define IDH_PTYPE_NOT_DFP 0 |
|---|
| 135 | +#define IDH_PTYPE_DFP_HUB 1 |
|---|
| 136 | +#define IDH_PTYPE_DFP_HOST 2 |
|---|
| 137 | +#define IDH_PTYPE_DFP_PB 3 |
|---|
| 138 | + |
|---|
| 139 | +/* ID Header Mask */ |
|---|
| 140 | +#define IDH_DFP_MASK GENMASK(25, 23) |
|---|
| 141 | +#define IDH_CONN_MASK GENMASK(22, 21) |
|---|
| 142 | + |
|---|
| 143 | +#define VDO_IDH(usbh, usbd, ufp_cable, is_modal, dfp, conn, vid) \ |
|---|
| 144 | + ((usbh) << 31 | (usbd) << 30 | ((ufp_cable) & 0x7) << 27 \ |
|---|
| 145 | + | (is_modal) << 26 | ((dfp) & 0x7) << 23 | ((conn) & 0x3) << 21 \ |
|---|
| 146 | + | ((vid) & 0xffff)) |
|---|
| 130 | 147 | |
|---|
| 131 | 148 | #define PD_IDH_PTYPE(vdo) (((vdo) >> 27) & 0x7) |
|---|
| 132 | 149 | #define PD_IDH_VID(vdo) ((vdo) & 0xffff) |
|---|
| 133 | 150 | #define PD_IDH_MODAL_SUPP(vdo) ((vdo) & (1 << 26)) |
|---|
| 151 | +#define PD_IDH_DFP_PTYPE(vdo) (((vdo) >> 23) & 0x7) |
|---|
| 152 | +#define PD_IDH_CONN_TYPE(vdo) (((vdo) >> 21) & 0x3) |
|---|
| 134 | 153 | |
|---|
| 135 | 154 | /* |
|---|
| 136 | 155 | * Cert Stat VDO |
|---|
| .. | .. |
|---|
| 138 | 157 | * <31:0> : USB-IF assigned XID for this cable |
|---|
| 139 | 158 | */ |
|---|
| 140 | 159 | #define PD_CSTAT_XID(vdo) (vdo) |
|---|
| 160 | +#define VDO_CERT(xid) ((xid) & 0xffffffff) |
|---|
| 141 | 161 | |
|---|
| 142 | 162 | /* |
|---|
| 143 | 163 | * Product VDO |
|---|
| .. | .. |
|---|
| 149 | 169 | #define PD_PRODUCT_PID(vdo) (((vdo) >> 16) & 0xffff) |
|---|
| 150 | 170 | |
|---|
| 151 | 171 | /* |
|---|
| 152 | | - * Cable VDO |
|---|
| 172 | + * UFP VDO (PD Revision 3.0+ only) |
|---|
| 173 | + * -------- |
|---|
| 174 | + * <31:29> :: UFP VDO version |
|---|
| 175 | + * <28> :: Reserved |
|---|
| 176 | + * <27:24> :: Device capability |
|---|
| 177 | + * <23:22> :: Connector type (10b == receptacle, 11b == captive plug) |
|---|
| 178 | + * <21:11> :: Reserved |
|---|
| 179 | + * <10:8> :: Vconn power (AMA only) |
|---|
| 180 | + * <7> :: Vconn required (AMA only, 0b == no, 1b == yes) |
|---|
| 181 | + * <6> :: Vbus required (AMA only, 0b == yes, 1b == no) |
|---|
| 182 | + * <5:3> :: Alternate modes |
|---|
| 183 | + * <2:0> :: USB highest speed |
|---|
| 184 | + */ |
|---|
| 185 | +#define PD_VDO_UFP_DEVCAP(vdo) (((vdo) & GENMASK(27, 24)) >> 24) |
|---|
| 186 | + |
|---|
| 187 | +/* UFP VDO Version */ |
|---|
| 188 | +#define UFP_VDO_VER1_2 2 |
|---|
| 189 | + |
|---|
| 190 | +/* Device Capability */ |
|---|
| 191 | +#define DEV_USB2_CAPABLE BIT(0) |
|---|
| 192 | +#define DEV_USB2_BILLBOARD BIT(1) |
|---|
| 193 | +#define DEV_USB3_CAPABLE BIT(2) |
|---|
| 194 | +#define DEV_USB4_CAPABLE BIT(3) |
|---|
| 195 | + |
|---|
| 196 | +/* Connector Type */ |
|---|
| 197 | +#define UFP_RECEPTACLE 2 |
|---|
| 198 | +#define UFP_CAPTIVE 3 |
|---|
| 199 | + |
|---|
| 200 | +/* Vconn Power (AMA only, set to AMA_VCONN_NOT_REQ if Vconn is not required) */ |
|---|
| 201 | +#define AMA_VCONN_PWR_1W 0 |
|---|
| 202 | +#define AMA_VCONN_PWR_1W5 1 |
|---|
| 203 | +#define AMA_VCONN_PWR_2W 2 |
|---|
| 204 | +#define AMA_VCONN_PWR_3W 3 |
|---|
| 205 | +#define AMA_VCONN_PWR_4W 4 |
|---|
| 206 | +#define AMA_VCONN_PWR_5W 5 |
|---|
| 207 | +#define AMA_VCONN_PWR_6W 6 |
|---|
| 208 | + |
|---|
| 209 | +/* Vconn Required (AMA only) */ |
|---|
| 210 | +#define AMA_VCONN_NOT_REQ 0 |
|---|
| 211 | +#define AMA_VCONN_REQ 1 |
|---|
| 212 | + |
|---|
| 213 | +/* Vbus Required (AMA only) */ |
|---|
| 214 | +#define AMA_VBUS_REQ 0 |
|---|
| 215 | +#define AMA_VBUS_NOT_REQ 1 |
|---|
| 216 | + |
|---|
| 217 | +/* Alternate Modes */ |
|---|
| 218 | +#define UFP_ALTMODE_NOT_SUPP 0 |
|---|
| 219 | +#define UFP_ALTMODE_TBT3 BIT(0) |
|---|
| 220 | +#define UFP_ALTMODE_RECFG BIT(1) |
|---|
| 221 | +#define UFP_ALTMODE_NO_RECFG BIT(2) |
|---|
| 222 | + |
|---|
| 223 | +/* USB Highest Speed */ |
|---|
| 224 | +#define UFP_USB2_ONLY 0 |
|---|
| 225 | +#define UFP_USB32_GEN1 1 |
|---|
| 226 | +#define UFP_USB32_4_GEN2 2 |
|---|
| 227 | +#define UFP_USB4_GEN3 3 |
|---|
| 228 | + |
|---|
| 229 | +#define VDO_UFP(ver, cap, conn, vcpwr, vcr, vbr, alt, spd) \ |
|---|
| 230 | + (((ver) & 0x7) << 29 | ((cap) & 0xf) << 24 | ((conn) & 0x3) << 22 \ |
|---|
| 231 | + | ((vcpwr) & 0x7) << 8 | (vcr) << 7 | (vbr) << 6 | ((alt) & 0x7) << 3 \ |
|---|
| 232 | + | ((spd) & 0x7)) |
|---|
| 233 | + |
|---|
| 234 | +/* |
|---|
| 235 | + * DFP VDO (PD Revision 3.0+ only) |
|---|
| 236 | + * -------- |
|---|
| 237 | + * <31:29> :: DFP VDO version |
|---|
| 238 | + * <28:27> :: Reserved |
|---|
| 239 | + * <26:24> :: Host capability |
|---|
| 240 | + * <23:22> :: Connector type (10b == receptacle, 11b == captive plug) |
|---|
| 241 | + * <21:5> :: Reserved |
|---|
| 242 | + * <4:0> :: Port number |
|---|
| 243 | + */ |
|---|
| 244 | +#define PD_VDO_DFP_HOSTCAP(vdo) (((vdo) & GENMASK(26, 24)) >> 24) |
|---|
| 245 | + |
|---|
| 246 | +#define DFP_VDO_VER1_1 1 |
|---|
| 247 | +#define HOST_USB2_CAPABLE BIT(0) |
|---|
| 248 | +#define HOST_USB3_CAPABLE BIT(1) |
|---|
| 249 | +#define HOST_USB4_CAPABLE BIT(2) |
|---|
| 250 | +#define DFP_RECEPTACLE 2 |
|---|
| 251 | +#define DFP_CAPTIVE 3 |
|---|
| 252 | + |
|---|
| 253 | +#define VDO_DFP(ver, cap, conn, pnum) \ |
|---|
| 254 | + (((ver) & 0x7) << 29 | ((cap) & 0x7) << 24 | ((conn) & 0x3) << 22 \ |
|---|
| 255 | + | ((pnum) & 0x1f)) |
|---|
| 256 | + |
|---|
| 257 | +/* |
|---|
| 258 | + * Cable VDO (for both Passive and Active Cable VDO in PD Rev2.0) |
|---|
| 153 | 259 | * --------- |
|---|
| 154 | 260 | * <31:28> :: Cable HW version |
|---|
| 155 | 261 | * <27:24> :: Cable FW version |
|---|
| 156 | 262 | * <23:20> :: Reserved, Shall be set to zero |
|---|
| 157 | | - * <19:18> :: type-C to Type-A/B/C (00b == A, 01 == B, 10 == C) |
|---|
| 158 | | - * <17> :: Type-C to Plug/Receptacle (0b == plug, 1b == receptacle) |
|---|
| 263 | + * <19:18> :: type-C to Type-A/B/C/Captive (00b == A, 01 == B, 10 == C, 11 == Captive) |
|---|
| 264 | + * <17> :: Reserved, Shall be set to zero |
|---|
| 159 | 265 | * <16:13> :: cable latency (0001 == <10ns(~1m length)) |
|---|
| 160 | 266 | * <12:11> :: cable termination type (11b == both ends active VCONN req) |
|---|
| 161 | 267 | * <10> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable) |
|---|
| 162 | 268 | * <9> :: SSTX2 Directionality support |
|---|
| 163 | 269 | * <8> :: SSRX1 Directionality support |
|---|
| 164 | 270 | * <7> :: SSRX2 Directionality support |
|---|
| 165 | | - * <6:5> :: Vbus current handling capability |
|---|
| 271 | + * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A) |
|---|
| 166 | 272 | * <4> :: Vbus through cable (0b == no, 1b == yes) |
|---|
| 167 | 273 | * <3> :: SOP" controller present? (0b == no, 1b == yes) |
|---|
| 168 | 274 | * <2:0> :: USB SS Signaling support |
|---|
| 275 | + * |
|---|
| 276 | + * Passive Cable VDO (PD Rev3.0+) |
|---|
| 277 | + * --------- |
|---|
| 278 | + * <31:28> :: Cable HW version |
|---|
| 279 | + * <27:24> :: Cable FW version |
|---|
| 280 | + * <23:21> :: VDO version |
|---|
| 281 | + * <20> :: Reserved, Shall be set to zero |
|---|
| 282 | + * <19:18> :: Type-C to Type-C/Captive (10b == C, 11b == Captive) |
|---|
| 283 | + * <17> :: Reserved, Shall be set to zero |
|---|
| 284 | + * <16:13> :: cable latency (0001 == <10ns(~1m length)) |
|---|
| 285 | + * <12:11> :: cable termination type (10b == Vconn not req, 01b == Vconn req) |
|---|
| 286 | + * <10:9> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V) |
|---|
| 287 | + * <8:7> :: Reserved, Shall be set to zero |
|---|
| 288 | + * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A) |
|---|
| 289 | + * <4:3> :: Reserved, Shall be set to zero |
|---|
| 290 | + * <2:0> :: USB highest speed |
|---|
| 291 | + * |
|---|
| 292 | + * Active Cable VDO 1 (PD Rev3.0+) |
|---|
| 293 | + * --------- |
|---|
| 294 | + * <31:28> :: Cable HW version |
|---|
| 295 | + * <27:24> :: Cable FW version |
|---|
| 296 | + * <23:21> :: VDO version |
|---|
| 297 | + * <20> :: Reserved, Shall be set to zero |
|---|
| 298 | + * <19:18> :: Connector type (10b == C, 11b == Captive) |
|---|
| 299 | + * <17> :: Reserved, Shall be set to zero |
|---|
| 300 | + * <16:13> :: cable latency (0001 == <10ns(~1m length)) |
|---|
| 301 | + * <12:11> :: cable termination type (10b == one end active, 11b == both ends active VCONN req) |
|---|
| 302 | + * <10:9> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V) |
|---|
| 303 | + * <8> :: SBU supported (0b == supported, 1b == not supported) |
|---|
| 304 | + * <7> :: SBU type (0b == passive, 1b == active) |
|---|
| 305 | + * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A) |
|---|
| 306 | + * <2:0> :: USB highest speed |
|---|
| 169 | 307 | */ |
|---|
| 308 | +/* Cable VDO Version */ |
|---|
| 309 | +#define CABLE_VDO_VER1_0 0 |
|---|
| 310 | +#define CABLE_VDO_VER1_3 3 |
|---|
| 311 | + |
|---|
| 312 | +/* Connector Type (_ATYPE and _BTYPE are for PD Rev2.0 only) */ |
|---|
| 170 | 313 | #define CABLE_ATYPE 0 |
|---|
| 171 | 314 | #define CABLE_BTYPE 1 |
|---|
| 172 | 315 | #define CABLE_CTYPE 2 |
|---|
| 173 | | -#define CABLE_PLUG 0 |
|---|
| 174 | | -#define CABLE_RECEPTACLE 1 |
|---|
| 175 | | -#define CABLE_CURR_1A5 0 |
|---|
| 316 | +#define CABLE_CAPTIVE 3 |
|---|
| 317 | + |
|---|
| 318 | +/* Cable Latency */ |
|---|
| 319 | +#define CABLE_LATENCY_1M 1 |
|---|
| 320 | +#define CABLE_LATENCY_2M 2 |
|---|
| 321 | +#define CABLE_LATENCY_3M 3 |
|---|
| 322 | +#define CABLE_LATENCY_4M 4 |
|---|
| 323 | +#define CABLE_LATENCY_5M 5 |
|---|
| 324 | +#define CABLE_LATENCY_6M 6 |
|---|
| 325 | +#define CABLE_LATENCY_7M 7 |
|---|
| 326 | +#define CABLE_LATENCY_7M_PLUS 8 |
|---|
| 327 | + |
|---|
| 328 | +/* Cable Termination Type */ |
|---|
| 329 | +#define PCABLE_VCONN_NOT_REQ 0 |
|---|
| 330 | +#define PCABLE_VCONN_REQ 1 |
|---|
| 331 | +#define ACABLE_ONE_END 2 |
|---|
| 332 | +#define ACABLE_BOTH_END 3 |
|---|
| 333 | + |
|---|
| 334 | +/* Maximum Vbus Voltage */ |
|---|
| 335 | +#define CABLE_MAX_VBUS_20V 0 |
|---|
| 336 | +#define CABLE_MAX_VBUS_30V 1 |
|---|
| 337 | +#define CABLE_MAX_VBUS_40V 2 |
|---|
| 338 | +#define CABLE_MAX_VBUS_50V 3 |
|---|
| 339 | + |
|---|
| 340 | +/* Active Cable SBU Supported/Type */ |
|---|
| 341 | +#define ACABLE_SBU_SUPP 0 |
|---|
| 342 | +#define ACABLE_SBU_NOT_SUPP 1 |
|---|
| 343 | +#define ACABLE_SBU_PASSIVE 0 |
|---|
| 344 | +#define ACABLE_SBU_ACTIVE 1 |
|---|
| 345 | + |
|---|
| 346 | +/* Vbus Current Handling Capability */ |
|---|
| 347 | +#define CABLE_CURR_DEF 0 |
|---|
| 176 | 348 | #define CABLE_CURR_3A 1 |
|---|
| 177 | 349 | #define CABLE_CURR_5A 2 |
|---|
| 350 | + |
|---|
| 351 | +/* USB SuperSpeed Signaling Support (PD Rev2.0) */ |
|---|
| 178 | 352 | #define CABLE_USBSS_U2_ONLY 0 |
|---|
| 179 | 353 | #define CABLE_USBSS_U31_GEN1 1 |
|---|
| 180 | 354 | #define CABLE_USBSS_U31_GEN2 2 |
|---|
| 181 | | -#define VDO_CABLE(hw, fw, cbl, gdr, lat, term, tx1d, tx2d, rx1d, rx2d, cur,\ |
|---|
| 182 | | - vps, sopp, usbss) \ |
|---|
| 183 | | - (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 | ((cbl) & 0x3) << 18 \ |
|---|
| 184 | | - | (gdr) << 17 | ((lat) & 0x7) << 13 | ((term) & 0x3) << 11 \ |
|---|
| 185 | | - | (tx1d) << 10 | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7 \ |
|---|
| 186 | | - | ((cur) & 0x3) << 5 | (vps) << 4 | (sopp) << 3 \ |
|---|
| 187 | | - | ((usbss) & 0x7)) |
|---|
| 355 | + |
|---|
| 356 | +/* USB Highest Speed */ |
|---|
| 357 | +#define CABLE_USB2_ONLY 0 |
|---|
| 358 | +#define CABLE_USB32_GEN1 1 |
|---|
| 359 | +#define CABLE_USB32_4_GEN2 2 |
|---|
| 360 | +#define CABLE_USB4_GEN3 3 |
|---|
| 361 | + |
|---|
| 362 | +#define VDO_CABLE(hw, fw, cbl, lat, term, tx1d, tx2d, rx1d, rx2d, cur, vps, sopp, usbss) \ |
|---|
| 363 | + (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 | ((cbl) & 0x3) << 18 \ |
|---|
| 364 | + | ((lat) & 0x7) << 13 | ((term) & 0x3) << 11 | (tx1d) << 10 \ |
|---|
| 365 | + | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7 | ((cur) & 0x3) << 5 \ |
|---|
| 366 | + | (vps) << 4 | (sopp) << 3 | ((usbss) & 0x7)) |
|---|
| 367 | +#define VDO_PCABLE(hw, fw, ver, conn, lat, term, vbm, cur, spd) \ |
|---|
| 368 | + (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \ |
|---|
| 369 | + | ((conn) & 0x3) << 18 | ((lat) & 0xf) << 13 | ((term) & 0x3) << 11 \ |
|---|
| 370 | + | ((vbm) & 0x3) << 9 | ((cur) & 0x3) << 5 | ((spd) & 0x7)) |
|---|
| 371 | +#define VDO_ACABLE1(hw, fw, ver, conn, lat, term, vbm, sbu, sbut, cur, vbt, sopp, spd) \ |
|---|
| 372 | + (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \ |
|---|
| 373 | + | ((conn) & 0x3) << 18 | ((lat) & 0xf) << 13 | ((term) & 0x3) << 11 \ |
|---|
| 374 | + | ((vbm) & 0x3) << 9 | (sbu) << 8 | (sbut) << 7 | ((cur) & 0x3) << 5 \ |
|---|
| 375 | + | (vbt) << 4 | (sopp) << 3 | ((spd) & 0x7)) |
|---|
| 376 | + |
|---|
| 377 | +#define VDO_TYPEC_CABLE_TYPE(vdo) (((vdo) >> 18) & 0x3) |
|---|
| 188 | 378 | |
|---|
| 189 | 379 | /* |
|---|
| 190 | | - * AMA VDO |
|---|
| 380 | + * Active Cable VDO 2 |
|---|
| 381 | + * --------- |
|---|
| 382 | + * <31:24> :: Maximum operating temperature |
|---|
| 383 | + * <23:16> :: Shutdown temperature |
|---|
| 384 | + * <15> :: Reserved, Shall be set to zero |
|---|
| 385 | + * <14:12> :: U3/CLd power |
|---|
| 386 | + * <11> :: U3 to U0 transition mode (0b == direct, 1b == through U3S) |
|---|
| 387 | + * <10> :: Physical connection (0b == copper, 1b == optical) |
|---|
| 388 | + * <9> :: Active element (0b == redriver, 1b == retimer) |
|---|
| 389 | + * <8> :: USB4 supported (0b == yes, 1b == no) |
|---|
| 390 | + * <7:6> :: USB2 hub hops consumed |
|---|
| 391 | + * <5> :: USB2 supported (0b == yes, 1b == no) |
|---|
| 392 | + * <4> :: USB3.2 supported (0b == yes, 1b == no) |
|---|
| 393 | + * <3> :: USB lanes supported (0b == one lane, 1b == two lanes) |
|---|
| 394 | + * <2> :: Optically isolated active cable (0b == no, 1b == yes) |
|---|
| 395 | + * <1> :: Reserved, Shall be set to zero |
|---|
| 396 | + * <0> :: USB gen (0b == gen1, 1b == gen2+) |
|---|
| 397 | + */ |
|---|
| 398 | + |
|---|
| 399 | +/* U3/CLd Power*/ |
|---|
| 400 | +#define ACAB2_U3_CLD_10MW_PLUS 0 |
|---|
| 401 | +#define ACAB2_U3_CLD_10MW 1 |
|---|
| 402 | +#define ACAB2_U3_CLD_5MW 2 |
|---|
| 403 | +#define ACAB2_U3_CLD_1MW 3 |
|---|
| 404 | +#define ACAB2_U3_CLD_500UW 4 |
|---|
| 405 | +#define ACAB2_U3_CLD_200UW 5 |
|---|
| 406 | +#define ACAB2_U3_CLD_50UW 6 |
|---|
| 407 | + |
|---|
| 408 | +/* Other Active Cable VDO 2 Fields */ |
|---|
| 409 | +#define ACAB2_U3U0_DIRECT 0 |
|---|
| 410 | +#define ACAB2_U3U0_U3S 1 |
|---|
| 411 | +#define ACAB2_PHY_COPPER 0 |
|---|
| 412 | +#define ACAB2_PHY_OPTICAL 1 |
|---|
| 413 | +#define ACAB2_REDRIVER 0 |
|---|
| 414 | +#define ACAB2_RETIMER 1 |
|---|
| 415 | +#define ACAB2_USB4_SUPP 0 |
|---|
| 416 | +#define ACAB2_USB4_NOT_SUPP 1 |
|---|
| 417 | +#define ACAB2_USB2_SUPP 0 |
|---|
| 418 | +#define ACAB2_USB2_NOT_SUPP 1 |
|---|
| 419 | +#define ACAB2_USB32_SUPP 0 |
|---|
| 420 | +#define ACAB2_USB32_NOT_SUPP 1 |
|---|
| 421 | +#define ACAB2_LANES_ONE 0 |
|---|
| 422 | +#define ACAB2_LANES_TWO 1 |
|---|
| 423 | +#define ACAB2_OPT_ISO_NO 0 |
|---|
| 424 | +#define ACAB2_OPT_ISO_YES 1 |
|---|
| 425 | +#define ACAB2_GEN_1 0 |
|---|
| 426 | +#define ACAB2_GEN_2_PLUS 1 |
|---|
| 427 | + |
|---|
| 428 | +#define VDO_ACABLE2(mtemp, stemp, u3p, trans, phy, ele, u4, hops, u2, u32, lane, iso, gen) \ |
|---|
| 429 | + (((mtemp) & 0xff) << 24 | ((stemp) & 0xff) << 16 | ((u3p) & 0x7) << 12 \ |
|---|
| 430 | + | (trans) << 11 | (phy) << 10 | (ele) << 9 | (u4) << 8 \ |
|---|
| 431 | + | ((hops) & 0x3) << 6 | (u2) << 5 | (u32) << 4 | (lane) << 3 \ |
|---|
| 432 | + | (iso) << 2 | (gen)) |
|---|
| 433 | + |
|---|
| 434 | +/* |
|---|
| 435 | + * AMA VDO (PD Rev2.0) |
|---|
| 191 | 436 | * --------- |
|---|
| 192 | 437 | * <31:28> :: Cable HW version |
|---|
| 193 | 438 | * <27:24> :: Cable FW version |
|---|
| .. | .. |
|---|
| 210 | 455 | #define PD_VDO_AMA_VCONN_REQ(vdo) (((vdo) >> 4) & 1) |
|---|
| 211 | 456 | #define PD_VDO_AMA_VBUS_REQ(vdo) (((vdo) >> 3) & 1) |
|---|
| 212 | 457 | |
|---|
| 213 | | -#define AMA_VCONN_PWR_1W 0 |
|---|
| 214 | | -#define AMA_VCONN_PWR_1W5 1 |
|---|
| 215 | | -#define AMA_VCONN_PWR_2W 2 |
|---|
| 216 | | -#define AMA_VCONN_PWR_3W 3 |
|---|
| 217 | | -#define AMA_VCONN_PWR_4W 4 |
|---|
| 218 | | -#define AMA_VCONN_PWR_5W 5 |
|---|
| 219 | | -#define AMA_VCONN_PWR_6W 6 |
|---|
| 220 | 458 | #define AMA_USBSS_U2_ONLY 0 |
|---|
| 221 | 459 | #define AMA_USBSS_U31_GEN1 1 |
|---|
| 222 | 460 | #define AMA_USBSS_U31_GEN2 2 |
|---|
| 223 | 461 | #define AMA_USBSS_BBONLY 3 |
|---|
| 224 | 462 | |
|---|
| 225 | 463 | /* |
|---|
| 464 | + * VPD VDO |
|---|
| 465 | + * --------- |
|---|
| 466 | + * <31:28> :: HW version |
|---|
| 467 | + * <27:24> :: FW version |
|---|
| 468 | + * <23:21> :: VDO version |
|---|
| 469 | + * <20:17> :: Reserved, Shall be set to zero |
|---|
| 470 | + * <16:15> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V) |
|---|
| 471 | + * <14> :: Charge through current support (0b == 3A, 1b == 5A) |
|---|
| 472 | + * <13> :: Reserved, Shall be set to zero |
|---|
| 473 | + * <12:7> :: Vbus impedance |
|---|
| 474 | + * <6:1> :: Ground impedance |
|---|
| 475 | + * <0> :: Charge through support (0b == no, 1b == yes) |
|---|
| 476 | + */ |
|---|
| 477 | +#define VPD_VDO_VER1_0 0 |
|---|
| 478 | +#define VPD_MAX_VBUS_20V 0 |
|---|
| 479 | +#define VPD_MAX_VBUS_30V 1 |
|---|
| 480 | +#define VPD_MAX_VBUS_40V 2 |
|---|
| 481 | +#define VPD_MAX_VBUS_50V 3 |
|---|
| 482 | +#define VPDCT_CURR_3A 0 |
|---|
| 483 | +#define VPDCT_CURR_5A 1 |
|---|
| 484 | +#define VPDCT_NOT_SUPP 0 |
|---|
| 485 | +#define VPDCT_SUPP 1 |
|---|
| 486 | + |
|---|
| 487 | +#define VDO_VPD(hw, fw, ver, vbm, curr, vbi, gi, ct) \ |
|---|
| 488 | + (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \ |
|---|
| 489 | + | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \ |
|---|
| 490 | + | ((gi) & 0x3f) << 1 | (ct)) |
|---|
| 491 | + |
|---|
| 492 | +/* |
|---|
| 226 | 493 | * SVDM Discover SVIDs request -> response |
|---|
| 227 | 494 | * |
|---|
| 228 | 495 | * Request is properly formatted VDM Header with discover SVIDs command. |
|---|
| 229 | | - * Response is a set of SVIDs of all all supported SVIDs with all zero's to |
|---|
| 496 | + * Response is a set of SVIDs of all supported SVIDs with all zero's to |
|---|
| 230 | 497 | * mark the end of SVIDs. If more than 12 SVIDs are supported command SHOULD be |
|---|
| 231 | 498 | * repeated. |
|---|
| 232 | 499 | */ |
|---|