summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-03-24 09:26:00 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-04-01 23:39:02 +0000
commit6cb426e137ebf15dd1f428c657e26bd3d367b7ac (patch)
tree3381db1d90b89d959c66a6f887582be2abbf2431
parent4c1bad17aa0ad015971ab0e446c87e12003d4a6d (diff)
downloadchrome-ec-stabilize-6937.B.tar.gz
ryu: add P5/Smaug supportstabilize-6937.B
Update EC board configuration for P5 boards : - PMIC_THERM_L GPIO used for PMIC shutdown has moved. - add 5V regulator control (used for VBUS only) - the Type-C superspeed muxes control changed - add a temporary pull-up on EN_PP3300 - add new FW_DEBUG_MODE GPIO Try to be compatible with both P4 and P5 by detecting the board variant at runtime. At EC startup, USBC_SS1_USB_MODE_L/USBC_SS2_USB_MODE_L/USBC_SS_EN_L (aka PD3/PD9/PE0 aka MUX_CONF0/1/2) now default to low level rather than high (as the new default value on P5), but they are reset to the correct value when initializing the PD task (high for P4, low for P5+). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:38330 TEST=Ran on P4, check board ID on P5 PCB. Change-Id: Ie9010805a91362c2b4d5eddd825d452d6ccc5b28 Reviewed-on: https://chromium-review.googlesource.com/262310 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/ryu/board.c94
-rw-r--r--board/ryu/board.h8
-rw-r--r--board/ryu/gpio.inc22
-rw-r--r--board/ryu/usb_pd_config.h4
4 files changed, 119 insertions, 9 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c
index e0b3079fcc..f6da9c2653 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -352,7 +352,12 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-void board_set_usb_mux(int port, enum typec_mux mux, int polarity)
+/* TODO(crosbug.com/p/38333) remove me */
+#define GPIO_USBC_SS1_USB_MODE_L GPIO_USBC_MUX_CONF0
+#define GPIO_USBC_SS2_USB_MODE_L GPIO_USBC_MUX_CONF1
+#define GPIO_USBC_SS_EN_L GPIO_USBC_MUX_CONF2
+
+void p4_board_set_usb_mux(int port, enum typec_mux mux, int polarity)
{
/* reset everything */
gpio_set_level(GPIO_USBC_SS_EN_L, 1);
@@ -380,7 +385,36 @@ void board_set_usb_mux(int port, enum typec_mux mux, int polarity)
gpio_set_level(GPIO_USBC_SS_EN_L, 0);
}
-int board_get_usb_mux(int port, const char **dp_str, const char **usb_str)
+void board_set_usb_mux(int port, enum typec_mux mux, int polarity)
+{
+ if (board_get_version() < 5) {
+ /* P4/EVT or older boards */
+ /* TODO(crosbug.com/p/38333) remove this */
+ p4_board_set_usb_mux(port, mux, polarity);
+ return;
+ }
+
+ /* reset everything */
+ gpio_set_level(GPIO_USBC_MUX_CONF0, 0);
+ gpio_set_level(GPIO_USBC_MUX_CONF1, 0);
+ gpio_set_level(GPIO_USBC_MUX_CONF2, 0);
+
+ if (mux == TYPEC_MUX_NONE)
+ /* everything is already disabled, we can return */
+ return;
+
+ gpio_set_level(GPIO_USBC_MUX_CONF0, polarity);
+
+ if (mux == TYPEC_MUX_USB || mux == TYPEC_MUX_DOCK)
+ /* USB 3.0 uses 2 superspeed lanes */
+ gpio_set_level(GPIO_USBC_MUX_CONF2, 1);
+
+ if (mux == TYPEC_MUX_DP || mux == TYPEC_MUX_DOCK)
+ /* DP uses available superspeed lanes (x2 or x4) */
+ gpio_set_level(GPIO_USBC_MUX_CONF1, 1);
+}
+
+int p4_board_get_usb_mux(int port, const char **dp_str, const char **usb_str)
{
int has_ss = !gpio_get_level(GPIO_USBC_SS_EN_L);
int has_usb = !gpio_get_level(GPIO_USBC_SS1_USB_MODE_L) ||
@@ -401,6 +435,33 @@ int board_get_usb_mux(int port, const char **dp_str, const char **usb_str)
return has_ss;
}
+int board_get_usb_mux(int port, const char **dp_str, const char **usb_str)
+{
+ int has_usb, has_dp, polarity;
+
+ if (board_get_version() < 5) {
+ /* P4/EVT or older boards */
+ /* TODO(crosbug.com/p/38333) remove this */
+ return p4_board_get_usb_mux(port, dp_str, usb_str);
+ }
+
+ has_usb = gpio_get_level(GPIO_USBC_MUX_CONF2);
+ has_dp = gpio_get_level(GPIO_USBC_MUX_CONF1);
+ polarity = gpio_get_level(GPIO_USBC_MUX_CONF0);
+
+ if (has_dp)
+ *dp_str = polarity ? "DP2" : "DP1";
+ else
+ *dp_str = NULL;
+
+ if (has_usb)
+ *usb_str = polarity ? "USB2" : "USB1";
+ else
+ *usb_str = NULL;
+
+ return has_dp || has_usb;
+}
+
/**
* Discharge battery when on AC power for factory test.
*/
@@ -565,3 +626,32 @@ void usb_spi_board_disable(struct usb_spi_config const *config)
/* Release AP from reset */
gpio_set_level(GPIO_PMIC_WARM_RESET_L, 1);
}
+
+int board_get_version(void)
+{
+ static int ver;
+
+ if (!ver) {
+ /*
+ * read the board EC ID on the tristate strappings
+ * using ternary encoding: 0 = 0, 1 = 1, Hi-Z = 2
+ */
+ uint8_t id0 = 0, id1 = 0;
+ gpio_set_flags(GPIO_BOARD_ID0, GPIO_PULL_DOWN | GPIO_INPUT);
+ gpio_set_flags(GPIO_BOARD_ID1, GPIO_PULL_DOWN | GPIO_INPUT);
+ usleep(100);
+ id0 = gpio_get_level(GPIO_BOARD_ID0);
+ id1 = gpio_get_level(GPIO_BOARD_ID1);
+ gpio_set_flags(GPIO_BOARD_ID0, GPIO_PULL_UP | GPIO_INPUT);
+ gpio_set_flags(GPIO_BOARD_ID1, GPIO_PULL_UP | GPIO_INPUT);
+ usleep(100);
+ id0 = gpio_get_level(GPIO_BOARD_ID0) && !id0 ? 2 : id0;
+ id1 = gpio_get_level(GPIO_BOARD_ID1) && !id1 ? 2 : id1;
+ gpio_set_flags(GPIO_BOARD_ID0, GPIO_INPUT);
+ gpio_set_flags(GPIO_BOARD_ID1, GPIO_INPUT);
+ ver = id1 * 3 + id0;
+ CPRINTS("Board ID = %d\n", ver);
+ }
+
+ return ver;
+}
diff --git a/board/ryu/board.h b/board/ryu/board.h
index 092284e40e..285c598cc1 100644
--- a/board/ryu/board.h
+++ b/board/ryu/board.h
@@ -16,7 +16,7 @@
#define CONFIG_UART_CONSOLE 2
/* By default, enable all console messages excepted USB */
-#define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_USBPD))
+#define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_USB))
/* Optional features */
#undef CONFIG_CMD_HASH
@@ -127,12 +127,18 @@
#ifndef __ASSEMBLER__
+int board_get_version(void);
+
/* Timer selection */
#define TIM_CLOCK32 5
#define TIM_WATCHDOG 19
#include "gpio_signal.h"
+/* PMIC_THERM_L selection at runtime depending on board version */
+#define GPIO_PMIC_THERM_L (board_get_version() >= 5 ? GPIO_P5_PMIC_THERM_L : \
+ GPIO_P4_PMIC_THERM_L)
+
enum power_signal {
TEGRA_XPSHOLD = 0,
TEGRA_SUSPEND_ASSERTED,
diff --git a/board/ryu/gpio.inc b/board/ryu/gpio.inc
index f526b570b9..6e783c4757 100644
--- a/board/ryu/gpio.inc
+++ b/board/ryu/gpio.inc
@@ -38,9 +38,16 @@ GPIO(USBC_TX_CLKIN, B, 3, GPIO_OUT_LOW, NULL)
/* System power */
GPIO(PMIC_PWRON_L, D, 14, GPIO_ODR_HIGH, NULL)
GPIO(PMIC_WARM_RESET_L, E, 4, GPIO_ODR_HIGH, NULL)
-GPIO(EN_PP3300_RSVD, E, 13, GPIO_INPUT, NULL)
+GPIO(EN_PP5000, A, 14, GPIO_OUT_LOW, NULL) /* Proto 5+ */
+/*
+ * We are missing an external pull-up for EN_PP3300. Pull it up here.
+ * EN_PP3300 is still controlled by PMIC though.
+ */
+GPIO(EN_PP3300_RSVD, E, 13, GPIO_INPUT | GPIO_PULL_UP, NULL)
/* sensor temp output and PMIC reset input */
-GPIO(PMIC_THERM_L, D, 12, GPIO_ODR_HIGH, NULL)
+GPIO(P5_PMIC_THERM_L, B, 8, GPIO_ODR_HIGH, NULL)
+/* TODO(crosbug.com/p/38333) remove P4_PMIC_THERM_L */
+GPIO(P4_PMIC_THERM_L, D, 12, GPIO_ODR_HIGH, NULL)
GPIO(VBUS_SENSE, A, 0, GPIO_ANALOG, NULL)
GPIO(CHGR_IADP, B, 0, GPIO_ANALOG, NULL)
@@ -59,11 +66,13 @@ GPIO(USBC_VCONN2_EN_L, D, 10, GPIO_OUT_HIGH, NULL)
GPIO(USBC_CC1_DEVICE_ODL, A, 5, GPIO_ODR_LOW, NULL)
GPIO(USBC_CC2_DEVICE_ODL, E, 14, GPIO_ODR_LOW, NULL)
+/* Pericom PI3USB30592 mux controls on Proto 5+ */
+GPIO(USBC_MUX_CONF0, D, 3, GPIO_OUT_LOW, NULL)
+GPIO(USBC_MUX_CONF1, D, 9, GPIO_OUT_LOW, NULL)
+GPIO(USBC_MUX_CONF2, E, 0, GPIO_OUT_LOW, NULL)
+/* TODO(crosbug.com/p/38333) remove USBC_DP_xxx GPIOs */
GPIO(USBC_DP_MODE_L, D, 1, GPIO_OUT_HIGH, NULL)
GPIO(USBC_DP_POLARITY, D, 2, GPIO_OUT_HIGH, NULL)
-GPIO(USBC_SS1_USB_MODE_L, D, 3, GPIO_OUT_HIGH, NULL)
-GPIO(USBC_SS2_USB_MODE_L, D, 9, GPIO_OUT_HIGH, NULL)
-GPIO(USBC_SS_EN_L, E, 0, GPIO_OUT_HIGH, NULL)
/* Inputs */
GPIO(BOARD_ID0, E, 11, GPIO_INPUT, NULL)
@@ -98,11 +107,12 @@ GPIO(USB_PU_EN_L, C, 2, GPIO_OUT_HIGH, NULL)
GPIO(PD_DISABLE_DEBUG, C, 6, GPIO_OUT_LOW, NULL)
GPIO(SPI_FLASH_NSS, B, 9, GPIO_INPUT, NULL)
GPIO(VDDSPI_EN, C, 12, GPIO_OUT_LOW, NULL)
-GPIO(SH_RESET_L, C, 4, GPIO_ODR_HIGH, NULL)
+GPIO(SH_RESET, C, 4, GPIO_ODR_HIGH, NULL)
GPIO(SH_BOOT, C, 9, GPIO_ODR_HIGH, NULL)
GPIO(EC_INT_L, F, 2, GPIO_ODR_HIGH, NULL)
GPIO(ENTERING_RW, E, 15, GPIO_OUT_LOW, NULL)
GPIO(WP_L, F, 6, GPIO_INPUT, NULL)
+GPIO(FW_DEBUG_MODE_L, C, 7, GPIO_ODR_HIGH, NULL) /* Proto 5+ */
#if 0
/* Alternate functions */
diff --git a/board/ryu/usb_pd_config.h b/board/ryu/usb_pd_config.h
index ee0ef268c6..8ab1017e3f 100644
--- a/board/ryu/usb_pd_config.h
+++ b/board/ryu/usb_pd_config.h
@@ -132,6 +132,8 @@ static inline void pd_tx_init(void)
static inline void pd_set_host_mode(int port, int enable)
{
if (enable) {
+ /* Turn the 5V regulator providing VBUS */
+ gpio_set_level(GPIO_EN_PP5000, 1);
/* We never charging in power source mode */
gpio_set_level(GPIO_USBC_CHARGE_EN_L, 1);
charge_set_input_current_limit(0);
@@ -141,6 +143,8 @@ static inline void pd_set_host_mode(int port, int enable)
} else {
/* Kill VBUS power supply */
gpio_set_level(GPIO_USBC_5V_EN, 0);
+ /* Turn off the 5V regulator */
+ gpio_set_level(GPIO_EN_PP5000, 0);
/* Pull low for device mode. */
gpio_set_level(GPIO_USBC_CC1_DEVICE_ODL, 0);
gpio_set_level(GPIO_USBC_CC2_DEVICE_ODL, 0);