xref: /rk3399_ARM-atf/drivers/nxp/clk/s32cc/s32cc_clk_modules.c (revision 7c36209b29da152cc5e98b6a141fe85d78fca84b)
1*7c36209bSGhennadi Procopciuc /*
2*7c36209bSGhennadi Procopciuc  * Copyright 2020-2024 NXP
3*7c36209bSGhennadi Procopciuc  *
4*7c36209bSGhennadi Procopciuc  * SPDX-License-Identifier: BSD-3-Clause
5*7c36209bSGhennadi Procopciuc  */
6*7c36209bSGhennadi Procopciuc #include <s32cc-clk-ids.h>
7*7c36209bSGhennadi Procopciuc #include <s32cc-clk-modules.h>
8*7c36209bSGhennadi Procopciuc #include <s32cc-clk-utils.h>
9*7c36209bSGhennadi Procopciuc 
10*7c36209bSGhennadi Procopciuc /* Oscillators */
11*7c36209bSGhennadi Procopciuc static struct s32cc_osc fxosc =
12*7c36209bSGhennadi Procopciuc 	S32CC_OSC_INIT(S32CC_FXOSC);
13*7c36209bSGhennadi Procopciuc static struct s32cc_clk fxosc_clk =
14*7c36209bSGhennadi Procopciuc 	S32CC_MODULE_CLK(fxosc);
15*7c36209bSGhennadi Procopciuc 
16*7c36209bSGhennadi Procopciuc static struct s32cc_osc firc =
17*7c36209bSGhennadi Procopciuc 	S32CC_OSC_INIT(S32CC_FIRC);
18*7c36209bSGhennadi Procopciuc static struct s32cc_clk firc_clk =
19*7c36209bSGhennadi Procopciuc 	S32CC_MODULE_CLK(firc);
20*7c36209bSGhennadi Procopciuc 
21*7c36209bSGhennadi Procopciuc static struct s32cc_osc sirc =
22*7c36209bSGhennadi Procopciuc 	S32CC_OSC_INIT(S32CC_SIRC);
23*7c36209bSGhennadi Procopciuc static struct s32cc_clk sirc_clk =
24*7c36209bSGhennadi Procopciuc 	S32CC_MODULE_CLK(sirc);
25*7c36209bSGhennadi Procopciuc 
26*7c36209bSGhennadi Procopciuc static struct s32cc_clk *s32cc_hw_clk_list[3] = {
27*7c36209bSGhennadi Procopciuc 	/* Oscillators */
28*7c36209bSGhennadi Procopciuc 	[S32CC_CLK_ID(S32CC_CLK_FIRC)] = &firc_clk,
29*7c36209bSGhennadi Procopciuc 	[S32CC_CLK_ID(S32CC_CLK_SIRC)] = &sirc_clk,
30*7c36209bSGhennadi Procopciuc 	[S32CC_CLK_ID(S32CC_CLK_FXOSC)] = &fxosc_clk,
31*7c36209bSGhennadi Procopciuc };
32*7c36209bSGhennadi Procopciuc 
33*7c36209bSGhennadi Procopciuc static struct s32cc_clk_array s32cc_hw_clocks = {
34*7c36209bSGhennadi Procopciuc 	.type_mask = S32CC_CLK_TYPE(S32CC_CLK_FIRC),
35*7c36209bSGhennadi Procopciuc 	.clks = &s32cc_hw_clk_list[0],
36*7c36209bSGhennadi Procopciuc 	.n_clks = ARRAY_SIZE(s32cc_hw_clk_list),
37*7c36209bSGhennadi Procopciuc };
38*7c36209bSGhennadi Procopciuc 
39*7c36209bSGhennadi Procopciuc struct s32cc_clk *s32cc_get_arch_clk(unsigned long id)
40*7c36209bSGhennadi Procopciuc {
41*7c36209bSGhennadi Procopciuc 	static const struct s32cc_clk_array *clk_table[1] = {
42*7c36209bSGhennadi Procopciuc 		&s32cc_hw_clocks,
43*7c36209bSGhennadi Procopciuc 	};
44*7c36209bSGhennadi Procopciuc 
45*7c36209bSGhennadi Procopciuc 	return s32cc_get_clk_from_table(clk_table, ARRAY_SIZE(clk_table), id);
46*7c36209bSGhennadi Procopciuc }
47