Lines Matching +full:non +full:- +full:secure +full:- +full:otp

1 // SPDX-License-Identifier: GPL-2.0+
19 #include <u-boot/sha256.h>
20 #include <u-boot/sha512.h>
21 #include <u-boot/rsa.h>
22 #include <u-boot/rsa-mod-exp.h>
36 #define OTP_USAGE -1
37 #define OTP_FAILURE -2
214 …{0, OTP_KEY_TYPE_AES, OTP_LIT_END, 0, "AES-256 as OEM platform key for image encryption/decr…
215 {1, OTP_KEY_TYPE_VAULT, OTP_LIT_END, 0, "AES-256 as secret vault key"},
217 {8, OTP_KEY_TYPE_RSA_PUB, OTP_LIT_END, 1, "RSA-public as OEM DSS public keys in Mode 2"},
218 {9, OTP_KEY_TYPE_RSA_PUB, OTP_LIT_END, 0, "RSA-public as SOC public key"},
219 {10, OTP_KEY_TYPE_RSA_PUB, OTP_LIT_END, 0, "RSA-public as AES key decryption key"},
220 {13, OTP_KEY_TYPE_RSA_PRIV, OTP_LIT_END, 0, "RSA-private as SOC private key"},
221 {14, OTP_KEY_TYPE_RSA_PRIV, OTP_LIT_END, 0, "RSA-private as AES key decryption key"},
225 {1, OTP_KEY_TYPE_VAULT, OTP_LIT_END, 0, "AES-256 as secret vault key"},
226 …EY_TYPE_AES, OTP_LIT_END, 1, "AES-256 as OEM platform key for image encryption/decryption in…
227 {8, OTP_KEY_TYPE_RSA_PUB, OTP_LIT_END, 1, "RSA-public as OEM DSS public keys in Mode 2"},
228 {10, OTP_KEY_TYPE_RSA_PUB, OTP_LIT_END, 0, "RSA-public as AES key decryption key"},
229 {14, OTP_KEY_TYPE_RSA_PRIV, OTP_LIT_END, 0, "RSA-private as AES key decryption key"},
233 {1, OTP_KEY_TYPE_VAULT, OTP_LIT_END, 0, "AES-256 as secret vault key"},
234 …EY_TYPE_AES, OTP_LIT_END, 1, "AES-256 as OEM platform key for image encryption/decryption in…
235 {8, OTP_KEY_TYPE_RSA_PUB, OTP_LIT_END, 1, "RSA-public as OEM DSS public keys in Mode 2"},
236 {10, OTP_KEY_TYPE_RSA_PUB, OTP_LIT_END, 0, "RSA-public as AES key decryption key"},
237 {14, OTP_KEY_TYPE_RSA_PRIV, OTP_LIT_END, 0, "RSA-private as AES key decryption key"},
241 {1, OTP_KEY_TYPE_VAULT, OTP_LIT_END, 0, "AES-256 as secret vault key"},
242 …EY_TYPE_AES, OTP_LIT_END, 1, "AES-256 as OEM platform key for image encryption/decryption in…
243 {8, OTP_KEY_TYPE_RSA_PUB, OTP_LIT_END, 1, "RSA-public as OEM DSS public keys in Mode 2"},
244 …{9, OTP_KEY_TYPE_RSA_PUB, OTP_BIG_END, 1, "RSA-public as OEM DSS public keys in Mode 2(big endia…
245 {10, OTP_KEY_TYPE_RSA_PUB, OTP_LIT_END, 0, "RSA-public as AES key decryption key"},
246 {11, OTP_KEY_TYPE_RSA_PUB, OTP_BIG_END, 0, "RSA-public as AES key decryption key(big endian)"},
247 {12, OTP_KEY_TYPE_RSA_PRIV, OTP_LIT_END, 0, "RSA-private as AES key decryption key"},
248 {13, OTP_KEY_TYPE_RSA_PRIV, OTP_BIG_END, 0, "RSA-private as AES key decryption key(big endian)"},
276 bit_offset = offset - 32; in get_dw_bit()
316 /* AST2600-A0 */ in chip_version()
319 /* AST2600-A1 */ in chip_version()
322 /* AST2600-A2 */ in chip_version()
325 /* AST2600-A3 */ in chip_version()
328 /* AST2620-A1 */ in chip_version()
331 /* AST2620-A2 */ in chip_version()
334 /* AST2620-A3 */ in chip_version()
337 /* AST2605-A2 */ in chip_version()
340 /* AST2605-A3 */ in chip_version()
343 /* AST2605-A3 */ in chip_version()
471 writel(otp_addr - 1, OTP_ADDR); //Read address in verify_bit()
500 writel(otp_addr - 1, OTP_ADDR); //Read address in verify_dw()
718 otpstrap[j].writeable_option = -1; in otp_strap_status()
726 otpstrap[j].writeable_option = -1; in otp_strap_status()
734 int option = (i - 16) / 2; in otp_strap_status()
741 if (bit_value == 0 && otpstrap[j].writeable_option == -1) in otp_strap_status()
744 otpstrap[j].remain_times--; in otp_strap_status()
749 char bit_value = ((OTPSTRAP_RAW[1] >> (j - 32)) & 0x1); in otp_strap_status()
751 if (bit_value == 0 && otpstrap[j].writeable_option == -1) in otp_strap_status()
754 otpstrap[j].remain_times--; in otp_strap_status()
767 if (((OTPSTRAP_RAW[1] >> (j - 32)) & 0x1) == 1) in otp_strap_status()
781 if (bit == otpstrap->value) { in otp_strap_bit_confirm()
790 if (otpstrap->protected == 1 && prog_flag) { in otp_strap_bit_confirm()
794 if (otpstrap->remain_times == 0 && prog_flag) { in otp_strap_bit_confirm()
799 printf(" This bit will be protected and become non-writable.\n"); in otp_strap_bit_confirm()
801 …lue becomes from 0x%X to 0x%X.\n", offset, otpstrap->writeable_option + 1, otpstrap->value, otpstr… in otp_strap_bit_confirm()
827 offset = (bit_offset - 32); in otp_prog_strap_b()
892 printf("0x%-8X", i); in otp_print_strap()
893 printf("%-7d", otpstrap[i].value); in otp_print_strap()
925 bit_offset = i - 32; in otp_print_revid()
938 u32 *OTPSCU = (u32 *)image_layout->scu_pro; in otp_print_scu_image()
939 u32 *OTPSCU_IGNORE = (u32 *)image_layout->scu_pro_ignore; in otp_print_scu_image()
951 mask = BIT(scu_info[i].length) - 1; in otp_print_scu_image()
956 bit_offset = scu_info[i].bit_offset - 32; in otp_print_scu_image()
974 printf("0x%-6X", scu_offset); in otp_print_scu_image()
976 printf("0x%-11X", bit_offset); in otp_print_scu_image()
978 printf("0x%-2X:0x%-6x", bit_offset, bit_offset + scu_info[i].length - 1); in otp_print_scu_image()
979 printf("0x%-14X", otp_value); in otp_print_scu_image()
1009 bit_offset = scu_info[i].bit_offset + j - 32; in otp_print_scu_info()
1012 printf("0x%-6X", scu_offset); in otp_print_scu_info()
1013 printf("0x%-4X", bit_offset); in otp_print_scu_info()
1014 printf("0x%-13X", reg_p); in otp_print_scu_info()
1022 else if (j == length - 1) in otp_print_scu_info()
1033 u32 *OTPCFG = (u32 *)image_layout->conf; in otp_print_conf_image()
1034 u32 *OTPCFG_IGNORE = (u32 *)image_layout->conf_ignore; in otp_print_conf_image()
1054 mask = BIT(conf_info[i].length) - 1; in otp_print_conf_image()
1077 printf("0x%-4X", dw_offset); in otp_print_conf_image()
1080 printf("0x%-9X", conf_info[i].bit_offset); in otp_print_conf_image()
1082 printf("0x%-2X:0x%-4X", in otp_print_conf_image()
1083 conf_info[i].bit_offset + conf_info[i].length - 1, in otp_print_conf_image()
1086 printf("0x%-10x", otp_value); in otp_print_conf_image()
1119 printf("OTP revision ID is invalid.\n"); in otp_print_conf_image()
1130 printf("OTP revision ID is invalid.\n"); in otp_print_conf_image()
1138 printf("OTP revision ID\n"); in otp_print_conf_image()
1140 printf("OTP revision ID: 0x%x\n", rid_num); in otp_print_conf_image()
1169 if (input_offset != -1 && input_offset != conf_info[i].dw_offset) in otp_print_conf_info()
1173 mask = BIT(conf_info[i].length) - 1; in otp_print_conf_info()
1181 printf("0x%-4X", dw_offset); in otp_print_conf_info()
1184 printf("0x%-9X", conf_info[i].bit_offset); in otp_print_conf_info()
1186 printf("0x%-2X:0x%-4X", in otp_print_conf_info()
1187 conf_info[i].bit_offset + conf_info[i].length - 1, in otp_print_conf_info()
1190 printf("0x%-10x", otp_value); in otp_print_conf_info()
1234 OTPSTRAP = (u32 *)image_layout->strap; in otp_print_strap_image()
1235 OTPSTRAP_PRO = (u32 *)image_layout->strap_pro; in otp_print_strap_image()
1236 OTPSTRAP_IGNORE = (u32 *)image_layout->strap_ignore; in otp_print_strap_image()
1245 bit_offset = strap_info[i].bit_offset - 32; in otp_print_strap_image()
1251 mask = BIT(strap_info[i].length) - 1; in otp_print_strap_image()
1266 printf("0x%-9X", strap_info[i].bit_offset); in otp_print_strap_image()
1268 printf("0x%-2X:0x%-4X", in otp_print_strap_image()
1269 strap_info[i].bit_offset + strap_info[i].length - 1, in otp_print_strap_image()
1272 printf("0x%-10x", otp_value); in otp_print_strap_image()
1273 printf("0x%-10x", otp_protect); in otp_print_strap_image()
1324 printf("0x%-7X", strap_info[i].bit_offset + j); in otp_print_strap_info()
1325 printf("0x%-5X", strap_status[bit_offset + j].value); in otp_print_strap_info()
1326 printf("%-9d", strap_status[bit_offset + j].remain_times); in otp_print_strap_info()
1327 printf("0x%-7X", strap_status[bit_offset + j].protected); in otp_print_strap_info()
1339 else if (j == length - 1) in otp_print_strap_info()
1346 printf("0x%-9X", strap_info[i].bit_offset); in otp_print_strap_info()
1348 printf("0x%-2X:0x%-4X", in otp_print_strap_info()
1349 bit_offset + length - 1, bit_offset); in otp_print_strap_info()
1352 printf("0x%-10X", otp_value); in otp_print_strap_info()
1370 struct otpkey_type key_info = { .value = -1 }; in _otp_print_key()
1390 if (key_info.value == -1) in _otp_print_key()
1495 printf("OTP data header is empty\n"); in otp_print_key()
1511 buf = (u32 *)image_layout->data; in otp_print_data_image()
1535 buf = (u32 *)image_layout->data; in otp_prog_data()
1536 buf_ignore = (u32 *)image_layout->data_ignore; in otp_prog_data()
1573 strap = (u32 *)image_layout->strap; in otp_prog_strap()
1574 strap_pro = (u32 *)image_layout->strap_pro; in otp_prog_strap()
1575 strap_ignore = (u32 *)image_layout->strap_ignore; in otp_prog_strap()
1588 offset = (i - 32); in otp_prog_strap()
1642 u32 *conf = (u32 *)image_layout->conf; in otp_prog_conf()
1643 u32 *conf_ignore = (u32 *)image_layout->conf_ignore; in otp_prog_conf()
1704 u32 *OTPSCU = (u32 *)image_layout->scu_pro; in otp_prog_scu_protect()
1705 u32 *OTPSCU_IGNORE = (u32 *)image_layout->scu_pro_ignore; in otp_prog_scu_protect()
1762 u32 *buf = (u32 *)image_layout->data; in otp_check_data_image()
1763 u32 *buf_ignore = (u32 *)image_layout->data_ignore; in otp_check_data_image()
1766 data_dw = image_layout->data_length / 4; in otp_check_data_image()
1767 // ignore last two dw, the last two dw is used for slt otp write check. in otp_check_data_image()
1768 for (i = 0; i < data_dw - 2; i++) { in otp_check_data_image()
1777 printf("Input image can't program into OTP, please check.\n"); in otp_check_data_image()
1787 printf("Input image can't program into OTP, please check.\n"); in otp_check_data_image()
1808 strap = (u32 *)image_layout->strap; in otp_check_strap_image()
1809 strap_pro = (u32 *)image_layout->strap_pro; in otp_check_strap_image()
1810 strap_ignore = (u32 *)image_layout->strap_ignore; in otp_check_strap_image()
1818 bit = (strap[1] >> (i - 32)) & 0x1; in otp_check_strap_image()
1819 ibit = (strap_ignore[1] >> (i - 32)) & 0x1; in otp_check_strap_image()
1820 pbit = (strap_pro[1] >> (i - 32)) & 0x1; in otp_check_strap_image()
1829 printf("Input image can't program into OTP, please check.\n"); in otp_check_strap_image()
1837 u32 *conf = (u32 *)image_layout->conf; in otp_check_conf_image()
1838 u32 *conf_ignore = (u32 *)image_layout->conf_ignore; in otp_check_conf_image()
1851 printf("Input image can't program into OTP, please check.\n"); in otp_check_conf_image()
1863 u32 *OTPSCU = (u32 *)image_layout->scu_pro; in otp_check_scu_image()
1864 u32 *OTPSCU_IGNORE = (u32 *)image_layout->scu_pro_ignore; in otp_check_scu_image()
1877 printf("Input image can't program into OTP, please check.\n"); in otp_check_scu_image()
1896 algo->hash_func_ws(data, data_len, value, algo->chunk_size); in do_hash()
1943 image_size = OTP_IMAGE_SIZE(otp_header->image_info); in otp_prog_image()
1953 checksum = buf + otp_header->checksum_offset; in otp_prog_image()
1955 if (strcmp(OTP_MAGIC, (char *)otp_header->otp_magic) != 0) { in otp_prog_image()
1960 image_layout.data_length = (int)(OTP_REGION_SIZE(otp_header->data_info) / 2); in otp_prog_image()
1961 image_layout.data = buf + OTP_REGION_OFFSET(otp_header->data_info); in otp_prog_image()
1964 image_layout.conf_length = (int)(OTP_REGION_SIZE(otp_header->config_info) / 2); in otp_prog_image()
1965 image_layout.conf = buf + OTP_REGION_OFFSET(otp_header->config_info); in otp_prog_image()
1968 image_layout.strap = buf + OTP_REGION_OFFSET(otp_header->strap_info); in otp_prog_image()
1969 image_layout.strap_length = (int)(OTP_REGION_SIZE(otp_header->strap_info) / 3); in otp_prog_image()
1973 image_layout.scu_pro = buf + OTP_REGION_OFFSET(otp_header->scu_protect_info); in otp_prog_image()
1974 image_layout.scu_pro_length = (int)(OTP_REGION_SIZE(otp_header->scu_protect_info) / 2); in otp_prog_image()
1977 if (otp_header->soc_ver == SOC_AST2600A0) { in otp_prog_image()
1979 } else if (otp_header->soc_ver == SOC_AST2600A1) { in otp_prog_image()
1981 } else if (otp_header->soc_ver == SOC_AST2600A2) { in otp_prog_image()
1983 } else if (otp_header->soc_ver == SOC_AST2600A3) { in otp_prog_image()
1995 switch (OTPTOOL_VERSION_MAJOR(otp_header->otptool_ver)) { in otp_prog_image()
1997 printf("WARNING: OTP image is not generated by otptool v2.x.x\n"); in otp_prog_image()
1998 printf("Please use the latest version of otptool to generate OTP image\n"); in otp_prog_image()
2005 printf("OTP image version is not supported\n"); in otp_prog_image()
2015 printf("OTP memory is locked\n"); in otp_prog_image()
2019 if (otp_header->image_info & OTP_INC_DATA) { in otp_prog_image()
2021 printf("OTP data region is protected\n"); in otp_prog_image()
2022 ret = -1; in otp_prog_image()
2025 printf("OTP secure region is protected\n"); in otp_prog_image()
2026 ret = -1; in otp_prog_image()
2028 printf("Read OTP Data Region:\n"); in otp_prog_image()
2034 ret = -1; in otp_prog_image()
2036 if (otp_header->image_info & OTP_INC_CONFIG) { in otp_prog_image()
2038 printf("OTP config region is protected\n"); in otp_prog_image()
2039 ret = -1; in otp_prog_image()
2041 printf("Read OTP Config Region:\n"); in otp_prog_image()
2047 ret = -1; in otp_prog_image()
2049 if (otp_header->image_info & OTP_INC_STRAP) { in otp_prog_image()
2051 printf("OTP strap region is protected\n"); in otp_prog_image()
2052 ret = -1; in otp_prog_image()
2054 printf("Read OTP Strap Region:\n"); in otp_prog_image()
2059 ret = -1; in otp_prog_image()
2061 if (otp_header->image_info & OTP_INC_SCU_PRO) { in otp_prog_image()
2063 printf("OTP strap region is protected\n"); in otp_prog_image()
2064 ret = -1; in otp_prog_image()
2072 ret = -1; in otp_prog_image()
2074 if (ret == -1) in otp_prog_image()
2078 if (otp_header->image_info & OTP_INC_DATA) { in otp_prog_image()
2081 printf("OTP data error, please check.\n"); in otp_prog_image()
2085 if (otp_header->image_info & OTP_INC_CONFIG) { in otp_prog_image()
2088 printf("OTP config error, please check.\n"); in otp_prog_image()
2092 if (otp_header->image_info & OTP_INC_STRAP) { in otp_prog_image()
2095 printf("OTP strap error, please check.\n"); in otp_prog_image()
2099 if (otp_header->image_info & OTP_INC_SCU_PRO) { in otp_prog_image()
2102 printf("OTP scu protect error, please check.\n"); in otp_prog_image()
2114 if (otp_header->image_info & OTP_INC_DATA) { in otp_prog_image()
2123 if (otp_header->image_info & OTP_INC_STRAP) { in otp_prog_image()
2132 if (otp_header->image_info & OTP_INC_SCU_PRO) { in otp_prog_image()
2141 if (otp_header->image_info & OTP_INC_CONFIG) { in otp_prog_image()
2177 printf("OTP is programmed, which can't be clean\n"); in otp_prog_bit()
2191 printf("OTP is programmed, which can't be cleared\n"); in otp_prog_bit()
2195 otp_read_data(otp_dw_offset - 1, read); in otp_prog_bit()
2200 printf("OTP is programmed, which can't be written\n"); in otp_prog_bit()
2243 printf("OTP cannot be programmed\n"); in otp_prog_bit()
2284 printf("Current OTP revision ID cannot handle by this command,\n" in otp_update_rid()
2285 "please use 'otp pb' command to update it manually\n"); in otp_update_rid()
2290 printf("current OTP revision ID: 0x%x\n", rid_num); in otp_update_rid()
2295 printf("OTP rev_id is bigger than 0x%X\n", update_num); in otp_update_rid()
2299 printf("OTP rev_id is same as input\n"); in otp_update_rid()
2310 bit_offset = i - 32; in otp_update_rid()
2333 bit_offset = i - 32; in otp_update_rid()
2346 printf("OTP revision ID: 0x%x\n", rid_num); in otp_update_rid()
2348 printf("OTP revision ID\n"); in otp_update_rid()
2433 si->enc_flag = (cfg0 >> 27) & 0x1; in parse_config()
2437 si->secure_region = 1; in parse_config()
2439 si->secure_region = 0; in parse_config()
2441 si->header_offset = cfg3 & 0xffff; in parse_config()
2442 if (si->header_offset == 0) in parse_config()
2443 si->header_offset = 0x20; in parse_config()
2447 si->retire_list[i] = 1; in parse_config()
2449 si->retire_list[i] = 0; in parse_config()
2457 if (si->enc_flag) in parse_config()
2466 si->rsa_algo = 1024; in parse_config()
2469 si->rsa_algo = 2048; in parse_config()
2472 si->rsa_algo = 3072; in parse_config()
2475 si->rsa_algo = 4096; in parse_config()
2479 si->sha_algo = 224; in parse_config()
2480 si->digest_len = 28; in parse_config()
2483 si->sha_algo = 256; in parse_config()
2484 si->digest_len = 32; in parse_config()
2487 si->sha_algo = 384; in parse_config()
2488 si->digest_len = 48; in parse_config()
2491 si->sha_algo = 512; in parse_config()
2492 si->digest_len = 64; in parse_config()
2516 if (si->retire_list[id] == 1) in parse_data()
2531 switch (si->sha_algo) { in sb_sha()
2533 printf("otp verify does not support SHA224\n"); in sb_sha()
2562 u32 rsa_len = si->rsa_algo / 8; in mode2_verify()
2572 rsa_m_rev[i] = rsa_m[rsa_len - 1 - i]; in mode2_verify()
2573 signature_rev[i] = signature[rsa_len - 1 - i]; in mode2_verify()
2576 prop.num_bits = si->rsa_algo; in mode2_verify()
2582 prop.num_bits = si->rsa_algo; in mode2_verify()
2596 sign_ret[i] = sign_ret[rsa_len - 1 - i]; in mode2_verify()
2597 sign_ret[rsa_len - 1 - i] = tmp; in mode2_verify()
2599 ret = memcmp(digest, sign_ret, si->digest_len); in mode2_verify()
2601 ret = memcmp(digest, sign_ret + (rsa_len - si->digest_len), si->digest_len); in mode2_verify()
2645 signature = sec_image + sh->signature_offset; in otp_verify_boot_image()
2648 printf("WARNING: Secure Region is enabled, the verification may not correct.\n"); in otp_verify_boot_image()
2650 if (sh->sign_image_size % 512) { in otp_verify_boot_image()
2657 sw_rid[0] = sh->revision_low; in otp_verify_boot_image()
2658 sw_rid[1] = sh->revision_high; in otp_verify_boot_image()
2662 printf("Header revision_low: %x\n", sh->revision_low); in otp_verify_boot_image()
2663 printf("Header revision_high: %x\n", sh->revision_high); in otp_verify_boot_image()
2664 printf("OTP revision_low: %x\n", otp_rid[0]); in otp_verify_boot_image()
2665 printf("OTP revision_high: %x\n", otp_rid[1]); in otp_verify_boot_image()
2670 printf("Check secure image header: "); in otp_verify_boot_image()
2671 if (((sh->aes_data_offset + sh->enc_offset + sh->sign_image_size + in otp_verify_boot_image()
2672 sh->signature_offset + sh->revision_high + sh->revision_low + in otp_verify_boot_image()
2673 sh->reserved + sh->bl1_header_checksum) & 0xffffffff) != 0) { in otp_verify_boot_image()
2675 printf("aes_data_offset: %x\n", sh->aes_data_offset); in otp_verify_boot_image()
2676 printf("enc_offset: %x\n", sh->enc_offset); in otp_verify_boot_image()
2677 printf("sign_image_size: %x\n", sh->sign_image_size); in otp_verify_boot_image()
2678 printf("signature_offset: %x\n", sh->signature_offset); in otp_verify_boot_image()
2679 printf("revision_high: %x\n", sh->revision_high); in otp_verify_boot_image()
2680 printf("revision_low: %x\n", sh->revision_low); in otp_verify_boot_image()
2681 printf("reserved: %x\n", sh->reserved); in otp_verify_boot_image()
2682 printf("bl1_header_checksum: %x\n", sh->bl1_header_checksum); in otp_verify_boot_image()
2687 ret = sb_sha(&si, sec_image, sh->sign_image_size, digest); in otp_verify_boot_image()
2691 printf("Verifying secure image\n"); in otp_verify_boot_image()
2693 if (kl[i].key_info->key_type != OTP_KEY_TYPE_RSA_PUB) in otp_verify_boot_image()
2701 if (!mode2_verify(sec_image, sh->sign_image_size, in otp_verify_boot_image()
2702 signature, key, kl[i].key_info->order, digest, in otp_verify_boot_image()
2711 if (kl[i].key_info->order == OTP_BIG_END) in otp_verify_boot_image()
2715 printf("Verify secure image: PASS\n"); in otp_verify_boot_image()
2718 printf("Verify secure image: FAIL\n"); in otp_verify_boot_image()
2834 argc--; in do_otppb()
2847 argc--; in do_otppb()
2853 argc--; in do_otppb()
2881 printf("OTP memory is locked\n"); in do_otppb()
2887 printf("OTP data region is protected\n"); in do_otppb()
2888 ret = -1; in do_otppb()
2891 printf("OTP secure region is not readable, skip it to prevent unpredictable result\n"); in do_otppb()
2892 ret = -1; in do_otppb()
2894 // header region(0x0~0x40) is still readable even secure region is set. in do_otppb()
2896 printf("OTP secure region is protected\n"); in do_otppb()
2897 ret = -1; in do_otppb()
2900 printf("OTP data region is protected\n"); in do_otppb()
2901 ret = -1; in do_otppb()
2906 printf("OTP config region is protected\n"); in do_otppb()
2907 ret = -1; in do_otppb()
2927 ret = -1; in do_otppb()
2932 ret = -1; in do_otppb()
2941 retire = bit_offset - 16; in do_otppb()
2946 ret = -1; in do_otppb()
2952 printf("OTP strap region is protected\n"); in do_otppb()
2953 ret = -1; in do_otppb()
2962 ret = -1; in do_otppb()
2969 printf("OTP strap region is protected\n"); in do_otppb()
2970 ret = -1; in do_otppb()
2974 if (ret == -1) in do_otppb()
3020 otp_print_conf_info(-1); in do_otpinfo()
3026 argc--; in do_otpinfo()
3064 bit_offset = input - 32; in do_otpprotect()
3071 printf("OTP strap region is protected\n"); in do_otpprotect()
3134 printf("OTP strap region is protected\n"); in do_otp_scuprotect()
3166 printf("SOC OTP version: %s\n", info_cb.ver_name); in do_otpver()
3167 printf("OTP tool version: %s\n", OTP_VER); in do_otpver()
3168 printf("OTP info version: %s\n", OTP_INFO_VER); in do_otpver()
3227 printf("current OTP revision ID: 0x%x\n", rid_num); in do_otprid()
3230 printf("Current OTP revision ID cannot handle by 'otp update',\n" in do_otprid()
3231 "please use 'otp pb' command to update it manually\n" in do_otprid()
3232 "current OTP revision ID\n"); in do_otprid()
3338 /* Drop the otp command */ in do_ast_otp()
3339 argc--; in do_ast_otp()
3342 if (!cp || argc > cp->maxargs) in do_ast_otp()
3404 pro_sts->mem_lock = (otp_conf0 >> 31) & 0x1; in do_ast_otp()
3405 pro_sts->pro_key_ret = (otp_conf0 >> 29) & 0x1; in do_ast_otp()
3406 pro_sts->pro_strap = (otp_conf0 >> 25) & 0x1; in do_ast_otp()
3407 pro_sts->pro_conf = (otp_conf0 >> 24) & 0x1; in do_ast_otp()
3408 pro_sts->pro_data = (otp_conf0 >> 23) & 0x1; in do_ast_otp()
3409 pro_sts->pro_sec = (otp_conf0 >> 22) & 0x1; in do_ast_otp()
3410 pro_sts->sec_size = ((otp_conf0 >> 16) & 0x3f) << 5; in do_ast_otp()
3412 ret = cp->cmd(cmdtp, flag, argc, argv); in do_ast_otp()
3413 writel(1, OTP_PROTECT_KEY); //protect otp controller in do_ast_otp()
3418 U_BOOT_CMD(otp, 7, 0, do_ast_otp,
3419 "ASPEED One-Time-Programmable sub-system",
3421 "otp read conf|data <otp_dw_offset> <dw_count>\n"
3422 "otp read strap <strap_bit_offset> <bit_count>\n"
3423 "otp info strap [v]\n"
3424 "otp info conf [otp_dw_offset]\n"
3425 "otp info scu\n"
3426 "otp info key\n"
3427 "otp prog [o] <addr>\n"
3428 "otp pb conf|data [o] <otp_dw_offset> <bit_offset> <value>\n"
3429 "otp pb strap [o] <bit_offset> <value>\n"
3430 "otp protect [o] <bit_offset>\n"
3431 "otp scuprotect [o] <scu_offset> <bit_offset>\n"
3432 "otp update [o] <revision_id>\n"
3433 "otp rid\n"
3434 "otp retire [o] <key_id>\n"
3435 "otp verify <addr>\n"
3436 "otp invalid [o] <header_offset>\n"