Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <amdblocks/gpio_banks.h> |
| 5 | #include <amdblocks/acpimmio.h> |
Felix Held | a5a5295 | 2020-12-01 18:14:01 +0100 | [diff] [blame^] | 6 | #include <amdblocks/smi.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 7 | #include <soc/gpio.h> |
| 8 | #include <soc/smi.h> |
| 9 | |
| 10 | static const struct soc_amd_event gpio_event_table[] = { |
Marshall Dawson | 2e0f278 | 2019-06-14 09:51:02 -0600 | [diff] [blame] | 11 | { GPIO_0, GEVENT_21 }, /* GPIO0 may only be used as PWR_BTN_L in ACPI */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 12 | { GPIO_1, GEVENT_19 }, |
| 13 | { GPIO_2, GEVENT_8 }, |
| 14 | { GPIO_3, GEVENT_2 }, |
| 15 | { GPIO_4, GEVENT_4 }, |
| 16 | { GPIO_5, GEVENT_7 }, |
| 17 | { GPIO_6, GEVENT_10 }, |
| 18 | { GPIO_7, GEVENT_11 }, |
| 19 | { GPIO_8, GEVENT_23 }, |
| 20 | { GPIO_9, GEVENT_22 }, |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 21 | { GPIO_16, GEVENT_12 }, |
| 22 | { GPIO_17, GEVENT_13 }, |
| 23 | { GPIO_18, GEVENT_14 }, |
| 24 | { GPIO_21, GEVENT_5 }, |
| 25 | { GPIO_22, GEVENT_3 }, |
| 26 | { GPIO_23, GEVENT_16 }, |
| 27 | { GPIO_24, GEVENT_15 }, |
Marshall Dawson | 2e0f278 | 2019-06-14 09:51:02 -0600 | [diff] [blame] | 28 | { GPIO_40, GEVENT_20 }, |
| 29 | { GPIO_84, GEVENT_18 }, |
| 30 | { GPIO_86, GEVENT_9 }, |
| 31 | { GPIO_89, GEVENT_0 }, |
| 32 | { GPIO_90, GEVENT_1 }, |
| 33 | { GPIO_91, GEVENT_6 }, |
| 34 | { GPIO_129, GEVENT_17 }, |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | void soc_route_sci(uint8_t event) |
| 38 | { |
| 39 | smi_write8(SMI_SCI_MAP(event), event); |
| 40 | } |
| 41 | |
| 42 | void soc_get_gpio_event_table(const struct soc_amd_event **table, size_t *items) |
| 43 | { |
| 44 | *table = gpio_event_table; |
| 45 | *items = ARRAY_SIZE(gpio_event_table); |
| 46 | } |
| 47 | |
| 48 | void soc_gpio_hook(uint8_t gpio, uint8_t mux) |
| 49 | { |
| 50 | /* Always program Gevent when WAKE_L_AGPIO2 is configured as WAKE_L */ |
| 51 | if ((gpio == 2) && !(mux & AMD_GPIO_MUX_MASK)) |
| 52 | soc_route_sci(GPIO_2_EVENT); |
| 53 | } |