diff options
author | Nick Sanders <nsanders@chromium.org> | 2016-08-02 19:35:44 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-09-01 22:56:22 -0700 |
commit | a4bfc663a3cd645b43963bb814269efe864f8d1e (patch) | |
tree | 185ab7cc413c4b580ea50845a024838aba577732 /chip/stm32/usb_dwc_hw.h | |
parent | 54f4612764e07e5e3ccd8a4af04ee83a46454612 (diff) | |
download | chrome-ec-a4bfc663a3cd645b43963bb814269efe864f8d1e.tar.gz |
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 <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/365448
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'chip/stm32/usb_dwc_hw.h')
-rw-r--r-- | chip/stm32/usb_dwc_hw.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/chip/stm32/usb_dwc_hw.h b/chip/stm32/usb_dwc_hw.h new file mode 100644 index 0000000000..36361ab371 --- /dev/null +++ b/chip/stm32/usb_dwc_hw.h @@ -0,0 +1,45 @@ +/* Copyright 2016 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __CROS_EC_USB_DWC_HW_H +#define __CROS_EC_USB_DWC_HW_H + +#include "usb_dwc_registers.h" + +/* Helpers for endpoint declaration */ +#define _EP_HANDLER2(num, suffix) CONCAT3(ep_, num, suffix) +#define _EP_TX_HANDLER(num) _EP_HANDLER2(num, _tx) +#define _EP_RX_HANDLER(num) _EP_HANDLER2(num, _rx) +#define _EP_RESET_HANDLER(num) _EP_HANDLER2(num, _rst) + +#define USB_DECLARE_EP(num, tx_handler, rx_handler, rst_handler) \ + void _EP_TX_HANDLER(num)(void) \ + __attribute__ ((alias(STRINGIFY(tx_handler)))); \ + void _EP_RX_HANDLER(num)(void) \ + __attribute__ ((alias(STRINGIFY(rx_handler)))); \ + void _EP_RESET_HANDLER(num)(void) \ + __attribute__ ((alias(STRINGIFY(rst_handler)))) + +/* Endpoint callbacks */ +extern void (*usb_ep_tx[]) (void); +extern void (*usb_ep_rx[]) (void); +extern void (*usb_ep_reset[]) (void); +struct usb_setup_packet; +/* EP0 Interface handler callbacks */ +static int (*usb_iface_request[]) (struct usb_setup_packet *req); + +/* + * Declare any interface-specific control request handlers. These Setup packets + * arrive on the control endpoint (EP0), but are handled by the interface code. + * The callback must prepare the EP0 IN or OUT FIFOs and return the number of + * bytes placed in the IN FIFO. A negative return value will STALL the response + * (and thus indicate error to the host). + */ +#define _IFACE_HANDLER(num) CONCAT3(iface_, num, _request) +#define USB_DECLARE_IFACE(num, handler) \ + int _IFACE_HANDLER(num)(struct usb_setup_packet *req) \ + __attribute__ ((alias(STRINGIFY(handler)))) + +#endif /* __CROS_EC_USB_DWC_HW_H */ |