Angel Pons | 0612b27 | 2020-04-05 15:46:56 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 3 | |
| 4 | #include <arch/acpigen.h> |
| 5 | #include <device/pci.h> |
| 6 | #include <device/pci_ids.h> |
| 7 | #include <intelblocks/sd.h> |
| 8 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 9 | #if CONFIG(HAVE_ACPI_TABLES) |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 10 | static void sd_fill_ssdt(struct device *dev) |
| 11 | { |
| 12 | const char *path; |
| 13 | struct acpi_gpio default_gpio = { 0 }; |
| 14 | struct acpi_dp *dp; |
| 15 | |
| 16 | if (!dev->enabled) |
| 17 | return; |
| 18 | |
| 19 | if (sd_fill_soc_gpio_info(&default_gpio, dev) != 0) |
| 20 | return; |
| 21 | |
| 22 | /* Use device path as the Scope for the SSDT */ |
| 23 | path = acpi_device_path(dev); |
| 24 | if (!path) |
| 25 | return; |
| 26 | acpigen_write_scope(path); |
| 27 | acpigen_write_name("_CRS"); |
| 28 | |
| 29 | /* Write GpioInt() as default (if set) or custom from devicetree */ |
| 30 | acpigen_write_resourcetemplate_header(); |
| 31 | acpi_device_write_gpio(&default_gpio); |
| 32 | acpigen_write_resourcetemplate_footer(); |
| 33 | |
| 34 | /* Bind the cd-gpio name to the GpioInt() resource */ |
| 35 | dp = acpi_dp_new_table("_DSD"); |
| 36 | if (!dp) |
| 37 | return; |
| 38 | acpi_dp_add_gpio(dp, "cd-gpio", path, 0, 0, 1); |
| 39 | acpi_dp_write(dp); |
| 40 | |
| 41 | acpigen_pop_len(); |
| 42 | } |
| 43 | #endif |
| 44 | |
| 45 | static struct device_operations dev_ops = { |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 46 | .read_resources = pci_dev_read_resources, |
| 47 | .set_resources = pci_dev_set_resources, |
| 48 | .enable_resources = pci_dev_enable_resources, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 49 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 50 | .acpi_fill_ssdt = sd_fill_ssdt, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 51 | #endif |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 52 | .ops_pci = &pci_dev_ops_pci, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | static const unsigned short pci_device_ids[] = { |
| 56 | PCI_DEVICE_ID_INTEL_APL_SD, |
Lijian Zhao | bbedef9 | 2017-07-29 16:38:38 -0700 | [diff] [blame] | 57 | PCI_DEVICE_ID_INTEL_CNL_SD, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 58 | PCI_DEVICE_ID_INTEL_GLK_SD, |
| 59 | PCI_DEVICE_ID_INTEL_SKL_SD, |
praveen hodagatta pranesh | e26c4a4 | 2018-09-20 03:49:45 +0800 | [diff] [blame] | 60 | PCI_DEVICE_ID_INTEL_CNP_H_SD, |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 61 | PCI_DEVICE_ID_INTEL_ICL_SD, |
Ronak Kanabar | da7ffb48 | 2019-02-05 01:51:13 +0530 | [diff] [blame] | 62 | PCI_DEVICE_ID_INTEL_CMP_SD, |
Gaggery Tsai | 12a651c | 2019-12-05 11:23:20 -0800 | [diff] [blame] | 63 | PCI_DEVICE_ID_INTEL_CMP_H_SD, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame] | 64 | PCI_DEVICE_ID_INTEL_MCC_SD, |
Meera Ravindranath | 3f4af0d | 2020-02-12 16:01:22 +0530 | [diff] [blame] | 65 | PCI_DEVICE_ID_INTEL_JSP_SD, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 66 | 0 |
| 67 | }; |
| 68 | |
| 69 | static const struct pci_driver pch_sd __pci_driver = { |
| 70 | .ops = &dev_ops, |
| 71 | .vendor = PCI_VENDOR_ID_INTEL, |
| 72 | .devices = pci_device_ids |
| 73 | }; |