diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-06-09 14:29:09 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-06-12 16:37:39 +0000 |
commit | 5b7cfac64e971a7e925d17a8b33e651a01e71707 (patch) | |
tree | 72ee34fae7f6bee5d2c8d781e5256fbceee3f8e1 /board/samus_pd | |
parent | 9941f088d7a56ba4ba7396d9221612b00143a3cc (diff) | |
download | chrome-ec-5b7cfac64e971a7e925d17a8b33e651a01e71707.tar.gz |
usb: pi3usb9281: Allow flexible chip configurations
Previously we supported using a single pi3usb9281 chip, or using two
chips on the same i2c bus behind a mux. Now that we need to support a
third configuration of multiple chips on different busses, it makes
sense to be able to configure the configuration freely at the board
level.
BUG=chrome-os-partner:40920
TEST=Manual on samus_pd. Plug USB charger, verify detection is correct
on both charge ports.
BRANCH=None
Change-Id: I120dcb1c3ceb6f013b92407effcd8cb66e7ffcce
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276511
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'board/samus_pd')
-rw-r--r-- | board/samus_pd/board.c | 28 | ||||
-rw-r--r-- | board/samus_pd/board.h | 4 |
2 files changed, 22 insertions, 10 deletions
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c index eee86c4a8b..161fc135fc 100644 --- a/board/samus_pd/board.c +++ b/board/samus_pd/board.c @@ -24,6 +24,7 @@ #include "system.h" #include "task.h" #include "usb.h" +#include "usb_charge.h" #include "usb_pd.h" #include "util.h" @@ -77,6 +78,24 @@ const struct pwm_t pwm_channels[] = { }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); +struct mutex pericom_mux_lock; +struct pi3usb9281_config pi3usb9281_chips[] = { + { + .i2c_port = I2C_PORT_PERICOM, + .mux_gpio = GPIO_USB_C_BC12_SEL, + .mux_gpio_level = 0, + .mux_lock = &pericom_mux_lock, + }, + { + .i2c_port = I2C_PORT_PERICOM, + .mux_gpio = GPIO_USB_C_BC12_SEL, + .mux_gpio_level = 1, + .mux_lock = &pericom_mux_lock, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) == + CONFIG_USB_SWITCH_PI3USB9281_CHIP_COUNT); + static void pericom_port0_reenable_interrupts(void) { CPRINTS("VBUS p0 %d", gpio_get_level(GPIO_USB_C0_VBUS_WAKE)); @@ -309,10 +328,6 @@ static void board_init(void) /* Enable pericom BC1.2 interrupts. */ gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_L); gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L); - pi3usb9281_set_interrupt_mask(0, 0xff); - pi3usb9281_set_interrupt_mask(1, 0xff); - pi3usb9281_enable_interrupts(0); - pi3usb9281_enable_interrupts(1); /* Determine initial chipset state */ if (slp_s5 && slp_s3) { @@ -555,10 +570,7 @@ int board_set_active_charge_port(int charge_port) int is_real_port = (charge_port >= 0 && charge_port < CONFIG_USB_PD_PORT_COUNT); /* check if we are source vbus on that port */ - int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : - GPIO_USB_C1_5V_EN); - - if (is_real_port && source) { + if (is_real_port && usb_charger_port_is_sourcing_vbus(charge_port)) { CPRINTS("Skip enable p%d", charge_port); return EC_ERROR_INVAL; } diff --git a/board/samus_pd/board.h b/board/samus_pd/board.h index c3dcd49ca0..8e72a259ac 100644 --- a/board/samus_pd/board.h +++ b/board/samus_pd/board.h @@ -61,8 +61,7 @@ #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_SWITCH_PI3USB9281 -#undef CONFIG_USB_SWITCH_PI3USB9281_MUX_GPIO -#define CONFIG_USB_SWITCH_PI3USB9281_MUX_GPIO GPIO_USB_C_BC12_SEL +#define CONFIG_USB_SWITCH_PI3USB9281_CHIP_COUNT 2 #define CONFIG_USBC_SS_MUX_DFP_ONLY #define CONFIG_USBC_SS_MUX #define CONFIG_USBC_VCONN @@ -79,6 +78,7 @@ #define I2C_PORT_MASTER 1 #define I2C_PORT_SLAVE 0 #define I2C_PORT_EC I2C_PORT_SLAVE +#define I2C_PORT_PERICOM I2C_PORT_MASTER /* slave address for host commands */ #ifdef HAS_TASK_HOSTCMD |