xref: /rk3399_ARM-atf/plat/rockchip/common/include/plat_params.h (revision 09d40e0e08283a249e7dce0e106c07c5141f9b7e)
1 /*
2  * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef PLAT_PARAMS_H
8 #define PLAT_PARAMS_H
9 
10 #include <stdint.h>
11 
12 /*
13  * We defined several plat parameter structs for BL2 to pass platform related
14  * parameters to Rockchip BL31 platform code.  All plat parameters start with
15  * a common header, which has a type field to indicate the parameter type, and
16  * a next pointer points to next parameter. If the parameter is the last one in
17  * the list, next pointer will points to NULL.  After the header comes the
18  * variable-sized members that describe the parameter. The picture below shows
19  * how the parameters are kept in memory.
20  *
21  * head of list  ---> +----------------+ --+
22  *                    |      type      |   |
23  *                    +----------------+   |--> struct bl31_plat_param
24  *               +----|      next      |   |
25  *               |    +----------------+ --+
26  *               |    | parameter data |
27  *               |    +----------------+
28  *               |
29  *               +--> +----------------+ --+
30  *                    |      type      |   |
31  *                    +----------------+   |--> struct bl31_plat_param
32  *           NULL <---|      next      |   |
33  *                    +----------------+ --+
34  *                    | parameter data |
35  *                    +----------------+
36  *
37  * Note: The SCTLR_EL3.A bit (Alignment fault check enable) of ARM TF is set,
38  * so be sure each parameter struct starts on 64-bit aligned address. If not,
39  * alignment fault will occur during accessing its data member.
40  */
41 
42 #define BL31_GPIO_DIR_OUT		0
43 #define BL31_GPIO_DIR_IN		1
44 
45 #define BL31_GPIO_LEVEL_LOW		0
46 #define BL31_GPIO_LEVEL_HIGH		1
47 
48 #define BL31_GPIO_PULL_NONE		0
49 #define BL31_GPIO_PULL_UP		1
50 #define BL31_GPIO_PULL_DOWN		2
51 
52 /* param type */
53 enum {
54 	PARAM_NONE = 0,
55 	PARAM_RESET,
56 	PARAM_POWEROFF,
57 	PARAM_SUSPEND_GPIO,
58 	PARAM_SUSPEND_APIO,
59 	PARAM_COREBOOT_TABLE,
60 };
61 
62 struct apio_info {
63 	uint8_t apio1 : 1;
64 	uint8_t apio2 : 1;
65 	uint8_t apio3 : 1;
66 	uint8_t apio4 : 1;
67 	uint8_t apio5 : 1;
68 };
69 
70 struct gpio_info {
71 	uint8_t polarity;
72 	uint8_t direction;
73 	uint8_t pull_mode;
74 	uint32_t index;
75 };
76 
77 /* common header for all plat parameter type */
78 struct bl31_plat_param {
79 	uint64_t type;
80 	void *next;
81 };
82 
83 struct bl31_gpio_param {
84 	struct bl31_plat_param h;
85 	struct gpio_info gpio;
86 };
87 
88 struct bl31_apio_param {
89 	struct bl31_plat_param h;
90 	struct apio_info apio;
91 };
92 
93 struct bl31_u64_param {
94 	struct bl31_plat_param h;
95 	uint64_t value;
96 };
97 
98 #endif /* PLAT_PARAMS_H */
99