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"
33 #include "gfx_v9_4_3.h"
38 #include "nbio_v6_1.h"
39 #include "nbio_v7_0.h"
40 #include "nbio_v7_4.h"
41 #include "nbio_v7_9.h"
43 #include "vega10_ih.h"
44 #include "vega20_ih.h"
45 #include "sdma_v4_0.h"
46 #include "sdma_v4_4_2.h"
51 #include "jpeg_v2_5.h"
52 #include "smuio_v9_0.h"
53 #include "gmc_v10_0.h"
54 #include "gmc_v11_0.h"
55 #include "gfxhub_v2_0.h"
56 #include "mmhub_v2_0.h"
57 #include "nbio_v2_3.h"
58 #include "nbio_v4_3.h"
59 #include "nbio_v7_2.h"
60 #include "nbio_v7_7.h"
66 #include "navi10_ih.h"
69 #include "gfx_v10_0.h"
70 #include "gfx_v11_0.h"
71 #include "sdma_v5_0.h"
72 #include "sdma_v5_2.h"
73 #include "sdma_v6_0.h"
74 #include "lsdma_v6_0.h"
76 #include "jpeg_v2_0.h"
78 #include "jpeg_v3_0.h"
80 #include "jpeg_v4_0.h"
81 #include "vcn_v4_0_3.h"
82 #include "jpeg_v4_0_3.h"
83 #include "amdgpu_vkms.h"
84 #include "mes_v10_1.h"
85 #include "mes_v11_0.h"
86 #include "smuio_v11_0.h"
87 #include "smuio_v11_0_6.h"
88 #include "smuio_v13_0.h"
89 #include "smuio_v13_0_3.h"
90 #include "smuio_v13_0_6.h"
92 #define FIRMWARE_IP_DISCOVERY "amdgpu/ip_discovery.bin"
93 MODULE_FIRMWARE(FIRMWARE_IP_DISCOVERY);
95 #define mmRCC_CONFIG_MEMSIZE 0xde3
96 #define mmMM_INDEX 0x0
97 #define mmMM_INDEX_HI 0x6
100 static const char *hw_id_names[HW_ID_MAX] = {
104 [SMUIO_HWID] = "SMUIO",
105 [FUSE_HWID] = "FUSE",
106 [CLKA_HWID] = "CLKA",
110 [AUDIO_AZ_HWID] = "AUDIO_AZ",
116 [XDMA_HWID] = "XDMA",
117 [DCEAZ_HWID] = "DCEAZ",
119 [SDPMUX_HWID] = "SDPMUX",
121 [IOHC_HWID] = "IOHC",
122 [L2IMU_HWID] = "L2IMU",
124 [MMHUB_HWID] = "MMHUB",
125 [ATHUB_HWID] = "ATHUB",
126 [DBGU_NBIO_HWID] = "DBGU_NBIO",
128 [DBGU0_HWID] = "DBGU0",
129 [DBGU1_HWID] = "DBGU1",
130 [OSSSYS_HWID] = "OSSSYS",
132 [SDMA0_HWID] = "SDMA0",
133 [SDMA1_HWID] = "SDMA1",
134 [SDMA2_HWID] = "SDMA2",
135 [SDMA3_HWID] = "SDMA3",
136 [LSDMA_HWID] = "LSDMA",
138 [DBGU_IO_HWID] = "DBGU_IO",
140 [CLKB_HWID] = "CLKB",
142 [DFX_DAP_HWID] = "DFX_DAP",
143 [L1IMU_PCIE_HWID] = "L1IMU_PCIE",
144 [L1IMU_NBIF_HWID] = "L1IMU_NBIF",
145 [L1IMU_IOAGR_HWID] = "L1IMU_IOAGR",
146 [L1IMU3_HWID] = "L1IMU3",
147 [L1IMU4_HWID] = "L1IMU4",
148 [L1IMU5_HWID] = "L1IMU5",
149 [L1IMU6_HWID] = "L1IMU6",
150 [L1IMU7_HWID] = "L1IMU7",
151 [L1IMU8_HWID] = "L1IMU8",
152 [L1IMU9_HWID] = "L1IMU9",
153 [L1IMU10_HWID] = "L1IMU10",
154 [L1IMU11_HWID] = "L1IMU11",
155 [L1IMU12_HWID] = "L1IMU12",
156 [L1IMU13_HWID] = "L1IMU13",
157 [L1IMU14_HWID] = "L1IMU14",
158 [L1IMU15_HWID] = "L1IMU15",
159 [WAFLC_HWID] = "WAFLC",
160 [FCH_USB_PD_HWID] = "FCH_USB_PD",
161 [PCIE_HWID] = "PCIE",
163 [DDCL_HWID] = "DDCL",
165 [IOAGR_HWID] = "IOAGR",
166 [NBIF_HWID] = "NBIF",
167 [IOAPIC_HWID] = "IOAPIC",
168 [SYSTEMHUB_HWID] = "SYSTEMHUB",
169 [NTBCCP_HWID] = "NTBCCP",
171 [SATA_HWID] = "SATA",
173 [CCXSEC_HWID] = "CCXSEC",
174 [XGMI_HWID] = "XGMI",
175 [XGBE_HWID] = "XGBE",
179 static int hw_id_map[MAX_HWIP] = {
181 [HDP_HWIP] = HDP_HWID,
182 [SDMA0_HWIP] = SDMA0_HWID,
183 [SDMA1_HWIP] = SDMA1_HWID,
184 [SDMA2_HWIP] = SDMA2_HWID,
185 [SDMA3_HWIP] = SDMA3_HWID,
186 [LSDMA_HWIP] = LSDMA_HWID,
187 [MMHUB_HWIP] = MMHUB_HWID,
188 [ATHUB_HWIP] = ATHUB_HWID,
189 [NBIO_HWIP] = NBIF_HWID,
190 [MP0_HWIP] = MP0_HWID,
191 [MP1_HWIP] = MP1_HWID,
192 [UVD_HWIP] = UVD_HWID,
193 [VCE_HWIP] = VCE_HWID,
195 [DCE_HWIP] = DMU_HWID,
196 [OSSSYS_HWIP] = OSSSYS_HWID,
197 [SMUIO_HWIP] = SMUIO_HWID,
198 [PWR_HWIP] = PWR_HWID,
199 [NBIF_HWIP] = NBIF_HWID,
200 [THM_HWIP] = THM_HWID,
201 [CLK_HWIP] = CLKA_HWID,
202 [UMC_HWIP] = UMC_HWID,
203 [XGMI_HWIP] = XGMI_HWID,
204 [DCI_HWIP] = DCI_HWID,
205 [PCIE_HWIP] = PCIE_HWID,
208 static int amdgpu_discovery_read_binary_from_sysmem(struct amdgpu_device *adev, uint8_t *binary)
210 u64 tmr_offset, tmr_size, pos;
214 ret = amdgpu_acpi_get_tmr_info(adev, &tmr_offset, &tmr_size);
218 pos = tmr_offset + tmr_size - DISCOVERY_TMR_OFFSET;
220 /* This region is read-only and reserved from system use */
221 discv_regn = memremap(pos, adev->mman.discovery_tmr_size, MEMREMAP_WC);
223 memcpy(binary, discv_regn, adev->mman.discovery_tmr_size);
224 memunmap(discv_regn);
231 static int amdgpu_discovery_read_binary_from_mem(struct amdgpu_device *adev,
234 uint64_t vram_size = (uint64_t)RREG32(mmRCC_CONFIG_MEMSIZE) << 20;
238 uint64_t pos = vram_size - DISCOVERY_TMR_OFFSET;
239 amdgpu_device_vram_access(adev, pos, (uint32_t *)binary,
240 adev->mman.discovery_tmr_size, false);
242 ret = amdgpu_discovery_read_binary_from_sysmem(adev, binary);
248 static int amdgpu_discovery_read_binary_from_file(struct amdgpu_device *adev, uint8_t *binary)
250 const struct firmware *fw;
254 switch (amdgpu_discovery) {
256 fw_name = FIRMWARE_IP_DISCOVERY;
259 dev_warn(adev->dev, "amdgpu_discovery is not set properly\n");
263 r = request_firmware(&fw, fw_name, adev->dev);
265 dev_err(adev->dev, "can't load firmware \"%s\"\n",
270 memcpy((u8 *)binary, (u8 *)fw->data, fw->size);
271 release_firmware(fw);
276 static uint16_t amdgpu_discovery_calculate_checksum(uint8_t *data, uint32_t size)
278 uint16_t checksum = 0;
281 for (i = 0; i < size; i++)
287 static inline bool amdgpu_discovery_verify_checksum(uint8_t *data, uint32_t size,
290 return !!(amdgpu_discovery_calculate_checksum(data, size) == expected);
293 static inline bool amdgpu_discovery_verify_binary_signature(uint8_t *binary)
295 struct binary_header *bhdr;
296 bhdr = (struct binary_header *)binary;
298 return (le32_to_cpu(bhdr->binary_signature) == BINARY_SIGNATURE);
301 static void amdgpu_discovery_harvest_config_quirk(struct amdgpu_device *adev)
304 * So far, apply this quirk only on those Navy Flounder boards which
305 * have a bad harvest table of VCN config.
307 if ((adev->ip_versions[UVD_HWIP][1] == IP_VERSION(3, 0, 1)) &&
308 (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 2))) {
309 switch (adev->pdev->revision) {
317 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
318 adev->vcn.inst_mask &= ~AMDGPU_VCN_HARVEST_VCN1;
326 static int amdgpu_discovery_init(struct amdgpu_device *adev)
328 struct table_info *info;
329 struct binary_header *bhdr;
335 adev->mman.discovery_tmr_size = DISCOVERY_TMR_SIZE;
336 adev->mman.discovery_bin = kzalloc(adev->mman.discovery_tmr_size, GFP_KERNEL);
337 if (!adev->mman.discovery_bin)
340 /* Read from file if it is the preferred option */
341 if (amdgpu_discovery == 2) {
342 dev_info(adev->dev, "use ip discovery information from file");
343 r = amdgpu_discovery_read_binary_from_file(adev, adev->mman.discovery_bin);
346 dev_err(adev->dev, "failed to read ip discovery binary from file\n");
352 r = amdgpu_discovery_read_binary_from_mem(
353 adev, adev->mman.discovery_bin);
358 /* check the ip discovery binary signature */
359 if (!amdgpu_discovery_verify_binary_signature(adev->mman.discovery_bin)) {
361 "get invalid ip discovery binary signature\n");
366 bhdr = (struct binary_header *)adev->mman.discovery_bin;
368 offset = offsetof(struct binary_header, binary_checksum) +
369 sizeof(bhdr->binary_checksum);
370 size = le16_to_cpu(bhdr->binary_size) - offset;
371 checksum = le16_to_cpu(bhdr->binary_checksum);
373 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
375 dev_err(adev->dev, "invalid ip discovery binary checksum\n");
380 info = &bhdr->table_list[IP_DISCOVERY];
381 offset = le16_to_cpu(info->offset);
382 checksum = le16_to_cpu(info->checksum);
385 struct ip_discovery_header *ihdr =
386 (struct ip_discovery_header *)(adev->mman.discovery_bin + offset);
387 if (le32_to_cpu(ihdr->signature) != DISCOVERY_TABLE_SIGNATURE) {
388 dev_err(adev->dev, "invalid ip discovery data table signature\n");
393 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
394 le16_to_cpu(ihdr->size), checksum)) {
395 dev_err(adev->dev, "invalid ip discovery data table checksum\n");
401 info = &bhdr->table_list[GC];
402 offset = le16_to_cpu(info->offset);
403 checksum = le16_to_cpu(info->checksum);
406 struct gpu_info_header *ghdr =
407 (struct gpu_info_header *)(adev->mman.discovery_bin + offset);
409 if (le32_to_cpu(ghdr->table_id) != GC_TABLE_ID) {
410 dev_err(adev->dev, "invalid ip discovery gc table id\n");
415 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
416 le32_to_cpu(ghdr->size), checksum)) {
417 dev_err(adev->dev, "invalid gc data table checksum\n");
423 info = &bhdr->table_list[HARVEST_INFO];
424 offset = le16_to_cpu(info->offset);
425 checksum = le16_to_cpu(info->checksum);
428 struct harvest_info_header *hhdr =
429 (struct harvest_info_header *)(adev->mman.discovery_bin + offset);
431 if (le32_to_cpu(hhdr->signature) != HARVEST_TABLE_SIGNATURE) {
432 dev_err(adev->dev, "invalid ip discovery harvest table signature\n");
437 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
438 sizeof(struct harvest_table), checksum)) {
439 dev_err(adev->dev, "invalid harvest data table checksum\n");
445 info = &bhdr->table_list[VCN_INFO];
446 offset = le16_to_cpu(info->offset);
447 checksum = le16_to_cpu(info->checksum);
450 struct vcn_info_header *vhdr =
451 (struct vcn_info_header *)(adev->mman.discovery_bin + offset);
453 if (le32_to_cpu(vhdr->table_id) != VCN_INFO_TABLE_ID) {
454 dev_err(adev->dev, "invalid ip discovery vcn table id\n");
459 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
460 le32_to_cpu(vhdr->size_bytes), checksum)) {
461 dev_err(adev->dev, "invalid vcn data table checksum\n");
467 info = &bhdr->table_list[MALL_INFO];
468 offset = le16_to_cpu(info->offset);
469 checksum = le16_to_cpu(info->checksum);
472 struct mall_info_header *mhdr =
473 (struct mall_info_header *)(adev->mman.discovery_bin + offset);
475 if (le32_to_cpu(mhdr->table_id) != MALL_INFO_TABLE_ID) {
476 dev_err(adev->dev, "invalid ip discovery mall table id\n");
481 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
482 le32_to_cpu(mhdr->size_bytes), checksum)) {
483 dev_err(adev->dev, "invalid mall data table checksum\n");
492 kfree(adev->mman.discovery_bin);
493 adev->mman.discovery_bin = NULL;
498 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev);
500 void amdgpu_discovery_fini(struct amdgpu_device *adev)
502 amdgpu_discovery_sysfs_fini(adev);
503 kfree(adev->mman.discovery_bin);
504 adev->mman.discovery_bin = NULL;
507 static int amdgpu_discovery_validate_ip(const struct ip_v4 *ip)
509 if (ip->instance_number >= HWIP_MAX_INSTANCE) {
510 DRM_ERROR("Unexpected instance_number (%d) from ip discovery blob\n",
511 ip->instance_number);
514 if (le16_to_cpu(ip->hw_id) >= HW_ID_MAX) {
515 DRM_ERROR("Unexpected hw_id (%d) from ip discovery blob\n",
516 le16_to_cpu(ip->hw_id));
523 static void amdgpu_discovery_read_harvest_bit_per_ip(struct amdgpu_device *adev,
524 uint32_t *vcn_harvest_count)
526 struct binary_header *bhdr;
527 struct ip_discovery_header *ihdr;
528 struct die_header *dhdr;
530 uint16_t die_offset, ip_offset, num_dies, num_ips;
533 bhdr = (struct binary_header *)adev->mman.discovery_bin;
534 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
535 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
536 num_dies = le16_to_cpu(ihdr->num_dies);
538 /* scan harvest bit of all IP data structures */
539 for (i = 0; i < num_dies; i++) {
540 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
541 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
542 num_ips = le16_to_cpu(dhdr->num_ips);
543 ip_offset = die_offset + sizeof(*dhdr);
545 for (j = 0; j < num_ips; j++) {
546 ip = (struct ip_v4 *)(adev->mman.discovery_bin + ip_offset);
548 if (amdgpu_discovery_validate_ip(ip))
551 if (le16_to_cpu(ip->variant) == 1) {
552 switch (le16_to_cpu(ip->hw_id)) {
554 (*vcn_harvest_count)++;
555 if (ip->instance_number == 0) {
556 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN0;
557 adev->vcn.inst_mask &=
558 ~AMDGPU_VCN_HARVEST_VCN0;
559 adev->jpeg.inst_mask &=
560 ~AMDGPU_VCN_HARVEST_VCN0;
562 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
563 adev->vcn.inst_mask &=
564 ~AMDGPU_VCN_HARVEST_VCN1;
565 adev->jpeg.inst_mask &=
566 ~AMDGPU_VCN_HARVEST_VCN1;
570 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
577 if (ihdr->base_addr_64_bit)
578 ip_offset += struct_size(ip, base_address_64, ip->num_base_address);
580 ip_offset += struct_size(ip, base_address, ip->num_base_address);
585 static void amdgpu_discovery_read_from_harvest_table(struct amdgpu_device *adev,
586 uint32_t *vcn_harvest_count,
587 uint32_t *umc_harvest_count)
589 struct binary_header *bhdr;
590 struct harvest_table *harvest_info;
593 uint32_t umc_harvest_config = 0;
595 bhdr = (struct binary_header *)adev->mman.discovery_bin;
596 offset = le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset);
599 dev_err(adev->dev, "invalid harvest table offset\n");
603 harvest_info = (struct harvest_table *)(adev->mman.discovery_bin + offset);
605 for (i = 0; i < 32; i++) {
606 if (le16_to_cpu(harvest_info->list[i].hw_id) == 0)
609 switch (le16_to_cpu(harvest_info->list[i].hw_id)) {
611 (*vcn_harvest_count)++;
612 adev->vcn.harvest_config |=
613 (1 << harvest_info->list[i].number_instance);
614 adev->jpeg.harvest_config |=
615 (1 << harvest_info->list[i].number_instance);
617 adev->vcn.inst_mask &=
618 ~(1U << harvest_info->list[i].number_instance);
619 adev->jpeg.inst_mask &=
620 ~(1U << harvest_info->list[i].number_instance);
623 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
626 umc_harvest_config |=
627 1 << (le16_to_cpu(harvest_info->list[i].number_instance));
628 (*umc_harvest_count)++;
631 adev->gfx.xcc_mask &=
632 ~(1U << harvest_info->list[i].number_instance);
635 adev->sdma.sdma_mask &=
636 ~(1U << harvest_info->list[i].number_instance);
643 adev->umc.active_mask = ((1 << adev->umc.node_inst_num) - 1) &
647 /* ================================================== */
649 struct ip_hw_instance {
650 struct kobject kobj; /* ip_discovery/die/#die/#hw_id/#instance/<attrs...> */
654 u8 major, minor, revision;
657 int num_base_addresses;
662 struct kset hw_id_kset; /* ip_discovery/die/#die/#hw_id/, contains ip_hw_instance */
666 struct ip_die_entry {
667 struct kset ip_kset; /* ip_discovery/die/#die/, contains ip_hw_id */
671 /* -------------------------------------------------- */
673 struct ip_hw_instance_attr {
674 struct attribute attr;
675 ssize_t (*show)(struct ip_hw_instance *ip_hw_instance, char *buf);
678 static ssize_t hw_id_show(struct ip_hw_instance *ip_hw_instance, char *buf)
680 return sysfs_emit(buf, "%d\n", ip_hw_instance->hw_id);
683 static ssize_t num_instance_show(struct ip_hw_instance *ip_hw_instance, char *buf)
685 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_instance);
688 static ssize_t major_show(struct ip_hw_instance *ip_hw_instance, char *buf)
690 return sysfs_emit(buf, "%d\n", ip_hw_instance->major);
693 static ssize_t minor_show(struct ip_hw_instance *ip_hw_instance, char *buf)
695 return sysfs_emit(buf, "%d\n", ip_hw_instance->minor);
698 static ssize_t revision_show(struct ip_hw_instance *ip_hw_instance, char *buf)
700 return sysfs_emit(buf, "%d\n", ip_hw_instance->revision);
703 static ssize_t harvest_show(struct ip_hw_instance *ip_hw_instance, char *buf)
705 return sysfs_emit(buf, "0x%01X\n", ip_hw_instance->harvest);
708 static ssize_t num_base_addresses_show(struct ip_hw_instance *ip_hw_instance, char *buf)
710 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_base_addresses);
713 static ssize_t base_addr_show(struct ip_hw_instance *ip_hw_instance, char *buf)
718 for (res = at = ii = 0; ii < ip_hw_instance->num_base_addresses; ii++) {
719 /* Here we satisfy the condition that, at + size <= PAGE_SIZE.
721 if (at + 12 > PAGE_SIZE)
723 res = sysfs_emit_at(buf, at, "0x%08X\n",
724 ip_hw_instance->base_addr[ii]);
730 return res < 0 ? res : at;
733 static struct ip_hw_instance_attr ip_hw_attr[] = {
735 __ATTR_RO(num_instance),
740 __ATTR_RO(num_base_addresses),
741 __ATTR_RO(base_addr),
744 static struct attribute *ip_hw_instance_attrs[ARRAY_SIZE(ip_hw_attr) + 1];
745 ATTRIBUTE_GROUPS(ip_hw_instance);
747 #define to_ip_hw_instance(x) container_of(x, struct ip_hw_instance, kobj)
748 #define to_ip_hw_instance_attr(x) container_of(x, struct ip_hw_instance_attr, attr)
750 static ssize_t ip_hw_instance_attr_show(struct kobject *kobj,
751 struct attribute *attr,
754 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
755 struct ip_hw_instance_attr *ip_hw_attr = to_ip_hw_instance_attr(attr);
757 if (!ip_hw_attr->show)
760 return ip_hw_attr->show(ip_hw_instance, buf);
763 static const struct sysfs_ops ip_hw_instance_sysfs_ops = {
764 .show = ip_hw_instance_attr_show,
767 static void ip_hw_instance_release(struct kobject *kobj)
769 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
771 kfree(ip_hw_instance);
774 static const struct kobj_type ip_hw_instance_ktype = {
775 .release = ip_hw_instance_release,
776 .sysfs_ops = &ip_hw_instance_sysfs_ops,
777 .default_groups = ip_hw_instance_groups,
780 /* -------------------------------------------------- */
782 #define to_ip_hw_id(x) container_of(to_kset(x), struct ip_hw_id, hw_id_kset)
784 static void ip_hw_id_release(struct kobject *kobj)
786 struct ip_hw_id *ip_hw_id = to_ip_hw_id(kobj);
788 if (!list_empty(&ip_hw_id->hw_id_kset.list))
789 DRM_ERROR("ip_hw_id->hw_id_kset is not empty");
793 static const struct kobj_type ip_hw_id_ktype = {
794 .release = ip_hw_id_release,
795 .sysfs_ops = &kobj_sysfs_ops,
798 /* -------------------------------------------------- */
800 static void die_kobj_release(struct kobject *kobj);
801 static void ip_disc_release(struct kobject *kobj);
803 struct ip_die_entry_attribute {
804 struct attribute attr;
805 ssize_t (*show)(struct ip_die_entry *ip_die_entry, char *buf);
808 #define to_ip_die_entry_attr(x) container_of(x, struct ip_die_entry_attribute, attr)
810 static ssize_t num_ips_show(struct ip_die_entry *ip_die_entry, char *buf)
812 return sysfs_emit(buf, "%d\n", ip_die_entry->num_ips);
815 /* If there are more ip_die_entry attrs, other than the number of IPs,
816 * we can make this intro an array of attrs, and then initialize
817 * ip_die_entry_attrs in a loop.
819 static struct ip_die_entry_attribute num_ips_attr =
822 static struct attribute *ip_die_entry_attrs[] = {
826 ATTRIBUTE_GROUPS(ip_die_entry); /* ip_die_entry_groups */
828 #define to_ip_die_entry(x) container_of(to_kset(x), struct ip_die_entry, ip_kset)
830 static ssize_t ip_die_entry_attr_show(struct kobject *kobj,
831 struct attribute *attr,
834 struct ip_die_entry_attribute *ip_die_entry_attr = to_ip_die_entry_attr(attr);
835 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
837 if (!ip_die_entry_attr->show)
840 return ip_die_entry_attr->show(ip_die_entry, buf);
843 static void ip_die_entry_release(struct kobject *kobj)
845 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
847 if (!list_empty(&ip_die_entry->ip_kset.list))
848 DRM_ERROR("ip_die_entry->ip_kset is not empty");
852 static const struct sysfs_ops ip_die_entry_sysfs_ops = {
853 .show = ip_die_entry_attr_show,
856 static const struct kobj_type ip_die_entry_ktype = {
857 .release = ip_die_entry_release,
858 .sysfs_ops = &ip_die_entry_sysfs_ops,
859 .default_groups = ip_die_entry_groups,
862 static const struct kobj_type die_kobj_ktype = {
863 .release = die_kobj_release,
864 .sysfs_ops = &kobj_sysfs_ops,
867 static const struct kobj_type ip_discovery_ktype = {
868 .release = ip_disc_release,
869 .sysfs_ops = &kobj_sysfs_ops,
872 struct ip_discovery_top {
873 struct kobject kobj; /* ip_discovery/ */
874 struct kset die_kset; /* ip_discovery/die/, contains ip_die_entry */
875 struct amdgpu_device *adev;
878 static void die_kobj_release(struct kobject *kobj)
880 struct ip_discovery_top *ip_top = container_of(to_kset(kobj),
881 struct ip_discovery_top,
883 if (!list_empty(&ip_top->die_kset.list))
884 DRM_ERROR("ip_top->die_kset is not empty");
887 static void ip_disc_release(struct kobject *kobj)
889 struct ip_discovery_top *ip_top = container_of(kobj, struct ip_discovery_top,
891 struct amdgpu_device *adev = ip_top->adev;
897 static uint8_t amdgpu_discovery_get_harvest_info(struct amdgpu_device *adev,
898 uint16_t hw_id, uint8_t inst)
902 /* Until a uniform way is figured, get mask based on hwid */
905 harvest = ((1 << inst) & adev->vcn.inst_mask) == 0;
908 if (adev->harvest_ip_mask & AMD_HARVEST_IP_DMU_MASK)
912 /* TODO: It needs another parsing; for now, ignore.*/
915 harvest = ((1 << inst) & adev->gfx.xcc_mask) == 0;
918 harvest = ((1 << inst) & adev->sdma.sdma_mask) == 0;
927 static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev,
928 struct ip_die_entry *ip_die_entry,
929 const size_t _ip_offset, const int num_ips,
934 DRM_DEBUG("num_ips:%d", num_ips);
936 /* Find all IPs of a given HW ID, and add their instance to
937 * #die/#hw_id/#instance/<attributes>
939 for (ii = 0; ii < HW_ID_MAX; ii++) {
940 struct ip_hw_id *ip_hw_id = NULL;
941 size_t ip_offset = _ip_offset;
943 for (jj = 0; jj < num_ips; jj++) {
945 struct ip_hw_instance *ip_hw_instance;
947 ip = (struct ip_v4 *)(adev->mman.discovery_bin + ip_offset);
948 if (amdgpu_discovery_validate_ip(ip) ||
949 le16_to_cpu(ip->hw_id) != ii)
952 DRM_DEBUG("match:%d @ ip_offset:%zu", ii, ip_offset);
954 /* We have a hw_id match; register the hw
955 * block if not yet registered.
958 ip_hw_id = kzalloc(sizeof(*ip_hw_id), GFP_KERNEL);
961 ip_hw_id->hw_id = ii;
963 kobject_set_name(&ip_hw_id->hw_id_kset.kobj, "%d", ii);
964 ip_hw_id->hw_id_kset.kobj.kset = &ip_die_entry->ip_kset;
965 ip_hw_id->hw_id_kset.kobj.ktype = &ip_hw_id_ktype;
966 res = kset_register(&ip_hw_id->hw_id_kset);
968 DRM_ERROR("Couldn't register ip_hw_id kset");
972 if (hw_id_names[ii]) {
973 res = sysfs_create_link(&ip_die_entry->ip_kset.kobj,
974 &ip_hw_id->hw_id_kset.kobj,
977 DRM_ERROR("Couldn't create IP link %s in IP Die:%s\n",
979 kobject_name(&ip_die_entry->ip_kset.kobj));
984 /* Now register its instance.
986 ip_hw_instance = kzalloc(struct_size(ip_hw_instance,
988 ip->num_base_address),
990 if (!ip_hw_instance) {
991 DRM_ERROR("no memory for ip_hw_instance");
994 ip_hw_instance->hw_id = le16_to_cpu(ip->hw_id); /* == ii */
995 ip_hw_instance->num_instance = ip->instance_number;
996 ip_hw_instance->major = ip->major;
997 ip_hw_instance->minor = ip->minor;
998 ip_hw_instance->revision = ip->revision;
999 ip_hw_instance->harvest =
1000 amdgpu_discovery_get_harvest_info(
1001 adev, ip_hw_instance->hw_id,
1002 ip_hw_instance->num_instance);
1003 ip_hw_instance->num_base_addresses = ip->num_base_address;
1005 for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++) {
1007 ip_hw_instance->base_addr[kk] =
1008 lower_32_bits(le64_to_cpu(ip->base_address_64[kk])) & 0x3FFFFFFF;
1010 ip_hw_instance->base_addr[kk] = ip->base_address[kk];
1013 kobject_init(&ip_hw_instance->kobj, &ip_hw_instance_ktype);
1014 ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset;
1015 res = kobject_add(&ip_hw_instance->kobj, NULL,
1016 "%d", ip_hw_instance->num_instance);
1019 ip_offset += struct_size(ip, base_address_64,
1020 ip->num_base_address);
1022 ip_offset += struct_size(ip, base_address,
1023 ip->num_base_address);
1030 static int amdgpu_discovery_sysfs_recurse(struct amdgpu_device *adev)
1032 struct binary_header *bhdr;
1033 struct ip_discovery_header *ihdr;
1034 struct die_header *dhdr;
1035 struct kset *die_kset = &adev->ip_top->die_kset;
1036 u16 num_dies, die_offset, num_ips;
1040 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1041 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1042 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1043 num_dies = le16_to_cpu(ihdr->num_dies);
1045 DRM_DEBUG("number of dies: %d\n", num_dies);
1047 for (ii = 0; ii < num_dies; ii++) {
1048 struct ip_die_entry *ip_die_entry;
1050 die_offset = le16_to_cpu(ihdr->die_info[ii].die_offset);
1051 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1052 num_ips = le16_to_cpu(dhdr->num_ips);
1053 ip_offset = die_offset + sizeof(*dhdr);
1055 /* Add the die to the kset.
1057 * dhdr->die_id == ii, which was checked in
1058 * amdgpu_discovery_reg_base_init().
1061 ip_die_entry = kzalloc(sizeof(*ip_die_entry), GFP_KERNEL);
1065 ip_die_entry->num_ips = num_ips;
1067 kobject_set_name(&ip_die_entry->ip_kset.kobj, "%d", le16_to_cpu(dhdr->die_id));
1068 ip_die_entry->ip_kset.kobj.kset = die_kset;
1069 ip_die_entry->ip_kset.kobj.ktype = &ip_die_entry_ktype;
1070 res = kset_register(&ip_die_entry->ip_kset);
1072 DRM_ERROR("Couldn't register ip_die_entry kset");
1073 kfree(ip_die_entry);
1077 amdgpu_discovery_sysfs_ips(adev, ip_die_entry, ip_offset, num_ips, !!ihdr->base_addr_64_bit);
1083 static int amdgpu_discovery_sysfs_init(struct amdgpu_device *adev)
1085 struct kset *die_kset;
1088 if (!adev->mman.discovery_bin)
1091 adev->ip_top = kzalloc(sizeof(*adev->ip_top), GFP_KERNEL);
1095 adev->ip_top->adev = adev;
1097 res = kobject_init_and_add(&adev->ip_top->kobj, &ip_discovery_ktype,
1098 &adev->dev->kobj, "ip_discovery");
1100 DRM_ERROR("Couldn't init and add ip_discovery/");
1104 die_kset = &adev->ip_top->die_kset;
1105 kobject_set_name(&die_kset->kobj, "%s", "die");
1106 die_kset->kobj.parent = &adev->ip_top->kobj;
1107 die_kset->kobj.ktype = &die_kobj_ktype;
1108 res = kset_register(&adev->ip_top->die_kset);
1110 DRM_ERROR("Couldn't register die_kset");
1114 for (ii = 0; ii < ARRAY_SIZE(ip_hw_attr); ii++)
1115 ip_hw_instance_attrs[ii] = &ip_hw_attr[ii].attr;
1116 ip_hw_instance_attrs[ii] = NULL;
1118 res = amdgpu_discovery_sysfs_recurse(adev);
1122 kobject_put(&adev->ip_top->kobj);
1126 /* -------------------------------------------------- */
1128 #define list_to_kobj(el) container_of(el, struct kobject, entry)
1130 static void amdgpu_discovery_sysfs_ip_hw_free(struct ip_hw_id *ip_hw_id)
1132 struct list_head *el, *tmp;
1133 struct kset *hw_id_kset;
1135 hw_id_kset = &ip_hw_id->hw_id_kset;
1136 spin_lock(&hw_id_kset->list_lock);
1137 list_for_each_prev_safe(el, tmp, &hw_id_kset->list) {
1139 spin_unlock(&hw_id_kset->list_lock);
1140 /* kobject is embedded in ip_hw_instance */
1141 kobject_put(list_to_kobj(el));
1142 spin_lock(&hw_id_kset->list_lock);
1144 spin_unlock(&hw_id_kset->list_lock);
1145 kobject_put(&ip_hw_id->hw_id_kset.kobj);
1148 static void amdgpu_discovery_sysfs_die_free(struct ip_die_entry *ip_die_entry)
1150 struct list_head *el, *tmp;
1151 struct kset *ip_kset;
1153 ip_kset = &ip_die_entry->ip_kset;
1154 spin_lock(&ip_kset->list_lock);
1155 list_for_each_prev_safe(el, tmp, &ip_kset->list) {
1157 spin_unlock(&ip_kset->list_lock);
1158 amdgpu_discovery_sysfs_ip_hw_free(to_ip_hw_id(list_to_kobj(el)));
1159 spin_lock(&ip_kset->list_lock);
1161 spin_unlock(&ip_kset->list_lock);
1162 kobject_put(&ip_die_entry->ip_kset.kobj);
1165 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev)
1167 struct list_head *el, *tmp;
1168 struct kset *die_kset;
1170 die_kset = &adev->ip_top->die_kset;
1171 spin_lock(&die_kset->list_lock);
1172 list_for_each_prev_safe(el, tmp, &die_kset->list) {
1174 spin_unlock(&die_kset->list_lock);
1175 amdgpu_discovery_sysfs_die_free(to_ip_die_entry(list_to_kobj(el)));
1176 spin_lock(&die_kset->list_lock);
1178 spin_unlock(&die_kset->list_lock);
1179 kobject_put(&adev->ip_top->die_kset.kobj);
1180 kobject_put(&adev->ip_top->kobj);
1183 /* ================================================== */
1185 static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
1187 struct binary_header *bhdr;
1188 struct ip_discovery_header *ihdr;
1189 struct die_header *dhdr;
1191 uint16_t die_offset;
1195 uint8_t num_base_address;
1200 r = amdgpu_discovery_init(adev);
1202 DRM_ERROR("amdgpu_discovery_init failed\n");
1206 adev->gfx.xcc_mask = 0;
1207 adev->sdma.sdma_mask = 0;
1208 adev->vcn.inst_mask = 0;
1209 adev->jpeg.inst_mask = 0;
1210 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1211 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1212 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1213 num_dies = le16_to_cpu(ihdr->num_dies);
1215 DRM_DEBUG("number of dies: %d\n", num_dies);
1217 for (i = 0; i < num_dies; i++) {
1218 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
1219 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1220 num_ips = le16_to_cpu(dhdr->num_ips);
1221 ip_offset = die_offset + sizeof(*dhdr);
1223 if (le16_to_cpu(dhdr->die_id) != i) {
1224 DRM_ERROR("invalid die id %d, expected %d\n",
1225 le16_to_cpu(dhdr->die_id), i);
1229 DRM_DEBUG("number of hardware IPs on die%d: %d\n",
1230 le16_to_cpu(dhdr->die_id), num_ips);
1232 for (j = 0; j < num_ips; j++) {
1233 ip = (struct ip_v4 *)(adev->mman.discovery_bin + ip_offset);
1235 if (amdgpu_discovery_validate_ip(ip))
1238 num_base_address = ip->num_base_address;
1240 DRM_DEBUG("%s(%d) #%d v%d.%d.%d:\n",
1241 hw_id_names[le16_to_cpu(ip->hw_id)],
1242 le16_to_cpu(ip->hw_id),
1243 ip->instance_number,
1244 ip->major, ip->minor,
1247 if (le16_to_cpu(ip->hw_id) == VCN_HWID) {
1248 /* Bit [5:0]: original revision value
1249 * Bit [7:6]: en/decode capability:
1250 * 0b00 : VCN function normally
1251 * 0b10 : encode is disabled
1252 * 0b01 : decode is disabled
1254 adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
1255 ip->revision & 0xc0;
1256 ip->revision &= ~0xc0;
1257 if (adev->vcn.num_vcn_inst <
1258 AMDGPU_MAX_VCN_INSTANCES) {
1259 adev->vcn.num_vcn_inst++;
1260 adev->vcn.inst_mask |=
1261 (1U << ip->instance_number);
1262 adev->jpeg.inst_mask |=
1263 (1U << ip->instance_number);
1265 dev_err(adev->dev, "Too many VCN instances: %d vs %d\n",
1266 adev->vcn.num_vcn_inst + 1,
1267 AMDGPU_MAX_VCN_INSTANCES);
1270 if (le16_to_cpu(ip->hw_id) == SDMA0_HWID ||
1271 le16_to_cpu(ip->hw_id) == SDMA1_HWID ||
1272 le16_to_cpu(ip->hw_id) == SDMA2_HWID ||
1273 le16_to_cpu(ip->hw_id) == SDMA3_HWID) {
1274 if (adev->sdma.num_instances <
1275 AMDGPU_MAX_SDMA_INSTANCES) {
1276 adev->sdma.num_instances++;
1277 adev->sdma.sdma_mask |=
1278 (1U << ip->instance_number);
1280 dev_err(adev->dev, "Too many SDMA instances: %d vs %d\n",
1281 adev->sdma.num_instances + 1,
1282 AMDGPU_MAX_SDMA_INSTANCES);
1286 if (le16_to_cpu(ip->hw_id) == UMC_HWID) {
1287 adev->gmc.num_umc++;
1288 adev->umc.node_inst_num++;
1291 if (le16_to_cpu(ip->hw_id) == GC_HWID)
1292 adev->gfx.xcc_mask |=
1293 (1U << ip->instance_number);
1295 for (k = 0; k < num_base_address; k++) {
1297 * convert the endianness of base addresses in place,
1298 * so that we don't need to convert them when accessing adev->reg_offset.
1300 if (ihdr->base_addr_64_bit)
1301 /* Truncate the 64bit base address from ip discovery
1302 * and only store lower 32bit ip base in reg_offset[].
1303 * Bits > 32 follows ASIC specific format, thus just
1304 * discard them and handle it within specific ASIC.
1305 * By this way reg_offset[] and related helpers can
1307 * The base address is in dwords, thus clear the
1308 * highest 2 bits to store.
1310 ip->base_address[k] =
1311 lower_32_bits(le64_to_cpu(ip->base_address_64[k])) & 0x3FFFFFFF;
1313 ip->base_address[k] = le32_to_cpu(ip->base_address[k]);
1314 DRM_DEBUG("\t0x%08x\n", ip->base_address[k]);
1317 for (hw_ip = 0; hw_ip < MAX_HWIP; hw_ip++) {
1318 if (hw_id_map[hw_ip] == le16_to_cpu(ip->hw_id) &&
1319 hw_id_map[hw_ip] != 0) {
1320 DRM_DEBUG("set register base offset for %s\n",
1321 hw_id_names[le16_to_cpu(ip->hw_id)]);
1322 adev->reg_offset[hw_ip][ip->instance_number] =
1324 /* Instance support is somewhat inconsistent.
1325 * SDMA is a good example. Sienna cichlid has 4 total
1326 * SDMA instances, each enumerated separately (HWIDs
1327 * 42, 43, 68, 69). Arcturus has 8 total SDMA instances,
1328 * but they are enumerated as multiple instances of the
1329 * same HWIDs (4x HWID 42, 4x HWID 43). UMC is another
1330 * example. On most chips there are multiple instances
1331 * with the same HWID.
1333 adev->ip_versions[hw_ip][ip->instance_number] =
1334 IP_VERSION(ip->major, ip->minor, ip->revision);
1339 if (ihdr->base_addr_64_bit)
1340 ip_offset += struct_size(ip, base_address_64, ip->num_base_address);
1342 ip_offset += struct_size(ip, base_address, ip->num_base_address);
1349 static void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
1351 int vcn_harvest_count = 0;
1352 int umc_harvest_count = 0;
1355 * Harvest table does not fit Navi1x and legacy GPUs,
1356 * so read harvest bit per IP data structure to set
1357 * harvest configuration.
1359 if (adev->ip_versions[GC_HWIP][0] < IP_VERSION(10, 2, 0) &&
1360 adev->ip_versions[GC_HWIP][0] != IP_VERSION(9, 4, 3)) {
1361 if ((adev->pdev->device == 0x731E &&
1362 (adev->pdev->revision == 0xC6 ||
1363 adev->pdev->revision == 0xC7)) ||
1364 (adev->pdev->device == 0x7340 &&
1365 adev->pdev->revision == 0xC9) ||
1366 (adev->pdev->device == 0x7360 &&
1367 adev->pdev->revision == 0xC7))
1368 amdgpu_discovery_read_harvest_bit_per_ip(adev,
1369 &vcn_harvest_count);
1371 amdgpu_discovery_read_from_harvest_table(adev,
1373 &umc_harvest_count);
1376 amdgpu_discovery_harvest_config_quirk(adev);
1378 if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
1379 adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
1380 adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
1383 if (umc_harvest_count < adev->gmc.num_umc) {
1384 adev->gmc.num_umc -= umc_harvest_count;
1389 struct gc_info_v1_0 v1;
1390 struct gc_info_v1_1 v1_1;
1391 struct gc_info_v1_2 v1_2;
1392 struct gc_info_v2_0 v2;
1393 struct gc_info_v2_1 v2_1;
1396 static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
1398 struct binary_header *bhdr;
1399 union gc_info *gc_info;
1402 if (!adev->mman.discovery_bin) {
1403 DRM_ERROR("ip discovery uninitialized\n");
1407 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1408 offset = le16_to_cpu(bhdr->table_list[GC].offset);
1413 gc_info = (union gc_info *)(adev->mman.discovery_bin + offset);
1415 switch (le16_to_cpu(gc_info->v1.header.version_major)) {
1417 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v1.gc_num_se);
1418 adev->gfx.config.max_cu_per_sh = 2 * (le32_to_cpu(gc_info->v1.gc_num_wgp0_per_sa) +
1419 le32_to_cpu(gc_info->v1.gc_num_wgp1_per_sa));
1420 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1421 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v1.gc_num_rb_per_se);
1422 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v1.gc_num_gl2c);
1423 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v1.gc_num_gprs);
1424 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v1.gc_num_max_gs_thds);
1425 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v1.gc_gs_table_depth);
1426 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v1.gc_gsprim_buff_depth);
1427 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v1.gc_double_offchip_lds_buffer);
1428 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v1.gc_wave_size);
1429 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v1.gc_max_waves_per_simd);
1430 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v1.gc_max_scratch_slots_per_cu);
1431 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v1.gc_lds_size);
1432 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v1.gc_num_sc_per_se) /
1433 le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1434 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v1.gc_num_packer_per_sc);
1435 if (gc_info->v1.header.version_minor >= 1) {
1436 adev->gfx.config.gc_num_tcp_per_sa = le32_to_cpu(gc_info->v1_1.gc_num_tcp_per_sa);
1437 adev->gfx.config.gc_num_sdp_interface = le32_to_cpu(gc_info->v1_1.gc_num_sdp_interface);
1438 adev->gfx.config.gc_num_tcps = le32_to_cpu(gc_info->v1_1.gc_num_tcps);
1440 if (gc_info->v1.header.version_minor >= 2) {
1441 adev->gfx.config.gc_num_tcp_per_wpg = le32_to_cpu(gc_info->v1_2.gc_num_tcp_per_wpg);
1442 adev->gfx.config.gc_tcp_l1_size = le32_to_cpu(gc_info->v1_2.gc_tcp_l1_size);
1443 adev->gfx.config.gc_num_sqc_per_wgp = le32_to_cpu(gc_info->v1_2.gc_num_sqc_per_wgp);
1444 adev->gfx.config.gc_l1_instruction_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_instruction_cache_size_per_sqc);
1445 adev->gfx.config.gc_l1_data_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_data_cache_size_per_sqc);
1446 adev->gfx.config.gc_gl1c_per_sa = le32_to_cpu(gc_info->v1_2.gc_gl1c_per_sa);
1447 adev->gfx.config.gc_gl1c_size_per_instance = le32_to_cpu(gc_info->v1_2.gc_gl1c_size_per_instance);
1448 adev->gfx.config.gc_gl2c_per_gpu = le32_to_cpu(gc_info->v1_2.gc_gl2c_per_gpu);
1452 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v2.gc_num_se);
1453 adev->gfx.config.max_cu_per_sh = le32_to_cpu(gc_info->v2.gc_num_cu_per_sh);
1454 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1455 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v2.gc_num_rb_per_se);
1456 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v2.gc_num_tccs);
1457 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v2.gc_num_gprs);
1458 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v2.gc_num_max_gs_thds);
1459 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v2.gc_gs_table_depth);
1460 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v2.gc_gsprim_buff_depth);
1461 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v2.gc_double_offchip_lds_buffer);
1462 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v2.gc_wave_size);
1463 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v2.gc_max_waves_per_simd);
1464 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v2.gc_max_scratch_slots_per_cu);
1465 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v2.gc_lds_size);
1466 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v2.gc_num_sc_per_se) /
1467 le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1468 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v2.gc_num_packer_per_sc);
1469 if (gc_info->v2.header.version_minor == 1) {
1470 adev->gfx.config.gc_num_tcp_per_sa = le32_to_cpu(gc_info->v2_1.gc_num_tcp_per_sh);
1471 adev->gfx.config.gc_tcp_size_per_cu = le32_to_cpu(gc_info->v2_1.gc_tcp_size_per_cu);
1472 adev->gfx.config.gc_num_sdp_interface = le32_to_cpu(gc_info->v2_1.gc_num_sdp_interface); /* per XCD */
1473 adev->gfx.config.gc_num_cu_per_sqc = le32_to_cpu(gc_info->v2_1.gc_num_cu_per_sqc);
1474 adev->gfx.config.gc_l1_instruction_cache_size_per_sqc = le32_to_cpu(gc_info->v2_1.gc_instruction_cache_size_per_sqc);
1475 adev->gfx.config.gc_l1_data_cache_size_per_sqc = le32_to_cpu(gc_info->v2_1.gc_scalar_data_cache_size_per_sqc);
1476 adev->gfx.config.gc_tcc_size = le32_to_cpu(gc_info->v2_1.gc_tcc_size); /* per XCD */
1481 "Unhandled GC info table %d.%d\n",
1482 le16_to_cpu(gc_info->v1.header.version_major),
1483 le16_to_cpu(gc_info->v1.header.version_minor));
1490 struct mall_info_v1_0 v1;
1491 struct mall_info_v2_0 v2;
1494 static int amdgpu_discovery_get_mall_info(struct amdgpu_device *adev)
1496 struct binary_header *bhdr;
1497 union mall_info *mall_info;
1498 u32 u, mall_size_per_umc, m_s_present, half_use;
1502 if (!adev->mman.discovery_bin) {
1503 DRM_ERROR("ip discovery uninitialized\n");
1507 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1508 offset = le16_to_cpu(bhdr->table_list[MALL_INFO].offset);
1513 mall_info = (union mall_info *)(adev->mman.discovery_bin + offset);
1515 switch (le16_to_cpu(mall_info->v1.header.version_major)) {
1518 mall_size_per_umc = le32_to_cpu(mall_info->v1.mall_size_per_m);
1519 m_s_present = le32_to_cpu(mall_info->v1.m_s_present);
1520 half_use = le32_to_cpu(mall_info->v1.m_half_use);
1521 for (u = 0; u < adev->gmc.num_umc; u++) {
1522 if (m_s_present & (1 << u))
1523 mall_size += mall_size_per_umc * 2;
1524 else if (half_use & (1 << u))
1525 mall_size += mall_size_per_umc / 2;
1527 mall_size += mall_size_per_umc;
1529 adev->gmc.mall_size = mall_size;
1530 adev->gmc.m_half_use = half_use;
1533 mall_size_per_umc = le32_to_cpu(mall_info->v2.mall_size_per_umc);
1534 adev->gmc.mall_size = mall_size_per_umc * adev->gmc.num_umc;
1538 "Unhandled MALL info table %d.%d\n",
1539 le16_to_cpu(mall_info->v1.header.version_major),
1540 le16_to_cpu(mall_info->v1.header.version_minor));
1547 struct vcn_info_v1_0 v1;
1550 static int amdgpu_discovery_get_vcn_info(struct amdgpu_device *adev)
1552 struct binary_header *bhdr;
1553 union vcn_info *vcn_info;
1557 if (!adev->mman.discovery_bin) {
1558 DRM_ERROR("ip discovery uninitialized\n");
1562 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1563 * which is smaller than VCN_INFO_TABLE_MAX_NUM_INSTANCES
1564 * but that may change in the future with new GPUs so keep this
1565 * check for defensive purposes.
1567 if (adev->vcn.num_vcn_inst > VCN_INFO_TABLE_MAX_NUM_INSTANCES) {
1568 dev_err(adev->dev, "invalid vcn instances\n");
1572 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1573 offset = le16_to_cpu(bhdr->table_list[VCN_INFO].offset);
1578 vcn_info = (union vcn_info *)(adev->mman.discovery_bin + offset);
1580 switch (le16_to_cpu(vcn_info->v1.header.version_major)) {
1582 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1583 * so this won't overflow.
1585 for (v = 0; v < adev->vcn.num_vcn_inst; v++) {
1586 adev->vcn.vcn_codec_disable_mask[v] =
1587 le32_to_cpu(vcn_info->v1.instance_info[v].fuse_data.all_bits);
1592 "Unhandled VCN info table %d.%d\n",
1593 le16_to_cpu(vcn_info->v1.header.version_major),
1594 le16_to_cpu(vcn_info->v1.header.version_minor));
1600 static int amdgpu_discovery_set_common_ip_blocks(struct amdgpu_device *adev)
1602 /* what IP to use for this? */
1603 switch (adev->ip_versions[GC_HWIP][0]) {
1604 case IP_VERSION(9, 0, 1):
1605 case IP_VERSION(9, 1, 0):
1606 case IP_VERSION(9, 2, 1):
1607 case IP_VERSION(9, 2, 2):
1608 case IP_VERSION(9, 3, 0):
1609 case IP_VERSION(9, 4, 0):
1610 case IP_VERSION(9, 4, 1):
1611 case IP_VERSION(9, 4, 2):
1612 case IP_VERSION(9, 4, 3):
1613 amdgpu_device_ip_block_add(adev, &vega10_common_ip_block);
1615 case IP_VERSION(10, 1, 10):
1616 case IP_VERSION(10, 1, 1):
1617 case IP_VERSION(10, 1, 2):
1618 case IP_VERSION(10, 1, 3):
1619 case IP_VERSION(10, 1, 4):
1620 case IP_VERSION(10, 3, 0):
1621 case IP_VERSION(10, 3, 1):
1622 case IP_VERSION(10, 3, 2):
1623 case IP_VERSION(10, 3, 3):
1624 case IP_VERSION(10, 3, 4):
1625 case IP_VERSION(10, 3, 5):
1626 case IP_VERSION(10, 3, 6):
1627 case IP_VERSION(10, 3, 7):
1628 amdgpu_device_ip_block_add(adev, &nv_common_ip_block);
1630 case IP_VERSION(11, 0, 0):
1631 case IP_VERSION(11, 0, 1):
1632 case IP_VERSION(11, 0, 2):
1633 case IP_VERSION(11, 0, 3):
1634 case IP_VERSION(11, 0, 4):
1635 amdgpu_device_ip_block_add(adev, &soc21_common_ip_block);
1639 "Failed to add common ip block(GC_HWIP:0x%x)\n",
1640 adev->ip_versions[GC_HWIP][0]);
1646 static int amdgpu_discovery_set_gmc_ip_blocks(struct amdgpu_device *adev)
1648 /* use GC or MMHUB IP version */
1649 switch (adev->ip_versions[GC_HWIP][0]) {
1650 case IP_VERSION(9, 0, 1):
1651 case IP_VERSION(9, 1, 0):
1652 case IP_VERSION(9, 2, 1):
1653 case IP_VERSION(9, 2, 2):
1654 case IP_VERSION(9, 3, 0):
1655 case IP_VERSION(9, 4, 0):
1656 case IP_VERSION(9, 4, 1):
1657 case IP_VERSION(9, 4, 2):
1658 case IP_VERSION(9, 4, 3):
1659 amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block);
1661 case IP_VERSION(10, 1, 10):
1662 case IP_VERSION(10, 1, 1):
1663 case IP_VERSION(10, 1, 2):
1664 case IP_VERSION(10, 1, 3):
1665 case IP_VERSION(10, 1, 4):
1666 case IP_VERSION(10, 3, 0):
1667 case IP_VERSION(10, 3, 1):
1668 case IP_VERSION(10, 3, 2):
1669 case IP_VERSION(10, 3, 3):
1670 case IP_VERSION(10, 3, 4):
1671 case IP_VERSION(10, 3, 5):
1672 case IP_VERSION(10, 3, 6):
1673 case IP_VERSION(10, 3, 7):
1674 amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block);
1676 case IP_VERSION(11, 0, 0):
1677 case IP_VERSION(11, 0, 1):
1678 case IP_VERSION(11, 0, 2):
1679 case IP_VERSION(11, 0, 3):
1680 case IP_VERSION(11, 0, 4):
1681 amdgpu_device_ip_block_add(adev, &gmc_v11_0_ip_block);
1685 "Failed to add gmc ip block(GC_HWIP:0x%x)\n",
1686 adev->ip_versions[GC_HWIP][0]);
1692 static int amdgpu_discovery_set_ih_ip_blocks(struct amdgpu_device *adev)
1694 switch (adev->ip_versions[OSSSYS_HWIP][0]) {
1695 case IP_VERSION(4, 0, 0):
1696 case IP_VERSION(4, 0, 1):
1697 case IP_VERSION(4, 1, 0):
1698 case IP_VERSION(4, 1, 1):
1699 case IP_VERSION(4, 3, 0):
1700 amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block);
1702 case IP_VERSION(4, 2, 0):
1703 case IP_VERSION(4, 2, 1):
1704 case IP_VERSION(4, 4, 0):
1705 case IP_VERSION(4, 4, 2):
1706 amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block);
1708 case IP_VERSION(5, 0, 0):
1709 case IP_VERSION(5, 0, 1):
1710 case IP_VERSION(5, 0, 2):
1711 case IP_VERSION(5, 0, 3):
1712 case IP_VERSION(5, 2, 0):
1713 case IP_VERSION(5, 2, 1):
1714 amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);
1716 case IP_VERSION(6, 0, 0):
1717 case IP_VERSION(6, 0, 1):
1718 case IP_VERSION(6, 0, 2):
1719 amdgpu_device_ip_block_add(adev, &ih_v6_0_ip_block);
1721 case IP_VERSION(6, 1, 0):
1722 amdgpu_device_ip_block_add(adev, &ih_v6_1_ip_block);
1726 "Failed to add ih ip block(OSSSYS_HWIP:0x%x)\n",
1727 adev->ip_versions[OSSSYS_HWIP][0]);
1733 static int amdgpu_discovery_set_psp_ip_blocks(struct amdgpu_device *adev)
1735 switch (adev->ip_versions[MP0_HWIP][0]) {
1736 case IP_VERSION(9, 0, 0):
1737 amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block);
1739 case IP_VERSION(10, 0, 0):
1740 case IP_VERSION(10, 0, 1):
1741 amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block);
1743 case IP_VERSION(11, 0, 0):
1744 case IP_VERSION(11, 0, 2):
1745 case IP_VERSION(11, 0, 4):
1746 case IP_VERSION(11, 0, 5):
1747 case IP_VERSION(11, 0, 9):
1748 case IP_VERSION(11, 0, 7):
1749 case IP_VERSION(11, 0, 11):
1750 case IP_VERSION(11, 0, 12):
1751 case IP_VERSION(11, 0, 13):
1752 case IP_VERSION(11, 5, 0):
1753 amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);
1755 case IP_VERSION(11, 0, 8):
1756 amdgpu_device_ip_block_add(adev, &psp_v11_0_8_ip_block);
1758 case IP_VERSION(11, 0, 3):
1759 case IP_VERSION(12, 0, 1):
1760 amdgpu_device_ip_block_add(adev, &psp_v12_0_ip_block);
1762 case IP_VERSION(13, 0, 0):
1763 case IP_VERSION(13, 0, 1):
1764 case IP_VERSION(13, 0, 2):
1765 case IP_VERSION(13, 0, 3):
1766 case IP_VERSION(13, 0, 5):
1767 case IP_VERSION(13, 0, 6):
1768 case IP_VERSION(13, 0, 7):
1769 case IP_VERSION(13, 0, 8):
1770 case IP_VERSION(13, 0, 10):
1771 case IP_VERSION(13, 0, 11):
1772 case IP_VERSION(14, 0, 0):
1773 amdgpu_device_ip_block_add(adev, &psp_v13_0_ip_block);
1775 case IP_VERSION(13, 0, 4):
1776 amdgpu_device_ip_block_add(adev, &psp_v13_0_4_ip_block);
1780 "Failed to add psp ip block(MP0_HWIP:0x%x)\n",
1781 adev->ip_versions[MP0_HWIP][0]);
1787 static int amdgpu_discovery_set_smu_ip_blocks(struct amdgpu_device *adev)
1789 switch (adev->ip_versions[MP1_HWIP][0]) {
1790 case IP_VERSION(9, 0, 0):
1791 case IP_VERSION(10, 0, 0):
1792 case IP_VERSION(10, 0, 1):
1793 case IP_VERSION(11, 0, 2):
1794 if (adev->asic_type == CHIP_ARCTURUS)
1795 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1797 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block);
1799 case IP_VERSION(11, 0, 0):
1800 case IP_VERSION(11, 0, 5):
1801 case IP_VERSION(11, 0, 9):
1802 case IP_VERSION(11, 0, 7):
1803 case IP_VERSION(11, 0, 8):
1804 case IP_VERSION(11, 0, 11):
1805 case IP_VERSION(11, 0, 12):
1806 case IP_VERSION(11, 0, 13):
1807 case IP_VERSION(11, 5, 0):
1808 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1810 case IP_VERSION(12, 0, 0):
1811 case IP_VERSION(12, 0, 1):
1812 amdgpu_device_ip_block_add(adev, &smu_v12_0_ip_block);
1814 case IP_VERSION(13, 0, 0):
1815 case IP_VERSION(13, 0, 1):
1816 case IP_VERSION(13, 0, 2):
1817 case IP_VERSION(13, 0, 3):
1818 case IP_VERSION(13, 0, 4):
1819 case IP_VERSION(13, 0, 5):
1820 case IP_VERSION(13, 0, 6):
1821 case IP_VERSION(13, 0, 7):
1822 case IP_VERSION(13, 0, 8):
1823 case IP_VERSION(13, 0, 10):
1824 case IP_VERSION(13, 0, 11):
1825 amdgpu_device_ip_block_add(adev, &smu_v13_0_ip_block);
1829 "Failed to add smu ip block(MP1_HWIP:0x%x)\n",
1830 adev->ip_versions[MP1_HWIP][0]);
1836 #if defined(CONFIG_DRM_AMD_DC)
1837 static void amdgpu_discovery_set_sriov_display(struct amdgpu_device *adev)
1839 amdgpu_device_set_sriov_virtual_display(adev);
1840 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1844 static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)
1846 if (adev->enable_virtual_display) {
1847 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1851 if (!amdgpu_device_has_dc_support(adev))
1854 #if defined(CONFIG_DRM_AMD_DC)
1855 if (adev->ip_versions[DCE_HWIP][0]) {
1856 switch (adev->ip_versions[DCE_HWIP][0]) {
1857 case IP_VERSION(1, 0, 0):
1858 case IP_VERSION(1, 0, 1):
1859 case IP_VERSION(2, 0, 2):
1860 case IP_VERSION(2, 0, 0):
1861 case IP_VERSION(2, 0, 3):
1862 case IP_VERSION(2, 1, 0):
1863 case IP_VERSION(3, 0, 0):
1864 case IP_VERSION(3, 0, 2):
1865 case IP_VERSION(3, 0, 3):
1866 case IP_VERSION(3, 0, 1):
1867 case IP_VERSION(3, 1, 2):
1868 case IP_VERSION(3, 1, 3):
1869 case IP_VERSION(3, 1, 4):
1870 case IP_VERSION(3, 1, 5):
1871 case IP_VERSION(3, 1, 6):
1872 case IP_VERSION(3, 2, 0):
1873 case IP_VERSION(3, 2, 1):
1874 if (amdgpu_sriov_vf(adev))
1875 amdgpu_discovery_set_sriov_display(adev);
1877 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1881 "Failed to add dm ip block(DCE_HWIP:0x%x)\n",
1882 adev->ip_versions[DCE_HWIP][0]);
1885 } else if (adev->ip_versions[DCI_HWIP][0]) {
1886 switch (adev->ip_versions[DCI_HWIP][0]) {
1887 case IP_VERSION(12, 0, 0):
1888 case IP_VERSION(12, 0, 1):
1889 case IP_VERSION(12, 1, 0):
1890 if (amdgpu_sriov_vf(adev))
1891 amdgpu_discovery_set_sriov_display(adev);
1893 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1897 "Failed to add dm ip block(DCI_HWIP:0x%x)\n",
1898 adev->ip_versions[DCI_HWIP][0]);
1906 static int amdgpu_discovery_set_gc_ip_blocks(struct amdgpu_device *adev)
1908 switch (adev->ip_versions[GC_HWIP][0]) {
1909 case IP_VERSION(9, 0, 1):
1910 case IP_VERSION(9, 1, 0):
1911 case IP_VERSION(9, 2, 1):
1912 case IP_VERSION(9, 2, 2):
1913 case IP_VERSION(9, 3, 0):
1914 case IP_VERSION(9, 4, 0):
1915 case IP_VERSION(9, 4, 1):
1916 case IP_VERSION(9, 4, 2):
1917 amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
1919 case IP_VERSION(9, 4, 3):
1920 if (!amdgpu_exp_hw_support)
1922 amdgpu_device_ip_block_add(adev, &gfx_v9_4_3_ip_block);
1924 case IP_VERSION(10, 1, 10):
1925 case IP_VERSION(10, 1, 2):
1926 case IP_VERSION(10, 1, 1):
1927 case IP_VERSION(10, 1, 3):
1928 case IP_VERSION(10, 1, 4):
1929 case IP_VERSION(10, 3, 0):
1930 case IP_VERSION(10, 3, 2):
1931 case IP_VERSION(10, 3, 1):
1932 case IP_VERSION(10, 3, 4):
1933 case IP_VERSION(10, 3, 5):
1934 case IP_VERSION(10, 3, 6):
1935 case IP_VERSION(10, 3, 3):
1936 case IP_VERSION(10, 3, 7):
1937 amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block);
1939 case IP_VERSION(11, 0, 0):
1940 case IP_VERSION(11, 0, 1):
1941 case IP_VERSION(11, 0, 2):
1942 case IP_VERSION(11, 0, 3):
1943 case IP_VERSION(11, 0, 4):
1944 amdgpu_device_ip_block_add(adev, &gfx_v11_0_ip_block);
1948 "Failed to add gfx ip block(GC_HWIP:0x%x)\n",
1949 adev->ip_versions[GC_HWIP][0]);
1955 static int amdgpu_discovery_set_sdma_ip_blocks(struct amdgpu_device *adev)
1957 switch (adev->ip_versions[SDMA0_HWIP][0]) {
1958 case IP_VERSION(4, 0, 0):
1959 case IP_VERSION(4, 0, 1):
1960 case IP_VERSION(4, 1, 0):
1961 case IP_VERSION(4, 1, 1):
1962 case IP_VERSION(4, 1, 2):
1963 case IP_VERSION(4, 2, 0):
1964 case IP_VERSION(4, 2, 2):
1965 case IP_VERSION(4, 4, 0):
1966 amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
1968 case IP_VERSION(4, 4, 2):
1969 amdgpu_device_ip_block_add(adev, &sdma_v4_4_2_ip_block);
1971 case IP_VERSION(5, 0, 0):
1972 case IP_VERSION(5, 0, 1):
1973 case IP_VERSION(5, 0, 2):
1974 case IP_VERSION(5, 0, 5):
1975 amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block);
1977 case IP_VERSION(5, 2, 0):
1978 case IP_VERSION(5, 2, 2):
1979 case IP_VERSION(5, 2, 4):
1980 case IP_VERSION(5, 2, 5):
1981 case IP_VERSION(5, 2, 6):
1982 case IP_VERSION(5, 2, 3):
1983 case IP_VERSION(5, 2, 1):
1984 case IP_VERSION(5, 2, 7):
1985 amdgpu_device_ip_block_add(adev, &sdma_v5_2_ip_block);
1987 case IP_VERSION(6, 0, 0):
1988 case IP_VERSION(6, 0, 1):
1989 case IP_VERSION(6, 0, 2):
1990 case IP_VERSION(6, 0, 3):
1991 case IP_VERSION(6, 1, 0):
1992 amdgpu_device_ip_block_add(adev, &sdma_v6_0_ip_block);
1996 "Failed to add sdma ip block(SDMA0_HWIP:0x%x)\n",
1997 adev->ip_versions[SDMA0_HWIP][0]);
2003 static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
2005 if (adev->ip_versions[VCE_HWIP][0]) {
2006 switch (adev->ip_versions[UVD_HWIP][0]) {
2007 case IP_VERSION(7, 0, 0):
2008 case IP_VERSION(7, 2, 0):
2009 /* UVD is not supported on vega20 SR-IOV */
2010 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
2011 amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block);
2015 "Failed to add uvd v7 ip block(UVD_HWIP:0x%x)\n",
2016 adev->ip_versions[UVD_HWIP][0]);
2019 switch (adev->ip_versions[VCE_HWIP][0]) {
2020 case IP_VERSION(4, 0, 0):
2021 case IP_VERSION(4, 1, 0):
2022 /* VCE is not supported on vega20 SR-IOV */
2023 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
2024 amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block);
2028 "Failed to add VCE v4 ip block(VCE_HWIP:0x%x)\n",
2029 adev->ip_versions[VCE_HWIP][0]);
2033 switch (adev->ip_versions[UVD_HWIP][0]) {
2034 case IP_VERSION(1, 0, 0):
2035 case IP_VERSION(1, 0, 1):
2036 amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block);
2038 case IP_VERSION(2, 0, 0):
2039 case IP_VERSION(2, 0, 2):
2040 case IP_VERSION(2, 2, 0):
2041 amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
2042 if (!amdgpu_sriov_vf(adev))
2043 amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
2045 case IP_VERSION(2, 0, 3):
2047 case IP_VERSION(2, 5, 0):
2048 amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
2049 amdgpu_device_ip_block_add(adev, &jpeg_v2_5_ip_block);
2051 case IP_VERSION(2, 6, 0):
2052 amdgpu_device_ip_block_add(adev, &vcn_v2_6_ip_block);
2053 amdgpu_device_ip_block_add(adev, &jpeg_v2_6_ip_block);
2055 case IP_VERSION(3, 0, 0):
2056 case IP_VERSION(3, 0, 16):
2057 case IP_VERSION(3, 1, 1):
2058 case IP_VERSION(3, 1, 2):
2059 case IP_VERSION(3, 0, 2):
2060 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
2061 if (!amdgpu_sriov_vf(adev))
2062 amdgpu_device_ip_block_add(adev, &jpeg_v3_0_ip_block);
2064 case IP_VERSION(3, 0, 33):
2065 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
2067 case IP_VERSION(4, 0, 0):
2068 case IP_VERSION(4, 0, 2):
2069 case IP_VERSION(4, 0, 4):
2070 amdgpu_device_ip_block_add(adev, &vcn_v4_0_ip_block);
2071 amdgpu_device_ip_block_add(adev, &jpeg_v4_0_ip_block);
2073 case IP_VERSION(4, 0, 3):
2074 amdgpu_device_ip_block_add(adev, &vcn_v4_0_3_ip_block);
2075 amdgpu_device_ip_block_add(adev, &jpeg_v4_0_3_ip_block);
2079 "Failed to add vcn/jpeg ip block(UVD_HWIP:0x%x)\n",
2080 adev->ip_versions[UVD_HWIP][0]);
2087 static int amdgpu_discovery_set_mes_ip_blocks(struct amdgpu_device *adev)
2089 switch (adev->ip_versions[GC_HWIP][0]) {
2090 case IP_VERSION(10, 1, 10):
2091 case IP_VERSION(10, 1, 1):
2092 case IP_VERSION(10, 1, 2):
2093 case IP_VERSION(10, 1, 3):
2094 case IP_VERSION(10, 1, 4):
2095 case IP_VERSION(10, 3, 0):
2096 case IP_VERSION(10, 3, 1):
2097 case IP_VERSION(10, 3, 2):
2098 case IP_VERSION(10, 3, 3):
2099 case IP_VERSION(10, 3, 4):
2100 case IP_VERSION(10, 3, 5):
2101 case IP_VERSION(10, 3, 6):
2103 amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block);
2104 adev->enable_mes = true;
2106 adev->enable_mes_kiq = true;
2109 case IP_VERSION(11, 0, 0):
2110 case IP_VERSION(11, 0, 1):
2111 case IP_VERSION(11, 0, 2):
2112 case IP_VERSION(11, 0, 3):
2113 case IP_VERSION(11, 0, 4):
2114 amdgpu_device_ip_block_add(adev, &mes_v11_0_ip_block);
2115 adev->enable_mes = true;
2116 adev->enable_mes_kiq = true;
2124 static void amdgpu_discovery_init_soc_config(struct amdgpu_device *adev)
2126 switch (adev->ip_versions[GC_HWIP][0]) {
2127 case IP_VERSION(9, 4, 3):
2128 aqua_vanjaram_init_soc_config(adev);
2135 int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)
2139 switch (adev->asic_type) {
2141 vega10_reg_base_init(adev);
2142 adev->sdma.num_instances = 2;
2143 adev->gmc.num_umc = 4;
2144 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 0, 0);
2145 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 0, 0);
2146 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 0);
2147 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 0);
2148 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 0);
2149 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 0);
2150 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2151 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 1, 0);
2152 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 0, 0);
2153 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2154 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2155 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2156 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 0);
2157 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 0, 1);
2158 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2159 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2160 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 0);
2163 vega10_reg_base_init(adev);
2164 adev->sdma.num_instances = 2;
2165 adev->gmc.num_umc = 4;
2166 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2167 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2168 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 1);
2169 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 1);
2170 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 1);
2171 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 1);
2172 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 5, 0);
2173 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 2, 0);
2174 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 0);
2175 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2176 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2177 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2178 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 1);
2179 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 1);
2180 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2181 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2182 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 1);
2185 vega10_reg_base_init(adev);
2186 adev->sdma.num_instances = 1;
2187 adev->vcn.num_vcn_inst = 1;
2188 adev->gmc.num_umc = 2;
2189 if (adev->apu_flags & AMD_APU_IS_RAVEN2) {
2190 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2191 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2192 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 1);
2193 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 1);
2194 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 1);
2195 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 1);
2196 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 1);
2197 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 5, 0);
2198 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 1);
2199 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 1);
2200 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 1, 0);
2201 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 1);
2202 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 2);
2203 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 1);
2204 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 1);
2206 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2207 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2208 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 0);
2209 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 0);
2210 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 0);
2211 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2212 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 0);
2213 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 0, 0);
2214 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 0);
2215 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 0);
2216 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 0, 0);
2217 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 0);
2218 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 1, 0);
2219 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 0);
2220 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 0);
2224 vega20_reg_base_init(adev);
2225 adev->sdma.num_instances = 2;
2226 adev->gmc.num_umc = 8;
2227 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2228 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2229 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 0);
2230 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 0);
2231 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 0);
2232 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 0);
2233 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 0);
2234 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 0);
2235 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 1);
2236 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 2);
2237 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2238 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 2);
2239 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 2);
2240 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 0);
2241 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 2, 0);
2242 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(7, 2, 0);
2243 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 1, 0);
2244 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 1, 0);
2247 arct_reg_base_init(adev);
2248 adev->sdma.num_instances = 8;
2249 adev->vcn.num_vcn_inst = 2;
2250 adev->gmc.num_umc = 8;
2251 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2252 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2253 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 1);
2254 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 1);
2255 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 2);
2256 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 2);
2257 adev->ip_versions[SDMA1_HWIP][1] = IP_VERSION(4, 2, 2);
2258 adev->ip_versions[SDMA1_HWIP][2] = IP_VERSION(4, 2, 2);
2259 adev->ip_versions[SDMA1_HWIP][3] = IP_VERSION(4, 2, 2);
2260 adev->ip_versions[SDMA1_HWIP][4] = IP_VERSION(4, 2, 2);
2261 adev->ip_versions[SDMA1_HWIP][5] = IP_VERSION(4, 2, 2);
2262 adev->ip_versions[SDMA1_HWIP][6] = IP_VERSION(4, 2, 2);
2263 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 1);
2264 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 1);
2265 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 2);
2266 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 4);
2267 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2268 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 3);
2269 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 3);
2270 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 1);
2271 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 5, 0);
2272 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 5, 0);
2274 case CHIP_ALDEBARAN:
2275 aldebaran_reg_base_init(adev);
2276 adev->sdma.num_instances = 5;
2277 adev->vcn.num_vcn_inst = 2;
2278 adev->gmc.num_umc = 4;
2279 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2280 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2281 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 4, 0);
2282 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 4, 0);
2283 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 4, 0);
2284 adev->ip_versions[SDMA0_HWIP][1] = IP_VERSION(4, 4, 0);
2285 adev->ip_versions[SDMA0_HWIP][2] = IP_VERSION(4, 4, 0);
2286 adev->ip_versions[SDMA0_HWIP][3] = IP_VERSION(4, 4, 0);
2287 adev->ip_versions[SDMA0_HWIP][4] = IP_VERSION(4, 4, 0);
2288 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 2);
2289 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 4);
2290 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 7, 0);
2291 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(13, 0, 2);
2292 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(13, 0, 2);
2293 adev->ip_versions[THM_HWIP][0] = IP_VERSION(13, 0, 2);
2294 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(13, 0, 2);
2295 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 2);
2296 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 6, 0);
2297 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 6, 0);
2298 adev->ip_versions[XGMI_HWIP][0] = IP_VERSION(6, 1, 0);
2301 r = amdgpu_discovery_reg_base_init(adev);
2305 amdgpu_discovery_harvest_ip(adev);
2306 amdgpu_discovery_get_gfx_info(adev);
2307 amdgpu_discovery_get_mall_info(adev);
2308 amdgpu_discovery_get_vcn_info(adev);
2312 amdgpu_discovery_init_soc_config(adev);
2313 amdgpu_discovery_sysfs_init(adev);
2315 switch (adev->ip_versions[GC_HWIP][0]) {
2316 case IP_VERSION(9, 0, 1):
2317 case IP_VERSION(9, 2, 1):
2318 case IP_VERSION(9, 4, 0):
2319 case IP_VERSION(9, 4, 1):
2320 case IP_VERSION(9, 4, 2):
2321 case IP_VERSION(9, 4, 3):
2322 adev->family = AMDGPU_FAMILY_AI;
2324 case IP_VERSION(9, 1, 0):
2325 case IP_VERSION(9, 2, 2):
2326 case IP_VERSION(9, 3, 0):
2327 adev->family = AMDGPU_FAMILY_RV;
2329 case IP_VERSION(10, 1, 10):
2330 case IP_VERSION(10, 1, 1):
2331 case IP_VERSION(10, 1, 2):
2332 case IP_VERSION(10, 1, 3):
2333 case IP_VERSION(10, 1, 4):
2334 case IP_VERSION(10, 3, 0):
2335 case IP_VERSION(10, 3, 2):
2336 case IP_VERSION(10, 3, 4):
2337 case IP_VERSION(10, 3, 5):
2338 adev->family = AMDGPU_FAMILY_NV;
2340 case IP_VERSION(10, 3, 1):
2341 adev->family = AMDGPU_FAMILY_VGH;
2342 adev->apu_flags |= AMD_APU_IS_VANGOGH;
2344 case IP_VERSION(10, 3, 3):
2345 adev->family = AMDGPU_FAMILY_YC;
2347 case IP_VERSION(10, 3, 6):
2348 adev->family = AMDGPU_FAMILY_GC_10_3_6;
2350 case IP_VERSION(10, 3, 7):
2351 adev->family = AMDGPU_FAMILY_GC_10_3_7;
2353 case IP_VERSION(11, 0, 0):
2354 case IP_VERSION(11, 0, 2):
2355 case IP_VERSION(11, 0, 3):
2356 adev->family = AMDGPU_FAMILY_GC_11_0_0;
2358 case IP_VERSION(11, 0, 1):
2359 case IP_VERSION(11, 0, 4):
2360 adev->family = AMDGPU_FAMILY_GC_11_0_1;
2366 switch (adev->ip_versions[GC_HWIP][0]) {
2367 case IP_VERSION(9, 1, 0):
2368 case IP_VERSION(9, 2, 2):
2369 case IP_VERSION(9, 3, 0):
2370 case IP_VERSION(10, 1, 3):
2371 case IP_VERSION(10, 1, 4):
2372 case IP_VERSION(10, 3, 1):
2373 case IP_VERSION(10, 3, 3):
2374 case IP_VERSION(10, 3, 6):
2375 case IP_VERSION(10, 3, 7):
2376 case IP_VERSION(11, 0, 1):
2377 case IP_VERSION(11, 0, 4):
2378 adev->flags |= AMD_IS_APU;
2384 if (adev->ip_versions[XGMI_HWIP][0] == IP_VERSION(4, 8, 0))
2385 adev->gmc.xgmi.supported = true;
2387 /* set NBIO version */
2388 switch (adev->ip_versions[NBIO_HWIP][0]) {
2389 case IP_VERSION(6, 1, 0):
2390 case IP_VERSION(6, 2, 0):
2391 adev->nbio.funcs = &nbio_v6_1_funcs;
2392 adev->nbio.hdp_flush_reg = &nbio_v6_1_hdp_flush_reg;
2394 case IP_VERSION(7, 0, 0):
2395 case IP_VERSION(7, 0, 1):
2396 case IP_VERSION(2, 5, 0):
2397 adev->nbio.funcs = &nbio_v7_0_funcs;
2398 adev->nbio.hdp_flush_reg = &nbio_v7_0_hdp_flush_reg;
2400 case IP_VERSION(7, 4, 0):
2401 case IP_VERSION(7, 4, 1):
2402 case IP_VERSION(7, 4, 4):
2403 adev->nbio.funcs = &nbio_v7_4_funcs;
2404 adev->nbio.hdp_flush_reg = &nbio_v7_4_hdp_flush_reg;
2406 case IP_VERSION(7, 9, 0):
2407 adev->nbio.funcs = &nbio_v7_9_funcs;
2408 adev->nbio.hdp_flush_reg = &nbio_v7_9_hdp_flush_reg;
2410 case IP_VERSION(7, 2, 0):
2411 case IP_VERSION(7, 2, 1):
2412 case IP_VERSION(7, 3, 0):
2413 case IP_VERSION(7, 5, 0):
2414 case IP_VERSION(7, 5, 1):
2415 adev->nbio.funcs = &nbio_v7_2_funcs;
2416 adev->nbio.hdp_flush_reg = &nbio_v7_2_hdp_flush_reg;
2418 case IP_VERSION(2, 1, 1):
2419 case IP_VERSION(2, 3, 0):
2420 case IP_VERSION(2, 3, 1):
2421 case IP_VERSION(2, 3, 2):
2422 case IP_VERSION(3, 3, 0):
2423 case IP_VERSION(3, 3, 1):
2424 case IP_VERSION(3, 3, 2):
2425 case IP_VERSION(3, 3, 3):
2426 adev->nbio.funcs = &nbio_v2_3_funcs;
2427 adev->nbio.hdp_flush_reg = &nbio_v2_3_hdp_flush_reg;
2429 case IP_VERSION(4, 3, 0):
2430 case IP_VERSION(4, 3, 1):
2431 if (amdgpu_sriov_vf(adev))
2432 adev->nbio.funcs = &nbio_v4_3_sriov_funcs;
2434 adev->nbio.funcs = &nbio_v4_3_funcs;
2435 adev->nbio.hdp_flush_reg = &nbio_v4_3_hdp_flush_reg;
2437 case IP_VERSION(7, 7, 0):
2438 case IP_VERSION(7, 7, 1):
2439 adev->nbio.funcs = &nbio_v7_7_funcs;
2440 adev->nbio.hdp_flush_reg = &nbio_v7_7_hdp_flush_reg;
2446 switch (adev->ip_versions[HDP_HWIP][0]) {
2447 case IP_VERSION(4, 0, 0):
2448 case IP_VERSION(4, 0, 1):
2449 case IP_VERSION(4, 1, 0):
2450 case IP_VERSION(4, 1, 1):
2451 case IP_VERSION(4, 1, 2):
2452 case IP_VERSION(4, 2, 0):
2453 case IP_VERSION(4, 2, 1):
2454 case IP_VERSION(4, 4, 0):
2455 case IP_VERSION(4, 4, 2):
2456 adev->hdp.funcs = &hdp_v4_0_funcs;
2458 case IP_VERSION(5, 0, 0):
2459 case IP_VERSION(5, 0, 1):
2460 case IP_VERSION(5, 0, 2):
2461 case IP_VERSION(5, 0, 3):
2462 case IP_VERSION(5, 0, 4):
2463 case IP_VERSION(5, 2, 0):
2464 adev->hdp.funcs = &hdp_v5_0_funcs;
2466 case IP_VERSION(5, 2, 1):
2467 adev->hdp.funcs = &hdp_v5_2_funcs;
2469 case IP_VERSION(6, 0, 0):
2470 case IP_VERSION(6, 0, 1):
2471 case IP_VERSION(6, 1, 0):
2472 adev->hdp.funcs = &hdp_v6_0_funcs;
2478 switch (adev->ip_versions[DF_HWIP][0]) {
2479 case IP_VERSION(3, 6, 0):
2480 case IP_VERSION(3, 6, 1):
2481 case IP_VERSION(3, 6, 2):
2482 adev->df.funcs = &df_v3_6_funcs;
2484 case IP_VERSION(2, 1, 0):
2485 case IP_VERSION(2, 1, 1):
2486 case IP_VERSION(2, 5, 0):
2487 case IP_VERSION(3, 5, 1):
2488 case IP_VERSION(3, 5, 2):
2489 adev->df.funcs = &df_v1_7_funcs;
2491 case IP_VERSION(4, 3, 0):
2492 adev->df.funcs = &df_v4_3_funcs;
2498 switch (adev->ip_versions[SMUIO_HWIP][0]) {
2499 case IP_VERSION(9, 0, 0):
2500 case IP_VERSION(9, 0, 1):
2501 case IP_VERSION(10, 0, 0):
2502 case IP_VERSION(10, 0, 1):
2503 case IP_VERSION(10, 0, 2):
2504 adev->smuio.funcs = &smuio_v9_0_funcs;
2506 case IP_VERSION(11, 0, 0):
2507 case IP_VERSION(11, 0, 2):
2508 case IP_VERSION(11, 0, 3):
2509 case IP_VERSION(11, 0, 4):
2510 case IP_VERSION(11, 0, 7):
2511 case IP_VERSION(11, 0, 8):
2512 adev->smuio.funcs = &smuio_v11_0_funcs;
2514 case IP_VERSION(11, 0, 6):
2515 case IP_VERSION(11, 0, 10):
2516 case IP_VERSION(11, 0, 11):
2517 case IP_VERSION(11, 5, 0):
2518 case IP_VERSION(13, 0, 1):
2519 case IP_VERSION(13, 0, 9):
2520 case IP_VERSION(13, 0, 10):
2521 adev->smuio.funcs = &smuio_v11_0_6_funcs;
2523 case IP_VERSION(13, 0, 2):
2524 adev->smuio.funcs = &smuio_v13_0_funcs;
2526 case IP_VERSION(13, 0, 3):
2527 adev->smuio.funcs = &smuio_v13_0_3_funcs;
2528 if (adev->smuio.funcs->get_pkg_type(adev) == AMDGPU_PKG_TYPE_APU) {
2529 adev->flags |= AMD_IS_APU;
2532 case IP_VERSION(13, 0, 6):
2533 case IP_VERSION(13, 0, 8):
2534 case IP_VERSION(14, 0, 0):
2535 adev->smuio.funcs = &smuio_v13_0_6_funcs;
2541 switch (adev->ip_versions[LSDMA_HWIP][0]) {
2542 case IP_VERSION(6, 0, 0):
2543 case IP_VERSION(6, 0, 1):
2544 case IP_VERSION(6, 0, 2):
2545 case IP_VERSION(6, 0, 3):
2546 adev->lsdma.funcs = &lsdma_v6_0_funcs;
2552 r = amdgpu_discovery_set_common_ip_blocks(adev);
2556 r = amdgpu_discovery_set_gmc_ip_blocks(adev);
2560 /* For SR-IOV, PSP needs to be initialized before IH */
2561 if (amdgpu_sriov_vf(adev)) {
2562 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2565 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2569 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2573 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2574 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2580 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2581 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2586 r = amdgpu_discovery_set_display_ip_blocks(adev);
2590 r = amdgpu_discovery_set_gc_ip_blocks(adev);
2594 r = amdgpu_discovery_set_sdma_ip_blocks(adev);
2598 if ((adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
2599 !amdgpu_sriov_vf(adev)) ||
2600 (adev->firmware.load_type == AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO && amdgpu_dpm == 1)) {
2601 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2606 r = amdgpu_discovery_set_mm_ip_blocks(adev);
2610 r = amdgpu_discovery_set_mes_ip_blocks(adev);