Skip to content

Commit

Permalink
dts: stm32f3: Remap USB IRQ to avoid conflict with CAN
Browse files Browse the repository at this point in the history
On stm32f302/3 series, USB and CAN_1 share same IRQ lines.
To use USB and CAN_1 together, USB IRQ could be remap to other
line numbers, on which there is no conflict.
Remap the USB IRQ lines by default:
-Assign remap number in matching dtsi files
-Perform remap in usb driver init

Additionally, fix compilation issue in usb driver.

Fixes zephyrproject-rtos#22343

Signed-off-by: Erwan Gouriou <[email protected]>
  • Loading branch information
erwango committed Jan 31, 2020
1 parent fbbf68d commit c01c00b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/usb/device/usb_dc_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ static int usb_dc_stm32_init(void)
}
#endif /* USB */

#ifdef SYSCFG_CFGR1_USB_IT_RMP
/* On STM32F302/F303 USB IRQ collides with CAN_1 IRQ */
/* Remap IRQ by default to enable use of both IPs simultaneoulsy */
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

IRQ_CONNECT(DT_USB_IRQ, DT_USB_IRQ_PRI,
usb_dc_stm32_isr, 0, 0);
irq_enable(DT_USB_IRQ);
Expand All @@ -395,7 +406,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_LB 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_LB 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

0 comments on commit c01c00b

Please sign in to comment.