xref: /rk3399_ARM-atf/plat/mediatek/common/mtk_plat_common.h (revision cf906b2a2e017077d54bbe9111a099cd0cc59433)
1*cf906b2aSLeon Chen /*
2*cf906b2aSLeon Chen  * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3*cf906b2aSLeon Chen  *
4*cf906b2aSLeon Chen  * Redistribution and use in source and binary forms, with or without
5*cf906b2aSLeon Chen  * modification, are permitted provided that the following conditions are met:
6*cf906b2aSLeon Chen  *
7*cf906b2aSLeon Chen  * Redistributions of source code must retain the above copyright notice, this
8*cf906b2aSLeon Chen  * list of conditions and the following disclaimer.
9*cf906b2aSLeon Chen  *
10*cf906b2aSLeon Chen  * Redistributions in binary form must reproduce the above copyright notice,
11*cf906b2aSLeon Chen  * this list of conditions and the following disclaimer in the documentation
12*cf906b2aSLeon Chen  * and/or other materials provided with the distribution.
13*cf906b2aSLeon Chen  *
14*cf906b2aSLeon Chen  * Neither the name of ARM nor the names of its contributors may be used
15*cf906b2aSLeon Chen  * to endorse or promote products derived from this software without specific
16*cf906b2aSLeon Chen  * prior written permission.
17*cf906b2aSLeon Chen  *
18*cf906b2aSLeon Chen  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*cf906b2aSLeon Chen  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*cf906b2aSLeon Chen  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*cf906b2aSLeon Chen  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22*cf906b2aSLeon Chen  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*cf906b2aSLeon Chen  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*cf906b2aSLeon Chen  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*cf906b2aSLeon Chen  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*cf906b2aSLeon Chen  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*cf906b2aSLeon Chen  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*cf906b2aSLeon Chen  * POSSIBILITY OF SUCH DAMAGE.
29*cf906b2aSLeon Chen  */
30*cf906b2aSLeon Chen #ifndef __MTK_PLAT_COMMON_H__
31*cf906b2aSLeon Chen #define __MTK_PLAT_COMMON_H__
32*cf906b2aSLeon Chen #include <stdint.h>
33*cf906b2aSLeon Chen /*******************************************************************************
34*cf906b2aSLeon Chen  * Function and variable prototypes
35*cf906b2aSLeon Chen  ******************************************************************************/
36*cf906b2aSLeon Chen #define DEVINFO_SIZE 4
37*cf906b2aSLeon Chen #define LINUX_KERNEL_32 0
38*cf906b2aSLeon Chen #define SMC32_PARAM_MASK		(0xFFFFFFFF)
39*cf906b2aSLeon Chen 
40*cf906b2aSLeon Chen struct atf_arg_t {
41*cf906b2aSLeon Chen 	unsigned int atf_magic;
42*cf906b2aSLeon Chen 	unsigned int tee_support;
43*cf906b2aSLeon Chen 	unsigned int tee_entry;
44*cf906b2aSLeon Chen 	unsigned int tee_boot_arg_addr;
45*cf906b2aSLeon Chen 	unsigned int hwuid[4];     /* HW Unique id for t-base used */
46*cf906b2aSLeon Chen 	unsigned int HRID[2];      /* HW random id for t-base used */
47*cf906b2aSLeon Chen 	unsigned int atf_log_port;
48*cf906b2aSLeon Chen 	unsigned int atf_log_baudrate;
49*cf906b2aSLeon Chen 	unsigned int atf_log_buf_start;
50*cf906b2aSLeon Chen 	unsigned int atf_log_buf_size;
51*cf906b2aSLeon Chen 	unsigned int atf_irq_num;
52*cf906b2aSLeon Chen 	unsigned int devinfo[DEVINFO_SIZE];
53*cf906b2aSLeon Chen 	unsigned int atf_aee_debug_buf_start;
54*cf906b2aSLeon Chen 	unsigned int atf_aee_debug_buf_size;
55*cf906b2aSLeon Chen };
56*cf906b2aSLeon Chen 
57*cf906b2aSLeon Chen struct kernel_info {
58*cf906b2aSLeon Chen 	uint64_t pc;
59*cf906b2aSLeon Chen 	uint64_t r0;
60*cf906b2aSLeon Chen 	uint64_t r1;
61*cf906b2aSLeon Chen 	uint64_t r2;
62*cf906b2aSLeon Chen 	uint64_t k32_64;
63*cf906b2aSLeon Chen };
64*cf906b2aSLeon Chen 
65*cf906b2aSLeon Chen struct mtk_bl_param_t {
66*cf906b2aSLeon Chen 	uint64_t bootarg_loc;
67*cf906b2aSLeon Chen 	uint64_t bootarg_size;
68*cf906b2aSLeon Chen 	uint64_t bl33_start_addr;
69*cf906b2aSLeon Chen 	uint64_t tee_info_addr;
70*cf906b2aSLeon Chen };
71*cf906b2aSLeon Chen 
72*cf906b2aSLeon Chen /* Declarations for mtk_plat_common.c */
73*cf906b2aSLeon Chen uint32_t plat_get_spsr_for_bl32_entry(void);
74*cf906b2aSLeon Chen uint32_t plat_get_spsr_for_bl33_entry(void);
75*cf906b2aSLeon Chen void clean_top_32b_of_param(uint32_t smc_fid, uint64_t *x1,
76*cf906b2aSLeon Chen 				uint64_t *x2,
77*cf906b2aSLeon Chen 				uint64_t *x3,
78*cf906b2aSLeon Chen 				uint64_t *x4);
79*cf906b2aSLeon Chen void bl31_prepare_kernel_entry(uint64_t k32_64);
80*cf906b2aSLeon Chen void enable_ns_access_to_cpuectlr(void);
81*cf906b2aSLeon Chen void boot_to_kernel(uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4);
82*cf906b2aSLeon Chen uint64_t get_kernel_info_pc(void);
83*cf906b2aSLeon Chen uint64_t get_kernel_info_r0(void);
84*cf906b2aSLeon Chen uint64_t get_kernel_info_r1(void);
85*cf906b2aSLeon Chen uint64_t get_kernel_info_r2(void);
86*cf906b2aSLeon Chen 
87*cf906b2aSLeon Chen extern struct atf_arg_t gteearg;
88*cf906b2aSLeon Chen #endif
89