xref: /rk3399_ARM-atf/plat/rockchip/common/include/plat_private.h (revision bc5c30073e1ec28407e22727848df1adda433636)
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 
76fba6e04STony Xie #ifndef __PLAT_PRIVATE_H__
86fba6e04STony Xie #define __PLAT_PRIVATE_H__
96fba6e04STony Xie 
106fba6e04STony Xie #ifndef __ASSEMBLY__
116fba6e04STony Xie #include <mmio.h>
126fba6e04STony Xie #include <stdint.h>
136fba6e04STony Xie #include <xlat_tables.h>
149ec78bdfSTony Xie #include <psci.h>
156fba6e04STony Xie 
16ec693569SCaesar Wang #define __sramdata __attribute__((section(".sram.data")))
17ec693569SCaesar Wang #define __sramconst __attribute__((section(".sram.rodata")))
18*bc5c3007SLin Huang #define __sramfunc __attribute__((section(".sram.text")))
19*bc5c3007SLin Huang 
20*bc5c3007SLin Huang #define __pmusramdata __attribute__((section(".pmusram.data")))
21*bc5c3007SLin Huang #define __pmusramconst __attribute__((section(".pmusram.rodata")))
22*bc5c3007SLin Huang #define __pmusramfunc __attribute__((section(".pmusram.text")))
23ec693569SCaesar Wang 
24ec693569SCaesar Wang extern uint32_t __bl31_sram_text_start, __bl31_sram_text_end;
25ec693569SCaesar Wang extern uint32_t __bl31_sram_data_start, __bl31_sram_data_end;
26*bc5c3007SLin Huang extern uint32_t __bl31_sram_stack_start, __bl31_sram_stack_end;
27977001aaSXing Zheng extern uint32_t __sram_incbin_start, __sram_incbin_end;
28ec693569SCaesar Wang 
296fba6e04STony Xie 
306fba6e04STony Xie /******************************************************************************
316fba6e04STony Xie  * The register have write-mask bits, it is mean, if you want to set the bits,
326fba6e04STony Xie  * you needs set the write-mask bits at the same time,
336fba6e04STony Xie  * The write-mask bits is in high 16-bits.
346fba6e04STony Xie  * The fllowing macro definition helps access write-mask bits reg efficient!
356fba6e04STony Xie  ******************************************************************************/
366fba6e04STony Xie #define REG_MSK_SHIFT	16
376fba6e04STony Xie 
386fba6e04STony Xie #ifndef WMSK_BIT
396fba6e04STony Xie #define WMSK_BIT(nr)		BIT((nr) + REG_MSK_SHIFT)
406fba6e04STony Xie #endif
416fba6e04STony Xie 
426fba6e04STony Xie /* set one bit with write mask */
436fba6e04STony Xie #ifndef BIT_WITH_WMSK
446fba6e04STony Xie #define BIT_WITH_WMSK(nr)	(BIT(nr) | WMSK_BIT(nr))
456fba6e04STony Xie #endif
466fba6e04STony Xie 
476fba6e04STony Xie #ifndef BITS_SHIFT
486fba6e04STony Xie #define BITS_SHIFT(bits, shift)	(bits << (shift))
496fba6e04STony Xie #endif
506fba6e04STony Xie 
516fba6e04STony Xie #ifndef BITS_WITH_WMASK
52f47a25ddSCaesar Wang #define BITS_WITH_WMASK(bits, msk, shift)\
536fba6e04STony Xie 	(BITS_SHIFT(bits, shift) | BITS_SHIFT(msk, (shift + REG_MSK_SHIFT)))
546fba6e04STony Xie #endif
556fba6e04STony Xie 
566fba6e04STony Xie /******************************************************************************
576fba6e04STony Xie  * Function and variable prototypes
586fba6e04STony Xie  *****************************************************************************/
596fba6e04STony Xie void plat_configure_mmu_el3(unsigned long total_base,
606fba6e04STony Xie 			    unsigned long total_size,
616fba6e04STony Xie 			    unsigned long,
626fba6e04STony Xie 			    unsigned long,
636fba6e04STony Xie 			    unsigned long,
646fba6e04STony Xie 			    unsigned long);
656fba6e04STony Xie 
666fba6e04STony Xie void plat_cci_init(void);
676fba6e04STony Xie void plat_cci_enable(void);
686fba6e04STony Xie void plat_cci_disable(void);
696fba6e04STony Xie 
706fba6e04STony Xie void plat_delay_timer_init(void);
716fba6e04STony Xie 
7268ff45f4SCaesar Wang void params_early_setup(void *plat_params_from_bl2);
7368ff45f4SCaesar Wang 
746fba6e04STony Xie void plat_rockchip_gic_driver_init(void);
756fba6e04STony Xie void plat_rockchip_gic_init(void);
766fba6e04STony Xie void plat_rockchip_gic_cpuif_enable(void);
776fba6e04STony Xie void plat_rockchip_gic_cpuif_disable(void);
786fba6e04STony Xie void plat_rockchip_gic_pcpu_init(void);
796fba6e04STony Xie 
806fba6e04STony Xie void plat_rockchip_pmu_init(void);
816fba6e04STony Xie void plat_rockchip_soc_init(void);
829ec78bdfSTony Xie uintptr_t plat_get_sec_entrypoint(void);
836fba6e04STony Xie 
84f47a25ddSCaesar Wang void platform_cpu_warmboot(void);
85f47a25ddSCaesar Wang 
86e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_reset(void);
87e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_poweroff(void);
88e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count);
892bff35bbSCaesar Wang struct apio_info *plat_get_rockchip_suspend_apio(void);
909901dcf6SCaesar Wang void plat_rockchip_gpio_init(void);
919901dcf6SCaesar Wang 
92f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_on(unsigned long mpidr, uint64_t entrypoint);
93f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_off(uint32_t lvl,
94f32ab444Stony.xie 				 plat_local_state_t lvl_state);
95f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_off(void);
96f32ab444Stony.xie int rockchip_soc_sys_pwr_dm_suspend(void);
97f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_suspend(void);
98f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_suspend(uint32_t lvl,
99f32ab444Stony.xie 				     plat_local_state_t lvl_state);
100f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_on_finish(uint32_t lvl,
101f32ab444Stony.xie 				       plat_local_state_t lvl_state);
102f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_on_finish(void);
103f32ab444Stony.xie int rockchip_soc_sys_pwr_dm_resume(void);
104f32ab444Stony.xie 
105f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_resume(uint32_t lvl,
106f32ab444Stony.xie 				    plat_local_state_t lvl_state);
107f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_resume(void);
108f32ab444Stony.xie void __dead2 rockchip_soc_soft_reset(void);
109f32ab444Stony.xie void __dead2 rockchip_soc_system_off(void);
110f32ab444Stony.xie void __dead2 rockchip_soc_cores_pd_pwr_dn_wfi(
111f32ab444Stony.xie 				const psci_power_state_t *target_state);
112f32ab444Stony.xie void __dead2 rockchip_soc_sys_pd_pwr_dn_wfi(void);
113f32ab444Stony.xie 
1146fba6e04STony Xie extern const unsigned char rockchip_power_domain_tree_desc[];
1156fba6e04STony Xie 
116*bc5c3007SLin Huang extern void *pmu_cpuson_entrypoint;
1176fba6e04STony Xie extern uint64_t cpuson_entry_point[PLATFORM_CORE_COUNT];
1186fba6e04STony Xie extern uint32_t cpuson_flags[PLATFORM_CORE_COUNT];
1196fba6e04STony Xie 
1206fba6e04STony Xie extern const mmap_region_t plat_rk_mmap[];
121ec693569SCaesar Wang 
122*bc5c3007SLin Huang void rockchip_plat_mmu_el3(void);
123ec693569SCaesar Wang 
1246fba6e04STony Xie #endif /* __ASSEMBLY__ */
1256fba6e04STony Xie 
1269ec78bdfSTony Xie /******************************************************************************
1279ec78bdfSTony Xie  * cpu up status
1289ec78bdfSTony Xie  * The bits of macro value is not more than 12 bits for cmp instruction!
1299ec78bdfSTony Xie  ******************************************************************************/
1309ec78bdfSTony Xie #define PMU_CPU_HOTPLUG		0xf00
1319ec78bdfSTony Xie #define PMU_CPU_AUTO_PWRDN	0xf0
1329ec78bdfSTony Xie #define PMU_CLST_RET	0xa5
1336fba6e04STony Xie 
1346fba6e04STony Xie #endif /* __PLAT_PRIVATE_H__ */
135