From a4bfc663a3cd645b43963bb814269efe864f8d1e Mon Sep 17 00:00:00 2001 From: Nick Sanders Date: Tue, 2 Aug 2016 19:35:44 -0700 Subject: sweetberry: add dwc usb support stm32f446 uses a synopsys designware USB block rather than the typical ST one. This change adds driver support for the new block, including usb console support. BUG=chromium:608039 TEST=usb console works BRANCH=None Change-Id: I0e143758ae0b5285f1c94ea2ec5aee159e22e00c Signed-off-by: Nick Sanders Reviewed-on: https://chromium-review.googlesource.com/365448 Reviewed-by: Randall Spangler --- board/sweetberry/board.c | 33 +++++++++++++++++++++++++++++++++ board/sweetberry/board.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) (limited to 'board/sweetberry') diff --git a/board/sweetberry/board.c b/board/sweetberry/board.c index 21c595826f..5c29b553ee 100644 --- a/board/sweetberry/board.c +++ b/board/sweetberry/board.c @@ -14,7 +14,35 @@ #include "registers.h" #include "stm32-dma.h" #include "task.h" +#include "usb_descriptor.h" #include "util.h" +#include "usb_dwc_hw.h" +#include "usb_dwc_console.h" + +/****************************************************************************** + * Define the strings used in our USB descriptors. + */ +const void *const usb_strings[] = { + [USB_STR_DESC] = usb_string_desc, + [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."), + [USB_STR_PRODUCT] = USB_STRING_DESC("Sweetberry"), + [USB_STR_SERIALNO] = USB_STRING_DESC("1234-a"), + [USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32), + [USB_STR_CONSOLE_NAME] = USB_STRING_DESC("Sweetberry EC Shell"), +}; + +BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT); + +struct dwc_usb usb_ctl = { + .ep = { + &ep0_ctl, + &ep_console_ctl, + }, + .speed = USB_SPEED_FS, + .phy_type = USB_PHY_ULPI, + .dma_en = 1, + .irq = STM32_IRQ_OTG_HS, +}; /* I2C ports */ const struct i2c_port_t i2c_ports[] = { @@ -39,6 +67,11 @@ void board_config_post_gpio_init(void) /* GPIO PC9 to high speed */ GPIO_SET_HS(C, 9); + if (usb_ctl.phy_type == USB_PHY_ULPI) + gpio_set_level(GPIO_USB_MUX_SEL, 0); + else + gpio_set_level(GPIO_USB_MUX_SEL, 1); + /* Set USB GPIO to high speed */ GPIO_SET_HS(A, 11); GPIO_SET_HS(A, 12); diff --git a/board/sweetberry/board.h b/board/sweetberry/board.h index 407d30e442..4bb8a13535 100644 --- a/board/sweetberry/board.h +++ b/board/sweetberry/board.h @@ -36,6 +36,26 @@ #define I2C_PORT_2 2 #define FMPI2C_PORT_3 3 +/* USB Configuration */ +#define CONFIG_USB +#define CONFIG_USB_PID 0x5020 +#define CONFIG_USB_CONSOLE + +#undef CONFIG_USB_MAXPOWER_MA +#define CONFIG_USB_MAXPOWER_MA 100 + +#define CONFIG_USB_SERIALNO +#define DEFAULT_SERIALNO "Uninitialized" + +/* USB interface indexes (use define rather than enum to expand them) */ +#define USB_IFACE_CONSOLE 0 +#define USB_IFACE_COUNT 1 + +/* USB endpoint indexes (use define rather than enum to expand them) */ +#define USB_EP_CONTROL 0 +#define USB_EP_CONSOLE 1 +#define USB_EP_COUNT 2 + /* This is not actually a Chromium EC so disable some features. */ #undef CONFIG_WATCHDOG_HELP #undef CONFIG_LID_SWITCH @@ -57,5 +77,16 @@ #include "gpio_signal.h" +/* USB string indexes */ +enum usb_strings { + USB_STR_DESC = 0, + USB_STR_VENDOR, + USB_STR_PRODUCT, + USB_STR_SERIALNO, + USB_STR_VERSION, + USB_STR_CONSOLE_NAME, + USB_STR_COUNT +}; + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ -- cgit v1.2.1