xref: /rk3399_ARM-atf/plat/rockchip/common/include/plat_private.h (revision 9ec78bdfc6a8058771920aec51f82513a0e4d4f0)
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>
38*9ec78bdfSTony Xie #include <psci.h>
396fba6e04STony Xie 
406fba6e04STony Xie /******************************************************************************
416fba6e04STony Xie  * For rockchip socs pm ops
426fba6e04STony Xie  ******************************************************************************/
436fba6e04STony Xie struct rockchip_pm_ops_cb {
446fba6e04STony Xie 	int (*cores_pwr_dm_on)(unsigned long mpidr, uint64_t entrypoint);
456fba6e04STony Xie 	int (*cores_pwr_dm_off)(void);
466fba6e04STony Xie 	int (*cores_pwr_dm_on_finish)(void);
476fba6e04STony Xie 	int (*cores_pwr_dm_suspend)(void);
486fba6e04STony Xie 	int (*cores_pwr_dm_resume)(void);
49*9ec78bdfSTony Xie 	/* hlvl is used for clusters or system level */
50*9ec78bdfSTony Xie 	int (*hlvl_pwr_dm_suspend)(uint32_t lvl, plat_local_state_t lvl_state);
51*9ec78bdfSTony Xie 	int (*hlvl_pwr_dm_resume)(uint32_t lvl, plat_local_state_t lvl_state);
52*9ec78bdfSTony Xie 	int (*hlvl_pwr_dm_off)(uint32_t lvl, plat_local_state_t lvl_state);
53*9ec78bdfSTony Xie 	int (*hlvl_pwr_dm_on_finish)(uint32_t lvl,
54*9ec78bdfSTony Xie 				     plat_local_state_t lvl_state);
556fba6e04STony Xie 	int (*sys_pwr_dm_suspend)(void);
566fba6e04STony Xie 	int (*sys_pwr_dm_resume)(void);
576fba6e04STony Xie 	void (*sys_gbl_soft_reset)(void) __dead2;
586fba6e04STony Xie 	void (*system_off)(void) __dead2;
596fba6e04STony Xie };
606fba6e04STony Xie 
616fba6e04STony Xie /******************************************************************************
626fba6e04STony Xie  * The register have write-mask bits, it is mean, if you want to set the bits,
636fba6e04STony Xie  * you needs set the write-mask bits at the same time,
646fba6e04STony Xie  * The write-mask bits is in high 16-bits.
656fba6e04STony Xie  * The fllowing macro definition helps access write-mask bits reg efficient!
666fba6e04STony Xie  ******************************************************************************/
676fba6e04STony Xie #define REG_MSK_SHIFT	16
686fba6e04STony Xie 
696fba6e04STony Xie #ifndef BIT
706fba6e04STony Xie #define BIT(nr)			(1 << (nr))
716fba6e04STony Xie #endif
726fba6e04STony Xie 
736fba6e04STony Xie #ifndef WMSK_BIT
746fba6e04STony Xie #define WMSK_BIT(nr)		BIT((nr) + REG_MSK_SHIFT)
756fba6e04STony Xie #endif
766fba6e04STony Xie 
776fba6e04STony Xie /* set one bit with write mask */
786fba6e04STony Xie #ifndef BIT_WITH_WMSK
796fba6e04STony Xie #define BIT_WITH_WMSK(nr)	(BIT(nr) | WMSK_BIT(nr))
806fba6e04STony Xie #endif
816fba6e04STony Xie 
826fba6e04STony Xie #ifndef BITS_SHIFT
836fba6e04STony Xie #define BITS_SHIFT(bits, shift)	(bits << (shift))
846fba6e04STony Xie #endif
856fba6e04STony Xie 
866fba6e04STony Xie #ifndef BITS_WITH_WMASK
87f47a25ddSCaesar Wang #define BITS_WITH_WMASK(bits, msk, shift)\
886fba6e04STony Xie 	(BITS_SHIFT(bits, shift) | BITS_SHIFT(msk, (shift + REG_MSK_SHIFT)))
896fba6e04STony Xie #endif
906fba6e04STony Xie 
916fba6e04STony Xie /******************************************************************************
926fba6e04STony Xie  * Function and variable prototypes
936fba6e04STony Xie  *****************************************************************************/
946fba6e04STony Xie void plat_configure_mmu_el3(unsigned long total_base,
956fba6e04STony Xie 			    unsigned long total_size,
966fba6e04STony Xie 			    unsigned long,
976fba6e04STony Xie 			    unsigned long,
986fba6e04STony Xie 			    unsigned long,
996fba6e04STony Xie 			    unsigned long);
1006fba6e04STony Xie 
1016fba6e04STony Xie void plat_cci_init(void);
1026fba6e04STony Xie void plat_cci_enable(void);
1036fba6e04STony Xie void plat_cci_disable(void);
1046fba6e04STony Xie 
1056fba6e04STony Xie void plat_delay_timer_init(void);
1066fba6e04STony Xie 
10768ff45f4SCaesar Wang void params_early_setup(void *plat_params_from_bl2);
10868ff45f4SCaesar Wang 
1096fba6e04STony Xie void plat_rockchip_gic_driver_init(void);
1106fba6e04STony Xie void plat_rockchip_gic_init(void);
1116fba6e04STony Xie void plat_rockchip_gic_cpuif_enable(void);
1126fba6e04STony Xie void plat_rockchip_gic_cpuif_disable(void);
1136fba6e04STony Xie void plat_rockchip_gic_pcpu_init(void);
1146fba6e04STony Xie 
1156fba6e04STony Xie void plat_rockchip_pmusram_prepare(void);
1166fba6e04STony Xie void plat_rockchip_pmu_init(void);
1176fba6e04STony Xie void plat_rockchip_soc_init(void);
1186fba6e04STony Xie void plat_setup_rockchip_pm_ops(struct rockchip_pm_ops_cb *ops);
119*9ec78bdfSTony Xie uintptr_t plat_get_sec_entrypoint(void);
1206fba6e04STony Xie 
121f47a25ddSCaesar Wang void platform_cpu_warmboot(void);
122f47a25ddSCaesar Wang 
12368ff45f4SCaesar Wang void *plat_get_rockchip_gpio_reset(void);
12468ff45f4SCaesar Wang void *plat_get_rockchip_gpio_poweroff(void);
1259901dcf6SCaesar Wang void plat_rockchip_gpio_init(void);
1269901dcf6SCaesar Wang 
1276fba6e04STony Xie extern const unsigned char rockchip_power_domain_tree_desc[];
1286fba6e04STony Xie 
1296fba6e04STony Xie extern void *pmu_cpuson_entrypoint_start;
1306fba6e04STony Xie extern void *pmu_cpuson_entrypoint_end;
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[];
1356fba6e04STony Xie #endif /* __ASSEMBLY__ */
1366fba6e04STony Xie 
137*9ec78bdfSTony Xie /******************************************************************************
138*9ec78bdfSTony Xie  * cpu up status
139*9ec78bdfSTony Xie  * The bits of macro value is not more than 12 bits for cmp instruction!
140*9ec78bdfSTony Xie  ******************************************************************************/
141*9ec78bdfSTony Xie #define PMU_CPU_HOTPLUG		0xf00
142*9ec78bdfSTony Xie #define PMU_CPU_AUTO_PWRDN	0xf0
143*9ec78bdfSTony Xie #define PMU_CLST_RET	0xa5
1446fba6e04STony Xie 
1456fba6e04STony Xie #endif /* __PLAT_PRIVATE_H__ */
146