summaryrefslogtreecommitdiff
path: root/common/usb_pd_dual_role.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2020-02-11 12:48:46 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-12 20:05:34 +0000
commit0c2d07061c82d718288dbc287ca56b17da2206f9 (patch)
tree51529bc2c06549f5c82037809c530fc1aac23d9d /common/usb_pd_dual_role.c
parentb7f0b4cd0cd42319d204ac653224f3661a463237 (diff)
downloadchrome-ec-0c2d07061c82d718288dbc287ca56b17da2206f9.tar.gz
TCPMv1/v2: Move pd_process_source_cap() to common file
BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I6bd6b5875a322ca4ba6d77a4cfc96a72630e5f5c Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051220 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usb_pd_dual_role.c')
-rw-r--r--common/usb_pd_dual_role.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/common/usb_pd_dual_role.c b/common/usb_pd_dual_role.c
index e4702fbeda..b2b6c25aae 100644
--- a/common/usb_pd_dual_role.c
+++ b/common/usb_pd_dual_role.c
@@ -5,6 +5,7 @@
* Dual Role (Source & Sink) USB-PD module.
*/
+#include "charge_manager.h"
#include "charge_state.h"
#include "usb_common.h"
#include "usb_pd.h"
@@ -281,6 +282,25 @@ void pd_build_request(uint32_t src_cap_cnt, const uint32_t * const src_caps,
*rdo |= RDO_NO_SUSPEND;
}
}
+
+void pd_process_source_cap(int port, int cnt, uint32_t *src_caps)
+{
+ pd_set_src_caps(port, cnt, src_caps);
+
+ if (IS_ENABLED(CONFIG_CHARGE_MANAGER)) {
+ uint32_t ma, mv, pdo;
+
+ /* Get max power info that we could request */
+ pd_find_pdo_index(pd_get_src_cap_cnt(port),
+ pd_get_src_caps(port),
+ PD_MAX_VOLTAGE_MV, &pdo);
+ pd_extract_pdo_power(pdo, &ma, &mv);
+
+ /* Set max. limit, but apply 500mA ceiling */
+ charge_manager_set_ceil(port, CEIL_REQUESTOR_PD, PD_MIN_MA);
+ pd_set_input_current_limit(port, ma, mv);
+ }
+}
#endif /* defined(PD_MAX_VOLTAGE_MV) && defined(PD_OPERATING_POWER_MW) */
int pd_charge_from_device(uint16_t vid, uint16_t pid)