25#ifndef LIBSWITCHTEC_MFG_H
26#define LIBSWITCHTEC_MFG_H
28#define SWITCHTEC_MB_LOG_LEN 32
30#define SWITCHTEC_PUB_KEY_LEN 512
31#define SWITCHTEC_SIG_LEN 512
32#define SWITCHTEC_KMSK_LEN 64
33#define SWITCHTEC_KMSK_NUM 4
35#define SWITCHTEC_SECURITY_SPI_RATE_MAX_NUM 16
42 uint32_t ver_sec_unlock;
44enum switchtec_debug_mode {
45 SWITCHTEC_DEBUG_MODE_ENABLED,
46 SWITCHTEC_DEBUG_MODE_DISABLED_BUT_ENABLE_ALLOWED,
47 SWITCHTEC_DEBUG_MODE_DISABLED,
48 SWITCHTEC_DEBUG_MODE_DISABLED_EXT
51enum switchtec_secure_state {
52 SWITCHTEC_UNINITIALIZED_UNSECURED,
53 SWITCHTEC_INITIALIZED_UNSECURED,
54 SWITCHTEC_INITIALIZED_SECURED,
55 SWITCHTEC_SECURE_STATE_UNKNOWN = 0xff,
61enum switchtec_otp_program_status {
62 SWITCHTEC_OTP_PROGRAMMABLE = 0,
63 SWITCHTEC_OTP_UNPROGRAMMABLE = 1,
69 bool main_fw_ver_valid;
70 bool sec_unlock_ver_valid;
72 enum switchtec_otp_program_status basic;
73 enum switchtec_otp_program_status mixed_ver;
74 enum switchtec_otp_program_status main_fw_ver;
75 enum switchtec_otp_program_status sec_unlock_ver;
76 enum switchtec_otp_program_status kmsk[4];
80 uint8_t basic_setting_valid;
81 uint8_t public_key_exp_valid;
82 uint8_t public_key_num_valid;
83 uint8_t public_key_ver_valid;
84 uint8_t public_key_valid;
86 enum switchtec_debug_mode debug_mode;
87 enum switchtec_secure_state secure_state;
89 uint8_t jtag_lock_after_reset;
90 uint8_t jtag_lock_after_bl1;
91 uint8_t jtag_bl1_unlock_allowed;
92 uint8_t jtag_post_bl1_unlock_allowed;
95 uint32_t i2c_recovery_tmo;
99 uint32_t public_key_exponent;
100 uint32_t public_key_num;
101 uint32_t public_key_ver;
103 uint8_t public_key[SWITCHTEC_KMSK_NUM][SWITCHTEC_KMSK_LEN];
110 uint8_t jtag_lock_after_reset;
111 uint8_t jtag_lock_after_bl1;
112 uint8_t jtag_bl1_unlock_allowed;
113 uint8_t jtag_post_bl1_unlock_allowed;
116 uint32_t i2c_recovery_tmo;
119 uint32_t i2c_cmd_map;
120 uint32_t public_key_exponent;
123enum switchtec_active_index_id {
124 SWITCHTEC_ACTIVE_INDEX_0 = 0,
125 SWITCHTEC_ACTIVE_INDEX_1 = 1,
126 SWITCHTEC_ACTIVE_INDEX_NOT_SET = 0xfe
130 enum switchtec_active_index_id bl2;
131 enum switchtec_active_index_id firmware;
132 enum switchtec_active_index_id config;
133 enum switchtec_active_index_id keyman;
136enum switchtec_bl2_recovery_mode {
137 SWITCHTEC_BL2_RECOVERY_I2C = 1,
138 SWITCHTEC_BL2_RECOVERY_XMODEM = 2,
139 SWITCHTEC_BL2_RECOVERY_I2C_AND_XMODEM = 3
143 uint8_t kmsk[SWITCHTEC_KMSK_LEN];
147 uint8_t pubkey[SWITCHTEC_PUB_KEY_LEN];
152 uint8_t signature[SWITCHTEC_SIG_LEN];
157 float rates[SWITCHTEC_SECURITY_SPI_RATE_MAX_NUM];
162int switchtec_security_config_get(
struct switchtec_dev *dev,
164int switchtec_security_spi_avail_rate_get(
struct switchtec_dev *dev,
166int switchtec_security_config_set(
struct switchtec_dev *dev,
168int switchtec_mailbox_to_file(
struct switchtec_dev *dev,
int fd);
169int switchtec_active_image_index_get(
struct switchtec_dev *dev,
171int switchtec_active_image_index_set(
struct switchtec_dev *dev,
173int switchtec_fw_exec(
struct switchtec_dev *dev,
174 enum switchtec_bl2_recovery_mode recovery_mode);
175int switchtec_boot_resume(
struct switchtec_dev *dev);
176int switchtec_kmsk_set(
struct switchtec_dev *dev,
180int switchtec_secure_state_set(
struct switchtec_dev *dev,
181 enum switchtec_secure_state state);
182int switchtec_dbg_unlock(
struct switchtec_dev *dev, uint32_t serial,
183 uint32_t ver_sec_unlock,
186int switchtec_dbg_unlock_version_update(
struct switchtec_dev *dev,
188 uint32_t ver_sec_unlock,
191int switchtec_read_sec_cfg_file(
struct switchtec_dev *dev,
194int switchtec_read_pubk_file(FILE *pubk_file,
struct switchtec_pubkey *pubk);
195int switchtec_read_kmsk_file(FILE *kmsk_file,
struct switchtec_kmsk *kmsk);
196int switchtec_read_signature_file(FILE *sig_file,
int switchtec_sn_ver_get(struct switchtec_dev *dev, struct switchtec_sn_ver_info *info)
Get serial number and security version.