Fix duplicate atomic_t typedef conflicting with types.h

This commit is contained in:
2026-05-31 05:50:29 +03:00
parent 98326148ef
commit 3431bbfeb2
6455 changed files with 7049323 additions and 203 deletions
@@ -0,0 +1,734 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2017-2018, Intel Corporation
* Copyright (C) 2025, Altera Corporation
*/
#ifndef __STRATIX10_SMC_H
#define __STRATIX10_SMC_H
#include <linux/arm-smccc.h>
#include <linux/bitops.h>
/**
* This file defines the Secure Monitor Call (SMC) message protocol used for
* service layer driver in normal world (EL1) to communicate with secure
* monitor software in Secure Monitor Exception Level 3 (EL3).
*
* This file is shared with secure firmware (FW) which is out of kernel tree.
*
* An ARM SMC instruction takes a function identifier and up to 6 64-bit
* register values as arguments, and can return up to 4 64-bit register
* value. The operation of the secure monitor is determined by the parameter
* values passed in through registers.
*
* EL1 and EL3 communicates pointer as physical address rather than the
* virtual address.
*
* Functions specified by ARM SMC Calling convention:
*
* FAST call executes atomic operations, returns when the requested operation
* has completed.
* STD call starts a operation which can be preempted by a non-secure
* interrupt. The call can return before the requested operation has
* completed.
*
* a0..a7 is used as register names in the descriptions below, on arm32
* that translates to r0..r7 and on arm64 to w0..w7.
*/
/**
* @func_num: function ID
*/
#define INTEL_SIP_SMC_STD_CALL_VAL(func_num) \
ARM_SMCCC_CALL_VAL(ARM_SMCCC_STD_CALL, ARM_SMCCC_SMC_64, \
ARM_SMCCC_OWNER_SIP, (func_num))
#define INTEL_SIP_SMC_FAST_CALL_VAL(func_num) \
ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_64, \
ARM_SMCCC_OWNER_SIP, (func_num))
#define INTEL_SIP_SMC_ASYNC_VAL(func_name) \
ARM_SMCCC_CALL_VAL(ARM_SMCCC_STD_CALL, ARM_SMCCC_SMC_64, \
ARM_SMCCC_OWNER_SIP, (func_name))
/**
* Return values in INTEL_SIP_SMC_* call
*
* INTEL_SIP_SMC_RETURN_UNKNOWN_FUNCTION:
* Secure monitor software doesn't recognize the request.
*
* INTEL_SIP_SMC_STATUS_OK:
* Secure monitor software accepts the service client's request.
*
* INTEL_SIP_SMC_STATUS_BUSY:
* Secure monitor software is still processing service client's request.
*
* INTEL_SIP_SMC_STATUS_REJECTED:
* Secure monitor software reject the service client's request.
*
* INTEL_SIP_SMC_STATUS_ERROR:
* There is error during the process of service request.
*
* INTEL_SIP_SMC_RSU_ERROR:
* There is error during the process of remote status update request.
*/
#define INTEL_SIP_SMC_RETURN_UNKNOWN_FUNCTION 0xFFFFFFFF
#define INTEL_SIP_SMC_STATUS_OK 0x0
#define INTEL_SIP_SMC_STATUS_BUSY 0x1
#define INTEL_SIP_SMC_STATUS_REJECTED 0x2
#define INTEL_SIP_SMC_STATUS_ERROR 0x4
#define INTEL_SIP_SMC_RSU_ERROR 0x7
/**
* Request INTEL_SIP_SMC_FPGA_CONFIG_START
*
* Sync call used by service driver at EL1 to request the FPGA in EL3 to
* be prepare to receive a new configuration.
*
* Call register usage:
* a0: INTEL_SIP_SMC_FPGA_CONFIG_START.
* a1: flag for full or partial configuration. 0 for full and 1 for partial
* configuration.
* a2-7: not used.
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK, or INTEL_SIP_SMC_STATUS_ERROR.
* a1-3: not used.
*/
#define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_START 1
#define INTEL_SIP_SMC_FPGA_CONFIG_START \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_START)
/**
* Request INTEL_SIP_SMC_FPGA_CONFIG_WRITE
*
* Async call used by service driver at EL1 to provide FPGA configuration data
* to secure world.
*
* Call register usage:
* a0: INTEL_SIP_SMC_FPGA_CONFIG_WRITE.
* a1: 64bit physical address of the configuration data memory block
* a2: Size of configuration data block.
* a3-7: not used.
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_BUSY or
* INTEL_SIP_SMC_STATUS_ERROR.
* a1: 64bit physical address of 1st completed memory block if any completed
* block, otherwise zero value.
* a2: 64bit physical address of 2nd completed memory block if any completed
* block, otherwise zero value.
* a3: 64bit physical address of 3rd completed memory block if any completed
* block, otherwise zero value.
*/
#define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_WRITE 2
#define INTEL_SIP_SMC_FPGA_CONFIG_WRITE \
INTEL_SIP_SMC_STD_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_WRITE)
/**
* Request INTEL_SIP_SMC_FPGA_CONFIG_COMPLETED_WRITE
*
* Sync call used by service driver at EL1 to track the completed write
* transactions. This request is called after INTEL_SIP_SMC_FPGA_CONFIG_WRITE
* call returns INTEL_SIP_SMC_STATUS_BUSY.
*
* Call register usage:
* a0: INTEL_SIP_SMC_FPGA_CONFIG_COMPLETED_WRITE.
* a1-7: not used.
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_FPGA_BUSY or
* INTEL_SIP_SMC_STATUS_ERROR.
* a1: 64bit physical address of 1st completed memory block.
* a2: 64bit physical address of 2nd completed memory block if
* any completed block, otherwise zero value.
* a3: 64bit physical address of 3rd completed memory block if
* any completed block, otherwise zero value.
*/
#define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE 3
#define INTEL_SIP_SMC_FPGA_CONFIG_COMPLETED_WRITE \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE)
/**
* Request INTEL_SIP_SMC_FPGA_CONFIG_ISDONE
*
* Sync call used by service driver at EL1 to inform secure world that all
* data are sent, to check whether or not the secure world had completed
* the FPGA configuration process.
*
* Call register usage:
* a0: INTEL_SIP_SMC_FPGA_CONFIG_ISDONE.
* a1-7: not used.
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_BUSY or
* INTEL_SIP_SMC_STATUS_ERROR.
* a1-3: not used.
*/
#define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_ISDONE 4
#define INTEL_SIP_SMC_FPGA_CONFIG_ISDONE \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_ISDONE)
/**
* Request INTEL_SIP_SMC_FPGA_CONFIG_GET_MEM
*
* Sync call used by service driver at EL1 to query the physical address of
* memory block reserved by secure monitor software.
*
* Call register usage:
* a0:INTEL_SIP_SMC_FPGA_CONFIG_GET_MEM.
* a1-7: not used.
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_STATUS_ERROR.
* a1: start of physical address of reserved memory block.
* a2: size of reserved memory block.
* a3: not used.
*/
#define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_GET_MEM 5
#define INTEL_SIP_SMC_FPGA_CONFIG_GET_MEM \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_GET_MEM)
/**
* Request INTEL_SIP_SMC_FPGA_CONFIG_LOOPBACK
*
* For SMC loop-back mode only, used for internal integration, debugging
* or troubleshooting.
*
* Call register usage:
* a0: INTEL_SIP_SMC_FPGA_CONFIG_LOOPBACK.
* a1-7: not used.
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_STATUS_ERROR.
* a1-3: not used.
*/
#define INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_LOOPBACK 6
#define INTEL_SIP_SMC_FPGA_CONFIG_LOOPBACK \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_LOOPBACK)
/**
* Request INTEL_SIP_SMC_REG_READ
*
* Read a protected register at EL3
*
* Call register usage:
* a0: INTEL_SIP_SMC_REG_READ.
* a1: register address.
* a2-7: not used.
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_REG_ERROR.
* a1: value in the register
* a2-3: not used.
*/
#define INTEL_SIP_SMC_FUNCID_REG_READ 7
#define INTEL_SIP_SMC_REG_READ \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_REG_READ)
/**
* Request INTEL_SIP_SMC_REG_WRITE
*
* Write a protected register at EL3
*
* Call register usage:
* a0: INTEL_SIP_SMC_REG_WRITE.
* a1: register address
* a2: value to program into register.
* a3-7: not used.
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_REG_ERROR.
* a1-3: not used.
*/
#define INTEL_SIP_SMC_FUNCID_REG_WRITE 8
#define INTEL_SIP_SMC_REG_WRITE \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_REG_WRITE)
/**
* Request INTEL_SIP_SMC_FUNCID_REG_UPDATE
*
* Update one or more bits in a protected register at EL3 using a
* read-modify-write operation.
*
* Call register usage:
* a0: INTEL_SIP_SMC_REG_UPDATE.
* a1: register address
* a2: write Mask.
* a3: value to write.
* a4-7: not used.
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_REG_ERROR.
* a1-3: Not used.
*/
#define INTEL_SIP_SMC_FUNCID_REG_UPDATE 9
#define INTEL_SIP_SMC_REG_UPDATE \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_REG_UPDATE)
/**
* Request INTEL_SIP_SMC_RSU_STATUS
*
* Request remote status update boot log, call is synchronous.
*
* Call register usage:
* a0 INTEL_SIP_SMC_RSU_STATUS
* a1-7 not used
*
* Return status
* a0: Current Image
* a1: Last Failing Image
* a2: Version | State
* a3: Error details | Error location
*
* Or
*
* a0: INTEL_SIP_SMC_RSU_ERROR
*/
#define INTEL_SIP_SMC_FUNCID_RSU_STATUS 11
#define INTEL_SIP_SMC_RSU_STATUS \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_STATUS)
/**
* Request INTEL_SIP_SMC_RSU_UPDATE
*
* Request to set the offset of the bitstream to boot after reboot, call
* is synchronous.
*
* Call register usage:
* a0 INTEL_SIP_SMC_RSU_UPDATE
* a1 64bit physical address of the configuration data memory in flash
* a2-7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
*/
#define INTEL_SIP_SMC_FUNCID_RSU_UPDATE 12
#define INTEL_SIP_SMC_RSU_UPDATE \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_UPDATE)
/**
* Request INTEL_SIP_SMC_ECC_DBE
*
* Sync call used by service driver at EL1 to alert EL3 that a Double
* Bit ECC error has occurred.
*
* Call register usage:
* a0 INTEL_SIP_SMC_ECC_DBE
* a1 SysManager Double Bit Error value
* a2-7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
*/
#define INTEL_SIP_SMC_FUNCID_ECC_DBE 13
#define INTEL_SIP_SMC_ECC_DBE \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_ECC_DBE)
/**
* Request INTEL_SIP_SMC_RSU_NOTIFY
*
* Sync call used by service driver at EL1 to report hard processor
* system execution stage to firmware
*
* Call register usage:
* a0 INTEL_SIP_SMC_RSU_NOTIFY
* a1 32bit value representing hard processor system execution stage
* a2-7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
*/
#define INTEL_SIP_SMC_FUNCID_RSU_NOTIFY 14
#define INTEL_SIP_SMC_RSU_NOTIFY \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_NOTIFY)
/**
* Request INTEL_SIP_SMC_RSU_RETRY_COUNTER
*
* Sync call used by service driver at EL1 to query RSU retry counter
*
* Call register usage:
* a0 INTEL_SIP_SMC_RSU_RETRY_COUNTER
* a1-7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
* a1 the retry counter
*
* Or
*
* a0 INTEL_SIP_SMC_RSU_ERROR
*/
#define INTEL_SIP_SMC_FUNCID_RSU_RETRY_COUNTER 15
#define INTEL_SIP_SMC_RSU_RETRY_COUNTER \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_RETRY_COUNTER)
/**
* Request INTEL_SIP_SMC_RSU_DCMF_VERSION
*
* Sync call used by service driver at EL1 to query DCMF (Decision
* Configuration Management Firmware) version from FW
*
* Call register usage:
* a0 INTEL_SIP_SMC_RSU_DCMF_VERSION
* a1-7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
* a1 dcmf1 | dcmf0
* a2 dcmf3 | dcmf2
*
* Or
*
* a0 INTEL_SIP_SMC_RSU_ERROR
*/
#define INTEL_SIP_SMC_FUNCID_RSU_DCMF_VERSION 16
#define INTEL_SIP_SMC_RSU_DCMF_VERSION \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_DCMF_VERSION)
/**
* Request INTEL_SIP_SMC_RSU_MAX_RETRY
*
* Sync call used by service driver at EL1 to query max retry value from FW
*
* Call register usage:
* a0 INTEL_SIP_SMC_RSU_MAX_RETRY
* a1-7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
* a1 max retry value
*
* Or
* a0 INTEL_SIP_SMC_RSU_ERROR
*/
#define INTEL_SIP_SMC_FUNCID_RSU_MAX_RETRY 18
#define INTEL_SIP_SMC_RSU_MAX_RETRY \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_MAX_RETRY)
/**
* Request INTEL_SIP_SMC_RSU_DCMF_STATUS
*
* Sync call used by service driver at EL1 to query DCMF status from FW
*
* Call register usage:
* a0 INTEL_SIP_SMC_RSU_DCMF_STATUS
* a1-7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
* a1 dcmf3 | dcmf2 | dcmf1 | dcmf0
*
* Or
*
* a0 INTEL_SIP_SMC_RSU_ERROR
*/
#define INTEL_SIP_SMC_FUNCID_RSU_DCMF_STATUS 20
#define INTEL_SIP_SMC_RSU_DCMF_STATUS \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_RSU_DCMF_STATUS)
/**
* Request INTEL_SIP_SMC_SERVICE_COMPLETED
* Sync call to check if the secure world have completed service request
* or not.
*
* Call register usage:
* a0: INTEL_SIP_SMC_SERVICE_COMPLETED
* a1: this register is optional. If used, it is the physical address for
* secure firmware to put output data
* a2: this register is optional. If used, it is the size of output data
* a3-a7: not used
*
* Return status:
* a0: INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_ERROR,
* INTEL_SIP_SMC_REJECTED or INTEL_SIP_SMC_STATUS_BUSY
* a1: mailbox error if a0 is INTEL_SIP_SMC_STATUS_ERROR
* a2: physical address containing the process info
* for FCS certificate -- the data contains the certificate status
* for FCS cryption -- the data contains the actual data size FW processes
* a3: output data size
*/
#define INTEL_SIP_SMC_FUNCID_SERVICE_COMPLETED 30
#define INTEL_SIP_SMC_SERVICE_COMPLETED \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_SERVICE_COMPLETED)
/**
* Request INTEL_SIP_SMC_FIRMWARE_VERSION
*
* Sync call used to query the version of running firmware
*
* Call register usage:
* a0 INTEL_SIP_SMC_FIRMWARE_VERSION
* a1-a7 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_STATUS_ERROR
* a1 running firmware version
*/
#define INTEL_SIP_SMC_FUNCID_FIRMWARE_VERSION 31
#define INTEL_SIP_SMC_FIRMWARE_VERSION \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FIRMWARE_VERSION)
/**
* SMC call protocol for Mailbox, starting FUNCID from 60
*
* Call register usage:
* a0 INTEL_SIP_SMC_MBOX_SEND_CMD
* a1 mailbox command code
* a2 physical address that contain mailbox command data (not include header)
* a3 mailbox command data size in word
* a4 set to 0 for CASUAL, set to 1 for URGENT
* a5 physical address for secure firmware to put response data
* (not include header)
* a6 maximum size in word of physical address to store response data
* a7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_REJECTED or
* INTEL_SIP_SMC_STATUS_ERROR
* a1 mailbox error code
* a2 response data length in word
* a3 not used
*/
#define INTEL_SIP_SMC_FUNCID_MBOX_SEND_CMD 60
#define INTEL_SIP_SMC_MBOX_SEND_CMD \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_MBOX_SEND_CMD)
/**
* Request INTEL_SIP_SMC_SVC_VERSION
*
* Sync call used to query the SIP SMC API Version
*
* Call register usage:
* a0 INTEL_SIP_SMC_SVC_VERSION
* a1-a7 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK
* a1 Major
* a2 Minor
*/
#define INTEL_SIP_SMC_SVC_FUNCID_VERSION 512
#define INTEL_SIP_SMC_SVC_VERSION \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_SVC_FUNCID_VERSION)
/**
* SMC call protocol for FPGA Crypto Service (FCS)
* FUNCID starts from 90
*/
/**
* Request INTEL_SIP_SMC_FCS_RANDOM_NUMBER
*
* Sync call used to query the random number generated by the firmware
*
* Call register usage:
* a0 INTEL_SIP_SMC_FCS_RANDOM_NUMBER
* a1 the physical address for firmware to write generated random data
* a2-a7 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_FCS_ERROR or
* INTEL_SIP_SMC_FCS_REJECTED
* a1 mailbox error
* a2 the physical address of generated random number
* a3 size
*/
#define INTEL_SIP_SMC_FUNCID_FCS_RANDOM_NUMBER 90
#define INTEL_SIP_SMC_FCS_RANDOM_NUMBER \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FCS_RANDOM_NUMBER)
/**
* Request INTEL_SIP_SMC_FCS_CRYPTION
* Async call for data encryption and HMAC signature generation, or for
* data decryption and HMAC verification.
*
* Call INTEL_SIP_SMC_SERVICE_COMPLETED to get the output encrypted or
* decrypted data
*
* Call register usage:
* a0 INTEL_SIP_SMC_FCS_CRYPTION
* a1 cryption mode (1 for encryption and 0 for decryption)
* a2 physical address which stores to be encrypted or decrypted data
* a3 input data size
* a4 physical address which will hold the encrypted or decrypted output data
* a5 output data size
* a6-a7 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_STATUS_ERROR or
* INTEL_SIP_SMC_STATUS_REJECTED
* a1-3 not used
*/
#define INTEL_SIP_SMC_FUNCID_FCS_CRYPTION 91
#define INTEL_SIP_SMC_FCS_CRYPTION \
INTEL_SIP_SMC_STD_CALL_VAL(INTEL_SIP_SMC_FUNCID_FCS_CRYPTION)
/**
* Request INTEL_SIP_SMC_FCS_SERVICE_REQUEST
* Async call for authentication service of HPS software
*
* Call register usage:
* a0 INTEL_SIP_SMC_FCS_SERVICE_REQUEST
* a1 the physical address of data block
* a2 size of data block
* a3-a7 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_ERROR or
* INTEL_SIP_SMC_REJECTED
* a1-a3 not used
*/
#define INTEL_SIP_SMC_FUNCID_FCS_SERVICE_REQUEST 92
#define INTEL_SIP_SMC_FCS_SERVICE_REQUEST \
INTEL_SIP_SMC_STD_CALL_VAL(INTEL_SIP_SMC_FUNCID_FCS_SERVICE_REQUEST)
/**
* Request INTEL_SIP_SMC_FUNCID_FCS_SEND_CERTIFICATE
* Sync call to send a signed certificate
*
* Call register usage:
* a0 INTEL_SIP_SMC_FCS_SEND_CERTIFICATE
* a1 the physical address of CERTIFICATE block
* a2 size of data block
* a3-a7 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_FCS_REJECTED
* a1-a3 not used
*/
#define INTEL_SIP_SMC_FUNCID_FCS_SEND_CERTIFICATE 93
#define INTEL_SIP_SMC_FCS_SEND_CERTIFICATE \
INTEL_SIP_SMC_STD_CALL_VAL(INTEL_SIP_SMC_FUNCID_FCS_SEND_CERTIFICATE)
/**
* Request INTEL_SIP_SMC_FCS_GET_PROVISION_DATA
* Sync call to dump all the fuses and key hashes
*
* Call register usage:
* a0 INTEL_SIP_SMC_FCS_GET_PROVISION_DATA
* a1 the physical address for firmware to write structure of fuse and
* key hashes
* a2-a7 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK, INTEL_SIP_SMC_FCS_ERROR or
* INTEL_SIP_SMC_FCS_REJECTED
* a1 mailbox error
* a2 physical address for the structure of fuse and key hashes
* a3 the size of structure
*
*/
#define INTEL_SIP_SMC_FUNCID_FCS_GET_PROVISION_DATA 94
#define INTEL_SIP_SMC_FCS_GET_PROVISION_DATA \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FCS_GET_PROVISION_DATA)
/**
* Request INTEL_SIP_SMC_HWMON_READTEMP
* Sync call to request temperature
*
* Call register usage:
* a0 Temperature Channel
* a1-a7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
* a1 Temperature Value
* a2-a3 not used
*/
#define INTEL_SIP_SMC_FUNCID_HWMON_READTEMP 32
#define INTEL_SIP_SMC_HWMON_READTEMP \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_HWMON_READTEMP)
/**
* Request INTEL_SIP_SMC_HWMON_READVOLT
* Sync call to request voltage
*
* Call register usage:
* a0 Voltage Channel
* a1-a7 not used
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
* a1 Voltage Value
* a2-a3 not used
*/
#define INTEL_SIP_SMC_FUNCID_HWMON_READVOLT 33
#define INTEL_SIP_SMC_HWMON_READVOLT \
INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_HWMON_READVOLT)
/**
* Request INTEL_SIP_SMC_ASYNC_POLL
* Async call used by service driver at EL1 to query mailbox response from SDM.
*
* Call register usage:
* a0 INTEL_SIP_SMC_ASYNC_POLL
* a1 transaction job id
* a2-17 will be used to return the response data
*
* Return status
* a0 INTEL_SIP_SMC_STATUS_OK
* a1-17 will contain the response values from mailbox for the previous send
* transaction
* Or
* a0 INTEL_SIP_SMC_STATUS_NO_RESPONSE
* a1-17 not used
*/
#define INTEL_SIP_SMC_ASYNC_FUNC_ID_POLL (0xC8)
#define INTEL_SIP_SMC_ASYNC_POLL \
INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_POLL)
/**
* Request INTEL_SIP_SMC_ASYNC_RSU_GET_SPT
* Async call to get RSU SPT from SDM.
* Call register usage:
* a0 INTEL_SIP_SMC_ASYNC_RSU_GET_SPT
* a1 transaction job id
* a2-a17 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK ,INTEL_SIP_SMC_STATUS_REJECTED
* or INTEL_SIP_SMC_STATUS_BUSY
* a1-a17 not used
*/
#define INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_GET_SPT (0xEA)
#define INTEL_SIP_SMC_ASYNC_RSU_GET_SPT \
INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_GET_SPT)
/**
* Request INTEL_SIP_SMC_ASYNC_RSU_GET_ERROR_STATUS
* Async call to get RSU error status from SDM.
* Call register usage:
* a0 INTEL_SIP_SMC_ASYNC_RSU_GET_ERROR_STATUS
* a1 transaction job id
* a2-a17 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK ,INTEL_SIP_SMC_STATUS_REJECTED
* or INTEL_SIP_SMC_STATUS_BUSY
* a1-a17 not used
*/
#define INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_GET_ERROR_STATUS (0xEB)
#define INTEL_SIP_SMC_ASYNC_RSU_GET_ERROR_STATUS \
INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_GET_ERROR_STATUS)
/**
* Request INTEL_SIP_SMC_ASYNC_RSU_NOTIFY
* Async call to send NOTIFY value to SDM.
* Call register usage:
* a0 INTEL_SIP_SMC_ASYNC_RSU_NOTIFY
* a1 transaction job id
* a2 notify value
* a3-a17 not used
*
* Return status:
* a0 INTEL_SIP_SMC_STATUS_OK ,INTEL_SIP_SMC_STATUS_REJECTED
* or INTEL_SIP_SMC_STATUS_BUSY
* a1-a17 not used
*/
#define INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_NOTIFY (0xEC)
#define INTEL_SIP_SMC_ASYNC_RSU_NOTIFY \
INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_RSU_NOTIFY)
#endif
@@ -0,0 +1,392 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2017-2018, Intel Corporation
* Copyright (C) 2025, Altera Corporation
*/
#ifndef __STRATIX10_SVC_CLIENT_H
#define __STRATIX10_SVC_CLIENT_H
/*
* Service layer driver supports client names
*
* fpga: for FPGA configuration
* rsu: for remote status update
* hwmon: for hardware monitoring (voltage and temperature)
*/
#define SVC_CLIENT_FPGA "fpga"
#define SVC_CLIENT_RSU "rsu"
#define SVC_CLIENT_FCS "fcs"
#define SVC_CLIENT_HWMON "hwmon"
/*
* Status of the sent command, in bit number
*
* SVC_STATUS_OK:
* Secure firmware accepts the request issued by one of service clients.
*
* SVC_STATUS_BUFFER_SUBMITTED:
* Service client successfully submits data buffer to secure firmware.
*
* SVC_STATUS_BUFFER_DONE:
* Secure firmware completes data process, ready to accept the
* next WRITE transaction.
*
* SVC_STATUS_COMPLETED:
* Secure firmware completes service request successfully. In case of
* FPGA configuration, FPGA should be in user mode.
*
* SVC_COMMAND_STATUS_BUSY:
* Service request is still in process.
*
* SVC_COMMAND_STATUS_ERROR:
* Error encountered during the process of the service request.
*
* SVC_STATUS_NO_SUPPORT:
* Secure firmware doesn't support requested features such as RSU retry
* or RSU notify.
*/
#define SVC_STATUS_OK 0
#define SVC_STATUS_BUFFER_SUBMITTED 1
#define SVC_STATUS_BUFFER_DONE 2
#define SVC_STATUS_COMPLETED 3
#define SVC_STATUS_BUSY 4
#define SVC_STATUS_ERROR 5
#define SVC_STATUS_NO_SUPPORT 6
#define SVC_STATUS_INVALID_PARAM 7
/*
* Flag bit for COMMAND_RECONFIG
*
* COMMAND_RECONFIG_FLAG_PARTIAL:
* Set to FPGA configuration type (full or partial).
*/
#define COMMAND_RECONFIG_FLAG_PARTIAL 0
/*
* Timeout settings for service clients:
* timeout value used in Stratix10 FPGA manager driver.
* timeout value used in RSU driver
*/
#define SVC_RECONFIG_REQUEST_TIMEOUT_MS 5000
#define SVC_RECONFIG_BUFFER_TIMEOUT_MS 5000
#define SVC_RSU_REQUEST_TIMEOUT_MS 2000
#define SVC_FCS_REQUEST_TIMEOUT_MS 2000
#define SVC_COMPLETED_TIMEOUT_MS 30000
#define SVC_HWMON_REQUEST_TIMEOUT_MS 2000
struct stratix10_svc_chan;
/**
* enum stratix10_svc_command_code - supported service commands
*
* @COMMAND_NOOP: do 'dummy' request for integration/debug/trouble-shooting
*
* @COMMAND_RECONFIG: ask for FPGA configuration preparation, return status
* is SVC_STATUS_OK
*
* @COMMAND_RECONFIG_DATA_SUBMIT: submit buffer(s) of bit-stream data for the
* FPGA configuration, return status is SVC_STATUS_SUBMITTED or SVC_STATUS_ERROR
*
* @COMMAND_RECONFIG_DATA_CLAIM: check the status of the configuration, return
* status is SVC_STATUS_COMPLETED, or SVC_STATUS_BUSY, or SVC_STATUS_ERROR
*
* @COMMAND_RECONFIG_STATUS: check the status of the configuration, return
* status is SVC_STATUS_COMPLETED, or SVC_STATUS_BUSY, or SVC_STATUS_ERROR
*
* @COMMAND_RSU_STATUS: request remote system update boot log, return status
* is log data or SVC_STATUS_RSU_ERROR
*
* @COMMAND_RSU_UPDATE: set the offset of the bitstream to boot after reboot,
* return status is SVC_STATUS_OK or SVC_STATUS_ERROR
*
* @COMMAND_RSU_NOTIFY: report the status of hard processor system
* software to firmware, return status is SVC_STATUS_OK or
* SVC_STATUS_ERROR
*
* @COMMAND_RSU_RETRY: query firmware for the current image's retry counter,
* return status is SVC_STATUS_OK or SVC_STATUS_ERROR
*
* @COMMAND_RSU_MAX_RETRY: query firmware for the max retry value,
* return status is SVC_STATUS_OK or SVC_STATUS_ERROR
*
* @COMMAND_RSU_DCMF_VERSION: query firmware for the DCMF version, return status
* is SVC_STATUS_OK or SVC_STATUS_ERROR
*
* @COMMAND_POLL_SERVICE_STATUS: poll if the service request is complete,
* return statis is SVC_STATUS_OK, SVC_STATUS_ERROR or SVC_STATUS_BUSY
*
* @COMMAND_FIRMWARE_VERSION: query running firmware version, return status
* is SVC_STATUS_OK or SVC_STATUS_ERROR
*
* @COMMAND_SMC_SVC_VERSION: Non-mailbox SMC SVC API Version,
* return status is SVC_STATUS_OK
*
* @COMMAND_MBOX_SEND_CMD: send generic mailbox command, return status is
* SVC_STATUS_OK or SVC_STATUS_ERROR
*
* @COMMAND_RSU_DCMF_STATUS: query firmware for the DCMF status
* return status is SVC_STATUS_OK or SVC_STATUS_ERROR
*
* @COMMAND_RSU_GET_SPT_TABLE: query firmware for SPT table
* return status is SVC_STATUS_OK or SVC_STATUS_ERROR
*
* @COMMAND_FCS_REQUEST_SERVICE: request validation of image from firmware,
* return status is SVC_STATUS_OK, SVC_STATUS_INVALID_PARAM
*
* @COMMAND_FCS_SEND_CERTIFICATE: send a certificate, return status is
* SVC_STATUS_OK, SVC_STATUS_INVALID_PARAM, SVC_STATUS_ERROR
*
* @COMMAND_FCS_GET_PROVISION_DATA: read the provisioning data, return status is
* SVC_STATUS_OK, SVC_STATUS_INVALID_PARAM, SVC_STATUS_ERROR
*
* @COMMAND_FCS_DATA_ENCRYPTION: encrypt the data, return status is
* SVC_STATUS_OK, SVC_STATUS_INVALID_PARAM, SVC_STATUS_ERROR
*
* @COMMAND_FCS_DATA_DECRYPTION: decrypt the data, return status is
* SVC_STATUS_OK, SVC_STATUS_INVALID_PARAM, SVC_STATUS_ERROR
*
* @COMMAND_FCS_RANDOM_NUMBER_GEN: generate a random number, return status
* is SVC_STATUS_OK, SVC_STATUS_ERROR
*
* @COMMAND_HWMON_READTEMP: query the temperature from the hardware monitor,
* return status is SVC_STATUS_OK or SVC_STATUS_ERROR
*
* @COMMAND_HWMON_READVOLT: query the voltage from the hardware monitor,
* return status is SVC_STATUS_OK or SVC_STATUS_ERROR
*/
enum stratix10_svc_command_code {
/* for FPGA */
COMMAND_NOOP = 0,
COMMAND_RECONFIG,
COMMAND_RECONFIG_DATA_SUBMIT,
COMMAND_RECONFIG_DATA_CLAIM,
COMMAND_RECONFIG_STATUS,
/* for RSU */
COMMAND_RSU_STATUS = 10,
COMMAND_RSU_UPDATE,
COMMAND_RSU_NOTIFY,
COMMAND_RSU_RETRY,
COMMAND_RSU_MAX_RETRY,
COMMAND_RSU_DCMF_VERSION,
COMMAND_RSU_DCMF_STATUS,
COMMAND_FIRMWARE_VERSION,
COMMAND_RSU_GET_SPT_TABLE,
/* for FCS */
COMMAND_FCS_REQUEST_SERVICE = 20,
COMMAND_FCS_SEND_CERTIFICATE,
COMMAND_FCS_GET_PROVISION_DATA,
COMMAND_FCS_DATA_ENCRYPTION,
COMMAND_FCS_DATA_DECRYPTION,
COMMAND_FCS_RANDOM_NUMBER_GEN,
/* for general status poll */
COMMAND_POLL_SERVICE_STATUS = 40,
/* for generic mailbox send command */
COMMAND_MBOX_SEND_CMD = 100,
/* Non-mailbox SMC Call */
COMMAND_SMC_SVC_VERSION = 200,
/* for HWMON */
COMMAND_HWMON_READTEMP,
COMMAND_HWMON_READVOLT
};
/**
* struct stratix10_svc_client_msg - message sent by client to service
* @payload: starting address of data need be processed
* @payload_length: to be processed data size in bytes
* @payload_output: starting address of processed data
* @payload_length_output: processed data size in bytes
* @command: service command
* @arg: args to be passed via registers and not physically mapped buffers
*/
struct stratix10_svc_client_msg {
void *payload;
size_t payload_length;
void *payload_output;
size_t payload_length_output;
enum stratix10_svc_command_code command;
u64 arg[3];
};
/**
* struct stratix10_svc_command_config_type - config type
* @flags: flag bit for the type of FPGA configuration
*/
struct stratix10_svc_command_config_type {
u32 flags;
};
/**
* struct stratix10_svc_cb_data - callback data structure from service layer
* @status: the status of sent command
* @kaddr1: address of 1st completed data block
* @kaddr2: address of 2nd completed data block
* @kaddr3: address of 3rd completed data block
*/
struct stratix10_svc_cb_data {
u32 status;
void *kaddr1;
void *kaddr2;
void *kaddr3;
};
/**
* struct stratix10_svc_client - service client structure
* @dev: the client device
* @receive_cb: callback to provide service client the received data
* @priv: client private data
*/
struct stratix10_svc_client {
struct device *dev;
void (*receive_cb)(struct stratix10_svc_client *client,
struct stratix10_svc_cb_data *cb_data);
void *priv;
};
/**
* stratix10_svc_request_channel_byname() - request service channel
* @client: identity of the client requesting the channel
* @name: supporting client name defined above
*
* Return: a pointer to channel assigned to the client on success,
* or ERR_PTR() on error.
*/
struct stratix10_svc_chan
*stratix10_svc_request_channel_byname(struct stratix10_svc_client *client,
const char *name);
/**
* stratix10_svc_free_channel() - free service channel.
* @chan: service channel to be freed
*/
void stratix10_svc_free_channel(struct stratix10_svc_chan *chan);
/**
* stratix10_svc_allocate_memory() - allocate the momory
* @chan: service channel assigned to the client
* @size: number of bytes client requests
*
* Service layer allocates the requested number of bytes from the memory
* pool for the client.
*
* Return: the starting address of allocated memory on success, or
* ERR_PTR() on error.
*/
void *stratix10_svc_allocate_memory(struct stratix10_svc_chan *chan,
size_t size);
/**
* stratix10_svc_free_memory() - free allocated memory
* @chan: service channel assigned to the client
* @kaddr: starting address of memory to be free back to pool
*/
void stratix10_svc_free_memory(struct stratix10_svc_chan *chan, void *kaddr);
/**
* stratix10_svc_send() - send a message to the remote
* @chan: service channel assigned to the client
* @msg: message data to be sent, in the format of
* struct stratix10_svc_client_msg
*
* Return: 0 for success, -ENOMEM or -ENOBUFS on error.
*/
int stratix10_svc_send(struct stratix10_svc_chan *chan, void *msg);
/**
* stratix10_svc_done() - complete service request
* @chan: service channel assigned to the client
*
* This function is used by service client to inform service layer that
* client's service requests are completed, or there is an error in the
* request process.
*/
void stratix10_svc_done(struct stratix10_svc_chan *chan);
/**
* typedef async_callback_t - A type definition for an asynchronous callback function.
*
* This type defines a function pointer for an asynchronous callback.
* The callback function takes a single argument, which is a pointer to
* user-defined data.
*
* @cb_arg: Argument to be passed to the callback function.
*/
typedef void (*async_callback_t)(void *cb_arg);
/**
* stratix10_svc_add_async_client - Add an asynchronous client to a Stratix 10
* service channel.
* @chan: Pointer to the Stratix 10 service channel structure.
* @use_unique_clientid: Boolean flag indicating whether to use a unique client ID.
*
* This function registers an asynchronous client with the specified Stratix 10
* service channel. If the use_unique_clientid flag is set to true, a unique client
* ID will be assigned to the client.
*
* Return: 0 on success, or a negative error code on failure:
* -EINVAL if the channel is NULL or the async controller is not initialized.
* -EALREADY if the async channel is already allocated.
* -ENOMEM if memory allocation fails.
* Other negative values if ID allocation fails
*/
int stratix10_svc_add_async_client(struct stratix10_svc_chan *chan, bool use_unique_clientid);
/**
* stratix10_svc_remove_async_client - Remove an asynchronous client from the Stratix 10
* service channel.
* @chan: Pointer to the Stratix 10 service channel structure.
*
* This function removes an asynchronous client from the specified Stratix 10 service channel.
* It is typically used to clean up and release resources associated with the client.
*
* Return: 0 on success, -EINVAL if the channel or asynchronous channel is invalid.
*/
int stratix10_svc_remove_async_client(struct stratix10_svc_chan *chan);
/**
* stratix10_svc_async_send - Send an asynchronous message to the SDM mailbox
* in EL3 secure firmware.
* @chan: Pointer to the service channel structure.
* @msg: Pointer to the message to be sent.
* @handler: Pointer to the handler object used by caller to track the transaction.
* @cb: Callback function to be called upon completion.
* @cb_arg: Argument to be passed to the callback function.
*
* This function sends a message asynchronously to the SDM mailbox in EL3 secure firmware.
* and registers a callback function to be invoked when the operation completes.
*
* Return: 0 on success,and negative error codes on failure.
*/
int stratix10_svc_async_send(struct stratix10_svc_chan *chan, void *msg, void **handler,
async_callback_t cb, void *cb_arg);
/**
* stratix10_svc_async_poll - Polls the status of an asynchronous service request.
* @chan: Pointer to the service channel structure.
* @tx_handle: Handle to the transaction being polled.
* @data: Pointer to the callback data structure to be filled with the result.
*
* This function checks the status of an asynchronous service request
* and fills the provided callback data structure with the result.
*
* Return: 0 on success, -EINVAL if any input parameter is invalid or if the
* async controller is not initialized, -EAGAIN if the transaction is
* still in progress, or other negative error codes on failure.
*/
int stratix10_svc_async_poll(struct stratix10_svc_chan *chan, void *tx_handle,
struct stratix10_svc_cb_data *data);
/**
* stratix10_svc_async_done - Complete an asynchronous transaction
* @chan: Pointer to the service channel structure
* @tx_handle: Pointer to the transaction handle
*
* This function completes an asynchronous transaction by removing the
* transaction from the hash table and deallocating the associated resources.
*
* Return: 0 on success, -EINVAL on invalid input or errors.
*/
int stratix10_svc_async_done(struct stratix10_svc_chan *chan, void *tx_handle);
#endif