162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __DT_POWER_DELIVERY_H 362306a36Sopenharmony_ci#define __DT_POWER_DELIVERY_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci/* Power delivery Power Data Object definitions */ 662306a36Sopenharmony_ci#define PDO_TYPE_FIXED 0 762306a36Sopenharmony_ci#define PDO_TYPE_BATT 1 862306a36Sopenharmony_ci#define PDO_TYPE_VAR 2 962306a36Sopenharmony_ci#define PDO_TYPE_APDO 3 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define PDO_TYPE_SHIFT 30 1262306a36Sopenharmony_ci#define PDO_TYPE_MASK 0x3 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#define PDO_TYPE(t) ((t) << PDO_TYPE_SHIFT) 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define PDO_VOLT_MASK 0x3ff 1762306a36Sopenharmony_ci#define PDO_CURR_MASK 0x3ff 1862306a36Sopenharmony_ci#define PDO_PWR_MASK 0x3ff 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define PDO_FIXED_DUAL_ROLE (1 << 29) /* Power role swap supported */ 2162306a36Sopenharmony_ci#define PDO_FIXED_SUSPEND (1 << 28) /* USB Suspend supported (Source) */ 2262306a36Sopenharmony_ci#define PDO_FIXED_HIGHER_CAP (1 << 28) /* Requires more than vSafe5V (Sink) */ 2362306a36Sopenharmony_ci#define PDO_FIXED_EXTPOWER (1 << 27) /* Externally powered */ 2462306a36Sopenharmony_ci#define PDO_FIXED_USB_COMM (1 << 26) /* USB communications capable */ 2562306a36Sopenharmony_ci#define PDO_FIXED_DATA_SWAP (1 << 25) /* Data role swap supported */ 2662306a36Sopenharmony_ci#define PDO_FIXED_VOLT_SHIFT 10 /* 50mV units */ 2762306a36Sopenharmony_ci#define PDO_FIXED_CURR_SHIFT 0 /* 10mA units */ 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define PDO_FIXED_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_FIXED_VOLT_SHIFT) 3062306a36Sopenharmony_ci#define PDO_FIXED_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_FIXED_CURR_SHIFT) 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define PDO_FIXED(mv, ma, flags) \ 3362306a36Sopenharmony_ci (PDO_TYPE(PDO_TYPE_FIXED) | (flags) | \ 3462306a36Sopenharmony_ci PDO_FIXED_VOLT(mv) | PDO_FIXED_CURR(ma)) 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci#define VSAFE5V 5000 /* mv units */ 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#define PDO_BATT_MAX_VOLT_SHIFT 20 /* 50mV units */ 3962306a36Sopenharmony_ci#define PDO_BATT_MIN_VOLT_SHIFT 10 /* 50mV units */ 4062306a36Sopenharmony_ci#define PDO_BATT_MAX_PWR_SHIFT 0 /* 250mW units */ 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define PDO_BATT_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MIN_VOLT_SHIFT) 4362306a36Sopenharmony_ci#define PDO_BATT_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MAX_VOLT_SHIFT) 4462306a36Sopenharmony_ci#define PDO_BATT_MAX_POWER(mw) ((((mw) / 250) & PDO_PWR_MASK) << PDO_BATT_MAX_PWR_SHIFT) 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci#define PDO_BATT(min_mv, max_mv, max_mw) \ 4762306a36Sopenharmony_ci (PDO_TYPE(PDO_TYPE_BATT) | PDO_BATT_MIN_VOLT(min_mv) | \ 4862306a36Sopenharmony_ci PDO_BATT_MAX_VOLT(max_mv) | PDO_BATT_MAX_POWER(max_mw)) 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci#define PDO_VAR_MAX_VOLT_SHIFT 20 /* 50mV units */ 5162306a36Sopenharmony_ci#define PDO_VAR_MIN_VOLT_SHIFT 10 /* 50mV units */ 5262306a36Sopenharmony_ci#define PDO_VAR_MAX_CURR_SHIFT 0 /* 10mA units */ 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#define PDO_VAR_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) 5562306a36Sopenharmony_ci#define PDO_VAR_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT) 5662306a36Sopenharmony_ci#define PDO_VAR_MAX_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT) 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#define PDO_VAR(min_mv, max_mv, max_ma) \ 5962306a36Sopenharmony_ci (PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) | \ 6062306a36Sopenharmony_ci PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma)) 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci#define APDO_TYPE_PPS 0 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci#define PDO_APDO_TYPE_SHIFT 28 /* Only valid value currently is 0x0 - PPS */ 6562306a36Sopenharmony_ci#define PDO_APDO_TYPE_MASK 0x3 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#define PDO_APDO_TYPE(t) ((t) << PDO_APDO_TYPE_SHIFT) 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define PDO_PPS_APDO_MAX_VOLT_SHIFT 17 /* 100mV units */ 7062306a36Sopenharmony_ci#define PDO_PPS_APDO_MIN_VOLT_SHIFT 8 /* 100mV units */ 7162306a36Sopenharmony_ci#define PDO_PPS_APDO_MAX_CURR_SHIFT 0 /* 50mA units */ 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define PDO_PPS_APDO_VOLT_MASK 0xff 7462306a36Sopenharmony_ci#define PDO_PPS_APDO_CURR_MASK 0x7f 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define PDO_PPS_APDO_MIN_VOLT(mv) \ 7762306a36Sopenharmony_ci ((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MIN_VOLT_SHIFT) 7862306a36Sopenharmony_ci#define PDO_PPS_APDO_MAX_VOLT(mv) \ 7962306a36Sopenharmony_ci ((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MAX_VOLT_SHIFT) 8062306a36Sopenharmony_ci#define PDO_PPS_APDO_MAX_CURR(ma) \ 8162306a36Sopenharmony_ci ((((ma) / 50) & PDO_PPS_APDO_CURR_MASK) << PDO_PPS_APDO_MAX_CURR_SHIFT) 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#define PDO_PPS_APDO(min_mv, max_mv, max_ma) \ 8462306a36Sopenharmony_ci (PDO_TYPE(PDO_TYPE_APDO) | PDO_APDO_TYPE(APDO_TYPE_PPS) | \ 8562306a36Sopenharmony_ci PDO_PPS_APDO_MIN_VOLT(min_mv) | PDO_PPS_APDO_MAX_VOLT(max_mv) | \ 8662306a36Sopenharmony_ci PDO_PPS_APDO_MAX_CURR(max_ma)) 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci /* 8962306a36Sopenharmony_ci * Based on "Table 6-14 Fixed Supply PDO - Sink" of "USB Power Delivery Specification Revision 3.0, 9062306a36Sopenharmony_ci * Version 1.2" 9162306a36Sopenharmony_ci * Initial current capability of the new source when vSafe5V is applied. 9262306a36Sopenharmony_ci */ 9362306a36Sopenharmony_ci#define FRS_DEFAULT_POWER 1 9462306a36Sopenharmony_ci#define FRS_5V_1P5A 2 9562306a36Sopenharmony_ci#define FRS_5V_3A 3 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci/* 9862306a36Sopenharmony_ci * SVDM Identity Header 9962306a36Sopenharmony_ci * -------------------- 10062306a36Sopenharmony_ci * <31> :: data capable as a USB host 10162306a36Sopenharmony_ci * <30> :: data capable as a USB device 10262306a36Sopenharmony_ci * <29:27> :: product type (UFP / Cable / VPD) 10362306a36Sopenharmony_ci * <26> :: modal operation supported (1b == yes) 10462306a36Sopenharmony_ci * <25:23> :: product type (DFP) (SVDM version 2.0+ only; set to zero in version 1.0) 10562306a36Sopenharmony_ci * <22:21> :: connector type (SVDM version 2.0+ only; set to zero in version 1.0) 10662306a36Sopenharmony_ci * <20:16> :: Reserved, Shall be set to zero 10762306a36Sopenharmony_ci * <15:0> :: USB-IF assigned VID for this cable vendor 10862306a36Sopenharmony_ci */ 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* PD Rev2.0 definition */ 11162306a36Sopenharmony_ci#define IDH_PTYPE_UNDEF 0 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci/* SOP Product Type (UFP) */ 11462306a36Sopenharmony_ci#define IDH_PTYPE_NOT_UFP 0 11562306a36Sopenharmony_ci#define IDH_PTYPE_HUB 1 11662306a36Sopenharmony_ci#define IDH_PTYPE_PERIPH 2 11762306a36Sopenharmony_ci#define IDH_PTYPE_PSD 3 11862306a36Sopenharmony_ci#define IDH_PTYPE_AMA 5 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci/* SOP' Product Type (Cable Plug / VPD) */ 12162306a36Sopenharmony_ci#define IDH_PTYPE_NOT_CABLE 0 12262306a36Sopenharmony_ci#define IDH_PTYPE_PCABLE 3 12362306a36Sopenharmony_ci#define IDH_PTYPE_ACABLE 4 12462306a36Sopenharmony_ci#define IDH_PTYPE_VPD 6 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci/* SOP Product Type (DFP) */ 12762306a36Sopenharmony_ci#define IDH_PTYPE_NOT_DFP 0 12862306a36Sopenharmony_ci#define IDH_PTYPE_DFP_HUB 1 12962306a36Sopenharmony_ci#define IDH_PTYPE_DFP_HOST 2 13062306a36Sopenharmony_ci#define IDH_PTYPE_DFP_PB 3 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci#define VDO_IDH(usbh, usbd, ufp_cable, is_modal, dfp, conn, vid) \ 13362306a36Sopenharmony_ci ((usbh) << 31 | (usbd) << 30 | ((ufp_cable) & 0x7) << 27 \ 13462306a36Sopenharmony_ci | (is_modal) << 26 | ((dfp) & 0x7) << 23 | ((conn) & 0x3) << 21 \ 13562306a36Sopenharmony_ci | ((vid) & 0xffff)) 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci/* 13862306a36Sopenharmony_ci * Cert Stat VDO 13962306a36Sopenharmony_ci * ------------- 14062306a36Sopenharmony_ci * <31:0> : USB-IF assigned XID for this cable 14162306a36Sopenharmony_ci */ 14262306a36Sopenharmony_ci#define VDO_CERT(xid) ((xid) & 0xffffffff) 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci/* 14562306a36Sopenharmony_ci * Product VDO 14662306a36Sopenharmony_ci * ----------- 14762306a36Sopenharmony_ci * <31:16> : USB Product ID 14862306a36Sopenharmony_ci * <15:0> : USB bcdDevice 14962306a36Sopenharmony_ci */ 15062306a36Sopenharmony_ci#define VDO_PRODUCT(pid, bcd) (((pid) & 0xffff) << 16 | ((bcd) & 0xffff)) 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci/* 15362306a36Sopenharmony_ci * UFP VDO (PD Revision 3.0+ only) 15462306a36Sopenharmony_ci * -------- 15562306a36Sopenharmony_ci * <31:29> :: UFP VDO version 15662306a36Sopenharmony_ci * <28> :: Reserved 15762306a36Sopenharmony_ci * <27:24> :: Device capability 15862306a36Sopenharmony_ci * <23:22> :: Connector type (10b == receptacle, 11b == captive plug) 15962306a36Sopenharmony_ci * <21:11> :: Reserved 16062306a36Sopenharmony_ci * <10:8> :: Vconn power (AMA only) 16162306a36Sopenharmony_ci * <7> :: Vconn required (AMA only, 0b == no, 1b == yes) 16262306a36Sopenharmony_ci * <6> :: Vbus required (AMA only, 0b == yes, 1b == no) 16362306a36Sopenharmony_ci * <5:3> :: Alternate modes 16462306a36Sopenharmony_ci * <2:0> :: USB highest speed 16562306a36Sopenharmony_ci */ 16662306a36Sopenharmony_ci/* UFP VDO Version */ 16762306a36Sopenharmony_ci#define UFP_VDO_VER1_2 2 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci/* Device Capability */ 17062306a36Sopenharmony_ci#define DEV_USB2_CAPABLE (1 << 0) 17162306a36Sopenharmony_ci#define DEV_USB2_BILLBOARD (1 << 1) 17262306a36Sopenharmony_ci#define DEV_USB3_CAPABLE (1 << 2) 17362306a36Sopenharmony_ci#define DEV_USB4_CAPABLE (1 << 3) 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci/* Connector Type */ 17662306a36Sopenharmony_ci#define UFP_RECEPTACLE 2 17762306a36Sopenharmony_ci#define UFP_CAPTIVE 3 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci/* Vconn Power (AMA only, set to AMA_VCONN_NOT_REQ if Vconn is not required) */ 18062306a36Sopenharmony_ci#define AMA_VCONN_PWR_1W 0 18162306a36Sopenharmony_ci#define AMA_VCONN_PWR_1W5 1 18262306a36Sopenharmony_ci#define AMA_VCONN_PWR_2W 2 18362306a36Sopenharmony_ci#define AMA_VCONN_PWR_3W 3 18462306a36Sopenharmony_ci#define AMA_VCONN_PWR_4W 4 18562306a36Sopenharmony_ci#define AMA_VCONN_PWR_5W 5 18662306a36Sopenharmony_ci#define AMA_VCONN_PWR_6W 6 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci/* Vconn Required (AMA only) */ 18962306a36Sopenharmony_ci#define AMA_VCONN_NOT_REQ 0 19062306a36Sopenharmony_ci#define AMA_VCONN_REQ 1 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci/* Vbus Required (AMA only) */ 19362306a36Sopenharmony_ci#define AMA_VBUS_REQ 0 19462306a36Sopenharmony_ci#define AMA_VBUS_NOT_REQ 1 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci/* Alternate Modes */ 19762306a36Sopenharmony_ci#define UFP_ALTMODE_NOT_SUPP 0 19862306a36Sopenharmony_ci#define UFP_ALTMODE_TBT3 (1 << 0) 19962306a36Sopenharmony_ci#define UFP_ALTMODE_RECFG (1 << 1) 20062306a36Sopenharmony_ci#define UFP_ALTMODE_NO_RECFG (1 << 2) 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci/* USB Highest Speed */ 20362306a36Sopenharmony_ci#define UFP_USB2_ONLY 0 20462306a36Sopenharmony_ci#define UFP_USB32_GEN1 1 20562306a36Sopenharmony_ci#define UFP_USB32_4_GEN2 2 20662306a36Sopenharmony_ci#define UFP_USB4_GEN3 3 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci#define VDO_UFP(ver, cap, conn, vcpwr, vcr, vbr, alt, spd) \ 20962306a36Sopenharmony_ci (((ver) & 0x7) << 29 | ((cap) & 0xf) << 24 | ((conn) & 0x3) << 22 \ 21062306a36Sopenharmony_ci | ((vcpwr) & 0x7) << 8 | (vcr) << 7 | (vbr) << 6 | ((alt) & 0x7) << 3 \ 21162306a36Sopenharmony_ci | ((spd) & 0x7)) 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci/* 21462306a36Sopenharmony_ci * DFP VDO (PD Revision 3.0+ only) 21562306a36Sopenharmony_ci * -------- 21662306a36Sopenharmony_ci * <31:29> :: DFP VDO version 21762306a36Sopenharmony_ci * <28:27> :: Reserved 21862306a36Sopenharmony_ci * <26:24> :: Host capability 21962306a36Sopenharmony_ci * <23:22> :: Connector type (10b == receptacle, 11b == captive plug) 22062306a36Sopenharmony_ci * <21:5> :: Reserved 22162306a36Sopenharmony_ci * <4:0> :: Port number 22262306a36Sopenharmony_ci */ 22362306a36Sopenharmony_ci#define DFP_VDO_VER1_1 1 22462306a36Sopenharmony_ci#define HOST_USB2_CAPABLE (1 << 0) 22562306a36Sopenharmony_ci#define HOST_USB3_CAPABLE (1 << 1) 22662306a36Sopenharmony_ci#define HOST_USB4_CAPABLE (1 << 2) 22762306a36Sopenharmony_ci#define DFP_RECEPTACLE 2 22862306a36Sopenharmony_ci#define DFP_CAPTIVE 3 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci#define VDO_DFP(ver, cap, conn, pnum) \ 23162306a36Sopenharmony_ci (((ver) & 0x7) << 29 | ((cap) & 0x7) << 24 | ((conn) & 0x3) << 22 \ 23262306a36Sopenharmony_ci | ((pnum) & 0x1f)) 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci/* 23562306a36Sopenharmony_ci * Cable VDO (for both Passive and Active Cable VDO in PD Rev2.0) 23662306a36Sopenharmony_ci * --------- 23762306a36Sopenharmony_ci * <31:28> :: Cable HW version 23862306a36Sopenharmony_ci * <27:24> :: Cable FW version 23962306a36Sopenharmony_ci * <23:20> :: Reserved, Shall be set to zero 24062306a36Sopenharmony_ci * <19:18> :: type-C to Type-A/B/C/Captive (00b == A, 01 == B, 10 == C, 11 == Captive) 24162306a36Sopenharmony_ci * <17> :: Reserved, Shall be set to zero 24262306a36Sopenharmony_ci * <16:13> :: cable latency (0001 == <10ns(~1m length)) 24362306a36Sopenharmony_ci * <12:11> :: cable termination type (11b == both ends active VCONN req) 24462306a36Sopenharmony_ci * <10> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable) 24562306a36Sopenharmony_ci * <9> :: SSTX2 Directionality support 24662306a36Sopenharmony_ci * <8> :: SSRX1 Directionality support 24762306a36Sopenharmony_ci * <7> :: SSRX2 Directionality support 24862306a36Sopenharmony_ci * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A) 24962306a36Sopenharmony_ci * <4> :: Vbus through cable (0b == no, 1b == yes) 25062306a36Sopenharmony_ci * <3> :: SOP" controller present? (0b == no, 1b == yes) 25162306a36Sopenharmony_ci * <2:0> :: USB SS Signaling support 25262306a36Sopenharmony_ci * 25362306a36Sopenharmony_ci * Passive Cable VDO (PD Rev3.0+) 25462306a36Sopenharmony_ci * --------- 25562306a36Sopenharmony_ci * <31:28> :: Cable HW version 25662306a36Sopenharmony_ci * <27:24> :: Cable FW version 25762306a36Sopenharmony_ci * <23:21> :: VDO version 25862306a36Sopenharmony_ci * <20> :: Reserved, Shall be set to zero 25962306a36Sopenharmony_ci * <19:18> :: Type-C to Type-C/Captive (10b == C, 11b == Captive) 26062306a36Sopenharmony_ci * <17> :: Reserved, Shall be set to zero 26162306a36Sopenharmony_ci * <16:13> :: cable latency (0001 == <10ns(~1m length)) 26262306a36Sopenharmony_ci * <12:11> :: cable termination type (10b == Vconn not req, 01b == Vconn req) 26362306a36Sopenharmony_ci * <10:9> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V) 26462306a36Sopenharmony_ci * <8:7> :: Reserved, Shall be set to zero 26562306a36Sopenharmony_ci * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A) 26662306a36Sopenharmony_ci * <4:3> :: Reserved, Shall be set to zero 26762306a36Sopenharmony_ci * <2:0> :: USB highest speed 26862306a36Sopenharmony_ci * 26962306a36Sopenharmony_ci * Active Cable VDO 1 (PD Rev3.0+) 27062306a36Sopenharmony_ci * --------- 27162306a36Sopenharmony_ci * <31:28> :: Cable HW version 27262306a36Sopenharmony_ci * <27:24> :: Cable FW version 27362306a36Sopenharmony_ci * <23:21> :: VDO version 27462306a36Sopenharmony_ci * <20> :: Reserved, Shall be set to zero 27562306a36Sopenharmony_ci * <19:18> :: Connector type (10b == C, 11b == Captive) 27662306a36Sopenharmony_ci * <17> :: Reserved, Shall be set to zero 27762306a36Sopenharmony_ci * <16:13> :: cable latency (0001 == <10ns(~1m length)) 27862306a36Sopenharmony_ci * <12:11> :: cable termination type (10b == one end active, 11b == both ends active VCONN req) 27962306a36Sopenharmony_ci * <10:9> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V) 28062306a36Sopenharmony_ci * <8> :: SBU supported (0b == supported, 1b == not supported) 28162306a36Sopenharmony_ci * <7> :: SBU type (0b == passive, 1b == active) 28262306a36Sopenharmony_ci * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A) 28362306a36Sopenharmony_ci * <4> :: Vbus through cable (0b == no, 1b == yes) 28462306a36Sopenharmony_ci * <3> :: SOP" controller present? (0b == no, 1b == yes) 28562306a36Sopenharmony_ci * <2:0> :: USB highest speed 28662306a36Sopenharmony_ci */ 28762306a36Sopenharmony_ci/* Cable VDO Version */ 28862306a36Sopenharmony_ci#define CABLE_VDO_VER1_0 0 28962306a36Sopenharmony_ci#define CABLE_VDO_VER1_3 3 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci/* Connector Type (_ATYPE and _BTYPE are for PD Rev2.0 only) */ 29262306a36Sopenharmony_ci#define CABLE_ATYPE 0 29362306a36Sopenharmony_ci#define CABLE_BTYPE 1 29462306a36Sopenharmony_ci#define CABLE_CTYPE 2 29562306a36Sopenharmony_ci#define CABLE_CAPTIVE 3 29662306a36Sopenharmony_ci 29762306a36Sopenharmony_ci/* Cable Latency */ 29862306a36Sopenharmony_ci#define CABLE_LATENCY_1M 1 29962306a36Sopenharmony_ci#define CABLE_LATENCY_2M 2 30062306a36Sopenharmony_ci#define CABLE_LATENCY_3M 3 30162306a36Sopenharmony_ci#define CABLE_LATENCY_4M 4 30262306a36Sopenharmony_ci#define CABLE_LATENCY_5M 5 30362306a36Sopenharmony_ci#define CABLE_LATENCY_6M 6 30462306a36Sopenharmony_ci#define CABLE_LATENCY_7M 7 30562306a36Sopenharmony_ci#define CABLE_LATENCY_7M_PLUS 8 30662306a36Sopenharmony_ci 30762306a36Sopenharmony_ci/* Cable Termination Type */ 30862306a36Sopenharmony_ci#define PCABLE_VCONN_NOT_REQ 0 30962306a36Sopenharmony_ci#define PCABLE_VCONN_REQ 1 31062306a36Sopenharmony_ci#define ACABLE_ONE_END 2 31162306a36Sopenharmony_ci#define ACABLE_BOTH_END 3 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ci/* Maximum Vbus Voltage */ 31462306a36Sopenharmony_ci#define CABLE_MAX_VBUS_20V 0 31562306a36Sopenharmony_ci#define CABLE_MAX_VBUS_30V 1 31662306a36Sopenharmony_ci#define CABLE_MAX_VBUS_40V 2 31762306a36Sopenharmony_ci#define CABLE_MAX_VBUS_50V 3 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci/* Active Cable SBU Supported/Type */ 32062306a36Sopenharmony_ci#define ACABLE_SBU_SUPP 0 32162306a36Sopenharmony_ci#define ACABLE_SBU_NOT_SUPP 1 32262306a36Sopenharmony_ci#define ACABLE_SBU_PASSIVE 0 32362306a36Sopenharmony_ci#define ACABLE_SBU_ACTIVE 1 32462306a36Sopenharmony_ci 32562306a36Sopenharmony_ci/* Vbus Current Handling Capability */ 32662306a36Sopenharmony_ci#define CABLE_CURR_DEF 0 32762306a36Sopenharmony_ci#define CABLE_CURR_3A 1 32862306a36Sopenharmony_ci#define CABLE_CURR_5A 2 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_ci/* USB SuperSpeed Signaling Support (PD Rev2.0) */ 33162306a36Sopenharmony_ci#define CABLE_USBSS_U2_ONLY 0 33262306a36Sopenharmony_ci#define CABLE_USBSS_U31_GEN1 1 33362306a36Sopenharmony_ci#define CABLE_USBSS_U31_GEN2 2 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ci/* USB Highest Speed */ 33662306a36Sopenharmony_ci#define CABLE_USB2_ONLY 0 33762306a36Sopenharmony_ci#define CABLE_USB32_GEN1 1 33862306a36Sopenharmony_ci#define CABLE_USB32_4_GEN2 2 33962306a36Sopenharmony_ci#define CABLE_USB4_GEN3 3 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci#define VDO_CABLE(hw, fw, cbl, lat, term, tx1d, tx2d, rx1d, rx2d, cur, vps, sopp, usbss) \ 34262306a36Sopenharmony_ci (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 | ((cbl) & 0x3) << 18 \ 34362306a36Sopenharmony_ci | ((lat) & 0x7) << 13 | ((term) & 0x3) << 11 | (tx1d) << 10 \ 34462306a36Sopenharmony_ci | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7 | ((cur) & 0x3) << 5 \ 34562306a36Sopenharmony_ci | (vps) << 4 | (sopp) << 3 | ((usbss) & 0x7)) 34662306a36Sopenharmony_ci#define VDO_PCABLE(hw, fw, ver, conn, lat, term, vbm, cur, spd) \ 34762306a36Sopenharmony_ci (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \ 34862306a36Sopenharmony_ci | ((conn) & 0x3) << 18 | ((lat) & 0xf) << 13 | ((term) & 0x3) << 11 \ 34962306a36Sopenharmony_ci | ((vbm) & 0x3) << 9 | ((cur) & 0x3) << 5 | ((spd) & 0x7)) 35062306a36Sopenharmony_ci#define VDO_ACABLE1(hw, fw, ver, conn, lat, term, vbm, sbu, sbut, cur, vbt, sopp, spd) \ 35162306a36Sopenharmony_ci (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \ 35262306a36Sopenharmony_ci | ((conn) & 0x3) << 18 | ((lat) & 0xf) << 13 | ((term) & 0x3) << 11 \ 35362306a36Sopenharmony_ci | ((vbm) & 0x3) << 9 | (sbu) << 8 | (sbut) << 7 | ((cur) & 0x3) << 5 \ 35462306a36Sopenharmony_ci | (vbt) << 4 | (sopp) << 3 | ((spd) & 0x7)) 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_ci/* 35762306a36Sopenharmony_ci * Active Cable VDO 2 35862306a36Sopenharmony_ci * --------- 35962306a36Sopenharmony_ci * <31:24> :: Maximum operating temperature 36062306a36Sopenharmony_ci * <23:16> :: Shutdown temperature 36162306a36Sopenharmony_ci * <15> :: Reserved, Shall be set to zero 36262306a36Sopenharmony_ci * <14:12> :: U3/CLd power 36362306a36Sopenharmony_ci * <11> :: U3 to U0 transition mode (0b == direct, 1b == through U3S) 36462306a36Sopenharmony_ci * <10> :: Physical connection (0b == copper, 1b == optical) 36562306a36Sopenharmony_ci * <9> :: Active element (0b == redriver, 1b == retimer) 36662306a36Sopenharmony_ci * <8> :: USB4 supported (0b == yes, 1b == no) 36762306a36Sopenharmony_ci * <7:6> :: USB2 hub hops consumed 36862306a36Sopenharmony_ci * <5> :: USB2 supported (0b == yes, 1b == no) 36962306a36Sopenharmony_ci * <4> :: USB3.2 supported (0b == yes, 1b == no) 37062306a36Sopenharmony_ci * <3> :: USB lanes supported (0b == one lane, 1b == two lanes) 37162306a36Sopenharmony_ci * <2> :: Optically isolated active cable (0b == no, 1b == yes) 37262306a36Sopenharmony_ci * <1> :: Reserved, Shall be set to zero 37362306a36Sopenharmony_ci * <0> :: USB gen (0b == gen1, 1b == gen2+) 37462306a36Sopenharmony_ci */ 37562306a36Sopenharmony_ci/* U3/CLd Power*/ 37662306a36Sopenharmony_ci#define ACAB2_U3_CLD_10MW_PLUS 0 37762306a36Sopenharmony_ci#define ACAB2_U3_CLD_10MW 1 37862306a36Sopenharmony_ci#define ACAB2_U3_CLD_5MW 2 37962306a36Sopenharmony_ci#define ACAB2_U3_CLD_1MW 3 38062306a36Sopenharmony_ci#define ACAB2_U3_CLD_500UW 4 38162306a36Sopenharmony_ci#define ACAB2_U3_CLD_200UW 5 38262306a36Sopenharmony_ci#define ACAB2_U3_CLD_50UW 6 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci/* Other Active Cable VDO 2 Fields */ 38562306a36Sopenharmony_ci#define ACAB2_U3U0_DIRECT 0 38662306a36Sopenharmony_ci#define ACAB2_U3U0_U3S 1 38762306a36Sopenharmony_ci#define ACAB2_PHY_COPPER 0 38862306a36Sopenharmony_ci#define ACAB2_PHY_OPTICAL 1 38962306a36Sopenharmony_ci#define ACAB2_REDRIVER 0 39062306a36Sopenharmony_ci#define ACAB2_RETIMER 1 39162306a36Sopenharmony_ci#define ACAB2_USB4_SUPP 0 39262306a36Sopenharmony_ci#define ACAB2_USB4_NOT_SUPP 1 39362306a36Sopenharmony_ci#define ACAB2_USB2_SUPP 0 39462306a36Sopenharmony_ci#define ACAB2_USB2_NOT_SUPP 1 39562306a36Sopenharmony_ci#define ACAB2_USB32_SUPP 0 39662306a36Sopenharmony_ci#define ACAB2_USB32_NOT_SUPP 1 39762306a36Sopenharmony_ci#define ACAB2_LANES_ONE 0 39862306a36Sopenharmony_ci#define ACAB2_LANES_TWO 1 39962306a36Sopenharmony_ci#define ACAB2_OPT_ISO_NO 0 40062306a36Sopenharmony_ci#define ACAB2_OPT_ISO_YES 1 40162306a36Sopenharmony_ci#define ACAB2_GEN_1 0 40262306a36Sopenharmony_ci#define ACAB2_GEN_2_PLUS 1 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_ci#define VDO_ACABLE2(mtemp, stemp, u3p, trans, phy, ele, u4, hops, u2, u32, lane, iso, gen) \ 40562306a36Sopenharmony_ci (((mtemp) & 0xff) << 24 | ((stemp) & 0xff) << 16 | ((u3p) & 0x7) << 12 \ 40662306a36Sopenharmony_ci | (trans) << 11 | (phy) << 10 | (ele) << 9 | (u4) << 8 \ 40762306a36Sopenharmony_ci | ((hops) & 0x3) << 6 | (u2) << 5 | (u32) << 4 | (lane) << 3 \ 40862306a36Sopenharmony_ci | (iso) << 2 | (gen)) 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ci/* 41162306a36Sopenharmony_ci * AMA VDO (PD Rev2.0) 41262306a36Sopenharmony_ci * --------- 41362306a36Sopenharmony_ci * <31:28> :: Cable HW version 41462306a36Sopenharmony_ci * <27:24> :: Cable FW version 41562306a36Sopenharmony_ci * <23:12> :: Reserved, Shall be set to zero 41662306a36Sopenharmony_ci * <11> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable) 41762306a36Sopenharmony_ci * <10> :: SSTX2 Directionality support 41862306a36Sopenharmony_ci * <9> :: SSRX1 Directionality support 41962306a36Sopenharmony_ci * <8> :: SSRX2 Directionality support 42062306a36Sopenharmony_ci * <7:5> :: Vconn power 42162306a36Sopenharmony_ci * <4> :: Vconn power required 42262306a36Sopenharmony_ci * <3> :: Vbus power required 42362306a36Sopenharmony_ci * <2:0> :: USB SS Signaling support 42462306a36Sopenharmony_ci */ 42562306a36Sopenharmony_ci#define VDO_AMA(hw, fw, tx1d, tx2d, rx1d, rx2d, vcpwr, vcr, vbr, usbss) \ 42662306a36Sopenharmony_ci (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 \ 42762306a36Sopenharmony_ci | (tx1d) << 11 | (tx2d) << 10 | (rx1d) << 9 | (rx2d) << 8 \ 42862306a36Sopenharmony_ci | ((vcpwr) & 0x7) << 5 | (vcr) << 4 | (vbr) << 3 \ 42962306a36Sopenharmony_ci | ((usbss) & 0x7)) 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_ci#define PD_VDO_AMA_VCONN_REQ(vdo) (((vdo) >> 4) & 1) 43262306a36Sopenharmony_ci#define PD_VDO_AMA_VBUS_REQ(vdo) (((vdo) >> 3) & 1) 43362306a36Sopenharmony_ci 43462306a36Sopenharmony_ci#define AMA_USBSS_U2_ONLY 0 43562306a36Sopenharmony_ci#define AMA_USBSS_U31_GEN1 1 43662306a36Sopenharmony_ci#define AMA_USBSS_U31_GEN2 2 43762306a36Sopenharmony_ci#define AMA_USBSS_BBONLY 3 43862306a36Sopenharmony_ci 43962306a36Sopenharmony_ci/* 44062306a36Sopenharmony_ci * VPD VDO 44162306a36Sopenharmony_ci * --------- 44262306a36Sopenharmony_ci * <31:28> :: HW version 44362306a36Sopenharmony_ci * <27:24> :: FW version 44462306a36Sopenharmony_ci * <23:21> :: VDO version 44562306a36Sopenharmony_ci * <20:17> :: Reserved, Shall be set to zero 44662306a36Sopenharmony_ci * <16:15> :: Maximum Vbus voltage (00b == 20V, 01b == 30V, 10b == 40V, 11b == 50V) 44762306a36Sopenharmony_ci * <14> :: Charge through current support (0b == 3A, 1b == 5A) 44862306a36Sopenharmony_ci * <13> :: Reserved, Shall be set to zero 44962306a36Sopenharmony_ci * <12:7> :: Vbus impedance 45062306a36Sopenharmony_ci * <6:1> :: Ground impedance 45162306a36Sopenharmony_ci * <0> :: Charge through support (0b == no, 1b == yes) 45262306a36Sopenharmony_ci */ 45362306a36Sopenharmony_ci#define VPD_VDO_VER1_0 0 45462306a36Sopenharmony_ci#define VPD_MAX_VBUS_20V 0 45562306a36Sopenharmony_ci#define VPD_MAX_VBUS_30V 1 45662306a36Sopenharmony_ci#define VPD_MAX_VBUS_40V 2 45762306a36Sopenharmony_ci#define VPD_MAX_VBUS_50V 3 45862306a36Sopenharmony_ci#define VPDCT_CURR_3A 0 45962306a36Sopenharmony_ci#define VPDCT_CURR_5A 1 46062306a36Sopenharmony_ci#define VPDCT_NOT_SUPP 0 46162306a36Sopenharmony_ci#define VPDCT_SUPP 1 46262306a36Sopenharmony_ci 46362306a36Sopenharmony_ci#define VDO_VPD(hw, fw, ver, vbm, curr, vbi, gi, ct) \ 46462306a36Sopenharmony_ci (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \ 46562306a36Sopenharmony_ci | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \ 46662306a36Sopenharmony_ci | ((gi) & 0x3f) << 1 | (ct)) 46762306a36Sopenharmony_ci 46862306a36Sopenharmony_ci#endif /* __DT_POWER_DELIVERY_H */ 469