summaryrefslogtreecommitdiff
path: root/board/quiche/board.c
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2020-11-04 16:39:19 -0800
committerCommit Bot <commit-bot@chromium.org>2020-12-11 16:30:42 +0000
commitd7bf71b42b78fa09da12f764bd3571d0cc446765 (patch)
tree6aa24fd11dd4f5b909b8a05c46bc2875aef95b65 /board/quiche/board.c
parente1058a41ca850c8d1513021390defc5a4e5c4b07 (diff)
downloadchrome-ec-d7bf71b42b78fa09da12f764bd3571d0cc446765.tar.gz
honeybuns: Enable usbc support
This CL adds boards specific parts required to enable TCPMv2.0 for both quiche and gingerbread. TCPMv2 configs are included, though, only type-c support is being selected. The reason for this intermediate point is an attempt to have more manageable amounts of changes for CL reviews. BUG=b:167601672 BRANCH=None TEST=verfied type-c attaches properly on quiche Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I2a4c3bf4089fb3e167d06921b177d8c4e61a021f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215424 Tested-by: Scott Collyer <scollyer@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Auto-Submit: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'board/quiche/board.c')
-rw-r--r--board/quiche/board.c89
1 files changed, 88 insertions, 1 deletions
diff --git a/board/quiche/board.c b/board/quiche/board.c
index 46a19f4b5e..afcd9b1443 100644
--- a/board/quiche/board.c
+++ b/board/quiche/board.c
@@ -5,8 +5,35 @@
/* Quiche board-specific configuration */
+#include "common.h"
+#include "driver/ppc/sn5s330.h"
+#include "driver/tcpm/ps8xxx.h"
+#include "driver/tcpm/stm32gx.h"
+#include "driver/tcpm/tcpci.h"
+#include "gpio.h"
#include "hooks.h"
#include "switch.h"
+#include "system.h"
+#include "task.h"
+#include "uart.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
+
+static void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_HOST_USBC_PPC_INT_ODL:
+ sn5s330_interrupt(USB_PD_PORT_HOST);
+ break;
+
+ default:
+ break;
+ }
+}
#include "gpio_list.h" /* Must come after other header files. */
@@ -42,8 +69,68 @@ const struct power_seq board_power_seq[] = {
const size_t board_power_seq_count = ARRAY_SIZE(board_power_seq);
+/* TCPCs */
+const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
+ .drv = &stm32gx_tcpm_drv,
+ },
+};
+
+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,
+ },
+};
+
+/* USB-C PPC Configuration */
+struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ [USB_PD_PORT_HOST] = {
+ .i2c_port = I2C_PORT_USBC,
+ .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
+ .drv = &sn5s330_drv
+ },
+};
+unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
+
+/* Power Delivery and charging functions */
+void board_tcpc_init(void)
+{
+ /* Enable PPC interrupts. */
+ gpio_enable_interrupt(GPIO_HOST_USBC_PPC_INT_ODL);
+}
+DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
+
+static void board_select_drp_mode(void)
+{
+ /*
+ * Host port should operate as a dual role port. If it attaches as a
+ * sink, then it will trigger a PRS to end up as a SRC UFP. The port's
+ * DRP state only needs to be set once, after it's initialized in TCPMv2
+ * as the default role of sink only.
+ */
+ pd_set_dual_role(USB_PD_PORT_HOST, PD_DRP_TOGGLE_ON);
+ CPRINTS("ucpd: set drp toggle on");
+}
+DECLARE_DEFERRED(board_select_drp_mode);
+
static void board_init(void)
{
- /* TODO */
+ hook_call_deferred(&board_select_drp_mode_data, 50 * MSEC);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+int ppc_get_alert_status(int port)
+{
+ if (port == USB_PD_PORT_HOST)
+ return gpio_get_level(GPIO_HOST_USBC_PPC_INT_ODL) == 0;
+
+ return 0;
+}
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* TODO(b/174825406): check correct operation for honeybuns */
+}