1 /*
2  * SPDX-License-Identifier: Apache-2.0
3  *
4  * Copyright (c) 2024 Realtek Semiconductor Corporation, SIBG-SD7
5  * Author: Lin Yu-Cheng <lin_yu_cheng@realtek.com> / Titan Chen
6  */
7 
8 #include <zephyr/kernel.h>
9 #include <zephyr/device.h>
10 #include <zephyr/init.h>
11 #include <zephyr/logging/log.h>
12 #include "debug_swj.h"
13 
14 LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
15 
16 #if defined(CONFIG_RTS5912_ON_ENTER_CPU_IDLE_HOOK)
z_arm_on_enter_cpu_idle(void)17 bool z_arm_on_enter_cpu_idle(void)
18 {
19 	/* Returning false prevent device goes to sleep mode */
20 	return false;
21 }
22 #endif
23 
24 /**
25  * @brief Perform basic hardware initialization at boot.
26  *
27  * This needs to be run from the very beginning.
28  */
soc_early_init_hook(void)29 void soc_early_init_hook(void)
30 {
31 	if (!IS_ENABLED(CONFIG_RTS5912_DEBUG_SWJ)) {
32 		return;
33 	}
34 
35 	int ret;
36 
37 	/* Apply device related preinit configuration */
38 	ret = swj_connector_init();
39 	if (ret < 0) {
40 		LOG_ERR("SWJ init failed");
41 	}
42 }
43