Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi_device.h> |
| 4 | #include <acpi/acpigen.h> |
Subrata Banik | 13bbb04 | 2023-04-14 12:59:19 +0530 | [diff] [blame] | 5 | #include <cbmem.h> |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 6 | #include <console/console.h> |
| 7 | #include <device/pci.h> |
| 8 | #include <device/pci_ids.h> |
Subrata Banik | 13bbb04 | 2023-04-14 12:59:19 +0530 | [diff] [blame] | 9 | #include <intelblocks/cse.h> |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 10 | #include "chip.h" |
| 11 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 12 | static void ish_fill_ssdt_generator(const struct device *dev) |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 13 | { |
| 14 | struct drivers_intel_ish_config *config = dev->chip_info; |
| 15 | struct device *root = dev->bus->dev; |
| 16 | struct acpi_dp *dsd; |
| 17 | |
Reka Norman | 6419fbf | 2022-12-12 10:32:53 +1100 | [diff] [blame] | 18 | if (!config) |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 19 | return; |
| 20 | |
| 21 | acpigen_write_scope(acpi_device_path(root)); |
| 22 | |
| 23 | dsd = acpi_dp_new_table("_DSD"); |
Reka Norman | 6419fbf | 2022-12-12 10:32:53 +1100 | [diff] [blame] | 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 | |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 34 | acpi_dp_write(dsd); |
| 35 | |
| 36 | acpigen_pop_len(); /* Scope */ |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | static struct device_operations intel_ish_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 40 | .read_resources = noop_read_resources, |
| 41 | .set_resources = noop_set_resources, |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 42 | .acpi_fill_ssdt = ish_fill_ssdt_generator, |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
| 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 | |
Subrata Banik | 13bbb04 | 2023-04-14 12:59:19 +0530 | [diff] [blame] | 51 | static void intel_ish_get_version(void) |
| 52 | { |
| 53 | struct cse_fw_partition_info *version = cbmem_find(CBMEM_ID_CSE_PARTITION_VERSION); |
| 54 | if (version == NULL) |
| 55 | return; |
| 56 | |
| 57 | printk(BIOS_DEBUG, "ISH version: %d.%d.%d.%d\n", |
| 58 | version->ish_partition_info.cur_ish_fw_version.major, |
| 59 | version->ish_partition_info.cur_ish_fw_version.minor, |
| 60 | version->ish_partition_info.cur_ish_fw_version.hotfix, |
| 61 | version->ish_partition_info.cur_ish_fw_version.build); |
| 62 | } |
| 63 | |
| 64 | static void intel_ish_final(struct device *dev) |
| 65 | { |
Subrata Banik | 272ce9a | 2023-06-13 00:44:44 +0530 | [diff] [blame] | 66 | if (CONFIG(SOC_INTEL_STORE_ISH_FW_VERSION)) |
Subrata Banik | 13bbb04 | 2023-04-14 12:59:19 +0530 | [diff] [blame] | 67 | intel_ish_get_version(); |
| 68 | } |
| 69 | |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 70 | /* Copy of default_pci_ops_dev with scan_bus addition */ |
| 71 | static const struct device_operations pci_ish_device_ops = { |
| 72 | .read_resources = pci_dev_read_resources, |
| 73 | .set_resources = pci_dev_set_resources, |
| 74 | .enable_resources = pci_dev_enable_resources, |
| 75 | .init = pci_dev_init, |
| 76 | .scan_bus = &scan_generic_bus, /* Non-default */ |
| 77 | .ops_pci = &pci_dev_ops_pci, |
Subrata Banik | 13bbb04 | 2023-04-14 12:59:19 +0530 | [diff] [blame] | 78 | .final = intel_ish_final, |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | static const unsigned short pci_device_ids[] = { |
Wonkyu Kim | 9f40107 | 2020-11-13 15:16:32 -0800 | [diff] [blame] | 82 | PCI_DID_INTEL_MTL_ISHB, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 83 | PCI_DID_INTEL_CNL_ISHB, |
| 84 | PCI_DID_INTEL_CML_ISHB, |
| 85 | PCI_DID_INTEL_TGL_ISHB, |
| 86 | PCI_DID_INTEL_TGL_H_ISHB, |
Meera Ravindranath | ac08e8f | 2022-10-06 14:24:07 +0530 | [diff] [blame] | 87 | PCI_DID_INTEL_ADL_N_ISHB, |
Subrata Banik | 3a60e5c | 2022-12-23 18:09:11 +0000 | [diff] [blame] | 88 | PCI_DID_INTEL_ADL_P_ISHB, |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 89 | 0 |
| 90 | }; |
| 91 | |
| 92 | static const struct pci_driver ish_intel_driver __pci_driver = { |
| 93 | .ops = &pci_ish_device_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 94 | .vendor = PCI_VID_INTEL, |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 95 | .devices = pci_device_ids, |
| 96 | }; |
| 97 | |
| 98 | struct chip_operations drivers_intel_ish_ops = { |
| 99 | CHIP_NAME("Intel ISH Chip") |
| 100 | .enable_dev = intel_ish_enable, |
| 101 | }; |