1 /*
2  * Copyright (c) 2014-2015, Linaro Ltd and Contributors. All rights reserved.
3  * Copyright (c) 2014-2015, Hisilicon Ltd and Contributors. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * Neither the name of ARM nor the names of its contributors may be used
16  * to endorse or promote products derived from this software without specific
17  * prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef __HIKEY_PRIVATE_H__
33 #define __HIKEY_PRIVATE_H__
34 
35 #include <bl_common.h>
36 
37 /*******************************************************************************
38  * This structure represents the superset of information that is passed to
39  * BL3-1 e.g. while passing control to it from BL2 which is bl31_params
40  * and other platform specific params
41  ******************************************************************************/
42 typedef struct bl2_to_bl31_params_mem {
43 	struct bl31_params bl31_params;
44 	struct image_info bl31_image_info;
45 	struct image_info bl32_image_info;
46 	struct image_info bl33_image_info;
47 	struct entry_point_info bl33_ep_info;
48 	struct entry_point_info bl32_ep_info;
49 	struct entry_point_info bl31_ep_info;
50 } bl2_to_bl31_params_mem_t;
51 
52 #define RANDOM_MAX		0x7fffffffffffffff
53 #define RANDOM_MAGIC		0x9a4dbeaf
54 
55 struct random_serial_num {
56 	uint64_t	magic;
57 	uint64_t	data;
58 	char		serialno[32];
59 };
60 
61 /*******************************************************************************
62  * Function and variable prototypes
63  ******************************************************************************/
64 void configure_mmu_el1(unsigned long total_base,
65 		       unsigned long total_size,
66 		       unsigned long ro_start,
67 		       unsigned long ro_limit,
68 		       unsigned long coh_start,
69 		       unsigned long coh_limit);
70 void configure_mmu_el3(unsigned long total_base,
71 		       unsigned long total_size,
72 		       unsigned long ro_start,
73 		       unsigned long ro_limit,
74 		       unsigned long coh_start,
75 		       unsigned long coh_limit);
76 extern int flush_loader_image(void);
77 extern int flush_user_images(char *cmdbuf, unsigned long addr,
78 			     unsigned long length);
79 extern int flush_random_serialno(unsigned long addr, unsigned long length);
80 extern void generate_serialno(struct random_serial_num *random);
81 extern int assign_serialno(char *cmdbuf, struct random_serial_num *random);
82 extern char *load_serialno(void);
83 extern void hi6220_pll_init(void);
84 extern void io_setup(void);
85 extern int plat_get_image_source(const char *image_name,
86 				 uintptr_t *dev_handle,
87 				 uintptr_t *image_spec);
88 extern void plat_gic_init(void);
89 extern void usb_download(void);
90 
91 void plat_security_setup(void);
92 
93 #endif /* __HIKEY_PRIVATE_H__ */
94