1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2017-2018, Intel Corporation
9 #include <linux/arm-smccc.h>
10 #include <linux/bitops.h>
13 * This file defines the Secure Monitor Call (SMC) message protocol used for
14 * service layer driver in normal world (EL1) to communicate with secure
15 * monitor software in Secure Monitor Exception Level 3 (EL3).
17 * This file is shared with secure firmware (FW) which is out of u-boot tree.
19 * An ARM SMC instruction takes a function identifier and up to 6 64-bit
20 * register values as arguments, and can return up to 4 64-bit register
21 * values. The operation of the secure monitor is determined by the parameter
22 * values passed in through registers.
24 * EL1 and EL3 communicates pointer as physical address rather than the
29 * Functions specified by ARM SMC Calling convention:
31 * FAST call executes atomic operations, returns when the requested operation
33 * STD call starts a operation which can be preempted by a non-secure
34 * interrupt. The call can return before the requested operation has
37 * a0..a7 is used as register names in the descriptions below, on arm32
38 * that translates to r0..r7 and on arm64 to w0..w7.
41 #define INTEL_SIP_SMC_STD_CALL_VAL(func_num) \
42 ARM_SMCCC_CALL_VAL(ARM_SMCCC_STD_CALL, ARM_SMCCC_SMC_64, \
43 ARM_SMCCC_OWNER_SIP, (func_num))
45 #define INTEL_SIP_SMC_FAST_CALL_VAL(func_num) \
46 ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_64, \
47 ARM_SMCCC_OWNER_SIP, (func_num))
50 * Return values in INTEL_SIP_SMC_* call
52 * INTEL_SIP_SMC_RETURN_UNKNOWN_FUNCTION:
53 * Secure monitor software doesn't recognize the request.
55 * INTEL_SIP_SMC_STATUS_OK:
56 * SMC call completed successfully,
57 * In case of FPGA configuration write operation, it means secure monitor
58 * software can accept the next chunk of FPGA configuration data.
60 * INTEL_SIP_SMC_STATUS_BUSY:
61 * In case of FPGA configuration write operation, it means secure monitor
62 * software is still processing previous data & can't accept the next chunk
63 * of data. Service driver needs to issue
64 * INTEL_SIP_SMC_FPGA_CONFIG_COMPLETED_WRITE call to query the
67 * INTEL_SIP_SMC_STATUS_ERROR:
68 * There is error during the SMC call process.
70 * INTEL_SIP_SMC_REG_ERROR:
71 * There is error during a read or write operation of the protected
74 #define INTEL_SIP_SMC_RETURN_UNKNOWN_FUNCTION 0xFFFFFFFF
75 #define INTEL_SIP_SMC_STATUS_OK 0x0
76 #define INTEL_SIP_SMC_STATUS_BUSY 0x1
77 #define INTEL_SIP_SMC_STATUS_REJECTED 0x2
78 #define INTEL_SIP_SMC_STATUS_ERROR 0x4
79 #define INTEL_SIP_SMC_REG_ERROR 0x5
80 #define INTEL_SIP_SMC_RSU_ERROR 0x7
83 * Request INTEL_SIP_SMC_FPGA_CONFIG_START
85 * Sync call used by service driver at EL1 to request the FPGA in EL3 to
86 * be prepare to receive a new configuration.
88 * Call register usage:
89 * a0: INTEL_SIP_SMC_FPGA_CONFIG_START.
90 * a1: flag for full or partial configuration
91 * 0 full reconfiguration.
92 * 1 partial reconfiguration.
96 * a0: INTEL_SIP_SMC_STATUS_OK, or INTEL_SIP_SMC_STATUS_ERROR.
99 #define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_START 1
100 #define INTEL_SIP_SMC_FPGA_CONFIG_START \
101 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_START)
104 * Request INTEL_SIP_SMC_FPGA_CONFIG_WRITE
106 * Async call used by service driver at EL1 to provide FPGA configuration data
109 * Call register usage:
110 * a0: INTEL_SIP_SMC_FPGA_CONFIG_WRITE.
111 * a1: 64bit physical address of the configuration data memory block
112 * a2: Size of configuration data block.
116 * a0: INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_BUSY,
117 * INTEL_SIP_SMC_STATUS_REJECTED or INTEL_SIP_SMC_STATUS_ERROR.
118 * a1: 64bit physical address of 1st completed memory block if any completed
119 * block, otherwise zero value.
120 * a2: 64bit physical address of 2nd completed memory block if any completed
121 * block, otherwise zero value.
122 * a3: 64bit physical address of 3rd completed memory block if any completed
123 * block, otherwise zero value.
125 #define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_WRITE 2
126 #define INTEL_SIP_SMC_FPGA_CONFIG_WRITE \
127 INTEL_SIP_SMC_STD_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_WRITE)
130 * Request INTEL_SIP_SMC_FPGA_CONFIG_COMPLETED_WRITE
132 * Sync call used by service driver at EL1 to track the completed write
133 * transactions. This request is called after INTEL_SIP_SMC_FPGA_CONFIG_WRITE
134 * call returns INTEL_SIP_SMC_STATUS_BUSY.
136 * Call register usage:
137 * a0: INTEL_SIP_SMC_FPGA_CONFIG_COMPLETED_WRITE.
141 * a0: INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_BUSY or
142 * INTEL_SIP_SMC_STATUS_ERROR.
143 * a1: 64bit physical address of 1st completed memory block.
144 * a2: 64bit physical address of 2nd completed memory block if
145 * any completed block, otherwise zero value.
146 * a3: 64bit physical address of 3rd completed memory block if
147 * any completed block, otherwise zero value.
149 #define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE 3
150 #define INTEL_SIP_SMC_FPGA_CONFIG_COMPLETED_WRITE \
151 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE)
154 * Request INTEL_SIP_SMC_FPGA_CONFIG_ISDONE
156 * Sync call used by service driver at EL1 to inform secure world that all
157 * data are sent, to check whether or not the secure world had completed
158 * the FPGA configuration process.
160 * Call register usage:
161 * a0: INTEL_SIP_SMC_FPGA_CONFIG_ISDONE.
165 * a0: INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_BUSY or
166 * INTEL_SIP_SMC_STATUS_ERROR.
169 #define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_ISDONE 4
170 #define INTEL_SIP_SMC_FPGA_CONFIG_ISDONE \
171 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_ISDONE)
174 * Request INTEL_SIP_SMC_FPGA_CONFIG_GET_MEM
176 * Sync call used by service driver at EL1 to query the physical address of
177 * memory block reserved by secure monitor software.
179 * Call register usage:
180 * a0:INTEL_SIP_SMC_FPGA_CONFIG_GET_MEM.
184 * a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_STATUS_ERROR.
185 * a1: start of physical address of reserved memory block.
186 * a2: size of reserved memory block.
189 #define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_GET_MEM 5
190 #define INTEL_SIP_SMC_FPGA_CONFIG_GET_MEM \
191 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_GET_MEM)
194 * Request INTEL_SIP_SMC_FPGA_CONFIG_LOOPBACK
196 * For SMC loop-back mode only, used for internal integration, debugging
197 * or troubleshooting.
199 * Call register usage:
200 * a0: INTEL_SIP_SMC_FPGA_CONFIG_LOOPBACK.
204 * a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_STATUS_ERROR.
207 #define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_LOOPBACK 6
208 #define INTEL_SIP_SMC_FPGA_CONFIG_LOOPBACK \
209 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_LOOPBACK)
212 * Request INTEL_SIP_SMC_REG_READ
214 * Read a protected register using SMCCC
216 * Call register usage:
217 * a0: INTEL_SIP_SMC_REG_READ.
218 * a1: register address.
222 * a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_REG_ERROR.
223 * a1: Value in the register
226 #define INTEL_SIP_SMC_FUNCID_REG_READ 7
227 #define INTEL_SIP_SMC_REG_READ \
228 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_REG_READ)
231 * Request INTEL_SIP_SMC_REG_WRITE
233 * Write a protected register using SMCCC
235 * Call register usage:
236 * a0: INTEL_SIP_SMC_REG_WRITE.
237 * a1: register address
238 * a2: value to program into register.
242 * a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_REG_ERROR.
245 #define INTEL_SIP_SMC_FUNCID_REG_WRITE 8
246 #define INTEL_SIP_SMC_REG_WRITE \
247 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_REG_WRITE)
250 * Request INTEL_SIP_SMC_FUNCID_REG_UPDATE
252 * Update one or more bits in a protected register using a
253 * read-modify-write operation.
255 * Call register usage:
256 * a0: INTEL_SIP_SMC_REG_UPDATE.
257 * a1: register address
259 * a3: Value to write.
263 * a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_REG_ERROR.
266 #define INTEL_SIP_SMC_FUNCID_REG_UPDATE 9
267 #define INTEL_SIP_SMC_REG_UPDATE \
268 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_REG_UPDATE)
271 * Request INTEL_SIP_SMC_RSU_STATUS
273 * Sync call used by service driver at EL1 to query the RSU status
275 * Call register usage:
276 * a0 INTEL_SIP_SMC_RSU_STATUS
281 * a1: Last Failing Image
282 * a2: Version [width 32 bit] | State [width 32 bit]
283 * a3: Error details [width 32 bit] | Error location [width 32 bit]
287 * a0: INTEL_SIP_SMC_RSU_ERROR
289 #define INTEL_SIP_SMC_FUNCID_RSU_STATUS 11
290 #define INTEL_SIP_SMC_RSU_STATUS \
291 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_STATUS)
294 * Request INTEL_SIP_SMC_RSU_UPDATE
296 * Sync call used by service driver at EL1 to tell you next reboot is RSU_UPDATE
298 * Call register usage:
299 * a0 INTEL_SIP_SMC_RSU_UPDATE
300 * a1 64bit physical address of the configuration data memory in flash
304 * a0 INTEL_SIP_SMC_STATUS_OK
306 #define INTEL_SIP_SMC_FUNCID_RSU_UPDATE 12
307 #define INTEL_SIP_SMC_RSU_UPDATE \
308 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_UPDATE)
311 * Request INTEL_SIP_SMC_ECC_DBE
313 * Sync call used by service driver at EL1 alert EL3 that a Double Bit
314 * ECC error has occurred.
316 * Call register usage:
317 * a0 INTEL_SIP_SMC_ECC_DBE
318 * a1 SysManager Double Bit Error value
322 * a0 INTEL_SIP_SMC_STATUS_OK
324 #define INTEL_SIP_SMC_FUNCID_ECC_DBE 13
325 #define INTEL_SIP_SMC_ECC_DBE \
326 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_ECC_DBE)
329 * Request INTEL_SIP_SMC_RSU_NOTIFY
331 * Sync call used by service driver at EL1 to report HPS software execution stage
333 * Call register usage:
334 * a0 INTEL_SIP_SMC_RSU_NOTIFY
335 * a1 32bit HPS software execution stage
339 * a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_REG_ERROR.
341 #define INTEL_SIP_SMC_FUNCID_RSU_NOTIFY 14
342 #define INTEL_SIP_SMC_RSU_NOTIFY \
343 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_NOTIFY)
346 * Request INTEL_SIP_SMC_RSU_RETRY_COUNTER
348 * Sync call used by service driver at EL1 to query the RSU retry counter
350 * Call register usage:
351 * a0 INTEL_SIP_SMC_RSU_RETRY_COUNTER
355 * a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_RSU_ERROR.
358 #define INTEL_SIP_SMC_FUNCID_RSU_RETRY_COUNTER 15
359 #define INTEL_SIP_SMC_RSU_RETRY_COUNTER \
360 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_RETRY_COUNTER)
363 * Request INTEL_SIP_SMC_RSU_DCMF_VERSION
365 * Sync call used by service driver at EL1 to query DCMF version
367 * Call register usage:
368 * a0 INTEL_SIP_SMC_RSU_DCMF_VERSION
372 * a0 INTEL_SIP_SMC_STATUS_OK
373 * a1 dcmf1 version | dcmf0 version
374 * a2 dcmf3 version | dcmf2 version
378 * a0 INTEL_SIP_SMC_RSU_ERROR
380 #define INTEL_SIP_SMC_FUNCID_RSU_DCMF_VERSION 16
381 #define INTEL_SIP_SMC_RSU_DCMF_VERSION \
382 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_DCMF_VERSION)
385 * Request INTEL_SIP_SMC_RSU_COPY_DCMF_VERSION
387 * Sync call used by SSBL (EL2) to copy DCMF version to ATF memory
389 * Call register usage:
390 * a0 INTEL_SIP_SMC_RSU_COPY_DCMF_VERSION
391 * a1 dcmf1 version | dcmf0 version
392 * a2 dcmf3 version | dcmf2 version
395 * a0 INTEL_SIP_SMC_STATUS_OK
397 #define INTEL_SIP_SMC_FUNCID_RSU_COPY_DCMF_VERSION 17
398 #define INTEL_SIP_SMC_RSU_COPY_DCMF_VERSION \
399 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_COPY_DCMF_VERSION)
402 * Request INTEL_SIP_SMC_RSU_MAX_RETRY
404 * Sync call used by service driver at EL1 to query max_retry parameter
406 * Call register usage:
407 * a0 INTEL_SIP_SMC_RSU_MAX_RETRY
411 * a0 INTEL_SIP_SMC_STATUS_OK
416 * a0 INTEL_SIP_SMC_RSU_ERROR
418 #define INTEL_SIP_SMC_FUNCID_RSU_MAX_RETRY 18
419 #define INTEL_SIP_SMC_RSU_MAX_RETRY \
420 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_MAX_RETRY)
423 * Request INTEL_SIP_SMC_RSU_COPY_MAX_RETRY
425 * Sync call used by SSBL (EL2) to copy RSU 'max retry' to ATF memory
427 * Call register usage:
428 * a0 INTEL_SIP_SMC_RSU_COPY_MAX_RETRY
433 * a0 INTEL_SIP_SMC_STATUS_OK
435 #define INTEL_SIP_SMC_FUNCID_RSU_COPY_MAX_RETRY 19
436 #define INTEL_SIP_SMC_RSU_COPY_MAX_RETRY \
437 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_COPY_MAX_RETRY)
440 * Request INTEL_SIP_SMC_RSU_DCMF_STATUS
442 * Sync call used by service driver at EL1 to query DCMF status
444 * Call register usage:
445 * a0 INTEL_SIP_SMC_RSU_DCMF_STATUS
449 * a0 INTEL_SIP_SMC_STATUS_OK
450 * a1 dcmf3 status | dcmf2 status | dcmf1 status | dcmf0 status
454 * a0 INTEL_SIP_SMC_RSU_ERROR
456 #define INTEL_SIP_SMC_FUNCID_RSU_DCMF_STATUS 20
457 #define INTEL_SIP_SMC_RSU_DCMF_STATUS \
458 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_DCMF_STATUS)
461 * Request INTEL_SIP_SMC_RSU_COPY_DCMF_STATUS
463 * Sync call used by SSBL (EL2) to copy RSU 'dcmf status' to ATF memory
465 * Call register usage:
466 * a0 INTEL_SIP_SMC_RSU_COPY_DCMF_STATUS
471 * a0 INTEL_SIP_SMC_STATUS_OK
473 #define INTEL_SIP_SMC_FUNCID_RSU_COPY_DCMF_STATUS 21
474 #define INTEL_SIP_SMC_RSU_COPY_DCMF_STATUS \
475 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_COPY_DCMF_STATUS)
478 * Request INTEL_SIP_SMC_HPS_SET_BRIDGES
480 * Enable/disable the SoC FPGA bridges
482 * Call register usage:
483 * a0 INTEL_SIP_SMC_HPS_SET_BRIDGES
484 * a1 Set bridges status:
490 * a0 INTEL_SIP_SMC_STATUS_OK
492 #define INTEL_SIP_SMC_FUNCID_HPS_SET_BRIDGES 50
493 #define INTEL_SIP_SMC_HPS_SET_BRIDGES \
494 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_HPS_SET_BRIDGES)
497 * Request INTEL_SIP_SMC_MBOX_SEND_CMD
499 * Send mailbox command to SDM
501 * Call register usage:
502 * a0 INTEL_SIP_SMC_MBOX_SEND_CMD
504 * a2 64bit physical address pointer to command's arguments
505 * a3 Length of the argument
509 * a5 64bit physical address pointer to a buffer for receiving responses
510 * a6 Length of the buffer
513 * a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_STATUS_ERROR
514 * a1 Status of mailbox response
515 * a2 Received length in the buffer
517 #define INTEL_SIP_SMC_FUNCID_MBOX_SEND_CMD 60
518 #define INTEL_SIP_SMC_MBOX_SEND_CMD \
519 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_MBOX_SEND_CMD)
522 * Request INTEL_SIP_SMC_GET_USERCODE
524 * Send mailbox command to get usercode from SDM
526 * Call register usage:
527 * a0 INTEL_SIP_SMC_GET_USERCODE
531 * a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_STATUS_ERROR
535 #define INTEL_SIP_SMC_FUNCID_GET_USERCODE 61
536 #define INTEL_SIP_SMC_GET_USERCODE \
537 INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_GET_USERCODE)