summaryrefslogtreecommitdiff
path: root/chip/stm32/usb_dwc_console.c
diff options
context:
space:
mode:
Diffstat (limited to 'chip/stm32/usb_dwc_console.c')
-rw-r--r--chip/stm32/usb_dwc_console.c64
1 files changed, 29 insertions, 35 deletions
diff --git a/chip/stm32/usb_dwc_console.c b/chip/stm32/usb_dwc_console.c
index 0d1340fb83..fd66db7380 100644
--- a/chip/stm32/usb_dwc_console.c
+++ b/chip/stm32/usb_dwc_console.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -17,7 +17,7 @@
#include "usb_hw.h"
/* Console output macro */
-#define CPRINTF(format, args...) cprintf(CC_USB, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
#define USB_CONSOLE_TIMEOUT_US (30 * MSEC)
static int last_tx_ok = 1;
@@ -28,31 +28,31 @@ static int is_readonly;
/* USB-Serial descriptors */
const struct usb_interface_descriptor USB_IFACE_DESC(USB_IFACE_CONSOLE) = {
- .bLength = USB_DT_INTERFACE_SIZE,
- .bDescriptorType = USB_DT_INTERFACE,
- .bInterfaceNumber = USB_IFACE_CONSOLE,
- .bAlternateSetting = 0,
- .bNumEndpoints = 2,
- .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
- .bInterfaceSubClass = USB_SUBCLASS_GOOGLE_SERIAL,
- .bInterfaceProtocol = USB_PROTOCOL_GOOGLE_SERIAL,
- .iInterface = USB_STR_CONSOLE_NAME,
+ .bLength = USB_DT_INTERFACE_SIZE,
+ .bDescriptorType = USB_DT_INTERFACE,
+ .bInterfaceNumber = USB_IFACE_CONSOLE,
+ .bAlternateSetting = 0,
+ .bNumEndpoints = 2,
+ .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
+ .bInterfaceSubClass = USB_SUBCLASS_GOOGLE_SERIAL,
+ .bInterfaceProtocol = USB_PROTOCOL_GOOGLE_SERIAL,
+ .iInterface = USB_STR_CONSOLE_NAME,
};
const struct usb_endpoint_descriptor USB_EP_DESC(USB_IFACE_CONSOLE, 0) = {
- .bLength = USB_DT_ENDPOINT_SIZE,
- .bDescriptorType = USB_DT_ENDPOINT,
- .bEndpointAddress = 0x80 | USB_EP_CONSOLE,
- .bmAttributes = 0x02 /* Bulk IN */,
- .wMaxPacketSize = USB_MAX_PACKET_SIZE,
- .bInterval = 10,
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = 0x80 | USB_EP_CONSOLE,
+ .bmAttributes = 0x02 /* Bulk IN */,
+ .wMaxPacketSize = USB_MAX_PACKET_SIZE,
+ .bInterval = 10,
};
const struct usb_endpoint_descriptor USB_EP_DESC(USB_IFACE_CONSOLE, 1) = {
- .bLength = USB_DT_ENDPOINT_SIZE,
- .bDescriptorType = USB_DT_ENDPOINT,
- .bEndpointAddress = USB_EP_CONSOLE,
- .bmAttributes = 0x02 /* Bulk OUT */,
- .wMaxPacketSize = USB_MAX_PACKET_SIZE,
- .bInterval = 0
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = USB_EP_CONSOLE,
+ .bmAttributes = 0x02 /* Bulk OUT */,
+ .wMaxPacketSize = USB_MAX_PACKET_SIZE,
+ .bInterval = 0
};
static uint8_t ep_buf_tx[USB_MAX_PACKET_SIZE];
@@ -61,7 +61,6 @@ static uint8_t ep_buf_rx[USB_MAX_PACKET_SIZE];
static struct queue const tx_q = QUEUE_NULL(256, uint8_t);
static struct queue const rx_q = QUEUE_NULL(USB_MAX_PACKET_SIZE, uint8_t);
-
struct dwc_usb_ep ep_console_ctl = {
.max_packet = USB_MAX_PACKET_SIZE,
.tx_fifo = USB_EP_CONSOLE,
@@ -76,8 +75,6 @@ struct dwc_usb_ep ep_console_ctl = {
.in_databuffer_max = sizeof(ep_buf_rx),
};
-
-
/* Let the USB HW IN-to-host FIFO transmit some bytes */
static void usb_enable_tx(int len)
{
@@ -162,9 +159,8 @@ static void con_ep_rx(void)
/* Bytes received decrement DOEPTSIZ XFERSIZE */
if (GR_USB_DOEPINT(USB_EP_CONSOLE) & DOEPINT_XFERCOMPL) {
ep->out_pending =
- ep->max_packet -
- (GR_USB_DOEPTSIZ(USB_EP_CONSOLE) &
- GC_USB_DOEPTSIZ1_XFERSIZE_MASK);
+ ep->max_packet - (GR_USB_DOEPTSIZ(USB_EP_CONSOLE) &
+ GC_USB_DOEPTSIZ1_XFERSIZE_MASK);
}
/* Wake up the Rx FIFO handler */
@@ -193,8 +189,8 @@ static void tx_fifo_handler(void)
if (!tx_fifo_is_ready())
return;
- count = QUEUE_REMOVE_UNITS(&tx_q,
- ep->in_databuffer, USB_MAX_PACKET_SIZE);
+ count = QUEUE_REMOVE_UNITS(&tx_q, ep->in_databuffer,
+ USB_MAX_PACKET_SIZE);
if (count)
usb_enable_tx(count);
}
@@ -232,7 +228,6 @@ static void ep_event(enum usb_ep_event evt)
usb_enable_rx(USB_MAX_PACKET_SIZE);
}
-
USB_DECLARE_EP(USB_EP_CONSOLE, con_ep_tx, con_ep_rx, ep_event);
static int usb_wait_console(void)
@@ -274,8 +269,7 @@ static int usb_wait_console(void)
}
static int __tx_char(void *context, int c)
{
- struct queue *state =
- (struct queue *) context;
+ struct queue *state = (struct queue *)context;
if (c == '\n' && __tx_char(state, '\r'))
return 1;
@@ -308,7 +302,7 @@ int usb_puts(const char *outstr)
if (is_readonly)
return EC_SUCCESS;
- ret = usb_wait_console();
+ ret = usb_wait_console();
if (ret)
return ret;