16fba6e04STony Xie /* 2036935a8SXiaoDong Huang * Copyright (c) 2014-2025, ARM Limited and Contributors. All rights reserved. 36fba6e04STony Xie * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 56fba6e04STony Xie */ 66fba6e04STony Xie 7c3cf06f1SAntonio Nino Diaz #ifndef PLAT_PRIVATE_H 8c3cf06f1SAntonio Nino Diaz #define PLAT_PRIVATE_H 96fba6e04STony Xie 10d5dfdeb6SJulius Werner #ifndef __ASSEMBLER__ 1109d40e0eSAntonio Nino Diaz 126fba6e04STony Xie #include <stdint.h> 1309d40e0eSAntonio Nino Diaz 1409d40e0eSAntonio Nino Diaz #include <lib/mmio.h> 159fd9f1d0Sshengfei Xu #include <lib/psci/psci.h> 169fd9f1d0Sshengfei Xu #include <lib/xlat_tables/xlat_tables_compat.h> 17c1185ffdSJulius Werner #include <plat_params.h> 186fba6e04STony Xie 19ec693569SCaesar Wang #define __sramdata __attribute__((section(".sram.data"))) 20ec693569SCaesar Wang #define __sramconst __attribute__((section(".sram.rodata"))) 21bc5c3007SLin Huang #define __sramfunc __attribute__((section(".sram.text"))) 22bc5c3007SLin Huang 23bc5c3007SLin Huang #define __pmusramdata __attribute__((section(".pmusram.data"))) 24bc5c3007SLin Huang #define __pmusramconst __attribute__((section(".pmusram.rodata"))) 25bc5c3007SLin Huang #define __pmusramfunc __attribute__((section(".pmusram.text"))) 26ec693569SCaesar Wang 27ec693569SCaesar Wang extern uint32_t __bl31_sram_text_start, __bl31_sram_text_end; 28ec693569SCaesar Wang extern uint32_t __bl31_sram_data_start, __bl31_sram_data_end; 29bc5c3007SLin Huang extern uint32_t __bl31_sram_stack_start, __bl31_sram_stack_end; 304e836d35SLin Huang extern uint32_t __bl31_sram_text_real_end, __bl31_sram_data_real_end; 31036935a8SXiaoDong Huang extern uint32_t __bl31_pmusram_text_start, __bl31_pmusram_text_end; 32036935a8SXiaoDong Huang extern uint32_t __bl31_pmusram_data_start, __bl31_pmusram_data_end; 33036935a8SXiaoDong Huang extern uint32_t __bl31_pmusram_text_real_end, __bl31_pmusram_data_real_end; 34977001aaSXing Zheng extern uint32_t __sram_incbin_start, __sram_incbin_end; 354e836d35SLin Huang extern uint32_t __sram_incbin_real_end; 36ec693569SCaesar Wang 376fba6e04STony Xie /****************************************************************************** 386fba6e04STony Xie * The register have write-mask bits, it is mean, if you want to set the bits, 396fba6e04STony Xie * you needs set the write-mask bits at the same time, 406fba6e04STony Xie * The write-mask bits is in high 16-bits. 416fba6e04STony Xie * The fllowing macro definition helps access write-mask bits reg efficient! 426fba6e04STony Xie ******************************************************************************/ 436fba6e04STony Xie #define REG_MSK_SHIFT 16 446fba6e04STony Xie 456fba6e04STony Xie #ifndef WMSK_BIT 466fba6e04STony Xie #define WMSK_BIT(nr) BIT((nr) + REG_MSK_SHIFT) 476fba6e04STony Xie #endif 486fba6e04STony Xie 496fba6e04STony Xie /* set one bit with write mask */ 506fba6e04STony Xie #ifndef BIT_WITH_WMSK 516fba6e04STony Xie #define BIT_WITH_WMSK(nr) (BIT(nr) | WMSK_BIT(nr)) 526fba6e04STony Xie #endif 536fba6e04STony Xie 546fba6e04STony Xie #ifndef BITS_SHIFT 55901e94edSXiaoDong Huang #define BITS_SHIFT(bits, shift) ((bits) << (shift)) 566fba6e04STony Xie #endif 576fba6e04STony Xie 586fba6e04STony Xie #ifndef BITS_WITH_WMASK 59f47a25ddSCaesar Wang #define BITS_WITH_WMASK(bits, msk, shift)\ 606fba6e04STony Xie (BITS_SHIFT(bits, shift) | BITS_SHIFT(msk, (shift + REG_MSK_SHIFT))) 616fba6e04STony Xie #endif 626fba6e04STony Xie 636fba6e04STony Xie /****************************************************************************** 646fba6e04STony Xie * Function and variable prototypes 656fba6e04STony Xie *****************************************************************************/ 66402b3cf8SJulius Werner #ifdef __aarch64__ 676fba6e04STony Xie void plat_configure_mmu_el3(unsigned long total_base, 686fba6e04STony Xie unsigned long total_size, 696fba6e04STony Xie unsigned long, 706fba6e04STony Xie unsigned long, 716fba6e04STony Xie unsigned long, 726fba6e04STony Xie unsigned long); 736fba6e04STony Xie 7482e18f89SHeiko Stuebner void rockchip_plat_mmu_el3(void); 75402b3cf8SJulius Werner #else 76402b3cf8SJulius Werner void plat_configure_mmu_svc_mon(unsigned long total_base, 77402b3cf8SJulius Werner unsigned long total_size, 78402b3cf8SJulius Werner unsigned long, 79402b3cf8SJulius Werner unsigned long, 80402b3cf8SJulius Werner unsigned long, 81402b3cf8SJulius Werner unsigned long); 82402b3cf8SJulius Werner 83402b3cf8SJulius Werner void rockchip_plat_mmu_svc_mon(void); 8482e18f89SHeiko Stuebner #endif 8582e18f89SHeiko Stuebner 866fba6e04STony Xie void plat_cci_init(void); 876fba6e04STony Xie void plat_cci_enable(void); 886fba6e04STony Xie void plat_cci_disable(void); 896fba6e04STony Xie 906fba6e04STony Xie void plat_delay_timer_init(void); 916fba6e04STony Xie 92c1185ffdSJulius Werner void params_early_setup(u_register_t plat_params_from_bl2); 9368ff45f4SCaesar Wang 946fba6e04STony Xie void plat_rockchip_gic_driver_init(void); 956fba6e04STony Xie void plat_rockchip_gic_init(void); 966fba6e04STony Xie void plat_rockchip_gic_cpuif_enable(void); 976fba6e04STony Xie void plat_rockchip_gic_cpuif_disable(void); 986fba6e04STony Xie void plat_rockchip_gic_pcpu_init(void); 996fba6e04STony Xie 1006fba6e04STony Xie void plat_rockchip_pmu_init(void); 1016fba6e04STony Xie void plat_rockchip_soc_init(void); 1029ec78bdfSTony Xie uintptr_t plat_get_sec_entrypoint(void); 1036fba6e04STony Xie 104f47a25ddSCaesar Wang void platform_cpu_warmboot(void); 105f47a25ddSCaesar Wang 106c1185ffdSJulius Werner struct bl_aux_gpio_info *plat_get_rockchip_gpio_reset(void); 107c1185ffdSJulius Werner struct bl_aux_gpio_info *plat_get_rockchip_gpio_poweroff(void); 108c1185ffdSJulius Werner struct bl_aux_gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count); 109c1185ffdSJulius Werner struct bl_aux_rk_apio_info *plat_get_rockchip_suspend_apio(void); 1109901dcf6SCaesar Wang void plat_rockchip_gpio_init(void); 1112adcad64SLin Huang void plat_rockchip_save_gpio(void); 1122adcad64SLin Huang void plat_rockchip_restore_gpio(void); 1139901dcf6SCaesar Wang 114f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_on(unsigned long mpidr, uint64_t entrypoint); 115f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_off(uint32_t lvl, 116f32ab444Stony.xie plat_local_state_t lvl_state); 117f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_off(void); 118f32ab444Stony.xie int rockchip_soc_sys_pwr_dm_suspend(void); 119f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_suspend(void); 120f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_suspend(uint32_t lvl, 121f32ab444Stony.xie plat_local_state_t lvl_state); 122f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_on_finish(uint32_t lvl, 123f32ab444Stony.xie plat_local_state_t lvl_state); 124f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_on_finish(void); 125f32ab444Stony.xie int rockchip_soc_sys_pwr_dm_resume(void); 126f32ab444Stony.xie 127f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_resume(uint32_t lvl, 128f32ab444Stony.xie plat_local_state_t lvl_state); 129f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_resume(void); 130f32ab444Stony.xie void __dead2 rockchip_soc_soft_reset(void); 131f32ab444Stony.xie void __dead2 rockchip_soc_system_off(void); 132*1ed77d1bSBoyan Karatotev void rockchip_soc_cores_pd_pwr_dn_wfi( 133f32ab444Stony.xie const psci_power_state_t *target_state); 134*1ed77d1bSBoyan Karatotev void rockchip_soc_sys_pd_pwr_dn_wfi(void); 135f32ab444Stony.xie 1366fba6e04STony Xie extern const unsigned char rockchip_power_domain_tree_desc[]; 1376fba6e04STony Xie 138bc5c3007SLin Huang extern void *pmu_cpuson_entrypoint; 13982e18f89SHeiko Stuebner extern u_register_t cpuson_entry_point[PLATFORM_CORE_COUNT]; 1406fba6e04STony Xie extern uint32_t cpuson_flags[PLATFORM_CORE_COUNT]; 1416fba6e04STony Xie extern const mmap_region_t plat_rk_mmap[]; 142ec693569SCaesar Wang 143220c33a2SChristoph Müllner uint32_t rockchip_get_uart_base(void); 14430970e0fSHeiko Stuebner uint32_t rockchip_get_uart_baudrate(void); 145dd4a0d16SHeiko Stuebner uint32_t rockchip_get_uart_clock(void); 146220c33a2SChristoph Müllner 14704150feeSXiaoDong Huang void rockchip_init_scmi_server(void); 148d5dfdeb6SJulius Werner #endif /* __ASSEMBLER__ */ 1496fba6e04STony Xie 1509ec78bdfSTony Xie /****************************************************************************** 1519ec78bdfSTony Xie * cpu up status 1529ec78bdfSTony Xie * The bits of macro value is not more than 12 bits for cmp instruction! 1539ec78bdfSTony Xie ******************************************************************************/ 1549ec78bdfSTony Xie #define PMU_CPU_HOTPLUG 0xf00 1559ec78bdfSTony Xie #define PMU_CPU_AUTO_PWRDN 0xf0 1569ec78bdfSTony Xie #define PMU_CLST_RET 0xa5 1576fba6e04STony Xie 158c3cf06f1SAntonio Nino Diaz #endif /* PLAT_PRIVATE_H */ 159