summaryrefslogtreecommitdiff
path: root/board/gingerbread
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2021-02-16 13:38:33 -0800
committerCommit Bot <commit-bot@chromium.org>2021-03-24 23:33:07 +0000
commit2cee0e2eb293cea2ccc1ae782de85480dc04d808 (patch)
treeaf410ddfd0b033f7029aafadc8de03effbb65e67 /board/gingerbread
parent1403ddcbbdea6a55db88465659af5f0cc79ace82 (diff)
downloadchrome-ec-2cee0e2eb293cea2ccc1ae782de85480dc04d808.tar.gz
honeybuns: Add full usb-pd support for C0
This CL adds config options and board level structs to fully support USB-PD on port C0 for both gingerbread and quiche. This includes all the svdm response functions required for support of DP Alt-mode as a UFP_D. This also includes honeybuns specific version of usb-pd policy functions. BUG=b:175660576 BRANCH=None TEST=Verify that C0 port can establish PD contract, enter ALT-DP mode and extend display over DP/HDMI connectors. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I11edee85e63381f00114e9fbe012a37fd8174279 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2699455 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'board/gingerbread')
-rw-r--r--board/gingerbread/board.c48
-rw-r--r--board/gingerbread/board.h6
-rw-r--r--board/gingerbread/ec.tasklist1
-rw-r--r--board/gingerbread/gpio.inc4
4 files changed, 52 insertions, 7 deletions
diff --git a/board/gingerbread/board.c b/board/gingerbread/board.c
index 03d70a69d3..82f02da6d3 100644
--- a/board/gingerbread/board.c
+++ b/board/gingerbread/board.c
@@ -7,24 +7,34 @@
#include "common.h"
#include "driver/ppc/sn5s330.h"
+#include "driver/tcpm/ps8xxx.h"
#include "driver/tcpm/stm32gx.h"
#include "driver/tcpm/tcpci.h"
+#include "driver/usb_mux/tusb1064.h"
#include "ec_version.h"
#include "gpio.h"
#include "hooks.h"
+#include "mp4245.h"
#include "switch.h"
#include "system.h"
#include "task.h"
+#include "timer.h"
#include "uart.h"
#include "usb_descriptor.h"
#include "usb_pd.h"
#include "usbc_ppc.h"
+#include "usb_descriptor.h"
+#include "usb_pd_dp_ufp.h"
+#include "usb_pe_sm.h"
+#include "usb_prl_sm.h"
+#include "usb_tc_sm.h"
#include "util.h"
-
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
+#define QUICHE_PD_DEBUG_LVL 1
+
#ifdef SECTION_IS_RW
#define CROS_EC_SECTION "RW"
#else
@@ -32,6 +42,10 @@
#endif
#ifdef SECTION_IS_RW
+static int pd_dual_role_init[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ PD_DRP_TOGGLE_ON,
+};
+
static void ppc_interrupt(enum gpio_signal signal)
{
switch (signal) {
@@ -44,6 +58,10 @@ static void ppc_interrupt(enum gpio_signal signal)
}
}
+void hpd_interrupt(enum gpio_signal signal)
+{
+ usb_pd_hpd_edge_event(signal);
+}
#endif /* SECTION_IS_RW */
#include "gpio_list.h" /* Must come after other header files. */
@@ -115,8 +133,9 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_HOST] = {
.usb_port = USB_PD_PORT_HOST,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
+ .i2c_port = I2C_PORT_I2C1,
+ .i2c_addr_flags = TUSB1064_I2C_ADDR0_FLAGS,
+ .driver = &tusb1064_usb_mux_driver,
},
};
@@ -130,14 +149,35 @@ struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
+const struct hpd_to_pd_config_t hpd_config = {
+ .port = USB_PD_PORT_HOST,
+ .signal = GPIO_DDI_MST_IN_HPD,
+};
+
+void board_reset_pd_mcu(void)
+{
+
+}
+
+
/* Power Delivery and charging functions */
void board_tcpc_init(void)
{
+ board_reset_pd_mcu();
+
/* Enable PPC interrupts. */
gpio_enable_interrupt(GPIO_HOST_USBC_PPC_INT_ODL);
+
+ /* Enable HPD interrupt */
+ gpio_enable_interrupt(GPIO_DDI_MST_IN_HPD);
+
}
-DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
+DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 2);
+enum pd_dual_role_states board_tc_get_initial_drp_mode(int port)
+{
+ return pd_dual_role_init[port];
+}
int ppc_get_alert_status(int port)
{
diff --git a/board/gingerbread/board.h b/board/gingerbread/board.h
index 75780a3fb2..1c5983cf68 100644
--- a/board/gingerbread/board.h
+++ b/board/gingerbread/board.h
@@ -20,7 +20,9 @@
/* USB Type C and USB PD defines */
#define USB_PD_PORT_HOST 0
#define USB_PD_PORT_DP 1
+
#define CONFIG_USB_PD_PORT_MAX_COUNT 1
+#define CONFIG_USB_MUX_TUSB1064
#define CONFIG_USB_PID 0x5049
#define CONFIG_USB_BCD_DEV 0x0001 /* v 0.01 */
@@ -34,7 +36,7 @@
/* Required symbolic I2C port names */
#define I2C_PORT_MP4245 I2C_PORT_I2C3
#define I2C_PORT_EEPROM I2C_PORT_I2C1
-#define MP4245_SLAVE_ADDR MP4245_I2C_ADDR_0_FLAGS
+#define MP4245_I2C_ADDR_FLAGS MP4245_I2C_ADDR_0_FLAGS
/*
* Macros for GPIO signals used in common code that don't match the
@@ -50,6 +52,8 @@
#include "registers.h"
+#define GPIO_DP_HPD GPIO_DDI_MST_IN_HPD
+
#define GPIO_TRIGGER_1 GPIO_EC_HUB1_RESET_L
#define GPIO_TRIGGER_2 GPIO_EC_HUB2_RESET_L
diff --git a/board/gingerbread/ec.tasklist b/board/gingerbread/ec.tasklist
index 1f79cd8fbd..f884f8df16 100644
--- a/board/gingerbread/ec.tasklist
+++ b/board/gingerbread/ec.tasklist
@@ -11,4 +11,5 @@
TASK_ALWAYS_RO(RWSIG, rwsig_task, NULL, 1280) \
TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS_RW(PD_C0, pd_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS_RW(UCPD, ucpd_task, 0, LARGER_TASK_STACK_SIZE)
diff --git a/board/gingerbread/gpio.inc b/board/gingerbread/gpio.inc
index e3bb4e2ad4..532903a98b 100644
--- a/board/gingerbread/gpio.inc
+++ b/board/gingerbread/gpio.inc
@@ -10,10 +10,10 @@
#ifdef SECTION_IS_RW
GPIO_INT(HOST_USBC_PPC_INT_ODL, PIN(C, 1), GPIO_INT_FALLING | GPIO_PULL_UP, ppc_interrupt)
-/* TODO (b/183289386): These singals are required for C0 and C1 operation.
+/* TODO (b/183289386): These singals are required for C1 operation.
* GPIO_INT(USBC_DP_MUX_ALERT_ODL, PIN(C, 12), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event)
- * GPIO_INT(DDI_MST_IN_HPD, PIN(C, 14), GPIO_INT_BOTH, hpd_interrupt)
*/
+GPIO_INT(DDI_MST_IN_HPD, PIN(C, 14), GPIO_INT_BOTH, hpd_interrupt)
#endif
/* Power sequencing signals */