Angel Pons | 0612b27 | 2020-04-05 15:46:56 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpigen.h> |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 4 | #include <device/pci.h> |
| 5 | #include <device/pci_ids.h> |
| 6 | #include <intelblocks/sd.h> |
| 7 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 8 | #if CONFIG(HAVE_ACPI_TABLES) |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 9 | static void sd_fill_ssdt(const struct device *dev) |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 10 | { |
| 11 | const char *path; |
| 12 | struct acpi_gpio default_gpio = { 0 }; |
| 13 | struct acpi_dp *dp; |
| 14 | |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 15 | if (sd_fill_soc_gpio_info(&default_gpio, dev) != 0) |
| 16 | return; |
| 17 | |
| 18 | /* Use device path as the Scope for the SSDT */ |
| 19 | path = acpi_device_path(dev); |
| 20 | if (!path) |
| 21 | return; |
| 22 | acpigen_write_scope(path); |
| 23 | acpigen_write_name("_CRS"); |
| 24 | |
| 25 | /* Write GpioInt() as default (if set) or custom from devicetree */ |
| 26 | acpigen_write_resourcetemplate_header(); |
| 27 | acpi_device_write_gpio(&default_gpio); |
| 28 | acpigen_write_resourcetemplate_footer(); |
| 29 | |
| 30 | /* Bind the cd-gpio name to the GpioInt() resource */ |
| 31 | dp = acpi_dp_new_table("_DSD"); |
| 32 | if (!dp) |
| 33 | return; |
| 34 | acpi_dp_add_gpio(dp, "cd-gpio", path, 0, 0, 1); |
| 35 | acpi_dp_write(dp); |
| 36 | |
| 37 | acpigen_pop_len(); |
| 38 | } |
| 39 | #endif |
| 40 | |
Nico Huber | 5768619 | 2022-08-06 19:11:55 +0200 | [diff] [blame] | 41 | struct device_operations sd_ops = { |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 42 | .read_resources = pci_dev_read_resources, |
| 43 | .set_resources = pci_dev_set_resources, |
| 44 | .enable_resources = pci_dev_enable_resources, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 45 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 46 | .acpi_fill_ssdt = sd_fill_ssdt, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 47 | #endif |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 48 | .ops_pci = &pci_dev_ops_pci, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | static const unsigned short pci_device_ids[] = { |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 52 | PCI_DID_INTEL_APL_SD, |
| 53 | PCI_DID_INTEL_CNL_SD, |
| 54 | PCI_DID_INTEL_GLK_SD, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 55 | PCI_DID_INTEL_CNP_H_SD, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 56 | PCI_DID_INTEL_CMP_SD, |
| 57 | PCI_DID_INTEL_CMP_H_SD, |
| 58 | PCI_DID_INTEL_MCC_SD, |
| 59 | PCI_DID_INTEL_JSP_SD, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 60 | 0 |
| 61 | }; |
| 62 | |
| 63 | static const struct pci_driver pch_sd __pci_driver = { |
Nico Huber | 5768619 | 2022-08-06 19:11:55 +0200 | [diff] [blame] | 64 | .ops = &sd_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 65 | .vendor = PCI_VID_INTEL, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 66 | .devices = pci_device_ids |
| 67 | }; |