Skip to content

Commit df0304a

Browse files
JiafeiPankartben
authored andcommitted
drivers: clock_control: mcux_ccm: add flexcan clock support
Enable FlexCAN clock support on imx8mp. Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
1 parent 1757ea3 commit df0304a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

drivers/clock_control/clock_control_mcux_ccm.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ static const clock_ip_name_t i2c_clk_root[] = {
108108
};
109109
#endif
110110

111+
#if defined(CONFIG_CAN_MCUX_FLEXCAN) && defined(CONFIG_SOC_MIMX8ML8)
112+
static const clock_ip_name_t flexcan_clk_root[] = {
113+
kCLOCK_RootFlexCan1,
114+
kCLOCK_RootFlexCan2,
115+
};
116+
#endif
117+
111118
static int mcux_ccm_on(const struct device *dev,
112119
clock_control_subsys_t sub_system)
113120
{
@@ -383,6 +390,22 @@ static int mcux_ccm_get_subsys_rate(const struct device *dev,
383390
#endif
384391

385392
#ifdef CONFIG_CAN_MCUX_FLEXCAN
393+
#ifdef CONFIG_SOC_MIMX8ML8
394+
case IMX_CCM_CAN1_CLK:
395+
case IMX_CCM_CAN2_CLK:
396+
{
397+
uint32_t instance = clock_name & IMX_CCM_INSTANCE_MASK;
398+
uint32_t can_mux = CLOCK_GetRootMux(flexcan_clk_root[instance]);
399+
400+
if (can_mux == 0) {
401+
*rate = MHZ(24);
402+
} else if (can_mux == 4) { /* SYSTEM_PLL1_CLK */
403+
*rate = CLOCK_GetPllFreq(kCLOCK_SystemPll1Ctrl) /
404+
(CLOCK_GetRootPreDivider(flexcan_clk_root[instance])) /
405+
(CLOCK_GetRootPostDivider(flexcan_clk_root[instance]));
406+
}
407+
} break;
408+
#else
386409
case IMX_CCM_CAN_CLK:
387410
{
388411
uint32_t can_mux = CLOCK_GetMux(kCLOCK_CanMux);
@@ -399,6 +422,7 @@ static int mcux_ccm_get_subsys_rate(const struct device *dev,
399422
}
400423
} break;
401424
#endif
425+
#endif
402426

403427
#ifdef CONFIG_COUNTER_MCUX_GPT
404428
case IMX_CCM_GPT_CLK:

include/zephyr/dt-bindings/clock/imx_ccm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#define IMX_CCM_UART4_CLK 0x0803UL
4545

4646
#define IMX_CCM_CAN_CLK 0x0900UL
47+
#define IMX_CCM_CAN1_CLK 0x0900UL
48+
#define IMX_CCM_CAN2_CLK 0x0901UL
4749

4850
#define IMX_CCM_GPT_CLK 0x0A00UL
4951

0 commit comments

Comments
 (0)