blob: 71998998d0a9dad342de5e85cb5b75edec7a4b94 [file] [log] [blame]
Tony Xief6118cc2016-01-15 17:17:32 +08001/*
2 * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef __PLAT_PRIVATE_H__
32#define __PLAT_PRIVATE_H__
33
34#ifndef __ASSEMBLY__
35#include <mmio.h>
36#include <stdint.h>
37#include <xlat_tables.h>
Tony Xie42e113e2016-07-16 11:16:51 +080038#include <psci.h>
Tony Xief6118cc2016-01-15 17:17:32 +080039
40/******************************************************************************
41 * For rockchip socs pm ops
42 ******************************************************************************/
43struct rockchip_pm_ops_cb {
44 int (*cores_pwr_dm_on)(unsigned long mpidr, uint64_t entrypoint);
45 int (*cores_pwr_dm_off)(void);
46 int (*cores_pwr_dm_on_finish)(void);
47 int (*cores_pwr_dm_suspend)(void);
48 int (*cores_pwr_dm_resume)(void);
Tony Xie42e113e2016-07-16 11:16:51 +080049 /* hlvl is used for clusters or system level */
50 int (*hlvl_pwr_dm_suspend)(uint32_t lvl, plat_local_state_t lvl_state);
51 int (*hlvl_pwr_dm_resume)(uint32_t lvl, plat_local_state_t lvl_state);
52 int (*hlvl_pwr_dm_off)(uint32_t lvl, plat_local_state_t lvl_state);
53 int (*hlvl_pwr_dm_on_finish)(uint32_t lvl,
54 plat_local_state_t lvl_state);
Tony Xief6118cc2016-01-15 17:17:32 +080055 int (*sys_pwr_dm_suspend)(void);
56 int (*sys_pwr_dm_resume)(void);
57 void (*sys_gbl_soft_reset)(void) __dead2;
58 void (*system_off)(void) __dead2;
59};
60
61/******************************************************************************
62 * The register have write-mask bits, it is mean, if you want to set the bits,
63 * you needs set the write-mask bits at the same time,
64 * The write-mask bits is in high 16-bits.
65 * The fllowing macro definition helps access write-mask bits reg efficient!
66 ******************************************************************************/
67#define REG_MSK_SHIFT 16
68
69#ifndef BIT
70#define BIT(nr) (1 << (nr))
71#endif
72
73#ifndef WMSK_BIT
74#define WMSK_BIT(nr) BIT((nr) + REG_MSK_SHIFT)
75#endif
76
77/* set one bit with write mask */
78#ifndef BIT_WITH_WMSK
79#define BIT_WITH_WMSK(nr) (BIT(nr) | WMSK_BIT(nr))
80#endif
81
82#ifndef BITS_SHIFT
83#define BITS_SHIFT(bits, shift) (bits << (shift))
84#endif
85
86#ifndef BITS_WITH_WMASK
Caesar Wang59e41b52016-04-10 14:11:07 +080087#define BITS_WITH_WMASK(bits, msk, shift)\
Tony Xief6118cc2016-01-15 17:17:32 +080088 (BITS_SHIFT(bits, shift) | BITS_SHIFT(msk, (shift + REG_MSK_SHIFT)))
89#endif
90
91/******************************************************************************
92 * Function and variable prototypes
93 *****************************************************************************/
94void plat_configure_mmu_el3(unsigned long total_base,
95 unsigned long total_size,
96 unsigned long,
97 unsigned long,
98 unsigned long,
99 unsigned long);
100
101void plat_cci_init(void);
102void plat_cci_enable(void);
103void plat_cci_disable(void);
104
105void plat_delay_timer_init(void);
106
Caesar Wang3e3c5b02016-05-25 19:03:04 +0800107void params_early_setup(void *plat_params_from_bl2);
108
Tony Xief6118cc2016-01-15 17:17:32 +0800109void plat_rockchip_gic_driver_init(void);
110void plat_rockchip_gic_init(void);
111void plat_rockchip_gic_cpuif_enable(void);
112void plat_rockchip_gic_cpuif_disable(void);
113void plat_rockchip_gic_pcpu_init(void);
114
115void plat_rockchip_pmusram_prepare(void);
116void plat_rockchip_pmu_init(void);
117void plat_rockchip_soc_init(void);
118void plat_setup_rockchip_pm_ops(struct rockchip_pm_ops_cb *ops);
Tony Xie42e113e2016-07-16 11:16:51 +0800119uintptr_t plat_get_sec_entrypoint(void);
Tony Xief6118cc2016-01-15 17:17:32 +0800120
Caesar Wang59e41b52016-04-10 14:11:07 +0800121void platform_cpu_warmboot(void);
122
Caesar Wang3e3c5b02016-05-25 19:03:04 +0800123void *plat_get_rockchip_gpio_reset(void);
124void *plat_get_rockchip_gpio_poweroff(void);
Caesar Wang038f6aa2016-05-25 19:21:43 +0800125void plat_rockchip_gpio_init(void);
126
Tony Xief6118cc2016-01-15 17:17:32 +0800127extern const unsigned char rockchip_power_domain_tree_desc[];
128
129extern void *pmu_cpuson_entrypoint_start;
130extern void *pmu_cpuson_entrypoint_end;
131extern uint64_t cpuson_entry_point[PLATFORM_CORE_COUNT];
132extern uint32_t cpuson_flags[PLATFORM_CORE_COUNT];
133
134extern const mmap_region_t plat_rk_mmap[];
135#endif /* __ASSEMBLY__ */
136
Tony Xie42e113e2016-07-16 11:16:51 +0800137/******************************************************************************
138 * cpu up status
139 * The bits of macro value is not more than 12 bits for cmp instruction!
140 ******************************************************************************/
141#define PMU_CPU_HOTPLUG 0xf00
142#define PMU_CPU_AUTO_PWRDN 0xf0
143#define PMU_CLST_RET 0xa5
Tony Xief6118cc2016-01-15 17:17:32 +0800144
145#endif /* __PLAT_PRIVATE_H__ */