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/pmgr | |
| 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/pmgr')
| -rw-r--r-- | include/pmgr/pmgr.c | 111 | ||||
| -rw-r--r-- | include/pmgr/pmgr.h | 43 | ||||
| -rw-r--r-- | include/pmgr/pmgrpmu.c | 546 | ||||
| -rw-r--r-- | include/pmgr/pmgrpmu.h | 39 | ||||
| -rw-r--r-- | include/pmgr/pwrdev.c | 319 | ||||
| -rw-r--r-- | include/pmgr/pwrdev.h | 60 | ||||
| -rw-r--r-- | include/pmgr/pwrmonitor.c | 376 | ||||
| -rw-r--r-- | include/pmgr/pwrmonitor.h | 69 | ||||
| -rw-r--r-- | include/pmgr/pwrpolicy.c | 782 | ||||
| -rw-r--r-- | include/pmgr/pwrpolicy.h | 136 |
10 files changed, 2481 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 | } | ||
diff --git a/include/pmgr/pmgr.h b/include/pmgr/pmgr.h new file mode 100644 index 0000000..9b142de --- /dev/null +++ b/include/pmgr/pmgr.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 2 | * general power device structures & definitions | ||
| 3 | * | ||
| 4 | * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 7 | * copy of this software and associated documentation files (the "Software"), | ||
| 8 | * to deal in the Software without restriction, including without limitation | ||
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 10 | * and/or sell copies of the Software, and to permit persons to whom the | ||
| 11 | * Software is furnished to do so, subject to the following conditions: | ||
| 12 | * | ||
| 13 | * The above copyright notice and this permission notice shall be included in | ||
| 14 | * all copies or substantial portions of the Software. | ||
| 15 | * | ||
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| 22 | * DEALINGS IN THE SOFTWARE. | ||
| 23 | */ | ||
| 24 | #ifndef NVGPU_PMGR_H | ||
| 25 | #define NVGPU_PMGR_H | ||
| 26 | |||
| 27 | #include "pwrdev.h" | ||
| 28 | #include "pwrmonitor.h" | ||
| 29 | #include "pwrpolicy.h" | ||
| 30 | |||
| 31 | struct pmgr_pmupstate { | ||
| 32 | struct pwr_devices pmgr_deviceobjs; | ||
| 33 | struct pmgr_pwr_monitor pmgr_monitorobjs; | ||
| 34 | struct pmgr_pwr_policy pmgr_policyobjs; | ||
| 35 | }; | ||
| 36 | |||
| 37 | u32 pmgr_domain_sw_setup(struct gk20a *g); | ||
| 38 | int pmgr_domain_pmu_setup(struct gk20a *g); | ||
| 39 | int pmgr_pwr_devices_get_current(struct gk20a *g, u32 *val); | ||
| 40 | int pmgr_pwr_devices_get_voltage(struct gk20a *g, u32 *val); | ||
| 41 | int pmgr_pwr_devices_get_power(struct gk20a *g, u32 *val); | ||
| 42 | |||
| 43 | #endif /* NVGPU_PMGR_H */ | ||
diff --git a/include/pmgr/pmgrpmu.c b/include/pmgr/pmgrpmu.c new file mode 100644 index 0000000..b6947f2 --- /dev/null +++ b/include/pmgr/pmgrpmu.c | |||
| @@ -0,0 +1,546 @@ | |||
| 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/kmem.h> | ||
| 24 | #include <nvgpu/pmuif/nvgpu_gpmu_cmdif.h> | ||
| 25 | #include <nvgpu/pmu.h> | ||
| 26 | #include <nvgpu/gk20a.h> | ||
| 27 | |||
| 28 | #include "gp106/bios_gp106.h" | ||
| 29 | |||
| 30 | #include "boardobj/boardobjgrp.h" | ||
| 31 | #include "boardobj/boardobjgrp_e32.h" | ||
| 32 | |||
| 33 | #include "pwrdev.h" | ||
| 34 | #include "pmgrpmu.h" | ||
| 35 | |||
| 36 | struct pmgr_pmucmdhandler_params { | ||
| 37 | u32 success; | ||
| 38 | }; | ||
| 39 | |||
| 40 | static void pmgr_pmucmdhandler(struct gk20a *g, struct pmu_msg *msg, | ||
| 41 | void *param, u32 handle, u32 status) | ||
| 42 | { | ||
| 43 | struct pmgr_pmucmdhandler_params *phandlerparams = | ||
| 44 | (struct pmgr_pmucmdhandler_params *)param; | ||
| 45 | |||
| 46 | if ((msg->msg.pmgr.msg_type != NV_PMU_PMGR_MSG_ID_SET_OBJECT) && | ||
| 47 | (msg->msg.pmgr.msg_type != NV_PMU_PMGR_MSG_ID_QUERY) && | ||
| 48 | (msg->msg.pmgr.msg_type != NV_PMU_PMGR_MSG_ID_LOAD)) { | ||
| 49 | nvgpu_err(g, "unknow msg %x", msg->msg.pmgr.msg_type); | ||
| 50 | return; | ||
| 51 | } | ||
| 52 | |||
| 53 | |||
