blob: ad4ef7f31ab75ec3a9336e0b1d23e8c949b2306a [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>
11#include <debug.h>
12#include <gpio.h>
13#include <mmio.h>
14#include <platform.h>
15#include <plat_params.h>
16#include <plat_private.h>
17#include <string.h>
18
Caesar Wangef180072016-09-10 02:43:15 +080019static struct gpio_info param_reset;
20static struct gpio_info param_poweroff;
Caesar Wang5045a1c2016-09-10 02:47:53 +080021static struct bl31_apio_param param_apio;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080022static struct gpio_info *rst_gpio;
23static struct gpio_info *poweroff_gpio;
Caesar Wangef180072016-09-10 02:43:15 +080024static struct gpio_info suspend_gpio[10];
25uint32_t suspend_gpio_cnt;
Caesar Wang5045a1c2016-09-10 02:47:53 +080026static struct apio_info *suspend_apio;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080027
Caesar Wangef180072016-09-10 02:43:15 +080028struct gpio_info *plat_get_rockchip_gpio_reset(void)
Caesar Wang3e3c5b02016-05-25 19:03:04 +080029{
30 return rst_gpio;
31}
32
Caesar Wangef180072016-09-10 02:43:15 +080033struct gpio_info *plat_get_rockchip_gpio_poweroff(void)
Caesar Wang3e3c5b02016-05-25 19:03:04 +080034{
35 return poweroff_gpio;
36}
37
Caesar Wangef180072016-09-10 02:43:15 +080038struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count)
39{
40 *count = suspend_gpio_cnt;
41
42 return &suspend_gpio[0];
43}
44
Caesar Wang5045a1c2016-09-10 02:47:53 +080045struct apio_info *plat_get_rockchip_suspend_apio(void)
46{
47 return suspend_apio;
48}
49
Caesar Wang3e3c5b02016-05-25 19:03:04 +080050void params_early_setup(void *plat_param_from_bl2)
51{
Caesar Wang3e3c5b02016-05-25 19:03:04 +080052 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:
Caesar Wangef180072016-09-10 02:43:15 +080060 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;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080064 break;
65 case PARAM_POWEROFF:
Caesar Wangef180072016-09-10 02:43:15 +080066 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++;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080081 break;
Caesar Wang5045a1c2016-09-10 02:47:53 +080082 case PARAM_SUSPEND_APIO:
83 memcpy(&param_apio, bl2_param,
84 sizeof(struct bl31_apio_param));
85 suspend_apio = &param_apio.apio;
86 break;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080087 default:
Caesar Wangef180072016-09-10 02:43:15 +080088 ERROR("not expected type found %ld\n",
89 bl2_param->type);
90 break;
Caesar Wang3e3c5b02016-05-25 19:03:04 +080091 }
Caesar Wang3e3c5b02016-05-25 19:03:04 +080092 bl2_param = bl2_param->next;
93 }
94}