blob: 1f40d982550b8f39e3830abdcb758c758dd4350f [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
Bora Guvendika677fec2017-06-14 16:54:39 -07003#include <intelblocks/sd.h>
Duncan Laurieb25a45c2016-05-10 15:56:16 -07004#include "chip.h"
5
Furquan Shaikh3b54fdf2020-04-24 21:52:27 -07006int sd_fill_soc_gpio_info(struct acpi_gpio* gpio, const struct device *dev)
Duncan Laurieb25a45c2016-05-10 15:56:16 -07007{
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +03008 config_t *config = config_of(dev);
Duncan Laurieb25a45c2016-05-10 15:56:16 -07009
10 /* Nothing to write if GPIO is not set in devicetree */
Bora Guvendika677fec2017-06-14 16:54:39 -070011 if(!config->sdcard_cd_gpio_default && !config->sdcard_cd_gpio.pins[0])
12 return -1;
Duncan Laurieb25a45c2016-05-10 15:56:16 -070013
Bora Guvendika677fec2017-06-14 16:54:39 -070014 if (config->sdcard_cd_gpio_default) {
15 gpio->type = ACPI_GPIO_TYPE_INTERRUPT;
16 gpio->pull = ACPI_GPIO_PULL_NONE;
17 gpio->irq.mode = ACPI_IRQ_EDGE_TRIGGERED;
18 gpio->irq.polarity = ACPI_IRQ_ACTIVE_BOTH;
19 gpio->irq.shared = ACPI_IRQ_SHARED;
20 gpio->irq.wake = ACPI_IRQ_WAKE;
21 gpio->interrupt_debounce_timeout = 10000; /* 100ms */
22 gpio->pin_count = 1;
23 gpio->pins[0] = config->sdcard_cd_gpio_default;
24 } else
Jacob Garbere1909ee2019-05-14 16:14:57 -060025 *gpio = 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}