Skip to content

Commit 9c4d626

Browse files
cyliangtwfabiobaltieri
authored andcommitted
drivers: clock_control: support for Nuvoton m55m1x series
Add support 64-bit module-idx for m55m1x series. Signed-off-by: cyliang tw <cyliang@nuvoton.com>
1 parent 98b3a2f commit 9c4d626

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

drivers/clock_control/clock_control_numaker_scc.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,39 @@ struct numaker_scc_config {
2222
uint32_t core_clock;
2323
};
2424

25+
#if defined(CONFIG_SOC_SERIES_M55M1X)
26+
static const uint64_t numaker_clkmodidx_tab[] = {
27+
0x0000000000000000, 0x0000000000000400, 0x0000800000000000, 0x0001008000800000,
28+
0x0001008000800480, 0x0001810203FF8000, 0x0001810203FF8488, 0x0002018003800000,
29+
0x0002800000000000, 0x0003000000000000, 0x0003800000000000, 0x0004028283FF8000,
30+
0x0004028001800080, 0x0004830301FF8000, 0x0005000000000000, 0x0005800000000000,
31+
0x0005800000000400, 0x0005800000000800, 0x0005800000000C00, 0x0006000000000000,
32+
0x0006838000800000, 0x0006838000800480, 0x0007000000000000, 0x0007000000000400,
33+
0x0007000000000800, 0x0007000000000C00, 0x0007840000800000, 0x0007800000004000,
34+
0x0008000000000000, 0x0008800000000000, 0x0008800000000400, 0x0008800000000800,
35+
0x0008800000000C00, 0x0008800000001000, 0x0008800000001400, 0x0008800000001800,
36+
0x0008800000001C00, 0x0008800000002000, 0x0008800000002400, 0x0009000000000000,
37+
0x0009800000000000, 0x000A000000000000, 0x000A800000000000, 0x000A800000000400,
38+
0x000A800000000800, 0x000A800000000C00, 0x000B048383FF8000, 0x000B048383FF8488,
39+
0x000B850000800000, 0x000C000000000000, 0x000C858401FF8000, 0x000D000000000000,
40+
0x000D860481FF8000, 0x000E000000000000, 0x000E800000000000, 0x000F000000000000,
41+
0x000F868001800000, 0x0010000000000000, 0x0010870003800000, 0x0010870003800480,
42+
0x0011078503878000, 0x0011800000000000, 0x0012800000000000, 0x0013000000000000,
43+
0x0013800000000000, 0x0013800000000400, 0x0014080583FF8000, 0x0014888003800000,
44+
0x0014888003800480, 0x0015000000000000, 0x0015890603FF8000, 0x0015890603FF8488,
45+
0x0015890603FF8910, 0x0016000000000000, 0x0016898683FF8000, 0x0016898683FF8488,
46+
0x00170A0003800000, 0x00170A0003800480, 0x00170A0003800900, 0x00170A0003800D80,
47+
0x0017800000000000, 0x0018000000000000, 0x0018000000000400, 0x0018000000000800,
48+
0x0018000000000C00, 0x0019800000000000, 0x001A8B0003800000, 0x001A8B0003800480,
49+
0x001A8B0003800900, 0x001A8B0003800D80, 0x001B000000000000, 0x001B8B8003800000,
50+
0x001B8B8003800480, 0x001C0C0783878000, 0x001C0C0783878484, 0x001C0C0783878908,
51+
0x001C0C0783878D8C, 0x001C0C0783879210, 0x001C0C0783879694, 0x001C0C0783879B18,
52+
0x001C0C0783879F9C, 0x001C0C880387A000, 0x001C0C880387A484, 0x001C8D0880878000,
53+
0x001D0D0880878000, 0x001D800000000000, 0x001E000000000000, 0x001E8D8000800000,
54+
0x001E8D8000800480, 0x001F0F8000800000, 0x001F0F8000800480,
55+
};
56+
#endif
57+
2558
static inline int numaker_scc_on(const struct device *dev, clock_control_subsys_t subsys)
2659
{
2760
ARG_UNUSED(dev);
@@ -30,7 +63,12 @@ static inline int numaker_scc_on(const struct device *dev, clock_control_subsys_
3063

3164
if (scc_subsys->subsys_id == NUMAKER_SCC_SUBSYS_ID_PCC) {
3265
SYS_UnlockReg();
66+
#if defined(CONFIG_SOC_SERIES_M55M1X)
67+
__ASSERT_NO_MSG(scc_subsys->pcc.clk_modidx < ARRAY_SIZE(numaker_clkmodidx_tab));
68+
CLK_EnableModuleClock(numaker_clkmodidx_tab[scc_subsys->pcc.clk_modidx]);
69+
#else
3370
CLK_EnableModuleClock(scc_subsys->pcc.clk_modidx);
71+
#endif
3472
SYS_LockReg();
3573
} else {
3674
return -EINVAL;
@@ -47,7 +85,12 @@ static inline int numaker_scc_off(const struct device *dev, clock_control_subsys
4785

4886
if (scc_subsys->subsys_id == NUMAKER_SCC_SUBSYS_ID_PCC) {
4987
SYS_UnlockReg();
88+
#if defined(CONFIG_SOC_SERIES_M55M1X)
89+
__ASSERT_NO_MSG(scc_subsys->pcc.clk_modidx < ARRAY_SIZE(numaker_clkmodidx_tab));
90+
CLK_DisableModuleClock(numaker_clkmodidx_tab[scc_subsys->pcc.clk_modidx]);
91+
#else
5092
CLK_DisableModuleClock(scc_subsys->pcc.clk_modidx);
93+
#endif
5194
SYS_LockReg();
5295
} else {
5396
return -EINVAL;
@@ -84,8 +127,15 @@ static inline int numaker_scc_configure(const struct device *dev, clock_control_
84127

85128
if (scc_subsys->subsys_id == NUMAKER_SCC_SUBSYS_ID_PCC) {
86129
SYS_UnlockReg();
130+
#if defined(CONFIG_SOC_SERIES_M55M1X)
131+
__ASSERT_NO_MSG(scc_subsys->pcc.clk_modidx < ARRAY_SIZE(numaker_clkmodidx_tab));
132+
CLK_SetModuleClock(numaker_clkmodidx_tab[scc_subsys->pcc.clk_modidx],
133+
scc_subsys->pcc.clk_src,
134+
scc_subsys->pcc.clk_div);
135+
#else
87136
CLK_SetModuleClock(scc_subsys->pcc.clk_modidx, scc_subsys->pcc.clk_src,
88137
scc_subsys->pcc.clk_div);
138+
#endif
89139
SYS_LockReg();
90140
} else {
91141
return -EINVAL;

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ manifest:
198198
groups:
199199
- hal
200200
- name: hal_nuvoton
201-
revision: 466c3eed9c98453fb23953bf0e0427fea01924be
201+
revision: 40f7b809b28d9d391bee8b58188293277fabc51a
202202
path: modules/hal/nuvoton
203203
groups:
204204
- hal

0 commit comments

Comments
 (0)