1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
4 #include <metal/machine/platform.h>
6 #ifdef METAL_SIFIVE_GPIO_BUTTONS
9 #include <metal/drivers/riscv_cpu.h>
10 #include <metal/drivers/sifive_gpio-buttons.h>
11 #include <metal/machine.h>
13 int __metal_driver_button_exist (struct metal_button *button, char *label)
15 if (strcmp(__metal_driver_sifive_gpio_button_label(button), label) == 0) {
21 struct metal_interrupt *
22 __metal_driver_button_interrupt_controller(struct metal_button *button)
24 return __metal_driver_sifive_gpio_button_interrupt_controller(button);
27 int __metal_driver_button_get_interrupt_id(struct metal_button *button)
30 struct metal_interrupt *irc;
32 irq = __metal_driver_sifive_gpio_button_interrupt_line(button);
33 irc = __metal_driver_sifive_gpio_button_interrupt_controller(button);
36 max_irq = _metal_interrupt_command_request(irc,
37 METAL_MAX_INTERRUPT_GET,
41 return _metal_interrupt_command_request(irc,
42 METAL_INDEX_INTERRUPT_GET,
46 return METAL_INTERRUPT_ID_LCMX;
49 __METAL_DEFINE_VTABLE(__metal_driver_vtable_sifive_button) = {
50 .button_vtable.button_exist = __metal_driver_button_exist,
51 .button_vtable.interrupt_controller = __metal_driver_button_interrupt_controller,
52 .button_vtable.get_interrupt_id = __metal_driver_button_get_interrupt_id,