1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <acpi/acpi_device.h>
4 #include <acpi/acpigen.h>
5 #include <cbmem.h>
6 #include <console/console.h>
7 #include <device/pci.h>
8 #include <device/pci_ids.h>
9 #include <intelblocks/cse.h>
10 #include "chip.h"
11
ish_fill_ssdt_generator(const struct device * dev)12 static void ish_fill_ssdt_generator(const struct device *dev)
13 {
14 struct drivers_intel_ish_config *config = dev->chip_info;
15 struct device *root = dev->upstream->dev;
16 struct acpi_dp *dsd;
17
18 if (!config)
19 return;
20
21 acpigen_write_scope(acpi_device_path(root));
22
23 dsd = acpi_dp_new_table("_DSD");
24
25 if (config->firmware_name) {
26 acpi_dp_add_string(dsd, "firmware-name", config->firmware_name);
27 printk(BIOS_INFO, "%s: Set firmware-name: %s\n",
28 acpi_device_path(root), config->firmware_name);
29 }
30
31 if (config->add_acpi_dma_property)
32 acpi_device_add_dma_property(dsd);
33
34 acpi_dp_write(dsd);
35
36 acpigen_pop_len(); /* Scope */
37 }
38
39 static struct device_operations intel_ish_ops = {
40 .read_resources = noop_read_resources,
41 .set_resources = noop_set_resources,
42 .acpi_fill_ssdt = ish_fill_ssdt_generator,
43 };
44
intel_ish_enable(struct device * dev)45 static void intel_ish_enable(struct device *dev)
46 {
47 /* This dev is a generic device that is a child to the ISH PCI device */
48 dev->ops = &intel_ish_ops;
49 }
50
intel_ish_get_version(void)51 static void intel_ish_get_version(void)
52 {
53 if (CONFIG(SOC_INTEL_CSE_LITE_SYNC_BY_PAYLOAD))
54 return;
55
56 struct cse_specific_info *info = cbmem_find(CBMEM_ID_CSE_INFO);
57 if (info == NULL)
58 return;
59
60 printk(BIOS_DEBUG, "ISH version: %d.%d.%d.%d\n",
61 info->cse_fwp_version.ish_partition_info.cur_ish_fw_version.major,
62 info->cse_fwp_version.ish_partition_info.cur_ish_fw_version.minor,
63 info->cse_fwp_version.ish_partition_info.cur_ish_fw_version.hotfix,
64 info->cse_fwp_version.ish_partition_info.cur_ish_fw_version.build);
65 }
66
intel_ish_final(struct device * dev)67 static void intel_ish_final(struct device *dev)
68 {
69 if (CONFIG(SOC_INTEL_STORE_ISH_FW_VERSION))
70 intel_ish_get_version();
71 }
72
73 /* Copy of default_pci_ops_dev with scan_bus addition */
74 static const struct device_operations pci_ish_device_ops = {
75 .read_resources = pci_dev_read_resources,
76 .set_resources = pci_dev_set_resources,
77 .enable_resources = pci_dev_enable_resources,
78 .init = pci_dev_init,
79 .scan_bus = &scan_generic_bus, /* Non-default */
80 .ops_pci = &pci_dev_ops_pci,
81 .final = intel_ish_final,
82 };
83
84 static const unsigned short pci_device_ids[] = {
85 PCI_DID_INTEL_PTL_ISHB,
86 PCI_DID_INTEL_LNL_ISHB,
87 PCI_DID_INTEL_MTL_ISHB,
88 PCI_DID_INTEL_CNL_ISHB,
89 PCI_DID_INTEL_CML_ISHB,
90 PCI_DID_INTEL_TGL_ISHB,
91 PCI_DID_INTEL_TGL_H_ISHB,
92 PCI_DID_INTEL_ADL_N_ISHB,
93 PCI_DID_INTEL_ADL_P_ISHB,
94 0
95 };
96
97 static const struct pci_driver ish_intel_driver __pci_driver = {
98 .ops = &pci_ish_device_ops,
99 .vendor = PCI_VID_INTEL,
100 .devices = pci_device_ids,
101 };
102
103 struct chip_operations drivers_intel_ish_ops = {
104 .name = "Intel ISH Chip",
105 .enable_dev = intel_ish_enable,
106 };
107