From 39d63d316b92955f0338ec98a14d94542e4e10a9 Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Mon, 23 Apr 2018 14:27:43 -0500 Subject: [PATCH] clock_control: Add support for getting LPO frequency in mcux sim driver The mcux sim clock control driver was originally designed to pass through the clock subsystem value from dts to the mcux CLOCK_GetFreq() function. This assumed that the values in include/dt-bindings/clock/kinetis_sim.h matched the enumeration in fsl_clock.h, which is true for the coresys, platform, and bus clocks. However, the low-power oscillator (LPO) clock has a different values in k64 vs. kw2xd, therefore we must update the clock_control driver to parse the value from dts and convert it to the fsl_clock.h enumeration. Signed-off-by: Maureen Helm --- drivers/clock_control/clock_control_mcux_sim.c | 12 +++++++++++- include/dt-bindings/clock/kinetis_sim.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/clock_control/clock_control_mcux_sim.c b/drivers/clock_control/clock_control_mcux_sim.c index ff371a78556..a9f58d2b75b 100644 --- a/drivers/clock_control/clock_control_mcux_sim.c +++ b/drivers/clock_control/clock_control_mcux_sim.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #define SYS_LOG_LEVEL CONFIG_SYS_LOG_CLOCK_CONTROL_LEVEL @@ -25,7 +26,16 @@ static int mcux_sim_get_subsys_rate(struct device *dev, clock_control_subsys_t sub_system, u32_t *rate) { - clock_name_t clock_name = (clock_name_t) sub_system; + clock_name_t clock_name; + + switch ((u32_t) sub_system) { + case KINETIS_SIM_LPO_CLK: + clock_name = kCLOCK_LpoClk; + break; + default: + clock_name = (clock_name_t) sub_system; + break; + } *rate = CLOCK_GetFreq(clock_name); diff --git a/include/dt-bindings/clock/kinetis_sim.h b/include/dt-bindings/clock/kinetis_sim.h index 32b09c2d8ee..25edaf3b09c 100644 --- a/include/dt-bindings/clock/kinetis_sim.h +++ b/include/dt-bindings/clock/kinetis_sim.h @@ -10,5 +10,6 @@ #define KINETIS_SIM_CORESYS_CLK 0 #define KINETIS_SIM_PLATFORM_CLK 1 #define KINETIS_SIM_BUS_CLK 2 +#define KINETIS_SIM_LPO_CLK 19 #endif /* __KINETIS_SIM_H */