2017-03-04 07:37:23 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Advanced Micro Devices, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Author: Huang Rui
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef __AMDGPU_PSP_H__
|
|
|
|
#define __AMDGPU_PSP_H__
|
|
|
|
|
|
|
|
#include "amdgpu.h"
|
|
|
|
#include "psp_gfx_if.h"
|
2018-09-28 15:01:57 +08:00
|
|
|
#include "ta_xgmi_if.h"
|
2017-03-04 07:37:23 +08:00
|
|
|
|
|
|
|
#define PSP_FENCE_BUFFER_SIZE 0x1000
|
|
|
|
#define PSP_CMD_BUFFER_SIZE 0x1000
|
2018-10-11 15:36:15 +08:00
|
|
|
#define PSP_ASD_SHARED_MEM_SIZE 0x4000
|
|
|
|
#define PSP_XGMI_SHARED_MEM_SIZE 0x4000
|
2017-03-21 16:51:00 +08:00
|
|
|
#define PSP_1_MEG 0x100000
|
2018-08-14 10:33:25 +08:00
|
|
|
#define PSP_TMR_SIZE 0x400000
|
2017-03-04 07:37:23 +08:00
|
|
|
|
2018-01-24 05:17:24 +08:00
|
|
|
struct psp_context;
|
2018-09-29 21:52:50 +08:00
|
|
|
struct psp_xgmi_node_info;
|
2018-06-28 05:24:46 +08:00
|
|
|
struct psp_xgmi_topology_info;
|
2018-01-24 05:17:24 +08:00
|
|
|
|
2017-03-04 07:37:23 +08:00
|
|
|
enum psp_ring_type
|
|
|
|
{
|
|
|
|
PSP_RING_TYPE__INVALID = 0,
|
|
|
|
/*
|
|
|
|
* These values map to the way the PSP kernel identifies the
|
|
|
|
* rings.
|
|
|
|
*/
|
|
|
|
PSP_RING_TYPE__UM = 1, /* User mode ring (formerly called RBI) */
|
|
|
|
PSP_RING_TYPE__KM = 2 /* Kernel mode ring (formerly called GPCOM) */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct psp_ring
|
|
|
|
{
|
|
|
|
enum psp_ring_type ring_type;
|
|
|
|
struct psp_gfx_rb_frame *ring_mem;
|
|
|
|
uint64_t ring_mem_mc_addr;
|
|
|
|
void *ring_mem_handle;
|
|
|
|
uint32_t ring_size;
|
|
|
|
};
|
|
|
|
|
2018-01-24 05:17:24 +08:00
|
|
|
struct psp_funcs
|
2017-03-04 07:37:23 +08:00
|
|
|
{
|
|
|
|
int (*init_microcode)(struct psp_context *psp);
|
|
|
|
int (*bootloader_load_sysdrv)(struct psp_context *psp);
|
|
|
|
int (*bootloader_load_sos)(struct psp_context *psp);
|
|
|
|
int (*prep_cmd_buf)(struct amdgpu_firmware_info *ucode,
|
|
|
|
struct psp_gfx_cmd_resp *cmd);
|
|
|
|
int (*ring_init)(struct psp_context *psp, enum psp_ring_type ring_type);
|
2018-08-02 17:54:21 +08:00
|
|
|
int (*ring_create)(struct psp_context *psp,
|
|
|
|
enum psp_ring_type ring_type);
|
2017-09-08 13:04:52 +08:00
|
|
|
int (*ring_stop)(struct psp_context *psp,
|
|
|
|
enum psp_ring_type ring_type);
|
2017-04-17 20:50:18 +08:00
|
|
|
int (*ring_destroy)(struct psp_context *psp,
|
|
|
|
enum psp_ring_type ring_type);
|
2018-08-02 17:54:21 +08:00
|
|
|
int (*cmd_submit)(struct psp_context *psp,
|
|
|
|
struct amdgpu_firmware_info *ucode,
|
|
|
|
uint64_t cmd_buf_mc_addr, uint64_t fence_mc_addr,
|
|
|
|
int index);
|
2017-03-04 07:37:23 +08:00
|
|
|
bool (*compare_sram_data)(struct psp_context *psp,
|
|
|
|
struct amdgpu_firmware_info *ucode,
|
|
|
|
enum AMDGPU_UCODE_ID ucode_type);
|
|
|
|
bool (*smu_reload_quirk)(struct psp_context *psp);
|
2017-09-14 16:25:19 +08:00
|
|
|
int (*mode1_reset)(struct psp_context *psp);
|
2018-09-28 21:50:37 +08:00
|
|
|
uint64_t (*xgmi_get_node_id)(struct psp_context *psp);
|
2018-06-28 05:24:46 +08:00
|
|
|
uint64_t (*xgmi_get_hive_id)(struct psp_context *psp);
|
|
|
|
int (*xgmi_get_topology_info)(struct psp_context *psp, int number_devices,
|
2018-09-29 21:52:50 +08:00
|
|
|
struct psp_xgmi_topology_info *topology);
|
2018-06-28 05:24:46 +08:00
|
|
|
int (*xgmi_set_topology_info)(struct psp_context *psp, int number_devices,
|
2018-09-29 21:52:50 +08:00
|
|
|
struct psp_xgmi_topology_info *topology);
|
2018-01-24 05:17:24 +08:00
|
|
|
};
|
|
|
|
|
2018-10-11 15:36:15 +08:00
|
|
|
struct psp_xgmi_context {
|
|
|
|
uint8_t initialized;
|
|
|
|
uint32_t session_id;
|
|
|
|
struct amdgpu_bo *xgmi_shared_bo;
|
|
|
|
uint64_t xgmi_shared_mc_addr;
|
|
|
|
void *xgmi_shared_buf;
|
|
|
|
};
|
|
|
|
|
2018-01-24 05:17:24 +08:00
|
|
|
struct psp_context
|
|
|
|
{
|
|
|
|
struct amdgpu_device *adev;
|
|
|
|
struct psp_ring km_ring;
|
|
|
|
struct psp_gfx_cmd_resp *cmd;
|
|
|
|
|
2018-08-02 17:54:21 +08:00
|
|
|
const struct psp_funcs *funcs;
|
2017-03-04 07:37:23 +08:00
|
|
|
|
2018-09-28 14:23:11 +08:00
|
|
|
/* firmware buffer */
|
2018-08-02 17:54:21 +08:00
|
|
|
struct amdgpu_bo *fw_pri_bo;
|
|
|
|
uint64_t fw_pri_mc_addr;
|
2017-03-21 16:51:00 +08:00
|
|
|
void *fw_pri_buf;
|
|
|
|
|
2017-03-04 07:37:23 +08:00
|
|
|
/* sos firmware */
|
|
|
|
const struct firmware *sos_fw;
|
|
|
|
uint32_t sos_fw_version;
|
|
|
|
uint32_t sos_feature_version;
|
|
|
|
uint32_t sys_bin_size;
|
|
|
|
uint32_t sos_bin_size;
|
|
|
|
uint8_t *sys_start_addr;
|
|
|
|
uint8_t *sos_start_addr;
|
|
|
|
|
|
|
|
/* tmr buffer */
|
2018-08-02 17:54:21 +08:00
|
|
|
struct amdgpu_bo *tmr_bo;
|
|
|
|
uint64_t tmr_mc_addr;
|
2017-03-04 07:37:23 +08:00
|
|
|
void *tmr_buf;
|
|
|
|
|
2017-03-21 18:02:04 +08:00
|
|
|
/* asd firmware and buffer */
|
2017-03-04 07:37:23 +08:00
|
|
|
const struct firmware *asd_fw;
|
|
|
|
uint32_t asd_fw_version;
|
|
|
|
uint32_t asd_feature_version;
|
|
|
|
uint32_t asd_ucode_size;
|
|
|
|
uint8_t *asd_start_addr;
|
2018-08-02 17:54:21 +08:00
|
|
|
struct amdgpu_bo *asd_shared_bo;
|
|
|
|
uint64_t asd_shared_mc_addr;
|
2017-03-21 18:02:04 +08:00
|
|
|
void *asd_shared_buf;
|
2017-03-04 07:37:23 +08:00
|
|
|
|
|
|
|
/* fence buffer */
|
2018-08-02 17:54:21 +08:00
|
|
|
struct amdgpu_bo *fence_buf_bo;
|
|
|
|
uint64_t fence_buf_mc_addr;
|
2017-03-04 07:37:23 +08:00
|
|
|
void *fence_buf;
|
2017-06-11 18:57:08 +08:00
|
|
|
|
|
|
|
/* cmd buffer */
|
|
|
|
struct amdgpu_bo *cmd_buf_bo;
|
|
|
|
uint64_t cmd_buf_mc_addr;
|
|
|
|
struct psp_gfx_cmd_resp *cmd_buf_mem;
|
2018-09-28 14:23:11 +08:00
|
|
|
|
|
|
|
/* fence value associated with cmd buffer */
|
|
|
|
atomic_t fence_value;
|
2018-10-11 15:36:15 +08:00
|
|
|
|
|
|
|
/* xgmi ta firmware and buffer */
|
|
|
|
const struct firmware *ta_fw;
|
|
|
|
uint32_t ta_xgmi_ucode_version;
|
|
|
|
uint32_t ta_xgmi_ucode_size;
|
|
|
|
uint8_t *ta_xgmi_start_addr;
|
|
|
|
struct psp_xgmi_context xgmi_context;
|
2017-03-04 07:37:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct amdgpu_psp_funcs {
|
|
|
|
bool (*check_fw_loading_status)(struct amdgpu_device *adev,
|
|
|
|
enum AMDGPU_UCODE_ID);
|
|
|
|
};
|
|
|
|
|
2018-09-29 21:52:50 +08:00
|
|
|
#define AMDGPU_XGMI_MAX_CONNECTED_NODES 64
|
|
|
|
struct psp_xgmi_node_info {
|
|
|
|
uint64_t node_id;
|
|
|
|
uint8_t num_hops;
|
|
|
|
uint8_t is_sharing_enabled;
|
|
|
|
enum ta_xgmi_assigned_sdma_engine sdma_engine;
|
|
|
|
};
|
|
|
|
|
2018-06-28 05:24:46 +08:00
|
|
|
struct psp_xgmi_topology_info {
|
2018-09-29 21:52:50 +08:00
|
|
|
uint32_t num_nodes;
|
|
|
|
struct psp_xgmi_node_info nodes[AMDGPU_XGMI_MAX_CONNECTED_NODES];
|
2018-06-28 05:24:46 +08:00
|
|
|
};
|
|
|
|
|
2018-01-24 05:17:24 +08:00
|
|
|
#define psp_prep_cmd_buf(ucode, type) (psp)->funcs->prep_cmd_buf((ucode), (type))
|
|
|
|
#define psp_ring_init(psp, type) (psp)->funcs->ring_init((psp), (type))
|
|
|
|
#define psp_ring_create(psp, type) (psp)->funcs->ring_create((psp), (type))
|
|
|
|
#define psp_ring_stop(psp, type) (psp)->funcs->ring_stop((psp), (type))
|
|
|
|
#define psp_ring_destroy(psp, type) ((psp)->funcs->ring_destroy((psp), (type)))
|
2017-03-04 07:37:23 +08:00
|
|
|
#define psp_cmd_submit(psp, ucode, cmd_mc, fence_mc, index) \
|
2018-01-24 05:17:24 +08:00
|
|
|
(psp)->funcs->cmd_submit((psp), (ucode), (cmd_mc), (fence_mc), (index))
|
2017-03-04 07:37:23 +08:00
|
|
|
#define psp_compare_sram_data(psp, ucode, type) \
|
2018-01-24 05:17:24 +08:00
|
|
|
(psp)->funcs->compare_sram_data((psp), (ucode), (type))
|
2017-03-04 07:37:23 +08:00
|
|
|
#define psp_init_microcode(psp) \
|
2018-01-24 05:17:24 +08:00
|
|
|
((psp)->funcs->init_microcode ? (psp)->funcs->init_microcode((psp)) : 0)
|
2017-03-04 07:37:23 +08:00
|
|
|
#define psp_bootloader_load_sysdrv(psp) \
|
2018-01-24 05:17:24 +08:00
|
|
|
((psp)->funcs->bootloader_load_sysdrv ? (psp)->funcs->bootloader_load_sysdrv((psp)) : 0)
|
2017-03-04 07:37:23 +08:00
|
|
|
#define psp_bootloader_load_sos(psp) \
|
2018-01-24 05:17:24 +08:00
|
|
|
((psp)->funcs->bootloader_load_sos ? (psp)->funcs->bootloader_load_sos((psp)) : 0)
|
2017-03-04 07:37:23 +08:00
|
|
|
#define psp_smu_reload_quirk(psp) \
|
2018-01-24 05:17:24 +08:00
|
|
|
((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
|
2017-09-14 16:25:19 +08:00
|
|
|
#define psp_mode1_reset(psp) \
|
2018-01-24 05:17:24 +08:00
|
|
|
((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
|
2018-09-28 21:50:37 +08:00
|
|
|
#define psp_xgmi_get_node_id(psp) \
|
|
|
|
((psp)->funcs->xgmi_get_node_id ? (psp)->funcs->xgmi_get_node_id((psp)) : 0)
|
2018-06-28 05:24:46 +08:00
|
|
|
#define psp_xgmi_get_hive_id(psp) \
|
|
|
|
((psp)->funcs->xgmi_get_hive_id ? (psp)->funcs->xgmi_get_hive_id((psp)) : 0)
|
|
|
|
#define psp_xgmi_get_topology_info(psp, num_device, topology) \
|
|
|
|
((psp)->funcs->xgmi_get_topology_info ? \
|
|
|
|
(psp)->funcs->xgmi_get_topology_info((psp), (num_device), (topology)) : -EINVAL)
|
|
|
|
#define psp_xgmi_set_topology_info(psp, num_device, topology) \
|
|
|
|
((psp)->funcs->xgmi_set_topology_info ? \
|
|
|
|
(psp)->funcs->xgmi_set_topology_info((psp), (num_device), (topology)) : -EINVAL)
|
2017-03-04 07:37:23 +08:00
|
|
|
|
2018-08-02 17:54:21 +08:00
|
|
|
#define amdgpu_psp_check_fw_loading_status(adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))
|
|
|
|
|
2017-03-04 07:37:23 +08:00
|
|
|
extern const struct amd_ip_funcs psp_ip_funcs;
|
|
|
|
|
|
|
|
extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
|
|
|
|
extern int psp_wait_for(struct psp_context *psp, uint32_t reg_index,
|
|
|
|
uint32_t field_val, uint32_t mask, bool check_changed);
|
|
|
|
|
2016-12-16 10:01:55 +08:00
|
|
|
extern const struct amdgpu_ip_block_version psp_v10_0_ip_block;
|
|
|
|
|
2018-01-24 05:27:31 +08:00
|
|
|
int psp_gpu_reset(struct amdgpu_device *adev);
|
2018-09-28 15:01:57 +08:00
|
|
|
int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
|
|
|
|
|
2018-05-11 14:54:50 +08:00
|
|
|
extern const struct amdgpu_ip_block_version psp_v11_0_ip_block;
|
2018-01-24 05:27:31 +08:00
|
|
|
|
2017-03-04 07:37:23 +08:00
|
|
|
#endif
|