diff --git a/drivers/nxp/clk/s32cc/s32cc_clk.mk b/drivers/nxp/clk/s32cc/s32cc_clk.mk index 3f704c6f3..f5279d3a9 100644 --- a/drivers/nxp/clk/s32cc/s32cc_clk.mk +++ b/drivers/nxp/clk/s32cc/s32cc_clk.mk @@ -11,6 +11,8 @@ CLK_SOURCES := \ ${PLAT_DRIVERS_PATH}/clk/s32cc/s32cc_clk_drv.c \ ${PLAT_DRIVERS_PATH}/clk/s32cc/s32cc_clk_modules.c \ ${PLAT_DRIVERS_PATH}/clk/s32cc/s32cc_clk_utils.c \ + ${PLAT_DRIVERS_PATH}/clk/s32cc/s32cc_early_clks.c \ + drivers/clk/clk.c \ ifeq (${BL_COMM_CLK_NEEDED},yes) BL2_SOURCES += ${CLK_SOURCES} diff --git a/drivers/nxp/clk/s32cc/s32cc_early_clks.c b/drivers/nxp/clk/s32cc/s32cc_early_clks.c new file mode 100644 index 000000000..fc1dc020d --- /dev/null +++ b/drivers/nxp/clk/s32cc/s32cc_early_clks.c @@ -0,0 +1,25 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include +#include +#include +#include + +#define S32CC_FXOSC_FREQ (40U * MHZ) + +int s32cc_init_early_clks(void) +{ + int ret; + + s32cc_clk_register_drv(); + + ret = clk_set_rate(S32CC_CLK_FXOSC, S32CC_FXOSC_FREQ, NULL); + if (ret != 0) { + return ret; + } + + return ret; +} diff --git a/include/drivers/nxp/clk/s32cc/s32cc-clk-drv.h b/include/drivers/nxp/clk/s32cc/s32cc-clk-drv.h new file mode 100644 index 000000000..d879f5bed --- /dev/null +++ b/include/drivers/nxp/clk/s32cc/s32cc-clk-drv.h @@ -0,0 +1,11 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#ifndef S32CC_CLK_DRV_H +#define S32CC_CLK_DRV_H + +int s32cc_init_early_clks(void); + +#endif diff --git a/include/drivers/nxp/clk/s32cc/s32cc-clk-utils.h b/include/drivers/nxp/clk/s32cc/s32cc-clk-utils.h index aaf6c5f54..6a904063e 100644 --- a/include/drivers/nxp/clk/s32cc/s32cc-clk-utils.h +++ b/include/drivers/nxp/clk/s32cc/s32cc-clk-utils.h @@ -13,4 +13,6 @@ struct s32cc_clk *s32cc_get_clk_from_table(const struct s32cc_clk_array *const * struct s32cc_clk *s32cc_get_arch_clk(unsigned long id); +void s32cc_clk_register_drv(void); + #endif /* S32CC_CLK_UTILS_H */ diff --git a/plat/nxp/s32/s32g274ardb2/plat_bl2_el3_setup.c b/plat/nxp/s32/s32g274ardb2/plat_bl2_el3_setup.c index f265d956f..705832c7f 100644 --- a/plat/nxp/s32/s32g274ardb2/plat_bl2_el3_setup.c +++ b/plat/nxp/s32/s32g274ardb2/plat_bl2_el3_setup.c @@ -4,10 +4,12 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include #include #include +#include #include #define SIUL2_PC09_MSCR UL(0x4009C2E4) @@ -50,6 +52,13 @@ static void linflex_config_pinctrl(void) void bl2_el3_early_platform_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { + int ret; + + ret = s32cc_init_early_clks(); + if (ret != 0) { + panic(); + } + linflex_config_pinctrl(); console_s32g2_register();