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"
68 #include "gfx_v10_0.h"
69 #include "gfx_v11_0.h"
70 #include "sdma_v5_0.h"
71 #include "sdma_v5_2.h"
72 #include "sdma_v6_0.h"
73 #include "lsdma_v6_0.h"
75 #include "jpeg_v2_0.h"
77 #include "jpeg_v3_0.h"
79 #include "jpeg_v4_0.h"
80 #include "vcn_v4_0_3.h"
81 #include "jpeg_v4_0_3.h"
82 #include "amdgpu_vkms.h"
83 #include "mes_v10_1.h"
84 #include "mes_v11_0.h"
85 #include "smuio_v11_0.h"
86 #include "smuio_v11_0_6.h"
87 #include "smuio_v13_0.h"
88 #include "smuio_v13_0_3.h"
89 #include "smuio_v13_0_6.h"
91 #define FIRMWARE_IP_DISCOVERY "amdgpu/ip_discovery.bin"
92 MODULE_FIRMWARE(FIRMWARE_IP_DISCOVERY);
94 #define mmRCC_CONFIG_MEMSIZE 0xde3
95 #define mmMM_INDEX 0x0
96 #define mmMM_INDEX_HI 0x6
99 static const char *hw_id_names[HW_ID_MAX] = {
103 [SMUIO_HWID] = "SMUIO",
104 [FUSE_HWID] = "FUSE",
105 [CLKA_HWID] = "CLKA",
109 [AUDIO_AZ_HWID] = "AUDIO_AZ",
115 [XDMA_HWID] = "XDMA",
116 [DCEAZ_HWID] = "DCEAZ",
118 [SDPMUX_HWID] = "SDPMUX",
120 [IOHC_HWID] = "IOHC",
121 [L2IMU_HWID] = "L2IMU",
123 [MMHUB_HWID] = "MMHUB",
124 [ATHUB_HWID] = "ATHUB",
125 [DBGU_NBIO_HWID] = "DBGU_NBIO",
127 [DBGU0_HWID] = "DBGU0",
128 [DBGU1_HWID] = "DBGU1",
129 [OSSSYS_HWID] = "OSSSYS",
131 [SDMA0_HWID] = "SDMA0",
132 [SDMA1_HWID] = "SDMA1",
133 [SDMA2_HWID] = "SDMA2",
134 [SDMA3_HWID] = "SDMA3",
135 [LSDMA_HWID] = "LSDMA",
137 [DBGU_IO_HWID] = "DBGU_IO",
139 [CLKB_HWID] = "CLKB",
141 [DFX_DAP_HWID] = "DFX_DAP",
142 [L1IMU_PCIE_HWID] = "L1IMU_PCIE",
143 [L1IMU_NBIF_HWID] = "L1IMU_NBIF",
144 [L1IMU_IOAGR_HWID] = "L1IMU_IOAGR",
145 [L1IMU3_HWID] = "L1IMU3",
146 [L1IMU4_HWID] = "L1IMU4",
147 [L1IMU5_HWID] = "L1IMU5",
148 [L1IMU6_HWID] = "L1IMU6",
149 [L1IMU7_HWID] = "L1IMU7",
150 [L1IMU8_HWID] = "L1IMU8",
151 [L1IMU9_HWID] = "L1IMU9",
152 [L1IMU10_HWID] = "L1IMU10",
153 [L1IMU11_HWID] = "L1IMU11",
154 [L1IMU12_HWID] = "L1IMU12",
155 [L1IMU13_HWID] = "L1IMU13",
156 [L1IMU14_HWID] = "L1IMU14",
157 [L1IMU15_HWID] = "L1IMU15",
158 [WAFLC_HWID] = "WAFLC",
159 [FCH_USB_PD_HWID] = "FCH_USB_PD",
160 [PCIE_HWID] = "PCIE",
162 [DDCL_HWID] = "DDCL",
164 [IOAGR_HWID] = "IOAGR",
165 [NBIF_HWID] = "NBIF",
166 [IOAPIC_HWID] = "IOAPIC",
167 [SYSTEMHUB_HWID] = "SYSTEMHUB",
168 [NTBCCP_HWID] = "NTBCCP",
170 [SATA_HWID] = "SATA",
172 [CCXSEC_HWID] = "CCXSEC",
173 [XGMI_HWID] = "XGMI",
174 [XGBE_HWID] = "XGBE",
178 static int hw_id_map[MAX_HWIP] = {
180 [HDP_HWIP] = HDP_HWID,
181 [SDMA0_HWIP] = SDMA0_HWID,
182 [SDMA1_HWIP] = SDMA1_HWID,
183 [SDMA2_HWIP] = SDMA2_HWID,
184 [SDMA3_HWIP] = SDMA3_HWID,
185 [LSDMA_HWIP] = LSDMA_HWID,
186 [MMHUB_HWIP] = MMHUB_HWID,
187 [ATHUB_HWIP] = ATHUB_HWID,
188 [NBIO_HWIP] = NBIF_HWID,
189 [MP0_HWIP] = MP0_HWID,
190 [MP1_HWIP] = MP1_HWID,
191 [UVD_HWIP] = UVD_HWID,
192 [VCE_HWIP] = VCE_HWID,
194 [DCE_HWIP] = DMU_HWID,
195 [OSSSYS_HWIP] = OSSSYS_HWID,
196 [SMUIO_HWIP] = SMUIO_HWID,
197 [PWR_HWIP] = PWR_HWID,
198 [NBIF_HWIP] = NBIF_HWID,
199 [THM_HWIP] = THM_HWID,
200 [CLK_HWIP] = CLKA_HWID,
201 [UMC_HWIP] = UMC_HWID,
202 [XGMI_HWIP] = XGMI_HWID,
203 [DCI_HWIP] = DCI_HWID,
204 [PCIE_HWIP] = PCIE_HWID,
207 static int amdgpu_discovery_read_binary_from_sysmem(struct amdgpu_device *adev, uint8_t *binary)
209 u64 tmr_offset, tmr_size, pos;
213 ret = amdgpu_acpi_get_tmr_info(adev, &tmr_offset, &tmr_size);
217 pos = tmr_offset + tmr_size - DISCOVERY_TMR_OFFSET;
219 /* This region is read-only and reserved from system use */
220 discv_regn = memremap(pos, adev->mman.discovery_tmr_size, MEMREMAP_WC);
222 memcpy(binary, discv_regn, adev->mman.discovery_tmr_size);
223 memunmap(discv_regn);
230 static int amdgpu_discovery_read_binary_from_mem(struct amdgpu_device *adev,
233 uint64_t vram_size = (uint64_t)RREG32(mmRCC_CONFIG_MEMSIZE) << 20;
237 uint64_t pos = vram_size - DISCOVERY_TMR_OFFSET;
238 amdgpu_device_vram_access(adev, pos, (uint32_t *)binary,
239 adev->mman.discovery_tmr_size, false);
241 ret = amdgpu_discovery_read_binary_from_sysmem(adev, binary);
247 static int amdgpu_discovery_read_binary_from_file(struct amdgpu_device *adev, uint8_t *binary)
249 const struct firmware *fw;
253 switch (amdgpu_discovery) {
255 fw_name = FIRMWARE_IP_DISCOVERY;
258 dev_warn(adev->dev, "amdgpu_discovery is not set properly\n");
262 r = request_firmware(&fw, fw_name, adev->dev);
264 dev_err(adev->dev, "can't load firmware \"%s\"\n",
269 memcpy((u8 *)binary, (u8 *)fw->data, fw->size);
270 release_firmware(fw);
275 static uint16_t amdgpu_discovery_calculate_checksum(uint8_t *data, uint32_t size)
277 uint16_t checksum = 0;
280 for (i = 0; i < size; i++)
286 static inline bool amdgpu_discovery_verify_checksum(uint8_t *data, uint32_t size,
289 return !!(amdgpu_discovery_calculate_checksum(data, size) == expected);
292 static inline bool amdgpu_discovery_verify_binary_signature(uint8_t *binary)
294 struct binary_header *bhdr;
295 bhdr = (struct binary_header *)binary;
297 return (le32_to_cpu(bhdr->binary_signature) == BINARY_SIGNATURE);
300 static void amdgpu_discovery_harvest_config_quirk(struct amdgpu_device *adev)
303 * So far, apply this quirk only on those Navy Flounder boards which
304 * have a bad harvest table of VCN config.
306 if ((adev->ip_versions[UVD_HWIP][1] == IP_VERSION(3, 0, 1)) &&
307 (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 2))) {
308 switch (adev->pdev->revision) {
316 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
317 adev->vcn.inst_mask &= ~AMDGPU_VCN_HARVEST_VCN1;
325 static int amdgpu_discovery_init(struct amdgpu_device *adev)
327 struct table_info *info;
328 struct binary_header *bhdr;
334 adev->mman.discovery_tmr_size = DISCOVERY_TMR_SIZE;
335 adev->mman.discovery_bin = kzalloc(adev->mman.discovery_tmr_size, GFP_KERNEL);
336 if (!adev->mman.discovery_bin)
339 /* Read from file if it is the preferred option */
340 if (amdgpu_discovery == 2) {
341 dev_info(adev->dev, "use ip discovery information from file");
342 r = amdgpu_discovery_read_binary_from_file(adev, adev->mman.discovery_bin);
345 dev_err(adev->dev, "failed to read ip discovery binary from file\n");
351 r = amdgpu_discovery_read_binary_from_mem(
352 adev, adev->mman.discovery_bin);
357 /* check the ip discovery binary signature */
358 if (!amdgpu_discovery_verify_binary_signature(adev->mman.discovery_bin)) {
360 "get invalid ip discovery binary signature\n");
365 bhdr = (struct binary_header *)adev->mman.discovery_bin;
367 offset = offsetof(struct binary_header, binary_checksum) +
368 sizeof(bhdr->binary_checksum);
369 size = le16_to_cpu(bhdr->binary_size) - offset;
370 checksum = le16_to_cpu(bhdr->binary_checksum);
372 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
374 dev_err(adev->dev, "invalid ip discovery binary checksum\n");
379 info = &bhdr->table_list[IP_DISCOVERY];
380 offset = le16_to_cpu(info->offset);
381 checksum = le16_to_cpu(info->checksum);
384 struct ip_discovery_header *ihdr =
385 (struct ip_discovery_header *)(adev->mman.discovery_bin + offset);
386 if (le32_to_cpu(ihdr->signature) != DISCOVERY_TABLE_SIGNATURE) {
387 dev_err(adev->dev, "invalid ip discovery data table signature\n");
392 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
393 le16_to_cpu(ihdr->size), checksum)) {
394 dev_err(adev->dev, "invalid ip discovery data table checksum\n");
400 info = &bhdr->table_list[GC];
401 offset = le16_to_cpu(info->offset);
402 checksum = le16_to_cpu(info->checksum);
405 struct gpu_info_header *ghdr =
406 (struct gpu_info_header *)(adev->mman.discovery_bin + offset);
408 if (le32_to_cpu(ghdr->table_id) != GC_TABLE_ID) {
409 dev_err(adev->dev, "invalid ip discovery gc table id\n");
414 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
415 le32_to_cpu(ghdr->size), checksum)) {
416 dev_err(adev->dev, "invalid gc data table checksum\n");
422 info = &bhdr->table_list[HARVEST_INFO];
423 offset = le16_to_cpu(info->offset);
424 checksum = le16_to_cpu(info->checksum);
427 struct harvest_info_header *hhdr =
428 (struct harvest_info_header *)(adev->mman.discovery_bin + offset);
430 if (le32_to_cpu(hhdr->signature) != HARVEST_TABLE_SIGNATURE) {
431 dev_err(adev->dev, "invalid ip discovery harvest table signature\n");
436 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
437 sizeof(struct harvest_table), checksum)) {
438 dev_err(adev->dev, "invalid harvest data table checksum\n");
444 info = &bhdr->table_list[VCN_INFO];
445 offset = le16_to_cpu(info->offset);
446 checksum = le16_to_cpu(info->checksum);
449 struct vcn_info_header *vhdr =
450 (struct vcn_info_header *)(adev->mman.discovery_bin + offset);
452 if (le32_to_cpu(vhdr->table_id) != VCN_INFO_TABLE_ID) {
453 dev_err(adev->dev, "invalid ip discovery vcn table id\n");
458 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
459 le32_to_cpu(vhdr->size_bytes), checksum)) {
460 dev_err(adev->dev, "invalid vcn data table checksum\n");
466 info = &bhdr->table_list[MALL_INFO];
467 offset = le16_to_cpu(info->offset);
468 checksum = le16_to_cpu(info->checksum);
471 struct mall_info_header *mhdr =
472 (struct mall_info_header *)(adev->mman.discovery_bin + offset);
474 if (le32_to_cpu(mhdr->table_id) != MALL_INFO_TABLE_ID) {
475 dev_err(adev->dev, "invalid ip discovery mall table id\n");
480 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
481 le32_to_cpu(mhdr->size_bytes), checksum)) {
482 dev_err(adev->dev, "invalid mall data table checksum\n");
491 kfree(adev->mman.discovery_bin);
492 adev->mman.discovery_bin = NULL;
497 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev);
499 void amdgpu_discovery_fini(struct amdgpu_device *adev)
501 amdgpu_discovery_sysfs_fini(adev);
502 kfree(adev->mman.discovery_bin);
503 adev->mman.discovery_bin = NULL;
506 static int amdgpu_discovery_validate_ip(const struct ip_v4 *ip)
508 if (ip->instance_number >= HWIP_MAX_INSTANCE) {
509 DRM_ERROR("Unexpected instance_number (%d) from ip discovery blob\n",
510 ip->instance_number);
513 if (le16_to_cpu(ip->hw_id) >= HW_ID_MAX) {
514 DRM_ERROR("Unexpected hw_id (%d) from ip discovery blob\n",
515 le16_to_cpu(ip->hw_id));
522 static void amdgpu_discovery_read_harvest_bit_per_ip(struct amdgpu_device *adev,
523 uint32_t *vcn_harvest_count)
525 struct binary_header *bhdr;
526 struct ip_discovery_header *ihdr;
527 struct die_header *dhdr;
529 uint16_t die_offset, ip_offset, num_dies, num_ips;
532 bhdr = (struct binary_header *)adev->mman.discovery_bin;
533 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
534 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
535 num_dies = le16_to_cpu(ihdr->num_dies);
537 /* scan harvest bit of all IP data structures */
538 for (i = 0; i < num_dies; i++) {
539 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
540 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
541 num_ips = le16_to_cpu(dhdr->num_ips);
542 ip_offset = die_offset + sizeof(*dhdr);
544 for (j = 0; j < num_ips; j++) {
545 ip = (struct ip_v4 *)(adev->mman.discovery_bin + ip_offset);
547 if (amdgpu_discovery_validate_ip(ip))
550 if (le16_to_cpu(ip->variant) == 1) {
551 switch (le16_to_cpu(ip->hw_id)) {
553 (*vcn_harvest_count)++;
554 if (ip->instance_number == 0) {
555 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN0;
556 adev->vcn.inst_mask &=
557 ~AMDGPU_VCN_HARVEST_VCN0;
558 adev->jpeg.inst_mask &=
559 ~AMDGPU_VCN_HARVEST_VCN0;
561 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
562 adev->vcn.inst_mask &=
563 ~AMDGPU_VCN_HARVEST_VCN1;
564 adev->jpeg.inst_mask &=
565 ~AMDGPU_VCN_HARVEST_VCN1;
569 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
576 if (ihdr->base_addr_64_bit)
577 ip_offset += struct_size(ip, base_address_64, ip->num_base_address);
579 ip_offset += struct_size(ip, base_address, ip->num_base_address);
584 static void amdgpu_discovery_read_from_harvest_table(struct amdgpu_device *adev,
585 uint32_t *vcn_harvest_count,
586 uint32_t *umc_harvest_count)
588 struct binary_header *bhdr;
589 struct harvest_table *harvest_info;
592 uint32_t umc_harvest_config = 0;
594 bhdr = (struct binary_header *)adev->mman.discovery_bin;
595 offset = le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset);
598 dev_err(adev->dev, "invalid harvest table offset\n");
602 harvest_info = (struct harvest_table *)(adev->mman.discovery_bin + offset);
604 for (i = 0; i < 32; i++) {
605 if (le16_to_cpu(harvest_info->list[i].hw_id) == 0)
608 switch (le16_to_cpu(harvest_info->list[i].hw_id)) {
610 (*vcn_harvest_count)++;
611 adev->vcn.harvest_config |=
612 (1 << harvest_info->list[i].number_instance);
613 adev->jpeg.harvest_config |=
614 (1 << harvest_info->list[i].number_instance);
616 adev->vcn.inst_mask &=
617 ~(1U << harvest_info->list[i].number_instance);
618 adev->jpeg.inst_mask &=
619 ~(1U << harvest_info->list[i].number_instance);
622 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
625 umc_harvest_config |=
626 1 << (le16_to_cpu(harvest_info->list[i].number_instance));
627 (*umc_harvest_count)++;
630 adev->gfx.xcc_mask &=
631 ~(1U << harvest_info->list[i].number_instance);
634 adev->sdma.sdma_mask &=
635 ~(1U << harvest_info->list[i].number_instance);
642 adev->umc.active_mask = ((1 << adev->umc.node_inst_num) - 1) &
646 /* ================================================== */
648 struct ip_hw_instance {
649 struct kobject kobj; /* ip_discovery/die/#die/#hw_id/#instance/<attrs...> */
653 u8 major, minor, revision;
656 int num_base_addresses;
661 struct kset hw_id_kset; /* ip_discovery/die/#die/#hw_id/, contains ip_hw_instance */
665 struct ip_die_entry {
666 struct kset ip_kset; /* ip_discovery/die/#die/, contains ip_hw_id */
670 /* -------------------------------------------------- */
672 struct ip_hw_instance_attr {
673 struct attribute attr;
674 ssize_t (*show)(struct ip_hw_instance *ip_hw_instance, char *buf);
677 static ssize_t hw_id_show(struct ip_hw_instance *ip_hw_instance, char *buf)
679 return sysfs_emit(buf, "%d\n", ip_hw_instance->hw_id);
682 static ssize_t num_instance_show(struct ip_hw_instance *ip_hw_instance, char *buf)
684 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_instance);
687 static ssize_t major_show(struct ip_hw_instance *ip_hw_instance, char *buf)
689 return sysfs_emit(buf, "%d\n", ip_hw_instance->major);
692 static ssize_t minor_show(struct ip_hw_instance *ip_hw_instance, char *buf)
694 return sysfs_emit(buf, "%d\n", ip_hw_instance->minor);
697 static ssize_t revision_show(struct ip_hw_instance *ip_hw_instance, char *buf)
699 return sysfs_emit(buf, "%d\n", ip_hw_instance->revision);
702 static ssize_t harvest_show(struct ip_hw_instance *ip_hw_instance, char *buf)
704 return sysfs_emit(buf, "0x%01X\n", ip_hw_instance->harvest);
707 static ssize_t num_base_addresses_show(struct ip_hw_instance *ip_hw_instance, char *buf)
709 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_base_addresses);
712 static ssize_t base_addr_show(struct ip_hw_instance *ip_hw_instance, char *buf)
717 for (res = at = ii = 0; ii < ip_hw_instance->num_base_addresses; ii++) {
718 /* Here we satisfy the condition that, at + size <= PAGE_SIZE.
720 if (at + 12 > PAGE_SIZE)
722 res = sysfs_emit_at(buf, at, "0x%08X\n",
723 ip_hw_instance->base_addr[ii]);
729 return res < 0 ? res : at;
732 static struct ip_hw_instance_attr ip_hw_attr[] = {
734 __ATTR_RO(num_instance),
739 __ATTR_RO(num_base_addresses),
740 __ATTR_RO(base_addr),
743 static struct attribute *ip_hw_instance_attrs[ARRAY_SIZE(ip_hw_attr) + 1];
744 ATTRIBUTE_GROUPS(ip_hw_instance);
746 #define to_ip_hw_instance(x) container_of(x, struct ip_hw_instance, kobj)
747 #define to_ip_hw_instance_attr(x) container_of(x, struct ip_hw_instance_attr, attr)
749 static ssize_t ip_hw_instance_attr_show(struct kobject *kobj,
750 struct attribute *attr,
753 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
754 struct ip_hw_instance_attr *ip_hw_attr = to_ip_hw_instance_attr(attr);
756 if (!ip_hw_attr->show)
759 return ip_hw_attr->show(ip_hw_instance, buf);
762 static const struct sysfs_ops ip_hw_instance_sysfs_ops = {
763 .show = ip_hw_instance_attr_show,
766 static void ip_hw_instance_release(struct kobject *kobj)
768 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
770 kfree(ip_hw_instance);
773 static const struct kobj_type ip_hw_instance_ktype = {
774 .release = ip_hw_instance_release,
775 .sysfs_ops = &ip_hw_instance_sysfs_ops,
776 .default_groups = ip_hw_instance_groups,
779 /* -------------------------------------------------- */
781 #define to_ip_hw_id(x) container_of(to_kset(x), struct ip_hw_id, hw_id_kset)
783 static void ip_hw_id_release(struct kobject *kobj)
785 struct ip_hw_id *ip_hw_id = to_ip_hw_id(kobj);
787 if (!list_empty(&ip_hw_id->hw_id_kset.list))
788 DRM_ERROR("ip_hw_id->hw_id_kset is not empty");
792 static const struct kobj_type ip_hw_id_ktype = {
793 .release = ip_hw_id_release,
794 .sysfs_ops = &kobj_sysfs_ops,
797 /* -------------------------------------------------- */
799 static void die_kobj_release(struct kobject *kobj);
800 static void ip_disc_release(struct kobject *kobj);
802 struct ip_die_entry_attribute {
803 struct attribute attr;
804 ssize_t (*show)(struct ip_die_entry *ip_die_entry, char *buf);
807 #define to_ip_die_entry_attr(x) container_of(x, struct ip_die_entry_attribute, attr)
809 static ssize_t num_ips_show(struct ip_die_entry *ip_die_entry, char *buf)
811 return sysfs_emit(buf, "%d\n", ip_die_entry->num_ips);
814 /* If there are more ip_die_entry attrs, other than the number of IPs,
815 * we can make this intro an array of attrs, and then initialize
816 * ip_die_entry_attrs in a loop.
818 static struct ip_die_entry_attribute num_ips_attr =
821 static struct attribute *ip_die_entry_attrs[] = {
825 ATTRIBUTE_GROUPS(ip_die_entry); /* ip_die_entry_groups */
827 #define to_ip_die_entry(x) container_of(to_kset(x), struct ip_die_entry, ip_kset)
829 static ssize_t ip_die_entry_attr_show(struct kobject *kobj,
830 struct attribute *attr,
833 struct ip_die_entry_attribute *ip_die_entry_attr = to_ip_die_entry_attr(attr);
834 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
836 if (!ip_die_entry_attr->show)
839 return ip_die_entry_attr->show(ip_die_entry, buf);
842 static void ip_die_entry_release(struct kobject *kobj)
844 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
846 if (!list_empty(&ip_die_entry->ip_kset.list))
847 DRM_ERROR("ip_die_entry->ip_kset is not empty");
851 static const struct sysfs_ops ip_die_entry_sysfs_ops = {
852 .show = ip_die_entry_attr_show,
855 static const struct kobj_type ip_die_entry_ktype = {
856 .release = ip_die_entry_release,
857 .sysfs_ops = &ip_die_entry_sysfs_ops,
858 .default_groups = ip_die_entry_groups,
861 static const struct kobj_type die_kobj_ktype = {
862 .release = die_kobj_release,
863 .sysfs_ops = &kobj_sysfs_ops,
866 static const struct kobj_type ip_discovery_ktype = {
867 .release = ip_disc_release,
868 .sysfs_ops = &kobj_sysfs_ops,
871 struct ip_discovery_top {
872 struct kobject kobj; /* ip_discovery/ */
873 struct kset die_kset; /* ip_discovery/die/, contains ip_die_entry */
874 struct amdgpu_device *adev;
877 static void die_kobj_release(struct kobject *kobj)
879 struct ip_discovery_top *ip_top = container_of(to_kset(kobj),
880 struct ip_discovery_top,
882 if (!list_empty(&ip_top->die_kset.list))
883 DRM_ERROR("ip_top->die_kset is not empty");
886 static void ip_disc_release(struct kobject *kobj)
888 struct ip_discovery_top *ip_top = container_of(kobj, struct ip_discovery_top,
890 struct amdgpu_device *adev = ip_top->adev;
896 static uint8_t amdgpu_discovery_get_harvest_info(struct amdgpu_device *adev,
897 uint16_t hw_id, uint8_t inst)
901 /* Until a uniform way is figured, get mask based on hwid */
904 harvest = ((1 << inst) & adev->vcn.inst_mask) == 0;
907 if (adev->harvest_ip_mask & AMD_HARVEST_IP_DMU_MASK)
911 /* TODO: It needs another parsing; for now, ignore.*/
914 harvest = ((1 << inst) & adev->gfx.xcc_mask) == 0;
917 harvest = ((1 << inst) & adev->sdma.sdma_mask) == 0;
926 static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev,
927 struct ip_die_entry *ip_die_entry,
928 const size_t _ip_offset, const int num_ips,
933 DRM_DEBUG("num_ips:%d", num_ips);
935 /* Find all IPs of a given HW ID, and add their instance to
936 * #die/#hw_id/#instance/<attributes>
938 for (ii = 0; ii < HW_ID_MAX; ii++) {
939 struct ip_hw_id *ip_hw_id = NULL;
940 size_t ip_offset = _ip_offset;
942 for (jj = 0; jj < num_ips; jj++) {
944 struct ip_hw_instance *ip_hw_instance;
946 ip = (struct ip_v4 *)(adev->mman.discovery_bin + ip_offset);
947 if (amdgpu_discovery_validate_ip(ip) ||
948 le16_to_cpu(ip->hw_id) != ii)
951 DRM_DEBUG("match:%d @ ip_offset:%zu", ii, ip_offset);
953 /* We have a hw_id match; register the hw
954 * block if not yet registered.
957 ip_hw_id = kzalloc(sizeof(*ip_hw_id), GFP_KERNEL);
960 ip_hw_id->hw_id = ii;
962 kobject_set_name(&ip_hw_id->hw_id_kset.kobj, "%d", ii);
963 ip_hw_id->hw_id_kset.kobj.kset = &ip_die_entry->ip_kset;
964 ip_hw_id->hw_id_kset.kobj.ktype = &ip_hw_id_ktype;
965 res = kset_register(&ip_hw_id->hw_id_kset);
967 DRM_ERROR("Couldn't register ip_hw_id kset");
971 if (hw_id_names[ii]) {
972 res = sysfs_create_link(&ip_die_entry->ip_kset.kobj,
973 &ip_hw_id->hw_id_kset.kobj,
976 DRM_ERROR("Couldn't create IP link %s in IP Die:%s\n",
978 kobject_name(&ip_die_entry->ip_kset.kobj));
983 /* Now register its instance.
985 ip_hw_instance = kzalloc(struct_size(ip_hw_instance,
987 ip->num_base_address),
989 if (!ip_hw_instance) {
990 DRM_ERROR("no memory for ip_hw_instance");
993 ip_hw_instance->hw_id = le16_to_cpu(ip->hw_id); /* == ii */
994 ip_hw_instance->num_instance = ip->instance_number;
995 ip_hw_instance->major = ip->major;
996 ip_hw_instance->minor = ip->minor;
997 ip_hw_instance->revision = ip->revision;
998 ip_hw_instance->harvest =
999 amdgpu_discovery_get_harvest_info(
1000 adev, ip_hw_instance->hw_id,
1001 ip_hw_instance->num_instance);
1002 ip_hw_instance->num_base_addresses = ip->num_base_address;
1004 for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++) {
1006 ip_hw_instance->base_addr[kk] =
1007 lower_32_bits(le64_to_cpu(ip->base_address_64[kk])) & 0x3FFFFFFF;
1009 ip_hw_instance->base_addr[kk] = ip->base_address[kk];
1012 kobject_init(&ip_hw_instance->kobj, &ip_hw_instance_ktype);
1013 ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset;
1014 res = kobject_add(&ip_hw_instance->kobj, NULL,
1015 "%d", ip_hw_instance->num_instance);
1018 ip_offset += struct_size(ip, base_address_64,
1019 ip->num_base_address);
1021 ip_offset += struct_size(ip, base_address,
1022 ip->num_base_address);
1029 static int amdgpu_discovery_sysfs_recurse(struct amdgpu_device *adev)
1031 struct binary_header *bhdr;
1032 struct ip_discovery_header *ihdr;
1033 struct die_header *dhdr;
1034 struct kset *die_kset = &adev->ip_top->die_kset;
1035 u16 num_dies, die_offset, num_ips;
1039 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1040 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1041 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1042 num_dies = le16_to_cpu(ihdr->num_dies);
1044 DRM_DEBUG("number of dies: %d\n", num_dies);
1046 for (ii = 0; ii < num_dies; ii++) {
1047 struct ip_die_entry *ip_die_entry;
1049 die_offset = le16_to_cpu(ihdr->die_info[ii].die_offset);
1050 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1051 num_ips = le16_to_cpu(dhdr->num_ips);
1052 ip_offset = die_offset + sizeof(*dhdr);
1054 /* Add the die to the kset.
1056 * dhdr->die_id == ii, which was checked in
1057 * amdgpu_discovery_reg_base_init().
1060 ip_die_entry = kzalloc(sizeof(*ip_die_entry), GFP_KERNEL);
1064 ip_die_entry->num_ips = num_ips;
1066 kobject_set_name(&ip_die_entry->ip_kset.kobj, "%d", le16_to_cpu(dhdr->die_id));
1067 ip_die_entry->ip_kset.kobj.kset = die_kset;
1068 ip_die_entry->ip_kset.kobj.ktype = &ip_die_entry_ktype;
1069 res = kset_register(&ip_die_entry->ip_kset);
1071 DRM_ERROR("Couldn't register ip_die_entry kset");
1072 kfree(ip_die_entry);
1076 amdgpu_discovery_sysfs_ips(adev, ip_die_entry, ip_offset, num_ips, !!ihdr->base_addr_64_bit);
1082 static int amdgpu_discovery_sysfs_init(struct amdgpu_device *adev)
1084 struct kset *die_kset;
1087 if (!adev->mman.discovery_bin)
1090 adev->ip_top = kzalloc(sizeof(*adev->ip_top), GFP_KERNEL);
1094 adev->ip_top->adev = adev;
1096 res = kobject_init_and_add(&adev->ip_top->kobj, &ip_discovery_ktype,
1097 &adev->dev->kobj, "ip_discovery");
1099 DRM_ERROR("Couldn't init and add ip_discovery/");
1103 die_kset = &adev->ip_top->die_kset;
1104 kobject_set_name(&die_kset->kobj, "%s", "die");
1105 die_kset->kobj.parent = &adev->ip_top->kobj;
1106 die_kset->kobj.ktype = &die_kobj_ktype;
1107 res = kset_register(&adev->ip_top->die_kset);
1109 DRM_ERROR("Couldn't register die_kset");
1113 for (ii = 0; ii < ARRAY_SIZE(ip_hw_attr); ii++)
1114 ip_hw_instance_attrs[ii] = &ip_hw_attr[ii].attr;
1115 ip_hw_instance_attrs[ii] = NULL;
1117 res = amdgpu_discovery_sysfs_recurse(adev);
1121 kobject_put(&adev->ip_top->kobj);
1125 /* -------------------------------------------------- */
1127 #define list_to_kobj(el) container_of(el, struct kobject, entry)
1129 static void amdgpu_discovery_sysfs_ip_hw_free(struct ip_hw_id *ip_hw_id)
1131 struct list_head *el, *tmp;
1132 struct kset *hw_id_kset;
1134 hw_id_kset = &ip_hw_id->hw_id_kset;
1135 spin_lock(&hw_id_kset->list_lock);
1136 list_for_each_prev_safe(el, tmp, &hw_id_kset->list) {
1138 spin_unlock(&hw_id_kset->list_lock);
1139 /* kobject is embedded in ip_hw_instance */
1140 kobject_put(list_to_kobj(el));
1141 spin_lock(&hw_id_kset->list_lock);
1143 spin_unlock(&hw_id_kset->list_lock);
1144 kobject_put(&ip_hw_id->hw_id_kset.kobj);
1147 static void amdgpu_discovery_sysfs_die_free(struct ip_die_entry *ip_die_entry)
1149 struct list_head *el, *tmp;
1150 struct kset *ip_kset;
1152 ip_kset = &ip_die_entry->ip_kset;
1153 spin_lock(&ip_kset->list_lock);
1154 list_for_each_prev_safe(el, tmp, &ip_kset->list) {
1156 spin_unlock(&ip_kset->list_lock);
1157 amdgpu_discovery_sysfs_ip_hw_free(to_ip_hw_id(list_to_kobj(el)));
1158 spin_lock(&ip_kset->list_lock);
1160 spin_unlock(&ip_kset->list_lock);
1161 kobject_put(&ip_die_entry->ip_kset.kobj);
1164 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev)
1166 struct list_head *el, *tmp;
1167 struct kset *die_kset;
1169 die_kset = &adev->ip_top->die_kset;
1170 spin_lock(&die_kset->list_lock);
1171 list_for_each_prev_safe(el, tmp, &die_kset->list) {
1173 spin_unlock(&die_kset->list_lock);
1174 amdgpu_discovery_sysfs_die_free(to_ip_die_entry(list_to_kobj(el)));
1175 spin_lock(&die_kset->list_lock);
1177 spin_unlock(&die_kset->list_lock);
1178 kobject_put(&adev->ip_top->die_kset.kobj);
1179 kobject_put(&adev->ip_top->kobj);
1182 /* ================================================== */
1184 static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
1186 struct binary_header *bhdr;
1187 struct ip_discovery_header *ihdr;
1188 struct die_header *dhdr;
1190 uint16_t die_offset;
1194 uint8_t num_base_address;
1199 r = amdgpu_discovery_init(adev);
1201 DRM_ERROR("amdgpu_discovery_init failed\n");
1205 adev->gfx.xcc_mask = 0;
1206 adev->sdma.sdma_mask = 0;
1207 adev->vcn.inst_mask = 0;
1208 adev->jpeg.inst_mask = 0;
1209 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1210 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1211 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1212 num_dies = le16_to_cpu(ihdr->num_dies);
1214 DRM_DEBUG("number of dies: %d\n", num_dies);
1216 for (i = 0; i < num_dies; i++) {
1217 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
1218 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1219 num_ips = le16_to_cpu(dhdr->num_ips);
1220 ip_offset = die_offset + sizeof(*dhdr);
1222 if (le16_to_cpu(dhdr->die_id) != i) {
1223 DRM_ERROR("invalid die id %d, expected %d\n",
1224 le16_to_cpu(dhdr->die_id), i);
1228 DRM_DEBUG("number of hardware IPs on die%d: %d\n",
1229 le16_to_cpu(dhdr->die_id), num_ips);
1231 for (j = 0; j < num_ips; j++) {
1232 ip = (struct ip_v4 *)(adev->mman.discovery_bin + ip_offset);
1234 if (amdgpu_discovery_validate_ip(ip))
1237 num_base_address = ip->num_base_address;
1239 DRM_DEBUG("%s(%d) #%d v%d.%d.%d:\n",
1240 hw_id_names[le16_to_cpu(ip->hw_id)],
1241 le16_to_cpu(ip->hw_id),
1242 ip->instance_number,
1243 ip->major, ip->minor,
1246 if (le16_to_cpu(ip->hw_id) == VCN_HWID) {
1247 /* Bit [5:0]: original revision value
1248 * Bit [7:6]: en/decode capability:
1249 * 0b00 : VCN function normally
1250 * 0b10 : encode is disabled
1251 * 0b01 : decode is disabled
1253 adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
1254 ip->revision & 0xc0;
1255 ip->revision &= ~0xc0;
1256 if (adev->vcn.num_vcn_inst <
1257 AMDGPU_MAX_VCN_INSTANCES) {
1258 adev->vcn.num_vcn_inst++;
1259 adev->vcn.inst_mask |=
1260 (1U << ip->instance_number);
1261 adev->jpeg.inst_mask |=
1262 (1U << ip->instance_number);
1264 dev_err(adev->dev, "Too many VCN instances: %d vs %d\n",
1265 adev->vcn.num_vcn_inst + 1,
1266 AMDGPU_MAX_VCN_INSTANCES);
1269 if (le16_to_cpu(ip->hw_id) == SDMA0_HWID ||
1270 le16_to_cpu(ip->hw_id) == SDMA1_HWID ||
1271 le16_to_cpu(ip->hw_id) == SDMA2_HWID ||
1272 le16_to_cpu(ip->hw_id) == SDMA3_HWID) {
1273 if (adev->sdma.num_instances <
1274 AMDGPU_MAX_SDMA_INSTANCES) {
1275 adev->sdma.num_instances++;
1276 adev->sdma.sdma_mask |=
1277 (1U << ip->instance_number);
1279 dev_err(adev->dev, "Too many SDMA instances: %d vs %d\n",
1280 adev->sdma.num_instances + 1,
1281 AMDGPU_MAX_SDMA_INSTANCES);
1285 if (le16_to_cpu(ip->hw_id) == UMC_HWID) {
1286 adev->gmc.num_umc++;
1287 adev->umc.node_inst_num++;
1290 if (le16_to_cpu(ip->hw_id) == GC_HWID)
1291 adev->gfx.xcc_mask |=
1292 (1U << ip->instance_number);
1294 for (k = 0; k < num_base_address; k++) {
1296 * convert the endianness of base addresses in place,
1297 * so that we don't need to convert them when accessing adev->reg_offset.
1299 if (ihdr->base_addr_64_bit)
1300 /* Truncate the 64bit base address from ip discovery
1301 * and only store lower 32bit ip base in reg_offset[].
1302 * Bits > 32 follows ASIC specific format, thus just
1303 * discard them and handle it within specific ASIC.
1304 * By this way reg_offset[] and related helpers can
1306 * The base address is in dwords, thus clear the
1307 * highest 2 bits to store.
1309 ip->base_address[k] =
1310 lower_32_bits(le64_to_cpu(ip->base_address_64[k])) & 0x3FFFFFFF;
1312 ip->base_address[k] = le32_to_cpu(ip->base_address[k]);
1313 DRM_DEBUG("\t0x%08x\n", ip->base_address[k]);
1316 for (hw_ip = 0; hw_ip < MAX_HWIP; hw_ip++) {
1317 if (hw_id_map[hw_ip] == le16_to_cpu(ip->hw_id) &&
1318 hw_id_map[hw_ip] != 0) {
1319 DRM_DEBUG("set register base offset for %s\n",
1320 hw_id_names[le16_to_cpu(ip->hw_id)]);
1321 adev->reg_offset[hw_ip][ip->instance_number] =
1323 /* Instance support is somewhat inconsistent.
1324 * SDMA is a good example. Sienna cichlid has 4 total
1325 * SDMA instances, each enumerated separately (HWIDs
1326 * 42, 43, 68, 69). Arcturus has 8 total SDMA instances,
1327 * but they are enumerated as multiple instances of the
1328 * same HWIDs (4x HWID 42, 4x HWID 43). UMC is another
1329 * example. On most chips there are multiple instances
1330 * with the same HWID.
1332 adev->ip_versions[hw_ip][ip->instance_number] =
1333 IP_VERSION(ip->major, ip->minor, ip->revision);
1338 if (ihdr->base_addr_64_bit)
1339 ip_offset += struct_size(ip, base_address_64, ip->num_base_address);
1341 ip_offset += struct_size(ip, base_address, ip->num_base_address);
1348 static void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
1350 int vcn_harvest_count = 0;
1351 int umc_harvest_count = 0;
1354 * Harvest table does not fit Navi1x and legacy GPUs,
1355 * so read harvest bit per IP data structure to set
1356 * harvest configuration.
1358 if (adev->ip_versions[GC_HWIP][0] < IP_VERSION(10, 2, 0) &&
1359 adev->ip_versions[GC_HWIP][0] != IP_VERSION(9, 4, 3)) {
1360 if ((adev->pdev->device == 0x731E &&
1361 (adev->pdev->revision == 0xC6 ||
1362 adev->pdev->revision == 0xC7)) ||
1363 (adev->pdev->device == 0x7340 &&
1364 adev->pdev->revision == 0xC9) ||
1365 (adev->pdev->device == 0x7360 &&
1366 adev->pdev->revision == 0xC7))
1367 amdgpu_discovery_read_harvest_bit_per_ip(adev,
1368 &vcn_harvest_count);
1370 amdgpu_discovery_read_from_harvest_table(adev,
1372 &umc_harvest_count);
1375 amdgpu_discovery_harvest_config_quirk(adev);
1377 if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
1378 adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
1379 adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
1382 if (umc_harvest_count < adev->gmc.num_umc) {
1383 adev->gmc.num_umc -= umc_harvest_count;
1388 struct gc_info_v1_0 v1;
1389 struct gc_info_v1_1 v1_1;
1390 struct gc_info_v1_2 v1_2;
1391 struct gc_info_v2_0 v2;
1394 static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
1396 struct binary_header *bhdr;
1397 union gc_info *gc_info;
1400 if (!adev->mman.discovery_bin) {
1401 DRM_ERROR("ip discovery uninitialized\n");
1405 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1406 offset = le16_to_cpu(bhdr->table_list[GC].offset);
1411 gc_info = (union gc_info *)(adev->mman.discovery_bin + offset);
1413 switch (le16_to_cpu(gc_info->v1.header.version_major)) {
1415 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v1.gc_num_se);
1416 adev->gfx.config.max_cu_per_sh = 2 * (le32_to_cpu(gc_info->v1.gc_num_wgp0_per_sa) +
1417 le32_to_cpu(gc_info->v1.gc_num_wgp1_per_sa));
1418 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1419 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v1.gc_num_rb_per_se);
1420 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v1.gc_num_gl2c);
1421 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v1.gc_num_gprs);
1422 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v1.gc_num_max_gs_thds);
1423 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v1.gc_gs_table_depth);
1424 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v1.gc_gsprim_buff_depth);
1425 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v1.gc_double_offchip_lds_buffer);
1426 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v1.gc_wave_size);
1427 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v1.gc_max_waves_per_simd);
1428 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v1.gc_max_scratch_slots_per_cu);
1429 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v1.gc_lds_size);
1430 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v1.gc_num_sc_per_se) /
1431 le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1432 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v1.gc_num_packer_per_sc);
1433 if (gc_info->v1.header.version_minor >= 1) {
1434 adev->gfx.config.gc_num_tcp_per_sa = le32_to_cpu(gc_info->v1_1.gc_num_tcp_per_sa);
1435 adev->gfx.config.gc_num_sdp_interface = le32_to_cpu(gc_info->v1_1.gc_num_sdp_interface);
1436 adev->gfx.config.gc_num_tcps = le32_to_cpu(gc_info->v1_1.gc_num_tcps);
1438 if (gc_info->v1.header.version_minor >= 2) {
1439 adev->gfx.config.gc_num_tcp_per_wpg = le32_to_cpu(gc_info->v1_2.gc_num_tcp_per_wpg);
1440 adev->gfx.config.gc_tcp_l1_size = le32_to_cpu(gc_info->v1_2.gc_tcp_l1_size);
1441 adev->gfx.config.gc_num_sqc_per_wgp = le32_to_cpu(gc_info->v1_2.gc_num_sqc_per_wgp);
1442 adev->gfx.config.gc_l1_instruction_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_instruction_cache_size_per_sqc);
1443 adev->gfx.config.gc_l1_data_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_data_cache_size_per_sqc);
1444 adev->gfx.config.gc_gl1c_per_sa = le32_to_cpu(gc_info->v1_2.gc_gl1c_per_sa);
1445 adev->gfx.config.gc_gl1c_size_per_instance = le32_to_cpu(gc_info->v1_2.gc_gl1c_size_per_instance);
1446 adev->gfx.config.gc_gl2c_per_gpu = le32_to_cpu(gc_info->v1_2.gc_gl2c_per_gpu);
1450 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v2.gc_num_se);
1451 adev->gfx.config.max_cu_per_sh = le32_to_cpu(gc_info->v2.gc_num_cu_per_sh);
1452 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1453 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v2.gc_num_rb_per_se);
1454 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v2.gc_num_tccs);
1455 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v2.gc_num_gprs);
1456 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v2.gc_num_max_gs_thds);
1457 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v2.gc_gs_table_depth);
1458 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v2.gc_gsprim_buff_depth);
1459 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v2.gc_double_offchip_lds_buffer);
1460 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v2.gc_wave_size);
1461 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v2.gc_max_waves_per_simd);
1462 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v2.gc_max_scratch_slots_per_cu);
1463 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v2.gc_lds_size);
1464 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v2.gc_num_sc_per_se) /
1465 le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1466 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v2.gc_num_packer_per_sc);
1470 "Unhandled GC info table %d.%d\n",
1471 le16_to_cpu(gc_info->v1.header.version_major),
1472 le16_to_cpu(gc_info->v1.header.version_minor));
1479 struct mall_info_v1_0 v1;
1482 static int amdgpu_discovery_get_mall_info(struct amdgpu_device *adev)
1484 struct binary_header *bhdr;
1485 union mall_info *mall_info;
1486 u32 u, mall_size_per_umc, m_s_present, half_use;
1490 if (!adev->mman.discovery_bin) {
1491 DRM_ERROR("ip discovery uninitialized\n");
1495 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1496 offset = le16_to_cpu(bhdr->table_list[MALL_INFO].offset);
1501 mall_info = (union mall_info *)(adev->mman.discovery_bin + offset);
1503 switch (le16_to_cpu(mall_info->v1.header.version_major)) {
1506 mall_size_per_umc = le32_to_cpu(mall_info->v1.mall_size_per_m);
1507 m_s_present = le32_to_cpu(mall_info->v1.m_s_present);
1508 half_use = le32_to_cpu(mall_info->v1.m_half_use);
1509 for (u = 0; u < adev->gmc.num_umc; u++) {
1510 if (m_s_present & (1 << u))
1511 mall_size += mall_size_per_umc * 2;
1512 else if (half_use & (1 << u))
1513 mall_size += mall_size_per_umc / 2;
1515 mall_size += mall_size_per_umc;
1517 adev->gmc.mall_size = mall_size;
1518 adev->gmc.m_half_use = half_use;
1522 "Unhandled MALL info table %d.%d\n",
1523 le16_to_cpu(mall_info->v1.header.version_major),
1524 le16_to_cpu(mall_info->v1.header.version_minor));
1531 struct vcn_info_v1_0 v1;
1534 static int amdgpu_discovery_get_vcn_info(struct amdgpu_device *adev)
1536 struct binary_header *bhdr;
1537 union vcn_info *vcn_info;
1541 if (!adev->mman.discovery_bin) {
1542 DRM_ERROR("ip discovery uninitialized\n");
1546 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1547 * which is smaller than VCN_INFO_TABLE_MAX_NUM_INSTANCES
1548 * but that may change in the future with new GPUs so keep this
1549 * check for defensive purposes.
1551 if (adev->vcn.num_vcn_inst > VCN_INFO_TABLE_MAX_NUM_INSTANCES) {
1552 dev_err(adev->dev, "invalid vcn instances\n");
1556 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1557 offset = le16_to_cpu(bhdr->table_list[VCN_INFO].offset);
1562 vcn_info = (union vcn_info *)(adev->mman.discovery_bin + offset);
1564 switch (le16_to_cpu(vcn_info->v1.header.version_major)) {
1566 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1567 * so this won't overflow.
1569 for (v = 0; v < adev->vcn.num_vcn_inst; v++) {
1570 adev->vcn.vcn_codec_disable_mask[v] =
1571 le32_to_cpu(vcn_info->v1.instance_info[v].fuse_data.all_bits);
1576 "Unhandled VCN info table %d.%d\n",
1577 le16_to_cpu(vcn_info->v1.header.version_major),
1578 le16_to_cpu(vcn_info->v1.header.version_minor));
1584 static int amdgpu_discovery_set_common_ip_blocks(struct amdgpu_device *adev)
1586 /* what IP to use for this? */
1587 switch (adev->ip_versions[GC_HWIP][0]) {
1588 case IP_VERSION(9, 0, 1):
1589 case IP_VERSION(9, 1, 0):
1590 case IP_VERSION(9, 2, 1):
1591 case IP_VERSION(9, 2, 2):
1592 case IP_VERSION(9, 3, 0):
1593 case IP_VERSION(9, 4, 0):
1594 case IP_VERSION(9, 4, 1):
1595 case IP_VERSION(9, 4, 2):
1596 case IP_VERSION(9, 4, 3):
1597 amdgpu_device_ip_block_add(adev, &vega10_common_ip_block);
1599 case IP_VERSION(10, 1, 10):
1600 case IP_VERSION(10, 1, 1):
1601 case IP_VERSION(10, 1, 2):
1602 case IP_VERSION(10, 1, 3):
1603 case IP_VERSION(10, 1, 4):
1604 case IP_VERSION(10, 3, 0):
1605 case IP_VERSION(10, 3, 1):
1606 case IP_VERSION(10, 3, 2):
1607 case IP_VERSION(10, 3, 3):
1608 case IP_VERSION(10, 3, 4):
1609 case IP_VERSION(10, 3, 5):
1610 case IP_VERSION(10, 3, 6):
1611 case IP_VERSION(10, 3, 7):
1612 amdgpu_device_ip_block_add(adev, &nv_common_ip_block);
1614 case IP_VERSION(11, 0, 0):
1615 case IP_VERSION(11, 0, 1):
1616 case IP_VERSION(11, 0, 2):
1617 case IP_VERSION(11, 0, 3):
1618 case IP_VERSION(11, 0, 4):
1619 amdgpu_device_ip_block_add(adev, &soc21_common_ip_block);
1623 "Failed to add common ip block(GC_HWIP:0x%x)\n",
1624 adev->ip_versions[GC_HWIP][0]);
1630 static int amdgpu_discovery_set_gmc_ip_blocks(struct amdgpu_device *adev)
1632 /* use GC or MMHUB IP version */
1633 switch (adev->ip_versions[GC_HWIP][0]) {
1634 case IP_VERSION(9, 0, 1):
1635 case IP_VERSION(9, 1, 0):
1636 case IP_VERSION(9, 2, 1):
1637 case IP_VERSION(9, 2, 2):
1638 case IP_VERSION(9, 3, 0):
1639 case IP_VERSION(9, 4, 0):
1640 case IP_VERSION(9, 4, 1):
1641 case IP_VERSION(9, 4, 2):
1642 case IP_VERSION(9, 4, 3):
1643 amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block);
1645 case IP_VERSION(10, 1, 10):
1646 case IP_VERSION(10, 1, 1):
1647 case IP_VERSION(10, 1, 2):
1648 case IP_VERSION(10, 1, 3):
1649 case IP_VERSION(10, 1, 4):
1650 case IP_VERSION(10, 3, 0):
1651 case IP_VERSION(10, 3, 1):
1652 case IP_VERSION(10, 3, 2):
1653 case IP_VERSION(10, 3, 3):
1654 case IP_VERSION(10, 3, 4):
1655 case IP_VERSION(10, 3, 5):
1656 case IP_VERSION(10, 3, 6):
1657 case IP_VERSION(10, 3, 7):
1658 amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block);
1660 case IP_VERSION(11, 0, 0):
1661 case IP_VERSION(11, 0, 1):
1662 case IP_VERSION(11, 0, 2):
1663 case IP_VERSION(11, 0, 3):
1664 case IP_VERSION(11, 0, 4):
1665 amdgpu_device_ip_block_add(adev, &gmc_v11_0_ip_block);
1669 "Failed to add gmc ip block(GC_HWIP:0x%x)\n",
1670 adev->ip_versions[GC_HWIP][0]);
1676 static int amdgpu_discovery_set_ih_ip_blocks(struct amdgpu_device *adev)
1678 switch (adev->ip_versions[OSSSYS_HWIP][0]) {
1679 case IP_VERSION(4, 0, 0):
1680 case IP_VERSION(4, 0, 1):
1681 case IP_VERSION(4, 1, 0):
1682 case IP_VERSION(4, 1, 1):
1683 case IP_VERSION(4, 3, 0):
1684 amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block);
1686 case IP_VERSION(4, 2, 0):
1687 case IP_VERSION(4, 2, 1):
1688 case IP_VERSION(4, 4, 0):
1689 case IP_VERSION(4, 4, 2):
1690 amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block);
1692 case IP_VERSION(5, 0, 0):
1693 case IP_VERSION(5, 0, 1):
1694 case IP_VERSION(5, 0, 2):
1695 case IP_VERSION(5, 0, 3):
1696 case IP_VERSION(5, 2, 0):
1697 case IP_VERSION(5, 2, 1):
1698 amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);
1700 case IP_VERSION(6, 0, 0):
1701 case IP_VERSION(6, 0, 1):
1702 case IP_VERSION(6, 0, 2):
1703 amdgpu_device_ip_block_add(adev, &ih_v6_0_ip_block);
1707 "Failed to add ih ip block(OSSSYS_HWIP:0x%x)\n",
1708 adev->ip_versions[OSSSYS_HWIP][0]);
1714 static int amdgpu_discovery_set_psp_ip_blocks(struct amdgpu_device *adev)
1716 switch (adev->ip_versions[MP0_HWIP][0]) {
1717 case IP_VERSION(9, 0, 0):
1718 amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block);
1720 case IP_VERSION(10, 0, 0):
1721 case IP_VERSION(10, 0, 1):
1722 amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block);
1724 case IP_VERSION(11, 0, 0):
1725 case IP_VERSION(11, 0, 2):
1726 case IP_VERSION(11, 0, 4):
1727 case IP_VERSION(11, 0, 5):
1728 case IP_VERSION(11, 0, 9):
1729 case IP_VERSION(11, 0, 7):
1730 case IP_VERSION(11, 0, 11):
1731 case IP_VERSION(11, 0, 12):
1732 case IP_VERSION(11, 0, 13):
1733 case IP_VERSION(11, 5, 0):
1734 amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);
1736 case IP_VERSION(11, 0, 8):
1737 amdgpu_device_ip_block_add(adev, &psp_v11_0_8_ip_block);
1739 case IP_VERSION(11, 0, 3):
1740 case IP_VERSION(12, 0, 1):
1741 amdgpu_device_ip_block_add(adev, &psp_v12_0_ip_block);
1743 case IP_VERSION(13, 0, 0):
1744 case IP_VERSION(13, 0, 1):
1745 case IP_VERSION(13, 0, 2):
1746 case IP_VERSION(13, 0, 3):
1747 case IP_VERSION(13, 0, 5):
1748 case IP_VERSION(13, 0, 6):
1749 case IP_VERSION(13, 0, 7):
1750 case IP_VERSION(13, 0, 8):
1751 case IP_VERSION(13, 0, 10):
1752 case IP_VERSION(13, 0, 11):
1753 amdgpu_device_ip_block_add(adev, &psp_v13_0_ip_block);
1755 case IP_VERSION(13, 0, 4):
1756 amdgpu_device_ip_block_add(adev, &psp_v13_0_4_ip_block);
1760 "Failed to add psp ip block(MP0_HWIP:0x%x)\n",
1761 adev->ip_versions[MP0_HWIP][0]);
1767 static int amdgpu_discovery_set_smu_ip_blocks(struct amdgpu_device *adev)
1769 switch (adev->ip_versions[MP1_HWIP][0]) {
1770 case IP_VERSION(9, 0, 0):
1771 case IP_VERSION(10, 0, 0):
1772 case IP_VERSION(10, 0, 1):
1773 case IP_VERSION(11, 0, 2):
1774 if (adev->asic_type == CHIP_ARCTURUS)
1775 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1777 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block);
1779 case IP_VERSION(11, 0, 0):
1780 case IP_VERSION(11, 0, 5):
1781 case IP_VERSION(11, 0, 9):
1782 case IP_VERSION(11, 0, 7):
1783 case IP_VERSION(11, 0, 8):
1784 case IP_VERSION(11, 0, 11):
1785 case IP_VERSION(11, 0, 12):
1786 case IP_VERSION(11, 0, 13):
1787 case IP_VERSION(11, 5, 0):
1788 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1790 case IP_VERSION(12, 0, 0):
1791 case IP_VERSION(12, 0, 1):
1792 amdgpu_device_ip_block_add(adev, &smu_v12_0_ip_block);
1794 case IP_VERSION(13, 0, 0):
1795 case IP_VERSION(13, 0, 1):
1796 case IP_VERSION(13, 0, 2):
1797 case IP_VERSION(13, 0, 3):
1798 case IP_VERSION(13, 0, 4):
1799 case IP_VERSION(13, 0, 5):
1800 case IP_VERSION(13, 0, 6):
1801 case IP_VERSION(13, 0, 7):
1802 case IP_VERSION(13, 0, 8):
1803 case IP_VERSION(13, 0, 10):
1804 case IP_VERSION(13, 0, 11):
1805 amdgpu_device_ip_block_add(adev, &smu_v13_0_ip_block);
1809 "Failed to add smu ip block(MP1_HWIP:0x%x)\n",
1810 adev->ip_versions[MP1_HWIP][0]);
1816 #if defined(CONFIG_DRM_AMD_DC)
1817 static void amdgpu_discovery_set_sriov_display(struct amdgpu_device *adev)
1819 amdgpu_device_set_sriov_virtual_display(adev);
1820 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1824 static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)
1826 if (adev->enable_virtual_display) {
1827 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1831 if (!amdgpu_device_has_dc_support(adev))
1834 #if defined(CONFIG_DRM_AMD_DC)
1835 if (adev->ip_versions[DCE_HWIP][0]) {
1836 switch (adev->ip_versions[DCE_HWIP][0]) {
1837 case IP_VERSION(1, 0, 0):
1838 case IP_VERSION(1, 0, 1):
1839 case IP_VERSION(2, 0, 2):
1840 case IP_VERSION(2, 0, 0):
1841 case IP_VERSION(2, 0, 3):
1842 case IP_VERSION(2, 1, 0):
1843 case IP_VERSION(3, 0, 0):
1844 case IP_VERSION(3, 0, 2):
1845 case IP_VERSION(3, 0, 3):
1846 case IP_VERSION(3, 0, 1):
1847 case IP_VERSION(3, 1, 2):
1848 case IP_VERSION(3, 1, 3):
1849 case IP_VERSION(3, 1, 4):
1850 case IP_VERSION(3, 1, 5):
1851 case IP_VERSION(3, 1, 6):
1852 case IP_VERSION(3, 2, 0):
1853 case IP_VERSION(3, 2, 1):
1854 if (amdgpu_sriov_vf(adev))
1855 amdgpu_discovery_set_sriov_display(adev);
1857 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1861 "Failed to add dm ip block(DCE_HWIP:0x%x)\n",
1862 adev->ip_versions[DCE_HWIP][0]);
1865 } else if (adev->ip_versions[DCI_HWIP][0]) {
1866 switch (adev->ip_versions[DCI_HWIP][0]) {
1867 case IP_VERSION(12, 0, 0):
1868 case IP_VERSION(12, 0, 1):
1869 case IP_VERSION(12, 1, 0):
1870 if (amdgpu_sriov_vf(adev))
1871 amdgpu_discovery_set_sriov_display(adev);
1873 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1877 "Failed to add dm ip block(DCI_HWIP:0x%x)\n",
1878 adev->ip_versions[DCI_HWIP][0]);
1886 static int amdgpu_discovery_set_gc_ip_blocks(struct amdgpu_device *adev)
1888 switch (adev->ip_versions[GC_HWIP][0]) {
1889 case IP_VERSION(9, 0, 1):
1890 case IP_VERSION(9, 1, 0):
1891 case IP_VERSION(9, 2, 1):
1892 case IP_VERSION(9, 2, 2):
1893 case IP_VERSION(9, 3, 0):
1894 case IP_VERSION(9, 4, 0):
1895 case IP_VERSION(9, 4, 1):
1896 case IP_VERSION(9, 4, 2):
1897 amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
1899 case IP_VERSION(9, 4, 3):
1900 if (!amdgpu_exp_hw_support)
1902 amdgpu_device_ip_block_add(adev, &gfx_v9_4_3_ip_block);
1904 case IP_VERSION(10, 1, 10):
1905 case IP_VERSION(10, 1, 2):
1906 case IP_VERSION(10, 1, 1):
1907 case IP_VERSION(10, 1, 3):
1908 case IP_VERSION(10, 1, 4):
1909 case IP_VERSION(10, 3, 0):
1910 case IP_VERSION(10, 3, 2):
1911 case IP_VERSION(10, 3, 1):
1912 case IP_VERSION(10, 3, 4):
1913 case IP_VERSION(10, 3, 5):
1914 case IP_VERSION(10, 3, 6):
1915 case IP_VERSION(10, 3, 3):
1916 case IP_VERSION(10, 3, 7):
1917 amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block);
1919 case IP_VERSION(11, 0, 0):
1920 case IP_VERSION(11, 0, 1):
1921 case IP_VERSION(11, 0, 2):
1922 case IP_VERSION(11, 0, 3):
1923 case IP_VERSION(11, 0, 4):
1924 amdgpu_device_ip_block_add(adev, &gfx_v11_0_ip_block);
1928 "Failed to add gfx ip block(GC_HWIP:0x%x)\n",
1929 adev->ip_versions[GC_HWIP][0]);
1935 static int amdgpu_discovery_set_sdma_ip_blocks(struct amdgpu_device *adev)
1937 switch (adev->ip_versions[SDMA0_HWIP][0]) {
1938 case IP_VERSION(4, 0, 0):
1939 case IP_VERSION(4, 0, 1):
1940 case IP_VERSION(4, 1, 0):
1941 case IP_VERSION(4, 1, 1):
1942 case IP_VERSION(4, 1, 2):
1943 case IP_VERSION(4, 2, 0):
1944 case IP_VERSION(4, 2, 2):
1945 case IP_VERSION(4, 4, 0):
1946 amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
1948 case IP_VERSION(4, 4, 2):
1949 amdgpu_device_ip_block_add(adev, &sdma_v4_4_2_ip_block);
1951 case IP_VERSION(5, 0, 0):
1952 case IP_VERSION(5, 0, 1):
1953 case IP_VERSION(5, 0, 2):
1954 case IP_VERSION(5, 0, 5):
1955 amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block);
1957 case IP_VERSION(5, 2, 0):
1958 case IP_VERSION(5, 2, 2):
1959 case IP_VERSION(5, 2, 4):
1960 case IP_VERSION(5, 2, 5):
1961 case IP_VERSION(5, 2, 6):
1962 case IP_VERSION(5, 2, 3):
1963 case IP_VERSION(5, 2, 1):
1964 case IP_VERSION(5, 2, 7):
1965 amdgpu_device_ip_block_add(adev, &sdma_v5_2_ip_block);
1967 case IP_VERSION(6, 0, 0):
1968 case IP_VERSION(6, 0, 1):
1969 case IP_VERSION(6, 0, 2):
1970 case IP_VERSION(6, 0, 3):
1971 amdgpu_device_ip_block_add(adev, &sdma_v6_0_ip_block);
1975 "Failed to add sdma ip block(SDMA0_HWIP:0x%x)\n",
1976 adev->ip_versions[SDMA0_HWIP][0]);
1982 static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
1984 if (adev->ip_versions[VCE_HWIP][0]) {
1985 switch (adev->ip_versions[UVD_HWIP][0]) {
1986 case IP_VERSION(7, 0, 0):
1987 case IP_VERSION(7, 2, 0):
1988 /* UVD is not supported on vega20 SR-IOV */
1989 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
1990 amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block);
1994 "Failed to add uvd v7 ip block(UVD_HWIP:0x%x)\n",
1995 adev->ip_versions[UVD_HWIP][0]);
1998 switch (adev->ip_versions[VCE_HWIP][0]) {
1999 case IP_VERSION(4, 0, 0):
2000 case IP_VERSION(4, 1, 0):
2001 /* VCE is not supported on vega20 SR-IOV */
2002 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
2003 amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block);
2007 "Failed to add VCE v4 ip block(VCE_HWIP:0x%x)\n",
2008 adev->ip_versions[VCE_HWIP][0]);
2012 switch (adev->ip_versions[UVD_HWIP][0]) {
2013 case IP_VERSION(1, 0, 0):
2014 case IP_VERSION(1, 0, 1):
2015 amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block);
2017 case IP_VERSION(2, 0, 0):
2018 case IP_VERSION(2, 0, 2):
2019 case IP_VERSION(2, 2, 0):
2020 amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
2021 if (!amdgpu_sriov_vf(adev))
2022 amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
2024 case IP_VERSION(2, 0, 3):
2026 case IP_VERSION(2, 5, 0):
2027 amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
2028 amdgpu_device_ip_block_add(adev, &jpeg_v2_5_ip_block);
2030 case IP_VERSION(2, 6, 0):
2031 amdgpu_device_ip_block_add(adev, &vcn_v2_6_ip_block);
2032 amdgpu_device_ip_block_add(adev, &jpeg_v2_6_ip_block);
2034 case IP_VERSION(3, 0, 0):
2035 case IP_VERSION(3, 0, 16):
2036 case IP_VERSION(3, 1, 1):
2037 case IP_VERSION(3, 1, 2):
2038 case IP_VERSION(3, 0, 2):
2039 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
2040 if (!amdgpu_sriov_vf(adev))
2041 amdgpu_device_ip_block_add(adev, &jpeg_v3_0_ip_block);
2043 case IP_VERSION(3, 0, 33):
2044 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
2046 case IP_VERSION(4, 0, 0):
2047 case IP_VERSION(4, 0, 2):
2048 case IP_VERSION(4, 0, 4):
2049 amdgpu_device_ip_block_add(adev, &vcn_v4_0_ip_block);
2050 amdgpu_device_ip_block_add(adev, &jpeg_v4_0_ip_block);
2052 case IP_VERSION(4, 0, 3):
2053 amdgpu_device_ip_block_add(adev, &vcn_v4_0_3_ip_block);
2054 amdgpu_device_ip_block_add(adev, &jpeg_v4_0_3_ip_block);
2058 "Failed to add vcn/jpeg ip block(UVD_HWIP:0x%x)\n",
2059 adev->ip_versions[UVD_HWIP][0]);
2066 static int amdgpu_discovery_set_mes_ip_blocks(struct amdgpu_device *adev)
2068 switch (adev->ip_versions[GC_HWIP][0]) {
2069 case IP_VERSION(10, 1, 10):
2070 case IP_VERSION(10, 1, 1):
2071 case IP_VERSION(10, 1, 2):
2072 case IP_VERSION(10, 1, 3):
2073 case IP_VERSION(10, 1, 4):
2074 case IP_VERSION(10, 3, 0):
2075 case IP_VERSION(10, 3, 1):
2076 case IP_VERSION(10, 3, 2):
2077 case IP_VERSION(10, 3, 3):
2078 case IP_VERSION(10, 3, 4):
2079 case IP_VERSION(10, 3, 5):
2080 case IP_VERSION(10, 3, 6):
2082 amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block);
2083 adev->enable_mes = true;
2085 adev->enable_mes_kiq = true;
2088 case IP_VERSION(11, 0, 0):
2089 case IP_VERSION(11, 0, 1):
2090 case IP_VERSION(11, 0, 2):
2091 case IP_VERSION(11, 0, 3):
2092 case IP_VERSION(11, 0, 4):
2093 amdgpu_device_ip_block_add(adev, &mes_v11_0_ip_block);
2094 adev->enable_mes = true;
2095 adev->enable_mes_kiq = true;
2103 static void amdgpu_discovery_init_soc_config(struct amdgpu_device *adev)
2105 switch (adev->ip_versions[GC_HWIP][0]) {
2106 case IP_VERSION(9, 4, 3):
2107 aqua_vanjaram_init_soc_config(adev);
2114 int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)
2118 switch (adev->asic_type) {
2120 vega10_reg_base_init(adev);
2121 adev->sdma.num_instances = 2;
2122 adev->gmc.num_umc = 4;
2123 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 0, 0);
2124 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 0, 0);
2125 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 0);
2126 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 0);
2127 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 0);
2128 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 0);
2129 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2130 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 1, 0);
2131 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 0, 0);
2132 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2133 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2134 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2135 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 0);
2136 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 0, 1);
2137 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2138 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2139 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 0);
2142 vega10_reg_base_init(adev);
2143 adev->sdma.num_instances = 2;
2144 adev->gmc.num_umc = 4;
2145 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2146 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2147 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 1);
2148 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 1);
2149 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 1);
2150 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 1);
2151 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 5, 0);
2152 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 2, 0);
2153 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 0);
2154 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2155 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2156 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2157 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 1);
2158 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 1);
2159 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2160 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2161 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 1);
2164 vega10_reg_base_init(adev);
2165 adev->sdma.num_instances = 1;
2166 adev->vcn.num_vcn_inst = 1;
2167 adev->gmc.num_umc = 2;
2168 if (adev->apu_flags & AMD_APU_IS_RAVEN2) {
2169 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2170 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2171 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 1);
2172 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 1);
2173 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 1);
2174 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 1);
2175 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 1);
2176 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 5, 0);
2177 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 1);
2178 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 1);
2179 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 1, 0);
2180 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 1);
2181 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 2);
2182 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 1);
2183 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 1);
2185 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2186 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2187 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 0);
2188 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 0);
2189 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 0);
2190 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2191 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 0);
2192 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 0, 0);
2193 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 0);
2194 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 0);
2195 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 0, 0);
2196 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 0);
2197 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 1, 0);
2198 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 0);
2199 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 0);
2203 vega20_reg_base_init(adev);
2204 adev->sdma.num_instances = 2;
2205 adev->gmc.num_umc = 8;
2206 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2207 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2208 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 0);
2209 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 0);
2210 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 0);
2211 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 0);
2212 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 0);
2213 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 0);
2214 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 1);
2215 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 2);
2216 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2217 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 2);
2218 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 2);
2219 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 0);
2220 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 2, 0);
2221 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(7, 2, 0);
2222 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 1, 0);
2223 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 1, 0);
2226 arct_reg_base_init(adev);
2227 adev->sdma.num_instances = 8;
2228 adev->vcn.num_vcn_inst = 2;
2229 adev->gmc.num_umc = 8;
2230 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2231 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2232 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 1);
2233 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 1);
2234 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 2);
2235 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 2);
2236 adev->ip_versions[SDMA1_HWIP][1] = IP_VERSION(4, 2, 2);
2237 adev->ip_versions[SDMA1_HWIP][2] = IP_VERSION(4, 2, 2);
2238 adev->ip_versions[SDMA1_HWIP][3] = IP_VERSION(4, 2, 2);
2239 adev->ip_versions[SDMA1_HWIP][4] = IP_VERSION(4, 2, 2);
2240 adev->ip_versions[SDMA1_HWIP][5] = IP_VERSION(4, 2, 2);
2241 adev->ip_versions[SDMA1_HWIP][6] = IP_VERSION(4, 2, 2);
2242 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 1);
2243 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 1);
2244 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 2);
2245 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 4);
2246 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2247 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 3);
2248 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 3);
2249 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 1);
2250 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 5, 0);
2251 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 5, 0);
2253 case CHIP_ALDEBARAN:
2254 aldebaran_reg_base_init(adev);
2255 adev->sdma.num_instances = 5;
2256 adev->vcn.num_vcn_inst = 2;
2257 adev->gmc.num_umc = 4;
2258 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2259 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2260 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 4, 0);
2261 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 4, 0);
2262 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 4, 0);
2263 adev->ip_versions[SDMA0_HWIP][1] = IP_VERSION(4, 4, 0);
2264 adev->ip_versions[SDMA0_HWIP][2] = IP_VERSION(4, 4, 0);
2265 adev->ip_versions[SDMA0_HWIP][3] = IP_VERSION(4, 4, 0);
2266 adev->ip_versions[SDMA0_HWIP][4] = IP_VERSION(4, 4, 0);
2267 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 2);
2268 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 4);
2269 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 7, 0);
2270 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(13, 0, 2);
2271 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(13, 0, 2);
2272 adev->ip_versions[THM_HWIP][0] = IP_VERSION(13, 0, 2);
2273 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(13, 0, 2);
2274 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 2);
2275 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 6, 0);
2276 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 6, 0);
2277 adev->ip_versions[XGMI_HWIP][0] = IP_VERSION(6, 1, 0);
2280 r = amdgpu_discovery_reg_base_init(adev);
2284 amdgpu_discovery_harvest_ip(adev);
2285 amdgpu_discovery_get_gfx_info(adev);
2286 amdgpu_discovery_get_mall_info(adev);
2287 amdgpu_discovery_get_vcn_info(adev);
2291 amdgpu_discovery_init_soc_config(adev);
2292 amdgpu_discovery_sysfs_init(adev);
2294 switch (adev->ip_versions[GC_HWIP][0]) {
2295 case IP_VERSION(9, 0, 1):
2296 case IP_VERSION(9, 2, 1):
2297 case IP_VERSION(9, 4, 0):
2298 case IP_VERSION(9, 4, 1):
2299 case IP_VERSION(9, 4, 2):
2300 case IP_VERSION(9, 4, 3):
2301 adev->family = AMDGPU_FAMILY_AI;
2303 case IP_VERSION(9, 1, 0):
2304 case IP_VERSION(9, 2, 2):
2305 case IP_VERSION(9, 3, 0):
2306 adev->family = AMDGPU_FAMILY_RV;
2308 case IP_VERSION(10, 1, 10):
2309 case IP_VERSION(10, 1, 1):
2310 case IP_VERSION(10, 1, 2):
2311 case IP_VERSION(10, 1, 3):
2312 case IP_VERSION(10, 1, 4):
2313 case IP_VERSION(10, 3, 0):
2314 case IP_VERSION(10, 3, 2):
2315 case IP_VERSION(10, 3, 4):
2316 case IP_VERSION(10, 3, 5):
2317 adev->family = AMDGPU_FAMILY_NV;
2319 case IP_VERSION(10, 3, 1):
2320 adev->family = AMDGPU_FAMILY_VGH;
2321 adev->apu_flags |= AMD_APU_IS_VANGOGH;
2323 case IP_VERSION(10, 3, 3):
2324 adev->family = AMDGPU_FAMILY_YC;
2326 case IP_VERSION(10, 3, 6):
2327 adev->family = AMDGPU_FAMILY_GC_10_3_6;
2329 case IP_VERSION(10, 3, 7):
2330 adev->family = AMDGPU_FAMILY_GC_10_3_7;
2332 case IP_VERSION(11, 0, 0):
2333 case IP_VERSION(11, 0, 2):
2334 case IP_VERSION(11, 0, 3):
2335 adev->family = AMDGPU_FAMILY_GC_11_0_0;
2337 case IP_VERSION(11, 0, 1):
2338 case IP_VERSION(11, 0, 4):
2339 adev->family = AMDGPU_FAMILY_GC_11_0_1;
2345 switch (adev->ip_versions[GC_HWIP][0]) {
2346 case IP_VERSION(9, 1, 0):
2347 case IP_VERSION(9, 2, 2):
2348 case IP_VERSION(9, 3, 0):
2349 case IP_VERSION(10, 1, 3):
2350 case IP_VERSION(10, 1, 4):
2351 case IP_VERSION(10, 3, 1):
2352 case IP_VERSION(10, 3, 3):
2353 case IP_VERSION(10, 3, 6):
2354 case IP_VERSION(10, 3, 7):
2355 case IP_VERSION(11, 0, 1):
2356 case IP_VERSION(11, 0, 4):
2357 adev->flags |= AMD_IS_APU;
2363 if (adev->ip_versions[XGMI_HWIP][0] == IP_VERSION(4, 8, 0))
2364 adev->gmc.xgmi.supported = true;
2366 /* set NBIO version */
2367 switch (adev->ip_versions[NBIO_HWIP][0]) {
2368 case IP_VERSION(6, 1, 0):
2369 case IP_VERSION(6, 2, 0):
2370 adev->nbio.funcs = &nbio_v6_1_funcs;
2371 adev->nbio.hdp_flush_reg = &nbio_v6_1_hdp_flush_reg;
2373 case IP_VERSION(7, 0, 0):
2374 case IP_VERSION(7, 0, 1):
2375 case IP_VERSION(2, 5, 0):
2376 adev->nbio.funcs = &nbio_v7_0_funcs;
2377 adev->nbio.hdp_flush_reg = &nbio_v7_0_hdp_flush_reg;
2379 case IP_VERSION(7, 4, 0):
2380 case IP_VERSION(7, 4, 1):
2381 case IP_VERSION(7, 4, 4):
2382 adev->nbio.funcs = &nbio_v7_4_funcs;
2383 adev->nbio.hdp_flush_reg = &nbio_v7_4_hdp_flush_reg;
2385 case IP_VERSION(7, 9, 0):
2386 adev->nbio.funcs = &nbio_v7_9_funcs;
2387 adev->nbio.hdp_flush_reg = &nbio_v7_9_hdp_flush_reg;
2389 case IP_VERSION(7, 2, 0):
2390 case IP_VERSION(7, 2, 1):
2391 case IP_VERSION(7, 3, 0):
2392 case IP_VERSION(7, 5, 0):
2393 case IP_VERSION(7, 5, 1):
2394 adev->nbio.funcs = &nbio_v7_2_funcs;
2395 adev->nbio.hdp_flush_reg = &nbio_v7_2_hdp_flush_reg;
2397 case IP_VERSION(2, 1, 1):
2398 case IP_VERSION(2, 3, 0):
2399 case IP_VERSION(2, 3, 1):
2400 case IP_VERSION(2, 3, 2):
2401 case IP_VERSION(3, 3, 0):
2402 case IP_VERSION(3, 3, 1):
2403 case IP_VERSION(3, 3, 2):
2404 case IP_VERSION(3, 3, 3):
2405 adev->nbio.funcs = &nbio_v2_3_funcs;
2406 adev->nbio.hdp_flush_reg = &nbio_v2_3_hdp_flush_reg;
2408 case IP_VERSION(4, 3, 0):
2409 case IP_VERSION(4, 3, 1):
2410 if (amdgpu_sriov_vf(adev))
2411 adev->nbio.funcs = &nbio_v4_3_sriov_funcs;
2413 adev->nbio.funcs = &nbio_v4_3_funcs;
2414 adev->nbio.hdp_flush_reg = &nbio_v4_3_hdp_flush_reg;
2416 case IP_VERSION(7, 7, 0):
2417 case IP_VERSION(7, 7, 1):
2418 adev->nbio.funcs = &nbio_v7_7_funcs;
2419 adev->nbio.hdp_flush_reg = &nbio_v7_7_hdp_flush_reg;
2425 switch (adev->ip_versions[HDP_HWIP][0]) {
2426 case IP_VERSION(4, 0, 0):
2427 case IP_VERSION(4, 0, 1):
2428 case IP_VERSION(4, 1, 0):
2429 case IP_VERSION(4, 1, 1):
2430 case IP_VERSION(4, 1, 2):
2431 case IP_VERSION(4, 2, 0):
2432 case IP_VERSION(4, 2, 1):
2433 case IP_VERSION(4, 4, 0):
2434 case IP_VERSION(4, 4, 2):
2435 adev->hdp.funcs = &hdp_v4_0_funcs;
2437 case IP_VERSION(5, 0, 0):
2438 case IP_VERSION(5, 0, 1):
2439 case IP_VERSION(5, 0, 2):
2440 case IP_VERSION(5, 0, 3):
2441 case IP_VERSION(5, 0, 4):
2442 case IP_VERSION(5, 2, 0):
2443 adev->hdp.funcs = &hdp_v5_0_funcs;
2445 case IP_VERSION(5, 2, 1):
2446 adev->hdp.funcs = &hdp_v5_2_funcs;
2448 case IP_VERSION(6, 0, 0):
2449 case IP_VERSION(6, 0, 1):
2450 adev->hdp.funcs = &hdp_v6_0_funcs;
2456 switch (adev->ip_versions[DF_HWIP][0]) {
2457 case IP_VERSION(3, 6, 0):
2458 case IP_VERSION(3, 6, 1):
2459 case IP_VERSION(3, 6, 2):
2460 adev->df.funcs = &df_v3_6_funcs;
2462 case IP_VERSION(2, 1, 0):
2463 case IP_VERSION(2, 1, 1):
2464 case IP_VERSION(2, 5, 0):
2465 case IP_VERSION(3, 5, 1):
2466 case IP_VERSION(3, 5, 2):
2467 adev->df.funcs = &df_v1_7_funcs;
2469 case IP_VERSION(4, 3, 0):
2470 adev->df.funcs = &df_v4_3_funcs;
2476 switch (adev->ip_versions[SMUIO_HWIP][0]) {
2477 case IP_VERSION(9, 0, 0):
2478 case IP_VERSION(9, 0, 1):
2479 case IP_VERSION(10, 0, 0):
2480 case IP_VERSION(10, 0, 1):
2481 case IP_VERSION(10, 0, 2):
2482 adev->smuio.funcs = &smuio_v9_0_funcs;
2484 case IP_VERSION(11, 0, 0):
2485 case IP_VERSION(11, 0, 2):
2486 case IP_VERSION(11, 0, 3):
2487 case IP_VERSION(11, 0, 4):
2488 case IP_VERSION(11, 0, 7):
2489 case IP_VERSION(11, 0, 8):
2490 adev->smuio.funcs = &smuio_v11_0_funcs;
2492 case IP_VERSION(11, 0, 6):
2493 case IP_VERSION(11, 0, 10):
2494 case IP_VERSION(11, 0, 11):
2495 case IP_VERSION(11, 5, 0):
2496 case IP_VERSION(13, 0, 1):
2497 case IP_VERSION(13, 0, 9):
2498 case IP_VERSION(13, 0, 10):
2499 adev->smuio.funcs = &smuio_v11_0_6_funcs;
2501 case IP_VERSION(13, 0, 2):
2502 adev->smuio.funcs = &smuio_v13_0_funcs;
2504 case IP_VERSION(13, 0, 3):
2505 adev->smuio.funcs = &smuio_v13_0_3_funcs;
2506 if (adev->smuio.funcs->get_pkg_type(adev) == AMDGPU_PKG_TYPE_APU) {
2507 adev->flags |= AMD_IS_APU;
2510 case IP_VERSION(13, 0, 6):
2511 case IP_VERSION(13, 0, 8):
2512 adev->smuio.funcs = &smuio_v13_0_6_funcs;
2518 switch (adev->ip_versions[LSDMA_HWIP][0]) {
2519 case IP_VERSION(6, 0, 0):
2520 case IP_VERSION(6, 0, 1):
2521 case IP_VERSION(6, 0, 2):
2522 case IP_VERSION(6, 0, 3):
2523 adev->lsdma.funcs = &lsdma_v6_0_funcs;
2529 r = amdgpu_discovery_set_common_ip_blocks(adev);
2533 r = amdgpu_discovery_set_gmc_ip_blocks(adev);
2537 /* For SR-IOV, PSP needs to be initialized before IH */
2538 if (amdgpu_sriov_vf(adev)) {
2539 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2542 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2546 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2550 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2551 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2557 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2558 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2563 r = amdgpu_discovery_set_display_ip_blocks(adev);
2567 r = amdgpu_discovery_set_gc_ip_blocks(adev);
2571 r = amdgpu_discovery_set_sdma_ip_blocks(adev);
2575 if ((adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
2576 !amdgpu_sriov_vf(adev)) ||
2577 (adev->firmware.load_type == AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO && amdgpu_dpm == 1)) {
2578 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2583 r = amdgpu_discovery_set_mm_ip_blocks(adev);
2587 r = amdgpu_discovery_set_mes_ip_blocks(adev);