xref: /rk3399_ARM-atf/plat/rockchip/common/include/plat_private.h (revision 977001aa877f90dfbc8033f8b266b7488c442038)
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;
47*977001aaSXing Zheng extern uint32_t __sram_incbin_start, __sram_incbin_end;
48ec693569SCaesar Wang 
496fba6e04STony Xie /******************************************************************************
506fba6e04STony Xie  * For rockchip socs pm ops
516fba6e04STony Xie  ******************************************************************************/
526fba6e04STony Xie struct rockchip_pm_ops_cb {
536fba6e04STony Xie 	int (*cores_pwr_dm_on)(unsigned long mpidr, uint64_t entrypoint);
546fba6e04STony Xie 	int (*cores_pwr_dm_off)(void);
556fba6e04STony Xie 	int (*cores_pwr_dm_on_finish)(void);
566fba6e04STony Xie 	int (*cores_pwr_dm_suspend)(void);
576fba6e04STony Xie 	int (*cores_pwr_dm_resume)(void);
589ec78bdfSTony Xie 	/* hlvl is used for clusters or system level */
599ec78bdfSTony Xie 	int (*hlvl_pwr_dm_suspend)(uint32_t lvl, plat_local_state_t lvl_state);
609ec78bdfSTony Xie 	int (*hlvl_pwr_dm_resume)(uint32_t lvl, plat_local_state_t lvl_state);
619ec78bdfSTony Xie 	int (*hlvl_pwr_dm_off)(uint32_t lvl, plat_local_state_t lvl_state);
629ec78bdfSTony Xie 	int (*hlvl_pwr_dm_on_finish)(uint32_t lvl,
639ec78bdfSTony Xie 				     plat_local_state_t lvl_state);
646fba6e04STony Xie 	int (*sys_pwr_dm_suspend)(void);
656fba6e04STony Xie 	int (*sys_pwr_dm_resume)(void);
666fba6e04STony Xie 	void (*sys_gbl_soft_reset)(void) __dead2;
676fba6e04STony Xie 	void (*system_off)(void) __dead2;
68bdb2763dSCaesar Wang 	void (*sys_pwr_down_wfi)(const psci_power_state_t *state_info) __dead2;
696fba6e04STony Xie };
706fba6e04STony Xie 
716fba6e04STony Xie /******************************************************************************
726fba6e04STony Xie  * The register have write-mask bits, it is mean, if you want to set the bits,
736fba6e04STony Xie  * you needs set the write-mask bits at the same time,
746fba6e04STony Xie  * The write-mask bits is in high 16-bits.
756fba6e04STony Xie  * The fllowing macro definition helps access write-mask bits reg efficient!
766fba6e04STony Xie  ******************************************************************************/
776fba6e04STony Xie #define REG_MSK_SHIFT	16
786fba6e04STony Xie 
796fba6e04STony Xie #ifndef WMSK_BIT
806fba6e04STony Xie #define WMSK_BIT(nr)		BIT((nr) + REG_MSK_SHIFT)
816fba6e04STony Xie #endif
826fba6e04STony Xie 
836fba6e04STony Xie /* set one bit with write mask */
846fba6e04STony Xie #ifndef BIT_WITH_WMSK
856fba6e04STony Xie #define BIT_WITH_WMSK(nr)	(BIT(nr) | WMSK_BIT(nr))
866fba6e04STony Xie #endif
876fba6e04STony Xie 
886fba6e04STony Xie #ifndef BITS_SHIFT
896fba6e04STony Xie #define BITS_SHIFT(bits, shift)	(bits << (shift))
906fba6e04STony Xie #endif
916fba6e04STony Xie 
926fba6e04STony Xie #ifndef BITS_WITH_WMASK
93f47a25ddSCaesar Wang #define BITS_WITH_WMASK(bits, msk, shift)\
946fba6e04STony Xie 	(BITS_SHIFT(bits, shift) | BITS_SHIFT(msk, (shift + REG_MSK_SHIFT)))
956fba6e04STony Xie #endif
966fba6e04STony Xie 
976fba6e04STony Xie /******************************************************************************
986fba6e04STony Xie  * Function and variable prototypes
996fba6e04STony Xie  *****************************************************************************/
1006fba6e04STony Xie void plat_configure_mmu_el3(unsigned long total_base,
1016fba6e04STony Xie 			    unsigned long total_size,
1026fba6e04STony Xie 			    unsigned long,
1036fba6e04STony Xie 			    unsigned long,
1046fba6e04STony Xie 			    unsigned long,
1056fba6e04STony Xie 			    unsigned long);
1066fba6e04STony Xie 
1076fba6e04STony Xie void plat_cci_init(void);
1086fba6e04STony Xie void plat_cci_enable(void);
1096fba6e04STony Xie void plat_cci_disable(void);
1106fba6e04STony Xie 
1116fba6e04STony Xie void plat_delay_timer_init(void);
1126fba6e04STony Xie 
11368ff45f4SCaesar Wang void params_early_setup(void *plat_params_from_bl2);
11468ff45f4SCaesar Wang 
1156fba6e04STony Xie void plat_rockchip_gic_driver_init(void);
1166fba6e04STony Xie void plat_rockchip_gic_init(void);
1176fba6e04STony Xie void plat_rockchip_gic_cpuif_enable(void);
1186fba6e04STony Xie void plat_rockchip_gic_cpuif_disable(void);
1196fba6e04STony Xie void plat_rockchip_gic_pcpu_init(void);
1206fba6e04STony Xie 
1216fba6e04STony Xie void plat_rockchip_pmusram_prepare(void);
1226fba6e04STony Xie void plat_rockchip_pmu_init(void);
1236fba6e04STony Xie void plat_rockchip_soc_init(void);
1246fba6e04STony Xie void plat_setup_rockchip_pm_ops(struct rockchip_pm_ops_cb *ops);
1259ec78bdfSTony Xie uintptr_t plat_get_sec_entrypoint(void);
1266fba6e04STony Xie 
127f47a25ddSCaesar Wang void platform_cpu_warmboot(void);
128f47a25ddSCaesar Wang 
129e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_reset(void);
130e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_poweroff(void);
131e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count);
1322bff35bbSCaesar Wang struct apio_info *plat_get_rockchip_suspend_apio(void);
1339901dcf6SCaesar Wang void plat_rockchip_gpio_init(void);
1349901dcf6SCaesar Wang 
1356fba6e04STony Xie extern const unsigned char rockchip_power_domain_tree_desc[];
1366fba6e04STony Xie 
1376fba6e04STony Xie extern void *pmu_cpuson_entrypoint_start;
1386fba6e04STony Xie extern void *pmu_cpuson_entrypoint_end;
1396fba6e04STony Xie extern uint64_t cpuson_entry_point[PLATFORM_CORE_COUNT];
1406fba6e04STony Xie extern uint32_t cpuson_flags[PLATFORM_CORE_COUNT];
1416fba6e04STony Xie 
1426fba6e04STony Xie extern const mmap_region_t plat_rk_mmap[];
143ec693569SCaesar Wang 
144ec693569SCaesar Wang void rockchip_plat_sram_mmu_el3(void);
145ec693569SCaesar Wang void plat_rockchip_mem_prepare(void);
146ec693569SCaesar Wang 
1476fba6e04STony Xie #endif /* __ASSEMBLY__ */
1486fba6e04STony Xie 
1499ec78bdfSTony Xie /******************************************************************************
1509ec78bdfSTony Xie  * cpu up status
1519ec78bdfSTony Xie  * The bits of macro value is not more than 12 bits for cmp instruction!
1529ec78bdfSTony Xie  ******************************************************************************/
1539ec78bdfSTony Xie #define PMU_CPU_HOTPLUG		0xf00
1549ec78bdfSTony Xie #define PMU_CPU_AUTO_PWRDN	0xf0
1559ec78bdfSTony Xie #define PMU_CLST_RET	0xa5
1566fba6e04STony Xie 
1576fba6e04STony Xie #endif /* __PLAT_PRIVATE_H__ */
158