1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
4 #include <metal/machine/platform.h>
6 #ifdef METAL_SIFIVE_LOCAL_EXTERNAL_INTERRUPTS0
9 #include <metal/drivers/sifive_local-external-interrupts0.h>
10 #include <metal/machine.h>
12 void __metal_driver_sifive_local_external_interrupt_init(struct metal_interrupt *controller)
14 struct __metal_driver_sifive_local_external_interrupts0 *local0;
16 local0 = (struct __metal_driver_sifive_local_external_interrupts0 *)(controller);
17 if ( !local0->init_done ) {
18 struct metal_interrupt *intc =
19 __metal_driver_sifive_local_external_interrupts0_interrupt_parent(controller);
22 /* Register its interruptswith with parent controller, aka all external to default isr */
24 i < __metal_driver_sifive_local_external_interrupts0_num_interrupts(controller);
26 intc->vtable->interrupt_register(intc,
27 __metal_driver_sifive_local_external_interrupts0_interrupt_lines(controller, i),
30 local0->init_done = 1;
35 int __metal_driver_sifive_local_external_interrupt_register(struct metal_interrupt *controller,
36 int id, metal_interrupt_handler_t isr,
42 struct metal_interrupt *intc =
43 __metal_driver_sifive_local_external_interrupts0_interrupt_parent(controller);
45 /* Enable its interrupts with parent controller */
47 rc = intc->vtable->interrupt_register(intc, id, isr, priv);
53 int __metal_driver_sifive_local_external_interrupt_enable(struct metal_interrupt *controller, int id)
58 struct metal_interrupt *intc =
59 __metal_driver_sifive_local_external_interrupts0_interrupt_parent(controller);
61 /* Enable its interrupts with parent controller */
63 rc = intc->vtable->interrupt_enable(intc, id);
69 int __metal_driver_sifive_local_external_interrupt_disable(struct metal_interrupt *controller, int id)
74 struct metal_interrupt *intc =
75 __metal_driver_sifive_local_external_interrupts0_interrupt_parent(controller);
77 /* Enable its interrupts with parent controller */
79 rc = intc->vtable->interrupt_disable(intc, id);
85 int __metal_driver_sifive_local_external_interrupt_set_threshold(struct metal_interrupt *controller,
86 unsigned int threshold)
88 /* Core controller does not support threshold configuration */
92 unsigned int __metal_driver_sifive_local_external_interrupt_get_threshold(struct metal_interrupt *controller)
94 /* Core controller does not support threshold configuration */
99 int __metal_driver_sifive_local_external_interrupt_set_priority(struct metal_interrupt *controller,
100 int id, unsigned int priority)
102 /* Core controller does not support priority configuration */
106 unsigned int __metal_driver_sifive_local_external_interrupt_get_priority(struct metal_interrupt *controller, int id)
108 /* Core controller does not support priority configuration */
112 int __metal_driver_sifive_local_external_command_request (struct metal_interrupt *controller,
113 int command, void *data)
119 case METAL_MAX_INTERRUPT_GET:
120 rc = __metal_driver_sifive_local_external_interrupts0_num_interrupts(controller);
122 case METAL_INDEX_INTERRUPT_GET:
126 rc = __metal_driver_sifive_local_external_interrupts0_interrupt_lines(controller, idx);
136 __METAL_DEFINE_VTABLE(__metal_driver_vtable_sifive_local_external_interrupts0) = {
137 .local0_vtable.interrupt_init = __metal_driver_sifive_local_external_interrupt_init,
138 .local0_vtable.interrupt_register = __metal_driver_sifive_local_external_interrupt_register,
139 .local0_vtable.interrupt_enable = __metal_driver_sifive_local_external_interrupt_enable,
140 .local0_vtable.interrupt_disable = __metal_driver_sifive_local_external_interrupt_disable,
141 .local0_vtable.interrupt_get_threshold = __metal_driver_sifive_local_external_interrupt_get_threshold,
142 .local0_vtable.interrupt_set_threshold = __metal_driver_sifive_local_external_interrupt_set_threshold,
143 .local0_vtable.interrupt_get_priority = __metal_driver_sifive_local_external_interrupt_get_priority,
144 .local0_vtable.interrupt_set_priority = __metal_driver_sifive_local_external_interrupt_set_priority,
145 .local0_vtable.command_request = __metal_driver_sifive_local_external_command_request,
150 typedef int no_empty_translation_units;