blob: 6dba46adc71d07bff84c346d2c6305a2976ba31f [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Jett Rink6bdfc802019-03-01 10:20:34 -07002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpi_device.h>
4#include <acpi/acpigen.h>
Subrata Banik13bbb042023-04-14 12:59:19 +05305#include <cbmem.h>
Jett Rink6bdfc802019-03-01 10:20:34 -07006#include <console/console.h>
7#include <device/pci.h>
8#include <device/pci_ids.h>
Subrata Banik13bbb042023-04-14 12:59:19 +05309#include <intelblocks/cse.h>
Jett Rink6bdfc802019-03-01 10:20:34 -070010#include "chip.h"
11
Furquan Shaikh7536a392020-04-24 21:59:21 -070012static void ish_fill_ssdt_generator(const struct device *dev)
Jett Rink6bdfc802019-03-01 10:20:34 -070013{
14 struct drivers_intel_ish_config *config = dev->chip_info;
15 struct device *root = dev->bus->dev;
16 struct acpi_dp *dsd;
17
Reka Norman6419fbf2022-12-12 10:32:53 +110018 if (!config)
Jett Rink6bdfc802019-03-01 10:20:34 -070019 return;
20
21 acpigen_write_scope(acpi_device_path(root));
22
23 dsd = acpi_dp_new_table("_DSD");
Reka Norman6419fbf2022-12-12 10:32:53 +110024
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 Rink6bdfc802019-03-01 10:20:34 -070034 acpi_dp_write(dsd);
35
36 acpigen_pop_len(); /* Scope */
Jett Rink6bdfc802019-03-01 10:20:34 -070037}
38
39static struct device_operations intel_ish_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020040 .read_resources = noop_read_resources,
41 .set_resources = noop_set_resources,
Nico Huber68680dd2020-03-31 17:34:52 +020042 .acpi_fill_ssdt = ish_fill_ssdt_generator,
Jett Rink6bdfc802019-03-01 10:20:34 -070043};
44
45static 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 Banik13bbb042023-04-14 12:59:19 +053051static void intel_ish_get_version(void)
52{
Subrata Banik88512b02023-08-17 15:44:52 +000053 struct cse_specific_info *info = cbmem_find(CBMEM_ID_CSE_INFO);
54 if (info == NULL)
Subrata Banik13bbb042023-04-14 12:59:19 +053055 return;
56
57 printk(BIOS_DEBUG, "ISH version: %d.%d.%d.%d\n",
Subrata Banik88512b02023-08-17 15:44:52 +000058 info->cse_fwp_version.ish_partition_info.cur_ish_fw_version.major,
59 info->cse_fwp_version.ish_partition_info.cur_ish_fw_version.minor,
60 info->cse_fwp_version.ish_partition_info.cur_ish_fw_version.hotfix,
61 info->cse_fwp_version.ish_partition_info.cur_ish_fw_version.build);
Subrata Banik13bbb042023-04-14 12:59:19 +053062}
63
64static void intel_ish_final(struct device *dev)
65{
Subrata Banik272ce9a2023-06-13 00:44:44 +053066 if (CONFIG(SOC_INTEL_STORE_ISH_FW_VERSION))
Subrata Banik13bbb042023-04-14 12:59:19 +053067 intel_ish_get_version();
68}
69
Jett Rink6bdfc802019-03-01 10:20:34 -070070/* Copy of default_pci_ops_dev with scan_bus addition */
71static 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 Banik13bbb042023-04-14 12:59:19 +053078 .final = intel_ish_final,
Jett Rink6bdfc802019-03-01 10:20:34 -070079};
80
81static const unsigned short pci_device_ids[] = {
Appukuttan V K50c8f2e2024-01-11 18:05:11 +053082 PCI_DID_INTEL_LNL_ISHB,
Wonkyu Kim9f401072020-11-13 15:16:32 -080083 PCI_DID_INTEL_MTL_ISHB,
Felix Singer43b7f412022-03-07 04:34:52 +010084 PCI_DID_INTEL_CNL_ISHB,
85 PCI_DID_INTEL_CML_ISHB,
86 PCI_DID_INTEL_TGL_ISHB,
87 PCI_DID_INTEL_TGL_H_ISHB,
Meera Ravindranathac08e8f2022-10-06 14:24:07 +053088 PCI_DID_INTEL_ADL_N_ISHB,
Subrata Banik3a60e5c2022-12-23 18:09:11 +000089 PCI_DID_INTEL_ADL_P_ISHB,
Jett Rink6bdfc802019-03-01 10:20:34 -070090 0
91};
92
93static const struct pci_driver ish_intel_driver __pci_driver = {
94 .ops = &pci_ish_device_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010095 .vendor = PCI_VID_INTEL,
Jett Rink6bdfc802019-03-01 10:20:34 -070096 .devices = pci_device_ids,
97};
98
99struct chip_operations drivers_intel_ish_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +0900100 .name = "Intel ISH Chip",
Jett Rink6bdfc802019-03-01 10:20:34 -0700101 .enable_dev = intel_ish_enable,
102};