aboutsummaryrefslogtreecommitdiffstats
path: root/include/volt
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2023-06-28 18:24:25 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2023-06-28 18:24:25 -0400
commit01e6fac4d61fdd7fff5433942ec93fc2ea1e4df1 (patch)
tree4ef34501728a087be24f4ba0af90f91486bf780b /include/volt
parent306a03d18b305e4e573be3b2931978fa10679eb9 (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/volt')
-rw-r--r--include/volt/volt.h39
-rw-r--r--include/volt/volt_dev.c609
-rw-r--r--include/volt/volt_dev.h77
-rw-r--r--include/volt/volt_pmu.c384
-rw-r--r--include/volt/volt_pmu.h46
-rw-r--r--include/volt/volt_policy.c513
-rw-r--r--include/volt/volt_policy.h80
-rw-r--r--include/volt/volt_rail.c485
-rw-r--r--include/volt/volt_rail.h90
9 files changed, 2323 insertions, 0 deletions
diff --git a/include/volt/volt.h b/include/volt/volt.h
new file mode 100644
index 0000000..8b4895f
--- /dev/null
+++ b/include/volt/volt.h
@@ -0,0 +1,39 @@
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_VOLT_H
24#define NVGPU_VOLT_H
25
26#include "volt_rail.h"
27#include "volt_dev.h"
28#include "volt_policy.h"
29#include "volt_pmu.h"
30
31#define VOLTAGE_DESCRIPTOR_TABLE_ENTRY_INVALID 0xFF
32
33struct obj_volt {
34 struct voltage_rail_metadata volt_rail_metadata;
35 struct voltage_device_metadata volt_dev_metadata;
36 struct voltage_policy_metadata volt_policy_metadata;
37};
38
39#endif /* NVGPU_VOLT_H */
diff --git a/include/volt/volt_dev.c b/include/volt/volt_dev.c
new file mode 100644
index 0000000..bb5d182
--- /dev/null
+++ b/include/volt/volt_dev.c
@@ -0,0 +1,609 @@
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/types.h>
24#include <nvgpu/sort.h>
25#include <nvgpu/pmuif/nvgpu_gpmu_cmdif.h>
26#include <nvgpu/bios.h>
27#include <nvgpu/kmem.h>
28#include <nvgpu/gk20a.h>
29
30#include "gp106/bios_gp106.h"
31
32#include "boardobj/boardobjgrp.h"
33#include "boardobj/boardobjgrp_e32.h"
34#include "ctrl/ctrlvolt.h"
35
36#include "volt.h"
37
38#define VOLT_DEV_PWM_VOLTAGE_STEPS_INVALID 0U
39#define VOLT_DEV_PWM_VOLTAGE_STEPS_DEFAULT 1U
40
41static int volt_device_pmu_data_init_super(struct gk20a *g,
42 struct boardobj *pboard_obj, struct nv_pmu_boardobj *ppmudata)
43{
44 int status;
45 struct voltage_device *pdev;
46 struct nv_pmu_volt_volt_device_boardobj_set *pset;
47
48 status = boardobj_pmudatainit_super(g, pboard_obj, ppmudata);
49 if (status) {
50 return status;
51 }
52
53 pdev = (struct voltage_device *)pboard_obj;
54 pset = (struct nv_pmu_volt_volt_device_boardobj_set *)ppmudata;
55
56 pset->switch_delay_us = pdev->switch_delay_us;
57 pset->voltage_min_uv = pdev->voltage_min_uv;
58 pset->voltage_max_uv = pdev->voltage_max_uv;
59 pset->volt_step_uv = pdev->volt_step_uv;
60
61 return status;
62}
63
64static int volt_device_pmu_data_init_pwm(struct gk20a *g,
65 struct boardobj *pboard_obj, struct nv_pmu_boardobj *ppmudata)
66{
67 int status = 0;
68 struct voltage_device_pwm *pdev;
69 struct nv_pmu_volt_volt_device_pwm_boardobj_set *pset;
70
71 status = volt_device_pmu_data_init_super(g, pboard_obj, ppmudata);
72 if (status) {
73 return status;
74 }
75
76 pdev = (struct voltage_device_pwm *)pboard_obj;
77 pset = (struct nv_pmu_volt_volt_device_pwm_boardobj_set *)ppmudata;
78
79 pset->raw_period = pdev->raw_period;
80 pset->voltage_base_uv = pdev->voltage_base_uv;
81 pset->voltage_offset_scale_uv = pdev->voltage_offset_scale_uv;
82 pset->pwm_source = pdev->source;
83
84 return status;
85}
86
87static int construct_volt_device(struct gk20a *g,
88 struct boardobj **ppboardobj, u16 size, void *pargs)
89{
90 struct voltage_device *ptmp_dev = (struct voltage_device *)pargs;
91 struct voltage_device *pvolt_dev = NULL;
92 int status = 0;
93
94 status = boardobj_construct_super(g, ppboardobj, size, pargs);
95 if (status) {
96 return status;
97 }
98
99 pvolt_dev = (struct voltage_device *)*ppboardobj;
100
101 pvolt_dev->volt_domain = ptmp_dev->volt_domain;
102 pvolt_dev->i2c_dev_idx = ptmp_dev->i2c_dev_idx;
103 pvolt_dev->switch_delay_us = ptmp_dev->switch_delay_us;
104 pvolt_dev->rsvd_0 = VOLTAGE_DESCRIPTOR_TABLE_ENTRY_INVALID;
105 pvolt_dev->rsvd_1 =
106 VOLTAGE_DESCRIPTOR_TABLE_ENTRY_INVALID;
107 pvolt_dev->operation_type = ptmp_dev->operation_type;
108 pvolt_dev->voltage_min_uv = ptmp_dev->voltage_min_uv;
109 pvolt_dev->voltage_max_uv = ptmp_dev->voltage_max_uv;
110
111 pvolt_dev->super.pmudatainit = volt_device_pmu_data_init_super;
112
113 return status;
114}
115
116static int construct_pwm_volt_device(struct gk20a *g,
117 struct boardobj **ppboardobj,
118 u16 size, void *pargs)
119{
120 struct boardobj *pboard_obj = NULL;
121 struct voltage_device_pwm *ptmp_dev =
122 (struct voltage_device_pwm *)pargs;
123 struct voltage_device_pwm *pdev = NULL;
124 int status = 0;
125
126 status = construct_volt_device(g, ppboardobj, size, pargs);
127 if (status) {
128 return status;
129 }
130
131 pboard_obj = (*ppboardobj);
132 pdev = (struct voltage_device_pwm *)*ppboardobj;
133
134 pboard_obj->pmudatainit = volt_device_pmu_data_init_pwm;
135
136 /* Set VOLTAGE_DEVICE_PWM-specific parameters */
137 pdev->voltage_base_uv = ptmp_dev->voltage_base_uv;
138 pdev->voltage_offset_scale_uv = ptmp_dev->voltage_offset_scale_uv;
139 pdev->source = ptmp_dev->source;
140 pdev->raw_period = ptmp_dev->raw_period;
141
142 return status;
143}
144
145
146static struct voltage_device_entry *volt_dev_construct_dev_entry_pwm(
147 struct gk20a *g,
148 u32 voltage_uv, void *pargs)
149{
150 struct voltage_device_pwm_entry *pentry = NULL;
151 struct voltage_device_pwm_entry *ptmp_entry =
152 (struct voltage_device_pwm_entry *)pargs;
153
154 pentry = nvgpu_kzalloc(g, sizeof(struct voltage_device_pwm_entry));
155 if (pentry == NULL) {
156 return NULL;
157 }
158
159 memset(pentry, 0, sizeof(struct voltage_device_pwm_entry));
160
161 pentry->super.voltage_uv = voltage_uv;
162 pentry->duty_cycle = ptmp_entry->duty_cycle;
163
164 return (struct voltage_device_entry *)pentry;
165