Software APIs
sw
device
tests
sim_dv
otp_ctrl_vendor_test_csr_access_test.c
1
// Copyright lowRISC contributors (OpenTitan project).
2
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3
// SPDX-License-Identifier: Apache-2.0
4
5
#include "
sw/device/lib/base/memory.h
"
6
#include "
sw/device/lib/base/mmio.h
"
7
#include "
sw/device/lib/dif/dif_lc_ctrl.h
"
8
#include "
sw/device/lib/dif/dif_otp_ctrl.h
"
9
#include "
sw/device/lib/runtime/log.h
"
10
#include "sw/device/lib/testing/test_framework/check.h"
11
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
12
#include "
sw/device/silicon_creator/lib/base/chip.h
"
13
14
#include "
hw/top_earlgrey/sw/autogen/top_earlgrey.h
"
15
16
static
dif_lc_ctrl_t lc;
17
static
dif_otp_ctrl_t otp;
18
19
OTTF_DEFINE_TEST_CONFIG();
20
21
static
void
init_peripherals(
void
) {
22
dif_otp_ctrl_config_t
config = {
23
.
check_timeout
= 100000,
24
.integrity_period_mask = 0x3ffff,
25
.consistency_period_mask = 0x3ffffff,
26
};
27
// Life cycle
28
CHECK_DIF_OK(dif_lc_ctrl_init(
29
mmio_region_from_addr
(
TOP_EARLGREY_LC_CTRL_REGS_BASE_ADDR
), &lc));
30
// OTP
31
CHECK_DIF_OK(dif_otp_ctrl_init(
32
mmio_region_from_addr
(
TOP_EARLGREY_OTP_CTRL_CORE_BASE_ADDR
), &otp));
33
CHECK_DIF_OK(
dif_otp_ctrl_configure
(&otp, config));
34
}
35
36
/**
37
* A simple SW test to enable OTP_CTRL and LC_CTRL.
38
* The main sequence is driven by JTAG agent in SV sequence
39
* `chip_sw_otp_ctrl_vendor_test_csr_access_vseq.sv`.
40
*/
41
bool
test_main
(
void
) {
42
init_peripherals();
43
// This is an anker for sv wait
44
LOG_INFO
(
"init peripheral is done"
);
45
return
true
;
46
}
Return to
OpenTitan Documentation