File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed
sw/device/silicon_creator/lib/drivers Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,21 @@ cc_test(
137137 ],
138138)
139139
140+ cc_library (
141+ name = "clkmgr" ,
142+ srcs = ["clkmgr.c" ],
143+ hdrs = [
144+ "clkmgr.h" ,
145+ ],
146+ deps = [
147+ "//hw/top:dt_clkmgr" ,
148+ "//sw/device/lib/base:abs_mmio" ,
149+ "//sw/device/lib/base:hardened" ,
150+ "//sw/device/lib/base:macros" ,
151+ "//sw/device/lib/base:multibits" ,
152+ ],
153+ )
154+
140155dual_cc_library (
141156 name = "flash_ctrl" ,
142157 srcs = dual_inputs (
Original file line number Diff line number Diff line change 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/silicon_creator/lib/drivers/clkmgr.h"
6+
7+ #include "hw/top/dt/dt_clkmgr.h"
8+ #include "sw/device/lib/base/abs_mmio.h"
9+ #include "sw/device/lib/base/multibits.h"
10+
11+ #include "hw/top/clkmgr_regs.h"
12+
13+ // Module ID for status codes.
14+ #define MODULE_ID MAKE_MODULE_ID('c', 'l', 'k')
15+
16+ hardened_bool_t clkmgr_check_jittery_clk_en (void ) {
17+ uintptr_t clkmgr_base_addr = dt_clkmgr_primary_reg_block (kDtClkmgrAon );
18+ uint32_t jittery_clk_en =
19+ abs_mmio_read32 (clkmgr_base_addr + CLKMGR_JITTER_ENABLE_REG_OFFSET );
20+
21+ // Check that the jittery clock is set to kMultiBitBool4True
22+ if (launder32 (jittery_clk_en ) != kMultiBitBool4True ) {
23+ return kHardenedBoolFalse ;
24+ }
25+ HARDENED_CHECK_EQ (jittery_clk_en , kMultiBitBool4True );
26+
27+ return kHardenedBoolTrue ;
28+ }
Original file line number Diff line number Diff line change 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+ #ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_CLKMGR_H_
6+ #define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_CLKMGR_H_
7+
8+ #include <stdbool.h>
9+ #include <stddef.h>
10+ #include <stdint.h>
11+
12+ #include "sw/device/lib/base/hardened.h"
13+ #include "sw/device/lib/base/macros.h"
14+
15+ #ifdef __cplusplus
16+ extern "C" {
17+ #endif
18+
19+ /**
20+ * Checks if the JITTER_ENABLE register of the CLKMGR is set to on.
21+ *
22+ * @return Whether the jittery clock is enabled.
23+ */
24+ OT_WARN_UNUSED_RESULT
25+ hardened_bool_t clkmgr_check_jittery_clk_en (void );
26+
27+ #ifdef __cplusplus
28+ }
29+ #endif
30+
31+ #endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_CLKMGR_H_
You can’t perform that action at this time.
0 commit comments