aboutsummaryrefslogtreecommitdiffstats
path: root/include/boardobj/boardobjgrp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/boardobj/boardobjgrp.h')
-rw-r--r--include/boardobj/boardobjgrp.h441
1 files changed, 441 insertions, 0 deletions
diff --git a/include/boardobj/boardobjgrp.h b/include/boardobj/boardobjgrp.h
new file mode 100644
index 0000000..cd13b85
--- /dev/null
+++ b/include/boardobj/boardobjgrp.h
@@ -0,0 +1,441 @@
1/*
2* Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
3*
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21*/
22
23#ifndef NVGPU_BOARDOBJGRP_H
24#define NVGPU_BOARDOBJGRP_H
25
26struct boardobjgrp;
27struct gk20a;
28struct nvgpu_list_node;
29struct pmu_surface;
30
31
32/* ------------------------ Includes ----------------------------------------*/
33#include "ctrl/ctrlboardobj.h"
34#include "boardobj.h"
35#include "boardobjgrpmask.h"
36#include <nvgpu/list.h>
37#include <nvgpu/pmu.h>
38
39/*
40* Board Object Group destructor.
41*
42*/
43typedef int boardobjgrp_destruct(struct boardobjgrp *pboardobjgrp);
44
45/*
46* Inserts a previously constructed Board Object into a Board Object Group for
47* tracking. Objects are inserted in the array based on the given index.
48*/
49typedef int boardobjgrp_objinsert(struct boardobjgrp *pboardobjgrp,
50 struct boardobj *pboardobj, u8 index);
51
52/*
53* Retrieves a Board Object from a Board Object Group using the group's index.
54*
55*/
56typedef struct boardobj *boardobjgrp_objgetbyidx(
57 struct boardobjgrp *pBobrdobjgrp, u8 index);
58
59/*
60* Retrieve Board Object immediately following one pointed by @ref pcurrentindex
61* filtered out by the provided mask. If (pMask == NULL) => no filtering.
62*/
63typedef struct boardobj *boardobjgrp_objgetnext(
64 struct boardobjgrp *pboardobjgrp,
65 u8 *currentindex, struct boardobjgrpmask *mask);
66
67/*
68* Board Object Group Remover and destructor. This is used to remove and
69* destruct specific entry from the Board Object Group.
70*/
71typedef int boardobjgrp_objremoveanddestroy(struct boardobjgrp *pboardobjgrp,
72 u8 index);
73
74/*
75* BOARDOBJGRP handler for PMU_UNIT_INIT. Calls the PMU_UNIT_INIT handlers
76* for the constructed PMU CMDs, and then sets the object via the
77* PMU_BOARDOBJ_CMD_GRP interface (if constructed).
78*/
79typedef int boardobjgrp_pmuinithandle(struct gk20a *g,
80 struct boardobjgrp *pboardobjGrp);
81
82/*
83* Fills out the appropriate the PMU_BOARDOBJGRP_<xyz> driver<->PMU description
84* header structure, more specifically a mask of BOARDOBJs.
85*/
86typedef int boardobjgrp_pmuhdrdatainit(struct gk20a *g,
87 struct boardobjgrp *pboardobjgrp,
88 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu,
89 struct boardobjgrpmask *mask);
90
91/*
92* Fills out the appropriate the PMU_BOARDOBJGRP_<xyz> driver->PMU description
93* structure, describing the BOARDOBJGRP and all of its BOARDOBJs to the PMU.
94*/
95typedef int boardobjgrp_pmudatainit(struct gk20a *g,
96 struct boardobjgrp *pboardobjgrp,
97 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu);
98
99/*
100* Sends a BOARDOBJGRP to the PMU via the PMU_BOARDOBJ_CMD_GRP interface.
101* This interface leverages @ref boardobjgrp_pmudatainit to populate the
102* structure.
103*/
104typedef int boardobjgrp_pmuset(struct gk20a *g,
105 struct boardobjgrp *pboardobjgrp);
106
107/*
108* Gets the dynamic status of the PMU BOARDOBJGRP via the
109* PMU_BOARDOBJ_CMD_GRP GET_STATUS interface.
110*/
111typedef int boardobjgrp_pmugetstatus(struct gk20a *g,
112 struct boardobjgrp *pboardobjgrp,
113 struct boardobjgrpmask *mask);
114
115typedef int boardobjgrp_pmudatainstget(struct gk20a *g,
116 struct nv_pmu_boardobjgrp *boardobjgrppmu,
117 struct nv_pmu_boardobj **ppboardobjpmudata, u8 idx);
118
119typedef int boardobjgrp_pmustatusinstget(struct gk20a *g, void *pboardobjgrppmu,
120 struct nv_pmu_boardobj_query **ppBoardobjpmustatus, u8 idx);
121
122/*
123* Structure describing an PMU CMD for interacting with the representaition
124* of this BOARDOBJGRP within the PMU.
125*/
126struct boardobjgrp_pmu_cmd {
127 u8 id;
128 u8 msgid;
129 u8 hdrsize;
130 u8 entrysize;
131 u16 dmem_buffer_size;
132 u32 super_surface_offset;
133 u32 fbsize;
134 struct nv_pmu_boardobjgrp_super *buf;
135 struct pmu_surface surf;
136};
137
138/*
139* Structure of state describing how to communicate with representation of this
140* BOARDOBJGRP in the PMU.
141*/
142struct boardobjgrp_pmu {
143 u8 unitid;
144 u8 classid;
145 bool bset;
146 u8 rpc_func_id;
147 struct boardobjgrp_pmu_cmd set;
148 struct boardobjgrp_pmu_cmd getstatus;
149};
150
151/*
152* Function by which a class which implements BOARDOBJGRP can construct a PMU
153* CMD. This provides the various information describing the PMU CMD including
154* the CMD and MSG ID and the size of the various sturctures in the payload.
155*/
156typedef int boardobjgrp_pmucmd_construct(struct gk20a *g,
157 struct boardobjgrp *pboardobjgrp,
158 struct boardobjgrp_pmu_cmd *cmd, u8 id, u8 msgid,
159 u16 hdrsize, u16 entrysize, u16 fbsize, u32 ss_offset, u8 rpc_func_id);
160
161/*
162* Destroys BOARDOBJGRP PMU SW state. CMD.
163*/
164typedef int boardobjgrp_pmucmd_destroy(struct gk20a *g,
165 struct boardobjgrp_pmu_cmd *cmd);
166
167/*
168* init handler for the BOARDOBJGRP PMU CMD. Allocates and maps the
169* PMU CMD payload within both the PMU and driver so that it can be referenced
170* at run-time.
171*/
172typedef int boardobjgrp_pmucmd_pmuinithandle(struct gk20a *g,
173 struct boardobjgrp *pboardobjgrp,
174 struct boardobjgrp_pmu_cmd *cmd);
175
176/*
177* Base Class Group for all physical or logical device on the PCB.
178* Contains fields common to all devices on the board. Specific types of
179* devices groups may extend this object adding any details specific to that
180* device group or device-type.
181*/
182struct boardobjgrp {
183 struct gk20a *g;
184 u32 objmask;
185 bool bconstructed;
186 u8 type;
187 u8 classid;
188 struct boardobj **ppobjects;
189 struct boardobjgrpmask *mask;
190 u8 objslots;
191 u8 objmaxidx;
192 struct boardobjgrp_pmu pmu;
193
194 /* Basic interfaces */
195 boardobjgrp_destruct *destruct;
196 boardobjgrp_objinsert *objinsert;
197 boardobjgrp_objgetbyidx *objgetbyidx;
198 boardobjgrp_objgetnext *objgetnext;
199 boardobjgrp_objremoveanddestroy *objremoveanddestroy;
200
201 /* PMU interfaces */
202 boardobjgrp_pmuinithandle *pmuinithandle;
203 boardobjgrp_pmuhdrdatainit *pmuhdrdatainit;
204 boardobjgrp_pmudatainit *pmudatainit;
205 boardobjgrp_pmuset *pmuset;
206 boardobjgrp_pmugetstatus *pmugetstatus;
207
208 boardobjgrp_pmudatainstget *pmudatainstget;
209 boardobjgrp_pmustatusinstget *pmustatusinstget;
210 struct nvgpu_list_node node;
211};
212
213/*
214* Macro test whether a specified index into the BOARDOBJGRP is valid.
215*
216*/
217#define boardobjgrp_idxisvalid(_pboardobjgrp, _idx) \
218 (((_idx) < (_pboardobjgrp)->objslots) && \
219 ((_pboardobjgrp)->ppobjects[(_idx)] != NULL))