xref: /rk3399_ARM-atf/plat/rockchip/common/include/plat_private.h (revision f32ab4445a669cb44d51c97f388bb363ad22b824)
16fba6e04STony Xie /*
26fba6e04STony Xie  * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
36fba6e04STony Xie  *
46fba6e04STony Xie  * Redistribution and use in source and binary forms, with or without
56fba6e04STony Xie  * modification, are permitted provided that the following conditions are met:
66fba6e04STony Xie  *
76fba6e04STony Xie  * Redistributions of source code must retain the above copyright notice, this
86fba6e04STony Xie  * list of conditions and the following disclaimer.
96fba6e04STony Xie  *
106fba6e04STony Xie  * Redistributions in binary form must reproduce the above copyright notice,
116fba6e04STony Xie  * this list of conditions and the following disclaimer in the documentation
126fba6e04STony Xie  * and/or other materials provided with the distribution.
136fba6e04STony Xie  *
146fba6e04STony Xie  * Neither the name of ARM nor the names of its contributors may be used
156fba6e04STony Xie  * to endorse or promote products derived from this software without specific
166fba6e04STony Xie  * prior written permission.
176fba6e04STony Xie  *
186fba6e04STony Xie  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
196fba6e04STony Xie  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
206fba6e04STony Xie  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
216fba6e04STony Xie  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
226fba6e04STony Xie  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
236fba6e04STony Xie  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
246fba6e04STony Xie  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
256fba6e04STony Xie  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
266fba6e04STony Xie  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
276fba6e04STony Xie  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
286fba6e04STony Xie  * POSSIBILITY OF SUCH DAMAGE.
296fba6e04STony Xie  */
306fba6e04STony Xie 
316fba6e04STony Xie #ifndef __PLAT_PRIVATE_H__
326fba6e04STony Xie #define __PLAT_PRIVATE_H__
336fba6e04STony Xie 
346fba6e04STony Xie #ifndef __ASSEMBLY__
356fba6e04STony Xie #include <mmio.h>
366fba6e04STony Xie #include <stdint.h>
376fba6e04STony Xie #include <xlat_tables.h>
389ec78bdfSTony Xie #include <psci.h>
396fba6e04STony Xie 
40ec693569SCaesar Wang #define __sramdata __attribute__((section(".sram.data")))
41ec693569SCaesar Wang #define __sramconst __attribute__((section(".sram.rodata")))
42ec693569SCaesar Wang #define __sramfunc __attribute__((section(".sram.text")))	\
43ec693569SCaesar Wang 			__attribute__((noinline))
44ec693569SCaesar Wang 
45ec693569SCaesar Wang extern uint32_t __bl31_sram_text_start, __bl31_sram_text_end;
46ec693569SCaesar Wang extern uint32_t __bl31_sram_data_start, __bl31_sram_data_end;
47ec693569SCaesar Wang 
486fba6e04STony Xie 
496fba6e04STony Xie /******************************************************************************
506fba6e04STony Xie  * The register have write-mask bits, it is mean, if you want to set the bits,
516fba6e04STony Xie  * you needs set the write-mask bits at the same time,
526fba6e04STony Xie  * The write-mask bits is in high 16-bits.
536fba6e04STony Xie  * The fllowing macro definition helps access write-mask bits reg efficient!
546fba6e04STony Xie  ******************************************************************************/
556fba6e04STony Xie #define REG_MSK_SHIFT	16
566fba6e04STony Xie 
576fba6e04STony Xie #ifndef WMSK_BIT
586fba6e04STony Xie #define WMSK_BIT(nr)		BIT((nr) + REG_MSK_SHIFT)
596fba6e04STony Xie #endif
606fba6e04STony Xie 
616fba6e04STony Xie /* set one bit with write mask */
626fba6e04STony Xie #ifndef BIT_WITH_WMSK
636fba6e04STony Xie #define BIT_WITH_WMSK(nr)	(BIT(nr) | WMSK_BIT(nr))
646fba6e04STony Xie #endif
656fba6e04STony Xie 
666fba6e04STony Xie #ifndef BITS_SHIFT
676fba6e04STony Xie #define BITS_SHIFT(bits, shift)	(bits << (shift))
686fba6e04STony Xie #endif
696fba6e04STony Xie 
706fba6e04STony Xie #ifndef BITS_WITH_WMASK
71f47a25ddSCaesar Wang #define BITS_WITH_WMASK(bits, msk, shift)\
726fba6e04STony Xie 	(BITS_SHIFT(bits, shift) | BITS_SHIFT(msk, (shift + REG_MSK_SHIFT)))
736fba6e04STony Xie #endif
746fba6e04STony Xie 
756fba6e04STony Xie /******************************************************************************
766fba6e04STony Xie  * Function and variable prototypes
776fba6e04STony Xie  *****************************************************************************/
786fba6e04STony Xie void plat_configure_mmu_el3(unsigned long total_base,
796fba6e04STony Xie 			    unsigned long total_size,
806fba6e04STony Xie 			    unsigned long,
816fba6e04STony Xie 			    unsigned long,
826fba6e04STony Xie 			    unsigned long,
836fba6e04STony Xie 			    unsigned long);
846fba6e04STony Xie 
856fba6e04STony Xie void plat_cci_init(void);
866fba6e04STony Xie void plat_cci_enable(void);
876fba6e04STony Xie void plat_cci_disable(void);
886fba6e04STony Xie 
896fba6e04STony Xie void plat_delay_timer_init(void);
906fba6e04STony Xie 
9168ff45f4SCaesar Wang void params_early_setup(void *plat_params_from_bl2);
9268ff45f4SCaesar Wang 
936fba6e04STony Xie void plat_rockchip_gic_driver_init(void);
946fba6e04STony Xie void plat_rockchip_gic_init(void);
956fba6e04STony Xie void plat_rockchip_gic_cpuif_enable(void);
966fba6e04STony Xie void plat_rockchip_gic_cpuif_disable(void);
976fba6e04STony Xie void plat_rockchip_gic_pcpu_init(void);
986fba6e04STony Xie 
996fba6e04STony Xie void plat_rockchip_pmusram_prepare(void);
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 
106e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_reset(void);
107e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_poweroff(void);
108e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count);
1092bff35bbSCaesar Wang struct apio_info *plat_get_rockchip_suspend_apio(void);
1109901dcf6SCaesar Wang void plat_rockchip_gpio_init(void);
1119901dcf6SCaesar Wang 
112*f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_on(unsigned long mpidr, uint64_t entrypoint);
113*f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_off(uint32_t lvl,
114*f32ab444Stony.xie 				 plat_local_state_t lvl_state);
115*f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_off(void);
116*f32ab444Stony.xie int rockchip_soc_sys_pwr_dm_suspend(void);
117*f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_suspend(void);
118*f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_suspend(uint32_t lvl,
119*f32ab444Stony.xie 				     plat_local_state_t lvl_state);
120*f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_on_finish(uint32_t lvl,
121*f32ab444Stony.xie 				       plat_local_state_t lvl_state);
122*f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_on_finish(void);
123*f32ab444Stony.xie int rockchip_soc_sys_pwr_dm_resume(void);
124*f32ab444Stony.xie 
125*f32ab444Stony.xie int rockchip_soc_hlvl_pwr_dm_resume(uint32_t lvl,
126*f32ab444Stony.xie 				    plat_local_state_t lvl_state);
127*f32ab444Stony.xie int rockchip_soc_cores_pwr_dm_resume(void);
128*f32ab444Stony.xie void __dead2 rockchip_soc_soft_reset(void);
129*f32ab444Stony.xie void __dead2 rockchip_soc_system_off(void);
130*f32ab444Stony.xie void __dead2 rockchip_soc_cores_pd_pwr_dn_wfi(
131*f32ab444Stony.xie 				const psci_power_state_t *target_state);
132*f32ab444Stony.xie void __dead2 rockchip_soc_sys_pd_pwr_dn_wfi(void);
133*f32ab444Stony.xie 
1346fba6e04STony Xie extern const unsigned char rockchip_power_domain_tree_desc[];
1356fba6e04STony Xie 
1366fba6e04STony Xie extern void *pmu_cpuson_entrypoint_start;
1376fba6e04STony Xie extern void *pmu_cpuson_entrypoint_end;
1386fba6e04STony Xie extern uint64_t cpuson_entry_point[PLATFORM_CORE_COUNT];
1396fba6e04STony Xie extern uint32_t cpuson_flags[PLATFORM_CORE_COUNT];
1406fba6e04STony Xie 
1416fba6e04STony Xie extern const mmap_region_t plat_rk_mmap[];
142ec693569SCaesar Wang 
143ec693569SCaesar Wang void rockchip_plat_sram_mmu_el3(void);
144ec693569SCaesar Wang void plat_rockchip_mem_prepare(void);
145ec693569SCaesar Wang 
1466fba6e04STony Xie #endif /* __ASSEMBLY__ */
1476fba6e04STony Xie 
1489ec78bdfSTony Xie /******************************************************************************
1499ec78bdfSTony Xie  * cpu up status
1509ec78bdfSTony Xie  * The bits of macro value is not more than 12 bits for cmp instruction!
1519ec78bdfSTony Xie  ******************************************************************************/
1529ec78bdfSTony Xie #define PMU_CPU_HOTPLUG		0xf00
1539ec78bdfSTony Xie #define PMU_CPU_AUTO_PWRDN	0xf0
1549ec78bdfSTony Xie #define PMU_CLST_RET	0xa5
1556fba6e04STony Xie 
1566fba6e04STony Xie #endif /* __PLAT_PRIVATE_H__ */
157