diff options
author | Scott Collyer <scollyer@google.com> | 2017-04-26 15:41:35 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-05-18 18:08:04 -0700 |
commit | 56dc7a3ef6b9fd5118550365738d099098270a20 (patch) | |
tree | fbf8b188bac95c6a1ee3b98cd3e09f9cdf95ce81 | |
parent | 30f6c60bcb851620d14c4871f16e85c3fe769056 (diff) | |
download | chrome-ec-56dc7a3ef6b9fd5118550365738d099098270a20.tar.gz |
servo_v4: Added support for HW board ID and limit on VBUS voltage
The first two versions of servo_v4 (red and blue) have the TPD2E001
ESD between VBUS and CC1/CC2. This part has a breakdown min voltage of
11V. Therefore for these versions of servo_v4, need to limit VBUS to
less than the default 20V value.
This CL adds support to read two board ID gpios attached to the gpio
expansion part. The max VBUS voltage is limited to 9V for red/blue and
allowed to be 20V for black.
BUG=b:38351574
BRANCH=servo_v4
TEST=Manual
Modified a servo_v4 to add the 2 new pullup resistors. Tested with
this unit and with a unit that does not have the pullups. Verified
that without the pullups the version ID reads a 0 and the max VBUS
voltage that will be requested by the CHG port is 9V. Wih the modified
servo_v4, verified that the version reads 3 and the CHG port will
request up to 20V.
Change-Id: Ic41fcbe3a5c000282552c7322b5ab18ebb203cd2
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/507027
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
-rw-r--r-- | board/servo_v4/board.c | 41 | ||||
-rw-r--r-- | board/servo_v4/board.h | 15 |
2 files changed, 56 insertions, 0 deletions
diff --git a/board/servo_v4/board.c b/board/servo_v4/board.c index ce2a647bb8..5559b09f68 100644 --- a/board/servo_v4/board.c +++ b/board/servo_v4/board.c @@ -24,6 +24,7 @@ #include "usart_rx_dma.h" #include "usb_gpio.h" #include "usb_i2c.h" +#include "usb_pd.h" #include "usb_spi.h" #include "usb-stream.h" #include "util.h" @@ -261,6 +262,21 @@ static void write_ioexpander(int bank, int gpio, int val) i2c_write8(1, 0x40, 0x6 + bank, tmp & ~(1 << gpio)); } +/* Read a single GPIO input on the tca6416 I2C ioexpander. */ +static int read_ioexpander_bit(int bank, int bit) +{ + int tmp; + int mask = 1 << bit; + + /* Configure GPIO for this bit as an input */ + i2c_read8(1, 0x40, 0x6 + bank, &tmp); + i2c_write8(1, 0x40, 0x6 + bank, tmp | mask); + /* Read input port register */ + i2c_read8(1, 0x40, bank, &tmp); + + return (tmp & mask) >> bit; +} + /* Enable uservo USB. */ static void init_uservo_port(void) { @@ -335,6 +351,23 @@ void ccd_set_mode(enum ccd_mode new_mode) } } +int board_get_version(void) +{ + static int ver = -1; + + if (ver < 0) { + uint8_t id0, id1; + + id0 = read_ioexpander_bit(1, 3); + id1 = read_ioexpander_bit(1, 4); + + ver = (id1 * 2) + id0; + CPRINTS("Board ID = %d", ver); + } + + return ver; +} + static void board_init(void) { /* USB to serial queues */ @@ -364,5 +397,13 @@ static void board_init(void) * console will survie a DUT EC reset. */ gpio_set_level(GPIO_SBU_MUX_EN, 1); + + /* + * Set the USB PD max voltage to value appropriate for the board + * version. The red/blue versions of servo_v4 have an ESD between VBUS + * and CC1/CC2 that has a breakdown voltage of 11V. + */ + pd_set_max_voltage(board_get_version() >= BOARD_VERSION_BLACK ? + PD_MAX_VOLTAGE_MV : 9000); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h index 629e19b38e..b909c72c50 100644 --- a/board/servo_v4/board.h +++ b/board/servo_v4/board.h @@ -8,6 +8,14 @@ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H +/* + * Board Versions: + * Versions are designated by the PCB color and consist of red, blue, and + * black. Only the black version has pullup resistors to distinguish its board + * id from previous versions. + */ +#define BOARD_VERSION_BLACK 3 + /* 48 MHz SYSCLK clock frequency */ #define CPU_CLOCK 48000000 @@ -194,5 +202,12 @@ int pd_tcpc_cc_ra(int port, int cc_volt, int cc_sel); */ int pd_set_rp_rd(int port, int cc_pull, int rp_value); +/** + * Get board HW ID version + * + * @return HW ID version + */ +int board_get_version(void); + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ |