Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dts: stm32f3: Remap USB IRQ to avoid conflict with CAN #22373

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions drivers/clock_control/clock_stm32f0_f3.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ void config_enable_default_clocks(void)
/* Enable System Configuration Controller clock. */
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_SYSCFG);
#endif
#else
#if defined(CONFIG_USB_DC_STM32) && defined(SYSCFG_CFGR1_USB_IT_RMP)
/* Enable System Configuration Controller clock. */
/* SYSCFG is required to remap IRQ to avoid conflicts with CAN */
/* cf §14.1.3, RM0316 */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
#endif
#endif /* !CONFIG_SOC_SERIES_STM32F3X */
}

Expand Down
16 changes: 15 additions & 1 deletion drivers/usb/device/usb_dc_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,20 @@ int usb_dc_attach(void)

LOG_DBG("");

#ifdef SYSCFG_CFGR1_USB_IT_RMP
/*
* STM32F302/F303: USB IRQ collides with CAN_1 IRQ (§14.1.3, RM0316)
* Remap IRQ by default to enable use of both IPs simultaneoulsy
* This should be done before calling any HAL function
*/
if (LL_APB2_GRP1_IsEnabledClock(LL_APB2_GRP1_PERIPH_SYSCFG)) {
LL_SYSCFG_EnableRemapIT_USB();
} else {
LOG_ERR("System Configuration Controller clock is "
"disabled. Unable to enable IRQ remapping.");
}
#endif

/*
* For STM32F0 series SoCs on QFN28 and TSSOP20 packages enable PIN
* pair PA11/12 mapped instead of PA9/10 (e.g. stm32f070x6)
Expand All @@ -395,7 +409,7 @@ int usb_dc_attach(void)
LL_SYSCFG_EnablePinRemap();
} else {
LOG_ERR("System Configuration Controller clock is "
"disable. Unable to enable pin remapping."
"disabled. Unable to enable pin remapping.");
}
#endif

Expand Down
5 changes: 5 additions & 0 deletions dts/arm/st/f3/stm32f302.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

/ {
soc {
usb: usb@40005c00 {
/* Remap USB_LP IRQ to enable use with CAN_1 */
interrupts = <75 0>;
};

i2c2: i2c@40005800 {
compatible = "st,stm32-i2c-v2";
clock-frequency = <I2C_BITRATE_STANDARD>;
Expand Down
5 changes: 5 additions & 0 deletions dts/arm/st/f3/stm32f303.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

/ {
soc {
usb: usb@40005c00 {
/* Remap USB_LP IRQ to enable use with CAN_1 */
interrupts = <75 0>;
};

i2c2: i2c@40005800 {
compatible = "st,stm32-i2c-v2";
clock-frequency = <I2C_BITRATE_STANDARD>;
Expand Down