mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-24 12:03:39 +00:00
5135db4d8b
We have two commands to change the bootmode fuses: mfgr_fuse which set fuse 0/5 and 0/6 and updt_fuse which burns bit 4 of 0/5. Before BSP 2.6 we fused in mfgr_fuse 0x5062, which boots from the user partition of the eMMC. To workaround certain hangs we moved to fastboot mode and using the first bootpartition of the eMMC requiring a fuse value of 0x5072 which could be achieved by the then added updt_fuse command. At the same time the mfgr_fuse command was changed to also fuse 0x5072, revert that second change so that one can fuse both values, one with just mfgr_fuse and the later with mfgr_fuse;updt_fuse. Note that the mfgr_fuse command is only needed at module production time, a customer might need to use updt_fuse when upgrading an older module to be compatible with a newer image. The command is integrated into the image update scripts. Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> Acked-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
97 lines
2.1 KiB
C
97 lines
2.1 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2014-2016, Toradex AG
|
|
*/
|
|
|
|
/*
|
|
* Helpers for i.MX OTP fusing during module production
|
|
*/
|
|
|
|
#include <common.h>
|
|
#ifndef CONFIG_SPL_BUILD
|
|
#include <console.h>
|
|
#include <fuse.h>
|
|
|
|
static int mfgr_fuse(void)
|
|
{
|
|
unsigned val, val6;
|
|
|
|
fuse_sense(0, 5, &val);
|
|
printf("Fuse 0, 5: %8x\n", val);
|
|
fuse_sense(0, 6, &val6);
|
|
printf("Fuse 0, 6: %8x\n", val6);
|
|
fuse_sense(4, 3, &val);
|
|
printf("Fuse 4, 3: %8x\n", val);
|
|
fuse_sense(4, 2, &val);
|
|
printf("Fuse 4, 2: %8x\n", val);
|
|
if (val6 & 0x10) {
|
|
puts("BT_FUSE_SEL already fused, will do nothing\n");
|
|
return CMD_RET_FAILURE;
|
|
}
|
|
/* boot cfg */
|
|
fuse_prog(0, 5, 0x00005062);
|
|
/* BT_FUSE_SEL */
|
|
fuse_prog(0, 6, 0x00000010);
|
|
return CMD_RET_SUCCESS;
|
|
}
|
|
|
|
int do_mfgr_fuse(cmd_tbl_t *cmdtp, int flag, int argc,
|
|
char * const argv[])
|
|
{
|
|
int ret;
|
|
puts("Fusing...\n");
|
|
ret = mfgr_fuse();
|
|
if (ret == CMD_RET_SUCCESS)
|
|
puts("done.\n");
|
|
else
|
|
puts("failed.\n");
|
|
return ret;
|
|
}
|
|
|
|
int do_updt_fuse(cmd_tbl_t *cmdtp, int flag, int argc,
|
|
char * const argv[])
|
|
{
|
|
unsigned val;
|
|
int ret;
|
|
int confirmed = argc >= 1 && !strcmp(argv[1], "-y");
|
|
|
|
/* can be used in scripts for command availability check */
|
|
if (argc >= 1 && !strcmp(argv[1], "-n"))
|
|
return CMD_RET_SUCCESS;
|
|
|
|
/* boot cfg */
|
|
fuse_sense(0, 5, &val);
|
|
printf("Fuse 0, 5: %8x\n", val);
|
|
if (val & 0x10) {
|
|
puts("Fast boot mode already fused, no need to fuse\n");
|
|
return CMD_RET_SUCCESS;
|
|
}
|
|
if (!confirmed) {
|
|
puts("Warning: Programming fuses is an irreversible operation!\n"
|
|
" Updating to fast boot mode prevents easy\n"
|
|
" downgrading to previous BSP versions.\n"
|
|
"\nReally perform this fuse programming? <y/N>\n");
|
|
if (!confirm_yesno())
|
|
return CMD_RET_FAILURE;
|
|
}
|
|
puts("Fusing fast boot mode...\n");
|
|
ret = fuse_prog(0, 5, 0x00005072);
|
|
if (ret == CMD_RET_SUCCESS)
|
|
puts("done.\n");
|
|
else
|
|
puts("failed.\n");
|
|
return ret;
|
|
}
|
|
|
|
U_BOOT_CMD(
|
|
mfgr_fuse, 1, 0, do_mfgr_fuse,
|
|
"OTP fusing during module production",
|
|
""
|
|
);
|
|
|
|
U_BOOT_CMD(
|
|
updt_fuse, 2, 0, do_updt_fuse,
|
|
"OTP fusing during module update",
|
|
"updt_fuse [-n] [-y] - boot cfg fast boot mode fusing"
|
|
);
|
|
#endif /* CONFIG_SPL_BUILD */
|