summaryrefslogtreecommitdiff
path: root/chip/g
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2019-08-08 09:46:43 -0700
committerCommit Bot <commit-bot@chromium.org>2019-09-19 03:03:34 +0000
commit16d2b24ac05f7a5654bddcf9cb61f0f6684d1806 (patch)
tree6d20d184c6b3752376d4492bd925f367bf8ef87c /chip/g
parent580a54658ad27550a1da5cd6077b901a12d447f2 (diff)
downloadchrome-ec-16d2b24ac05f7a5654bddcf9cb61f0f6684d1806.tar.gz
g: re-implement usb console with usb-stream configuration.
This patch introduces CONFIG_USB_CONSOLE_STREAM, which implements usb-console with usb-stream configuration, intending to remove code redundancy between the previous implementation (usb_console.c) and usb_stream.c. Flash usage decreases by 224 bytes, and RAM usage by 40 bytes. BUG=b:138447451 BRANCH=cr50 TEST=Checked cr50 USB console and cr50 UART console respectively. Key-in response and output are working well: ./util/uart_stress_tester.py /dev/ttyUSB0 -t 300 --debug Change-Id: I305038e1db83dc49bb12a8afdbfcc2a8135d50f5 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1741302 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'chip/g')
-rw-r--r--chip/g/usb-stream.c4
-rw-r--r--chip/g/usb-stream.h8
2 files changed, 11 insertions, 1 deletions
diff --git a/chip/g/usb-stream.c b/chip/g/usb-stream.c
index b929cf7d4e..ae3b42e5c2 100644
--- a/chip/g/usb-stream.c
+++ b/chip/g/usb-stream.c
@@ -117,7 +117,7 @@ void usb_stream_rx(struct usb_stream_config const *config)
}
/* True if the Tx/IN FIFO can take some bytes from us. */
-static inline int tx_fifo_is_ready(struct usb_stream_config const *config)
+int tx_fifo_is_ready(struct usb_stream_config const *config)
{
uint32_t status;
struct g_usb_desc *in_desc = config->in_desc;
@@ -290,6 +290,8 @@ void usb_stream_reset(struct usb_stream_config const *config)
GR_USB_DAINTMSK |= DAINT_INEP(config->endpoint) |
DAINT_OUTEP(config->endpoint);
+ *config->is_reset = 1;
+
/* Flush any queued data */
tx_stream_handler(config);
hook_call_deferred(config->deferred_rx, 0);
diff --git a/chip/g/usb-stream.h b/chip/g/usb-stream.h
index 6e01c3341c..49048a6d9c 100644
--- a/chip/g/usb-stream.h
+++ b/chip/g/usb-stream.h
@@ -33,6 +33,7 @@ struct usb_stream_config {
/* USB TX transfer is in progress */
uint8_t *tx_in_progress;
uint8_t *kicker_running;
+ uint8_t *is_reset;
/*
* Deferred function to call to handle USB and Queue request.
@@ -126,6 +127,7 @@ extern struct producer_ops const usb_stream_producer_ops;
static uint8_t CONCAT2(NAME, _buf_rx_)[RX_SIZE]; \
static uint8_t CONCAT2(NAME, _tx_in_progress_); \
static uint8_t CONCAT2(NAME, _kicker_running_); \
+ static uint8_t CONCAT2(NAME, _is_reset_); \
static void CONCAT2(NAME, _deferred_rx_)(void); \
static void CONCAT2(NAME, _tx_kicker_)(void); \
DECLARE_DEFERRED(CONCAT2(NAME, _deferred_rx_)); \
@@ -135,9 +137,11 @@ extern struct producer_ops const usb_stream_producer_ops;
struct usb_stream_config const NAME = { \
.endpoint = ENDPOINT, \
.is_uart_console = ((ENDPOINT == USB_EP_EC) || \
+ (ENDPOINT == USB_EP_CONSOLE) || \
(ENDPOINT == USB_EP_AP)), \
.tx_in_progress = &CONCAT2(NAME, _tx_in_progress_), \
.kicker_running = &CONCAT2(NAME, _kicker_running_), \
+ .is_reset = &CONCAT2(NAME, _is_reset_), \
.in_desc = &CONCAT2(NAME, _in_desc_)[0], \
.out_desc = &CONCAT2(NAME, _out_desc_), \
.deferred_rx = &CONCAT2(NAME, _deferred_rx__data), \
@@ -242,4 +246,8 @@ void usb_stream_tx(struct usb_stream_config const *config);
void usb_stream_rx(struct usb_stream_config const *config);
void usb_stream_reset(struct usb_stream_config const *config);
+/*
+ * Return non-zero if the USB stream is reset, or 0 otherwise
+ */
+int tx_fifo_is_ready(struct usb_stream_config const *config);
#endif /* __CROS_EC_USB_STREAM_H */