blob: 3dac01328c956a60d48e21361d41f23db8ab5489 [file] [log] [blame]
Caesar Wang3e3c5b02016-05-25 19:03:04 +08001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Caesar Wang3e3c5b02016-05-25 19:03:04 +08005 */
6
7#include <arm_gic.h>
8#include <assert.h>
9#include <bl_common.h>
10#include <console.h>
Julius Wernerc7087782017-06-09 15:22:44 -070011#include <coreboot.h>
Caesar Wang3e3c5b02016-05-25 19:03:04 +080012#include <debug.h>
13#include <gpio.h>
14#include <mmio.h>
Caesar Wang3e3c5b02016-05-25 19:03:04 +080015#include <plat_params.h>
16#include <plat_private.h>
Isla Mitchelle3631462017-07-14 10:46:32 +010017#include <platform.h>
Caesar Wang3e3c5b02016-05-25 19:03:04 +080018#include <string.h>
19
Caesar Wangef180072016-09-10 02:43:15 +080020static struct gpio_info param_reset;
21static struct gpio_info param_poweroff;
Caesar Wang5045a1c2016-09-10 02:47:53 +080022static struct bl31_apio_param param_apio;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080023static struct gpio_info *rst_gpio;
24static struct gpio_info *poweroff_gpio;
Caesar Wangef180072016-09-10 02:43:15 +080025static struct gpio_info suspend_gpio[10];
26uint32_t suspend_gpio_cnt;
Caesar Wang5045a1c2016-09-10 02:47:53 +080027static struct apio_info *suspend_apio;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080028
Caesar Wangef180072016-09-10 02:43:15 +080029struct gpio_info *plat_get_rockchip_gpio_reset(void)
Caesar Wang3e3c5b02016-05-25 19:03:04 +080030{
31 return rst_gpio;
32}
33
Caesar Wangef180072016-09-10 02:43:15 +080034struct gpio_info *plat_get_rockchip_gpio_poweroff(void)
Caesar Wang3e3c5b02016-05-25 19:03:04 +080035{
36 return poweroff_gpio;
37}
38
Caesar Wangef180072016-09-10 02:43:15 +080039struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count)
40{
41 *count = suspend_gpio_cnt;
42
43 return &suspend_gpio[0];
44}
45
Caesar Wang5045a1c2016-09-10 02:47:53 +080046struct apio_info *plat_get_rockchip_suspend_apio(void)
47{
48 return suspend_apio;
49}
50
Caesar Wang3e3c5b02016-05-25 19:03:04 +080051void params_early_setup(void *plat_param_from_bl2)
52{
Caesar Wang3e3c5b02016-05-25 19:03:04 +080053 struct bl31_plat_param *bl2_param;
54 struct bl31_gpio_param *gpio_param;
55
56 /* keep plat parameters for later processing if need */
57 bl2_param = (struct bl31_plat_param *)plat_param_from_bl2;
58 while (bl2_param) {
59 switch (bl2_param->type) {
60 case PARAM_RESET:
Caesar Wangef180072016-09-10 02:43:15 +080061 gpio_param = (struct bl31_gpio_param *)bl2_param;
62 memcpy(&param_reset, &gpio_param->gpio,
63 sizeof(struct gpio_info));
64 rst_gpio = &param_reset;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080065 break;
66 case PARAM_POWEROFF:
Caesar Wangef180072016-09-10 02:43:15 +080067 gpio_param = (struct bl31_gpio_param *)bl2_param;
68 memcpy(&param_poweroff, &gpio_param->gpio,
69 sizeof(struct gpio_info));
70 poweroff_gpio = &param_poweroff;
71 break;
72 case PARAM_SUSPEND_GPIO:
73 if (suspend_gpio_cnt >= ARRAY_SIZE(suspend_gpio)) {
74 ERROR("exceed support suspend gpio number\n");
75 break;
76 }
77 gpio_param = (struct bl31_gpio_param *)bl2_param;
78 memcpy(&suspend_gpio[suspend_gpio_cnt],
79 &gpio_param->gpio,
80 sizeof(struct gpio_info));
81 suspend_gpio_cnt++;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080082 break;
Caesar Wang5045a1c2016-09-10 02:47:53 +080083 case PARAM_SUSPEND_APIO:
84 memcpy(&param_apio, bl2_param,
85 sizeof(struct bl31_apio_param));
86 suspend_apio = &param_apio.apio;
87 break;
Julius Wernerc7087782017-06-09 15:22:44 -070088#if COREBOOT
89 case PARAM_COREBOOT_TABLE:
90 coreboot_table_setup((void *)
91 ((struct bl31_u64_param *)bl2_param)->value);
92 break;
93#endif
Caesar Wang3e3c5b02016-05-25 19:03:04 +080094 default:
Masahiro Yamadae93a0f42018-02-02 15:09:36 +090095 ERROR("not expected type found %lld\n",
Caesar Wangef180072016-09-10 02:43:15 +080096 bl2_param->type);
97 break;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080098 }
Caesar Wang3e3c5b02016-05-25 19:03:04 +080099 bl2_param = bl2_param->next;
100 }
101}