sgi_bl31_setup.c 2.65 KB
Newer Older
1
2
3
4
5
6
/*
 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

7
#include <assert.h>
8
9
#include <bl_common.h>
#include <debug.h>
10
#include <libfdt.h>
11
#include <plat_arm.h>
12
#include <sgi_ras.h>
13
#include <sgi_variant.h>
14
15
16
#include "../../css/drivers/scmi/scmi.h"
#include "../../css/drivers/mhu/css_mhu_doorbell.h"

17
18
sgi_platform_info_t sgi_plat_info;

19
20
21
22
23
24
25
26
static scmi_channel_plat_info_t sgi575_scmi_plat_info = {
		.scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
		.db_reg_addr = PLAT_CSS_MHU_BASE + CSS_SCMI_MHU_DB_REG_OFF,
		.db_preserve_mask = 0xfffffffe,
		.db_modify_mask = 0x1,
		.ring_doorbell = &mhu_ring_doorbell,
};

27
28
29
30
31
32
33
34
static scmi_channel_plat_info_t sgi_clark_scmi_plat_info = {
		.scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
		.db_reg_addr = PLAT_CSS_MHU_BASE + SENDER_REG_SET(0),
		.db_preserve_mask = 0xfffffffe,
		.db_modify_mask = 0x1,
		.ring_doorbell = &mhuv2_ring_doorbell,
};

35
36
scmi_channel_plat_info_t *plat_css_get_scmi_info()
{
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
	if (sgi_plat_info.platform_id == SGI_CLARK_SID_VER_PART_NUM)
		return &sgi_clark_scmi_plat_info;
	else if (sgi_plat_info.platform_id == SGI575_SSC_VER_PART_NUM)
		return &sgi575_scmi_plat_info;
	else
		panic();
};

/*******************************************************************************
 * This function sets the sgi_platform_id and sgi_config_id
 ******************************************************************************/
int sgi_identify_platform(unsigned long hw_config)
{
	void *fdt;
	int nodeoffset;
	const unsigned int *property;

	fdt = (void *)hw_config;

	/* Check the validity of the fdt */
	assert(fdt_check_header(fdt) == 0);

	nodeoffset = fdt_subnode_offset(fdt, 0, "system-id");
	if (nodeoffset < 0) {
		ERROR("Failed to get system-id node offset\n");
		return -1;
	}

	property = fdt_getprop(fdt, nodeoffset, "platform-id", NULL);
	if (property == NULL) {
		ERROR("Failed to get platform-id property\n");
		return -1;
	}

	sgi_plat_info.platform_id = fdt32_to_cpu(*property);

	property = fdt_getprop(fdt, nodeoffset, "config-id", NULL);
	if (property == NULL) {
		ERROR("Failed to get config-id property\n");
		return -1;
	}

	sgi_plat_info.config_id = fdt32_to_cpu(*property);

	return 0;
82
}
83
84
85
86

void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
				u_register_t arg2, u_register_t arg3)
{
87
88
89
90
91
92
	int ret;

	ret = sgi_identify_platform(arg2);
	if (ret == -1)
		panic();

93
94
	arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3);
}
95
96
97
98
99
100
101
102
103

void bl31_platform_setup(void)
{
	arm_bl31_platform_setup();

#if RAS_EXTENSION
	sgi_ras_intr_handler_setup();
#endif
}
104
105
106
107
108

const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops)
{
	return css_scmi_override_pm_ops(ops);
}