1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /*
8  * Factory information configuration registers
9  */
10 
11 /*
12  * TOLOW: we start with most registers cleared, and a few evident ones set to some values.
13  * It could be interesting to let people load them from command line
14  * for example by specifying a file with their values. and/or by specifying particular ones
15  * with command line options; something like -deviceaddr=<bt_address>
16  */
17 
18 #include <string.h>
19 #include "bs_rand_main.h"
20 #include "nsi_tasks.h"
21 #include "NHW_common_types.h"
22 #include "NHW_config.h"
23 #include "NHW_peri_types.h"
24 #include "weak_stubs.h"
25 
26 NRF_FICR_Type NRF_FICR_regs;
27 
nhw_54l_ficr_init(void)28 static void nhw_54l_ficr_init(void) {
29   memset(&NRF_FICR_regs, 0xFF, sizeof(NRF_FICR_regs));
30 
31   NRF_FICR_regs.INFO.DEVICEID[0] = (bs_random_uint32() & 0xFFFFFF00) + bsim_args_get_global_device_nbr();
32   NRF_FICR_regs.INFO.DEVICEID[1] = bs_random_uint32();
33   //NRF_FICR_regs.INFO.PART = 0x5415;
34   NRF_FICR_regs.INFO.RRAM = 0x5F4; /*1524 KB*/
35   //NRF_FICR_regs.INFO.DEVICETYPE = 0;
36   for (int i = 0; i < 4; i++) {
37     NRF_FICR_regs.ER[i] = bs_random_uint32();
38     NRF_FICR_regs.IR[i] = bs_random_uint32();
39   }
40   NRF_FICR_regs.DEVICEADDRTYPE = 0;
41   NRF_FICR_regs.DEVICEADDR[0] = bs_random_uint32();
42   NRF_FICR_regs.DEVICEADDR[1] = bs_random_uint32();
43 }
44 
45 NSI_TASK(nhw_54l_ficr_init, HW_INIT, 100);
46