Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2019 Google LLC |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #include <arch/acpi_device.h> |
| 17 | #include <arch/acpigen.h> |
| 18 | #include <console/console.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <device/pci_ids.h> |
| 21 | #include "chip.h" |
| 22 | |
| 23 | static void ish_fill_ssdt_generator(struct device *dev) |
| 24 | { |
| 25 | struct drivers_intel_ish_config *config = dev->chip_info; |
| 26 | struct device *root = dev->bus->dev; |
| 27 | struct acpi_dp *dsd; |
| 28 | |
| 29 | if (!dev->enabled || !config || !config->firmware_name) |
| 30 | return; |
| 31 | |
| 32 | acpigen_write_scope(acpi_device_path(root)); |
| 33 | |
| 34 | dsd = acpi_dp_new_table("_DSD"); |
| 35 | acpi_dp_add_string(dsd, "firmware-name", config->firmware_name); |
| 36 | acpi_dp_write(dsd); |
| 37 | |
| 38 | acpigen_pop_len(); /* Scope */ |
| 39 | |
| 40 | printk(BIOS_INFO, "%s: Set firmware-name: %s\n", |
| 41 | acpi_device_path(root), config->firmware_name); |
| 42 | } |
| 43 | |
| 44 | static struct device_operations intel_ish_ops = { |
| 45 | .read_resources = DEVICE_NOOP, |
| 46 | .set_resources = DEVICE_NOOP, |
| 47 | .enable_resources = DEVICE_NOOP, |
| 48 | .acpi_fill_ssdt_generator = ish_fill_ssdt_generator, |
| 49 | }; |
| 50 | |
| 51 | static void intel_ish_enable(struct device *dev) |
| 52 | { |
| 53 | /* This dev is a generic device that is a child to the ISH PCI device */ |
| 54 | dev->ops = &intel_ish_ops; |
| 55 | } |
| 56 | |
| 57 | /* Copy of default_pci_ops_dev with scan_bus addition */ |
| 58 | static const struct device_operations pci_ish_device_ops = { |
| 59 | .read_resources = pci_dev_read_resources, |
| 60 | .set_resources = pci_dev_set_resources, |
| 61 | .enable_resources = pci_dev_enable_resources, |
| 62 | .init = pci_dev_init, |
| 63 | .scan_bus = &scan_generic_bus, /* Non-default */ |
| 64 | .ops_pci = &pci_dev_ops_pci, |
| 65 | }; |
| 66 | |
| 67 | static const unsigned short pci_device_ids[] = { |
| 68 | PCI_DEVICE_ID_INTEL_CNL_ISHB, |
Bernardo Perez Priego | ab9a7c0 | 2019-08-02 18:25:01 -0700 | [diff] [blame^] | 69 | PCI_DEVICE_ID_INTEL_CML_ISHB, |
Jett Rink | 6bdfc80 | 2019-03-01 10:20:34 -0700 | [diff] [blame] | 70 | 0 |
| 71 | }; |
| 72 | |
| 73 | static const struct pci_driver ish_intel_driver __pci_driver = { |
| 74 | .ops = &pci_ish_device_ops, |
| 75 | .vendor = PCI_VENDOR_ID_INTEL, |
| 76 | .devices = pci_device_ids, |
| 77 | }; |
| 78 | |
| 79 | struct chip_operations drivers_intel_ish_ops = { |
| 80 | CHIP_NAME("Intel ISH Chip") |
| 81 | .enable_dev = intel_ish_enable, |
| 82 | }; |