Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2017 Google Inc. |
praveen hodagatta pranesh | e26c4a4 | 2018-09-20 03:49:45 +0800 | [diff] [blame] | 5 | * Copyright (C) 2018 Intel Corporation. |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #include <arch/acpigen.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <intelblocks/sd.h> |
| 21 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 22 | #if CONFIG(HAVE_ACPI_TABLES) |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 23 | static void sd_fill_ssdt(struct device *dev) |
| 24 | { |
| 25 | const char *path; |
| 26 | struct acpi_gpio default_gpio = { 0 }; |
| 27 | struct acpi_dp *dp; |
| 28 | |
| 29 | if (!dev->enabled) |
| 30 | return; |
| 31 | |
| 32 | if (sd_fill_soc_gpio_info(&default_gpio, dev) != 0) |
| 33 | return; |
| 34 | |
| 35 | /* Use device path as the Scope for the SSDT */ |
| 36 | path = acpi_device_path(dev); |
| 37 | if (!path) |
| 38 | return; |
| 39 | acpigen_write_scope(path); |
| 40 | acpigen_write_name("_CRS"); |
| 41 | |
| 42 | /* Write GpioInt() as default (if set) or custom from devicetree */ |
| 43 | acpigen_write_resourcetemplate_header(); |
| 44 | acpi_device_write_gpio(&default_gpio); |
| 45 | acpigen_write_resourcetemplate_footer(); |
| 46 | |
| 47 | /* Bind the cd-gpio name to the GpioInt() resource */ |
| 48 | dp = acpi_dp_new_table("_DSD"); |
| 49 | if (!dp) |
| 50 | return; |
| 51 | acpi_dp_add_gpio(dp, "cd-gpio", path, 0, 0, 1); |
| 52 | acpi_dp_write(dp); |
| 53 | |
| 54 | acpigen_pop_len(); |
| 55 | } |
| 56 | #endif |
| 57 | |
| 58 | static struct device_operations dev_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 59 | .read_resources = pci_dev_read_resources, |
| 60 | .set_resources = pci_dev_set_resources, |
| 61 | .enable_resources = pci_dev_enable_resources, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 62 | #if CONFIG(HAVE_ACPI_TABLES) |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 63 | .acpi_fill_ssdt_generator = sd_fill_ssdt, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 64 | #endif |
Subrata Banik | 6bbc91a | 2017-12-07 14:55:51 +0530 | [diff] [blame] | 65 | .ops_pci = &pci_dev_ops_pci, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | static const unsigned short pci_device_ids[] = { |
| 69 | PCI_DEVICE_ID_INTEL_APL_SD, |
Lijian Zhao | bbedef9 | 2017-07-29 16:38:38 -0700 | [diff] [blame] | 70 | PCI_DEVICE_ID_INTEL_CNL_SD, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 71 | PCI_DEVICE_ID_INTEL_GLK_SD, |
| 72 | PCI_DEVICE_ID_INTEL_SKL_SD, |
praveen hodagatta pranesh | e26c4a4 | 2018-09-20 03:49:45 +0800 | [diff] [blame] | 73 | PCI_DEVICE_ID_INTEL_CNP_H_SD, |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 74 | PCI_DEVICE_ID_INTEL_ICL_SD, |
Ronak Kanabar | da7ffb48 | 2019-02-05 01:51:13 +0530 | [diff] [blame] | 75 | PCI_DEVICE_ID_INTEL_CMP_SD, |
Gaggery Tsai | 12a651c | 2019-12-05 11:23:20 -0800 | [diff] [blame] | 76 | PCI_DEVICE_ID_INTEL_CMP_H_SD, |
rkanabar | 263f129 | 2019-11-28 10:41:45 +0530 | [diff] [blame] | 77 | PCI_DEVICE_ID_INTEL_JSP_PRE_PROD_SD, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame^] | 78 | PCI_DEVICE_ID_INTEL_MCC_SD, |
Bora Guvendik | 94ee328 | 2017-05-04 13:06:43 -0700 | [diff] [blame] | 79 | 0 |
| 80 | }; |
| 81 | |
| 82 | static const struct pci_driver pch_sd __pci_driver = { |
| 83 | .ops = &dev_ops, |
| 84 | .vendor = PCI_VENDOR_ID_INTEL, |
| 85 | .devices = pci_device_ids |
| 86 | }; |