summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2015-02-18 11:07:22 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-04 04:40:58 +0000
commit7f48c9a6b3029478cc78e60bec9fb3cc2859af92 (patch)
treead7d29474abbc64ecc342f9c67a5143b78cbb5c6
parente6f670440832f519464b19f497b4cac9476de548 (diff)
downloadchrome-ec-7f48c9a6b3029478cc78e60bec9fb3cc2859af92.tar.gz
Ryu: Add support for AP and SH console forwarding over USB
Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I28c593ebd242712df00863443d96830fa06b4d6b Reviewed-on: https://chromium-review.googlesource.com/255233 Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
-rw-r--r--board/ryu/board.c81
-rw-r--r--board/ryu/board.h22
-rw-r--r--board/ryu/gpio.inc4
3 files changed, 95 insertions, 12 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c
index 18241162cc..220fce39d3 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -29,6 +29,8 @@
#include "usb_pd.h"
#include "usb_pd_config.h"
#include "usb-stm32f3.h"
+#include "usb-stream.h"
+#include "usart-stm32f3.h"
#include "util.h"
#include "pi3usb9281.h"
@@ -176,15 +178,74 @@ void usb_evt(enum gpio_signal signal)
#include "gpio_list.h"
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("Ryu debug"),
- [USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32),
- [USB_STR_CONSOLE_NAME] = USB_STRING_DESC("EC_PD"),
+ [USB_STR_DESC] = usb_string_desc,
+ [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."),
+ [USB_STR_PRODUCT] = USB_STRING_DESC("Ryu debug"),
+ [USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32),
+ [USB_STR_CONSOLE_NAME] = USB_STRING_DESC("EC_PD"),
+ [USB_STR_AP_STREAM_NAME] = USB_STRING_DESC("AP"),
+ [USB_STR_SH_STREAM_NAME] = USB_STRING_DESC("SH"),
};
BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT);
+/*
+ * Define AP and SH console forwarding queues and associated USART and USB
+ * stream endpoints.
+ */
+
+QUEUE_CONFIG(ap_usart_to_usb, 64, uint8_t);
+QUEUE_CONFIG(usb_to_ap_usart, 64, uint8_t);
+QUEUE_CONFIG(sh_usart_to_usb, 64, uint8_t);
+QUEUE_CONFIG(usb_to_sh_usart, 64, uint8_t);
+
+struct usb_stream_config const usb_ap_stream;
+struct usb_stream_config const usb_sh_stream;
+
+USART_CONFIG(usart1,
+ usart1_hw,
+ 115200,
+ ap_usart_to_usb,
+ usb_to_ap_usart,
+ usb_ap_stream.consumer,
+ usb_ap_stream.producer)
+
+USART_CONFIG(usart3,
+ usart3_hw,
+ 115200,
+ sh_usart_to_usb,
+ usb_to_sh_usart,
+ usb_sh_stream.consumer,
+ usb_sh_stream.producer)
+
+#define AP_USB_STREAM_RX_SIZE 16
+#define AP_USB_STREAM_TX_SIZE 16
+
+USB_STREAM_CONFIG(usb_ap_stream,
+ USB_IFACE_AP_STREAM,
+ USB_STR_AP_STREAM_NAME,
+ USB_EP_AP_STREAM,
+ AP_USB_STREAM_RX_SIZE,
+ AP_USB_STREAM_TX_SIZE,
+ usb_to_ap_usart,
+ ap_usart_to_usb,
+ usart1.consumer,
+ usart1.producer)
+
+#define SH_USB_STREAM_RX_SIZE 16
+#define SH_USB_STREAM_TX_SIZE 16
+
+USB_STREAM_CONFIG(usb_sh_stream,
+ USB_IFACE_SH_STREAM,
+ USB_STR_SH_STREAM_NAME,
+ USB_EP_SH_STREAM,
+ SH_USB_STREAM_RX_SIZE,
+ SH_USB_STREAM_TX_SIZE,
+ usb_to_sh_usart,
+ sh_usart_to_usb,
+ usart3.consumer,
+ usart3.producer)
+
/* Initialize board. */
static void board_init(void)
{
@@ -226,6 +287,16 @@ static void board_init(void)
host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY);
/*
+ * Initialize AP and SH console forwarding USARTs and queues.
+ */
+ queue_init(&ap_usart_to_usb);
+ queue_init(&usb_to_ap_usart);
+ queue_init(&sh_usart_to_usb);
+ queue_init(&usb_to_sh_usart);
+ usart_init(&usart1);
+ usart_init(&usart3);
+
+ /*
* Enable CC lines after all GPIO have been initialized. Note, it is
* important that this is enabled after the CC_DEVICE_ODL lines are
* set low to specify device mode.
diff --git a/board/ryu/board.h b/board/ryu/board.h
index ea8a566e11..7b8c710205 100644
--- a/board/ryu/board.h
+++ b/board/ryu/board.h
@@ -81,6 +81,12 @@
#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR 0x3c
#endif
+/* USART and USB stream drivers */
+#define CONFIG_STREAM_USART
+#define CONFIG_STREAM_USART1
+#define CONFIG_STREAM_USART3
+#define CONFIG_STREAM_USB
+
/* USB Configuration */
#define CONFIG_USB
#define CONFIG_USB_PID 0x500f
@@ -89,13 +95,17 @@
#define CONFIG_USB_INHIBIT_INIT
/* USB interface indexes (use define rather than enum to expand them) */
-#define USB_IFACE_CONSOLE 0
-#define USB_IFACE_COUNT 1
+#define USB_IFACE_CONSOLE 0
+#define USB_IFACE_AP_STREAM 1
+#define USB_IFACE_SH_STREAM 2
+#define USB_IFACE_COUNT 3
/* 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
+#define USB_EP_CONTROL 0
+#define USB_EP_CONSOLE 1
+#define USB_EP_AP_STREAM 2
+#define USB_EP_SH_STREAM 3
+#define USB_EP_COUNT 4
/* Enable console over USB */
#define CONFIG_USB_CONSOLE
@@ -157,6 +167,8 @@ enum usb_strings {
USB_STR_PRODUCT,
USB_STR_VERSION,
USB_STR_CONSOLE_NAME,
+ USB_STR_AP_STREAM_NAME,
+ USB_STR_SH_STREAM_NAME,
USB_STR_COUNT
};
diff --git a/board/ryu/gpio.inc b/board/ryu/gpio.inc
index eddcabec3b..1c921db0bb 100644
--- a/board/ryu/gpio.inc
+++ b/board/ryu/gpio.inc
@@ -119,8 +119,8 @@ UNIMPLEMENTED(AP_RESET_L)
ALTERNATE(B, 0x0008, 5, MODULE_USB_PD, 0) /* SPI1: SCK(PB3) */
ALTERNATE(B, 0x0002, 2, MODULE_USB_PD, 0) /* TIM3_CH4: PB1 */
-ALTERNATE(B, 0x00C0, 7, MODULE_UART, 0) /* USART1: PB6/PB7 */
+ALTERNATE(B, 0x00C0, 7, MODULE_USART, 0) /* USART1: PB6/PB7 */
ALTERNATE(D, 0x0060, 7, MODULE_UART, GPIO_PULL_UP) /* USART2: PD4/PD5 */
-ALTERNATE(C, 0x0C00, 7, MODULE_UART, 0) /* USART3: PC10/PC11 */
+ALTERNATE(C, 0x0C00, 7, MODULE_USART, 0) /* USART3: PC10/PC11 */
ALTERNATE(A, 0xC600, 4, MODULE_I2C, 0) /* I2C SLAVE:PA9/10 MASTER:PA14/15 */
ALTERNATE(A, 0x1800,14, MODULE_USB, 0) /* USB: PA11/12 */