1 /*
2  * Copyright (c) 2019-2020, Intel Corporation. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef SOCFPGA_SIP_SVC_H
8 #define SOCFPGA_SIP_SVC_H
9 
10 
11 /* SiP status response */
12 #define INTEL_SIP_SMC_STATUS_OK				0
13 #define INTEL_SIP_SMC_STATUS_BUSY			0x1
14 #define INTEL_SIP_SMC_STATUS_REJECTED			0x2
15 #define INTEL_SIP_SMC_STATUS_ERROR			0x4
16 #define INTEL_SIP_SMC_RSU_ERROR				0x7
17 
18 
19 /* SMC SiP service function identifier */
20 
21 /* FPGA Reconfig */
22 #define INTEL_SIP_SMC_FPGA_CONFIG_START			0xC2000001
23 #define INTEL_SIP_SMC_FPGA_CONFIG_WRITE			0x42000002
24 #define INTEL_SIP_SMC_FPGA_CONFIG_COMPLETED_WRITE	0xC2000003
25 #define INTEL_SIP_SMC_FPGA_CONFIG_ISDONE		0xC2000004
26 #define INTEL_SIP_SMC_FPGA_CONFIG_GET_MEM		0xC2000005
27 
28 /* Secure Register Access */
29 #define INTEL_SIP_SMC_REG_READ				0xC2000007
30 #define INTEL_SIP_SMC_REG_WRITE				0xC2000008
31 #define INTEL_SIP_SMC_REG_UPDATE			0xC2000009
32 
33 /* Remote System Update */
34 #define INTEL_SIP_SMC_RSU_STATUS			0xC200000B
35 #define INTEL_SIP_SMC_RSU_UPDATE			0xC200000C
36 #define INTEL_SIP_SMC_RSU_NOTIFY			0xC200000E
37 #define INTEL_SIP_SMC_RSU_RETRY_COUNTER			0xC200000F
38 
39 /* Send Mailbox Command */
40 #define INTEL_SIP_SMC_MBOX_SEND_CMD			0xC200001E
41 
42 
43 /* SiP Definitions */
44 
45 /* FPGA config helpers */
46 #define INTEL_SIP_SMC_FPGA_CONFIG_ADDR			0x400000
47 #define INTEL_SIP_SMC_FPGA_CONFIG_SIZE			0x2000000
48 
49 /* SMC function IDs for SiP Service queries */
50 #define SIP_SVC_CALL_COUNT	0x8200ff00
51 #define SIP_SVC_UID		0x8200ff01
52 #define SIP_SVC_VERSION		0x8200ff03
53 
54 /* SiP Service Calls version numbers */
55 #define SIP_SVC_VERSION_MAJOR	0
56 #define SIP_SVC_VERSION_MINOR	1
57 
58 
59 /* Structure Definitions */
60 struct fpga_config_info {
61 	uint32_t addr;
62 	int size;
63 	int size_written;
64 	uint32_t write_requested;
65 	int subblocks_sent;
66 	int block_number;
67 };
68 
69 /* Function Definitions */
70 
71 bool is_address_in_ddr_range(uint64_t addr, uint64_t size);
72 
73 #endif /* SOCFPGA_SIP_SVC_H */
74