2 * Copyright 2018 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
24 #include <linux/firmware.h>
27 #include "amdgpu_discovery.h"
28 #include "soc15_hw_ip.h"
29 #include "discovery.h"
37 #include "nbio_v6_1.h"
38 #include "nbio_v7_0.h"
39 #include "nbio_v7_4.h"
40 #include "nbio_v7_9.h"
42 #include "vega10_ih.h"
43 #include "vega20_ih.h"
44 #include "sdma_v4_0.h"
45 #include "sdma_v4_4_2.h"
50 #include "jpeg_v2_5.h"
51 #include "smuio_v9_0.h"
52 #include "gmc_v10_0.h"
53 #include "gmc_v11_0.h"
54 #include "gfxhub_v2_0.h"
55 #include "mmhub_v2_0.h"
56 #include "nbio_v2_3.h"
57 #include "nbio_v4_3.h"
58 #include "nbio_v7_2.h"
59 #include "nbio_v7_7.h"
65 #include "navi10_ih.h"
67 #include "gfx_v10_0.h"
68 #include "gfx_v11_0.h"
69 #include "sdma_v5_0.h"
70 #include "sdma_v5_2.h"
71 #include "sdma_v6_0.h"
72 #include "lsdma_v6_0.h"
74 #include "jpeg_v2_0.h"
76 #include "jpeg_v3_0.h"
78 #include "jpeg_v4_0.h"
79 #include "vcn_v4_0_3.h"
80 #include "jpeg_v4_0_3.h"
81 #include "amdgpu_vkms.h"
82 #include "mes_v10_1.h"
83 #include "mes_v11_0.h"
84 #include "smuio_v11_0.h"
85 #include "smuio_v11_0_6.h"
86 #include "smuio_v13_0.h"
87 #include "smuio_v13_0_3.h"
88 #include "smuio_v13_0_6.h"
90 #define FIRMWARE_IP_DISCOVERY "amdgpu/ip_discovery.bin"
91 MODULE_FIRMWARE(FIRMWARE_IP_DISCOVERY);
93 #define mmRCC_CONFIG_MEMSIZE 0xde3
94 #define mmMM_INDEX 0x0
95 #define mmMM_INDEX_HI 0x6
98 static const char *hw_id_names[HW_ID_MAX] = {
102 [SMUIO_HWID] = "SMUIO",
103 [FUSE_HWID] = "FUSE",
104 [CLKA_HWID] = "CLKA",
108 [AUDIO_AZ_HWID] = "AUDIO_AZ",
114 [XDMA_HWID] = "XDMA",
115 [DCEAZ_HWID] = "DCEAZ",
117 [SDPMUX_HWID] = "SDPMUX",
119 [IOHC_HWID] = "IOHC",
120 [L2IMU_HWID] = "L2IMU",
122 [MMHUB_HWID] = "MMHUB",
123 [ATHUB_HWID] = "ATHUB",
124 [DBGU_NBIO_HWID] = "DBGU_NBIO",
126 [DBGU0_HWID] = "DBGU0",
127 [DBGU1_HWID] = "DBGU1",
128 [OSSSYS_HWID] = "OSSSYS",
130 [SDMA0_HWID] = "SDMA0",
131 [SDMA1_HWID] = "SDMA1",
132 [SDMA2_HWID] = "SDMA2",
133 [SDMA3_HWID] = "SDMA3",
134 [LSDMA_HWID] = "LSDMA",
136 [DBGU_IO_HWID] = "DBGU_IO",
138 [CLKB_HWID] = "CLKB",
140 [DFX_DAP_HWID] = "DFX_DAP",
141 [L1IMU_PCIE_HWID] = "L1IMU_PCIE",
142 [L1IMU_NBIF_HWID] = "L1IMU_NBIF",
143 [L1IMU_IOAGR_HWID] = "L1IMU_IOAGR",
144 [L1IMU3_HWID] = "L1IMU3",
145 [L1IMU4_HWID] = "L1IMU4",
146 [L1IMU5_HWID] = "L1IMU5",
147 [L1IMU6_HWID] = "L1IMU6",
148 [L1IMU7_HWID] = "L1IMU7",
149 [L1IMU8_HWID] = "L1IMU8",
150 [L1IMU9_HWID] = "L1IMU9",
151 [L1IMU10_HWID] = "L1IMU10",
152 [L1IMU11_HWID] = "L1IMU11",
153 [L1IMU12_HWID] = "L1IMU12",
154 [L1IMU13_HWID] = "L1IMU13",
155 [L1IMU14_HWID] = "L1IMU14",
156 [L1IMU15_HWID] = "L1IMU15",
157 [WAFLC_HWID] = "WAFLC",
158 [FCH_USB_PD_HWID] = "FCH_USB_PD",
159 [PCIE_HWID] = "PCIE",
161 [DDCL_HWID] = "DDCL",
163 [IOAGR_HWID] = "IOAGR",
164 [NBIF_HWID] = "NBIF",
165 [IOAPIC_HWID] = "IOAPIC",
166 [SYSTEMHUB_HWID] = "SYSTEMHUB",
167 [NTBCCP_HWID] = "NTBCCP",
169 [SATA_HWID] = "SATA",
171 [CCXSEC_HWID] = "CCXSEC",
172 [XGMI_HWID] = "XGMI",
173 [XGBE_HWID] = "XGBE",
177 static int hw_id_map[MAX_HWIP] = {
179 [HDP_HWIP] = HDP_HWID,
180 [SDMA0_HWIP] = SDMA0_HWID,
181 [SDMA1_HWIP] = SDMA1_HWID,
182 [SDMA2_HWIP] = SDMA2_HWID,
183 [SDMA3_HWIP] = SDMA3_HWID,
184 [LSDMA_HWIP] = LSDMA_HWID,
185 [MMHUB_HWIP] = MMHUB_HWID,
186 [ATHUB_HWIP] = ATHUB_HWID,
187 [NBIO_HWIP] = NBIF_HWID,
188 [MP0_HWIP] = MP0_HWID,
189 [MP1_HWIP] = MP1_HWID,
190 [UVD_HWIP] = UVD_HWID,
191 [VCE_HWIP] = VCE_HWID,
193 [DCE_HWIP] = DMU_HWID,
194 [OSSSYS_HWIP] = OSSSYS_HWID,
195 [SMUIO_HWIP] = SMUIO_HWID,
196 [PWR_HWIP] = PWR_HWID,
197 [NBIF_HWIP] = NBIF_HWID,
198 [THM_HWIP] = THM_HWID,
199 [CLK_HWIP] = CLKA_HWID,
200 [UMC_HWIP] = UMC_HWID,
201 [XGMI_HWIP] = XGMI_HWID,
202 [DCI_HWIP] = DCI_HWID,
203 [PCIE_HWIP] = PCIE_HWID,
206 static int amdgpu_discovery_read_binary_from_sysmem(struct amdgpu_device *adev, uint8_t *binary)
208 u64 tmr_offset, tmr_size, pos;
212 ret = amdgpu_acpi_get_tmr_info(adev, &tmr_offset, &tmr_size);
216 pos = tmr_offset + tmr_size - DISCOVERY_TMR_OFFSET;
218 /* This region is read-only and reserved from system use */
219 discv_regn = memremap(pos, adev->mman.discovery_tmr_size, MEMREMAP_WC);
221 memcpy(binary, discv_regn, adev->mman.discovery_tmr_size);
222 memunmap(discv_regn);
229 static int amdgpu_discovery_read_binary_from_mem(struct amdgpu_device *adev,
232 uint64_t vram_size = (uint64_t)RREG32(mmRCC_CONFIG_MEMSIZE) << 20;
236 uint64_t pos = vram_size - DISCOVERY_TMR_OFFSET;
237 amdgpu_device_vram_access(adev, pos, (uint32_t *)binary,
238 adev->mman.discovery_tmr_size, false);
240 ret = amdgpu_discovery_read_binary_from_sysmem(adev, binary);
246 static int amdgpu_discovery_read_binary_from_file(struct amdgpu_device *adev, uint8_t *binary)
248 const struct firmware *fw;
252 switch (amdgpu_discovery) {
254 fw_name = FIRMWARE_IP_DISCOVERY;
257 dev_warn(adev->dev, "amdgpu_discovery is not set properly\n");
261 r = request_firmware(&fw, fw_name, adev->dev);
263 dev_err(adev->dev, "can't load firmware \"%s\"\n",
268 memcpy((u8 *)binary, (u8 *)fw->data, fw->size);
269 release_firmware(fw);
274 static uint16_t amdgpu_discovery_calculate_checksum(uint8_t *data, uint32_t size)
276 uint16_t checksum = 0;
279 for (i = 0; i < size; i++)
285 static inline bool amdgpu_discovery_verify_checksum(uint8_t *data, uint32_t size,
288 return !!(amdgpu_discovery_calculate_checksum(data, size) == expected);
291 static inline bool amdgpu_discovery_verify_binary_signature(uint8_t *binary)
293 struct binary_header *bhdr;
294 bhdr = (struct binary_header *)binary;
296 return (le32_to_cpu(bhdr->binary_signature) == BINARY_SIGNATURE);
299 static void amdgpu_discovery_harvest_config_quirk(struct amdgpu_device *adev)
302 * So far, apply this quirk only on those Navy Flounder boards which
303 * have a bad harvest table of VCN config.
305 if ((adev->ip_versions[UVD_HWIP][1] == IP_VERSION(3, 0, 1)) &&
306 (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 2))) {
307 switch (adev->pdev->revision) {
315 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
316 adev->vcn.inst_mask &= ~AMDGPU_VCN_HARVEST_VCN1;
324 static int amdgpu_discovery_init(struct amdgpu_device *adev)
326 struct table_info *info;
327 struct binary_header *bhdr;
333 adev->mman.discovery_tmr_size = DISCOVERY_TMR_SIZE;
334 adev->mman.discovery_bin = kzalloc(adev->mman.discovery_tmr_size, GFP_KERNEL);
335 if (!adev->mman.discovery_bin)
338 /* Read from file if it is the preferred option */
339 if (amdgpu_discovery == 2) {
340 dev_info(adev->dev, "use ip discovery information from file");
341 r = amdgpu_discovery_read_binary_from_file(adev, adev->mman.discovery_bin);
344 dev_err(adev->dev, "failed to read ip discovery binary from file\n");
350 r = amdgpu_discovery_read_binary_from_mem(
351 adev, adev->mman.discovery_bin);
356 /* check the ip discovery binary signature */
357 if (!amdgpu_discovery_verify_binary_signature(adev->mman.discovery_bin)) {
359 "get invalid ip discovery binary signature\n");
364 bhdr = (struct binary_header *)adev->mman.discovery_bin;
366 offset = offsetof(struct binary_header, binary_checksum) +
367 sizeof(bhdr->binary_checksum);
368 size = le16_to_cpu(bhdr->binary_size) - offset;
369 checksum = le16_to_cpu(bhdr->binary_checksum);
371 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
373 dev_err(adev->dev, "invalid ip discovery binary checksum\n");
378 info = &bhdr->table_list[IP_DISCOVERY];
379 offset = le16_to_cpu(info->offset);
380 checksum = le16_to_cpu(info->checksum);
383 struct ip_discovery_header *ihdr =
384 (struct ip_discovery_header *)(adev->mman.discovery_bin + offset);
385 if (le32_to_cpu(ihdr->signature) != DISCOVERY_TABLE_SIGNATURE) {
386 dev_err(adev->dev, "invalid ip discovery data table signature\n");
391 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
392 le16_to_cpu(ihdr->size), checksum)) {
393 dev_err(adev->dev, "invalid ip discovery data table checksum\n");
399 info = &bhdr->table_list[GC];
400 offset = le16_to_cpu(info->offset);
401 checksum = le16_to_cpu(info->checksum);
404 struct gpu_info_header *ghdr =
405 (struct gpu_info_header *)(adev->mman.discovery_bin + offset);
407 if (le32_to_cpu(ghdr->table_id) != GC_TABLE_ID) {
408 dev_err(adev->dev, "invalid ip discovery gc table id\n");
413 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
414 le32_to_cpu(ghdr->size), checksum)) {
415 dev_err(adev->dev, "invalid gc data table checksum\n");
421 info = &bhdr->table_list[HARVEST_INFO];
422 offset = le16_to_cpu(info->offset);
423 checksum = le16_to_cpu(info->checksum);
426 struct harvest_info_header *hhdr =
427 (struct harvest_info_header *)(adev->mman.discovery_bin + offset);
429 if (le32_to_cpu(hhdr->signature) != HARVEST_TABLE_SIGNATURE) {
430 dev_err(adev->dev, "invalid ip discovery harvest table signature\n");
435 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
436 sizeof(struct harvest_table), checksum)) {
437 dev_err(adev->dev, "invalid harvest data table checksum\n");
443 info = &bhdr->table_list[VCN_INFO];
444 offset = le16_to_cpu(info->offset);
445 checksum = le16_to_cpu(info->checksum);
448 struct vcn_info_header *vhdr =
449 (struct vcn_info_header *)(adev->mman.discovery_bin + offset);
451 if (le32_to_cpu(vhdr->table_id) != VCN_INFO_TABLE_ID) {
452 dev_err(adev->dev, "invalid ip discovery vcn table id\n");
457 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
458 le32_to_cpu(vhdr->size_bytes), checksum)) {
459 dev_err(adev->dev, "invalid vcn data table checksum\n");
465 info = &bhdr->table_list[MALL_INFO];
466 offset = le16_to_cpu(info->offset);
467 checksum = le16_to_cpu(info->checksum);
470 struct mall_info_header *mhdr =
471 (struct mall_info_header *)(adev->mman.discovery_bin + offset);
473 if (le32_to_cpu(mhdr->table_id) != MALL_INFO_TABLE_ID) {
474 dev_err(adev->dev, "invalid ip discovery mall table id\n");
479 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
480 le32_to_cpu(mhdr->size_bytes), checksum)) {
481 dev_err(adev->dev, "invalid mall data table checksum\n");
490 kfree(adev->mman.discovery_bin);
491 adev->mman.discovery_bin = NULL;
496 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev);
498 void amdgpu_discovery_fini(struct amdgpu_device *adev)
500 amdgpu_discovery_sysfs_fini(adev);
501 kfree(adev->mman.discovery_bin);
502 adev->mman.discovery_bin = NULL;
505 static int amdgpu_discovery_validate_ip(const struct ip_v4 *ip)
507 if (ip->instance_number >= HWIP_MAX_INSTANCE) {
508 DRM_ERROR("Unexpected instance_number (%d) from ip discovery blob\n",
509 ip->instance_number);
512 if (le16_to_cpu(ip->hw_id) >= HW_ID_MAX) {
513 DRM_ERROR("Unexpected hw_id (%d) from ip discovery blob\n",
514 le16_to_cpu(ip->hw_id));
521 static void amdgpu_discovery_read_harvest_bit_per_ip(struct amdgpu_device *adev,
522 uint32_t *vcn_harvest_count)
524 struct binary_header *bhdr;
525 struct ip_discovery_header *ihdr;
526 struct die_header *dhdr;
528 uint16_t die_offset, ip_offset, num_dies, num_ips;
531 bhdr = (struct binary_header *)adev->mman.discovery_bin;
532 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
533 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
534 num_dies = le16_to_cpu(ihdr->num_dies);
536 /* scan harvest bit of all IP data structures */
537 for (i = 0; i < num_dies; i++) {
538 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
539 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
540 num_ips = le16_to_cpu(dhdr->num_ips);
541 ip_offset = die_offset + sizeof(*dhdr);
543 for (j = 0; j < num_ips; j++) {
544 ip = (struct ip_v4 *)(adev->mman.discovery_bin + ip_offset);
546 if (amdgpu_discovery_validate_ip(ip))
549 if (le16_to_cpu(ip->variant) == 1) {
550 switch (le16_to_cpu(ip->hw_id)) {
552 (*vcn_harvest_count)++;
553 if (ip->instance_number == 0) {
554 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN0;
555 adev->vcn.inst_mask &=
556 ~AMDGPU_VCN_HARVEST_VCN0;
557 adev->jpeg.inst_mask &=
558 ~AMDGPU_VCN_HARVEST_VCN0;
560 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
561 adev->vcn.inst_mask &=
562 ~AMDGPU_VCN_HARVEST_VCN1;
563 adev->jpeg.inst_mask &=
564 ~AMDGPU_VCN_HARVEST_VCN1;
568 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
575 if (ihdr->base_addr_64_bit)
576 ip_offset += struct_size(ip, base_address_64, ip->num_base_address);
578 ip_offset += struct_size(ip, base_address, ip->num_base_address);
583 static void amdgpu_discovery_read_from_harvest_table(struct amdgpu_device *adev,
584 uint32_t *vcn_harvest_count,
585 uint32_t *umc_harvest_count)
587 struct binary_header *bhdr;
588 struct harvest_table *harvest_info;
591 uint32_t umc_harvest_config = 0;
593 bhdr = (struct binary_header *)adev->mman.discovery_bin;
594 offset = le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset);
597 dev_err(adev->dev, "invalid harvest table offset\n");
601 harvest_info = (struct harvest_table *)(adev->mman.discovery_bin + offset);
603 for (i = 0; i < 32; i++) {
604 if (le16_to_cpu(harvest_info->list[i].hw_id) == 0)
607 switch (le16_to_cpu(harvest_info->list[i].hw_id)) {
609 (*vcn_harvest_count)++;
610 adev->vcn.harvest_config |=
611 (1 << harvest_info->list[i].number_instance);
612 adev->jpeg.harvest_config |=
613 (1 << harvest_info->list[i].number_instance);
615 adev->vcn.inst_mask &=
616 ~(1U << harvest_info->list[i].number_instance);
617 adev->jpeg.inst_mask &=
618 ~(1U << harvest_info->list[i].number_instance);
621 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
624 umc_harvest_config |=
625 1 << (le16_to_cpu(harvest_info->list[i].number_instance));
626 (*umc_harvest_count)++;
629 adev->gfx.xcc_mask &=
630 ~(1U << harvest_info->list[i].number_instance);
633 adev->sdma.sdma_mask &=
634 ~(1U << harvest_info->list[i].number_instance);
641 adev->umc.active_mask = ((1 << adev->umc.node_inst_num) - 1) &
645 /* ================================================== */
647 struct ip_hw_instance {
648 struct kobject kobj; /* ip_discovery/die/#die/#hw_id/#instance/<attrs...> */
652 u8 major, minor, revision;
655 int num_base_addresses;
660 struct kset hw_id_kset; /* ip_discovery/die/#die/#hw_id/, contains ip_hw_instance */
664 struct ip_die_entry {
665 struct kset ip_kset; /* ip_discovery/die/#die/, contains ip_hw_id */
669 /* -------------------------------------------------- */
671 struct ip_hw_instance_attr {
672 struct attribute attr;
673 ssize_t (*show)(struct ip_hw_instance *ip_hw_instance, char *buf);
676 static ssize_t hw_id_show(struct ip_hw_instance *ip_hw_instance, char *buf)
678 return sysfs_emit(buf, "%d\n", ip_hw_instance->hw_id);
681 static ssize_t num_instance_show(struct ip_hw_instance *ip_hw_instance, char *buf)
683 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_instance);
686 static ssize_t major_show(struct ip_hw_instance *ip_hw_instance, char *buf)
688 return sysfs_emit(buf, "%d\n", ip_hw_instance->major);
691 static ssize_t minor_show(struct ip_hw_instance *ip_hw_instance, char *buf)
693 return sysfs_emit(buf, "%d\n", ip_hw_instance->minor);
696 static ssize_t revision_show(struct ip_hw_instance *ip_hw_instance, char *buf)
698 return sysfs_emit(buf, "%d\n", ip_hw_instance->revision);
701 static ssize_t harvest_show(struct ip_hw_instance *ip_hw_instance, char *buf)
703 return sysfs_emit(buf, "0x%01X\n", ip_hw_instance->harvest);
706 static ssize_t num_base_addresses_show(struct ip_hw_instance *ip_hw_instance, char *buf)
708 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_base_addresses);
711 static ssize_t base_addr_show(struct ip_hw_instance *ip_hw_instance, char *buf)
716 for (res = at = ii = 0; ii < ip_hw_instance->num_base_addresses; ii++) {
717 /* Here we satisfy the condition that, at + size <= PAGE_SIZE.
719 if (at + 12 > PAGE_SIZE)
721 res = sysfs_emit_at(buf, at, "0x%08X\n",
722 ip_hw_instance->base_addr[ii]);
728 return res < 0 ? res : at;
731 static struct ip_hw_instance_attr ip_hw_attr[] = {
733 __ATTR_RO(num_instance),
738 __ATTR_RO(num_base_addresses),
739 __ATTR_RO(base_addr),
742 static struct attribute *ip_hw_instance_attrs[ARRAY_SIZE(ip_hw_attr) + 1];
743 ATTRIBUTE_GROUPS(ip_hw_instance);
745 #define to_ip_hw_instance(x) container_of(x, struct ip_hw_instance, kobj)
746 #define to_ip_hw_instance_attr(x) container_of(x, struct ip_hw_instance_attr, attr)
748 static ssize_t ip_hw_instance_attr_show(struct kobject *kobj,
749 struct attribute *attr,
752 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
753 struct ip_hw_instance_attr *ip_hw_attr = to_ip_hw_instance_attr(attr);
755 if (!ip_hw_attr->show)
758 return ip_hw_attr->show(ip_hw_instance, buf);
761 static const struct sysfs_ops ip_hw_instance_sysfs_ops = {
762 .show = ip_hw_instance_attr_show,
765 static void ip_hw_instance_release(struct kobject *kobj)
767 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
769 kfree(ip_hw_instance);
772 static const struct kobj_type ip_hw_instance_ktype = {
773 .release = ip_hw_instance_release,
774 .sysfs_ops = &ip_hw_instance_sysfs_ops,
775 .default_groups = ip_hw_instance_groups,
778 /* -------------------------------------------------- */
780 #define to_ip_hw_id(x) container_of(to_kset(x), struct ip_hw_id, hw_id_kset)
782 static void ip_hw_id_release(struct kobject *kobj)
784 struct ip_hw_id *ip_hw_id = to_ip_hw_id(kobj);
786 if (!list_empty(&ip_hw_id->hw_id_kset.list))
787 DRM_ERROR("ip_hw_id->hw_id_kset is not empty");
791 static const struct kobj_type ip_hw_id_ktype = {
792 .release = ip_hw_id_release,
793 .sysfs_ops = &kobj_sysfs_ops,
796 /* -------------------------------------------------- */
798 static void die_kobj_release(struct kobject *kobj);
799 static void ip_disc_release(struct kobject *kobj);
801 struct ip_die_entry_attribute {
802 struct attribute attr;
803 ssize_t (*show)(struct ip_die_entry *ip_die_entry, char *buf);
806 #define to_ip_die_entry_attr(x) container_of(x, struct ip_die_entry_attribute, attr)
808 static ssize_t num_ips_show(struct ip_die_entry *ip_die_entry, char *buf)
810 return sysfs_emit(buf, "%d\n", ip_die_entry->num_ips);
813 /* If there are more ip_die_entry attrs, other than the number of IPs,
814 * we can make this intro an array of attrs, and then initialize
815 * ip_die_entry_attrs in a loop.
817 static struct ip_die_entry_attribute num_ips_attr =
820 static struct attribute *ip_die_entry_attrs[] = {
824 ATTRIBUTE_GROUPS(ip_die_entry); /* ip_die_entry_groups */
826 #define to_ip_die_entry(x) container_of(to_kset(x), struct ip_die_entry, ip_kset)
828 static ssize_t ip_die_entry_attr_show(struct kobject *kobj,
829 struct attribute *attr,
832 struct ip_die_entry_attribute *ip_die_entry_attr = to_ip_die_entry_attr(attr);
833 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
835 if (!ip_die_entry_attr->show)
838 return ip_die_entry_attr->show(ip_die_entry, buf);
841 static void ip_die_entry_release(struct kobject *kobj)
843 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
845 if (!list_empty(&ip_die_entry->ip_kset.list))
846 DRM_ERROR("ip_die_entry->ip_kset is not empty");
850 static const struct sysfs_ops ip_die_entry_sysfs_ops = {
851 .show = ip_die_entry_attr_show,
854 static const struct kobj_type ip_die_entry_ktype = {
855 .release = ip_die_entry_release,
856 .sysfs_ops = &ip_die_entry_sysfs_ops,
857 .default_groups = ip_die_entry_groups,
860 static const struct kobj_type die_kobj_ktype = {
861 .release = die_kobj_release,
862 .sysfs_ops = &kobj_sysfs_ops,
865 static const struct kobj_type ip_discovery_ktype = {
866 .release = ip_disc_release,
867 .sysfs_ops = &kobj_sysfs_ops,
870 struct ip_discovery_top {
871 struct kobject kobj; /* ip_discovery/ */
872 struct kset die_kset; /* ip_discovery/die/, contains ip_die_entry */
873 struct amdgpu_device *adev;
876 static void die_kobj_release(struct kobject *kobj)
878 struct ip_discovery_top *ip_top = container_of(to_kset(kobj),
879 struct ip_discovery_top,
881 if (!list_empty(&ip_top->die_kset.list))
882 DRM_ERROR("ip_top->die_kset is not empty");
885 static void ip_disc_release(struct kobject *kobj)
887 struct ip_discovery_top *ip_top = container_of(kobj, struct ip_discovery_top,
889 struct amdgpu_device *adev = ip_top->adev;
895 static uint8_t amdgpu_discovery_get_harvest_info(struct amdgpu_device *adev,
896 uint16_t hw_id, uint8_t inst)
900 /* Until a uniform way is figured, get mask based on hwid */
903 harvest = ((1 << inst) & adev->vcn.inst_mask) == 0;
906 if (adev->harvest_ip_mask & AMD_HARVEST_IP_DMU_MASK)
910 /* TODO: It needs another parsing; for now, ignore.*/
913 harvest = ((1 << inst) & adev->gfx.xcc_mask) == 0;
916 harvest = ((1 << inst) & adev->sdma.sdma_mask) == 0;
925 static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev,
926 struct ip_die_entry *ip_die_entry,
927 const size_t _ip_offset, const int num_ips,
932 DRM_DEBUG("num_ips:%d", num_ips);
934 /* Find all IPs of a given HW ID, and add their instance to
935 * #die/#hw_id/#instance/<attributes>
937 for (ii = 0; ii < HW_ID_MAX; ii++) {
938 struct ip_hw_id *ip_hw_id = NULL;
939 size_t ip_offset = _ip_offset;
941 for (jj = 0; jj < num_ips; jj++) {
943 struct ip_hw_instance *ip_hw_instance;
945 ip = (struct ip_v4 *)(adev->mman.discovery_bin + ip_offset);
946 if (amdgpu_discovery_validate_ip(ip) ||
947 le16_to_cpu(ip->hw_id) != ii)
950 DRM_DEBUG("match:%d @ ip_offset:%zu", ii, ip_offset);
952 /* We have a hw_id match; register the hw
953 * block if not yet registered.
956 ip_hw_id = kzalloc(sizeof(*ip_hw_id), GFP_KERNEL);
959 ip_hw_id->hw_id = ii;
961 kobject_set_name(&ip_hw_id->hw_id_kset.kobj, "%d", ii);
962 ip_hw_id->hw_id_kset.kobj.kset = &ip_die_entry->ip_kset;
963 ip_hw_id->hw_id_kset.kobj.ktype = &ip_hw_id_ktype;
964 res = kset_register(&ip_hw_id->hw_id_kset);
966 DRM_ERROR("Couldn't register ip_hw_id kset");
970 if (hw_id_names[ii]) {
971 res = sysfs_create_link(&ip_die_entry->ip_kset.kobj,
972 &ip_hw_id->hw_id_kset.kobj,
975 DRM_ERROR("Couldn't create IP link %s in IP Die:%s\n",
977 kobject_name(&ip_die_entry->ip_kset.kobj));
982 /* Now register its instance.
984 ip_hw_instance = kzalloc(struct_size(ip_hw_instance,
986 ip->num_base_address),
988 if (!ip_hw_instance) {
989 DRM_ERROR("no memory for ip_hw_instance");
992 ip_hw_instance->hw_id = le16_to_cpu(ip->hw_id); /* == ii */
993 ip_hw_instance->num_instance = ip->instance_number;
994 ip_hw_instance->major = ip->major;
995 ip_hw_instance->minor = ip->minor;
996 ip_hw_instance->revision = ip->revision;
997 ip_hw_instance->harvest =
998 amdgpu_discovery_get_harvest_info(
999 adev, ip_hw_instance->hw_id,
1000 ip_hw_instance->num_instance);
1001 ip_hw_instance->num_base_addresses = ip->num_base_address;
1003 for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++) {
1005 ip_hw_instance->base_addr[kk] =
1006 lower_32_bits(le64_to_cpu(ip->base_address_64[kk])) & 0x3FFFFFFF;
1008 ip_hw_instance->base_addr[kk] = ip->base_address[kk];
1011 kobject_init(&ip_hw_instance->kobj, &ip_hw_instance_ktype);
1012 ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset;
1013 res = kobject_add(&ip_hw_instance->kobj, NULL,
1014 "%d", ip_hw_instance->num_instance);
1017 ip_offset += struct_size(ip, base_address_64,
1018 ip->num_base_address);
1020 ip_offset += struct_size(ip, base_address,
1021 ip->num_base_address);
1028 static int amdgpu_discovery_sysfs_recurse(struct amdgpu_device *adev)
1030 struct binary_header *bhdr;
1031 struct ip_discovery_header *ihdr;
1032 struct die_header *dhdr;
1033 struct kset *die_kset = &adev->ip_top->die_kset;
1034 u16 num_dies, die_offset, num_ips;
1038 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1039 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1040 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1041 num_dies = le16_to_cpu(ihdr->num_dies);
1043 DRM_DEBUG("number of dies: %d\n", num_dies);
1045 for (ii = 0; ii < num_dies; ii++) {
1046 struct ip_die_entry *ip_die_entry;
1048 die_offset = le16_to_cpu(ihdr->die_info[ii].die_offset);
1049 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1050 num_ips = le16_to_cpu(dhdr->num_ips);
1051 ip_offset = die_offset + sizeof(*dhdr);
1053 /* Add the die to the kset.
1055 * dhdr->die_id == ii, which was checked in
1056 * amdgpu_discovery_reg_base_init().
1059 ip_die_entry = kzalloc(sizeof(*ip_die_entry), GFP_KERNEL);
1063 ip_die_entry->num_ips = num_ips;
1065 kobject_set_name(&ip_die_entry->ip_kset.kobj, "%d", le16_to_cpu(dhdr->die_id));
1066 ip_die_entry->ip_kset.kobj.kset = die_kset;
1067 ip_die_entry->ip_kset.kobj.ktype = &ip_die_entry_ktype;
1068 res = kset_register(&ip_die_entry->ip_kset);
1070 DRM_ERROR("Couldn't register ip_die_entry kset");
1071 kfree(ip_die_entry);
1075 amdgpu_discovery_sysfs_ips(adev, ip_die_entry, ip_offset, num_ips, !!ihdr->base_addr_64_bit);
1081 static int amdgpu_discovery_sysfs_init(struct amdgpu_device *adev)
1083 struct kset *die_kset;
1086 if (!adev->mman.discovery_bin)
1089 adev->ip_top = kzalloc(sizeof(*adev->ip_top), GFP_KERNEL);
1093 adev->ip_top->adev = adev;
1095 res = kobject_init_and_add(&adev->ip_top->kobj, &ip_discovery_ktype,
1096 &adev->dev->kobj, "ip_discovery");
1098 DRM_ERROR("Couldn't init and add ip_discovery/");
1102 die_kset = &adev->ip_top->die_kset;
1103 kobject_set_name(&die_kset->kobj, "%s", "die");
1104 die_kset->kobj.parent = &adev->ip_top->kobj;
1105 die_kset->kobj.ktype = &die_kobj_ktype;
1106 res = kset_register(&adev->ip_top->die_kset);
1108 DRM_ERROR("Couldn't register die_kset");
1112 for (ii = 0; ii < ARRAY_SIZE(ip_hw_attr); ii++)
1113 ip_hw_instance_attrs[ii] = &ip_hw_attr[ii].attr;
1114 ip_hw_instance_attrs[ii] = NULL;
1116 res = amdgpu_discovery_sysfs_recurse(adev);
1120 kobject_put(&adev->ip_top->kobj);
1124 /* -------------------------------------------------- */
1126 #define list_to_kobj(el) container_of(el, struct kobject, entry)
1128 static void amdgpu_discovery_sysfs_ip_hw_free(struct ip_hw_id *ip_hw_id)
1130 struct list_head *el, *tmp;
1131 struct kset *hw_id_kset;
1133 hw_id_kset = &ip_hw_id->hw_id_kset;
1134 spin_lock(&hw_id_kset->list_lock);
1135 list_for_each_prev_safe(el, tmp, &hw_id_kset->list) {
1137 spin_unlock(&hw_id_kset->list_lock);
1138 /* kobject is embedded in ip_hw_instance */
1139 kobject_put(list_to_kobj(el));
1140 spin_lock(&hw_id_kset->list_lock);
1142 spin_unlock(&hw_id_kset->list_lock);
1143 kobject_put(&ip_hw_id->hw_id_kset.kobj);
1146 static void amdgpu_discovery_sysfs_die_free(struct ip_die_entry *ip_die_entry)
1148 struct list_head *el, *tmp;
1149 struct kset *ip_kset;
1151 ip_kset = &ip_die_entry->ip_kset;
1152 spin_lock(&ip_kset->list_lock);
1153 list_for_each_prev_safe(el, tmp, &ip_kset->list) {
1155 spin_unlock(&ip_kset->list_lock);
1156 amdgpu_discovery_sysfs_ip_hw_free(to_ip_hw_id(list_to_kobj(el)));
1157 spin_lock(&ip_kset->list_lock);
1159 spin_unlock(&ip_kset->list_lock);
1160 kobject_put(&ip_die_entry->ip_kset.kobj);
1163 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev)
1165 struct list_head *el, *tmp;
1166 struct kset *die_kset;
1168 die_kset = &adev->ip_top->die_kset;
1169 spin_lock(&die_kset->list_lock);
1170 list_for_each_prev_safe(el, tmp, &die_kset->list) {
1172 spin_unlock(&die_kset->list_lock);
1173 amdgpu_discovery_sysfs_die_free(to_ip_die_entry(list_to_kobj(el)));
1174 spin_lock(&die_kset->list_lock);
1176 spin_unlock(&die_kset->list_lock);
1177 kobject_put(&adev->ip_top->die_kset.kobj);
1178 kobject_put(&adev->ip_top->kobj);
1181 /* ================================================== */
1183 static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
1185 struct binary_header *bhdr;
1186 struct ip_discovery_header *ihdr;
1187 struct die_header *dhdr;
1189 uint16_t die_offset;
1193 uint8_t num_base_address;
1198 r = amdgpu_discovery_init(adev);
1200 DRM_ERROR("amdgpu_discovery_init failed\n");
1204 adev->gfx.xcc_mask = 0;
1205 adev->sdma.sdma_mask = 0;
1206 adev->vcn.inst_mask = 0;
1207 adev->jpeg.inst_mask = 0;
1208 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1209 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1210 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1211 num_dies = le16_to_cpu(ihdr->num_dies);
1213 DRM_DEBUG("number of dies: %d\n", num_dies);
1215 for (i = 0; i < num_dies; i++) {
1216 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
1217 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1218 num_ips = le16_to_cpu(dhdr->num_ips);
1219 ip_offset = die_offset + sizeof(*dhdr);
1221 if (le16_to_cpu(dhdr->die_id) != i) {
1222 DRM_ERROR("invalid die id %d, expected %d\n",
1223 le16_to_cpu(dhdr->die_id), i);
1227 DRM_DEBUG("number of hardware IPs on die%d: %d\n",
1228 le16_to_cpu(dhdr->die_id), num_ips);
1230 for (j = 0; j < num_ips; j++) {
1231 ip = (struct ip_v4 *)(adev->mman.discovery_bin + ip_offset);
1233 if (amdgpu_discovery_validate_ip(ip))
1236 num_base_address = ip->num_base_address;
1238 DRM_DEBUG("%s(%d) #%d v%d.%d.%d:\n",
1239 hw_id_names[le16_to_cpu(ip->hw_id)],
1240 le16_to_cpu(ip->hw_id),
1241 ip->instance_number,
1242 ip->major, ip->minor,
1245 if (le16_to_cpu(ip->hw_id) == VCN_HWID) {
1246 /* Bit [5:0]: original revision value
1247 * Bit [7:6]: en/decode capability:
1248 * 0b00 : VCN function normally
1249 * 0b10 : encode is disabled
1250 * 0b01 : decode is disabled
1252 adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
1253 ip->revision & 0xc0;
1254 ip->revision &= ~0xc0;
1255 if (adev->vcn.num_vcn_inst <
1256 AMDGPU_MAX_VCN_INSTANCES) {
1257 adev->vcn.num_vcn_inst++;
1258 adev->vcn.inst_mask |=
1259 (1U << ip->instance_number);
1260 adev->jpeg.inst_mask |=
1261 (1U << ip->instance_number);
1263 dev_err(adev->dev, "Too many VCN instances: %d vs %d\n",
1264 adev->vcn.num_vcn_inst + 1,
1265 AMDGPU_MAX_VCN_INSTANCES);
1268 if (le16_to_cpu(ip->hw_id) == SDMA0_HWID ||
1269 le16_to_cpu(ip->hw_id) == SDMA1_HWID ||
1270 le16_to_cpu(ip->hw_id) == SDMA2_HWID ||
1271 le16_to_cpu(ip->hw_id) == SDMA3_HWID) {
1272 if (adev->sdma.num_instances <
1273 AMDGPU_MAX_SDMA_INSTANCES) {
1274 adev->sdma.num_instances++;
1275 adev->sdma.sdma_mask |=
1276 (1U << ip->instance_number);
1278 dev_err(adev->dev, "Too many SDMA instances: %d vs %d\n",
1279 adev->sdma.num_instances + 1,
1280 AMDGPU_MAX_SDMA_INSTANCES);
1284 if (le16_to_cpu(ip->hw_id) == UMC_HWID) {
1285 adev->gmc.num_umc++;
1286 adev->umc.node_inst_num++;
1289 if (le16_to_cpu(ip->hw_id) == GC_HWID)
1290 adev->gfx.xcc_mask |=
1291 (1U << ip->instance_number);
1293 for (k = 0; k < num_base_address; k++) {
1295 * convert the endianness of base addresses in place,
1296 * so that we don't need to convert them when accessing adev->reg_offset.
1298 if (ihdr->base_addr_64_bit)
1299 /* Truncate the 64bit base address from ip discovery
1300 * and only store lower 32bit ip base in reg_offset[].
1301 * Bits > 32 follows ASIC specific format, thus just
1302 * discard them and handle it within specific ASIC.
1303 * By this way reg_offset[] and related helpers can
1305 * The base address is in dwords, thus clear the
1306 * highest 2 bits to store.
1308 ip->base_address[k] =
1309 lower_32_bits(le64_to_cpu(ip->base_address_64[k])) & 0x3FFFFFFF;
1311 ip->base_address[k] = le32_to_cpu(ip->base_address[k]);
1312 DRM_DEBUG("\t0x%08x\n", ip->base_address[k]);
1315 for (hw_ip = 0; hw_ip < MAX_HWIP; hw_ip++) {
1316 if (hw_id_map[hw_ip] == le16_to_cpu(ip->hw_id) &&
1317 hw_id_map[hw_ip] != 0) {
1318 DRM_DEBUG("set register base offset for %s\n",
1319 hw_id_names[le16_to_cpu(ip->hw_id)]);
1320 adev->reg_offset[hw_ip][ip->instance_number] =
1322 /* Instance support is somewhat inconsistent.
1323 * SDMA is a good example. Sienna cichlid has 4 total
1324 * SDMA instances, each enumerated separately (HWIDs
1325 * 42, 43, 68, 69). Arcturus has 8 total SDMA instances,
1326 * but they are enumerated as multiple instances of the
1327 * same HWIDs (4x HWID 42, 4x HWID 43). UMC is another
1328 * example. On most chips there are multiple instances
1329 * with the same HWID.
1331 adev->ip_versions[hw_ip][ip->instance_number] =
1332 IP_VERSION(ip->major, ip->minor, ip->revision);
1337 if (ihdr->base_addr_64_bit)
1338 ip_offset += struct_size(ip, base_address_64, ip->num_base_address);
1340 ip_offset += struct_size(ip, base_address, ip->num_base_address);
1347 static void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
1349 int vcn_harvest_count = 0;
1350 int umc_harvest_count = 0;
1353 * Harvest table does not fit Navi1x and legacy GPUs,
1354 * so read harvest bit per IP data structure to set
1355 * harvest configuration.
1357 if (adev->ip_versions[GC_HWIP][0] < IP_VERSION(10, 2, 0) &&
1358 adev->ip_versions[GC_HWIP][0] != IP_VERSION(9, 4, 3)) {
1359 if ((adev->pdev->device == 0x731E &&
1360 (adev->pdev->revision == 0xC6 ||
1361 adev->pdev->revision == 0xC7)) ||
1362 (adev->pdev->device == 0x7340 &&
1363 adev->pdev->revision == 0xC9) ||
1364 (adev->pdev->device == 0x7360 &&
1365 adev->pdev->revision == 0xC7))
1366 amdgpu_discovery_read_harvest_bit_per_ip(adev,
1367 &vcn_harvest_count);
1369 amdgpu_discovery_read_from_harvest_table(adev,
1371 &umc_harvest_count);
1374 amdgpu_discovery_harvest_config_quirk(adev);
1376 if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
1377 adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
1378 adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
1381 if (umc_harvest_count < adev->gmc.num_umc) {
1382 adev->gmc.num_umc -= umc_harvest_count;
1387 struct gc_info_v1_0 v1;
1388 struct gc_info_v1_1 v1_1;
1389 struct gc_info_v1_2 v1_2;
1390 struct gc_info_v2_0 v2;
1393 static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
1395 struct binary_header *bhdr;
1396 union gc_info *gc_info;
1399 if (!adev->mman.discovery_bin) {
1400 DRM_ERROR("ip discovery uninitialized\n");
1404 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1405 offset = le16_to_cpu(bhdr->table_list[GC].offset);
1410 gc_info = (union gc_info *)(adev->mman.discovery_bin + offset);
1412 switch (le16_to_cpu(gc_info->v1.header.version_major)) {
1414 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v1.gc_num_se);
1415 adev->gfx.config.max_cu_per_sh = 2 * (le32_to_cpu(gc_info->v1.gc_num_wgp0_per_sa) +
1416 le32_to_cpu(gc_info->v1.gc_num_wgp1_per_sa));
1417 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1418 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v1.gc_num_rb_per_se);
1419 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v1.gc_num_gl2c);
1420 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v1.gc_num_gprs);
1421 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v1.gc_num_max_gs_thds);
1422 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v1.gc_gs_table_depth);
1423 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v1.gc_gsprim_buff_depth);
1424 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v1.gc_double_offchip_lds_buffer);
1425 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v1.gc_wave_size);
1426 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v1.gc_max_waves_per_simd);
1427 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v1.gc_max_scratch_slots_per_cu);
1428 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v1.gc_lds_size);
1429 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v1.gc_num_sc_per_se) /
1430 le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1431 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v1.gc_num_packer_per_sc);
1432 if (gc_info->v1.header.version_minor >= 1) {
1433 adev->gfx.config.gc_num_tcp_per_sa = le32_to_cpu(gc_info->v1_1.gc_num_tcp_per_sa);
1434 adev->gfx.config.gc_num_sdp_interface = le32_to_cpu(gc_info->v1_1.gc_num_sdp_interface);
1435 adev->gfx.config.gc_num_tcps = le32_to_cpu(gc_info->v1_1.gc_num_tcps);
1437 if (gc_info->v1.header.version_minor >= 2) {
1438 adev->gfx.config.gc_num_tcp_per_wpg = le32_to_cpu(gc_info->v1_2.gc_num_tcp_per_wpg);
1439 adev->gfx.config.gc_tcp_l1_size = le32_to_cpu(gc_info->v1_2.gc_tcp_l1_size);
1440 adev->gfx.config.gc_num_sqc_per_wgp = le32_to_cpu(gc_info->v1_2.gc_num_sqc_per_wgp);
1441 adev->gfx.config.gc_l1_instruction_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_instruction_cache_size_per_sqc);
1442 adev->gfx.config.gc_l1_data_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_data_cache_size_per_sqc);
1443 adev->gfx.config.gc_gl1c_per_sa = le32_to_cpu(gc_info->v1_2.gc_gl1c_per_sa);
1444 adev->gfx.config.gc_gl1c_size_per_instance = le32_to_cpu(gc_info->v1_2.gc_gl1c_size_per_instance);
1445 adev->gfx.config.gc_gl2c_per_gpu = le32_to_cpu(gc_info->v1_2.gc_gl2c_per_gpu);
1449 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v2.gc_num_se);
1450 adev->gfx.config.max_cu_per_sh = le32_to_cpu(gc_info->v2.gc_num_cu_per_sh);
1451 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1452 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v2.gc_num_rb_per_se);
1453 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v2.gc_num_tccs);
1454 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v2.gc_num_gprs);
1455 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v2.gc_num_max_gs_thds);
1456 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v2.gc_gs_table_depth);
1457 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v2.gc_gsprim_buff_depth);
1458 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v2.gc_double_offchip_lds_buffer);
1459 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v2.gc_wave_size);
1460 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v2.gc_max_waves_per_simd);
1461 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v2.gc_max_scratch_slots_per_cu);
1462 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v2.gc_lds_size);
1463 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v2.gc_num_sc_per_se) /
1464 le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1465 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v2.gc_num_packer_per_sc);
1469 "Unhandled GC info table %d.%d\n",
1470 le16_to_cpu(gc_info->v1.header.version_major),
1471 le16_to_cpu(gc_info->v1.header.version_minor));
1478 struct mall_info_v1_0 v1;
1481 static int amdgpu_discovery_get_mall_info(struct amdgpu_device *adev)
1483 struct binary_header *bhdr;
1484 union mall_info *mall_info;
1485 u32 u, mall_size_per_umc, m_s_present, half_use;
1489 if (!adev->mman.discovery_bin) {
1490 DRM_ERROR("ip discovery uninitialized\n");
1494 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1495 offset = le16_to_cpu(bhdr->table_list[MALL_INFO].offset);
1500 mall_info = (union mall_info *)(adev->mman.discovery_bin + offset);
1502 switch (le16_to_cpu(mall_info->v1.header.version_major)) {
1505 mall_size_per_umc = le32_to_cpu(mall_info->v1.mall_size_per_m);
1506 m_s_present = le32_to_cpu(mall_info->v1.m_s_present);
1507 half_use = le32_to_cpu(mall_info->v1.m_half_use);
1508 for (u = 0; u < adev->gmc.num_umc; u++) {
1509 if (m_s_present & (1 << u))
1510 mall_size += mall_size_per_umc * 2;
1511 else if (half_use & (1 << u))
1512 mall_size += mall_size_per_umc / 2;
1514 mall_size += mall_size_per_umc;
1516 adev->gmc.mall_size = mall_size;
1520 "Unhandled MALL info table %d.%d\n",
1521 le16_to_cpu(mall_info->v1.header.version_major),
1522 le16_to_cpu(mall_info->v1.header.version_minor));
1529 struct vcn_info_v1_0 v1;
1532 static int amdgpu_discovery_get_vcn_info(struct amdgpu_device *adev)
1534 struct binary_header *bhdr;
1535 union vcn_info *vcn_info;
1539 if (!adev->mman.discovery_bin) {
1540 DRM_ERROR("ip discovery uninitialized\n");
1544 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1545 * which is smaller than VCN_INFO_TABLE_MAX_NUM_INSTANCES
1546 * but that may change in the future with new GPUs so keep this
1547 * check for defensive purposes.
1549 if (adev->vcn.num_vcn_inst > VCN_INFO_TABLE_MAX_NUM_INSTANCES) {
1550 dev_err(adev->dev, "invalid vcn instances\n");
1554 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1555 offset = le16_to_cpu(bhdr->table_list[VCN_INFO].offset);
1560 vcn_info = (union vcn_info *)(adev->mman.discovery_bin + offset);
1562 switch (le16_to_cpu(vcn_info->v1.header.version_major)) {
1564 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1565 * so this won't overflow.
1567 for (v = 0; v < adev->vcn.num_vcn_inst; v++) {
1568 adev->vcn.vcn_codec_disable_mask[v] =
1569 le32_to_cpu(vcn_info->v1.instance_info[v].fuse_data.all_bits);
1574 "Unhandled VCN info table %d.%d\n",
1575 le16_to_cpu(vcn_info->v1.header.version_major),
1576 le16_to_cpu(vcn_info->v1.header.version_minor));
1582 static int amdgpu_discovery_set_common_ip_blocks(struct amdgpu_device *adev)
1584 /* what IP to use for this? */
1585 switch (adev->ip_versions[GC_HWIP][0]) {
1586 case IP_VERSION(9, 0, 1):
1587 case IP_VERSION(9, 1, 0):
1588 case IP_VERSION(9, 2, 1):
1589 case IP_VERSION(9, 2, 2):
1590 case IP_VERSION(9, 3, 0):
1591 case IP_VERSION(9, 4, 0):
1592 case IP_VERSION(9, 4, 1):
1593 case IP_VERSION(9, 4, 2):
1594 case IP_VERSION(9, 4, 3):
1595 amdgpu_device_ip_block_add(adev, &vega10_common_ip_block);
1597 case IP_VERSION(10, 1, 10):
1598 case IP_VERSION(10, 1, 1):
1599 case IP_VERSION(10, 1, 2):
1600 case IP_VERSION(10, 1, 3):
1601 case IP_VERSION(10, 1, 4):
1602 case IP_VERSION(10, 3, 0):
1603 case IP_VERSION(10, 3, 1):
1604 case IP_VERSION(10, 3, 2):
1605 case IP_VERSION(10, 3, 3):
1606 case IP_VERSION(10, 3, 4):
1607 case IP_VERSION(10, 3, 5):
1608 case IP_VERSION(10, 3, 6):
1609 case IP_VERSION(10, 3, 7):
1610 amdgpu_device_ip_block_add(adev, &nv_common_ip_block);
1612 case IP_VERSION(11, 0, 0):
1613 case IP_VERSION(11, 0, 1):
1614 case IP_VERSION(11, 0, 2):
1615 case IP_VERSION(11, 0, 3):
1616 case IP_VERSION(11, 0, 4):
1617 amdgpu_device_ip_block_add(adev, &soc21_common_ip_block);
1621 "Failed to add common ip block(GC_HWIP:0x%x)\n",
1622 adev->ip_versions[GC_HWIP][0]);
1628 static int amdgpu_discovery_set_gmc_ip_blocks(struct amdgpu_device *adev)
1630 /* use GC or MMHUB IP version */
1631 switch (adev->ip_versions[GC_HWIP][0]) {
1632 case IP_VERSION(9, 0, 1):
1633 case IP_VERSION(9, 1, 0):
1634 case IP_VERSION(9, 2, 1):
1635 case IP_VERSION(9, 2, 2):
1636 case IP_VERSION(9, 3, 0):
1637 case IP_VERSION(9, 4, 0):
1638 case IP_VERSION(9, 4, 1):
1639 case IP_VERSION(9, 4, 2):
1640 case IP_VERSION(9, 4, 3):
1641 amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block);
1643 case IP_VERSION(10, 1, 10):
1644 case IP_VERSION(10, 1, 1):
1645 case IP_VERSION(10, 1, 2):
1646 case IP_VERSION(10, 1, 3):
1647 case IP_VERSION(10, 1, 4):
1648 case IP_VERSION(10, 3, 0):
1649 case IP_VERSION(10, 3, 1):
1650 case IP_VERSION(10, 3, 2):
1651 case IP_VERSION(10, 3, 3):
1652 case IP_VERSION(10, 3, 4):
1653 case IP_VERSION(10, 3, 5):
1654 case IP_VERSION(10, 3, 6):
1655 case IP_VERSION(10, 3, 7):
1656 amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block);
1658 case IP_VERSION(11, 0, 0):
1659 case IP_VERSION(11, 0, 1):
1660 case IP_VERSION(11, 0, 2):
1661 case IP_VERSION(11, 0, 3):
1662 case IP_VERSION(11, 0, 4):
1663 amdgpu_device_ip_block_add(adev, &gmc_v11_0_ip_block);
1667 "Failed to add gmc ip block(GC_HWIP:0x%x)\n",
1668 adev->ip_versions[GC_HWIP][0]);
1674 static int amdgpu_discovery_set_ih_ip_blocks(struct amdgpu_device *adev)
1676 switch (adev->ip_versions[OSSSYS_HWIP][0]) {
1677 case IP_VERSION(4, 0, 0):
1678 case IP_VERSION(4, 0, 1):
1679 case IP_VERSION(4, 1, 0):
1680 case IP_VERSION(4, 1, 1):
1681 case IP_VERSION(4, 3, 0):
1682 amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block);
1684 case IP_VERSION(4, 2, 0):
1685 case IP_VERSION(4, 2, 1):
1686 case IP_VERSION(4, 4, 0):
1687 case IP_VERSION(4, 4, 2):
1688 amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block);
1690 case IP_VERSION(5, 0, 0):
1691 case IP_VERSION(5, 0, 1):
1692 case IP_VERSION(5, 0, 2):
1693 case IP_VERSION(5, 0, 3):
1694 case IP_VERSION(5, 2, 0):
1695 case IP_VERSION(5, 2, 1):
1696 amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);
1698 case IP_VERSION(6, 0, 0):
1699 case IP_VERSION(6, 0, 1):
1700 case IP_VERSION(6, 0, 2):
1701 amdgpu_device_ip_block_add(adev, &ih_v6_0_ip_block);
1705 "Failed to add ih ip block(OSSSYS_HWIP:0x%x)\n",
1706 adev->ip_versions[OSSSYS_HWIP][0]);
1712 static int amdgpu_discovery_set_psp_ip_blocks(struct amdgpu_device *adev)
1714 switch (adev->ip_versions[MP0_HWIP][0]) {
1715 case IP_VERSION(9, 0, 0):
1716 amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block);
1718 case IP_VERSION(10, 0, 0):
1719 case IP_VERSION(10, 0, 1):
1720 amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block);
1722 case IP_VERSION(11, 0, 0):
1723 case IP_VERSION(11, 0, 2):
1724 case IP_VERSION(11, 0, 4):
1725 case IP_VERSION(11, 0, 5):
1726 case IP_VERSION(11, 0, 9):
1727 case IP_VERSION(11, 0, 7):
1728 case IP_VERSION(11, 0, 11):
1729 case IP_VERSION(11, 0, 12):
1730 case IP_VERSION(11, 0, 13):
1731 case IP_VERSION(11, 5, 0):
1732 amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);
1734 case IP_VERSION(11, 0, 8):
1735 amdgpu_device_ip_block_add(adev, &psp_v11_0_8_ip_block);
1737 case IP_VERSION(11, 0, 3):
1738 case IP_VERSION(12, 0, 1):
1739 amdgpu_device_ip_block_add(adev, &psp_v12_0_ip_block);
1741 case IP_VERSION(13, 0, 0):
1742 case IP_VERSION(13, 0, 1):
1743 case IP_VERSION(13, 0, 2):
1744 case IP_VERSION(13, 0, 3):
1745 case IP_VERSION(13, 0, 5):
1746 case IP_VERSION(13, 0, 6):
1747 case IP_VERSION(13, 0, 7):
1748 case IP_VERSION(13, 0, 8):
1749 case IP_VERSION(13, 0, 10):
1750 case IP_VERSION(13, 0, 11):
1751 amdgpu_device_ip_block_add(adev, &psp_v13_0_ip_block);
1753 case IP_VERSION(13, 0, 4):
1754 amdgpu_device_ip_block_add(adev, &psp_v13_0_4_ip_block);
1758 "Failed to add psp ip block(MP0_HWIP:0x%x)\n",
1759 adev->ip_versions[MP0_HWIP][0]);
1765 static int amdgpu_discovery_set_smu_ip_blocks(struct amdgpu_device *adev)
1767 switch (adev->ip_versions[MP1_HWIP][0]) {
1768 case IP_VERSION(9, 0, 0):
1769 case IP_VERSION(10, 0, 0):
1770 case IP_VERSION(10, 0, 1):
1771 case IP_VERSION(11, 0, 2):
1772 if (adev->asic_type == CHIP_ARCTURUS)
1773 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1775 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block);
1777 case IP_VERSION(11, 0, 0):
1778 case IP_VERSION(11, 0, 5):
1779 case IP_VERSION(11, 0, 9):
1780 case IP_VERSION(11, 0, 7):
1781 case IP_VERSION(11, 0, 8):
1782 case IP_VERSION(11, 0, 11):
1783 case IP_VERSION(11, 0, 12):
1784 case IP_VERSION(11, 0, 13):
1785 case IP_VERSION(11, 5, 0):
1786 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1788 case IP_VERSION(12, 0, 0):
1789 case IP_VERSION(12, 0, 1):
1790 amdgpu_device_ip_block_add(adev, &smu_v12_0_ip_block);
1792 case IP_VERSION(13, 0, 0):
1793 case IP_VERSION(13, 0, 1):
1794 case IP_VERSION(13, 0, 2):
1795 case IP_VERSION(13, 0, 3):
1796 case IP_VERSION(13, 0, 4):
1797 case IP_VERSION(13, 0, 5):
1798 case IP_VERSION(13, 0, 7):
1799 case IP_VERSION(13, 0, 8):
1800 case IP_VERSION(13, 0, 10):
1801 case IP_VERSION(13, 0, 11):
1802 amdgpu_device_ip_block_add(adev, &smu_v13_0_ip_block);
1806 "Failed to add smu ip block(MP1_HWIP:0x%x)\n",
1807 adev->ip_versions[MP1_HWIP][0]);
1813 #if defined(CONFIG_DRM_AMD_DC)
1814 static void amdgpu_discovery_set_sriov_display(struct amdgpu_device *adev)
1816 amdgpu_device_set_sriov_virtual_display(adev);
1817 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1821 static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)
1823 if (adev->enable_virtual_display) {
1824 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1828 if (!amdgpu_device_has_dc_support(adev))
1831 #if defined(CONFIG_DRM_AMD_DC)
1832 if (adev->ip_versions[DCE_HWIP][0]) {
1833 switch (adev->ip_versions[DCE_HWIP][0]) {
1834 case IP_VERSION(1, 0, 0):
1835 case IP_VERSION(1, 0, 1):
1836 case IP_VERSION(2, 0, 2):
1837 case IP_VERSION(2, 0, 0):
1838 case IP_VERSION(2, 0, 3):
1839 case IP_VERSION(2, 1, 0):
1840 case IP_VERSION(3, 0, 0):
1841 case IP_VERSION(3, 0, 2):
1842 case IP_VERSION(3, 0, 3):
1843 case IP_VERSION(3, 0, 1):
1844 case IP_VERSION(3, 1, 2):
1845 case IP_VERSION(3, 1, 3):
1846 case IP_VERSION(3, 1, 4):
1847 case IP_VERSION(3, 1, 5):
1848 case IP_VERSION(3, 1, 6):
1849 case IP_VERSION(3, 2, 0):
1850 case IP_VERSION(3, 2, 1):
1851 if (amdgpu_sriov_vf(adev))
1852 amdgpu_discovery_set_sriov_display(adev);
1854 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1858 "Failed to add dm ip block(DCE_HWIP:0x%x)\n",
1859 adev->ip_versions[DCE_HWIP][0]);
1862 } else if (adev->ip_versions[DCI_HWIP][0]) {
1863 switch (adev->ip_versions[DCI_HWIP][0]) {
1864 case IP_VERSION(12, 0, 0):
1865 case IP_VERSION(12, 0, 1):
1866 case IP_VERSION(12, 1, 0):
1867 if (amdgpu_sriov_vf(adev))
1868 amdgpu_discovery_set_sriov_display(adev);
1870 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1874 "Failed to add dm ip block(DCI_HWIP:0x%x)\n",
1875 adev->ip_versions[DCI_HWIP][0]);
1883 static int amdgpu_discovery_set_gc_ip_blocks(struct amdgpu_device *adev)
1885 switch (adev->ip_versions[GC_HWIP][0]) {
1886 case IP_VERSION(9, 0, 1):
1887 case IP_VERSION(9, 1, 0):
1888 case IP_VERSION(9, 2, 1):
1889 case IP_VERSION(9, 2, 2):
1890 case IP_VERSION(9, 3, 0):
1891 case IP_VERSION(9, 4, 0):
1892 case IP_VERSION(9, 4, 1):
1893 case IP_VERSION(9, 4, 2):
1894 amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
1896 case IP_VERSION(10, 1, 10):
1897 case IP_VERSION(10, 1, 2):
1898 case IP_VERSION(10, 1, 1):
1899 case IP_VERSION(10, 1, 3):
1900 case IP_VERSION(10, 1, 4):
1901 case IP_VERSION(10, 3, 0):
1902 case IP_VERSION(10, 3, 2):
1903 case IP_VERSION(10, 3, 1):
1904 case IP_VERSION(10, 3, 4):
1905 case IP_VERSION(10, 3, 5):
1906 case IP_VERSION(10, 3, 6):
1907 case IP_VERSION(10, 3, 3):
1908 case IP_VERSION(10, 3, 7):
1909 amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block);
1911 case IP_VERSION(11, 0, 0):
1912 case IP_VERSION(11, 0, 1):
1913 case IP_VERSION(11, 0, 2):
1914 case IP_VERSION(11, 0, 3):
1915 case IP_VERSION(11, 0, 4):
1916 amdgpu_device_ip_block_add(adev, &gfx_v11_0_ip_block);
1920 "Failed to add gfx ip block(GC_HWIP:0x%x)\n",
1921 adev->ip_versions[GC_HWIP][0]);
1927 static int amdgpu_discovery_set_sdma_ip_blocks(struct amdgpu_device *adev)
1929 switch (adev->ip_versions[SDMA0_HWIP][0]) {
1930 case IP_VERSION(4, 0, 0):
1931 case IP_VERSION(4, 0, 1):
1932 case IP_VERSION(4, 1, 0):
1933 case IP_VERSION(4, 1, 1):
1934 case IP_VERSION(4, 1, 2):
1935 case IP_VERSION(4, 2, 0):
1936 case IP_VERSION(4, 2, 2):
1937 case IP_VERSION(4, 4, 0):
1938 amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
1940 case IP_VERSION(4, 4, 2):
1941 amdgpu_device_ip_block_add(adev, &sdma_v4_4_2_ip_block);
1943 case IP_VERSION(5, 0, 0):
1944 case IP_VERSION(5, 0, 1):
1945 case IP_VERSION(5, 0, 2):
1946 case IP_VERSION(5, 0, 5):
1947 amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block);
1949 case IP_VERSION(5, 2, 0):
1950 case IP_VERSION(5, 2, 2):
1951 case IP_VERSION(5, 2, 4):
1952 case IP_VERSION(5, 2, 5):
1953 case IP_VERSION(5, 2, 6):
1954 case IP_VERSION(5, 2, 3):
1955 case IP_VERSION(5, 2, 1):
1956 case IP_VERSION(5, 2, 7):
1957 amdgpu_device_ip_block_add(adev, &sdma_v5_2_ip_block);
1959 case IP_VERSION(6, 0, 0):
1960 case IP_VERSION(6, 0, 1):
1961 case IP_VERSION(6, 0, 2):
1962 case IP_VERSION(6, 0, 3):
1963 amdgpu_device_ip_block_add(adev, &sdma_v6_0_ip_block);
1967 "Failed to add sdma ip block(SDMA0_HWIP:0x%x)\n",
1968 adev->ip_versions[SDMA0_HWIP][0]);
1974 static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
1976 if (adev->ip_versions[VCE_HWIP][0]) {
1977 switch (adev->ip_versions[UVD_HWIP][0]) {
1978 case IP_VERSION(7, 0, 0):
1979 case IP_VERSION(7, 2, 0):
1980 /* UVD is not supported on vega20 SR-IOV */
1981 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
1982 amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block);
1986 "Failed to add uvd v7 ip block(UVD_HWIP:0x%x)\n",
1987 adev->ip_versions[UVD_HWIP][0]);
1990 switch (adev->ip_versions[VCE_HWIP][0]) {
1991 case IP_VERSION(4, 0, 0):
1992 case IP_VERSION(4, 1, 0):
1993 /* VCE is not supported on vega20 SR-IOV */
1994 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
1995 amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block);
1999 "Failed to add VCE v4 ip block(VCE_HWIP:0x%x)\n",
2000 adev->ip_versions[VCE_HWIP][0]);
2004 switch (adev->ip_versions[UVD_HWIP][0]) {
2005 case IP_VERSION(1, 0, 0):
2006 case IP_VERSION(1, 0, 1):
2007 amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block);
2009 case IP_VERSION(2, 0, 0):
2010 case IP_VERSION(2, 0, 2):
2011 case IP_VERSION(2, 2, 0):
2012 amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
2013 if (!amdgpu_sriov_vf(adev))
2014 amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
2016 case IP_VERSION(2, 0, 3):
2018 case IP_VERSION(2, 5, 0):
2019 amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
2020 amdgpu_device_ip_block_add(adev, &jpeg_v2_5_ip_block);
2022 case IP_VERSION(2, 6, 0):
2023 amdgpu_device_ip_block_add(adev, &vcn_v2_6_ip_block);
2024 amdgpu_device_ip_block_add(adev, &jpeg_v2_6_ip_block);
2026 case IP_VERSION(3, 0, 0):
2027 case IP_VERSION(3, 0, 16):
2028 case IP_VERSION(3, 1, 1):
2029 case IP_VERSION(3, 1, 2):
2030 case IP_VERSION(3, 0, 2):
2031 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
2032 if (!amdgpu_sriov_vf(adev))
2033 amdgpu_device_ip_block_add(adev, &jpeg_v3_0_ip_block);
2035 case IP_VERSION(3, 0, 33):
2036 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
2038 case IP_VERSION(4, 0, 0):
2039 case IP_VERSION(4, 0, 2):
2040 case IP_VERSION(4, 0, 4):
2041 amdgpu_device_ip_block_add(adev, &vcn_v4_0_ip_block);
2042 amdgpu_device_ip_block_add(adev, &jpeg_v4_0_ip_block);
2044 case IP_VERSION(4, 0, 3):
2045 amdgpu_device_ip_block_add(adev, &vcn_v4_0_3_ip_block);
2046 amdgpu_device_ip_block_add(adev, &jpeg_v4_0_3_ip_block);
2050 "Failed to add vcn/jpeg ip block(UVD_HWIP:0x%x)\n",
2051 adev->ip_versions[UVD_HWIP][0]);
2058 static int amdgpu_discovery_set_mes_ip_blocks(struct amdgpu_device *adev)
2060 switch (adev->ip_versions[GC_HWIP][0]) {
2061 case IP_VERSION(10, 1, 10):
2062 case IP_VERSION(10, 1, 1):
2063 case IP_VERSION(10, 1, 2):
2064 case IP_VERSION(10, 1, 3):
2065 case IP_VERSION(10, 1, 4):
2066 case IP_VERSION(10, 3, 0):
2067 case IP_VERSION(10, 3, 1):
2068 case IP_VERSION(10, 3, 2):
2069 case IP_VERSION(10, 3, 3):
2070 case IP_VERSION(10, 3, 4):
2071 case IP_VERSION(10, 3, 5):
2072 case IP_VERSION(10, 3, 6):
2074 amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block);
2075 adev->enable_mes = true;
2077 adev->enable_mes_kiq = true;
2080 case IP_VERSION(11, 0, 0):
2081 case IP_VERSION(11, 0, 1):
2082 case IP_VERSION(11, 0, 2):
2083 case IP_VERSION(11, 0, 3):
2084 case IP_VERSION(11, 0, 4):
2085 amdgpu_device_ip_block_add(adev, &mes_v11_0_ip_block);
2086 adev->enable_mes = true;
2087 adev->enable_mes_kiq = true;
2095 static void amdgpu_discovery_init_soc_config(struct amdgpu_device *adev)
2097 switch (adev->ip_versions[GC_HWIP][0]) {
2098 case IP_VERSION(9, 4, 3):
2099 aqua_vanjaram_init_soc_config(adev);
2106 int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)
2110 switch (adev->asic_type) {
2112 vega10_reg_base_init(adev);
2113 adev->sdma.num_instances = 2;
2114 adev->gmc.num_umc = 4;
2115 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 0, 0);
2116 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 0, 0);
2117 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 0);
2118 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 0);
2119 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 0);
2120 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 0);
2121 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2122 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 1, 0);
2123 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 0, 0);
2124 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2125 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2126 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2127 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 0);
2128 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 0, 1);
2129 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2130 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2131 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 0);
2134 vega10_reg_base_init(adev);
2135 adev->sdma.num_instances = 2;
2136 adev->gmc.num_umc = 4;
2137 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2138 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2139 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 1);
2140 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 1);
2141 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 1);
2142 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 1);
2143 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 5, 0);
2144 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 2, 0);
2145 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 0);
2146 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2147 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2148 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2149 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 1);
2150 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 1);
2151 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2152 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2153 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 1);
2156 vega10_reg_base_init(adev);
2157 adev->sdma.num_instances = 1;
2158 adev->vcn.num_vcn_inst = 1;
2159 adev->gmc.num_umc = 2;
2160 if (adev->apu_flags & AMD_APU_IS_RAVEN2) {
2161 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2162 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2163 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 1);
2164 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 1);
2165 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 1);
2166 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 1);
2167 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 1);
2168 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 5, 0);
2169 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 1);
2170 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 1);
2171 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 1, 0);
2172 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 1);
2173 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 2);
2174 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 1);
2175 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 1);
2177 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2178 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2179 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 0);
2180 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 0);
2181 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 0);
2182 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2183 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 0);
2184 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 0, 0);
2185 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 0);
2186 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 0);
2187 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 0, 0);
2188 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 0);
2189 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 1, 0);
2190 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 0);
2191 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 0);
2195 vega20_reg_base_init(adev);
2196 adev->sdma.num_instances = 2;
2197 adev->gmc.num_umc = 8;
2198 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2199 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2200 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 0);
2201 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 0);
2202 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 0);
2203 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 0);
2204 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 0);
2205 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 0);
2206 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 1);
2207 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 2);
2208 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2209 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 2);
2210 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 2);
2211 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 0);
2212 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 2, 0);
2213 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(7, 2, 0);
2214 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 1, 0);
2215 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 1, 0);
2218 arct_reg_base_init(adev);
2219 adev->sdma.num_instances = 8;
2220 adev->vcn.num_vcn_inst = 2;
2221 adev->gmc.num_umc = 8;
2222 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2223 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2224 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 1);
2225 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 1);
2226 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 2);
2227 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 2);
2228 adev->ip_versions[SDMA1_HWIP][1] = IP_VERSION(4, 2, 2);
2229 adev->ip_versions[SDMA1_HWIP][2] = IP_VERSION(4, 2, 2);
2230 adev->ip_versions[SDMA1_HWIP][3] = IP_VERSION(4, 2, 2);
2231 adev->ip_versions[SDMA1_HWIP][4] = IP_VERSION(4, 2, 2);
2232 adev->ip_versions[SDMA1_HWIP][5] = IP_VERSION(4, 2, 2);
2233 adev->ip_versions[SDMA1_HWIP][6] = IP_VERSION(4, 2, 2);
2234 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 1);
2235 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 1);
2236 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 2);
2237 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 4);
2238 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2239 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 3);
2240 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 3);
2241 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 1);
2242 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 5, 0);
2243 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 5, 0);
2245 case CHIP_ALDEBARAN:
2246 aldebaran_reg_base_init(adev);
2247 adev->sdma.num_instances = 5;
2248 adev->vcn.num_vcn_inst = 2;
2249 adev->gmc.num_umc = 4;
2250 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2251 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2252 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 4, 0);
2253 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 4, 0);
2254 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 4, 0);
2255 adev->ip_versions[SDMA0_HWIP][1] = IP_VERSION(4, 4, 0);
2256 adev->ip_versions[SDMA0_HWIP][2] = IP_VERSION(4, 4, 0);
2257 adev->ip_versions[SDMA0_HWIP][3] = IP_VERSION(4, 4, 0);
2258 adev->ip_versions[SDMA0_HWIP][4] = IP_VERSION(4, 4, 0);
2259 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 2);
2260 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 4);
2261 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 7, 0);
2262 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(13, 0, 2);
2263 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(13, 0, 2);
2264 adev->ip_versions[THM_HWIP][0] = IP_VERSION(13, 0, 2);
2265 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(13, 0, 2);
2266 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 2);
2267 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 6, 0);
2268 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 6, 0);
2269 adev->ip_versions[XGMI_HWIP][0] = IP_VERSION(6, 1, 0);
2272 r = amdgpu_discovery_reg_base_init(adev);
2276 amdgpu_discovery_harvest_ip(adev);
2277 amdgpu_discovery_get_gfx_info(adev);
2278 amdgpu_discovery_get_mall_info(adev);
2279 amdgpu_discovery_get_vcn_info(adev);
2283 amdgpu_discovery_init_soc_config(adev);
2284 amdgpu_discovery_sysfs_init(adev);
2286 switch (adev->ip_versions[GC_HWIP][0]) {
2287 case IP_VERSION(9, 0, 1):
2288 case IP_VERSION(9, 2, 1):
2289 case IP_VERSION(9, 4, 0):
2290 case IP_VERSION(9, 4, 1):
2291 case IP_VERSION(9, 4, 2):
2292 case IP_VERSION(9, 4, 3):
2293 adev->family = AMDGPU_FAMILY_AI;
2295 case IP_VERSION(9, 1, 0):
2296 case IP_VERSION(9, 2, 2):
2297 case IP_VERSION(9, 3, 0):
2298 adev->family = AMDGPU_FAMILY_RV;
2300 case IP_VERSION(10, 1, 10):
2301 case IP_VERSION(10, 1, 1):
2302 case IP_VERSION(10, 1, 2):
2303 case IP_VERSION(10, 1, 3):
2304 case IP_VERSION(10, 1, 4):
2305 case IP_VERSION(10, 3, 0):
2306 case IP_VERSION(10, 3, 2):
2307 case IP_VERSION(10, 3, 4):
2308 case IP_VERSION(10, 3, 5):
2309 adev->family = AMDGPU_FAMILY_NV;
2311 case IP_VERSION(10, 3, 1):
2312 adev->family = AMDGPU_FAMILY_VGH;
2313 adev->apu_flags |= AMD_APU_IS_VANGOGH;
2315 case IP_VERSION(10, 3, 3):
2316 adev->family = AMDGPU_FAMILY_YC;
2318 case IP_VERSION(10, 3, 6):
2319 adev->family = AMDGPU_FAMILY_GC_10_3_6;
2321 case IP_VERSION(10, 3, 7):
2322 adev->family = AMDGPU_FAMILY_GC_10_3_7;
2324 case IP_VERSION(11, 0, 0):
2325 case IP_VERSION(11, 0, 2):
2326 case IP_VERSION(11, 0, 3):
2327 adev->family = AMDGPU_FAMILY_GC_11_0_0;
2329 case IP_VERSION(11, 0, 1):
2330 case IP_VERSION(11, 0, 4):
2331 adev->family = AMDGPU_FAMILY_GC_11_0_1;
2337 switch (adev->ip_versions[GC_HWIP][0]) {
2338 case IP_VERSION(9, 1, 0):
2339 case IP_VERSION(9, 2, 2):
2340 case IP_VERSION(9, 3, 0):
2341 case IP_VERSION(10, 1, 3):
2342 case IP_VERSION(10, 1, 4):
2343 case IP_VERSION(10, 3, 1):
2344 case IP_VERSION(10, 3, 3):
2345 case IP_VERSION(10, 3, 6):
2346 case IP_VERSION(10, 3, 7):
2347 case IP_VERSION(11, 0, 1):
2348 case IP_VERSION(11, 0, 4):
2349 adev->flags |= AMD_IS_APU;
2355 if (adev->ip_versions[XGMI_HWIP][0] == IP_VERSION(4, 8, 0))
2356 adev->gmc.xgmi.supported = true;
2358 /* set NBIO version */
2359 switch (adev->ip_versions[NBIO_HWIP][0]) {
2360 case IP_VERSION(6, 1, 0):
2361 case IP_VERSION(6, 2, 0):
2362 adev->nbio.funcs = &nbio_v6_1_funcs;
2363 adev->nbio.hdp_flush_reg = &nbio_v6_1_hdp_flush_reg;
2365 case IP_VERSION(7, 0, 0):
2366 case IP_VERSION(7, 0, 1):
2367 case IP_VERSION(2, 5, 0):
2368 adev->nbio.funcs = &nbio_v7_0_funcs;
2369 adev->nbio.hdp_flush_reg = &nbio_v7_0_hdp_flush_reg;
2371 case IP_VERSION(7, 4, 0):
2372 case IP_VERSION(7, 4, 1):
2373 case IP_VERSION(7, 4, 4):
2374 adev->nbio.funcs = &nbio_v7_4_funcs;
2375 adev->nbio.hdp_flush_reg = &nbio_v7_4_hdp_flush_reg;
2377 case IP_VERSION(7, 9, 0):
2378 adev->nbio.funcs = &nbio_v7_9_funcs;
2379 adev->nbio.hdp_flush_reg = &nbio_v7_9_hdp_flush_reg;
2381 case IP_VERSION(7, 2, 0):
2382 case IP_VERSION(7, 2, 1):
2383 case IP_VERSION(7, 3, 0):
2384 case IP_VERSION(7, 5, 0):
2385 case IP_VERSION(7, 5, 1):
2386 adev->nbio.funcs = &nbio_v7_2_funcs;
2387 adev->nbio.hdp_flush_reg = &nbio_v7_2_hdp_flush_reg;
2389 case IP_VERSION(2, 1, 1):
2390 case IP_VERSION(2, 3, 0):
2391 case IP_VERSION(2, 3, 1):
2392 case IP_VERSION(2, 3, 2):
2393 case IP_VERSION(3, 3, 0):
2394 case IP_VERSION(3, 3, 1):
2395 case IP_VERSION(3, 3, 2):
2396 case IP_VERSION(3, 3, 3):
2397 adev->nbio.funcs = &nbio_v2_3_funcs;
2398 adev->nbio.hdp_flush_reg = &nbio_v2_3_hdp_flush_reg;
2400 case IP_VERSION(4, 3, 0):
2401 case IP_VERSION(4, 3, 1):
2402 if (amdgpu_sriov_vf(adev))
2403 adev->nbio.funcs = &nbio_v4_3_sriov_funcs;
2405 adev->nbio.funcs = &nbio_v4_3_funcs;
2406 adev->nbio.hdp_flush_reg = &nbio_v4_3_hdp_flush_reg;
2408 case IP_VERSION(7, 7, 0):
2409 case IP_VERSION(7, 7, 1):
2410 adev->nbio.funcs = &nbio_v7_7_funcs;
2411 adev->nbio.hdp_flush_reg = &nbio_v7_7_hdp_flush_reg;
2417 switch (adev->ip_versions[HDP_HWIP][0]) {
2418 case IP_VERSION(4, 0, 0):
2419 case IP_VERSION(4, 0, 1):
2420 case IP_VERSION(4, 1, 0):
2421 case IP_VERSION(4, 1, 1):
2422 case IP_VERSION(4, 1, 2):
2423 case IP_VERSION(4, 2, 0):
2424 case IP_VERSION(4, 2, 1):
2425 case IP_VERSION(4, 4, 0):
2426 case IP_VERSION(4, 4, 2):
2427 adev->hdp.funcs = &hdp_v4_0_funcs;
2429 case IP_VERSION(5, 0, 0):
2430 case IP_VERSION(5, 0, 1):
2431 case IP_VERSION(5, 0, 2):
2432 case IP_VERSION(5, 0, 3):
2433 case IP_VERSION(5, 0, 4):
2434 case IP_VERSION(5, 2, 0):
2435 adev->hdp.funcs = &hdp_v5_0_funcs;
2437 case IP_VERSION(5, 2, 1):
2438 adev->hdp.funcs = &hdp_v5_2_funcs;
2440 case IP_VERSION(6, 0, 0):
2441 case IP_VERSION(6, 0, 1):
2442 adev->hdp.funcs = &hdp_v6_0_funcs;
2448 switch (adev->ip_versions[DF_HWIP][0]) {
2449 case IP_VERSION(3, 6, 0):
2450 case IP_VERSION(3, 6, 1):
2451 case IP_VERSION(3, 6, 2):
2452 adev->df.funcs = &df_v3_6_funcs;
2454 case IP_VERSION(2, 1, 0):
2455 case IP_VERSION(2, 1, 1):
2456 case IP_VERSION(2, 5, 0):
2457 case IP_VERSION(3, 5, 1):
2458 case IP_VERSION(3, 5, 2):
2459 adev->df.funcs = &df_v1_7_funcs;
2461 case IP_VERSION(4, 3, 0):
2462 adev->df.funcs = &df_v4_3_funcs;
2468 switch (adev->ip_versions[SMUIO_HWIP][0]) {
2469 case IP_VERSION(9, 0, 0):
2470 case IP_VERSION(9, 0, 1):
2471 case IP_VERSION(10, 0, 0):
2472 case IP_VERSION(10, 0, 1):
2473 case IP_VERSION(10, 0, 2):
2474 adev->smuio.funcs = &smuio_v9_0_funcs;
2476 case IP_VERSION(11, 0, 0):
2477 case IP_VERSION(11, 0, 2):
2478 case IP_VERSION(11, 0, 3):
2479 case IP_VERSION(11, 0, 4):
2480 case IP_VERSION(11, 0, 7):
2481 case IP_VERSION(11, 0, 8):
2482 adev->smuio.funcs = &smuio_v11_0_funcs;
2484 case IP_VERSION(11, 0, 6):
2485 case IP_VERSION(11, 0, 10):
2486 case IP_VERSION(11, 0, 11):
2487 case IP_VERSION(11, 5, 0):
2488 case IP_VERSION(13, 0, 1):
2489 case IP_VERSION(13, 0, 9):
2490 case IP_VERSION(13, 0, 10):
2491 adev->smuio.funcs = &smuio_v11_0_6_funcs;
2493 case IP_VERSION(13, 0, 2):
2494 adev->smuio.funcs = &smuio_v13_0_funcs;
2496 case IP_VERSION(13, 0, 3):
2497 adev->smuio.funcs = &smuio_v13_0_3_funcs;
2499 case IP_VERSION(13, 0, 6):
2500 case IP_VERSION(13, 0, 8):
2501 adev->smuio.funcs = &smuio_v13_0_6_funcs;
2507 switch (adev->ip_versions[LSDMA_HWIP][0]) {
2508 case IP_VERSION(6, 0, 0):
2509 case IP_VERSION(6, 0, 1):
2510 case IP_VERSION(6, 0, 2):
2511 case IP_VERSION(6, 0, 3):
2512 adev->lsdma.funcs = &lsdma_v6_0_funcs;
2518 r = amdgpu_discovery_set_common_ip_blocks(adev);
2522 r = amdgpu_discovery_set_gmc_ip_blocks(adev);
2526 /* For SR-IOV, PSP needs to be initialized before IH */
2527 if (amdgpu_sriov_vf(adev)) {
2528 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2531 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2535 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2539 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2540 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2546 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2547 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2552 r = amdgpu_discovery_set_display_ip_blocks(adev);
2556 r = amdgpu_discovery_set_gc_ip_blocks(adev);
2560 r = amdgpu_discovery_set_sdma_ip_blocks(adev);
2564 if ((adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
2565 !amdgpu_sriov_vf(adev)) ||
2566 (adev->firmware.load_type == AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO && amdgpu_dpm == 1)) {
2567 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2572 r = amdgpu_discovery_set_mm_ip_blocks(adev);
2576 r = amdgpu_discovery_set_mes_ip_blocks(adev);