diff options
Diffstat (limited to 'include/pmgr/pmgr.c')
-rw-r--r-- | include/pmgr/pmgr.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/include/pmgr/pmgr.c b/include/pmgr/pmgr.c new file mode 100644 index 0000000..f5be01b --- /dev/null +++ b/include/pmgr/pmgr.c | |||
@@ -0,0 +1,111 @@ | |||
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 "pwrdev.h" | ||
26 | #include "pmgrpmu.h" | ||
27 | |||
28 | int pmgr_pwr_devices_get_power(struct gk20a *g, u32 *val) | ||
29 | { | ||
30 | struct nv_pmu_pmgr_pwr_devices_query_payload payload; | ||
31 | int status; | ||
32 | |||
33 | status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); | ||
34 | if (status) { | ||
35 | nvgpu_err(g, "pmgr_pwr_devices_get_current_power failed %x", | ||
36 | status); | ||
37 | } | ||
38 | |||
39 | *val = payload.devices[0].powerm_w; | ||
40 | |||
41 | return status; | ||
42 | } | ||
43 | |||
44 | int pmgr_pwr_devices_get_current(struct gk20a *g, u32 *val) | ||
45 | { | ||
46 | struct nv_pmu_pmgr_pwr_devices_query_payload payload; | ||
47 | int status; | ||
48 | |||
49 | status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); | ||
50 | if (status) { | ||
51 | nvgpu_err(g, "pmgr_pwr_devices_get_current failed %x", | ||
52 | status); | ||
53 | } | ||
54 | |||
55 | *val = payload.devices[0].currentm_a; | ||
56 | |||
57 | return status; | ||
58 | } | ||
59 | |||
60 | int pmgr_pwr_devices_get_voltage(struct gk20a *g, u32 *val) | ||
61 | { | ||
62 | struct nv_pmu_pmgr_pwr_devices_query_payload payload; | ||
63 | int status; | ||
64 | |||
65 | status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); | ||
66 | if (status) { | ||
67 | nvgpu_err(g, "pmgr_pwr_devices_get_current_voltage failed %x", | ||
68 | status); | ||
69 | } | ||
70 | |||
71 | *val = payload.devices[0].voltageu_v; | ||
72 | |||
73 | return status; | ||
74 | } | ||
75 | |||
76 | u32 pmgr_domain_sw_setup(struct gk20a *g) | ||
77 | { | ||
78 | u32 status; | ||
79 | |||
80 | status = pmgr_device_sw_setup(g); | ||
81 | if (status) { | ||
82 | nvgpu_err(g, | ||
83 | "error creating boardobjgrp for pmgr devices, status - 0x%x", | ||
84 | status); | ||
85 | goto exit; | ||
86 | } | ||
87 | |||
88 | status = pmgr_monitor_sw_setup(g); | ||
89 | if (status) { | ||
90 | nvgpu_err(g, | ||
91 | "error creating boardobjgrp for pmgr monitor, status - 0x%x", | ||
92 | status); | ||
93 | goto exit; | ||
94 | } | ||
95 | |||
96 | status = pmgr_policy_sw_setup(g); | ||
97 | if (status) { | ||
98 | nvgpu_err(g, | ||
99 | "error creating boardobjgrp for pmgr policy, status - 0x%x", | ||
100 | status); | ||
101 | goto exit; | ||
102 | } | ||
103 | |||
104 | exit: | ||
105 | return status; | ||
106 | } | ||
107 | |||
108 | int pmgr_domain_pmu_setup(struct gk20a *g) | ||
109 | { | ||
110 | return pmgr_send_pmgr_tables_to_pmu(g); | ||
111 | } | ||