/* ================================================================== >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< ------------------------------------------------------------------ Copyright (c) 2019-2020 by Lattice Semiconductor Corporation ALL RIGHTS RESERVED ------------------------------------------------------------------ IMPORTANT: THIS FILE IS USED BY OR GENERATED BY the LATTICE PROPELâ„¢ DEVELOPMENT SUITE, WHICH INCLUDES PROPEL BUILDER AND PROPEL SDK. Lattice grants permission to use this code pursuant to the terms of the Lattice Propel License Agreement. DISCLAIMER: LATTICE MAKES NO WARRANTIES ON THIS FILE OR ITS CONTENTS, WHETHER EXPRESSED, IMPLIED, STATUTORY, OR IN ANY PROVISION OF THE LATTICE PROPEL LICENSE AGREEMENT OR COMMUNICATION WITH LICENSEE, AND LATTICE SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. LATTICE DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED HEREIN WILL MEET LICENSEE 'S REQUIREMENTS, OR THAT LICENSEE' S OPERATION OF ANY DEVICE, SOFTWARE OR SYSTEM USING THIS FILE OR ITS CONTENTS WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT DEFECTS HEREIN WILL BE CORRECTED. LICENSEE ASSUMES RESPONSIBILITY FOR SELECTION OF MATERIALS TO ACHIEVE ITS INTENDED RESULTS, AND FOR THE PROPER INSTALLATION, USE, AND RESULTS OBTAINED THEREFROM. LICENSEE ASSUMES THE ENTIRE RISK OF THE FILE AND ITS CONTENTS PROVING DEFECTIVE OR FAILING TO PERFORM PROPERLY AND IN SUCH EVENT, LICENSEE SHALL ASSUME THE ENTIRE COST AND RISK OF ANY REPAIR, SERVICE, CORRECTION, OR ANY OTHER LIABILITIES OR DAMAGES CAUSED BY OR ASSOCIATED WITH THE SOFTWARE.IN NO EVENT SHALL LATTICE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS FILE OR ITS CONTENTS, EVEN IF LATTICE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. LATTICE 'S SOLE LIABILITY, AND LICENSEE' S SOLE REMEDY, IS SET FORTH ABOVE. LATTICE DOES NOT WARRANT OR REPRESENT THAT THIS FILE, ITS CONTENTS OR USE THEREOF DOES NOT INFRINGE ON THIRD PARTIES' INTELLECTUAL PROPERTY RIGHTS, INCLUDING ANY PATENT. IT IS THE USER' S RESPONSIBILITY TO VERIFY THE USER SOFTWARE DESIGN FOR CONSISTENCY AND FUNCTIONALITY THROUGH THE USE OF FORMAL SOFTWARE VALIDATION METHODS. ------------------------------------------------------------------ ================================================================== */ #ifndef __UAB_H_ #define __UAB_H_ #include /* ------------------------------------------------------ - - - uab Device Register-map - - - ------------------------------------------------------ */ #define CFG0 0 #define UFM0 1 #define CFG1 4 #define UFM1 5 #define UFM2 8 #define UFM3 9 #define CSEC 10 #define USEC 11 #define PUBKEY 12 #define AESKEY 13 #define FEABITS 14 #define CFG0_SIZE 12541 #define UFM0_SIZE 3582 #define CFG1_SIZE 12541 #define UFM1_SIZE 3582 #define UFM2_SIZE 1150 #define UFM3_SIZE 191 enum { UAB_SUCC = 0, UAB_ERR = 1, }; enum { CFG0_ERASE = 0x000100, CFG1_ERASE = 0x000200, UFM0_ERASE = 0x000400, UFM1_ERASE = 0x000800, UFM2_ERASE = 0x001000, UFM3_ERASE = 0x002000, CSEC_ERASE = 0x004000, USEC_ERASE = 0x008000, PUBKEY_ERASE = 0x010000, AESKEY_ERASE = 0x020000, FEABITS_ERASE = 0x040000, }; struct uab_dev { volatile unsigned int uab_stat; volatile unsigned int addr_reg; volatile unsigned int oper_mode; volatile unsigned int wr_data0; volatile unsigned int wr_data1; volatile unsigned int wr_data2; volatile unsigned int wr_data3; volatile unsigned int rd_data0; volatile unsigned int rd_data1; volatile unsigned int rd_data2; volatile unsigned int rd_data3; volatile unsigned int start_oper; volatile unsigned int int_stat; volatile unsigned int int_en; volatile unsigned int int_set; volatile unsigned int cnx_jtag_cntl; //enable or disable the Jedi JTAG volatile unsigned int xo3d_jtag_cntl; volatile unsigned int force_reboot; }; struct uab_instance { const char *name; unsigned int base; }; #define UAB_STAT_RDY 0x01 #define UAB_OP_READ 0x00 #define UAB_OP_WRITE 0x01 #define UAB_OP_ERASE 0x02 #define UAB_OP_RDSPR 0x03 // special read table #define UAB_READ_PUBKEY0 0x5a018000 #define UAB_READ_PUBKEY1 0x5c018001 #define UAB_READ_PUBKEY2 0x62018002 #define UAB_READ_PUBKEY3 0x64018003 #define UAB_READ_SR0 0x3c000000 #define UAB_READ_SR1 0x3d000000 #define UAB_READ_FEA 0xfb00c040 #define UAB_READ_USERCODE 0xc0000000 #define UAB_READ_USEC 0x57000000 #define UAB_READ_CSEC 0x55000000 #define UAB_READ_CR0 0x20000000 #define UAB_READ_CR1 0x21000000 #define UAB_OP_WRSPR 0x04 #define UAB_OP_WRSHADOW 0x05 // special write table #define UAB_WRITE_PUBKEY0 0x59018000 #define UAB_WRITE_PUBKEY1 0x5B018001 #define UAB_WRITE_PUBKEY2 0x61018002 #define UAB_WRITE_PUBKEY3 0x63018003 #define UAB_WRITE_USEC 0x56000000 #define UAB_WRITE_CSEC 0x54000000 #define UAB_WRITE_FEA 0xf8000000 #define UAB_WRITE_DONE_CFG0 0x5e000000 #define UAB_WRITE_DONE_CFG1 0x5e000001 #define UAB_WRITE_AUTHDONE_CFG0 0xcc000000 #define UAB_WRITE_AUTHDONE_CFG1 0xcc000001 #define UAB_WRITE_AUTHDONE_ENABLE_HMAC_SHA 0xc4000002 #define UAB_WRITE_AUTHDONE_ENABLE_ECDSA 0xc4000003 #define UAB_WRITE_UDSS 0xCE000000 #define UAB_WRITE_CR0 0x22000000 #define UAB_WRITE_CR1 0x23000000 #define UAB_OP_START 0x01 // 0 - DONE, 1 - AUTH DONE #define UAB_SET_DONE 0 #define UAB_SET_AUTH_DONE 1 #define UAB_SR0 0 #define UAB_SR1 1 #define UDSS_PROG 2 #define UDSS_READ 4 /* ------------------------------------------------------ - - - uab APIs for UFM access - - - ------------------------------------------------------ */ unsigned char uab_init(struct uab_instance *this_uab, unsigned int base_addr); unsigned char uab_ufm_page_read(struct uab_instance *this_uab, unsigned int pageno, unsigned int ufm, unsigned char *buff, unsigned char *checksum); unsigned char uab_ufm_page_write(struct uab_instance *this_uab, unsigned int pageno, unsigned int ufm, unsigned char *data, unsigned char *checksum); unsigned char uab_ufm_erase(struct uab_instance *this_uab, unsigned int ufm); unsigned char uab_ufm_byte_write(struct uab_instance *this_uab, unsigned int pageno, unsigned char byteno, unsigned int ufm, unsigned char data); unsigned char uab_ufm_byte_read(struct uab_instance *this_uab, unsigned int pageno, unsigned char byteno, unsigned int ufm, unsigned char *data); unsigned char uab_refresh(struct uab_instance *this_uab); //unsigned char uab_boot_addr_get(struct uab_instance *this_uab, // unsigned int *boot_src); unsigned char uab_done_set(struct uab_instance *this_uab, uint32_t cfg, uint32_t auth); unsigned char uab_pubkey_read(struct uab_instance *this_uab, unsigned char pubkey[64]); unsigned char uab_pubkey_read_int(struct uab_instance *this_uab, unsigned int pubkey[16]); unsigned char uab_pubkey_write(struct uab_instance *this_uab, unsigned char pubkey[64]); unsigned char uab_usercode_read(struct uab_instance *this_uab, unsigned char usercode[4]); unsigned char uab_usec_read(struct uab_instance *this_uab, unsigned short *usec); unsigned char uab_usec_write(struct uab_instance *this_uab, unsigned short usec); unsigned char uab_usec_shadow_write(struct uab_instance *this_uab, unsigned short usec); unsigned char uab_csec_read(struct uab_instance *this_uab, unsigned int *csec); unsigned char uab_csec_write(struct uab_instance *this_uab, unsigned int csec); unsigned char uab_csec_shadow_write(struct uab_instance *this_uab, unsigned int csec); unsigned char uab_feabit_read(struct uab_instance *this_uab, unsigned int *feabit); unsigned char uab_feabit_write(struct uab_instance *this_uab, unsigned int feabit); unsigned char uab_feabit_shadow_write(struct uab_instance *this_uab, unsigned int feabit); unsigned char uab_auth_enable_write(struct uab_instance *this_uab, uint32_t enable); unsigned char uab_udss_write(struct uab_instance *this_uab, unsigned int ufm, unsigned char udss_val); unsigned char uab_cr0_read(struct uab_instance *this_uab, unsigned int *cr0_value); unsigned char uab_cr0_write(struct uab_instance *this_uab, unsigned int cr0_value); unsigned char uab_cr0_shadow_write(struct uab_instance *this_uab, unsigned int cr0); unsigned char uab_cr1_read(struct uab_instance *this_uab, unsigned int *cr1); unsigned char uab_cr1_write(struct uab_instance *this_uab, unsigned int cr1); unsigned char uab_cr1_shadow_write(struct uab_instance *this_uab, unsigned int cr1); #endif