summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2016-08-22 17:11:27 +0200
committerchrome-bot <chrome-bot@chromium.org>2016-09-01 19:52:35 -0700
commit02b80c49f473b872360a782f6a95c607c6734717 (patch)
tree4c4e9b53f264b81d57206a0035a3ce8adbf323a2 /include
parentf4863ef03d76fc3923c49bccdfaf28b47ddc80f9 (diff)
downloadchrome-ec-02b80c49f473b872360a782f6a95c607c6734717.tar.gz
pd: manage total source current available
Add a policy to handle the case where the device can source the `CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT` over one of its type-C port if there is no sink connected on the other ones. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:56110 TEST=manual: on Kevin, plug and unplug various devices on the 2 ports, while measuring the type-C pull-up with Twinkie. Change-Id: Id5961f04d0a1b1073f5ab340068efd9079918209 Reviewed-on: https://chromium-review.googlesource.com/373818 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/charge_manager.h11
-rw-r--r--include/config.h8
-rw-r--r--include/usb_pd.h22
3 files changed, 32 insertions, 9 deletions
diff --git a/include/charge_manager.h b/include/charge_manager.h
index 28546e22a1..7427d12aca 100644
--- a/include/charge_manager.h
+++ b/include/charge_manager.h
@@ -91,6 +91,17 @@ int charge_manager_get_charger_current(void);
void charge_manager_save_log(int port);
#endif
+/* Update whether a given port is sourcing current. */
+void charge_manager_source_port(int port, int enable);
+
+/*
+ * Get PD source power data objects.
+ *
+ * @param src_pdo pointer to the data to return.
+ * @return number of PDOs returned.
+ */
+int charge_manager_get_source_pdo(const uint32_t **src_pdo);
+
/* Board-level callback functions */
/*
diff --git a/include/config.h b/include/config.h
index 0228dd439b..56c0088990 100644
--- a/include/config.h
+++ b/include/config.h
@@ -2165,6 +2165,14 @@
/* Default pull-up value on the USB-C ports when they are used as source. */
#define CONFIG_USB_PD_PULLUP TYPEC_RP_1A5
+/*
+ * Override the pull-up value when only zero or one port is actively sourcing
+ * current and we can advertise more current than what is defined by
+ * `CONFIG_USB_PD_PULLUP`.
+ * Should be defined with one of the tcpc_rp_value.
+ */
+#undef CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT
+
/******************************************************************************/
/* USB port switch */
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 00b149475b..28a94efdb3 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -701,6 +701,7 @@ enum pd_states {
#define PD_FLAGS_VCONN_ON (1 << 12)/* vconn is being sourced */
#define PD_FLAGS_TRY_SRC (1 << 13)/* Try.SRC states are active */
#define PD_FLAGS_PARTNER_USB_COMM (1 << 14)/* port partner is USB comms */
+#define PD_FLAGS_UPDATE_SRC_CAPS (1 << 15)/* send new source capabilities */
/* Flags to clear on a disconnect */
#define PD_FLAGS_RESET_ON_DISCONNECT_MASK (PD_FLAGS_PARTNER_DR_POWER | \
PD_FLAGS_PARTNER_DR_DATA | \
@@ -713,7 +714,8 @@ enum pd_states {
PD_FLAGS_PARTNER_EXTPOWER | \
PD_FLAGS_VCONN_ON | \
PD_FLAGS_TRY_SRC | \
- PD_FLAGS_PARTNER_USB_COMM)
+ PD_FLAGS_PARTNER_USB_COMM | \
+ PD_FLAGS_UPDATE_SRC_CAPS)
enum pd_cc_states {
@@ -970,6 +972,14 @@ void pd_set_external_voltage_limit(int port, int mv);
void pd_set_input_current_limit(int port, uint32_t max_ma,
uint32_t supply_voltage);
+
+/**
+ * Update the power contract if it exists.
+ *
+ * @param port USB-C port number.
+ */
+void pd_update_contract(int port);
+
/**
* Set the type-C input current limit.
*
@@ -1201,18 +1211,12 @@ void pd_send_vdm(int port, uint32_t vid, int cmd, const uint32_t *data,
/* Power Data Objects for the source and the sink */
extern const uint32_t pd_src_pdo[];
extern const int pd_src_pdo_cnt;
+extern const uint32_t pd_src_pdo_max[];
+extern const int pd_src_pdo_max_cnt;
extern const uint32_t pd_snk_pdo[];
extern const int pd_snk_pdo_cnt;
/**
- * Get PD source power data objects.
- *
- * @param src_pdo pointer to the data to return.
- * @return number of PDOs returned.
- */
-int pd_get_source_pdo(const uint32_t **src_pdo);
-
-/**
* Request that a host event be sent to notify the AP of a PD power event.
*
* @param mask host event mask.