xref: /rk3399_ARM-atf/plat/rockchip/common/include/plat_private.h (revision 09d40e0e08283a249e7dce0e106c07c5141f9b7e)
16fba6e04STony Xie /*
26fba6e04STony Xie  * Copyright (c) 2014-2016, 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 
106fba6e04STony Xie #ifndef __ASSEMBLY__
11*09d40e0eSAntonio Nino Diaz 
126fba6e04STony Xie #include <stdint.h>
13*09d40e0eSAntonio Nino Diaz 
14*09d40e0eSAntonio Nino Diaz #include <lib/psci/psci.h>
15*09d40e0eSAntonio Nino Diaz #include <lib/xlat_tables/xlat_tables.h>
16*09d40e0eSAntonio Nino Diaz #include <lib/mmio.h>
176fba6e04STony Xie 
18ec693569SCaesar Wang #define __sramdata __attribute__((section(".sram.data")))
19ec693569SCaesar Wang #define __sramconst __attribute__((section(".sram.rodata")))
20bc5c3007SLin Huang #define __sramfunc __attribute__((section(".sram.text")))
21bc5c3007SLin Huang 
22bc5c3007SLin Huang #define __pmusramdata __attribute__((section(".pmusram.data")))
23bc5c3007SLin Huang #define __pmusramconst __attribute__((section(".pmusram.rodata")))
24bc5c3007SLin Huang #define __pmusramfunc __attribute__((section(".pmusram.text")))
25ec693569SCaesar Wang 
26ec693569SCaesar Wang extern uint32_t __bl31_sram_text_start, __bl31_sram_text_end;
27ec693569SCaesar Wang extern uint32_t __bl31_sram_data_start, __bl31_sram_data_end;
28bc5c3007SLin Huang extern uint32_t __bl31_sram_stack_start, __bl31_sram_stack_end;
294e836d35SLin Huang extern uint32_t __bl31_sram_text_real_end, __bl31_sram_data_real_end;
30977001aaSXing Zheng extern uint32_t __sram_incbin_start, __sram_incbin_end;
314e836d35SLin Huang extern uint32_t __sram_incbin_real_end;
32ec693569SCaesar Wang 
332d6f1f01SAntonio Nino Diaz struct rockchip_bl31_params {
342d6f1f01SAntonio Nino Diaz        param_header_t h;
352d6f1f01SAntonio Nino Diaz        image_info_t *bl31_image_info;
362d6f1f01SAntonio Nino Diaz        entry_point_info_t *bl32_ep_info;
372d6f1f01SAntonio Nino Diaz        image_info_t *bl32_image_info;
382d6f1f01SAntonio Nino Diaz        entry_point_info_t *bl33_ep_info;
392d6f1f01SAntonio Nino Diaz        image_info_t *bl33_image_info;
402d6f1f01SAntonio Nino Diaz };
416fba6e04STony Xie 
426fba6e04STony Xie /******************************************************************************
436fba6e04STony Xie  * The register have write-mask bits, it is mean, if you want to set the bits,
446fba6e04STony Xie  * you needs set the write-mask bits at the same time,
456fba6e04STony Xie  * The write-mask bits is in high 16-bits.
466fba6e04STony Xie  * The fllowing macro definition helps access write-mask bits reg efficient!
476fba6e04STony Xie  ******************************************************************************/
486fba6e04STony Xie #define REG_MSK_SHIFT	16
496fba6e04STony Xie 
506fba6e04STony Xie #ifndef WMSK_BIT
516fba6e04STony Xie #define WMSK_BIT(nr)		BIT((nr) + REG_MSK_SHIFT)
526fba6e04STony Xie #endif
536fba6e04STony Xie 
546fba6e04STony Xie /* set one bit with write mask */
556fba6e04STony Xie #ifndef BIT_WITH_WMSK
566fba6e04STony Xie #define BIT_WITH_WMSK(nr)	(BIT(nr) | WMSK_BIT(nr))
576fba6e04STony Xie #endif
586fba6e04STony Xie 
596fba6e04STony Xie #ifndef BITS_SHIFT
606fba6e04STony Xie #define BITS_SHIFT(bits, shift)	(bits << (shift))
616fba6e04STony Xie #endif
626fba6e04STony Xie 
636fba6e04STony Xie #ifndef BITS_WITH_WMASK
64f47a25ddSCaesar Wang #define BITS_WITH_WMASK(bits, msk, shift)\
656fba6e04STony Xie 	(BITS_SHIFT(bits, shift) | BITS_SHIFT(msk, (shift + REG_MSK_SHIFT)))
666fba6e04STony Xie #endif
676fba6e04STony Xie 
686fba6e04STony Xie /******************************************************************************
696fba6e04STony Xie  * Function and variable prototypes
706fba6e04STony Xie  *****************************************************************************/
716fba6e04STony Xie void plat_configure_mmu_el3(unsigned long total_base,
726fba6e04STony Xie 			    unsigned long total_size,
736fba6e04STony Xie 			    unsigned long,
746fba6e04STony Xie 			    unsigned long,
756fba6e04STony Xie 			    unsigned long,
766fba6e04STony Xie 			    unsigned long);
776fba6e04STony Xie 
786fba6e04STony Xie void plat_cci_init(void);
796fba6e04STony Xie void plat_cci_enable(void);
806fba6e04STony Xie void plat_cci_disable(void);
816fba6e04STony Xie 
826fba6e04STony Xie void plat_delay_timer_init(void);
836fba6e04STony Xie 
8468ff45f4SCaesar Wang void params_early_setup(void *plat_params_from_bl2);
8568ff45f4SCaesar Wang 
866fba6e04STony Xie void plat_rockchip_gic_driver_init(void);
876fba6e04STony Xie void plat_rockchip_gic_init(void);
886fba6e04STony Xie void plat_rockchip_gic_cpuif_enable(void);
896fba6e04STony Xie void plat_rockchip_gic_cpuif_disable(void);
906fba6e04STony Xie void plat_rockchip_gic_pcpu_init(void);
916fba6e04STony Xie 
926fba6e04STony Xie void plat_rockchip_pmu_init(void);
936fba6e04STony Xie void plat_rockchip_soc_init(void);
949ec78bdfSTony Xie uintptr_t plat_get_sec_entrypoint(void);
956fba6e04STony Xie 
96f47a25ddSCaesar Wang void platform_cpu_warmboot(void);
97f47a25ddSCaesar Wang 
98e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_reset(void);
99e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_poweroff(void);
100e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count);
1012bff35bbSCaesar Wang struct apio_info *plat_get_rockchip_suspend_apio(void);
1029901dcf6SCaesar Wang void plat_rockchip_gpio_init(void);
1032adcad64SLin Huang void plat_rockchip_save_gpio(void);
1042adcad64SLin Huang void plat_rockchip_restore_gpio(void);
1059901dcf6SCaesar Wang 
106f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_on(unsigned long mpidr, uint64_t entrypoint);
107f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_off(uint32_t lvl,
108f32ab444Stony.xie 				 plat_local_state_t lvl_state);
109f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_off(void);
110f32ab444Stony.xie int rockchip_soc_sys_pwr_dm_suspend(void);
111f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_suspend(void);
112f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_suspend(uint32_t lvl,
113f32ab444Stony.xie 				     plat_local_state_t lvl_state);
114f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_on_finish(uint32_t lvl,
115f32ab444Stony.xie 				       plat_local_state_t lvl_state);
116f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_on_finish(void);
117f32ab444Stony.xie int rockchip_soc_sys_pwr_dm_resume(void);
118f32ab444Stony.xie 
119f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_resume(uint32_t lvl,
120f32ab444Stony.xie 				    plat_local_state_t lvl_state);
121f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_resume(void);
122f32ab444Stony.xie void __dead2 rockchip_soc_soft_reset(void);
123f32ab444Stony.xie void __dead2 rockchip_soc_system_off(void);
124f32ab444Stony.xie void __dead2 rockchip_soc_cores_pd_pwr_dn_wfi(
125f32ab444Stony.xie 				const psci_power_state_t *target_state);
126f32ab444Stony.xie void __dead2 rockchip_soc_sys_pd_pwr_dn_wfi(void);
127f32ab444Stony.xie 
1286fba6e04STony Xie extern const unsigned char rockchip_power_domain_tree_desc[];
1296fba6e04STony Xie 
130bc5c3007SLin Huang extern void *pmu_cpuson_entrypoint;
1316fba6e04STony Xie extern uint64_t cpuson_entry_point[PLATFORM_CORE_COUNT];
1326fba6e04STony Xie extern uint32_t cpuson_flags[PLATFORM_CORE_COUNT];
1336fba6e04STony Xie 
1346fba6e04STony Xie extern const mmap_region_t plat_rk_mmap[];
135ec693569SCaesar Wang 
136bc5c3007SLin Huang void rockchip_plat_mmu_el3(void);
137ec693569SCaesar Wang 
1386fba6e04STony Xie #endif /* __ASSEMBLY__ */
1396fba6e04STony Xie 
1409ec78bdfSTony Xie /******************************************************************************
1419ec78bdfSTony Xie  * cpu up status
1429ec78bdfSTony Xie  * The bits of macro value is not more than 12 bits for cmp instruction!
1439ec78bdfSTony Xie  ******************************************************************************/
1449ec78bdfSTony Xie #define PMU_CPU_HOTPLUG		0xf00
1459ec78bdfSTony Xie #define PMU_CPU_AUTO_PWRDN	0xf0
1469ec78bdfSTony Xie #define PMU_CLST_RET	0xa5
1476fba6e04STony Xie 
148c3cf06f1SAntonio Nino Diaz #endif /* PLAT_PRIVATE_H */
149