summaryrefslogtreecommitdiff
path: root/baseboard
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2019-04-02 15:04:53 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-17 21:32:26 -0700
commita19ad262f2df67cf36d6051d1f309a9f50c2b7f3 (patch)
tree91f7e63b87c935a72adda74c0ed3838630b4ba96 /baseboard
parentf562e995c896e32816f013b848b8ffe61c8f09cd (diff)
downloadchrome-ec-a19ad262f2df67cf36d6051d1f309a9f50c2b7f3.tar.gz
hatch/kohaku: Move TCPC definitions to board from baseboard
Kohaku uses PS8751 for port 0 TCPC. Therefore, the TCPC config and mux config tables can't be common and must be moved out of baseboard into their respective board.c files. BUG=b:130194031 BRANCH=none TEST=make -j buildall Change-Id: Iea39e60d675a5ea0df346c52e78f5f472768984c Signed-off-by: Scott Collyer <scollyer@google.com> Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1551582 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'baseboard')
-rw-r--r--baseboard/hatch/baseboard.c85
-rw-r--r--baseboard/hatch/baseboard.h5
2 files changed, 31 insertions, 59 deletions
diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c
index ba90e10fa2..6253c43469 100644
--- a/baseboard/hatch/baseboard.c
+++ b/baseboard/hatch/baseboard.c
@@ -33,9 +33,6 @@
#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-#define USB_PD_PORT_TCPC_0 0
-#define USB_PD_PORT_TCPC_1 1
-
/******************************************************************************/
/* Wake up pins */
const enum gpio_signal hibernate_wake_pins[] = {
@@ -145,25 +142,6 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, baseboard_chipset_shutdown,
HOOK_PRIO_DEFAULT);
/******************************************************************************/
-/* USB-C TPCP Configuration */
-const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- [USB_PD_PORT_TCPC_0] = {
- .i2c_host_port = I2C_PORT_TCPC0,
- .i2c_slave_addr = AN7447_TCPC0_I2C_ADDR,
- .drv = &anx7447_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
- },
- [USB_PD_PORT_TCPC_1] = {
- .i2c_host_port = I2C_PORT_TCPC1,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
- .drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
- },
-};
-
-/******************************************************************************/
/* USB-C PPC Configuration */
struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
@@ -180,17 +158,6 @@ struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = {
};
unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
- [USB_PD_PORT_TCPC_0] = {
- .driver = &anx7447_usb_mux_driver,
- .hpd_update = &anx7447_tcpc_update_hpd_status,
- },
- [USB_PD_PORT_TCPC_1] = {
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
- }
-};
-
const struct pi3usb2901_config_t pi3usb2901_bc12_chips[] = {
[USB_PD_PORT_TCPC_0] = {
.i2c_port = I2C_PORT_PPC0,
@@ -251,34 +218,38 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
+static void reset_pd_port(int port, enum gpio_signal reset_gpio,
+ int hold_delay, int finish_delay)
+{
+ int level = !!(tcpc_config[port].flags & TCPC_FLAGS_RESET_ACTIVE_HIGH);
+
+ gpio_set_level(reset_gpio, level);
+ msleep(hold_delay);
+ gpio_set_level(reset_gpio, !level);
+ if (finish_delay)
+ msleep(finish_delay);
+}
+
void board_reset_pd_mcu(void)
{
/*
- * C0: Assert reset to TCPC0 (ANX7447) for required delay (1ms) only if
- * we have a battery
- *
- */
- if (battery_is_present() == BP_YES) {
- gpio_set_level(GPIO_USB_C0_TCPC_RST, 1);
- msleep(ANX74XX_RESET_HOLD_MS);
- gpio_set_level(GPIO_USB_C0_TCPC_RST, 0);
- msleep(ANX74XX_RESET_FINISH_MS);
- }
- /*
- * C1: Assert reset to TCPC1 (PS8751) for required delay (1ms) only if
- * we have a battery, otherwise we may brown out the system.
+ * TODO(b/130194590): This should be replaced with a common function
+ * once the gpio signal and delays are added to tcpc_config struct.
*/
- if (battery_is_present() == BP_YES) {
- /*
- * TODO(crbug:846412): After refactor, ensure that battery has
- * enough charge to last the reboot as well
- */
- gpio_set_level(GPIO_USB_C1_TCPC_RST_ODL, 0);
- msleep(PS8XXX_RESET_DELAY_MS);
- gpio_set_level(GPIO_USB_C1_TCPC_RST_ODL, 1);
- } else {
- CPRINTS("Skipping C1 TCPC reset because no battery");
- }
+
+ /* Assert reset to TCPC for required delay only if we have a battery. */
+ if (battery_is_present() != BP_YES)
+ return;
+
+ /* Reset TCPC0 */
+ reset_pd_port(USB_PD_PORT_TCPC_0, GPIO_USB_C0_TCPC_RST,
+ BOARD_TCPC_C0_RESET_HOLD_DELAY,
+ BOARD_TCPC_C0_RESET_POST_DELAY);
+
+ /* Reset TCPC1 */
+ reset_pd_port(USB_PD_PORT_TCPC_1, GPIO_USB_C1_TCPC_RST_ODL,
+ BOARD_TCPC_C1_RESET_HOLD_DELAY,
+ BOARD_TCPC_C1_RESET_POST_DELAY);
}
void board_pd_vconn_ctrl(int port, int cc_pin, int enabled)
diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h
index 5028e556b9..81b91dcb6c 100644
--- a/baseboard/hatch/baseboard.h
+++ b/baseboard/hatch/baseboard.h
@@ -96,8 +96,6 @@
#define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0
#define CONFIG_USB_PD_TCPC_LOW_POWER
#define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
-#define CONFIG_USB_PD_TCPM_ANX7447
-#define CONFIG_USB_PD_TCPM_PS8751
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_LOGGING
#define CONFIG_USB_PD_ALT_MODE
@@ -116,6 +114,9 @@
#define CONFIG_CMD_PD_CONTROL
#define CONFIG_CMD_PPC_DUMP
+#define USB_PD_PORT_TCPC_0 0
+#define USB_PD_PORT_TCPC_1 1
+
/* BC 1.2 */
#define CONFIG_USB_CHARGER
#define CONFIG_BC12_DETECT_PI3USB9201