drivers: counter: mcux_lpit: Add clock configuration and enable

Add explicit clock configuration and enable calls during driver
initialization. The driver now attempts to configure the clock
subsystem before enabling it.

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 <yao.xue@nxp.com>
This commit is contained in:
Albort Xue
2026-01-13 16:02:32 +08:00
committed by Henrik Brix Andersen
parent f8f94fd6cd
commit 59ffa602b4

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2023, 2025 NXP
* Copyright 2023, 2025-2026 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -171,12 +171,31 @@ static int mcux_lpit_init(const struct device *dev)
const struct mcux_lpit_config *config = dev->config;
lpit_config_t lpit_config;
uint32_t clock_rate;
int ret;
if (!device_is_ready(config->clock_dev)) {
LOG_ERR("Clock control device not ready");
return -ENODEV;
}
ret = clock_control_configure(config->clock_dev, config->clock_subsys, NULL);
if (ret != 0) {
/* Check if error is due to lack of support */
if (ret != -ENOSYS) {
/* Real error occurred */
LOG_ERR("Failed to configure clock: %d", ret);
return ret;
}
}
#if FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL
ret = clock_control_on(config->clock_dev, config->clock_subsys);
if (ret != 0) {
LOG_ERR("Failed to enable clock: %d", ret);
return ret;
}
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
LPIT_GetDefaultConfig(&lpit_config);
lpit_config.enableRunInDebug = config->lpit_config.enableRunInDebug;
lpit_config.enableRunInDoze = config->lpit_config.enableRunInDoze;