162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright 2016 Advanced Micro Devices, Inc.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation
762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
1262306a36Sopenharmony_ci * all copies or substantial portions of the Software.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1762306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1862306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1962306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2062306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
2162306a36Sopenharmony_ci *
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#ifndef __SOC15_H__
2562306a36Sopenharmony_ci#define __SOC15_H__
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#include "nbio_v6_1.h"
2862306a36Sopenharmony_ci#include "nbio_v7_0.h"
2962306a36Sopenharmony_ci#include "nbio_v7_4.h"
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciextern const struct amdgpu_ip_block_version vega10_common_ip_block;
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#define SOC15_FLUSH_GPU_TLB_NUM_WREG		6
3462306a36Sopenharmony_ci#define SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT	3
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_cistruct soc15_reg_golden {
3762306a36Sopenharmony_ci	u32	hwip;
3862306a36Sopenharmony_ci	u32	instance;
3962306a36Sopenharmony_ci	u32	segment;
4062306a36Sopenharmony_ci	u32	reg;
4162306a36Sopenharmony_ci	u32	and_mask;
4262306a36Sopenharmony_ci	u32	or_mask;
4362306a36Sopenharmony_ci};
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_cistruct soc15_reg_rlcg {
4662306a36Sopenharmony_ci	u32	hwip;
4762306a36Sopenharmony_ci	u32	instance;
4862306a36Sopenharmony_ci	u32	segment;
4962306a36Sopenharmony_ci	u32	reg;
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_cistruct soc15_reg {
5362306a36Sopenharmony_ci	uint32_t hwip;
5462306a36Sopenharmony_ci	uint32_t inst;
5562306a36Sopenharmony_ci	uint32_t seg;
5662306a36Sopenharmony_ci	uint32_t reg_offset;
5762306a36Sopenharmony_ci};
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_cistruct soc15_reg_entry {
6062306a36Sopenharmony_ci	uint32_t hwip;
6162306a36Sopenharmony_ci	uint32_t inst;
6262306a36Sopenharmony_ci	uint32_t seg;
6362306a36Sopenharmony_ci	uint32_t reg_offset;
6462306a36Sopenharmony_ci	uint32_t reg_value;
6562306a36Sopenharmony_ci	uint32_t se_num;
6662306a36Sopenharmony_ci	uint32_t instance;
6762306a36Sopenharmony_ci};
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_cistruct soc15_allowed_register_entry {
7062306a36Sopenharmony_ci	uint32_t hwip;
7162306a36Sopenharmony_ci	uint32_t inst;
7262306a36Sopenharmony_ci	uint32_t seg;
7362306a36Sopenharmony_ci	uint32_t reg_offset;
7462306a36Sopenharmony_ci	bool grbm_indexed;
7562306a36Sopenharmony_ci};
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_cistruct soc15_ras_field_entry {
7862306a36Sopenharmony_ci	const char *name;
7962306a36Sopenharmony_ci	uint32_t hwip;
8062306a36Sopenharmony_ci	uint32_t inst;
8162306a36Sopenharmony_ci	uint32_t seg;
8262306a36Sopenharmony_ci	uint32_t reg_offset;
8362306a36Sopenharmony_ci	uint32_t sec_count_mask;
8462306a36Sopenharmony_ci	uint32_t sec_count_shift;
8562306a36Sopenharmony_ci	uint32_t ded_count_mask;
8662306a36Sopenharmony_ci	uint32_t ded_count_shift;
8762306a36Sopenharmony_ci};
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci#define SOC15_REG_ENTRY(ip, inst, reg)	ip##_HWIP, inst, reg##_BASE_IDX, reg
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci#define SOC15_REG_ENTRY_OFFSET(entry)	(adev->reg_offset[entry.hwip][entry.inst][entry.seg] + entry.reg_offset)
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#define SOC15_REG_GOLDEN_VALUE(ip, inst, reg, and_mask, or_mask) \
9462306a36Sopenharmony_ci	{ ip##_HWIP, inst, reg##_BASE_IDX, reg, and_mask, or_mask }
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#define SOC15_REG_FIELD(reg, field) reg##__##field##_MASK, reg##__##field##__SHIFT
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci#define SOC15_REG_FIELD_VAL(val, mask, shift)	(((val) & mask) >> shift)
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci#define SOC15_RAS_REG_FIELD_VAL(val, entry, field) SOC15_REG_FIELD_VAL((val), (entry).field##_count_mask, (entry).field##_count_shift)
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_civoid soc15_grbm_select(struct amdgpu_device *adev,
10362306a36Sopenharmony_ci		    u32 me, u32 pipe, u32 queue, u32 vmid, int xcc_id);
10462306a36Sopenharmony_civoid soc15_set_virt_ops(struct amdgpu_device *adev);
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_civoid soc15_program_register_sequence(struct amdgpu_device *adev,
10762306a36Sopenharmony_ci					     const struct soc15_reg_golden *registers,
10862306a36Sopenharmony_ci					     const u32 array_size);
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ciint vega10_reg_base_init(struct amdgpu_device *adev);
11162306a36Sopenharmony_ciint vega20_reg_base_init(struct amdgpu_device *adev);
11262306a36Sopenharmony_ciint arct_reg_base_init(struct amdgpu_device *adev);
11362306a36Sopenharmony_ciint aldebaran_reg_base_init(struct amdgpu_device *adev);
11462306a36Sopenharmony_civoid aqua_vanjaram_ip_map_init(struct amdgpu_device *adev);
11562306a36Sopenharmony_ciu64 aqua_vanjaram_encode_ext_smn_addressing(int ext_id);
11662306a36Sopenharmony_ciint aqua_vanjaram_init_soc_config(struct amdgpu_device *adev);
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_civoid vega10_doorbell_index_init(struct amdgpu_device *adev);
11962306a36Sopenharmony_civoid vega20_doorbell_index_init(struct amdgpu_device *adev);
12062306a36Sopenharmony_civoid aqua_vanjaram_doorbell_index_init(struct amdgpu_device *adev);
12162306a36Sopenharmony_ci#endif
122