blob: d529faaacae4d1a506de3557b184d4b882c851a2 [file] [log] [blame]
Bora Guvendik94ee3282017-05-04 13:06:43 -07001/*
2 * This file is part of the coreboot project.
3 *
Bora Guvendik94ee3282017-05-04 13:06:43 -07004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <arch/acpigen.h>
16#include <device/pci.h>
17#include <device/pci_ids.h>
18#include <intelblocks/sd.h>
19
Julius Wernercd49cce2019-03-05 16:53:33 -080020#if CONFIG(HAVE_ACPI_TABLES)
Bora Guvendik94ee3282017-05-04 13:06:43 -070021static void sd_fill_ssdt(struct device *dev)
22{
23 const char *path;
24 struct acpi_gpio default_gpio = { 0 };
25 struct acpi_dp *dp;
26
27 if (!dev->enabled)
28 return;
29
30 if (sd_fill_soc_gpio_info(&default_gpio, dev) != 0)
31 return;
32
33 /* Use device path as the Scope for the SSDT */
34 path = acpi_device_path(dev);
35 if (!path)
36 return;
37 acpigen_write_scope(path);
38 acpigen_write_name("_CRS");
39
40 /* Write GpioInt() as default (if set) or custom from devicetree */
41 acpigen_write_resourcetemplate_header();
42 acpi_device_write_gpio(&default_gpio);
43 acpigen_write_resourcetemplate_footer();
44
45 /* Bind the cd-gpio name to the GpioInt() resource */
46 dp = acpi_dp_new_table("_DSD");
47 if (!dp)
48 return;
49 acpi_dp_add_gpio(dp, "cd-gpio", path, 0, 0, 1);
50 acpi_dp_write(dp);
51
52 acpigen_pop_len();
53}
54#endif
55
56static struct device_operations dev_ops = {
Nico Huber68680dd2020-03-31 17:34:52 +020057 .read_resources = pci_dev_read_resources,
58 .set_resources = pci_dev_set_resources,
59 .enable_resources = pci_dev_enable_resources,
Julius Wernercd49cce2019-03-05 16:53:33 -080060#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +020061 .acpi_fill_ssdt = sd_fill_ssdt,
Bora Guvendik94ee3282017-05-04 13:06:43 -070062#endif
Nico Huber68680dd2020-03-31 17:34:52 +020063 .ops_pci = &pci_dev_ops_pci,
Bora Guvendik94ee3282017-05-04 13:06:43 -070064};
65
66static const unsigned short pci_device_ids[] = {
67 PCI_DEVICE_ID_INTEL_APL_SD,
Lijian Zhaobbedef92017-07-29 16:38:38 -070068 PCI_DEVICE_ID_INTEL_CNL_SD,
Bora Guvendik94ee3282017-05-04 13:06:43 -070069 PCI_DEVICE_ID_INTEL_GLK_SD,
70 PCI_DEVICE_ID_INTEL_SKL_SD,
praveen hodagatta praneshe26c4a42018-09-20 03:49:45 +080071 PCI_DEVICE_ID_INTEL_CNP_H_SD,
Aamir Bohra9eac0392018-06-30 12:07:04 +053072 PCI_DEVICE_ID_INTEL_ICL_SD,
Ronak Kanabarda7ffb482019-02-05 01:51:13 +053073 PCI_DEVICE_ID_INTEL_CMP_SD,
Gaggery Tsai12a651c2019-12-05 11:23:20 -080074 PCI_DEVICE_ID_INTEL_CMP_H_SD,
Tan, Lean Sheng26136092020-01-20 19:13:56 -080075 PCI_DEVICE_ID_INTEL_MCC_SD,
Meera Ravindranath3f4af0d2020-02-12 16:01:22 +053076 PCI_DEVICE_ID_INTEL_JSP_SD,
Bora Guvendik94ee3282017-05-04 13:06:43 -070077 0
78};
79
80static const struct pci_driver pch_sd __pci_driver = {
81 .ops = &dev_ops,
82 .vendor = PCI_VENDOR_ID_INTEL,
83 .devices = pci_device_ids
84};