Software APIs
dt_rv_plic.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 rv_plic and top englishbreakfast.
10 */
11
12#include "dt/dt_rv_plic.h"
13
14
15
16/**
17 * Description of instances.
18 */
19typedef struct dt_desc_rv_plic {
20 dt_instance_id_t inst_id; /**< Instance ID */
21 uint32_t base_addr[kDtRvPlicRegBlockCount]; /**< Base address of each register block */
22 dt_clock_t clock[kDtRvPlicClockCount]; /**< Clock signal connected to each clock port */
23 dt_reset_t reset[kDtRvPlicResetCount]; /**< Reset signal connected to each reset port */
25
26
27
28
29static const dt_desc_rv_plic_t rv_plic_desc[kDtRvPlicCount] = {
30 [kDtRvPlic] = {
31 .inst_id = kDtInstanceIdRvPlic,
32 .base_addr = {
33 [kDtRvPlicRegBlockCore] = 0x48000000,
34 },
35 .clock = {
37 },
38 .reset = {
40 },
41 },
42};
43
44/**
45 * Return a pointer to the `dt_rv_plic_desc_t` structure of the requested
46 * `dt` if it's a valid index. Otherwise, this macro will `return` (i.e. exit
47 * the function) with the provided default value.
48 */
49#define TRY_GET_DT(dt, default) ({ if ((dt) < (dt_rv_plic_t)0 || (dt) >= kDtRvPlicCount) return (default); &rv_plic_desc[dt]; })
50
52 if (inst_id >= kDtInstanceIdRvPlic && inst_id <= kDtInstanceIdRvPlic) {
53 return (dt_rv_plic_t)(inst_id - kDtInstanceIdRvPlic);
54 }
55 return (dt_rv_plic_t)0;
56}
57
62
64 dt_rv_plic_t dt,
65 dt_rv_plic_reg_block_t reg_block) {
66 // Return a recognizable address in case of wrong argument.
67 return TRY_GET_DT(dt, 0xdeadbeef)->base_addr[reg_block];
68}
69
70
71
72
74 dt_rv_plic_t dt,
76 // Return the first clock in case of invalid argument.
77 return TRY_GET_DT(dt, (dt_clock_t)0)->clock[clk];
78}
79
81 dt_rv_plic_t dt,
83 const dt_rv_plic_reset_t count = kDtRvPlicResetCount;
84 if (rst >= count) {
85 return kDtResetUnknown;
86 }
87 return TRY_GET_DT(dt, kDtResetUnknown)->reset[rst];
88}
89
90