blob: cfe4b8cd31025f1d19c1399e87976056e7f30bb4 [file] [log] [blame]
Angel Pons3bd1e3d2020-04-05 15:47:17 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Duncan Laurieb25a45c2016-05-10 15:56:16 -07002
Elyes Haouasd1bf9bf2022-10-31 12:27:23 +01003#include <acpi/acpi_device.h>
4#include <device/device.h>
Bora Guvendika677fec2017-06-14 16:54:39 -07005#include <intelblocks/sd.h>
Elyes Haouasd1bf9bf2022-10-31 12:27:23 +01006#include <stdint.h>
7
Duncan Laurieb25a45c2016-05-10 15:56:16 -07008#include "chip.h"
9
Angel Pons6bd99f92021-02-20 00:16:47 +010010int sd_fill_soc_gpio_info(struct acpi_gpio *gpio, const struct device *dev)
Duncan Laurieb25a45c2016-05-10 15:56:16 -070011{
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +030012 config_t *config = config_of(dev);
Duncan Laurieb25a45c2016-05-10 15:56:16 -070013
Angel Pons6bd99f92021-02-20 00:16:47 +010014 if (!config->sdcard_cd_gpio)
Bora Guvendika677fec2017-06-14 16:54:39 -070015 return -1;
Duncan Laurieb25a45c2016-05-10 15:56:16 -070016
Angel Pons6bd99f92021-02-20 00:16:47 +010017 gpio->type = ACPI_GPIO_TYPE_INTERRUPT;
18 gpio->pull = ACPI_GPIO_PULL_NONE;
19 gpio->irq.mode = ACPI_IRQ_EDGE_TRIGGERED;
20 gpio->irq.polarity = ACPI_IRQ_ACTIVE_BOTH;
21 gpio->irq.shared = ACPI_IRQ_SHARED;
22 gpio->irq.wake = ACPI_IRQ_WAKE;
23 gpio->interrupt_debounce_timeout = 10000; /* 100ms */
24 gpio->pin_count = 1;
25 gpio->pins[0] = config->sdcard_cd_gpio;
Duncan Laurieb25a45c2016-05-10 15:56:16 -070026
Bora Guvendika677fec2017-06-14 16:54:39 -070027 return 0;
Duncan Laurieb25a45c2016-05-10 15:56:16 -070028}