diff options
| author | Jinyoung Park <jinyoungp@nvidia.com> | 2017-07-27 08:05:51 -0400 |
|---|---|---|
| committer | Jinyoung Park <jinyoungp@nvidia.com> | 2018-05-04 01:20:50 -0400 |
| commit | aa69cb8e873e52802ea7ff8be9b6722bf45cc7a3 (patch) | |
| tree | 00605c7fe5c158dad56999be9a9e9567493f3331 /include/soc/tegra/virt | |
| parent | 0c52691646941efdbf44802e3a0a791ba224f48e (diff) | |
virt: tegra: Add tegra_hv_pm_ctl driver
Added Nvidia Tegra hypervisor PM control to handle power state transition
commands over IVC channel.
Supported system shutdown/reboot initiation via sysfs.
Updated hyp_guest_reset hvc call interface.
STR-293
STR-294
STR-364
Jira VFND-4029
Jira HYP-77
Change-Id: I60274121de27495e5ae11ba34b02b65350496a9b
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1528042
GVS: Gerrit_Virtual_Submit
Reviewed-by: Abhijit . <abhijit@nvidia.com>
Tested-by: Sang-Hun Lee <sanlee@nvidia.com>
Reviewed-by: Sumeet Gupta <sumeetg@nvidia.com>
Diffstat (limited to 'include/soc/tegra/virt')
| -rw-r--r-- | include/soc/tegra/virt/syscalls.h | 23 | ||||
| -rw-r--r-- | include/soc/tegra/virt/tegra_hv_pm_ctl.h | 22 | ||||
| -rw-r--r-- | include/soc/tegra/virt/tegra_hv_sysmgr.h | 106 |
3 files changed, 146 insertions, 5 deletions
diff --git a/include/soc/tegra/virt/syscalls.h b/include/soc/tegra/virt/syscalls.h index 55805f203..ed92cb239 100644 --- a/include/soc/tegra/virt/syscalls.h +++ b/include/soc/tegra/virt/syscalls.h | |||
| @@ -34,6 +34,8 @@ | |||
| 34 | #ifndef __VMM_SYSCALLS_H__ | 34 | #ifndef __VMM_SYSCALLS_H__ |
| 35 | #define __VMM_SYSCALLS_H__ | 35 | #define __VMM_SYSCALLS_H__ |
| 36 | 36 | ||
| 37 | #include <soc/tegra/virt/tegra_hv_sysmgr.h> | ||
| 38 | |||
| 37 | #define HVC_NR_READ_STAT 1 | 39 | #define HVC_NR_READ_STAT 1 |
| 38 | #define HVC_NR_READ_IVC 2 | 40 | #define HVC_NR_READ_IVC 2 |
| 39 | #define HVC_NR_READ_GID 3 | 41 | #define HVC_NR_READ_GID 3 |
| @@ -293,14 +295,25 @@ static inline int hyp_read_hyp_info(uint64_t *hyp_info_page_pa) | |||
| 293 | return (int)r0; | 295 | return (int)r0; |
| 294 | } | 296 | } |
| 295 | 297 | ||
| 296 | static inline int hyp_guest_reset(unsigned int vmid) | 298 | static inline int hyp_guest_reset(unsigned int id, |
| 299 | struct hyp_sys_state_info *out) | ||
| 297 | { | 300 | { |
| 298 | register uint64_t r0 asm("x0") = vmid; | 301 | register uint64_t r0 asm("x0") = id; |
| 302 | register uint64_t r1 asm("x1"); | ||
| 303 | register uint64_t r2 asm("x2"); | ||
| 304 | register uint64_t r3 asm("x3"); | ||
| 299 | 305 | ||
| 300 | asm volatile("hvc %1" | 306 | asm volatile("hvc %4" |
| 301 | : "+r"(r0) | 307 | : "+r"(r0), "=r"(r1), |
| 308 | "=r"(r2), "=r"(r3) | ||
| 302 | : "i"(HVC_NR_GUEST_RESET) | 309 | : "i"(HVC_NR_GUEST_RESET) |
| 303 | : "x1", "x2", "x3", _X4_X17); | 310 | : _X4_X17); |
| 311 | |||
| 312 | if (out != 0) { | ||
| 313 | out->sys_transition_mask = (uint32_t)r1; | ||
| 314 | out->vm_shutdown_mask = (uint32_t)r2; | ||
| 315 | out->vm_reboot_mask = (uint32_t)r3; | ||
| 316 | } | ||
| 304 | 317 | ||
| 305 | return (int)r0; | 318 | return (int)r0; |
| 306 | } | 319 | } |
diff --git a/include/soc/tegra/virt/tegra_hv_pm_ctl.h b/include/soc/tegra/virt/tegra_hv_pm_ctl.h new file mode 100644 index 000000000..2ae163628 --- /dev/null +++ b/include/soc/tegra/virt/tegra_hv_pm_ctl.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
| 3 | * | ||
| 4 | * This software is licensed under the terms of the GNU General Public | ||
| 5 | * License version 2, as published by the Free Software Foundation, and | ||
| 6 | * may be copied, distributed, and modified under those terms. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #ifndef _TEGRA_HV_PM_CTL_H | ||
| 15 | #define _TEGRA_HV_PM_CTL_H | ||
| 16 | |||
| 17 | extern int (*tegra_hv_pm_ctl_prepare_shutdown)(void); | ||
| 18 | |||
| 19 | int tegra_hv_pm_ctl_trigger_sys_shutdown(void); | ||
| 20 | int tegra_hv_pm_ctl_trigger_sys_reboot(void); | ||
| 21 | |||
| 22 | #endif /* _TEGRA_HV_PM_CTL_H */ | ||
diff --git a/include/soc/tegra/virt/tegra_hv_sysmgr.h b/include/soc/tegra/virt/tegra_hv_sysmgr.h new file mode 100644 index 000000000..f446c1a36 --- /dev/null +++ b/include/soc/tegra/virt/tegra_hv_sysmgr.h | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
| 3 | * | ||
| 4 | * This software is licensed under the terms of the GNU General Public | ||
| 5 | * License version 2, as published by the Free Software Foundation, and | ||
| 6 | * may be copied, distributed, and modified under those terms. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #ifndef _TEGRA_HV_SYSMGR_H | ||
| 15 | #define _TEGRA_HV_SYSMGR_H | ||
| 16 | |||
| 17 | #include <linux/types.h> | ||
| 18 | |||
| 19 | #define SYSMGR_IVCMSG_SIZE_MAX 64 | ||
| 20 | |||
| 21 | enum hv_sysmgr_msg_type { | ||
| 22 | HV_SYSMGR_MSG_TYPE_GUEST_EVENT = 1, | ||
| 23 | HV_SYSMGR_MSG_TYPE_VM_PM_CTL_CMD = 2, | ||
| 24 | HV_SYSMGR_MSG_TYPE_INVALID | ||
| 25 | }; | ||
| 26 | |||
| 27 | enum hv_sysmgr_cmd_id { | ||
| 28 | HV_SYSMGR_CMD_NORMAL_SHUTDOWN = 0x0, | ||
| 29 | HV_SYSMGR_CMD_NORMAL_REBOOT = 0x1, | ||
| 30 | HV_SYSMGR_CMD_NORMAL_SUSPEND = 0x2, | ||
| 31 | HV_SYSMGR_CMD_NORMAL_RESUME = 0x3, | ||
| 32 | HV_SYSMGR_CMD_INVALID = 0xFFFFFFFF, | ||
| 33 | }; | ||
| 34 | |||
| 35 | enum hv_sysmgr_resp_id { | ||
| 36 | HV_SYSMGR_RESP_ACCEPTED = 0x0, | ||
| 37 | HV_SYSMGR_RESP_UNKNOWN_COMMAND = 0xF, | ||
| 38 | }; | ||
| 39 | |||
| 40 | /* This struct comes as payload of hv_pm_ctl_message */ | ||
| 41 | struct hv_sysmgr_command { | ||
| 42 | uint32_t cmd_id; | ||
| 43 | uint32_t resp_id; | ||
| 44 | } __packed; | ||
| 45 | |||
| 46 | struct hv_sysmgr_message { | ||
| 47 | /* msg class */ | ||
| 48 | uint32_t msg_type; | ||
| 49 | /* id of open socket */ | ||
| 50 | uint32_t socket_id; | ||
| 51 | /* client data area. Payload */ | ||
| 52 | uint8_t client_data[SYSMGR_IVCMSG_SIZE_MAX]; | ||
| 53 | } __packed; | ||
| 54 | |||
| 55 | |||
| 56 | /* | ||
| 57 | * QUERY_SYSTEM_STATE COMMAND DATA LAYOUT | ||
| 58 | */ | ||
| 59 | struct hyp_sys_state_info { | ||
| 60 | /* Indicates System State Transition */ | ||
| 61 | uint32_t sys_transition_mask; | ||
| 62 | |||
| 63 | /* Indicates which VM shutdown request is pending */ | ||
| 64 | uint32_t vm_shutdown_mask; | ||
| 65 | |||
| 66 | /* Indicates which VM reboot request is pending */ | ||
| 67 | uint32_t vm_reboot_mask; | ||
| 68 | }; | ||
| 69 | |||
| 70 | /* | ||
| 71 | * Power management calls ID's used by SYSMGR to manage LOCAL/GLOBAL EVENTS | ||
| 72 | */ | ||
| 73 | enum system_function_id { | ||
| 74 | INVALID_FUNC, | ||
| 75 | /* | ||
| 76 | * This is used to get reboot/shutdown masks per VM from hypervisor. | ||
| 77 | * Hypervisor updates state fields on a PSCI event from the VM. | ||
| 78 | */ | ||
| 79 | QUERY_SYSTEM_STATE, | ||
| 80 | GUEST_SHUTDOWN_INIT, | ||
| 81 | GUEST_SHUTDOWN_COMPLETE, | ||
| 82 | GUEST_REBOOT_INIT, | ||
| 83 | GUEST_REBOOT_CONTINUE, | ||
| 84 | GUEST_REBOOT_COMPLETE, | ||
| 85 | SYSTEM_SHUTDOWN_INIT, | ||
| 86 | SYSTEM_SHUTDOWN_COMPLETE, | ||
| 87 | SYSTEM_REBOOT_INIT, | ||
| 88 | SYSTEM_REBOOT_COMPLETE, | ||
| 89 | MAX_FUNC_ID, | ||
| 90 | }; | ||
| 91 | |||
| 92 | #define CREATE_CMD(func_id, vmid) ((func_id << 24U) | vmid) | ||
| 93 | |||
| 94 | #define QUERY_CMD CREATE_CMD(QUERY_SYSTEM_STATE, 0) | ||
| 95 | #define GUEST_SHUTDOWN_INIT_CMD(vmid) CREATE_CMD(GUEST_SHUTDOWN_INIT, vmid) | ||
| 96 | #define GUEST_SHUTDOWN_COMPLETE_CMD(vmid) \ | ||
| 97 | CREATE_CMD(GUEST_SHUTDOWN_COMPLETE, vmid) | ||
| 98 | #define GUEST_REBOOT_INIT_CMD(vmid) CREATE_CMD(GUEST_REBOOT_INIT, vmid) | ||
| 99 | #define GUEST_REBOOT_CONTINUE_CMD(vmid) CREATE_CMD(GUEST_REBOOT_CONTINUE, vmid) | ||
| 100 | #define GUEST_REBOOT_COMPLETE_CMD(vmid) CREATE_CMD(GUEST_REBOOT_COMPLETE, vmid) | ||
| 101 | #define SYS_SHUTDOWN_INIT_CMD CREATE_CMD(SYSTEM_SHUTDOWN_INIT, 0) | ||
| 102 | #define SYS_SHUTDOWN_COMPLETE_CMD CREATE_CMD(SYSTEM_SHUTDOWN_COMPLETE, 0) | ||
| 103 | #define SYS_REBOOT_INIT_CMD CREATE_CMD(SYSTEM_REBOOT_INIT, 0) | ||
| 104 | #define SYS_REBOOT_COMPLETE_CMD CREATE_CMD(SYSTEM_REBOOT_COMPLETE, 0) | ||
| 105 | |||
| 106 | #endif /* _TEGRA_HV_SYSMGR_H */ | ||
