Ghennadi Procopciuc | f648e5d | 2024-06-12 09:07:16 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2024 NXP |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | #include <drivers/clk.h> |
| 7 | #include <s32cc-clk-drv.h> |
| 8 | #include <s32cc-clk-ids.h> |
| 9 | #include <s32cc-clk-utils.h> |
| 10 | |
| 11 | #define S32CC_FXOSC_FREQ (40U * MHZ) |
| 12 | |
| 13 | int s32cc_init_early_clks(void) |
| 14 | { |
| 15 | int ret; |
| 16 | |
| 17 | s32cc_clk_register_drv(); |
| 18 | |
Ghennadi Procopciuc | 4e4786d | 2024-06-12 11:17:37 +0300 | [diff] [blame^] | 19 | ret = clk_set_parent(S32CC_CLK_ARM_PLL_MUX, S32CC_CLK_FXOSC); |
| 20 | if (ret != 0) { |
| 21 | return ret; |
| 22 | } |
| 23 | |
| 24 | ret = clk_set_parent(S32CC_CLK_MC_CGM1_MUX0, S32CC_CLK_ARM_PLL_PHI0); |
| 25 | if (ret != 0) { |
| 26 | return ret; |
| 27 | } |
| 28 | |
Ghennadi Procopciuc | f648e5d | 2024-06-12 09:07:16 +0300 | [diff] [blame] | 29 | ret = clk_set_rate(S32CC_CLK_FXOSC, S32CC_FXOSC_FREQ, NULL); |
| 30 | if (ret != 0) { |
| 31 | return ret; |
| 32 | } |
| 33 | |
Ghennadi Procopciuc | 9dee8e4 | 2024-06-12 09:25:17 +0300 | [diff] [blame] | 34 | ret = clk_enable(S32CC_CLK_FXOSC); |
| 35 | if (ret != 0) { |
| 36 | return ret; |
| 37 | } |
| 38 | |
Ghennadi Procopciuc | f648e5d | 2024-06-12 09:07:16 +0300 | [diff] [blame] | 39 | return ret; |
| 40 | } |