diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-05-11 17:31:16 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-27 02:39:41 +0000 |
commit | 5b5f737d8f6f1be15d4ab5f42f290d20576307c4 (patch) | |
tree | be384973f533436d9a53c46b742be35f5b377a4f /test | |
parent | 25ce43fc3d35669500d74e44f3b7c96302ee2ade (diff) | |
download | chrome-ec-5b5f737d8f6f1be15d4ab5f42f290d20576307c4.tar.gz |
pd: move non-phy layer config out of usb_pd_config.h
Move parts of usb_pd_config.h that are not part of the phy layer
out of usb_pd_config.h and into board.h. This cleans up the
division between the TCPC and TCPM as only the TCPC needs to
use usb_pd_config.h.
Also cleans up the use of the CC detection voltage thresholds
by creating standard macros to use based on Rp strength for the
board.
BUG=none
BRANCH=none
TEST=make -j buildall
Change-Id: I946cceb38bea8233095b8a4b287102bb8a3a296d
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270337
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/charge_manager.c | 15 | ||||
-rw-r--r-- | test/test_config.h | 3 | ||||
-rw-r--r-- | test/usb_pd.c | 15 |
3 files changed, 17 insertions, 16 deletions
diff --git a/test/charge_manager.c b/test/charge_manager.c index d504d9daf5..a2a366750c 100644 --- a/test/charge_manager.c +++ b/test/charge_manager.c @@ -11,7 +11,6 @@ #include "test_util.h" #include "timer.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "util.h" #define CHARGE_MANAGER_SLEEP_MS 50 @@ -33,8 +32,8 @@ BUILD_ASSERT(ARRAY_SIZE(supplier_priority) == CHARGE_SUPPLIER_COUNT); static unsigned int active_charge_limit = CHARGE_SUPPLIER_NONE; static unsigned int active_charge_port = CHARGE_PORT_NONE; static unsigned int charge_port_to_reject = CHARGE_PORT_NONE; -static int new_power_request[PD_PORT_COUNT]; -static int power_role[PD_PORT_COUNT]; +static int new_power_request[CONFIG_USB_PD_PORT_COUNT]; +static int power_role[CONFIG_USB_PD_PORT_COUNT]; /* Callback functions called by CM on state change */ void board_set_charge_limit(int charge_ma) @@ -70,7 +69,7 @@ void pd_set_new_power_request(int port) static void clear_new_power_requests(void) { int i; - for (i = 0; i < PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) new_power_request[i] = 0; } @@ -107,7 +106,7 @@ static void initialize_charge_table(int current, int voltage, int ceil) charge.current = current; charge.voltage = voltage; - for (i = 0; i < PD_PORT_COUNT; ++i) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) { charge_manager_set_ceil(i, ceil); charge_manager_update_dualrole(i, CAP_DEDICATED); pd_set_role(i, PD_ROLE_SINK); @@ -132,12 +131,12 @@ static int test_initialization(void) /* Initialize all supplier/port pairs, except for the last one */ for (i = 0; i < CHARGE_SUPPLIER_COUNT; ++i) - for (j = 0; j < PD_PORT_COUNT; ++j) { + for (j = 0; j < CONFIG_USB_PD_PORT_COUNT; ++j) { if (i == 0) charge_manager_update_dualrole(j, CAP_DEDICATED); if (i == CHARGE_SUPPLIER_COUNT - 1 && - j == PD_PORT_COUNT - 1) + j == CONFIG_USB_PD_PORT_COUNT - 1) break; charge_manager_update_charge(i, j, &charge); } @@ -148,7 +147,7 @@ static int test_initialization(void) /* Update last pair and verify a charge port has been selected */ charge_manager_update_charge(CHARGE_SUPPLIER_COUNT-1, - PD_PORT_COUNT-1, + CONFIG_USB_PD_PORT_COUNT-1, &charge); wait_for_charge_manager_refresh(); TEST_ASSERT(active_charge_port != CHARGE_PORT_NONE); diff --git a/test/test_config.h b/test/test_config.h index 6117a6c0dc..39746787b5 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -130,6 +130,7 @@ int board_discharge_on_ac(int enabled); #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_CUSTOM_VDM #define CONFIG_USB_PD_DUAL_ROLE +#define CONFIG_USB_PD_PORT_COUNT 2 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_SHA256 @@ -139,10 +140,12 @@ int board_discharge_on_ac(int enabled); #ifdef TEST_CHARGE_MANAGER #define CONFIG_CHARGE_MANAGER #define CONFIG_USB_PD_DUAL_ROLE +#define CONFIG_USB_PD_PORT_COUNT 2 #endif #ifdef TEST_CHARGE_RAMP #define CONFIG_CHARGE_RAMP +#define CONFIG_USB_PD_PORT_COUNT 2 #endif #endif /* TEST_BUILD */ diff --git a/test/usb_pd.c b/test/usb_pd.c index 4fb38d1916..2a8f73a684 100644 --- a/test/usb_pd.c +++ b/test/usb_pd.c @@ -11,7 +11,6 @@ #include "test_util.h" #include "timer.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "usb_pd_test_util.h" #include "util.h" @@ -23,7 +22,7 @@ struct pd_port_t { int polarity; int partner_role; /* -1 for none */ int partner_polarity; -} pd_port[PD_PORT_COUNT]; +} pd_port[CONFIG_USB_PD_PORT_COUNT]; /* Mock functions */ @@ -86,7 +85,7 @@ static void init_ports(void) { int i; - for (i = 0; i < PD_PORT_COUNT; ++i) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) { pd_port[i].host_mode = 0; pd_port[i].partner_role = -1; pd_port[i].has_vbus = 0; @@ -157,7 +156,7 @@ static void unplug(int port) { pd_port[port].has_vbus = 0; pd_port[port].partner_role = -1; - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); usleep(30 * MSEC); } @@ -166,7 +165,7 @@ static int test_request(void) uint32_t expected_rdo = RDO_FIXED(1, 900, 900, RDO_CAP_MISMATCH); plug_in_source(0, 0); - task_wake(PORT_TO_TASK_ID(0)); + task_wake(PD_PORT_TO_TASK_ID(0)); task_wait_event(2 * PD_T_CC_DEBOUNCE + 100 * MSEC); TEST_ASSERT(pd_port[0].polarity == 0); @@ -176,7 +175,7 @@ static int test_request(void) TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[0].msg_rx_id)); /* Wait for the power request */ - task_wake(PORT_TO_TASK_ID(0)); + task_wake(PD_PORT_TO_TASK_ID(0)); task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ inc_rx_id(0); @@ -200,7 +199,7 @@ static int test_sink(void) int i; plug_in_sink(1, 1); - task_wake(PORT_TO_TASK_ID(1)); + task_wake(PD_PORT_TO_TASK_ID(1)); task_wait_event(250 * MSEC); /* tTypeCSinkWaitCap: 210~250 ms */ TEST_ASSERT(pd_port[1].polarity == 1); @@ -217,7 +216,7 @@ static int test_sink(void) /* Looks good. Ack the source cap. */ simulate_goodcrc(1, PD_ROLE_SINK, pd_port[1].msg_tx_id); - task_wake(PORT_TO_TASK_ID(1)); + task_wake(PD_PORT_TO_TASK_ID(1)); usleep(30 * MSEC); inc_tx_id(1); |