diff options
| author | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
|---|---|---|
| committer | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
| commit | 01e6fac4d61fdd7fff5433942ec93fc2ea1e4df1 (patch) | |
| tree | 4ef34501728a087be24f4ba0af90f91486bf780b /include/clk/clk_vf_point.c | |
| parent | 306a03d18b305e4e573be3b2931978fa10679eb9 (diff) | |
Include nvgpu headers
These are needed to build on NVIDIA's Jetson boards for the time
being. Only a couple structs are required, so it should be fairly
easy to remove this dependency at some point in the future.
Diffstat (limited to 'include/clk/clk_vf_point.c')
| -rw-r--r-- | include/clk/clk_vf_point.c | 433 |
1 files changed, 433 insertions, 0 deletions
diff --git a/include/clk/clk_vf_point.c b/include/clk/clk_vf_point.c new file mode 100644 index 0000000..96413c8 --- /dev/null +++ b/include/clk/clk_vf_point.c | |||
| @@ -0,0 +1,433 @@ | |||
| 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 | #include <nvgpu/gk20a.h> | ||
| 24 | |||
| 25 | #include "clk.h" | ||
| 26 | #include "clk_vf_point.h" | ||
| 27 | #include "boardobj/boardobjgrp.h" | ||
| 28 | #include "boardobj/boardobjgrp_e32.h" | ||
| 29 | #include "ctrl/ctrlclk.h" | ||
| 30 | #include "ctrl/ctrlvolt.h" | ||
| 31 | |||
| 32 | static int _clk_vf_point_pmudatainit_super(struct gk20a *g, struct boardobj | ||
| 33 | *board_obj_ptr, struct nv_pmu_boardobj *ppmudata); | ||
| 34 | |||
| 35 | static int _clk_vf_points_pmudatainit(struct gk20a *g, | ||
| 36 | struct boardobjgrp *pboardobjgrp, | ||
| 37 | struct nv_pmu_boardobjgrp_super *pboardobjgrppmu) | ||
| 38 | { | ||
| 39 | u32 status = 0; | ||
| 40 | |||
| 41 | status = boardobjgrp_pmudatainit_e32(g, pboardobjgrp, pboardobjgrppmu); | ||
| 42 | if (status) { | ||
| 43 | nvgpu_err(g, | ||
| 44 | "error updating pmu boardobjgrp for clk vfpoint 0x%x", | ||
| 45 | status); | ||
| 46 | goto done; | ||
| 47 | } | ||
| 48 | |||
| 49 | done: | ||
| 50 | return status; | ||
| 51 | } | ||
| 52 | |||
| 53 | static int _clk_vf_points_pmudata_instget(struct gk20a *g, | ||
| 54 | struct nv_pmu_boardobjgrp *pmuboardobjgrp, | ||
| 55 | struct nv_pmu_boardobj **ppboardobjpmudata, | ||
| 56 | u8 idx) | ||
| 57 | { | ||
| 58 | struct nv_pmu_clk_clk_vf_point_boardobj_grp_set *pgrp_set = | ||
| 59 | (struct nv_pmu_clk_clk_vf_point_boardobj_grp_set *) | ||
| 60 | pmuboardobjgrp; | ||
| 61 | |||
| 62 | nvgpu_log_info(g, " "); | ||
| 63 | |||
| 64 | /*check whether pmuboardobjgrp has a valid boardobj in index*/ | ||
| 65 | if (idx >= CTRL_BOARDOBJGRP_E255_MAX_OBJECTS) { | ||
| 66 | return -EINVAL; | ||
| 67 | } | ||
| 68 | |||
| 69 | *ppboardobjpmudata = (struct nv_pmu_boardobj *) | ||
| 70 | &pgrp_set->objects[idx].data.board_obj; | ||
| 71 | nvgpu_log_info(g, " Done"); | ||
| 72 | return 0; | ||
| 73 | } | ||
| 74 | |||
| 75 | static int _clk_vf_points_pmustatus_instget(struct gk20a *g, | ||
| 76 | void *pboardobjgrppmu, | ||
| 77 | struct nv_pmu_boardobj_query **ppboardobjpmustatus, | ||
| 78 | u8 idx) | ||
| 79 | { | ||
| 80 | struct nv_pmu_clk_clk_vf_point_boardobj_grp_get_status *pgrp_get_status = | ||
| 81 | (struct nv_pmu_clk_clk_vf_point_boardobj_grp_get_status *) | ||
| 82 | pboardobjgrppmu; | ||
| 83 | |||
| 84 | /*check whether pmuboardobjgrp has a valid boardobj in index*/ | ||
| 85 | if (idx >= CTRL_BOARDOBJGRP_E255_MAX_OBJECTS) { | ||
| 86 | return -EINVAL; | ||
| 87 | } | ||
| 88 | |||
| 89 | *ppboardobjpmustatus = (struct nv_pmu_boardobj_query *) | ||
| 90 | &pgrp_get_status->objects[idx].data.board_obj; | ||
| 91 | return 0; | ||
| 92 | } | ||
| 93 | |||
| 94 | int clk_vf_point_sw_setup(struct gk20a *g) | ||
| 95 | { | ||
| 96 | int status; | ||
| 97 | struct boardobjgrp *pboardobjgrp = NULL; | ||
| 98 | |||
| 99 | nvgpu_log_info(g, " "); | ||
| 100 | |||
| 101 | status = boardobjgrpconstruct_e255(g, &g->clk_pmu.clk_vf_pointobjs.super); | ||
| 102 | if (status) { | ||
| 103 | nvgpu_err(g, | ||
| 104 | "error creating boardobjgrp for clk vfpoint, status - 0x%x", | ||
| 105 | status); | ||
| 106 | goto done; | ||
| 107 | } | ||
| 108 | |||
| 109 | pboardobjgrp = &g->clk_pmu.clk_vf_pointobjs.super.super; | ||
| 110 | |||
| 111 | BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, CLK, CLK_VF_POINT); | ||
| 112 | |||
| 113 | status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp, | ||
| 114 | clk, CLK, clk_vf_point, CLK_VF_POINT); | ||
| 115 | if (status) { | ||
| 116 | nvgpu_err(g, | ||
| 117 | "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x", | ||
| 118 | status); | ||
| 119 | goto done; | ||
| 120 | } | ||
| 121 | |||
| 122 | status = BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g, | ||
| 123 | &g->clk_pmu.clk_vf_pointobjs.super.super, | ||
| 124 | clk, CLK, clk_vf_point, CLK_VF_POINT); | ||
| 125 | if (status) { | ||
| 126 | nvgpu_err(g, | ||
| 127 | "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x", | ||
| 128 | status); | ||
| 129 | goto done; | ||
| 130 | } | ||
| 131 | |||
| 132 | pboardobjgrp->pmudatainit = _clk_vf_points_pmudatainit; | ||
| 133 | pboardobjgrp->pmudatainstget = _clk_vf_points_pmudata_instget; | ||
| 134 | pboardobjgrp->pmustatusinstget = _clk_vf_points_pmustatus_instget; | ||
| 135 | |||
| 136 | done: | ||
| 137 | nvgpu_log_info(g, " done status %x", status); | ||
| 138 | return status; | ||
| 139 | } | ||
| 140 | |||
| 141 | int clk_vf_point_pmu_setup(struct gk20a *g) | ||
| 142 | { | ||
| 143 | int status; | ||
| 144 | struct boardobjgrp *pboardobjgrp = NULL; | ||
| 145 | |||
| 146 | nvgpu_log_info(g, " "); | ||
| 147 | |||
| 148 | pboardobjgrp = &g->clk_pmu.clk_vf_pointobjs.super.super; | ||
| 149 | |||
| 150 | if (!pboardobjgrp->bconstructed) { | ||
| 151 | return -EINVAL; | ||
| 152 | } | ||
| 153 | |||
| 154 | status = pboardobjgrp->pmuinithandle(g, pboardobjgrp); | ||
| 155 | |||
| 156 | nvgpu_log_info(g, "Done"); | ||
| 157 | return status; | ||
| 158 | } | ||
| 159 | |||
| 160 | static int clk_vf_point_construct_super(struct gk20a *g, | ||
| 161 | struct boardobj **ppboardobj, | ||
| 162 | u16 size, void *pargs) | ||
| 163 | { | ||
| 164 | struct clk_vf_point *pclkvfpoint; | ||
| 165 | struct clk_vf_point *ptmpvfpoint = | ||
| 166 | (struct clk_vf_point *)pargs; | ||
| 167 | int status = 0; | ||
| 168 | |||
| 169 | status = boardobj_construct_super(g, ppboardobj, | ||
| 170 | size, pargs); | ||
| 171 | if (status) { | ||
| 172 | return -EINVAL; | ||
| 173 | } | ||
| 174 | |||
| 175 | pclkvfpoint = (struct clk_vf_point *)*ppboardobj; | ||
| 176 | |||
| 177 | pclkvfpoint->super.pmudatainit = | ||
| 178 | _clk_vf_point_pmudatainit_super; | ||
| 179 | |||
| 180 | pclkvfpoint->vfe_equ_idx = ptmpvfpoint->vfe_equ_idx; | ||
| 181 | pclkvfpoint->volt_rail_idx = ptmpvfpoint->volt_rail_idx; | ||
| 182 | |||
| 183 | return status; | ||
| 184 | } | ||
| 185 | |||
| 186 | static int _clk_vf_point_pmudatainit_volt(struct gk20a *g, | ||
| 187 | struct boardobj *board_obj_ptr, | ||
| 188 | struct nv_pmu_boardobj *ppmudata) | ||
| 189 | { | ||
| 190 | int status = 0; | ||
| 191 | struct clk_vf_point_volt *pclk_vf_point_volt; | ||
| 192 | struct nv_pmu_clk_clk_vf_point_volt_boardobj_set *pset; | ||
| 193 | |||
| 194 | nvgpu_log_info(g, " "); | ||
| 195 | |||
| 196 | status = _clk_vf_point_pmudatainit_super(g, board_obj_ptr, ppmudata); | ||
| 197 | if (status != 0) { | ||
| 198 | return status; | ||
| 199 | } | ||
| 200 | |||
| 201 | pclk_vf_point_volt = | ||
| 202 | (struct clk_vf_point_volt *)board_obj_ptr; | ||
| 203 | |||
| 204 | pset = (struct nv_pmu_clk_clk_vf_point_volt_boardobj_set *) | ||
| 205 | ppmudata; | ||
| 206 | |||
| 207 | pset->source_voltage_uv = pclk_vf_point_volt->source_voltage_uv; | ||
| 208 | pset->freq_delta.data = pclk_vf_point_volt->freq_delta.data; | ||
| 209 | pset->freq_delta.type = pclk_vf_point_volt->freq_delta.type; | ||
| 210 | |||
| 211 | return status; | ||
| 212 | } | ||
| 213 | |||
| 214 | static int _clk_vf_point_pmudatainit_freq(struct gk20a *g, | ||
| 215 | struct boardobj *board_obj_ptr, | ||
| 216 | struct nv_pmu_boardobj *ppmudata) | ||
