params_setup.c 2.28 KB
Newer Older
1
2
3
/*
 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
7
8
9
10
11
12
13
14
15
 */

#include <arm_gic.h>
#include <assert.h>
#include <bl_common.h>
#include <console.h>
#include <debug.h>
#include <gpio.h>
#include <mmio.h>
#include <plat_params.h>
#include <plat_private.h>
16
#include <platform.h>
17
18
#include <string.h>

19
20
static struct gpio_info param_reset;
static struct gpio_info param_poweroff;
21
static struct bl31_apio_param param_apio;
22
23
static struct gpio_info *rst_gpio;
static struct gpio_info *poweroff_gpio;
24
25
static struct gpio_info suspend_gpio[10];
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
31
32
{
	return rst_gpio;
}

33
struct gpio_info *plat_get_rockchip_gpio_poweroff(void)
34
35
36
37
{
	return poweroff_gpio;
}

38
39
40
41
42
43
44
struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count)
{
	*count = suspend_gpio_cnt;

	return &suspend_gpio[0];
}

45
46
47
48
49
struct apio_info *plat_get_rockchip_suspend_apio(void)
{
	return suspend_apio;
}

50
51
52
53
54
55
56
57
58
59
void params_early_setup(void *plat_param_from_bl2)
{
	struct bl31_plat_param *bl2_param;
	struct bl31_gpio_param *gpio_param;

	/* keep plat parameters for later processing if need */
	bl2_param = (struct bl31_plat_param *)plat_param_from_bl2;
	while (bl2_param) {
		switch (bl2_param->type) {
		case PARAM_RESET:
60
61
62
63
			gpio_param = (struct bl31_gpio_param *)bl2_param;
			memcpy(&param_reset, &gpio_param->gpio,
			       sizeof(struct gpio_info));
			rst_gpio = &param_reset;
64
65
			break;
		case PARAM_POWEROFF:
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
			gpio_param = (struct bl31_gpio_param *)bl2_param;
			memcpy(&param_poweroff, &gpio_param->gpio,
				sizeof(struct gpio_info));
			poweroff_gpio = &param_poweroff;
			break;
		case PARAM_SUSPEND_GPIO:
			if (suspend_gpio_cnt >= ARRAY_SIZE(suspend_gpio)) {
				ERROR("exceed support suspend gpio number\n");
				break;
			}
			gpio_param = (struct bl31_gpio_param *)bl2_param;
			memcpy(&suspend_gpio[suspend_gpio_cnt],
			       &gpio_param->gpio,
			       sizeof(struct gpio_info));
			suspend_gpio_cnt++;
81
			break;
82
83
84
85
86
		case PARAM_SUSPEND_APIO:
			memcpy(&param_apio, bl2_param,
			       sizeof(struct bl31_apio_param));
			suspend_apio = &param_apio.apio;
			break;
87
		default:
88
89
90
			ERROR("not expected type found %ld\n",
			      bl2_param->type);
			break;
91
92
93
94
		}
		bl2_param = bl2_param->next;
	}
}