From a677feca88f7b439f238c293a754f6baf0aa93e4 Mon Sep 17 00:00:00 2001 From: Bora Guvendik Date: Wed, 14 Jun 2017 16:54:39 -0700 Subject: [PATCH] soc/intel/skylake: Use SCS common code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch uses common SCS library to setup sd card. Change-Id: I06898e30a9b39f169b35f581a3ee09238f0f40c4 Signed-off-by: Bora Guvendik Reviewed-on: https://review.coreboot.org/20217 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Philippe Mathieu-Daudé --- src/soc/intel/skylake/Kconfig | 1 + src/soc/intel/skylake/sd.c | 81 ++++++++--------------------------- 2 files changed, 18 insertions(+), 64 deletions(-) diff --git a/src/soc/intel/skylake/Kconfig b/src/soc/intel/skylake/Kconfig index fb2d94b974..b59c475459 100644 --- a/src/soc/intel/skylake/Kconfig +++ b/src/soc/intel/skylake/Kconfig @@ -63,6 +63,7 @@ config CPU_SPECIFIC_OPTIONS select SOC_INTEL_COMMON_BLOCK_RTC select SOC_INTEL_COMMON_BLOCK_SA select SOC_INTEL_COMMON_BLOCK_SATA + select SOC_INTEL_COMMON_BLOCK_SCS select SOC_INTEL_COMMON_BLOCK_SMBUS select SOC_INTEL_COMMON_BLOCK_TIMER select SOC_INTEL_COMMON_BLOCK_UART diff --git a/src/soc/intel/skylake/sd.c b/src/soc/intel/skylake/sd.c index a9469becf6..12c6abe4fd 100644 --- a/src/soc/intel/skylake/sd.c +++ b/src/soc/intel/skylake/sd.c @@ -13,76 +13,29 @@ * GNU General Public License for more details. */ -#include -#include -#include -#include -#include -#include -#include +#include #include "chip.h" -#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) -static void sd_fill_ssdt(struct device *dev) +int sd_fill_soc_gpio_info(struct acpi_gpio* gpio, struct device *dev) { config_t *config = dev->chip_info; - const char *path; - struct acpi_gpio default_gpio = { - .type = ACPI_GPIO_TYPE_INTERRUPT, - .pull = ACPI_GPIO_PULL_NONE, - .irq.mode = ACPI_IRQ_EDGE_TRIGGERED, - .irq.polarity = ACPI_IRQ_ACTIVE_BOTH, - .irq.shared = ACPI_IRQ_SHARED, - .irq.wake = ACPI_IRQ_WAKE, - .interrupt_debounce_timeout = 10000, /* 100ms */ - .pin_count = 1, - .pins = { config->sdcard_cd_gpio_default } - }; - struct acpi_dp *dp; - - if (!dev->enabled) - return; /* Nothing to write if GPIO is not set in devicetree */ - if (!config->sdcard_cd_gpio_default && !config->sdcard_cd_gpio.pins[0]) - return; + if(!config->sdcard_cd_gpio_default && !config->sdcard_cd_gpio.pins[0]) + return -1; - /* Use device path as the Scope for the SSDT */ - path = acpi_device_path(dev); - if (!path) - return; - acpigen_write_scope(path); - acpigen_write_name("_CRS"); + if (config->sdcard_cd_gpio_default) { + gpio->type = ACPI_GPIO_TYPE_INTERRUPT; + gpio->pull = ACPI_GPIO_PULL_NONE; + gpio->irq.mode = ACPI_IRQ_EDGE_TRIGGERED; + gpio->irq.polarity = ACPI_IRQ_ACTIVE_BOTH; + gpio->irq.shared = ACPI_IRQ_SHARED; + gpio->irq.wake = ACPI_IRQ_WAKE; + gpio->interrupt_debounce_timeout = 10000; /* 100ms */ + gpio->pin_count = 1; + gpio->pins[0] = config->sdcard_cd_gpio_default; + } else + gpio = &config->sdcard_cd_gpio; - /* Write GpioInt() as default (if set) or custom from devicetree */ - acpigen_write_resourcetemplate_header(); - if (config->sdcard_cd_gpio_default) - acpi_device_write_gpio(&default_gpio); - else - acpi_device_write_gpio(&config->sdcard_cd_gpio); - acpigen_write_resourcetemplate_footer(); - - /* Bind the cd-gpio name to the GpioInt() resource */ - dp = acpi_dp_new_table("_DSD"); - acpi_dp_add_gpio(dp, "cd-gpio", path, 0, 0, 1); - acpi_dp_write(dp); - - acpigen_pop_len(); + return 0; } -#endif - -static struct device_operations dev_ops = { - .read_resources = &pci_dev_read_resources, - .set_resources = &pci_dev_set_resources, - .enable_resources = &pci_dev_enable_resources, - .ops_pci = &soc_pci_ops, -#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) - .acpi_fill_ssdt_generator = &sd_fill_ssdt, -#endif -}; - -static const struct pci_driver pch_sd __pci_driver = { - .ops = &dev_ops, - .vendor = PCI_VENDOR_ID_INTEL, - .device = 0x9d2d -};