Angel Pons | 3bd1e3d | 2020-04-05 15:47:17 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Duncan Laurie | b25a45c | 2016-05-10 15:56:16 -0700 | [diff] [blame] | 2 | |
Bora Guvendik | a677fec | 2017-06-14 16:54:39 -0700 | [diff] [blame] | 3 | #include <intelblocks/sd.h> |
Duncan Laurie | b25a45c | 2016-05-10 15:56:16 -0700 | [diff] [blame] | 4 | #include "chip.h" |
| 5 | |
Furquan Shaikh | 3b54fdf | 2020-04-24 21:52:27 -0700 | [diff] [blame] | 6 | int sd_fill_soc_gpio_info(struct acpi_gpio* gpio, const struct device *dev) |
Duncan Laurie | b25a45c | 2016-05-10 15:56:16 -0700 | [diff] [blame] | 7 | { |
Kyösti Mälkki | 8950cfb | 2019-07-13 22:16:25 +0300 | [diff] [blame] | 8 | config_t *config = config_of(dev); |
Duncan Laurie | b25a45c | 2016-05-10 15:56:16 -0700 | [diff] [blame] | 9 | |
| 10 | /* Nothing to write if GPIO is not set in devicetree */ |
Bora Guvendik | a677fec | 2017-06-14 16:54:39 -0700 | [diff] [blame] | 11 | if(!config->sdcard_cd_gpio_default && !config->sdcard_cd_gpio.pins[0]) |
| 12 | return -1; |
Duncan Laurie | b25a45c | 2016-05-10 15:56:16 -0700 | [diff] [blame] | 13 | |
Bora Guvendik | a677fec | 2017-06-14 16:54:39 -0700 | [diff] [blame] | 14 | 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 Garber | e1909ee | 2019-05-14 16:14:57 -0600 | [diff] [blame] | 25 | *gpio = config->sdcard_cd_gpio; |
Duncan Laurie | b25a45c | 2016-05-10 15:56:16 -0700 | [diff] [blame] | 26 | |
Bora Guvendik | a677fec | 2017-06-14 16:54:39 -0700 | [diff] [blame] | 27 | return 0; |
Duncan Laurie | b25a45c | 2016-05-10 15:56:16 -0700 | [diff] [blame] | 28 | } |