Skip to content

Commit d1aa885

Browse files
committed
drivers: can: STM32H7 in can_mcan_reg, clock config.
* Add STM32h7 fields to can_mcan_reg. * STM32H FDCAN clock config changes. Signed-off-by: Jeremy Wood <[email protected]>
1 parent b020e42 commit d1aa885

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

drivers/can/can_mcan_int.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,14 +1478,33 @@ struct can_mcan_reg {
14781478
volatile uint32_t ile; /* Interrupt Line Enable */
14791479
uint32_t res3[8]; /* Reserved (8) */
14801480
volatile uint32_t rxgfc; /* Global Filter Configuration */
1481+
#if defined(CONFIG_SOC_SERIES_STM32H7X)
1482+
volatile uint32_t sidfc; /* Standard ID Filter Configuration */
1483+
volatile uint32_t xidfc; /* Extended ID Filter Configuration */
1484+
uint32_t res31; /* Reserved (1) */
1485+
#endif /* CONFIG_SOC_SERIES_STM32H7X */
14811486
volatile uint32_t xidam; /* Extended ID AND Mask */
14821487
volatile uint32_t hpms; /* High Priority Message Status */
1488+
#if defined(CONFIG_SOC_SERIES_STM32H7X)
1489+
volatile uint32_t ndat1; /* New Data 1 */
1490+
volatile uint32_t ndat2; /* New Data 2 */
1491+
volatile uint32_t rxf0c; /* Rx FIFO 0 Configuration */
1492+
#else
14831493
uint32_t res4; /* Reserved (1) */
1494+
#endif /* CONFIG_SOC_SERIES_STM32H7X */
14841495
volatile uint32_t rxf0s; /* Rx FIFO 0 Status */
14851496
volatile uint32_t rxf0a; /* Rx FIFO 0 Acknowledge */
1497+
#if defined(CONFIG_SOC_SERIES_STM32H7X)
1498+
volatile uint32_t rxbc; /* Rx Buffer Configuration */
1499+
volatile uint32_t rxf1c; /* Rx FIFO 1 Configuration */
1500+
#endif /* CONFIG_SOC_SERIES_STM32H7X */
14861501
volatile uint32_t rxf1s; /* Rx FIFO 1 Status */
14871502
volatile uint32_t rxf1a; /* Rx FIFO 1 Acknowledge */
1503+
#if defined(CONFIG_SOC_SERIES_STM32H7X)
1504+
volatile uint32_t rxesc; /* Rx Buffer/FIFO Element Size Configuration */
1505+
#else
14881506
uint32_t res5[8]; /* Reserved (8) */
1507+
#endif /* CONFIG_SOC_SERIES_STM32H7X */
14891508
volatile uint32_t txbc; /* Tx Buffer Configuration */
14901509
volatile uint32_t txfqs; /* Tx FIFO/Queue Status */
14911510
volatile uint32_t txbrp; /* Tx Buffer Request Pending */
@@ -1495,8 +1514,15 @@ struct can_mcan_reg {
14951514
volatile uint32_t txbcf; /* Tx Buffer Cancellation Finished */
14961515
volatile uint32_t txbtie; /* Tx Buffer Transmission Interrupt Enable */
14971516
volatile uint32_t txcbie; /* Tx Buffer Cancellation Fi.Interrupt En. */
1517+
#if defined(CONFIG_SOC_SERIES_STM32H7X)
1518+
uint32_t res5[2]; /* Reserved (2) */
1519+
volatile uint32_t txefc; /* Tx Event FIFO Configuration */
1520+
#endif /* CONFIG_SOC_SERIES_STM32H7X */
14981521
volatile uint32_t txefs; /* Tx Event FIFO Status */
14991522
volatile uint32_t txefa; /* Tx Event FIFO Acknowledge */
1523+
#if defined(CONFIG_SOC_SERIES_STM32H7X)
1524+
uint32_t res6; /* Reserved (1) */
1525+
#endif /* CONFIG_SOC_SERIES_STM32H7X */
15001526
};
15011527
#else /* CONFIG_CAN_STM32FD */
15021528

drivers/can/can_stm32fd.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,19 @@ int can_stm32fd_get_core_clock(const struct device *dev, uint32_t *rate)
4040

4141
void can_stm32fd_clock_enable(void)
4242
{
43+
#if defined(CONFIG_SOC_SERIES_STM32H7X)
44+
LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PLL1Q);
45+
__HAL_RCC_FDCAN_CLK_ENABLE();
46+
47+
if (!LL_RCC_PLL1Q_IsEnabled()) {
48+
LOG_ERR("PLL1Q clock must be enabled!");
49+
}
50+
#else
4351
LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1);
4452
__HAL_RCC_FDCAN_CLK_ENABLE();
4553

4654
FDCAN_CONFIG->CKDIV = CONFIG_CAN_STM32_CLOCK_DIVISOR >> 1;
55+
#endif
4756
}
4857

4958
void can_stm32fd_register_state_change_isr(const struct device *dev,

0 commit comments

Comments
 (0)