diff options
-rw-r--r-- | chip/stm32/build.mk | 2 | ||||
-rw-r--r-- | chip/stm32/usb-stm32f0.c | 20 | ||||
-rw-r--r-- | chip/stm32/usb-stm32f3.c | 20 | ||||
-rw-r--r-- | chip/stm32/usb-stm32f3.h | 17 | ||||
-rw-r--r-- | chip/stm32/usb-stm32l.c | 20 | ||||
-rw-r--r-- | chip/stm32/usb.c | 32 |
6 files changed, 79 insertions, 32 deletions
diff --git a/chip/stm32/build.mk b/chip/stm32/build.mk index 57b711f094..75f97fb7b2 100644 --- a/chip/stm32/build.mk +++ b/chip/stm32/build.mk @@ -45,7 +45,7 @@ chip-$(CHIP_FAMILY_STM32F0)+=flash-f.o chip-$(CHIP_FAMILY_STM32F3)+=flash-f.o chip-$(CONFIG_ADC)+=adc-$(CHIP_FAMILY).o chip-$(CONFIG_PWM)+=pwm.o -chip-$(CONFIG_USB)+=usb.o usb_endpoints.o +chip-$(CONFIG_USB)+=usb.o usb-$(CHIP_FAMILY).o usb_endpoints.o chip-$(CONFIG_USB_CONSOLE)+=usb_console.o chip-$(CONFIG_USB_GPIO)+=usb_gpio.o chip-$(CONFIG_USB_HID)+=usb_hid.o diff --git a/chip/stm32/usb-stm32f0.c b/chip/stm32/usb-stm32f0.c new file mode 100644 index 0000000000..1805c74e5e --- /dev/null +++ b/chip/stm32/usb-stm32f0.c @@ -0,0 +1,20 @@ +/* Copyright (c) 2014 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. + * + * STM32F0 Family specific USB functionality + */ + +#include "registers.h" +#include "usb_api.h" + +void usb_connect(void) +{ + STM32_USB_BCDR |= (1 << 15) /* DPPU */; +} + +void usb_disconnect(void) +{ + /* disable pull-up on DP to disconnect */ + STM32_USB_BCDR &= ~(1 << 15) /* DPPU */; +} diff --git a/chip/stm32/usb-stm32f3.c b/chip/stm32/usb-stm32f3.c new file mode 100644 index 0000000000..ceab410da0 --- /dev/null +++ b/chip/stm32/usb-stm32f3.c @@ -0,0 +1,20 @@ +/* Copyright (c) 2014 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. + * + * STM32F3 Family specific USB functionality + */ + +#include "usb-stm32f3.h" + +#include "usb_api.h" + +void usb_connect(void) +{ + usb_board_connect(); +} + +void usb_disconnect(void) +{ + usb_board_connect(); +} diff --git a/chip/stm32/usb-stm32f3.h b/chip/stm32/usb-stm32f3.h new file mode 100644 index 0000000000..cf4590fa11 --- /dev/null +++ b/chip/stm32/usb-stm32f3.h @@ -0,0 +1,17 @@ +/* Copyright (c) 2014 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. + * + * STM32F3 Family specific USB functionality + */ + +/* + * A device that uses an STM32F3 part will need to define these two functions + * which are used to connect and disconnect the device from the USB bus. This + * is usually accomplished by enabling a pullup on the DP USB line. The pullup + * should be enabled by default so that the STM32 will enumerate correctly in + * DFU mode (which doesn't know how to enable the DP pullup, so it assumes that + * the pullup is always there). + */ +void usb_board_connect(void); +void usb_board_disconnect(void); diff --git a/chip/stm32/usb-stm32l.c b/chip/stm32/usb-stm32l.c new file mode 100644 index 0000000000..c5d58257cb --- /dev/null +++ b/chip/stm32/usb-stm32l.c @@ -0,0 +1,20 @@ +/* Copyright (c) 2014 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. + * + * STM32L Family specific USB functionality + */ + +#include "registers.h" +#include "usb_api.h" + +void usb_connect(void) +{ + STM32_SYSCFG_PMC |= 1; +} + +void usb_disconnect(void) +{ + /* disable pull-up on DP to disconnect */ + STM32_SYSCFG_PMC &= ~1; +} 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; |