From d9e86ad878bae152ca9c6d8dcb41f3147675c7d8 Mon Sep 17 00:00:00 2001 From: Albort Xue Date: Tue, 13 Jan 2026 15:14:56 +0800 Subject: [PATCH] drivers: can: mcux_flexcan: Add clock configuration and enable Add explicit clock configuration and enable calls during driver initialization. Note: -ENOSYS is temporarily ignored as not all clock control drivers currently implement the configure API. This handling should be removed once all clock drivers support configure. Signed-off-by: Albort Xue --- drivers/can/can_mcux_flexcan.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/can/can_mcux_flexcan.c b/drivers/can/can_mcux_flexcan.c index 3dd21474340..b9a6f3df3e9 100644 --- a/drivers/can/can_mcux_flexcan.c +++ b/drivers/can/can_mcux_flexcan.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2019-2026 Vestas Wind Systems A/S - * Copyright 2025 NXP + * Copyright 2025-2026 NXP * * SPDX-License-Identifier: Apache-2.0 */ @@ -1176,6 +1176,24 @@ static int mcux_flexcan_init(const struct device *dev) return -ENODEV; } + err = clock_control_configure(config->clock_dev, config->clock_subsys, NULL); + if (err) { + /* Check if error is due to lack of support */ + if (err != -ENOSYS) { + /* Real error occurred */ + LOG_ERR("Failed to configure clock: %d", err); + return err; + } + } + +#if FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL + err = clock_control_on(config->clock_dev, config->clock_subsys); + if (err) { + LOG_ERR("Failed to enable clock: %d", err); + return err; + } +#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */ + DEVICE_MMIO_NAMED_MAP(dev, flexcan_mmio, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP); LOG_DBG("Message Buffers: %d, RX MB: %d, TX MB: %d",