1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
4 #include <metal/machine/platform.h>
6 #ifdef METAL_SIFIVE_GPIO_SWITCHES
9 #include <metal/drivers/riscv_cpu.h>
10 #include <metal/drivers/sifive_gpio-switches.h>
11 #include <metal/machine.h>
13 int __metal_driver_switch_exist (struct metal_switch *flip, char *label)
15 if (strcmp(__metal_driver_sifive_gpio_switch_label(flip), label) == 0) {
21 struct metal_interrupt *
22 __metal_driver_switch_interrupt_controller(struct metal_switch *flip)
24 return __metal_driver_sifive_gpio_switch_interrupt_controller(flip);
27 int __metal_driver_switch_get_interrupt_id(struct metal_switch *flip)
30 struct metal_interrupt *irc;
32 irq = __metal_driver_sifive_gpio_switch_interrupt_line(flip);
33 irc = __metal_driver_sifive_gpio_switch_interrupt_controller(flip);
35 max_irq = _metal_interrupt_command_request(irc,
36 METAL_MAX_INTERRUPT_GET,
40 return _metal_interrupt_command_request(irc,
41 METAL_INDEX_INTERRUPT_GET,
45 return METAL_INTERRUPT_ID_LCMX;
48 __METAL_DEFINE_VTABLE(__metal_driver_vtable_sifive_switch) = {
49 .switch_vtable.switch_exist = __metal_driver_switch_exist,
50 .switch_vtable.interrupt_controller = __metal_driver_switch_interrupt_controller,
51 .switch_vtable.get_interrupt_id = __metal_driver_switch_get_interrupt_id,
56 typedef int no_empty_translation_units;