a7ba83e5ac512218b7c574eaf391e4181dc0d280
[project/bcm63xx/atf.git] / plat / rockchip / common / params_setup.c
1 /*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <assert.h>
8 #include <bl_common.h>
9 #include <console.h>
10 #include <coreboot.h>
11 #include <debug.h>
12 #include <gpio.h>
13 #include <mmio.h>
14 #include <plat_params.h>
15 #include <plat_private.h>
16 #include <platform.h>
17 #include <string.h>
18
19 static struct gpio_info param_reset;
20 static struct gpio_info param_poweroff;
21 static struct bl31_apio_param param_apio;
22 static struct gpio_info *rst_gpio;
23 static struct gpio_info *poweroff_gpio;
24 static struct gpio_info suspend_gpio[10];
25 uint32_t suspend_gpio_cnt;
26 static struct apio_info *suspend_apio;
27
28 struct gpio_info *plat_get_rockchip_gpio_reset(void)
29 {
30 return rst_gpio;
31 }
32
33 struct gpio_info *plat_get_rockchip_gpio_poweroff(void)
34 {
35 return poweroff_gpio;
36 }
37
38 struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count)
39 {
40 *count = suspend_gpio_cnt;
41
42 return &suspend_gpio[0];
43 }
44
45 struct apio_info *plat_get_rockchip_suspend_apio(void)
46 {
47 return suspend_apio;
48 }
49
50 void params_early_setup(void *plat_param_from_bl2)
51 {
52 struct bl31_plat_param *bl2_param;
53 struct bl31_gpio_param *gpio_param;
54
55 /* keep plat parameters for later processing if need */
56 bl2_param = (struct bl31_plat_param *)plat_param_from_bl2;
57 while (bl2_param) {
58 switch (bl2_param->type) {
59 case PARAM_RESET:
60 gpio_param = (struct bl31_gpio_param *)bl2_param;
61 memcpy(&param_reset, &gpio_param->gpio,
62 sizeof(struct gpio_info));
63 rst_gpio = &param_reset;
64 break;
65 case PARAM_POWEROFF:
66 gpio_param = (struct bl31_gpio_param *)bl2_param;
67 memcpy(&param_poweroff, &gpio_param->gpio,
68 sizeof(struct gpio_info));
69 poweroff_gpio = &param_poweroff;
70 break;
71 case PARAM_SUSPEND_GPIO:
72 if (suspend_gpio_cnt >= ARRAY_SIZE(suspend_gpio)) {
73 ERROR("exceed support suspend gpio number\n");
74 break;
75 }
76 gpio_param = (struct bl31_gpio_param *)bl2_param;
77 memcpy(&suspend_gpio[suspend_gpio_cnt],
78 &gpio_param->gpio,
79 sizeof(struct gpio_info));
80 suspend_gpio_cnt++;
81 break;
82 case PARAM_SUSPEND_APIO:
83 memcpy(&param_apio, bl2_param,
84 sizeof(struct bl31_apio_param));
85 suspend_apio = &param_apio.apio;
86 break;
87 #if COREBOOT
88 case PARAM_COREBOOT_TABLE:
89 coreboot_table_setup((void *)
90 ((struct bl31_u64_param *)bl2_param)->value);
91 break;
92 #endif
93 default:
94 ERROR("not expected type found %lld\n",
95 bl2_param->type);
96 break;
97 }
98 bl2_param = bl2_param->next;
99 }
100 }