1 /*
2  * Copyright (c) 2023-2024, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __NI_TOWER_DRV_H__
9 #define __NI_TOWER_DRV_H__
10 
11 #include <stdint.h>
12 
13 /**
14  * \brief NI-Tower error enumeration types
15  */
16 enum ni_tower_err {
17     NI_TOWER_SUCCESS,
18     NI_TOWER_ERR_INVALID_ARG,
19     NI_TOWER_ERR_NOT_FOUND,
20     NI_TOWER_DEVICE_INVALID,
21     NI_TOWER_ERR_NOT_PERMITTED,
22     NI_TOWER_ERR_REGION_OVERLAPS,
23     NI_TOWER_ERR
24 };
25 
26 /**
27  * \brief NI-Tower node type value enumerations
28  */
29 enum ni_tower_node_type_value {
30     /* Domains */
31     NI_TOWER_CFGNI = 0x0,
32     NI_TOWER_VD,
33     NI_TOWER_PD,
34     NI_TOWER_CD,
35     /* Components */
36     NI_TOWER_ASNI,
37     NI_TOWER_AMNI,
38     NI_TOWER_PMU,
39     NI_TOWER_HSNI,
40     NI_TOWER_HMNI,
41     NI_TOWER_PMNI
42 };
43 
44 /**
45  * \brief NI-Tower subfeature type value enumerations
46  */
47 enum ni_tower_subfeature_type_value {
48     NI_TOWER_APU = 0x0,
49     NI_TOWER_PSAM,
50     NI_TOWER_FCU,
51     NI_TOWER_IDM
52 };
53 
54 /**
55  * \brief NI-Tower configuration node granularity enumeration
56  */
57 enum ni_tower_granularity {
58     NI_TOWER_4KB_CONFIG_NODES,
59     NI_TOWER_64KB_CONFIG_NODES,
60 };
61 
62 /**
63  * \brief NI-Tower component node structure
64  */
65 struct ni_tower_component_node{
66     /* Component type of the node */
67     const enum ni_tower_node_type_value type;
68     /* Component id of the node */
69     const uint32_t id;
70 };
71 
72 /**
73  * \brief NI-Tower skip component discovery node data structure
74  */
75 struct ni_tower_skip_component_discovery_node_data {
76     /* Parent component node of the node to be skipped */
77     const struct ni_tower_component_node *parent_node;
78     /*
79      * Index of the child node of the \ref
80      * ni_tower_skip_component_discovery_node_data.parent_node to be skipped.
81      */
82     const uint32_t node_idx;
83 };
84 
85 /**
86  * \brief NI-Tower skip component discovery list structure
87  */
88 struct ni_tower_skip_component_discovery_list {
89     /*
90      * List of all skip node data to be skipped during discovery as specified
91      * in struct \ref ni_tower_skip_component_discovery_list_node.
92      */
93     const struct ni_tower_skip_component_discovery_node_data *skip_node_data;
94     /* Number of component nodes to be skipped */
95     const uint32_t skip_node_count;
96 };
97 
98 /**
99  * \brief NI-Tower device structure
100  */
101 struct ni_tower_dev {
102     /* NI-Tower periphbase address, same as CFGNI0 address */
103     const uintptr_t periphbase;
104     /*
105      * The memory-mapped registers of NI-Tower are organized in a series of
106      * 4KB or 64KB regions. Specify whether NI-Tower has 4KB or 64KB config
107      * nodes.
108      */
109     const enum ni_tower_granularity config_node_granularity;
110     /*
111      * Pointer to skip component discovery node list structure. This includes
112      * list of all component nodes to be skipped during the discovery process.
113      * This can be updated during runtime since the discovery reach of a
114      * component node can depend on state of the host system.
115      */
116     struct ni_tower_skip_component_discovery_list *skip_discovery_list;
117     /*
118      * Address space offset for the current chip. This is typically updated
119      * during the boot time by reading the current chip id (in case of RSE
120      * present in a multichip platform). The offset will be added to the region
121      * base and end address if the component enables \ref add_chip_addr_offset
122      * flag.
123      */
124     uint64_t chip_addr_offset;
125 };
126 
127 #endif /* __NI_TOWER_DRV_H__ */
128