summaryrefslogtreecommitdiff
path: root/board/host/usb_pd_policy.c
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2014-10-15 13:54:13 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-22 02:23:35 +0000
commit7eaa290c35a1ca5571854c7d31a5a125af665b65 (patch)
tree988251431ae31e2fad1079d5e301276e60b78bff /board/host/usb_pd_policy.c
parent93aa23c6856b8b78f2c6a980ad0e82cb802afc3c (diff)
downloadchrome-ec-7eaa290c35a1ca5571854c7d31a5a125af665b65.tar.gz
usb_pd_protocol: Add support for charge_manager and voltage reporting
Integrate charge_manager and include several API changes designed for reporting voltage. 1. Make pd_choose_voltage set the chosen voltage for use by caller. 2. Add voltage parameter to pd_set_input_current. 3. Add pd_get_role to grab the sync / source state of a port. 4. Add charge manager PD + type C port initialization to the pd state machine. BUG=chrome-os-partner:32003 TEST=Manual on samus. Insert Apple charger, verify charge limit is selected appropriately. Insert PD charger, verify that charge port switches to PD port. Remove + reinsert chargers, verify that port / limit is selected appropriately. Remove battery, insert power source, verify that our power source port never becomes disabled. BRANCH=samus Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Idf3198c71d2ddf1e401e766fc82a4b7a02aed068 Reviewed-on: https://chromium-review.googlesource.com/223758 Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'board/host/usb_pd_policy.c')
-rw-r--r--board/host/usb_pd_policy.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/board/host/usb_pd_policy.c b/board/host/usb_pd_policy.c
index 6237f05d5d..c1630aff0d 100644
--- a/board/host/usb_pd_policy.c
+++ b/board/host/usb_pd_policy.c
@@ -26,7 +26,8 @@ const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo);
/* Cap on the max voltage requested as a sink (in millivolts) */
static unsigned max_mv = -1; /* no cap */
-int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo)
+int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo,
+ uint32_t *curr_limit, uint32_t *supply_voltage)
{
int i;
int sel_mv;
@@ -56,14 +57,17 @@ int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo)
if ((src_caps[max_i] & PDO_TYPE_MASK) == PDO_TYPE_BATTERY) {
int uw = 250000 * (src_caps[max_i] & 0x3FF);
*rdo = RDO_BATT(max_i + 1, uw/2, uw, 0);
- CPRINTF("Request [%d] %dV %d/%d mW\n",
- max_i, sel_mv/1000, uw/1000, uw/1000);
+ *curr_limit = uw/sel_mv;
+ CPRINTF("Request [%d] %dV %dmW\n",
+ max_i, sel_mv/1000, uw/1000);
} else {
int ma = 10 * (src_caps[max_i] & 0x3FF);
*rdo = RDO_FIXED(max_i + 1, ma / 2, ma, 0);
- CPRINTF("Request [%d] %dV %d/%d mA\n",
- max_i, sel_mv/1000, max_i, ma/2, ma);
+ *curr_limit = ma;
+ CPRINTF("Request [%d] %dV %dmA\n",
+ max_i, sel_mv/1000, ma);
}
+ *supply_voltage = sel_mv;
return EC_SUCCESS;
}
@@ -109,7 +113,8 @@ void pd_power_supply_reset(int port)
/* Not implemented */
}
-void pd_set_input_current_limit(int port, uint32_t max_ma)
+void pd_set_input_current_limit(int port, uint32_t max_ma,
+ uint32_t supply_voltage)
{
/* Not implemented */
}