17c36209bSGhennadi Procopciuc /* 27c36209bSGhennadi Procopciuc * Copyright 2020-2024 NXP 37c36209bSGhennadi Procopciuc * 47c36209bSGhennadi Procopciuc * SPDX-License-Identifier: BSD-3-Clause 57c36209bSGhennadi Procopciuc */ 67c36209bSGhennadi Procopciuc #include <s32cc-clk-ids.h> 77c36209bSGhennadi Procopciuc #include <s32cc-clk-modules.h> 87c36209bSGhennadi Procopciuc #include <s32cc-clk-utils.h> 97c36209bSGhennadi Procopciuc 107c36209bSGhennadi Procopciuc /* Oscillators */ 117c36209bSGhennadi Procopciuc static struct s32cc_osc fxosc = 127c36209bSGhennadi Procopciuc S32CC_OSC_INIT(S32CC_FXOSC); 137c36209bSGhennadi Procopciuc static struct s32cc_clk fxosc_clk = 147c36209bSGhennadi Procopciuc S32CC_MODULE_CLK(fxosc); 157c36209bSGhennadi Procopciuc 167c36209bSGhennadi Procopciuc static struct s32cc_osc firc = 177c36209bSGhennadi Procopciuc S32CC_OSC_INIT(S32CC_FIRC); 187c36209bSGhennadi Procopciuc static struct s32cc_clk firc_clk = 197c36209bSGhennadi Procopciuc S32CC_MODULE_CLK(firc); 207c36209bSGhennadi Procopciuc 217c36209bSGhennadi Procopciuc static struct s32cc_osc sirc = 227c36209bSGhennadi Procopciuc S32CC_OSC_INIT(S32CC_SIRC); 237c36209bSGhennadi Procopciuc static struct s32cc_clk sirc_clk = 247c36209bSGhennadi Procopciuc S32CC_MODULE_CLK(sirc); 257c36209bSGhennadi Procopciuc 26a8be748aSGhennadi Procopciuc /* ARM PLL */ 27a8be748aSGhennadi Procopciuc static struct s32cc_clkmux arm_pll_mux = 28a8be748aSGhennadi Procopciuc S32CC_CLKMUX_INIT(S32CC_ARM_PLL, 0, 2, 29a8be748aSGhennadi Procopciuc S32CC_CLK_FIRC, 30a8be748aSGhennadi Procopciuc S32CC_CLK_FXOSC, 0, 0, 0); 31a8be748aSGhennadi Procopciuc static struct s32cc_clk arm_pll_mux_clk = 32a8be748aSGhennadi Procopciuc S32CC_MODULE_CLK(arm_pll_mux); 33a8be748aSGhennadi Procopciuc static struct s32cc_pll armpll = 34a8be748aSGhennadi Procopciuc S32CC_PLL_INIT(arm_pll_mux_clk, S32CC_ARM_PLL, 2); 35a8be748aSGhennadi Procopciuc static struct s32cc_clk arm_pll_vco_clk = 36a8be748aSGhennadi Procopciuc S32CC_FREQ_MODULE_CLK(armpll, 1400 * MHZ, 2000 * MHZ); 37a8be748aSGhennadi Procopciuc 38a8be748aSGhennadi Procopciuc static struct s32cc_pll_out_div arm_pll_phi0_div = 39a8be748aSGhennadi Procopciuc S32CC_PLL_OUT_DIV_INIT(armpll, 0); 40a8be748aSGhennadi Procopciuc static struct s32cc_clk arm_pll_phi0_clk = 41a8be748aSGhennadi Procopciuc S32CC_FREQ_MODULE_CLK(arm_pll_phi0_div, 0, GHZ); 42a8be748aSGhennadi Procopciuc 43*3fa91a94SGhennadi Procopciuc /* MC_CGM1 */ 44*3fa91a94SGhennadi Procopciuc static struct s32cc_clkmux cgm1_mux0 = 45*3fa91a94SGhennadi Procopciuc S32CC_SHARED_CLKMUX_INIT(S32CC_CGM1, 0, 3, 46*3fa91a94SGhennadi Procopciuc S32CC_CLK_FIRC, 47*3fa91a94SGhennadi Procopciuc S32CC_CLK_ARM_PLL_PHI0, 48*3fa91a94SGhennadi Procopciuc S32CC_CLK_ARM_PLL_DFS2, 0, 0); 49*3fa91a94SGhennadi Procopciuc static struct s32cc_clk cgm1_mux0_clk = S32CC_MODULE_CLK(cgm1_mux0); 50*3fa91a94SGhennadi Procopciuc 51a8be748aSGhennadi Procopciuc static struct s32cc_clk *s32cc_hw_clk_list[5] = { 527c36209bSGhennadi Procopciuc /* Oscillators */ 537c36209bSGhennadi Procopciuc [S32CC_CLK_ID(S32CC_CLK_FIRC)] = &firc_clk, 547c36209bSGhennadi Procopciuc [S32CC_CLK_ID(S32CC_CLK_SIRC)] = &sirc_clk, 557c36209bSGhennadi Procopciuc [S32CC_CLK_ID(S32CC_CLK_FXOSC)] = &fxosc_clk, 56a8be748aSGhennadi Procopciuc /* ARM PLL */ 57a8be748aSGhennadi Procopciuc [S32CC_CLK_ID(S32CC_CLK_ARM_PLL_PHI0)] = &arm_pll_phi0_clk, 587c36209bSGhennadi Procopciuc }; 597c36209bSGhennadi Procopciuc 607c36209bSGhennadi Procopciuc static struct s32cc_clk_array s32cc_hw_clocks = { 617c36209bSGhennadi Procopciuc .type_mask = S32CC_CLK_TYPE(S32CC_CLK_FIRC), 627c36209bSGhennadi Procopciuc .clks = &s32cc_hw_clk_list[0], 637c36209bSGhennadi Procopciuc .n_clks = ARRAY_SIZE(s32cc_hw_clk_list), 647c36209bSGhennadi Procopciuc }; 657c36209bSGhennadi Procopciuc 66*3fa91a94SGhennadi Procopciuc static struct s32cc_clk *s32cc_arch_clk_list[3] = { 67a8be748aSGhennadi Procopciuc /* ARM PLL */ 68a8be748aSGhennadi Procopciuc [S32CC_CLK_ID(S32CC_CLK_ARM_PLL_MUX)] = &arm_pll_mux_clk, 69a8be748aSGhennadi Procopciuc [S32CC_CLK_ID(S32CC_CLK_ARM_PLL_VCO)] = &arm_pll_vco_clk, 70*3fa91a94SGhennadi Procopciuc /* MC_CGM1 */ 71*3fa91a94SGhennadi Procopciuc [S32CC_CLK_ID(S32CC_CLK_MC_CGM1_MUX0)] = &cgm1_mux0_clk, 72a8be748aSGhennadi Procopciuc }; 73a8be748aSGhennadi Procopciuc 74a8be748aSGhennadi Procopciuc static struct s32cc_clk_array s32cc_arch_clocks = { 75a8be748aSGhennadi Procopciuc .type_mask = S32CC_CLK_TYPE(S32CC_CLK_ARM_PLL_MUX), 76a8be748aSGhennadi Procopciuc .clks = &s32cc_arch_clk_list[0], 77a8be748aSGhennadi Procopciuc .n_clks = ARRAY_SIZE(s32cc_arch_clk_list), 78a8be748aSGhennadi Procopciuc }; 79a8be748aSGhennadi Procopciuc 807c36209bSGhennadi Procopciuc struct s32cc_clk *s32cc_get_arch_clk(unsigned long id) 817c36209bSGhennadi Procopciuc { 82a8be748aSGhennadi Procopciuc static const struct s32cc_clk_array *clk_table[2] = { 837c36209bSGhennadi Procopciuc &s32cc_hw_clocks, 84a8be748aSGhennadi Procopciuc &s32cc_arch_clocks, 857c36209bSGhennadi Procopciuc }; 867c36209bSGhennadi Procopciuc 877c36209bSGhennadi Procopciuc return s32cc_get_clk_from_table(clk_table, ARRAY_SIZE(clk_table), id); 887c36209bSGhennadi Procopciuc } 89