blob: 11a4a94417863101c99641305708ac736c75bdd1 [file] [log] [blame]
Angel Pons0612b272020-04-05 15:46:56 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Bora Guvendik94ee3282017-05-04 13:06:43 -07002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpigen.h>
Bora Guvendik94ee3282017-05-04 13:06:43 -07004#include <device/pci.h>
5#include <device/pci_ids.h>
6#include <intelblocks/sd.h>
7
Julius Wernercd49cce2019-03-05 16:53:33 -08008#if CONFIG(HAVE_ACPI_TABLES)
Furquan Shaikh7536a392020-04-24 21:59:21 -07009static void sd_fill_ssdt(const struct device *dev)
Bora Guvendik94ee3282017-05-04 13:06:43 -070010{
11 const char *path;
12 struct acpi_gpio default_gpio = { 0 };
13 struct acpi_dp *dp;
14
Bora Guvendik94ee3282017-05-04 13:06:43 -070015 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
41static struct device_operations dev_ops = {
Nico Huber68680dd2020-03-31 17:34:52 +020042 .read_resources = pci_dev_read_resources,
43 .set_resources = pci_dev_set_resources,
44 .enable_resources = pci_dev_enable_resources,
Julius Wernercd49cce2019-03-05 16:53:33 -080045#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +020046 .acpi_fill_ssdt = sd_fill_ssdt,
Bora Guvendik94ee3282017-05-04 13:06:43 -070047#endif
Nico Huber68680dd2020-03-31 17:34:52 +020048 .ops_pci = &pci_dev_ops_pci,
Bora Guvendik94ee3282017-05-04 13:06:43 -070049};
50
51static const unsigned short pci_device_ids[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010052 PCI_DID_INTEL_APL_SD,
53 PCI_DID_INTEL_CNL_SD,
54 PCI_DID_INTEL_GLK_SD,
55 PCI_DID_INTEL_SKL_SD,
56 PCI_DID_INTEL_CNP_H_SD,
57 PCI_DID_INTEL_ICL_SD,
58 PCI_DID_INTEL_CMP_SD,
59 PCI_DID_INTEL_CMP_H_SD,
60 PCI_DID_INTEL_MCC_SD,
61 PCI_DID_INTEL_JSP_SD,
Bora Guvendik94ee3282017-05-04 13:06:43 -070062 0
63};
64
65static const struct pci_driver pch_sd __pci_driver = {
66 .ops = &dev_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010067 .vendor = PCI_VID_INTEL,
Bora Guvendik94ee3282017-05-04 13:06:43 -070068 .devices = pci_device_ids
69};