1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright 2020 NXP
*
*/
#include <common.h>
#include <hang.h>
#include <malloc.h>
#include <asm/io.h>
#include <dm.h>
#include <asm/arch/s400_api.h>
#include <misc.h>
DECLARE_GLOBAL_DATA_PTR;
int ahab_release_rdc(u8 core_id, u32 *response)
{
struct udevice *dev = gd->arch.s400_dev;
int size = sizeof(struct imx8ulp_s400_msg);
struct imx8ulp_s400_msg msg;
int ret;
if (!dev) {
printf("s400 dev is not initialized\n");
return -ENODEV;
}
msg.version = AHAB_VERSION;
msg.tag = AHAB_CMD_TAG;
msg.size = 2;
msg.command = AHAB_RELEASE_RDC_REQ_CID;
msg.data[0] = core_id;
ret = misc_call(dev, false, &msg, size, &msg, size);
if (ret)
printf("Error: %s: ret %d, core id %u, response 0x%x\n",
__func__, ret, core_id, msg.data[0]);
if (response)
*response = msg.data[0];
return ret;
}
int ahab_auth_oem_ctnr(ulong ctnr_addr, u32 *response)
{
struct udevice *dev = gd->arch.s400_dev;
int size = sizeof(struct imx8ulp_s400_msg);
struct imx8ulp_s400_msg msg;
int ret;
if (!dev) {
printf("s400 dev is not initialized\n");
return -ENODEV;
}
msg.version = AHAB_VERSION;
msg.tag = AHAB_CMD_TAG;
msg.size = 3;
msg.command = AHAB_AUTH_OEM_CTNR_CID;
msg.data[0] = upper_32_bits(ctnr_addr);
msg.data[1] = lower_32_bits(ctnr_addr);
ret = misc_call(dev, false, &msg, size, &msg, size);
if (ret)
printf("Error: %s: ret %d, cntr_addr 0x%lx, response 0x%x\n",
__func__, ret, ctnr_addr, msg.data[0]);
if (response)
*response = msg.data[0];
return ret;
}
int ahab_release_container(u32 *response)
{
struct udevice *dev = gd->arch.s400_dev;
int size = sizeof(struct imx8ulp_s400_msg);
struct imx8ulp_s400_msg msg;
int ret;
if (!dev) {
printf("s400 dev is not initialized\n");
return -ENODEV;
}
msg.version = AHAB_VERSION;
msg.tag = AHAB_CMD_TAG;
msg.size = 1;
msg.command = AHAB_RELEASE_CTNR_CID;
ret = misc_call(dev, false, &msg, size, &msg, size);
if (ret)
printf("Error: %s: ret %d, response 0x%x\n",
__func__, ret, msg.data[0]);
if (response)
*response = msg.data[0];
return ret;
}
int ahab_verify_image(u32 img_id, u32 *response)
{
struct udevice *dev = gd->arch.s400_dev;
int size = sizeof(struct imx8ulp_s400_msg);
struct imx8ulp_s400_msg msg;
int ret;
if (!dev) {
printf("s400 dev is not initialized\n");
return -ENODEV;
}
msg.version = AHAB_VERSION;
msg.tag = AHAB_CMD_TAG;
msg.size = 2;
msg.command = AHAB_VERIFY_IMG_CID;
msg.data[0] = 1 << img_id;
ret = misc_call(dev, false, &msg, size, &msg, size);
if (ret)
printf("Error: %s: ret %d, img_id %u, response 0x%x\n",
__func__, ret, img_id, msg.data[0]);
if (response)
*response = msg.data[0];
return ret;
}
int ahab_forward_lifecycle(u16 life_cycle, u32 *response)
{
struct udevice *dev = gd->arch.s400_dev;
int size = sizeof(struct imx8ulp_s400_msg);
struct imx8ulp_s400_msg msg;
int ret;
if (!dev) {
printf("s400 dev is not initialized\n");
return -ENODEV;
}
msg.version = AHAB_VERSION;
msg.tag = AHAB_CMD_TAG;
msg.size = 2;
msg.command = AHAB_FWD_LIFECYCLE_UP_REQ_CID;
msg.data[0] = life_cycle;
ret = misc_call(dev, false, &msg, size, &msg, size);
if (ret)
printf("Error: %s: ret %d, life_cycle 0x%x, response 0x%x\n",
__func__, ret, life_cycle, msg.data[0]);
if (response)
*response = msg.data[0];
return ret;
}
|