diff options
Diffstat (limited to 'zephyr/projects/corsola/src/kingler/button.c')
-rw-r--r-- | zephyr/projects/corsola/src/kingler/button.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/zephyr/projects/corsola/src/kingler/button.c b/zephyr/projects/corsola/src/kingler/button.c new file mode 100644 index 0000000000..920069bef6 --- /dev/null +++ b/zephyr/projects/corsola/src/kingler/button.c @@ -0,0 +1,35 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* kingler button */ + +#include "button.h" +#include "cros_board_info.h" +#include "gpio.h" +#include "hooks.h" + +static void buttons_hook(void) +{ + int version; + + if (cbi_get_board_version(&version)) { + return; + } + + /* b:219891339: drop this workaround when we deprecate rev0 */ + if (version == 0) { + /* swap VOLUP/VOLDN */ + button_reassign_gpio(BUTTON_VOLUME_DOWN, GPIO_VOLUME_UP_L); + button_reassign_gpio(BUTTON_VOLUME_UP, GPIO_VOLUME_DOWN_L); + /* + * button_reassign_gpio will disable the old button interrupt + * and then enable the new button interrupt which cause the + * GPIO_VOLUME_UP_L interrupt disabled after we reassign + * BUTTON_VOLUME_UP, so we need to re-enable it here. + */ + gpio_enable_interrupt(GPIO_VOLUME_UP_L); + } +} +DECLARE_HOOK(HOOK_INIT, buttons_hook, HOOK_PRIO_DEFAULT); |