Skip to content

Commit 108615c

Browse files
JiafeiPankartben
authored andcommitted
soc: imx95: a55: initialize lpuart clock
Initialize lpuart clock to avoid it is not initialized. Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
1 parent 2707fa2 commit 108615c

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

soc/nxp/imx/imx9/imx95/a55/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
zephyr_include_directories(.)
44
zephyr_sources_ifdef(CONFIG_ARM_MMU mmu_regions.c)
5+
zephyr_sources_ifdef(CONFIG_ARM_MMU soc.c)
56
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "")

soc/nxp/imx/imx9/imx95/a55/soc.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <stdio.h>
8+
#include <zephyr/init.h>
9+
#include <zephyr/kernel.h>
10+
#include <zephyr/device.h>
11+
#include <zephyr/drivers/firmware/scmi/clk.h>
12+
#include <zephyr/dt-bindings/clock/imx95_clock.h>
13+
#include <soc.h>
14+
15+
#define FREQ_24M_HZ 24000000 /* 24 MHz */
16+
17+
static int soc_clk_init(void)
18+
{
19+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart1), okay) || \
20+
DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart3), okay)
21+
const struct device *clk_dev = DEVICE_DT_GET(DT_NODELABEL(scmi_clk));
22+
struct scmi_protocol *proto = clk_dev->data;
23+
struct scmi_clock_rate_config clk_cfg = {0};
24+
uint32_t clk_id;
25+
struct scmi_clock_config cfg;
26+
int ret;
27+
28+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart1), okay)
29+
clk_id = IMX95_CLK_LPUART1;
30+
#elif DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart3), okay)
31+
clk_id = IMX95_CLK_LPUART3;
32+
#endif
33+
34+
ret = scmi_clock_parent_set(proto, clk_id, IMX95_CLK_24M);
35+
if (ret) {
36+
return ret;
37+
}
38+
39+
cfg.attributes = SCMI_CLK_CONFIG_ENABLE_DISABLE(true);
40+
cfg.clk_id = clk_id;
41+
ret = scmi_clock_config_set(proto, &cfg);
42+
if (ret) {
43+
return ret;
44+
}
45+
46+
clk_cfg.flags = SCMI_CLK_RATE_SET_FLAGS_ROUNDS_AUTO;
47+
clk_cfg.clk_id = clk_id;
48+
clk_cfg.rate[0] = FREQ_24M_HZ; /* 24 MHz*/
49+
clk_cfg.rate[1] = 0;
50+
51+
ret = scmi_clock_rate_set(proto, &clk_cfg);
52+
if (ret) {
53+
return ret;
54+
}
55+
#endif
56+
57+
return 0;
58+
}
59+
60+
static int soc_init(void)
61+
{
62+
return soc_clk_init();
63+
}
64+
/*
65+
* Because platform is using ARM SCMI, drivers like scmi, mbox etc are
66+
* initialized during PRE_KERNEL_1, so common init hooks can't be used, SoC
67+
* early init and board early init should run during PRE_KERNEL_2 instead.
68+
*/
69+
SYS_INIT(soc_init, PRE_KERNEL_2, 0);

0 commit comments

Comments
 (0)