summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-08-18 11:14:05 -0600
committerCommit Bot <commit-bot@chromium.org>2020-09-03 00:20:23 +0000
commit147803fd0f6785692c215e49d31b948ac871acb5 (patch)
tree3d53fead81e92c801adffe697ad4c8603e6e3572 /include
parent9ca75e89ce2d4af265d8f34f20d5892680bfa38d (diff)
downloadchrome-ec-147803fd0f6785692c215e49d31b948ac871acb5.tar.gz
TCPMv2: Add EC_CMD_TYPEC_DISCOVERY
This host command will return all discovery information for the given port and transmit type (SOP, SOP'). Each piece of information includes a count of the number of valid fields filled in to the arrays. To keep the command consolidated and easy to parse, this means there will be some number of bytes in each response which do not contain useful information. With this method, we may fit 7 SVID entries with mode information, which is less than the 16 which the EC can store, but more than most port partners present. BRANCH=None BUG=b:165264379 TEST=on waddledoo, confirm ectool shows: -no discovery information with nothing plugged in -no discovery information with a charger which doesn't reply to VDMs -SOP identity but no SVIDs with Moshi, which NAKs DiscoverSVIDs -SOP identity and all SVIDs with Apple 3-in-1 -SOP and SOP' identity and all SVIDs with TBT dock Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Idf21b23ebe4cda62781762188601b2cc35ede65d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363417 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/ec_commands.h37
-rw-r--r--include/usb_pd.h26
2 files changed, 63 insertions, 0 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h
index ade22a2f99..8e9b8b236f 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -6314,6 +6314,43 @@ struct ec_response_regulator_get_voltage {
uint32_t voltage_mv;
} __ec_align4;
+/*
+ * Gather all discovery information for the given port and partner type.
+ *
+ * Note that if discovery has not yet completed, only the currently completed
+ * responses will be filled in. If the discovery data structures are changed
+ * in the process of the command running, BUSY will be returned.
+ *
+ * VDO field sizes are set to the maximum possible number of VDOs a VDM may
+ * contain, while the number of SVIDs here is selected to fit within the PROTO2
+ * maximum parameter size.
+ */
+#define EC_CMD_TYPEC_DISCOVERY 0x0131
+
+enum typec_partner_type {
+ TYPEC_PARTNER_SOP = 0,
+ TYPEC_PARTNER_SOP_PRIME = 1,
+};
+
+struct ec_params_typec_discovery {
+ uint8_t port;
+ uint8_t partner_type; /* enum typec_partner_type */
+} __ec_align1;
+
+struct svid_mode_info {
+ uint16_t svid;
+ uint16_t mode_count; /* Number of modes partner sent */
+ uint32_t mode_vdo[6]; /* Max VDOs allowed after VDM header is 6 */
+};
+
+struct ec_response_typec_discovery {
+ uint8_t identity_count; /* Number of identity VDOs partner sent */
+ uint8_t svid_count; /* Number of SVIDs partner sent */
+ uint16_t reserved;
+ uint32_t discovery_vdo[6]; /* Max VDOs allowed after VDM header is 6 */
+ struct svid_mode_info svids[0];
+} __ec_align1;
+
/*****************************************************************************/
/* The command range 0x200-0x2FF is reserved for Rotor. */
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 67de78a3ac..b546a286f4 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -1908,9 +1908,35 @@ bool consume_sop_prime_repeat_msg(int port, uint8_t msg_id);
bool consume_sop_prime_prime_repeat_msg(int port, uint8_t msg_id);
/*
+ * Clears record of which tasks have accessed discovery data for this port and
+ * type.
+ *
+ * @param port USB-C port number
+ * @param type Transmit type (SOP, SOP')
+ */
+void pd_discovery_access_clear(int port, enum tcpm_transmit_type type);
+
+/*
+ * Validate that this current task is the only one which has retrieved the
+ * pointer from pd_get_am_discovery() since last call to
+ * pd_discovery_access_clear().
+ *
+ * @param port USB-C port number
+ * @param type Transmit type (SOP, SOP')
+ * @return True - No other tasks have accessed the data
+ */
+bool pd_discovery_access_validate(int port, enum tcpm_transmit_type type);
+
+/*
* Returns the pointer to PD alternate mode discovery results
+ *
* Note: Caller function can mutate the data in this structure.
*
+ * TCPMv2 will track all tasks which call this function after the most recent
+ * pd_discovery_access_clear(), so that the host command task reading out this
+ * structure may run pd_discovery_access_validate() at the end of its read to
+ * verify whether data might have changed in that timeframe.
+ *
* @param port USB-C port number
* @param type Transmit type (SOP, SOP') for discovered information
* @return pointer to PD alternate mode discovery results