diff options
author | Ben Lok <ben.lok@mediatek.com> | 2016-01-11 19:36:41 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-03-01 08:25:59 -0800 |
commit | afc76f1adf97d3a4039663e13afc457139d200fc (patch) | |
tree | e8120cae85a3e4526a5e2020619ceb289d14755c /board | |
parent | 0c9e75f01729d3589d408f3345db7deaa9c04783 (diff) | |
download | chrome-ec-afc76f1adf97d3a4039663e13afc457139d200fc.tar.gz |
oak: updates for rev5
1. Muxer of USB C1 port changes to Parade PS8740.
2. Add control of DP switch TS3USB3000RSER, using for switch DP to port 0/1
(same as rev2).
3. LED control logic is same as rev2.
4. Updates GPIO setting for rev5 pinouts.
BUG=chrome-os-partner:49375
BRANCH=none
TEST=build -j buildall tests
Change-Id: Ifc45ac30be8d46caa1cdb032ccce7569e5a14b99
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/321024
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/oak/board.c | 45 | ||||
-rw-r--r-- | board/oak/board.h | 3 | ||||
-rw-r--r-- | board/oak/gpio.inc | 35 | ||||
-rw-r--r-- | board/oak/led.c | 140 | ||||
-rw-r--r-- | board/oak/usb_pd_policy.c | 8 |
5 files changed, 151 insertions, 80 deletions
diff --git a/board/oak/board.c b/board/oak/board.c index 2015da26ef..d2ac75d20b 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -174,10 +174,17 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { .port_addr = 0x54 << 1, .driver = &pi3usb30532_usb_mux_driver, }, +#if (BOARD_REV <= OAK_REV4) { .port_addr = 0x55 << 1, .driver = &pi3usb30532_usb_mux_driver, }, +#else + { + .port_addr = 0x20, + .driver = &ps8740_usb_mux_driver, + }, +#endif }; /** @@ -352,9 +359,20 @@ int board_get_ramp_current_limit(int supplier, int sup_curr) } } +static void board_typec_set_dp_hpd(int port, int level) +{ +#if BOARD_REV >= OAK_REV5 + if (1 == dp_hw_port) + gpio_set_level(GPIO_C1_DP_HPD, level); +#endif + + gpio_set_level(GPIO_USB_DP_HPD, level); + +} + static void hpd_irq_deferred(void) { - gpio_set_level(GPIO_USB_DP_HPD, 1); + board_typec_set_dp_hpd(dp_hw_port, 1); } DECLARE_DEFERRED(hpd_irq_deferred); @@ -368,13 +386,14 @@ void board_typec_dp_on(int port) if (dp_hw_port != !port) { /* Get control of DP hardware */ dp_hw_port = port; -#if BOARD_REV == OAK_REV2 +#if BOARD_REV == OAK_REV2 || BOARD_REV >= OAK_REV5 + /* Rev2 or Rev5 later board has DP switch */ gpio_set_level(GPIO_DP_SWITCH_CTL, port); #endif if (!gpio_get_level(GPIO_USB_DP_HPD)) { - gpio_set_level(GPIO_USB_DP_HPD, 1); + board_typec_set_dp_hpd(port, 1); } else { - gpio_set_level(GPIO_USB_DP_HPD, 0); + board_typec_set_dp_hpd(port, 0); hook_call_deferred(hpd_irq_deferred, HPD_DSTREAM_DEBOUNCE_IRQ); } @@ -396,7 +415,8 @@ void board_typec_dp_off(int port, int *dp_flags) } dp_hw_port = PD_PORT_NONE; - gpio_set_level(GPIO_USB_DP_HPD, 0); + board_typec_set_dp_hpd(port, 0); + mutex_unlock(&dp_hw_lock); /* Enable the other port if its dp flag is on */ @@ -413,13 +433,14 @@ void board_typec_dp_set(int port, int level) if (dp_hw_port == PD_PORT_NONE) { dp_hw_port = port; -#if BOARD_REV == OAK_REV2 +#if BOARD_REV == OAK_REV2 || BOARD_REV >= OAK_REV5 + /* Rev2 or Rev5 later board has DP switch */ gpio_set_level(GPIO_DP_SWITCH_CTL, port); #endif } if (dp_hw_port == port) - gpio_set_level(GPIO_USB_DP_HPD, level); + board_typec_set_dp_hpd(port, level); mutex_unlock(&dp_hw_lock); } @@ -562,6 +583,11 @@ static void board_chipset_pre_init(void) { /* Enable level shift of AC_OK when power on */ board_extpower_buffer_to_soc(); +#if BOARD_REV >= OAK_REV5 + /* Enable DP muxer */ + gpio_set_level(GPIO_DP_MUX_EN_L , 0); + gpio_set_level(GPIO_PARADE_MUX_EN, 1); +#endif } DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT); @@ -570,6 +596,11 @@ static void board_chipset_shutdown(void) { /* Disable level shift to SoC when shutting down */ gpio_set_level(GPIO_LEVEL_SHIFT_EN_L, 1); +#if BOARD_REV >= OAK_REV5 + /* Disable DP muxer */ + gpio_set_level(GPIO_DP_MUX_EN_L , 1); + gpio_set_level(GPIO_PARADE_MUX_EN, 0); +#endif } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); diff --git a/board/oak/board.h b/board/oak/board.h index 5a5fed3501..46072eb001 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -132,6 +132,9 @@ /* Drivers */ /* USB Mux */ #define CONFIG_USB_MUX_PI3USB30532 +#if BOARD_REV >= OAK_REV5 +#define CONFIG_USB_MUX_PS8740 +#endif /* BC 1.2 charger */ #define CONFIG_USB_SWITCH_PI3USB9281 #define CONFIG_USB_SWITCH_PI3USB9281_CHIP_COUNT 2 diff --git a/board/oak/gpio.inc b/board/oak/gpio.inc index 29de1f276f..d3d776184f 100644 --- a/board/oak/gpio.inc +++ b/board/oak/gpio.inc @@ -60,16 +60,27 @@ GPIO(WP_L, PIN(B, 4), GPIO_INPUT) /* Write protect input */ GPIO(BAT_PRESENT_L, PIN(E, 3), GPIO_INPUT|GPIO_PULL_UP) /* Board version */ -GPIO(BOARD_VERSION1, PIN(E, 10), GPIO_INPUT|GPIO_PULL_DOWN) /* Board ID 0 */ -GPIO(BOARD_VERSION2, PIN(E, 9), GPIO_INPUT|GPIO_PULL_DOWN) /* Board ID 1 */ -GPIO(BOARD_VERSION3, PIN(E, 12), GPIO_INPUT|GPIO_PULL_DOWN) /* Board ID 2 */ -GPIO(BOARD_VERSION4, PIN(E, 11), GPIO_INPUT|GPIO_PULL_DOWN) /* Board ID 3 */ +GPIO(BOARD_VERSION1, PIN(E, 10), GPIO_INPUT) /* Board ID 0 */ +GPIO(BOARD_VERSION2, PIN(E, 9), GPIO_INPUT) /* Board ID 1 */ +GPIO(BOARD_VERSION3, PIN(E, 12), GPIO_INPUT) /* Board ID 2 */ +GPIO(BOARD_VERSION4, PIN(E, 11), GPIO_INPUT) /* Board ID 3 */ /* Outputs */ +#if BOARD_REV < OAK_REV5 GPIO(BAT_LED0, PIN(B, 11), GPIO_OUT_LOW) /* LED_GREEN */ GPIO(BAT_LED1, PIN(A, 11), GPIO_OUT_LOW) /* LED_ORANGE or LED_RED(>rev3)*/ +#else +GPIO(BAT_LED0, PIN(A, 11), GPIO_OUT_LOW) /* LED_GREEN */ +GPIO(BAT_LED1, PIN(B, 11), GPIO_OUT_LOW) /* LED_ORANGE or LED_RED(>rev3)*/ +#endif + +#if (BOARD_REV == OAK_REV3) || (BOARD_REV == OAK_REV4) GPIO(PWR_LED0, PIN(F, 10), GPIO_OUT_LOW) /* LED_GREEN */ GPIO(PWR_LED1, PIN(F, 9), GPIO_OUT_LOW) /* LED_ORANGE */ +#else +UNIMPLEMENTED(PWR_LED0) +UNIMPLEMENTED(PWR_LED1) +#endif GPIO(EC_BL_OVERRIDE, PIN(F, 1), GPIO_OUT_LOW) GPIO(ENTERING_RW, PIN(F, 0), GPIO_OUT_LOW) @@ -90,6 +101,7 @@ GPIO(KB_OUT09, PIN(B, 1), GPIO_KB_OUTPUT) GPIO(KB_OUT10, PIN(C, 5), GPIO_KB_OUTPUT) GPIO(KB_OUT11, PIN(C, 4), GPIO_KB_OUTPUT) GPIO(KB_OUT12, PIN(A, 13), GPIO_KB_OUTPUT) +UNIMPLEMENTED(DP_SWITCH_CTL) #elif BOARD_REV == OAK_REV2 GPIO(AP_RESET_L, PIN(C, 3), GPIO_INPUT|GPIO_PULL_UP) /* AP reset signal from servo board */ @@ -126,6 +138,7 @@ GPIO(KB_OUT09, PIN(B, 1), GPIO_KB_OUTPUT) GPIO(KB_OUT10, PIN(C, 5), GPIO_KB_OUTPUT) GPIO(KB_OUT11, PIN(C, 4), GPIO_KB_OUTPUT) GPIO(KB_OUT12, PIN(C, 2), GPIO_KB_OUTPUT) +UNIMPLEMENTED(DP_SWITCH_CTL) #else /* >= OAK_REV5 */ GPIO(AP_RESET_L, PIN(C, 3), GPIO_ODR_HIGH) /* Connect to the PMU_SYSRSTB */ @@ -138,11 +151,18 @@ GPIO(KB_OUT04, PIN(A, 8), GPIO_KB_OUTPUT) GPIO(KB_OUT05, PIN(D, 14), GPIO_KB_OUTPUT) GPIO(KB_OUT06, PIN(D, 13), GPIO_KB_OUTPUT) GPIO(KB_OUT07, PIN(D, 15), GPIO_KB_OUTPUT) -GPIO(KB_OUT08, PIN(D, 5), GPIO_KB_OUTPUT) +GPIO(KB_OUT08, PIN(C, 2), GPIO_KB_OUTPUT) GPIO(KB_OUT09, PIN(B, 1), GPIO_KB_OUTPUT) GPIO(KB_OUT10, PIN(C, 5), GPIO_KB_OUTPUT) GPIO(KB_OUT11, PIN(C, 4), GPIO_KB_OUTPUT) -GPIO(KB_OUT12, PIN(C, 2), GPIO_KB_OUTPUT) +GPIO(KB_OUT12, PIN(D, 5), GPIO_KB_OUTPUT) +GPIO(C1_DP_HPD, PIN(E,15), GPIO_OUT_LOW) /* inform PS8740 to exit from idle mode. */ +GPIO(DP_SWITCH_CTL, PIN(E, 5), GPIO_OUT_LOW) +GPIO(EN_OTG_USB_A_PWR, PIN(E, 4), GPIO_OUT_HIGH) +GPIO(OTG_USB_A_ILIM_SEL,PIN(E, 2), GPIO_OUT_HIGH) +GPIO(EC_IDDIG, PIN(E,13), GPIO_OUT_LOW) +GPIO(DP_MUX_EN_L, PIN(E, 6), GPIO_OUT_LOW) +GPIO(PARADE_MUX_EN, PIN(E, 7), GPIO_OUT_HIGH) #endif /* BOARD_REV */ GPIO(SYSTEM_POWER_H, PIN(B, 10), GPIO_OUT_LOW) @@ -162,8 +182,11 @@ GPIO(USB_PD_VBUS_WAKE, PIN(B, 15), GPIO_OUT_LOW) /* PD MCU wake */ GPIO(USB_DP_HPD, PIN(F, 3), GPIO_OUT_LOW) GPIO(USB_C0_DEVMODE_L, PIN(E, 4), GPIO_OUT_HIGH) /* set HSD2 (host mode) path as default */ GPIO(USB_C1_DEVMODE, PIN(E, 2), GPIO_OUT_LOW) /* set HSD1 (host mode) path as default */ + +#if (BOARD_REV < OAK_REV5) GPIO(TYPEC0_MUX_EN_L, PIN(E, 13), GPIO_OUT_LOW) GPIO(TYPEC1_MUX_EN_L, PIN(E, 14), GPIO_OUT_LOW) +#endif /* Analog pins */ GPIO(VDC_BOOSTIN_SENSE, PIN(C, 1), GPIO_ANALOG) /* ADC_IN11 */ diff --git a/board/oak/led.c b/board/oak/led.c index 063f454ce8..44d7a657d8 100644 --- a/board/oak/led.c +++ b/board/oak/led.c @@ -2,7 +2,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * - * Battery LED and Power LED control for LLAMA Board. + * Battery LED and Power LED control for Oak Board. */ #include "battery.h" @@ -32,28 +32,32 @@ enum led_color { static int bat_led_set(enum led_color color, int on) { + /* Before Rev5, it's active low; After that, it's active high */ + if (system_get_board_version() < OAK_REV5) + on = !on; + switch (color) { case BAT_LED_GREEN: - gpio_set_level(GPIO_BAT_LED0, on ? 0 : 1); /* BAT_LED_GREEN */ + gpio_set_level(GPIO_BAT_LED0, on); /* BAT_LED_GREEN */ break; case BAT_LED_ORANGE: /* for rev2 or before */ - gpio_set_level(GPIO_BAT_LED1, on ? 0 : 1); /* BAT_LED_ORANGE */ + gpio_set_level(GPIO_BAT_LED1, on); /* BAT_LED_ORANGE */ break; case BAT_LED_RED: /* for rev3 or later */ - gpio_set_level(GPIO_BAT_LED1, on ? 0 : 1); /* BAT_LED_RED */ + gpio_set_level(GPIO_BAT_LED1, on); /* BAT_LED_RED */ break; case BAT_LED_AMBER: /* for rev3 or later */ - gpio_set_level(GPIO_BAT_LED0, on ? 0 : 1); /* BAT_LED_AMBER */ - gpio_set_level(GPIO_BAT_LED1, on ? 0 : 1); + gpio_set_level(GPIO_BAT_LED0, on); /* BAT_LED_AMBER */ + gpio_set_level(GPIO_BAT_LED1, on); break; case PWR_LED_GREEN: - gpio_set_level(GPIO_PWR_LED0, on ? 0 : 1); /* PWR_LED_GREEN */ + gpio_set_level(GPIO_PWR_LED0, on); /* PWR_LED_GREEN */ break; case PWR_LED_ORANGE: - gpio_set_level(GPIO_PWR_LED1, on ? 0 : 1); /* PWR_LED_ORANGE */ + gpio_set_level(GPIO_PWR_LED1, on); /* PWR_LED_ORANGE */ break; default: return EC_ERROR_UNKNOWN; @@ -109,21 +113,11 @@ static void oak_led_set_power(int board_version) power_second++; - if (board_version < 3) { - /* PWR LED behavior: - * Power on: Green - * Suspend: Green in breeze mode ( 1 sec on/ 3 sec off) - * Power off: OFF - */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - bat_led_set(BAT_LED_GREEN, 0); - else if (chipset_in_state(CHIPSET_STATE_ON)) - bat_led_set(BAT_LED_GREEN, 1); - else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) - bat_led_set(BAT_LED_GREEN, (power_second & 3) ? 0 : 1); - } else { + switch(board_version) { + case OAK_REV3: + case OAK_REV4: /* - * For Rev3 or later version: + * For Rev3 and Rev4 revision. * PWR LED behavior: * Power on: Green ON * Suspend: Orange in breeze mode ( 1 sec on/ 3 sec off) @@ -137,8 +131,24 @@ static void oak_led_set_power(int board_version) bat_led_set(PWR_LED_ORANGE, 0); } else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) { bat_led_set(PWR_LED_GREEN, 0); - bat_led_set(PWR_LED_ORANGE, (power_second & 3) ? 0 : 1); + bat_led_set(PWR_LED_ORANGE, + (power_second & 3) ? 0 : 1); } + break; + default: + /* PWR LED behavior: + * Power on: Green + * Suspend: Green in breeze mode ( 1 sec on/ 3 sec off) + * Power off: OFF + */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + bat_led_set(BAT_LED_GREEN, 0); + else if (chipset_in_state(CHIPSET_STATE_ON)) + bat_led_set(BAT_LED_GREEN, 1); + else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) + bat_led_set(BAT_LED_GREEN, + (power_second & 3) ? 0 : 1); + break; } } @@ -148,82 +158,86 @@ static void oak_led_set_battery(int board_version) battery_second++; - if (board_version < 3) { - /* BAT LED behavior: - * Fully charged / idle: Off - * Under charging: Orange - * Battery low (10%): Orange in breeze mode(1 sec on, 3 sec off) - * Battery critical low (less than 3%) or abnormal battery - * situation: Orange in blinking mode (1 sec on, 1 sec off) - * Using battery or not connected to AC power: OFF + switch(board_version) { + case OAK_REV3: + case OAK_REV4: + /* + * For Rev3 and Rev4 revision: + * BAT LED behavior: + * - Fully charged / idle: Green ON + * - Charging: Amber ON (BAT_LED_RED && BAT_LED_GREEN) + * - Battery discharging capacity<10%, red blink + * - Battery error: Red ON */ switch (charge_get_state()) { case PWR_STATE_CHARGE: - bat_led_set(BAT_LED_ORANGE, 1); + bat_led_set(BAT_LED_AMBER, 1); break; case PWR_STATE_CHARGE_NEAR_FULL: - bat_led_set(BAT_LED_ORANGE, 1); + bat_led_set(BAT_LED_GREEN, 1); + bat_led_set(BAT_LED_RED, 0); break; case PWR_STATE_DISCHARGE: + bat_led_set(BAT_LED_GREEN, 0); if (charge_get_percent() < 3) - bat_led_set(BAT_LED_ORANGE, - (battery_second & 1) ? 0 : 1); + bat_led_set(BAT_LED_RED, + (battery_second & 1) ? 0 : 1); else if (charge_get_percent() < 10) - bat_led_set(BAT_LED_ORANGE, - (battery_second & 3) ? 0 : 1); + bat_led_set(BAT_LED_RED, + (battery_second & 3) ? 0 : 1); else - bat_led_set(BAT_LED_ORANGE, 0); + bat_led_set(BAT_LED_RED, 0); break; case PWR_STATE_ERROR: - bat_led_set(BAT_LED_ORANGE, - (battery_second & 1) ? 0 : 1); + bat_led_set(BAT_LED_RED, 1); break; - case PWR_STATE_IDLE: /* External power connected in IDLE. */ - bat_led_set(BAT_LED_ORANGE, 0); + case PWR_STATE_IDLE: /* Ext. power connected in IDLE. */ + bat_led_set(BAT_LED_GREEN, 1); + bat_led_set(BAT_LED_RED, 0); break; default: /* Other states don't alter LED behavior */ break; } - } else { - /* - * For Rev3 or later version: - * BAT LED behavior: - * - Fully charged / idle: Green ON - * - Charging: Amber ON (BAT_LED_RED && BAT_LED_GREEN) - * - Battery discharging capacity<10%, red blink - * - Battery error: Red ON + break; /* End of case OAK_REV3 & OAK_REV4 */ + default: + /* BAT LED behavior: + * Fully charged / idle: Off + * Under charging: Orange + * Bat. low (10%): Orange in breeze mode (1s on, 3s off) + * Bat. critical low (less than 3%) or abnormal battery + * situation: Orange in blinking mode (1s on, 1s off) + * Using battery or not connected to AC power: OFF */ switch (charge_get_state()) { case PWR_STATE_CHARGE: - bat_led_set(BAT_LED_AMBER, 1); + bat_led_set(BAT_LED_ORANGE, 1); break; case PWR_STATE_CHARGE_NEAR_FULL: - bat_led_set(BAT_LED_GREEN, 1); - bat_led_set(BAT_LED_RED, 0); + bat_led_set(BAT_LED_ORANGE, 1); break; case PWR_STATE_DISCHARGE: - bat_led_set(BAT_LED_GREEN, 0); if (charge_get_percent() < 3) - bat_led_set(BAT_LED_RED, - (battery_second & 1) ? 0 : 1); + bat_led_set(BAT_LED_ORANGE, + (battery_second & 1) ? 0 : 1); else if (charge_get_percent() < 10) - bat_led_set(BAT_LED_RED, - (battery_second & 3) ? 0 : 1); + bat_led_set(BAT_LED_ORANGE, + (battery_second & 3) ? 0 : 1); else - bat_led_set(BAT_LED_RED, 0); + bat_led_set(BAT_LED_ORANGE, 0); break; case PWR_STATE_ERROR: - bat_led_set(BAT_LED_RED, 1); + bat_led_set(BAT_LED_ORANGE, + (battery_second & 1) ? 0 : 1); break; - case PWR_STATE_IDLE: /* External power connected in IDLE. */ - bat_led_set(BAT_LED_GREEN, 1); - bat_led_set(BAT_LED_RED, 0); + case PWR_STATE_IDLE: /* Ext. power connected in IDLE. */ + bat_led_set(BAT_LED_ORANGE, 0); break; default: /* Other states don't alter LED behavior */ break; } + break; /* End of default */ } } diff --git a/board/oak/usb_pd_policy.c b/board/oak/usb_pd_policy.c index 38db163b58..458b6dcb90 100644 --- a/board/oak/usb_pd_policy.c +++ b/board/oak/usb_pd_policy.c @@ -140,6 +140,7 @@ int pd_check_vconn_swap(int port) void pd_execute_data_swap(int port, int data_role) { + /* Do nothing */ } void pd_check_pr_role(int port, int pr_role, int flags) @@ -214,7 +215,7 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, CPRINTF("Current: %dmA\n", payload[1]); break; case VDO_CMD_FLIP: - /* board_flip_usb_mux(port); */ + usb_mux_flip(port); break; #ifdef CONFIG_USB_PD_LOGGING case VDO_CMD_GET_LOG: @@ -289,14 +290,13 @@ static int svdm_dp_config(int port, uint32_t *payload) return 0; usb_mux_set(port, mf_pref ? TYPEC_MUX_DOCK : TYPEC_MUX_DP, - USB_SWITCH_CONNECT, pd_get_polarity(port)); + USB_SWITCH_CONNECT, pd_get_polarity(port)); payload[0] = VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); - payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ 1, /* DPv1.3 signaling */ - 2); /* UFP_U connected as UFP_D */ + 2); /* UFP connected */ return 2; }; |