diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2016-06-30 17:06:07 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-22 23:27:16 -0700 |
commit | 61c45fb33e9ea1b1db6e195c093b02444d303cce (patch) | |
tree | 8992827f71403652997e1261cb9ecfa270262e93 | |
parent | 82e4ac67acf3c75084be37a52ae14147135437fa (diff) | |
download | chrome-ec-61c45fb33e9ea1b1db6e195c093b02444d303cce.tar.gz |
BD99955: Map PD port number to charge port number
Charger port number may differ from PD port number hence added
a macro to select appropriate port numbers during compilation.
BUG=chrome-os-partner:54970
BRANCH=none
TEST=Reef can negotiate on both the ports.
Change-Id: Id3b4b639a5f8698c27341be037bb09370910cac5
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/357836
Commit-Ready: Martin Roth <martinroth@chromium.org>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | board/amenia/board.c | 10 | ||||
-rw-r--r-- | board/kevin/board.c | 22 | ||||
-rw-r--r-- | board/reef/board.c | 10 | ||||
-rw-r--r-- | driver/charger/bd99955.c | 4 | ||||
-rw-r--r-- | driver/charger/bd99955.h | 10 | ||||
-rw-r--r-- | include/config.h | 7 |
6 files changed, 37 insertions, 26 deletions
diff --git a/board/amenia/board.c b/board/amenia/board.c index 16bb51eaf2..4432421c18 100644 --- a/board/amenia/board.c +++ b/board/amenia/board.c @@ -240,12 +240,6 @@ const struct button_config buttons[CONFIG_BUTTON_COUNT] = { 30 * MSEC, 0}, }; -static const enum bd99955_charge_port - pd_port_to_bd99955_port[CONFIG_USB_PD_PORT_COUNT] = { - [0] = BD99955_CHARGE_PORT_VBUS, - [1] = BD99955_CHARGE_PORT_VCC, -}; - /* Called by APL power state machine when transitioning from G3 to S5 */ static void chipset_pre_init(void) { @@ -278,7 +272,7 @@ int pd_snk_is_vbus_provided(int port) switch (port) { case 0: case 1: - bd99955_port = pd_port_to_bd99955_port[port]; + bd99955_port = bd99955_pd_port_to_chg_port(port); break; default: panic("Invalid charge port\n"); @@ -329,7 +323,7 @@ int board_set_active_charge_port(int charge_port) switch (charge_port) { case 0: case 1: - bd99955_port = pd_port_to_bd99955_port[charge_port]; + bd99955_port = bd99955_pd_port_to_chg_port(charge_port); break; case CHARGE_PORT_NONE: bd99955_port = BD99955_CHARGE_PORT_NONE; diff --git a/board/kevin/board.c b/board/kevin/board.c index b7c48925fe..34f2c3ee3a 100644 --- a/board/kevin/board.c +++ b/board/kevin/board.c @@ -163,12 +163,6 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { {I2C_PORT_TCPC1, FUSB302_I2C_SLAVE_ADDR, &fusb302_tcpm_drv}, }; -static const enum bd99955_charge_port - pd_port_to_bd99955_port[CONFIG_USB_PD_PORT_COUNT] = { - [0] = BD99955_CHARGE_PORT_VBUS, - [1] = BD99955_CHARGE_PORT_VCC, -}; - struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { { .port_addr = 0, @@ -219,7 +213,7 @@ int board_set_active_charge_port(int charge_port) switch (charge_port) { case 0: case 1: - bd99955_port = pd_port_to_bd99955_port[charge_port]; + bd99955_port = bd99955_pd_port_to_chg_port(charge_port); break; case CHARGE_PORT_NONE: bd99955_port = BD99955_CHARGE_PORT_NONE; @@ -247,7 +241,19 @@ int extpower_is_present(void) int pd_snk_is_vbus_provided(int port) { - return bd99955_is_vbus_provided(pd_port_to_bd99955_port[port]); + enum bd99955_charge_port bd99955_port; + + switch (port) { + case 0: + case 1: + bd99955_port = bd99955_pd_port_to_chg_port(port); + break; + default: + panic("Invalid charge port\n"); + break; + } + + return bd99955_is_vbus_provided(bd99955_port); } static void board_init(void) diff --git a/board/reef/board.c b/board/reef/board.c index 5774ed15db..173ae126f0 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -353,12 +353,6 @@ const struct button_config buttons[CONFIG_BUTTON_COUNT] = { 30 * MSEC, 0}, }; -static const enum bd99955_charge_port - pd_port_to_bd99955_port[CONFIG_USB_PD_PORT_COUNT] = { - [0] = BD99955_CHARGE_PORT_VBUS, - [1] = BD99955_CHARGE_PORT_VCC, -}; - /* Called by APL power state machine when transitioning from G3 to S5 */ static void chipset_pre_init(void) { @@ -446,7 +440,7 @@ int pd_snk_is_vbus_provided(int port) switch (port) { case 0: case 1: - bd99955_port = pd_port_to_bd99955_port[port]; + bd99955_port = bd99955_pd_port_to_chg_port(port); break; default: panic("Invalid charge port\n"); @@ -498,7 +492,7 @@ int board_set_active_charge_port(int charge_port) switch (charge_port) { case 0: case 1: - bd99955_port = pd_port_to_bd99955_port[charge_port]; + bd99955_port = bd99955_pd_port_to_chg_port(charge_port); break; case CHARGE_PORT_NONE: bd99955_port = BD99955_CHARGE_PORT_NONE; diff --git a/driver/charger/bd99955.c b/driver/charger/bd99955.c index a3b1d6e776..43a6bc4bcb 100644 --- a/driver/charger/bd99955.c +++ b/driver/charger/bd99955.c @@ -377,8 +377,8 @@ static void usb_charger_process(enum bd99955_charge_port port) int vbus_provided = bd99955_is_vbus_provided(port); /* Inform other modules about VBUS level */ - /* TODO: map charger port num to board port num, they may differ. */ - usb_charger_vbus_change(port, vbus_provided); + usb_charger_vbus_change(bd99955_pd_port_to_chg_port(port), + vbus_provided); /* Do BC1.2 detection */ if (vbus_provided) { diff --git a/driver/charger/bd99955.h b/driver/charger/bd99955.h index f9c95d7663..e4c557eb1d 100644 --- a/driver/charger/bd99955.h +++ b/driver/charger/bd99955.h @@ -282,6 +282,16 @@ enum bd99955_charge_port { #define BD99955_CMD_SMBREG 0x7C #define BD99955_CMD_DEBUG_MODE_SET 0x7F +/* Map PD port number to charge port number */ +static inline enum bd99955_charge_port bd99955_pd_port_to_chg_port(int port) +{ +#ifdef CONFIG_BD99955_PRIMARY_CHARGE_PORT_VCC + return port ? BD99955_CHARGE_PORT_VBUS : BD99955_CHARGE_PORT_VCC; +#else + return port ? BD99955_CHARGE_PORT_VCC : BD99955_CHARGE_PORT_VBUS; +#endif +} + /* * Non-standard interface functions - bd99955 integrates additional * functionality not part of the standard charger interface. diff --git a/include/config.h b/include/config.h index b9ca01831c..a315d1c15b 100644 --- a/include/config.h +++ b/include/config.h @@ -370,6 +370,13 @@ #undef CONFIG_CHARGER_TPS65090 /* Note: does not use CONFIG_CHARGER */ /* + * BD99955 PD port to charger port mapping. + * By default VBUS is selected as primary port. + * Define only if the VCC is the primary port. + */ +#undef CONFIG_BD99955_PRIMARY_CHARGE_PORT_VCC + +/* * If the battery temperature sense pin is connected to charger, * get the battery temperature from the charger. */ |