blob: ec5f6e8cac5a78aa140b456628344d8864851293 [file] [log] [blame]
Bora Guvendik94ee3282017-05-04 13:06:43 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2017 Google Inc.
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/acpigen.h>
17#include <device/pci.h>
18#include <device/pci_ids.h>
19#include <intelblocks/sd.h>
20
21#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
22static void sd_fill_ssdt(struct device *dev)
23{
24 const char *path;
25 struct acpi_gpio default_gpio = { 0 };
26 struct acpi_dp *dp;
27
28 if (!dev->enabled)
29 return;
30
31 if (sd_fill_soc_gpio_info(&default_gpio, dev) != 0)
32 return;
33
34 /* Use device path as the Scope for the SSDT */
35 path = acpi_device_path(dev);
36 if (!path)
37 return;
38 acpigen_write_scope(path);
39 acpigen_write_name("_CRS");
40
41 /* Write GpioInt() as default (if set) or custom from devicetree */
42 acpigen_write_resourcetemplate_header();
43 acpi_device_write_gpio(&default_gpio);
44 acpigen_write_resourcetemplate_footer();
45
46 /* Bind the cd-gpio name to the GpioInt() resource */
47 dp = acpi_dp_new_table("_DSD");
48 if (!dp)
49 return;
50 acpi_dp_add_gpio(dp, "cd-gpio", path, 0, 0, 1);
51 acpi_dp_write(dp);
52
53 acpigen_pop_len();
54}
55#endif
56
57static struct device_operations dev_ops = {
58 .read_resources = &pci_dev_read_resources,
59 .set_resources = &pci_dev_set_resources,
60 .enable_resources = &pci_dev_enable_resources,
61#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
62 .acpi_fill_ssdt_generator = &sd_fill_ssdt,
63#endif
64};
65
66static const unsigned short pci_device_ids[] = {
67 PCI_DEVICE_ID_INTEL_APL_SD,
68 PCI_DEVICE_ID_INTEL_GLK_SD,
69 PCI_DEVICE_ID_INTEL_SKL_SD,
70 0
71};
72
73static const struct pci_driver pch_sd __pci_driver = {
74 .ops = &dev_ops,
75 .vendor = PCI_VENDOR_ID_INTEL,
76 .devices = pci_device_ids
77};