From 37514ae660ad04aad35c96c3aa6c6af38a742a26 Mon Sep 17 00:00:00 2001 From: Richard Osterloh Date: Wed, 4 Sep 2019 09:48:18 +0100 Subject: [PATCH] drivers: usb: Add STM32G4X USB support Add USB driver support for STM32G4X SoC series. Signed-off-by: Richard Osterloh --- drivers/usb/device/Kconfig | 2 +- drivers/usb/device/usb_dc_stm32.c | 2 +- dts/arm/st/g4/stm32g4.dtsi | 18 ++++++++++++++++++ soc/arm/st_stm32/stm32g4/dts_fixup.h | 8 ++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/usb/device/Kconfig b/drivers/usb/device/Kconfig index 1143c194fd1..fc8f0ba2711 100644 --- a/drivers/usb/device/Kconfig +++ b/drivers/usb/device/Kconfig @@ -37,7 +37,7 @@ config USB_DC_STM32 select USE_STM32_HAL_PCD select USE_STM32_HAL_PCD_EX help - Enable USB support on the STM32 F0, F1, F2, F3, F4, F7, L0 and L4 family of + Enable USB support on the STM32 F0, F1, F2, F3, F4, F7, L0, L4 and G4 family of processors. config USB_DC_SAM0 diff --git a/drivers/usb/device/usb_dc_stm32.c b/drivers/usb/device/usb_dc_stm32.c index 03166f74bd0..d9bdb808805 100644 --- a/drivers/usb/device/usb_dc_stm32.c +++ b/drivers/usb/device/usb_dc_stm32.c @@ -75,7 +75,7 @@ LOG_MODULE_REGISTER(usb_dc_stm32); /* * USB and USB_OTG_FS are defined in STM32Cube HAL and allows to distinguish - * between two kind of USB DC. STM32 F0, F3, and L0 series support USB device + * between two kind of USB DC. STM32 F0, F3, L0 and G4 series support USB device * controller. STM32 F4 and F7 series support USB_OTG_FS device controller. * STM32 F1 and L4 series support either USB or USB_OTG_FS device controller. * diff --git a/dts/arm/st/g4/stm32g4.dtsi b/dts/arm/st/g4/stm32g4.dtsi index c47972acbf8..7387f6af00b 100644 --- a/dts/arm/st/g4/stm32g4.dtsi +++ b/dts/arm/st/g4/stm32g4.dtsi @@ -409,8 +409,26 @@ label = "RTC_0"; }; + usb: usb@40005c00 { + compatible = "st,stm32-usb"; + reg = <0x40005c00 0x400>; + interrupts = <20 0>, <19 0>; + interrupt-names = "usb", "usbhp"; + num-bidir-endpoints = <8>; + ram-size = <1024>; + phys = <&usb_fs_phy>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00800000>; + status = "disabled"; + label= "USB"; + }; + }; + usb_fs_phy: usbphy { + compatible = "usb-nop-xceiv"; + #phy-cells = <0>; + label = "USB_FS_PHY"; + }; }; &nvic { diff --git a/soc/arm/st_stm32/stm32g4/dts_fixup.h b/soc/arm/st_stm32/stm32g4/dts_fixup.h index a0e52d3c42f..6ff0a6284cb 100644 --- a/soc/arm/st_stm32/stm32g4/dts_fixup.h +++ b/soc/arm/st_stm32/stm32g4/dts_fixup.h @@ -177,6 +177,14 @@ #define DT_SPI_3_CLOCK_BITS DT_ST_STM32_SPI_FIFO_40003C00_CLOCK_BITS #define DT_SPI_3_CLOCK_BUS DT_ST_STM32_SPI_FIFO_40003C00_CLOCK_BUS +#define DT_USB_BASE_ADDRESS DT_ST_STM32_USB_40005C00_BASE_ADDRESS +#define DT_USB_IRQ DT_ST_STM32_USB_40005C00_IRQ_USB +#define DT_USB_IRQ_PRI DT_ST_STM32_USB_40005C00_IRQ_USB_PRIORITY +#define DT_USB_NUM_BIDIR_ENDPOINTS DT_ST_STM32_USB_40005C00_NUM_BIDIR_ENDPOINTS +#define DT_USB_RAM_SIZE DT_ST_STM32_USB_40005C00_RAM_SIZE +#define DT_USB_CLOCK_BITS DT_ST_STM32_USB_40005C00_CLOCK_BITS +#define DT_USB_CLOCK_BUS DT_ST_STM32_USB_40005C00_CLOCK_BUS + #define DT_PWM_STM32_1_DEV_NAME DT_ST_STM32_PWM_40012C00_PWM_LABEL #define DT_PWM_STM32_1_PRESCALER DT_ST_STM32_PWM_40012C00_PWM_ST_PRESCALER #define DT_TIM_STM32_1_BASE_ADDRESS DT_ST_STM32_TIMERS_40012C00_BASE_ADDRESS