@ -11,7 +11,6 @@
@@ -11,7 +11,6 @@
# include <zephyr/drivers/clock_control.h>
# include <zephyr/drivers/pinctrl.h>
# include <zephyr/kernel.h>
# include <stm32_ll_rcc.h>
# include <zephyr/logging/log.h>
# include <zephyr/irq.h>
# include <zephyr/sys/util.h>
@ -84,16 +83,33 @@ static int can_stm32h7_clear_mram(const struct device *dev, uint16_t offset, siz
@@ -84,16 +83,33 @@ static int can_stm32h7_clear_mram(const struct device *dev, uint16_t offset, siz
static int can_stm32h7_get_core_clock ( const struct device * dev , uint32_t * rate )
{
const uint32_t rate_tmp = LL_RCC_GetFDCANClockFreq ( LL_RCC_FDCAN_CLKSOURCE ) ;
uint32_t rate_tmp ;
const struct can_mcan_config * mcan_cfg = dev - > config ;
const struct can_stm32h7_config * stm32h7_cfg = mcan_cfg - > custom ;
const struct device * const clk = DEVICE_DT_GET ( STM32_CLOCK_CONTROL_NODE ) ;
uint32_t cdiv ;
ARG_UNUSED ( dev ) ;
if ( ! device_is_ready ( clk ) ) {
LOG_ERR ( " clock control device not ready " ) ;
return - ENODEV ;
}
if ( rate_tmp = = LL_RCC_PERIPH_FREQUENCY_NO ) {
LOG_ERR ( " Can't read core clock " ) ;
if ( IS_ENABLED ( STM32H7_FDCAN_DOMAIN_CLOCK_SUPPORT ) & & ( stm32h7_cfg - > pclk_len > 1 ) ) {
if ( clock_control_get_rate ( clk ,
( clock_control_subsys_t ) & stm32h7_cfg - > pclken [ 1 ] ,
& rate_tmp ) < 0 ) {
LOG_ERR ( " Failed call clock_control_get_rate(pclk[1]) " ) ;
return - EIO ;
}
} else {
if ( clock_control_get_rate ( clk ,
( clock_control_subsys_t ) & stm32h7_cfg - > pclken [ 0 ] ,
& rate_tmp ) < 0 ) {
LOG_ERR ( " Failed call clock_control_get_rate(pclk[0]) " ) ;
return - EIO ;
}
}
cdiv = FIELD_GET ( FDCANCCU_CCFG_CDIV , FDCAN_CCU - > CCFG ) ;
if ( cdiv = = 0U ) {
* rate = rate_tmp ;