summaryrefslogtreecommitdiff
path: root/chip/stm32/usb.c
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2014-11-11 07:58:52 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-11 21:46:16 +0000
commit947ee79ae0cf34ec6271305ae094e3c627456766 (patch)
tree1b653583d90a4afaaaa2d5f987c31a356aba9839 /chip/stm32/usb.c
parent74a98425efd53098ed430e6817261cf6386cce3a (diff)
downloadchrome-ec-947ee79ae0cf34ec6271305ae094e3c627456766.tar.gz
USB: Add support for board specific connect/disconnect
Previously the usb driver used #ifs to select a mechanism to enable and disable the DP pullup. This doesn't scale well, especially when the knowledge of how to do this is not known to the chip specific code, but instead is board specific (as it is with the STM32F373). This change uses the build systems ability to build chip family specific files per build to select the appropriate behavior. And on the STM32F3 family of parts it just calls out to a board specific pair of connect/disconnect functions. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Enable console on ryu_p2 and discovery-stm32f072 board Verify that it works on both Change-Id: I976e02fbc7acbb0f85817d7295b26ee9ecab0711 Reviewed-on: https://chromium-review.googlesource.com/229040 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'chip/stm32/usb.c')
-rw-r--r--chip/stm32/usb.c32
1 files changed, 1 insertions, 31 deletions
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c
index 18193d4ffa..425b768632 100644
--- a/chip/stm32/usb.c
+++ b/chip/stm32/usb.c
@@ -303,40 +303,10 @@ void usb_init(void)
}
DECLARE_HOOK(HOOK_INIT, usb_init, HOOK_PRIO_DEFAULT);
-void usb_disconnect(void)
-{
- /* disable pull-up on DP to disconnect */
-#ifdef CHIP_VARIANT_STM32L15X
- STM32_SYSCFG_PMC &= ~1;
-#elif defined(CHIP_FAMILY_STM32F0)
- STM32_USB_BCDR &= ~(1 << 15) /* DPPU */;
-#else
-#warn "usb disconnect not implemented for this chip family"
-#endif
-}
-
-void usb_connect(void)
-{
- /* enable pull-up on DP to connect */
-#ifdef CHIP_VARIANT_STM32L15X
- STM32_SYSCFG_PMC |= 1;
-#elif defined(CHIP_FAMILY_STM32F0)
- STM32_USB_BCDR |= (1 << 15) /* DPPU */;
-#else
-#warn "usb connect not implemented for this chip family"
-#endif
-}
-
void usb_release(void)
{
/* signal disconnect to host */
-#ifdef CHIP_VARIANT_STM32L15X
- STM32_SYSCFG_PMC &= ~1;
-#elif defined(CHIP_FAMILY_STM32F0)
- STM32_USB_BCDR &= ~(1 << 15) /* DPPU */;
-#else
- /* hardwired or regular GPIO on other platforms */
-#endif
+ usb_disconnect();
/* power down USB */
STM32_USB_CNTR = 0;