params_setup.c 2.48 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
 */

#include <assert.h>
8
9
10
11
12
13
14
15
16
17
#include <string.h>

#include <common/bl_common.h>
#include <common/debug.h>
#include <drivers/console.h>
#include <drivers/gpio.h>
#include <lib/coreboot.h>
#include <lib/mmio.h>
#include <plat/common/platform.h>

18
19
20
#include <plat_params.h>
#include <plat_private.h>

21
22
static struct gpio_info param_reset;
static struct gpio_info param_poweroff;
23
static struct bl31_apio_param param_apio;
24
25
static struct gpio_info *rst_gpio;
static struct gpio_info *poweroff_gpio;
26
27
static struct gpio_info suspend_gpio[10];
uint32_t suspend_gpio_cnt;
28
static struct apio_info *suspend_apio;
29

30
struct gpio_info *plat_get_rockchip_gpio_reset(void)
31
32
33
34
{
	return rst_gpio;
}

35
struct gpio_info *plat_get_rockchip_gpio_poweroff(void)
36
37
38
39
{
	return poweroff_gpio;
}

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

	return &suspend_gpio[0];
}

47
48
49
50
51
struct apio_info *plat_get_rockchip_suspend_apio(void)
{
	return suspend_apio;
}

52
53
54
55
56
57
58
59
60
61
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:
62
63
64
65
			gpio_param = (struct bl31_gpio_param *)bl2_param;
			memcpy(&param_reset, &gpio_param->gpio,
			       sizeof(struct gpio_info));
			rst_gpio = &param_reset;
66
67
			break;
		case PARAM_POWEROFF:
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
			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++;
83
			break;
84
85
86
87
88
		case PARAM_SUSPEND_APIO:
			memcpy(&param_apio, bl2_param,
			       sizeof(struct bl31_apio_param));
			suspend_apio = &param_apio.apio;
			break;
89
90
91
92
93
94
#if COREBOOT
		case PARAM_COREBOOT_TABLE:
			coreboot_table_setup((void *)
				((struct bl31_u64_param *)bl2_param)->value);
			break;
#endif
95
		default:
96
			ERROR("not expected type found %lld\n",
97
98
			      bl2_param->type);
			break;
99
100
101
102
		}
		bl2_param = bl2_param->next;
	}
}