blob: 5abbe631fcf44a932a287587ba97b8390c8321e7 [file] [log] [blame]
lijuangc76a7632017-12-07 14:37:56 +08001/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
Shashank Mittal162244e2011-08-08 19:01:25 -07002
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
Siddhartha Agrawaleb094c52013-01-28 12:11:43 -080012 * * Neither the name of The Linux Foundation nor the names of its
Shashank Mittal162244e2011-08-08 19:01:25 -070013 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __SCM_H__
30#define __SCM_H__
31
lijuang395b5e62015-11-19 17:39:44 +080032#include <reboot.h>
33
Channagoud Kadabidd85e7f2014-08-05 19:58:37 -070034/* ARM SCM format support related flags */
35#define SIP_SVC_CALLS 0x02000000
36#define MAKE_SIP_SCM_CMD(svc_id, cmd_id) ((((svc_id << 8) | (cmd_id)) & 0xFFFF) | SIP_SVC_CALLS)
37#define MAKE_SCM_VAR_ARGS(num_args, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, ...) (\
38 (((t0) & 0xff) << 4) | \
39 (((t1) & 0xff) << 6) | \
40 (((t2) & 0xff) << 8) | \
41 (((t3) & 0xff) << 10) | \
42 (((t4) & 0xff) << 12) | \
43 (((t5) & 0xff) << 14) | \
44 (((t6) & 0xff) << 16) | \
45 (((t7) & 0xff) << 18) | \
46 (((t8) & 0xff) << 20) | \
47 (((t9) & 0xff) << 22) | \
48 (num_args & 0xffff))
49#define MAKE_SCM_ARGS(...) MAKE_SCM_VAR_ARGS(__VA_ARGS__, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
50#define SCM_ATOMIC_BIT BIT(31)
51#define SCM_MAX_ARG_LEN 5
52#define SCM_INDIR_MAX_LEN 10
53
54enum
55{
56 SMC_PARAM_TYPE_VALUE = 0,
57 SMC_PARAM_TYPE_BUFFER_READ,
58 SMC_PARAM_TYPE_BUFFER_READWRITE,
59 SMC_PARAM_TYPE_BUFFER_VALIDATION,
60} scm_arg_type;
61
Shashank Mittal162244e2011-08-08 19:01:25 -070062/* 8 Byte SSD magic number (LE) */
Neeti Desai127b9e02012-03-20 16:11:23 -070063#define DECRYPT_MAGIC_0 0x73737A74
64#define DECRYPT_MAGIC_1 0x676D6964
65#define ENCRYPT_MAGIC_0 0x6B647373
66#define ENCRYPT_MAGIC_1 0x676D6973
Shashank Mittal162244e2011-08-08 19:01:25 -070067#define SSD_HEADER_MAGIC_SIZE 8
68#define SSD_HEADER_XML_SIZE 2048
sundarajan srinivasan6173b872013-03-13 17:36:48 -070069#define SSD_HEADER_MIN_SIZE 128
70#define MULTIPLICATION_FACTOR 2
Shashank Mittal162244e2011-08-08 19:01:25 -070071
72typedef unsigned int uint32;
73
Ajay Dudanib01e5062011-12-03 23:23:42 -080074typedef struct {
75 uint32 len;
76 uint32 buf_offset;
77 uint32 resp_hdr_offset;
78 uint32 id;
Shashank Mittal162244e2011-08-08 19:01:25 -070079} scm_command;
80
Ajay Dudanib01e5062011-12-03 23:23:42 -080081typedef struct {
82 uint32 len;
83 uint32 buf_offset;
84 uint32 is_complete;
Shashank Mittal162244e2011-08-08 19:01:25 -070085} scm_response;
86
Ajay Dudanib01e5062011-12-03 23:23:42 -080087typedef struct {
Ajay Dudanib01e5062011-12-03 23:23:42 -080088 uint32 *img_ptr;
89 uint32 *img_len_ptr;
Neeti Desai127b9e02012-03-20 16:11:23 -070090} img_req;
Shashank Mittal162244e2011-08-08 19:01:25 -070091
Siddhartha Agrawaleb094c52013-01-28 12:11:43 -080092typedef struct {
93 uint32 id;
94 uint32 spare;
95} tz_secure_cfg;
96
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -080097typedef struct {
98 uint32 md_len;
99 uint32* md;
100} ssd_parse_md_req;
101
102typedef struct {
103 uint32 status;
104 uint32 md_ctx_id;
105 uint32* md_end_ptr;
106} ssd_parse_md_rsp;
107
108typedef struct {
109 uint32 md_ctx_id;
110 uint32 last_frag;
111 uint32 frag_len;
112 uint32 *frag;
113} ssd_decrypt_img_frag_req;
114
115typedef struct {
116 uint32 status;
117} ssd_decrypt_img_frag_rsp;
118
119typedef struct{
120 uint32 feature_id;
121} feature_version_req;
122
123typedef struct{
124 uint32 version;
125} feature_version_rsp;
126
127typedef struct{
Amit Blaybdfabc62015-01-29 22:04:13 +0200128 uint32 *status_ptr;
129 uint32 status_len;
130} get_secure_state_req;
131
132typedef struct{
133 uint32 status_low;
134 uint32 status_high;
135} get_secure_state_rsp;
136
137typedef struct{
138 uint32 row_address;
139 uint32 addr_type;
140 uint32 *row_data;
141 uint32 *qfprom_api_status;
142} qfprom_read_row_req;
143
144typedef struct{
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800145 uint32 *keystore_ptr;
146 uint32 keystore_len;
147} ssd_protect_keystore_req;
148
149typedef struct{
150 uint32 status;
151} ssd_protect_keystore_rsp;
152
Abhimanyu Kapurb3207fb2014-01-27 21:33:23 -0800153typedef struct {
Aparna Mallavarapu6875ade2014-06-16 22:15:28 +0530154 uint32_t config;
155 uint32_t spare;
156} tz_xpu_prot_cmd;
157
158typedef struct {
Abhimanyu Kapurb3207fb2014-01-27 21:33:23 -0800159 uint64_t el1_x0;
160 uint64_t el1_x1;
161 uint64_t el1_x2;
162 uint64_t el1_x3;
163 uint64_t el1_x4;
164 uint64_t el1_x5;
165 uint64_t el1_x6;
166 uint64_t el1_x7;
167 uint64_t el1_x8;
168 uint64_t el1_elr;
169} el1_system_param;
170
Maria Yubeeeeaf2014-06-30 13:05:43 +0800171struct tz_prng_data {
172 uint8_t *out_buf;
173 uint32_t out_buf_size;
Maria Yud3aec502014-12-23 16:58:47 +0800174}__PACKED;
Maria Yubeeeeaf2014-06-30 13:05:43 +0800175
Amit Blayfe23ee22015-01-09 19:09:51 +0200176typedef struct {
177 uint8_t *in_buf;
178 uint32_t in_buf_size;
179 uint8_t *out_buf;
180 uint32_t out_buf_size;
181 uint32_t direction;
182} mdtp_cipher_dip_req;
183
Channagoud Kadabidd85e7f2014-08-05 19:58:37 -0700184/* SCM support as per ARM spec */
185/*
186 * Structure to define the argument for scm call
187 * x0: is the command ID
188 * x1: Number of argument & type of arguments
189 * : Type can be any of
190 * : SMC_PARAM_TYPE_VALUE 0
191 * : SMC_PARAM_TYPE_BUFFER_READ 1
192 * : SMC_PARAM_TYPE_BUFFER_READWRITE 2
193 * : SMC_PARAM_TYPE_BUFFER_VALIDATION 3
194 * @Note: Number of argument count starts from X2.
195 * x2-x4: Arguments
196 * X5[10]: if the number of argument is more, an indirect
197 * : list can be passed here.
198 */
199typedef struct {
200 uint32_t x0;/* command ID details as per ARMv8 spec :
201 0:7 command, 8:15 service id
202 0x02000000: SIP calls
203 30: SMC32 or SMC64
204 31: Standard or fast calls*/
205 uint32_t x1; /* # of args and attributes for buffers
206 * 0-3: arg #
207 * 4-5: type of arg1
208 * 6-7: type of arg2
209 * :
210 * :
211 * 20-21: type of arg8
212 * 22-23: type of arg9
213 */
214 uint32_t x2; /* Param1 */
215 uint32_t x3; /* Param2 */
216 uint32_t x4; /* Param3 */
217 uint32_t x5[10]; /* Indirect parameter list */
218 uint32_t atomic; /* To indicate if its standard or fast call */
219} scmcall_arg;
220
221/* Return value for the SCM call:
222 * SCM call returns values in register if its less than
223 * 12 bytes, anything greater need to be input buffer + input len
224 * arguments
225 */
226typedef struct
227{
228 uint32_t x1;
229 uint32_t x2;
230 uint32_t x3;
231} scmcall_ret;
232
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800233/* Service IDs */
Aparna Mallavarapu68e233f2014-03-21 19:18:34 +0530234#define SCM_SVC_BOOT 0x01
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800235#define TZBSP_SVC_INFO 0x06
236#define SCM_SVC_SSD 0x07
237#define SVC_MEMORY_PROTECTION 0x0C
Maria Yubeeeeaf2014-06-30 13:05:43 +0800238#define TZ_SVC_CRYPTO 0x0A
Channagoud Kadabidd85e7f2014-08-05 19:58:37 -0700239#define SCM_SVC_INFO 0x06
Channagoud Kadabi6479ce32015-06-17 17:30:40 -0700240#define TZ_SVC_DLOAD_MODE 0x3
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800241
242/*Service specific command IDs */
Aparna Mallavarapu6875ade2014-06-16 22:15:28 +0530243#define ERR_FATAL_ENABLE 0x0
Neeti Desai127b9e02012-03-20 16:11:23 -0700244#define SSD_DECRYPT_ID 0x01
245#define SSD_ENCRYPT_ID 0x02
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800246#define SSD_PROTECT_KEYSTORE_ID 0x05
247#define SSD_PARSE_MD_ID 0x06
248#define SSD_DECRYPT_IMG_FRAG_ID 0x07
Aparna Mallavarapu68e233f2014-03-21 19:18:34 +0530249#define WDOG_DEBUG_DISABLE 0x09
250#define SCM_DLOAD_CMD 0x10
Aparna Mallavarapu6875ade2014-06-16 22:15:28 +0530251#define XPU_ERR_FATAL 0xe
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800252
253#define SECURE_DEVICE_MDSS 0x01
254
Siddhartha Agrawaleb094c52013-01-28 12:11:43 -0800255#define IOMMU_SECURE_CFG 0x02
256
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800257#define TZ_INFO_GET_FEATURE_ID 0x03
Amit Blaybdfabc62015-01-29 22:04:13 +0200258#define TZ_INFO_GET_SECURE_STATE 0x04
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800259
Maria Yubeeeeaf2014-06-30 13:05:43 +0800260#define PRNG_CMD_ID 0x01
Channagoud Kadabidd85e7f2014-08-05 19:58:37 -0700261#define IS_CALL_AVAIL_CMD 0x01
Aparna Mallavarapu246c30b2014-12-11 12:07:51 +0530262#define IS_SECURE_BOOT_ENABLED 0x04
Maria Yubeeeeaf2014-06-30 13:05:43 +0800263
Aparna Mallavarapu68e233f2014-03-21 19:18:34 +0530264/* Download Mode specific arguments to be passed to TZ */
Lijuan Gaof1286fb2015-01-29 19:47:28 +0800265#define SCM_EDLOAD_MODE 0x01
Aparna Mallavarapu68e233f2014-03-21 19:18:34 +0530266#define SCM_DLOAD_MODE 0x10
267
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800268/* SSD parsing status messages from TZ */
269#define SSD_PMD_ENCRYPTED 0
270#define SSD_PMD_NOT_ENCRYPTED 1
271#define SSD_PMD_NO_MD_FOUND 3
272#define SSD_PMD_BUSY 4
273#define SSD_PMD_BAD_MD_PTR_OR_LEN 5
274#define SSD_PMD_PARSING_INCOMPLETE 6
275#define SSD_PMD_PARSING_FAILED 7
276#define SSD_PMD_SETUP_CIPHER_FAILED 8
277
278/* Keystore status messages */
279#define TZBSP_SSD_PKS_SUCCESS 0 /**< Successful return. */
280#define TZBSP_SSD_PKS_INVALID_PTR 1 /**< Keystore pointer invalid. */
281#define TZBSP_SSD_PKS_INVALID_LEN 2 /**< Keystore length incorrect. */
282#define TZBSP_SSD_PKS_UNALIGNED_PTR 3 /**< Keystore pointer not word
283 aligned. */
284#define TZBSP_SSD_PKS_PROTECT_MEM_FAILED 4 /**< Failure when protecting
285 the keystore memory.*/
286#define TZBSP_SSD_PKS_INVALID_NUM_KEYS 5 /**< Unsupported number of
287 keys passed. If a valid
288 pointer to non-secure
289 memory is passed that
290 isn't a keystore, this is
291 a likely return code. */
292#define TZBSP_SSD_PKS_DECRYPT_FAILED 6 /**< The keystore could not be
293 decrypted. */
294
295/* Features in TZ */
296#define TZBSP_FVER_SSD 5
297
298#define TZBSP_GET_FEATURE_VERSION(major) ((major >> 22)& 0x3FF)
Siddhartha Agrawaleb094c52013-01-28 12:11:43 -0800299
Shashank Mittal162244e2011-08-08 19:01:25 -0700300static uint32 smc(uint32 cmd_addr);
Neeti Desai127b9e02012-03-20 16:11:23 -0700301int decrypt_scm(uint32_t ** img_ptr, uint32_t * img_len_ptr);
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800302int decrypt_scm_v2(uint32_t ** img_ptr, uint32_t * img_len_ptr);
Neeti Desai127b9e02012-03-20 16:11:23 -0700303int encrypt_scm(uint32_t ** img_ptr, uint32_t * img_len_ptr);
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800304int scm_svc_version(uint32 * major, uint32 * minor);
Amit Blaybdfabc62015-01-29 22:04:13 +0200305
306/**
307 * Check security status on the device. Returns the security check result.
308 * Bit value 0 means the check passing, and bit value 1 means the check failing.
309 *
310 * @state_low[out] : lower 32 bits of the state:
311 * Bit 0: secboot enabling check failed
312 * Bit 1: Sec HW key is not programmed
313 * Bit 2: debug disable check failed
314 * Bit 3: Anti-rollback check failed
315 * Bit 4: fuse config check failed
316 * Bit 5: rpmb fuse check failed
317 * @state_high[out] : highr 32 bits of the state.
318 *
319 * Returns 0 on success, negative on failure.
320 */
321int scm_svc_get_secure_state(uint32_t *state_low, uint32_t *state_high);
322
sundarajan srinivasan4dfd4f72013-02-27 14:13:09 -0800323int scm_protect_keystore(uint32_t * img_ptr, uint32_t img_len);
Dinesh K Garg6bbbb702015-01-30 11:13:31 -0800324int
325scm_call(uint32_t svc_id, uint32_t cmd_id, const void *cmd_buf,
326 size_t cmd_len, void *resp_buf, size_t resp_len);
327
Shashank Mittal162244e2011-08-08 19:01:25 -0700328
Deepa Dinamani193874e2012-02-07 14:00:04 -0800329#define SCM_SVC_FUSE 0x08
330#define SCM_BLOW_SW_FUSE_ID 0x01
331#define SCM_IS_SW_FUSE_BLOWN_ID 0x02
Amit Blaybdfabc62015-01-29 22:04:13 +0200332#define SCM_QFPROM_READ_ROW_ID 0x05
Shashank Mittal162244e2011-08-08 19:01:25 -0700333
Deepa Dinamani193874e2012-02-07 14:00:04 -0800334#define HLOS_IMG_TAMPER_FUSE 0
Monika Singh98257462018-06-06 11:28:49 +0530335#define WINSECAPP_LOADED_FUSE 1 /**< Used by the WinSec application to prevent reloading. */
336#define UEFISECAPP_LOADED_FUSE 2 /**< Used by UefiSecApp to prevent
337 reloading. */
338#define OEM_FUSE_1 3 /**< Reserved fuse bit for OEMs. */
339#define OEM_FUSE_2 4 /**< Reserved fuse bit for OEMs. */
340#define OEM_FUSE_3 5 /**< Reserved fuse bit for OEMs. */
341#define OEM_FUSE_4 6 /**< Reserved fuse bit for OEMs. */
342#define OEM_FUSE_5 7 /**< Reserved fuse bit for OEMs. */
343#define OEM_FUSE_6 8 /**< Reserved fuse bit for OEMs. */
344#define OEM_FUSE_7 9 /**< Reserved fuse bit for OEMs. */
345#define OEM_FUSE_8 10 /**< Reserved fuse bit for OEMs. */
346#define HLOS_BL_MILESTONE_FUSE 11 /**< Used to notify the bootloader milestone call.*/
347#define HLOS_TAMPER_NOTIFY_FUSE 12 /**< Used to notify TZ that HLOS has been tampered.*/
348#define NUM_SW_FUSES 13 /**< Number of supported software fuses.
349 @newpage */
Deepa Dinamani193874e2012-02-07 14:00:04 -0800350
351#define SCM_SVC_CE_CHN_SWITCH_ID 0x04
352#define SCM_CE_CHN_SWITCH_ID 0x02
353
Amir Samuelov4620ad22013-03-13 11:30:05 +0200354#define SCM_SVC_ES 0x10
355#define SCM_SAVE_PARTITION_HASH_ID 0x01
356
Amit Blayfe23ee22015-01-09 19:09:51 +0200357#define SCM_SVC_MDTP 0x12
358#define SCM_MDTP_CIPHER_DIP 0x01
359
Channagoud Kadabi179df0b2013-12-12 14:53:31 -0800360#define SCM_SVC_PWR 0x9
361#define SCM_IO_DISABLE_PMIC_ARBITER 0x1
Aparna Mallavarapu664ea772015-02-24 18:44:33 +0530362#define SCM_IO_DISABLE_PMIC_ARBITER1 0x2
Channagoud Kadabi179df0b2013-12-12 14:53:31 -0800363
Abhimanyu Kapurb3207fb2014-01-27 21:33:23 -0800364#define SCM_SVC_MILESTONE_32_64_ID 0x1
365#define SCM_SVC_MILESTONE_CMD_ID 0xf
Dinesh K Garg6bbbb702015-01-30 11:13:31 -0800366#define SCM_SVC_TZSCHEDULER 0xFC
Abhimanyu Kapurb3207fb2014-01-27 21:33:23 -0800367
Deepa Dinamani193874e2012-02-07 14:00:04 -0800368enum ap_ce_channel_type {
369AP_CE_REGISTER_USE = 0,
370AP_CE_ADM_USE = 1
371};
372
373/* Apps CE resource. */
374#define TZ_RESOURCE_CE_AP 2
375
Aparna Mallavarapu246c30b2014-12-11 12:07:51 +0530376/* Secure IO Service IDs */
377#define SCM_IO_READ 0x1
378#define SCM_IO_WRITE 0x2
379#define SCM_SVC_IO 0x5
380
Deepa Dinamani193874e2012-02-07 14:00:04 -0800381uint8_t switch_ce_chn_cmd(enum ap_ce_channel_type channel);
382
Amit Blayfe23ee22015-01-09 19:09:51 +0200383/**
384 * Encrypt or Decrypt a Data Integrity Partition (DIP) structure using a
385 * HW derived key. The DIP is used for storing integrity information for
386 * Mobile Device Theft Protection (MDTP) service.
387 *
388 * @in_buf[in] : Pointer to plain text buffer.
389 * @in_buf_size[in] : Plain text buffer size.
390 * @out_buf[in] : Pointer to encrypted buffer.
391 * @out_buf_size[in] : Encrypted buffer size.
392 * @direction[in] : 0 for ENCRYPTION, 1 for DECRYPTION.
393 *
394 * Returns 0 on success, negative on failure.
395 */
396int mdtp_cipher_dip_cmd(uint8_t *in_buf, uint32_t in_buf_size, uint8_t *out_buf,
397 uint32_t out_buf_size, uint32_t direction);
Deepa Dinamani193874e2012-02-07 14:00:04 -0800398
Monika Singh98257462018-06-06 11:28:49 +0530399uint32_t set_tamper_fuse_cmd(uint32_t fuse_id);
Shashank Mittal162244e2011-08-08 19:01:25 -0700400
Amit Blaybdfabc62015-01-29 22:04:13 +0200401/**
402 * Reads the row data of the specified QFPROM row address.
403 *
404 * @row_address[in] : Row address in the QFPROM region to read.
405 * @addr_type[in] : Raw or corrected address.
406 * @row_data[in] : Pointer to the data to be read.
407 * @qfprom_api_status[out] : Status of the read operation.
408 *
409 * Returns Any errors while reading data from the specified
410 * Returns 0 on success, negative on failure.
411 */
412int qfprom_read_row_cmd(uint32_t row_address, uint32_t addr_type, uint32_t *row_data, uint32_t *qfprom_api_status);
413
Channagoud Kadabi179df0b2013-12-12 14:53:31 -0800414int scm_halt_pmic_arbiter();
Aparna Mallavarapu68e233f2014-03-21 19:18:34 +0530415int scm_call_atomic2(uint32_t svc, uint32_t cmd, uint32_t arg1, uint32_t arg2);
vijay kumar4f4405f2014-08-08 11:49:53 +0530416int restore_secure_cfg(uint32_t id);
Channagoud Kadabi179df0b2013-12-12 14:53:31 -0800417
Abhimanyu Kapurb3207fb2014-01-27 21:33:23 -0800418void scm_elexec_call(paddr_t kernel_entry, paddr_t dtb_offset);
lijuangc76a7632017-12-07 14:37:56 +0800419int scm_random(uintptr_t * rbuf, uint32_t r_len);
Channagoud Kadabiefdeb8a2015-09-23 11:52:20 -0700420uintptr_t get_canary();
Aparna Mallavarapu6875ade2014-06-16 22:15:28 +0530421/* API to configure XPU violations as fatal */
422int scm_xpu_err_fatal_init();
Abhimanyu Kapurb3207fb2014-01-27 21:33:23 -0800423
Channagoud Kadabidd85e7f2014-08-05 19:58:37 -0700424/* APIs to support ARM scm standard
425 * Takes arguments : x0-x5 and returns result
426 * in x0-x3*/
427uint32_t scm_call2(scmcall_arg *arg, scmcall_ret *ret);
428
Shashank Mittal162244e2011-08-08 19:01:25 -0700429/**
430 * struct scm_command - one SCM command buffer
431 * @len: total available memory for command and response
432 * @buf_offset: start of command buffer
433 * @resp_hdr_offset: start of response buffer
434 * @id: command to be executed
435 * @buf: buffer returned from scm_get_command_buffer()
436 *
437 * An SCM command is layed out in memory as follows:
438 *
439 * ------------------- <--- struct scm_command
440 * | command header |
441 * ------------------- <--- scm_get_command_buffer()
442 * | command buffer |
443 * ------------------- <--- struct scm_response and
444 * | response header | scm_command_to_response()
445 * ------------------- <--- scm_get_response_buffer()
446 * | response buffer |
447 * -------------------
448 *
449 * There can be arbitrary padding between the headers and buffers so
450 * you should always use the appropriate scm_get_*_buffer() routines
451 * to access the buffers in a safe manner.
452 */
453struct scm_command {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800454 uint32_t len;
455 uint32_t buf_offset;
456 uint32_t resp_hdr_offset;
457 uint32_t id;
458 uint32_t buf[0];
Shashank Mittal162244e2011-08-08 19:01:25 -0700459};
460
461/**
462 * struct scm_response - one SCM response buffer
463 * @len: total available memory for response
464 * @buf_offset: start of response data relative to start of scm_response
465 * @is_complete: indicates if the command has finished processing
466 */
467struct scm_response {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800468 uint32_t len;
469 uint32_t buf_offset;
470 uint32_t is_complete;
Shashank Mittal162244e2011-08-08 19:01:25 -0700471};
Channagoud Kadabidd85e7f2014-08-05 19:58:37 -0700472/* Perform any scm init needed before making scm calls
473 * Used for checking if armv8 SCM support present
474 */
475void scm_init();
Aparna Mallavarapu246c30b2014-12-11 12:07:51 +0530476bool is_secure_boot_enable();
Dinesh K Garg6bbbb702015-01-30 11:13:31 -0800477
478/* Is armv8 supported */
479bool is_scm_armv8_support();
Channagoud Kadabib2e080f2015-03-27 18:29:10 -0700480
lijuang395b5e62015-11-19 17:39:44 +0800481int scm_dload_mode(enum reboot_reason mode);
Channagoud Kadabi6479ce32015-06-17 17:30:40 -0700482int scm_device_enter_dload();
Aparna Mallavarapuda91ea92015-07-10 12:03:46 +0530483int scm_call2_atomic(uint32_t svc, uint32_t cmd, uint32_t arg1, uint32_t arg2);
484uint32_t scm_io_write(uint32_t address, uint32_t val);
Channagoud Kadabi77f46a32015-08-05 16:13:13 -0700485int is_scm_call_available(uint32_t svc_id, uint32_t cmd_id);
lijuang1cff8382016-01-11 17:56:54 +0800486int scm_disable_sdi();
Monika Singh98257462018-06-06 11:28:49 +0530487bool allow_set_fuse(uint32_t version);
Shashank Mittal162244e2011-08-08 19:01:25 -0700488#endif