xref: /rk3399_ARM-atf/plat/rockchip/common/include/plat_private.h (revision ec6935692a1ecd69473ca0f1990d8ed280dfca61)
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 
40*ec693569SCaesar Wang #define __sramdata __attribute__((section(".sram.data")))
41*ec693569SCaesar Wang #define __sramconst __attribute__((section(".sram.rodata")))
42*ec693569SCaesar Wang #define __sramfunc __attribute__((section(".sram.text")))	\
43*ec693569SCaesar Wang 			__attribute__((noinline))
44*ec693569SCaesar Wang 
45*ec693569SCaesar Wang extern uint32_t __bl31_sram_text_start, __bl31_sram_text_end;
46*ec693569SCaesar Wang extern uint32_t __bl31_sram_data_start, __bl31_sram_data_end;
47*ec693569SCaesar Wang 
486fba6e04STony Xie /******************************************************************************
496fba6e04STony Xie  * For rockchip socs pm ops
506fba6e04STony Xie  ******************************************************************************/
516fba6e04STony Xie struct rockchip_pm_ops_cb {
526fba6e04STony Xie 	int (*cores_pwr_dm_on)(unsigned long mpidr, uint64_t entrypoint);
536fba6e04STony Xie 	int (*cores_pwr_dm_off)(void);
546fba6e04STony Xie 	int (*cores_pwr_dm_on_finish)(void);
556fba6e04STony Xie 	int (*cores_pwr_dm_suspend)(void);
566fba6e04STony Xie 	int (*cores_pwr_dm_resume)(void);
579ec78bdfSTony Xie 	/* hlvl is used for clusters or system level */
589ec78bdfSTony Xie 	int (*hlvl_pwr_dm_suspend)(uint32_t lvl, plat_local_state_t lvl_state);
599ec78bdfSTony Xie 	int (*hlvl_pwr_dm_resume)(uint32_t lvl, plat_local_state_t lvl_state);
609ec78bdfSTony Xie 	int (*hlvl_pwr_dm_off)(uint32_t lvl, plat_local_state_t lvl_state);
619ec78bdfSTony Xie 	int (*hlvl_pwr_dm_on_finish)(uint32_t lvl,
629ec78bdfSTony Xie 				     plat_local_state_t lvl_state);
636fba6e04STony Xie 	int (*sys_pwr_dm_suspend)(void);
646fba6e04STony Xie 	int (*sys_pwr_dm_resume)(void);
656fba6e04STony Xie 	void (*sys_gbl_soft_reset)(void) __dead2;
666fba6e04STony Xie 	void (*system_off)(void) __dead2;
67bdb2763dSCaesar Wang 	void (*sys_pwr_down_wfi)(const psci_power_state_t *state_info) __dead2;
686fba6e04STony Xie };
696fba6e04STony Xie 
706fba6e04STony Xie /******************************************************************************
716fba6e04STony Xie  * The register have write-mask bits, it is mean, if you want to set the bits,
726fba6e04STony Xie  * you needs set the write-mask bits at the same time,
736fba6e04STony Xie  * The write-mask bits is in high 16-bits.
746fba6e04STony Xie  * The fllowing macro definition helps access write-mask bits reg efficient!
756fba6e04STony Xie  ******************************************************************************/
766fba6e04STony Xie #define REG_MSK_SHIFT	16
776fba6e04STony Xie 
786fba6e04STony Xie #ifndef BIT
796fba6e04STony Xie #define BIT(nr)			(1 << (nr))
806fba6e04STony Xie #endif
816fba6e04STony Xie 
826fba6e04STony Xie #ifndef WMSK_BIT
836fba6e04STony Xie #define WMSK_BIT(nr)		BIT((nr) + REG_MSK_SHIFT)
846fba6e04STony Xie #endif
856fba6e04STony Xie 
866fba6e04STony Xie /* set one bit with write mask */
876fba6e04STony Xie #ifndef BIT_WITH_WMSK
886fba6e04STony Xie #define BIT_WITH_WMSK(nr)	(BIT(nr) | WMSK_BIT(nr))
896fba6e04STony Xie #endif
906fba6e04STony Xie 
916fba6e04STony Xie #ifndef BITS_SHIFT
926fba6e04STony Xie #define BITS_SHIFT(bits, shift)	(bits << (shift))
936fba6e04STony Xie #endif
946fba6e04STony Xie 
956fba6e04STony Xie #ifndef BITS_WITH_WMASK
96f47a25ddSCaesar Wang #define BITS_WITH_WMASK(bits, msk, shift)\
976fba6e04STony Xie 	(BITS_SHIFT(bits, shift) | BITS_SHIFT(msk, (shift + REG_MSK_SHIFT)))
986fba6e04STony Xie #endif
996fba6e04STony Xie 
1006fba6e04STony Xie /******************************************************************************
1016fba6e04STony Xie  * Function and variable prototypes
1026fba6e04STony Xie  *****************************************************************************/
1036fba6e04STony Xie void plat_configure_mmu_el3(unsigned long total_base,
1046fba6e04STony Xie 			    unsigned long total_size,
1056fba6e04STony Xie 			    unsigned long,
1066fba6e04STony Xie 			    unsigned long,
1076fba6e04STony Xie 			    unsigned long,
1086fba6e04STony Xie 			    unsigned long);
1096fba6e04STony Xie 
1106fba6e04STony Xie void plat_cci_init(void);
1116fba6e04STony Xie void plat_cci_enable(void);
1126fba6e04STony Xie void plat_cci_disable(void);
1136fba6e04STony Xie 
1146fba6e04STony Xie void plat_delay_timer_init(void);
1156fba6e04STony Xie 
11668ff45f4SCaesar Wang void params_early_setup(void *plat_params_from_bl2);
11768ff45f4SCaesar Wang 
1186fba6e04STony Xie void plat_rockchip_gic_driver_init(void);
1196fba6e04STony Xie void plat_rockchip_gic_init(void);
1206fba6e04STony Xie void plat_rockchip_gic_cpuif_enable(void);
1216fba6e04STony Xie void plat_rockchip_gic_cpuif_disable(void);
1226fba6e04STony Xie void plat_rockchip_gic_pcpu_init(void);
1236fba6e04STony Xie 
1246fba6e04STony Xie void plat_rockchip_pmusram_prepare(void);
1256fba6e04STony Xie void plat_rockchip_pmu_init(void);
1266fba6e04STony Xie void plat_rockchip_soc_init(void);
1276fba6e04STony Xie void plat_setup_rockchip_pm_ops(struct rockchip_pm_ops_cb *ops);
1289ec78bdfSTony Xie uintptr_t plat_get_sec_entrypoint(void);
1296fba6e04STony Xie 
130f47a25ddSCaesar Wang void platform_cpu_warmboot(void);
131f47a25ddSCaesar Wang 
132e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_reset(void);
133e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_gpio_poweroff(void);
134e550c631SCaesar Wang struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count);
1352bff35bbSCaesar Wang struct apio_info *plat_get_rockchip_suspend_apio(void);
1369901dcf6SCaesar Wang void plat_rockchip_gpio_init(void);
1379901dcf6SCaesar Wang 
1386fba6e04STony Xie extern const unsigned char rockchip_power_domain_tree_desc[];
1396fba6e04STony Xie 
1406fba6e04STony Xie extern void *pmu_cpuson_entrypoint_start;
1416fba6e04STony Xie extern void *pmu_cpuson_entrypoint_end;
1426fba6e04STony Xie extern uint64_t cpuson_entry_point[PLATFORM_CORE_COUNT];
1436fba6e04STony Xie extern uint32_t cpuson_flags[PLATFORM_CORE_COUNT];
1446fba6e04STony Xie 
1456fba6e04STony Xie extern const mmap_region_t plat_rk_mmap[];
146*ec693569SCaesar Wang 
147*ec693569SCaesar Wang void rockchip_plat_sram_mmu_el3(void);
148*ec693569SCaesar Wang void plat_rockchip_mem_prepare(void);
149*ec693569SCaesar Wang 
1506fba6e04STony Xie #endif /* __ASSEMBLY__ */
1516fba6e04STony Xie 
1529ec78bdfSTony Xie /******************************************************************************
1539ec78bdfSTony Xie  * cpu up status
1549ec78bdfSTony Xie  * The bits of macro value is not more than 12 bits for cmp instruction!
1559ec78bdfSTony Xie  ******************************************************************************/
1569ec78bdfSTony Xie #define PMU_CPU_HOTPLUG		0xf00
1579ec78bdfSTony Xie #define PMU_CPU_AUTO_PWRDN	0xf0
1589ec78bdfSTony Xie #define PMU_CLST_RET	0xa5
1596fba6e04STony Xie 
1606fba6e04STony Xie #endif /* __PLAT_PRIVATE_H__ */
161