1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/*
* Copyright (C) 2014, Toradex AG
*
* SPDX-License-Identifier: GPL-2.0+
*/
/*
* Helpers for i.MX OTP fusing during module production
*/
#include <common.h>
#include <fuse.h>
static unsigned mfgr_fuse(void);
unsigned mfgr_fuse(void)
{
unsigned val, val6;
unsigned mac_hi, mac_lo;
uchar mac_id[6];
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 1;
}
if (!eth_getenv_enetaddr("ethaddr", mac_id))
{
puts("ethaddr not set or not valid in environment, will do nothing\n");
return 1;
}
mac_hi = (mac_id[0] << 8) + mac_id[1];
mac_lo = (mac_id[2] << 24) + (mac_id[3] << 16) + (mac_id[4] << 8) + mac_id[5];
/* boot cfg */
fuse_prog(0, 5, 0x00005062);
/* BT_FUSE_SEL */
fuse_prog(0, 6, 0x00000010);
/* MAC addr */
fuse_prog(4, 3, mac_hi);
fuse_prog(4, 2, mac_lo);
return 0;
}
int do_mfgr_fuse(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
puts("Fusing...\n");
if(!mfgr_fuse())
puts("done.\n");
else
puts("failed.\n");
return 0;
}
U_BOOT_CMD(
mfgr_fuse, 1, 0, do_mfgr_fuse,
"OTP fusing during module production\n"
"requires the environment variable ethaddr to be set\n",
""
);
|