blob: 28faba5b7dd6309ac4e7c55ba40044127848b175 [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
Huang Rui0e5ca0d2017-03-03 18:37:23 -050033#define PSP_ASD_SHARED_MEM_SIZE 0x4000
Huang Rui53a5cf52017-03-21 16:51:00 +080034#define PSP_1_MEG 0x100000
Huang Rui0e5ca0d2017-03-03 18:37:23 -050035
36enum psp_ring_type
37{
38 PSP_RING_TYPE__INVALID = 0,
39 /*
40 * These values map to the way the PSP kernel identifies the
41 * rings.
42 */
43 PSP_RING_TYPE__UM = 1, /* User mode ring (formerly called RBI) */
44 PSP_RING_TYPE__KM = 2 /* Kernel mode ring (formerly called GPCOM) */
45};
46
47struct psp_ring
48{
49 enum psp_ring_type ring_type;
50 struct psp_gfx_rb_frame *ring_mem;
51 uint64_t ring_mem_mc_addr;
52 void *ring_mem_handle;
53 uint32_t ring_size;
54};
55
56struct psp_context
57{
58 struct amdgpu_device *adev;
59 struct psp_ring km_ring;
Huang Ruibe70bbd2017-03-21 18:36:57 +080060 struct psp_gfx_cmd_resp *cmd;
Huang Rui0e5ca0d2017-03-03 18:37:23 -050061
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);
Huang Ruibe70bbd2017-03-21 18:36:57 +080068 int (*ring_create)(struct psp_context *psp, enum psp_ring_type ring_type);
Huang Rui0e5ca0d2017-03-03 18:37:23 -050069 int (*cmd_submit)(struct psp_context *psp, struct amdgpu_firmware_info *ucode,
70 uint64_t cmd_buf_mc_addr, uint64_t fence_mc_addr, int index);
71 bool (*compare_sram_data)(struct psp_context *psp,
72 struct amdgpu_firmware_info *ucode,
73 enum AMDGPU_UCODE_ID ucode_type);
74 bool (*smu_reload_quirk)(struct psp_context *psp);
75
Huang Rui53a5cf52017-03-21 16:51:00 +080076 /* fence buffer */
77 struct amdgpu_bo *fw_pri_bo;
78 uint64_t fw_pri_mc_addr;
79 void *fw_pri_buf;
80
Huang Rui0e5ca0d2017-03-03 18:37:23 -050081 /* sos firmware */
82 const struct firmware *sos_fw;
83 uint32_t sos_fw_version;
84 uint32_t sos_feature_version;
85 uint32_t sys_bin_size;
86 uint32_t sos_bin_size;
87 uint8_t *sys_start_addr;
88 uint8_t *sos_start_addr;
89
90 /* tmr buffer */
91 struct amdgpu_bo *tmr_bo;
92 uint64_t tmr_mc_addr;
93 void *tmr_buf;
94
Huang Ruif5cfef92017-03-21 18:02:04 +080095 /* asd firmware and buffer */
Huang Rui0e5ca0d2017-03-03 18:37:23 -050096 const struct firmware *asd_fw;
97 uint32_t asd_fw_version;
98 uint32_t asd_feature_version;
99 uint32_t asd_ucode_size;
100 uint8_t *asd_start_addr;
Huang Ruif5cfef92017-03-21 18:02:04 +0800101 struct amdgpu_bo *asd_shared_bo;
102 uint64_t asd_shared_mc_addr;
103 void *asd_shared_buf;
Huang Rui0e5ca0d2017-03-03 18:37:23 -0500104
105 /* fence buffer */
106 struct amdgpu_bo *fence_buf_bo;
107 uint64_t fence_buf_mc_addr;
108 void *fence_buf;
109};
110
111struct amdgpu_psp_funcs {
112 bool (*check_fw_loading_status)(struct amdgpu_device *adev,
113 enum AMDGPU_UCODE_ID);
114};
115
116#define psp_prep_cmd_buf(ucode, type) (psp)->prep_cmd_buf((ucode), (type))
117#define psp_ring_init(psp, type) (psp)->ring_init((psp), (type))
Huang Ruibe70bbd2017-03-21 18:36:57 +0800118#define psp_ring_create(psp, type) (psp)->ring_create((psp), (type))
Huang Rui0e5ca0d2017-03-03 18:37:23 -0500119#define psp_cmd_submit(psp, ucode, cmd_mc, fence_mc, index) \
120 (psp)->cmd_submit((psp), (ucode), (cmd_mc), (fence_mc), (index))
121#define psp_compare_sram_data(psp, ucode, type) \
122 (psp)->compare_sram_data((psp), (ucode), (type))
123#define psp_init_microcode(psp) \
124 ((psp)->init_microcode ? (psp)->init_microcode((psp)) : 0)
125#define psp_bootloader_load_sysdrv(psp) \
126 ((psp)->bootloader_load_sysdrv ? (psp)->bootloader_load_sysdrv((psp)) : 0)
127#define psp_bootloader_load_sos(psp) \
128 ((psp)->bootloader_load_sos ? (psp)->bootloader_load_sos((psp)) : 0)
129#define psp_smu_reload_quirk(psp) \
130 ((psp)->smu_reload_quirk ? (psp)->smu_reload_quirk((psp)) : false)
131
132extern const struct amd_ip_funcs psp_ip_funcs;
133
134extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
135extern int psp_wait_for(struct psp_context *psp, uint32_t reg_index,
136 uint32_t field_val, uint32_t mask, bool check_changed);
137
138#endif