Pavona Software APIs
flash_macro_wrapper.c
Go to the documentation of this file.
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// Device table API auto-generated by `dtgen`
6
7/**
8 * @file
9 * @brief Device Tables (DT) for IP flash_macro_wrapper and top scafi_deprecated.
10 */
11
12#include "hw/top/dt/flash_macro_wrapper.h"
13
14
15
16/**
17 * Description of instances.
18 */
19typedef struct dt_desc_flash_macro_wrapper {
20 dt_instance_id_t inst_id; /**< Instance ID */
21 uint32_t reg_addr[kDtFlashMacroWrapperRegBlockCount]; /**< Base address of each register block */
22 dt_clock_t clock[kDtFlashMacroWrapperClockCount]; /**< Clock signal connected to each clock port */
23 dt_reset_t reset[kDtFlashMacroWrapperResetCount]; /**< Reset signal connected to each reset port */
24 dt_periph_io_t periph_io[kDtFlashMacroWrapperPeriphIoCount]; /**< Description of each peripheral I/O */
26
27
28
29
30static const dt_desc_flash_macro_wrapper_t flash_macro_wrapper_desc[kDtFlashMacroWrapperCount] = {
33 .reg_addr = {
34 [kDtFlashMacroWrapperRegBlockCore] = 0x41008000,
35 },
36 .clock = {
38 },
39 .reset = {
41 },
42 .periph_io = {
43 [kDtFlashMacroWrapperPeriphIoTck] = {
44 .__internal = {
47 .periph_input_or_direct_pad = 0,
48 .outsel_or_dt_pad = 0,
49 },
50 },
51 [kDtFlashMacroWrapperPeriphIoTms] = {
52 .__internal = {
55 .periph_input_or_direct_pad = 0,
56 .outsel_or_dt_pad = 0,
57 },
58 },
59 [kDtFlashMacroWrapperPeriphIoTdi] = {
60 .__internal = {
63 .periph_input_or_direct_pad = 0,
64 .outsel_or_dt_pad = 0,
65 },
66 },
67 [kDtFlashMacroWrapperPeriphIoTdo] = {
68 .__internal = {
71 .periph_input_or_direct_pad = 0,
72 .outsel_or_dt_pad = 0,
73 },
74 },
75 },
76 },
77};
78
79/**
80 * Return a pointer to the `dt_flash_macro_wrapper_desc_t` structure of the requested
81 * `dt` if it's a valid index. Otherwise, this macro will `return` (i.e. exit
82 * the function) with the provided default value.
83 */
84#define TRY_GET_DT(dt, default) ({ if ((dt) < (dt_flash_macro_wrapper_t)0 || (int)(dt) >= kDtFlashMacroWrapperCount) return (default); &flash_macro_wrapper_desc[dt]; })
85
92
97
101 // Return a recognizable address in case of wrong argument.
102 return TRY_GET_DT(dt, 0xdeadbeef)->reg_addr[reg_block];
103}
104
105
106
110 // Return a harmless value in case of wrong argument.
111 return TRY_GET_DT(dt, kDtPeriphIoConstantHighZ)->periph_io[sig];
112}
113
117 // Return the first clock in case of invalid argument.
118 return TRY_GET_DT(dt, (dt_clock_t)0)->clock[clk];
119}
120
130
131