Software APIs
rram_macro.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 rram_macro and top earlgrey.
10 */
11
13
14
15
16/**
17 * Description of instances.
18 */
19typedef struct dt_desc_rram_macro {
20 dt_instance_id_t inst_id; /**< Instance ID */
21 uint32_t reg_addr[kDtRramMacroRegBlockCount]; /**< Base address of each register block */
22 dt_clock_t clock[kDtRramMacroClockCount]; /**< Clock signal connected to each clock port */
23 dt_reset_t reset[kDtRramMacroResetCount]; /**< Reset signal connected to each reset port */
24 dt_periph_io_t periph_io[kDtRramMacroPeriphIoCount]; /**< Description of each peripheral I/O */
26
27
28
29
30static const dt_desc_rram_macro_t rram_macro_desc[kDtRramMacroCount] = {
31 [kDtRramMacro] = {
32 .inst_id = kDtInstanceIdRramMacro,
33 .reg_addr = {
34 [kDtRramMacroRegBlockPrim] = 0x41018000,
35 },
36 .clock = {
38 },
39 .reset = {
41 },
42 .periph_io = {
43 [kDtRramMacroPeriphIoTck] = {
44 .__internal = {
45 .type = kDtPeriphIoTypeMio,
46 .dir = kDtPeriphIoDirIn,
47 .periph_input_or_direct_pad = kTopEarlgreyPinmuxPeripheralInRramMacroTck,
48 .outsel_or_dt_pad = 0,
49 },
50 },
51 [kDtRramMacroPeriphIoTms] = {
52 .__internal = {
53 .type = kDtPeriphIoTypeMio,
54 .dir = kDtPeriphIoDirIn,
55 .periph_input_or_direct_pad = kTopEarlgreyPinmuxPeripheralInRramMacroTms,
56 .outsel_or_dt_pad = 0,
57 },
58 },
59 [kDtRramMacroPeriphIoTdi] = {
60 .__internal = {
61 .type = kDtPeriphIoTypeMio,
62 .dir = kDtPeriphIoDirIn,
63 .periph_input_or_direct_pad = kTopEarlgreyPinmuxPeripheralInRramMacroTdi,
64 .outsel_or_dt_pad = 0,
65 },
66 },
67 [kDtRramMacroPeriphIoTdo] = {
68 .__internal = {
69 .type = kDtPeriphIoTypeMio,
70 .dir = kDtPeriphIoDirOut,
71 .periph_input_or_direct_pad = 0,
72 .outsel_or_dt_pad = kTopEarlgreyPinmuxOutselRramMacroTdo,
73 },
74 },
75 },
76 },
77};
78
79/**
80 * Return a pointer to the `dt_rram_macro_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_rram_macro_t)0 || (int)(dt) >= kDtRramMacroCount) return (default); &rram_macro_desc[dt]; })
85
92
97
100 dt_rram_macro_reg_block_t reg_block) {
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
125 if (rst >= count) {
126 return kDtResetUnknown;
127 }
128 return TRY_GET_DT(dt, kDtResetUnknown)->reset[rst];
129}
130
131