Skip to content
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
14 changes: 14 additions & 0 deletions drivers/can/Kconfig.stm32fd
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,28 @@ config CAN_STM32FD_CLOCK_SOURCE_HSE

config CAN_STM32FD_CLOCK_SOURCE_PLL
bool "PLL"
depends on !SOC_SERIES_STM32U5X
help
PLL "Q" clock used ad FDCAN clock source.

config CAN_STM32FD_CLOCK_SOURCE_PCLK1
bool "PCLK1"
depends on !SOC_SERIES_STM32U5X
help
PCLK1 clock used ad FDCAN clock source.

config CAN_STM32FD_CLOCK_SOURCE_PLL1Q
bool "PLL1Q"
depends on SOC_SERIES_STM32U5X
help
PLL1 "Q" clock used as FDCAN clock source.

config CAN_STM32FD_CLOCK_SOURCE_PLL2P
bool "PLL2P"
depends on SOC_SERIES_STM32U5X
help
PLL2 "P" clock used as FDCAN clock source.

endchoice

config CAN_STM32FD_CLOCK_DIVISOR
Expand Down
17 changes: 17 additions & 0 deletions drivers/can/can_stm32fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <kernel.h>
#include <soc.h>
#include <stm32_ll_rcc.h>
#include <stm32_ll_bus.h>
#include <logging/log.h>

#include "can_stm32fd.h"
Expand All @@ -22,6 +23,10 @@ LOG_MODULE_REGISTER(can_stm32fd, CONFIG_CAN_LOG_LEVEL);
#define CAN_STM32FD_CLOCK_SOURCE LL_RCC_FDCAN_CLKSOURCE_PLL
#elif defined(CONFIG_CAN_STM32FD_CLOCK_SOURCE_PCLK1)
#define CAN_STM32FD_CLOCK_SOURCE LL_RCC_FDCAN_CLKSOURCE_PCLK1
#elif defined(CONFIG_CAN_STM32FD_CLOCK_SOURCE_PLL1Q)
#define CAN_STM32FD_CLOCK_SOURCE LL_RCC_FDCAN_CLKSOURCE_PLL1
#elif defined(CONFIG_CAN_STM32FD_CLOCK_SOURCE_PLL2P)
#define CAN_STM32FD_CLOCK_SOURCE LL_RCC_FDCAN_CLKSOURCE_PLL2
#else
#error "Unsupported FDCAN clock source"
#endif
Expand Down Expand Up @@ -56,7 +61,19 @@ static int can_stm32fd_get_core_clock(const struct device *dev, uint32_t *rate)
static void can_stm32fd_clock_enable(void)
{
LL_RCC_SetFDCANClockSource(CAN_STM32FD_CLOCK_SOURCE);

/* LL_RCC API names do not align with PLL output name but are correct */
#ifdef CONFIG_CAN_STM32FD_CLOCK_SOURCE_PLL1Q
LL_RCC_PLL1_EnableDomain_48M();
#elif CONFIG_CAN_STM32FD_CLOCK_SOURCE_PLL2P
LL_RCC_PLL2_EnableDomain_SAI();
#endif

#ifdef CONFIG_SOC_SERIES_STM32U5X
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_FDCAN1);
#else
__HAL_RCC_FDCAN_CLK_ENABLE();
#endif

FDCAN_CONFIG->CKDIV = CAN_STM32FD_CLOCK_DIVISOR >> 1;
}
Expand Down
26 changes: 26 additions & 0 deletions dts/arm/st/u5/stm32u5.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,32 @@
has-vref-channel;
};

can {
compatible = "bosch,m-can-base";
#address-cells = <1>;
#size-cells = <1>;
std-filter-elements = <28>;
ext-filter-elements = <8>;
rx-fifo0-elements = <3>;
rx-fifo1-elements = <3>;
rx-buffer-elements = <0>;
tx-buffer-elements = <3>;

can1: can@4000a400 {
compatible = "st,stm32-fdcan";
reg = <0x4000a400 0x400>, <0x4000ac00 0x350>;
reg-names = "m_can", "message_ram";
interrupts = <39 0>, <40 0>;
interrupt-names = "LINE_0", "LINE_1";
status = "disabled";
label = "CAN_1";
sjw = <1>;
sample-point = <875>;
sjw-data = <1>;
sample-point-data = <875>;
};
};

ucpd1: ucpd@4000dc00 {
compatible = "st,stm32-ucpd";
reg = <0x4000dc00 0x400>;
Expand Down