1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (C) 2021 Foundries.io Ltd 4 */ 5 6 #ifndef __DRIVERS_ZYNQMP_PM_H__ 7 #define __DRIVERS_ZYNQMP_PM_H__ 8 9 #include <drivers/zynqmp_efuse.h> 10 #include <platform_config.h> 11 #include <tee_api_types.h> 12 #include <util.h> 13 14 /* 15 * Information about accessing eFuses and the Physically Uncloneable Function 16 * (PUF) Support can be found at 17 * https://www.xilinx.com/support/documentation/application_notes/xapp1319-zynq-usp-prog-nvm.pdf 18 */ 19 #define ZYNQMP_NONPUF_EFUSE 0 20 #define ZYNQMP_PUF_EFUSE 1 21 22 /* List of eFuse identifiers */ 23 enum zynqmp_efuse_id { 24 DNA = 0, IP_DISABLE, USER0, USER1, USER2, USER3, USER4, USER5, USER6, 25 USER7, MISC_USER_CTRL, SEC_CTRL, 26 }; 27 28 /* Valid bytes in the eFuse */ 29 #define ZYNQMP_EFUSE_LEN(_id) ZYNQMP_EFUSE_##_id##_LENGTH 30 31 /* Memory required to access the eFuse */ 32 #define ZYNQMP_EFUSE_MEM(_id) (ROUNDUP(ZYNQMP_EFUSE_LEN(_id), CACHELINE_LEN)) 33 34 /* Alignment required in the buffers used to read the eFuse */ 35 #define __aligned_efuse __aligned(CACHELINE_LEN) 36 37 /* 38 * Read eFuse memory 39 * @buf: buffer, where eFuse date will be stored. The data is returned 40 * in LE byte order. 41 * @buf_sz: buffer size in bytes 42 * @id: eFuse identifier. 43 * @puf: is eFuse PUF, ZYNQMP_PUF_EFUSE/ZYNQMP_NONPUF_EFUSE 44 * Return a TEE_Result compliant status 45 */ 46 TEE_Result zynqmp_efuse_read(uint8_t *buf, size_t buf_sz, 47 enum zynqmp_efuse_id id, bool puf); 48 49 /* 50 * Program eFuse memory 51 * @buf: buffer where eFuse data are stored in LE byte order. 52 * @buf_sz: buffer size in bytes 53 * @id: eFuse identifier. 54 * @puf: is eFuse PUF, ZYNQMP_PUF_EFUSE/ZYNQMP_NONPUF_EFUSE 55 * Return a TEE_Result compliant status 56 */ 57 TEE_Result zynqmp_efuse_write(uint8_t *buf, size_t buf_sz, 58 enum zynqmp_efuse_id id, bool puf); 59 60 /* 61 * Read the SoC version number: 62 * Different eFuse bitfields carry different meaning depending on this version. 63 */ 64 TEE_Result zynqmp_soc_version(uint32_t *version); 65 66 #endif /*__DRIVERS_ZYNQMP_PM_H__*/ 67