diff options
author | Ayushee <ayushee.shah@intel.com> | 2019-06-20 22:53:18 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-16 06:32:49 +0000 |
commit | 91be7060d7694eedb53ce73b39bc7423a3814536 (patch) | |
tree | 4c236211331689195ee8c02854e6b0b6d63cbf83 /include | |
parent | d731e31bce43a8616bff235626bc69f71712bc7a (diff) | |
download | chrome-ec-91be7060d7694eedb53ce73b39bc7423a3814536.tar.gz |
usb_pd: Adding USB-C cable detection
When a discover identity command is sent with a SOP prime
packet, the cable plug of an emark cable responds with the
cable attribute.
Added a structure pd_cable that stores the cable type and
and resetting it when the cable is disconnected. Also added
console command that gives the type of cable connected.
Host(DFP) Cable Port-Partner(UFP)
-------------------------EXPLICIT CONTRACT------------------------
Discover Identity SOP ----------------------------->
request |
<------------------------- Discover Identity
response
Discover Identity SOP' --------->
request |
(If Emark Cable)
<------------ Discover Identity SOP'
| response
Store cable type |
(If Non-Emark Cable)
<-------------- No response
|
Discover SVID SOP
request ------------------------------------>
(Rest of the PD flow)
BUG=b:129990370
BRANCH=none
TEST=Verified on dragonegg, able to get cable response
Change-Id: I2536cf24d58f7ee5ff462b34fc32f69d7a200d41
Signed-off-by: Ayushee <ayushee.shah@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1707851
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/usb_pd.h | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/include/usb_pd.h b/include/usb_pd.h index 3f693e40f0..2173c6d193 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -410,14 +410,17 @@ struct pd_policy { * <25:16> :: SBZ * <15:0> :: USB-IF assigned VID for this cable vendor */ -#define IDH_PTYPE_UNDEF 0 -#define IDH_PTYPE_HUB 1 -#define IDH_PTYPE_PERIPH 2 -#define IDH_PTYPE_PCABLE 3 -#define IDH_PTYPE_ACABLE 4 -#define IDH_PTYPE_AMA 5 -#define IDH_PTYPE_VPD 6 +enum idh_ptype { + IDH_PTYPE_UNDEF, + IDH_PTYPE_HUB, + IDH_PTYPE_PERIPH, + IDH_PTYPE_PCABLE, + IDH_PTYPE_ACABLE, + IDH_PTYPE_AMA, + IDH_PTYPE_VPD, + IDH_PTYPE_COUNT, +}; #define VDO_IDH(usbh, usbd, ptype, is_modal, vid) \ ((usbh) << 31 | (usbd) << 30 | ((ptype) & 0x7) << 27 \ | (is_modal) << 26 | ((vid) & 0xffff)) @@ -480,6 +483,17 @@ struct pd_policy { | ((cur) & 0x3) << 5 | (vps) << 4 | (sopp) << 3 \ | ((usbss) & 0x7)) +/* Cable structure for storing cable attributes */ +struct pd_cable { + /* Type of cable */ + enum idh_ptype type; + /* Cable flags. See CABLE_FLAGS_* */ + uint8_t flags; +}; + +/* Flag for sending SOP Prime packet */ +#define CABLE_FLAGS_SOP_PRIME_ENABLE BIT(0) + /* * AMA VDO * --------- @@ -1534,6 +1548,25 @@ uint16_t pd_get_identity_vid(int port); uint16_t pd_get_identity_pid(int port); /** + * Returns the status of cable flag - CABLE_FLAGS_SOP_PRIME_ENABLE + * + * @param port USB-C port number + * @param data_role current data role + * @param pd_flags current pd flags + * @return For rev3.0, true if vconn is on + * For rev2.0, true if vconn is on and data_role is dfp + * False otherwise + */ +uint8_t is_sop_prime_ready(int port, uint8_t data_role, uint32_t pd_flags); + +/** + * Reset Cable type, Cable attributes and cable flags + * + * @param port USB-C port number + */ +void reset_pd_cable(int port); + +/** * Store Device ID & RW hash of device * * @param port USB-C port number |