blob: b309b6a62c651db4174c6fe2cea9e85fab95e2a8 [file] [log] [blame]
Huang Rui0e5ca0d2017-03-03 18:37:23 -05001/*
2 * Copyright 2016 Advanced Micro Devices, Inc.
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Author: Huang Rui
23 *
24 */
25#ifndef __AMDGPU_PSP_H__
26#define __AMDGPU_PSP_H__
27
28#include "amdgpu.h"
29#include "psp_gfx_if.h"
30
31#define PSP_FENCE_BUFFER_SIZE 0x1000
32#define PSP_CMD_BUFFER_SIZE 0x1000
33#define PSP_ASD_BIN_SIZE 0x40000
34#define PSP_ASD_SHARED_MEM_SIZE 0x4000
Huang Rui53a5cf52017-03-21 16:51:00 +080035#define PSP_1_MEG 0x100000
Huang Rui0e5ca0d2017-03-03 18:37:23 -050036
37enum psp_ring_type
38{
39 PSP_RING_TYPE__INVALID = 0,
40 /*
41 * These values map to the way the PSP kernel identifies the
42 * rings.
43 */
44 PSP_RING_TYPE__UM = 1, /* User mode ring (formerly called RBI) */
45 PSP_RING_TYPE__KM = 2 /* Kernel mode ring (formerly called GPCOM) */
46};
47
48struct psp_ring
49{
50 enum psp_ring_type ring_type;
51 struct psp_gfx_rb_frame *ring_mem;
52 uint64_t ring_mem_mc_addr;
53 void *ring_mem_handle;
54 uint32_t ring_size;
55};
56
57struct psp_context
58{
59 struct amdgpu_device *adev;
60 struct psp_ring km_ring;
61
62 int (*init_microcode)(struct psp_context *psp);
63 int (*bootloader_load_sysdrv)(struct psp_context *psp);
64 int (*bootloader_load_sos)(struct psp_context *psp);
65 int (*prep_cmd_buf)(struct amdgpu_firmware_info *ucode,
66 struct psp_gfx_cmd_resp *cmd);
67 int (*ring_init)(struct psp_context *psp, enum psp_ring_type ring_type);
68 int (*cmd_submit)(struct psp_context *psp, struct amdgpu_firmware_info *ucode,
69 uint64_t cmd_buf_mc_addr, uint64_t fence_mc_addr, int index);
70 bool (*compare_sram_data)(struct psp_context *psp,
71 struct amdgpu_firmware_info *ucode,
72 enum AMDGPU_UCODE_ID ucode_type);
73 bool (*smu_reload_quirk)(struct psp_context *psp);
74
Huang Rui53a5cf52017-03-21 16:51:00 +080075 /* fence buffer */
76 struct amdgpu_bo *fw_pri_bo;
77 uint64_t fw_pri_mc_addr;
78 void *fw_pri_buf;
79
Huang Rui0e5ca0d2017-03-03 18:37:23 -050080 /* sos firmware */
81 const struct firmware *sos_fw;
82 uint32_t sos_fw_version;
83 uint32_t sos_feature_version;
84 uint32_t sys_bin_size;
85 uint32_t sos_bin_size;
86 uint8_t *sys_start_addr;
87 uint8_t *sos_start_addr;
88
89 /* tmr buffer */
90 struct amdgpu_bo *tmr_bo;
91 uint64_t tmr_mc_addr;
92 void *tmr_buf;
93
94 /* asd firmware */
95 const struct firmware *asd_fw;
96 uint32_t asd_fw_version;
97 uint32_t asd_feature_version;
98 uint32_t asd_ucode_size;
99 uint8_t *asd_start_addr;
100
101 /* fence buffer */
102 struct amdgpu_bo *fence_buf_bo;
103 uint64_t fence_buf_mc_addr;
104 void *fence_buf;
105};
106
107struct amdgpu_psp_funcs {
108 bool (*check_fw_loading_status)(struct amdgpu_device *adev,
109 enum AMDGPU_UCODE_ID);
110};
111
112#define psp_prep_cmd_buf(ucode, type) (psp)->prep_cmd_buf((ucode), (type))
113#define psp_ring_init(psp, type) (psp)->ring_init((psp), (type))
114#define psp_cmd_submit(psp, ucode, cmd_mc, fence_mc, index) \
115 (psp)->cmd_submit((psp), (ucode), (cmd_mc), (fence_mc), (index))
116#define psp_compare_sram_data(psp, ucode, type) \
117 (psp)->compare_sram_data((psp), (ucode), (type))
118#define psp_init_microcode(psp) \
119 ((psp)->init_microcode ? (psp)->init_microcode((psp)) : 0)
120#define psp_bootloader_load_sysdrv(psp) \
121 ((psp)->bootloader_load_sysdrv ? (psp)->bootloader_load_sysdrv((psp)) : 0)
122#define psp_bootloader_load_sos(psp) \
123 ((psp)->bootloader_load_sos ? (psp)->bootloader_load_sos((psp)) : 0)
124#define psp_smu_reload_quirk(psp) \
125 ((psp)->smu_reload_quirk ? (psp)->smu_reload_quirk((psp)) : false)
126
127extern const struct amd_ip_funcs psp_ip_funcs;
128
129extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
130extern int psp_wait_for(struct psp_context *psp, uint32_t reg_index,
131 uint32_t field_val, uint32_t mask, bool check_changed);
132
133#endif