Software APIs
dt_aes.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 aes and top englishbreakfast.
10 */
11
12#include "dt/dt_aes.h"
13
14
15
16/**
17 * Description of instances.
18 */
19typedef struct dt_desc_aes {
20 dt_instance_id_t inst_id; /**< Instance ID */
21 uint32_t base_addr[kDtAesRegBlockCount]; /**< Base address of each register block */
22 dt_clock_t clock[kDtAesClockCount]; /**< Clock signal connected to each clock port */
23 dt_reset_t reset[kDtAesResetCount]; /**< Reset signal connected to each reset port */
25
26
27
28
29static const dt_desc_aes_t aes_desc[kDtAesCount] = {
30 [kDtAes] = {
31 .inst_id = kDtInstanceIdAes,
32 .base_addr = {
33 [kDtAesRegBlockCore] = 0x41100000,
34 },
35 .clock = {
38 },
39 .reset = {
42 },
43 },
44};
45
46/**
47 * Return a pointer to the `dt_aes_desc_t` structure of the requested
48 * `dt` if it's a valid index. Otherwise, this macro will `return` (i.e. exit
49 * the function) with the provided default value.
50 */
51#define TRY_GET_DT(dt, default) ({ if ((dt) < (dt_aes_t)0 || (dt) >= kDtAesCount) return (default); &aes_desc[dt]; })
52
54 if (inst_id >= kDtInstanceIdAes && inst_id <= kDtInstanceIdAes) {
55 return (dt_aes_t)(inst_id - kDtInstanceIdAes);
56 }
57 return (dt_aes_t)0;
58}
59
64
66 dt_aes_t dt,
67 dt_aes_reg_block_t reg_block) {
68 // Return a recognizable address in case of wrong argument.
69 return TRY_GET_DT(dt, 0xdeadbeef)->base_addr[reg_block];
70}
71
72
73
74
76 dt_aes_t dt,
77 dt_aes_clock_t clk) {
78 // Return the first clock in case of invalid argument.
79 return TRY_GET_DT(dt, (dt_clock_t)0)->clock[clk];
80}
81
83 dt_aes_t dt,
84 dt_aes_reset_t rst) {
85 const dt_aes_reset_t count = kDtAesResetCount;
86 if (rst >= count) {
87 return kDtResetUnknown;
88 }
89 return TRY_GET_DT(dt, kDtResetUnknown)->reset[rst];
90}
91
92