|
| 1 | +/* |
| 2 | + * Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD) |
| 3 | + * Copyright (c) 2023 Alp Sayin <[email protected]> |
| 4 | + * |
| 5 | + * SPDX-License-Identifier: Apache-2.0 |
| 6 | + */ |
| 7 | + |
| 8 | + |
| 9 | +#include "soc.h" |
| 10 | + |
| 11 | +#include <zephyr/device.h> |
| 12 | +#include <zephyr/init.h> |
| 13 | +#include <zephyr/kernel.h> |
| 14 | + |
| 15 | +#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL |
| 16 | +#include <zephyr/logging/log.h> |
| 17 | +LOG_MODULE_REGISTER(soc); |
| 18 | + |
| 19 | +#ifdef CONFIG_XLNX_INTC |
| 20 | + |
| 21 | +/** |
| 22 | + * @brief Override arch_irq_enable with a call to Xintc driver |
| 23 | + * |
| 24 | + * @param irq irq number to enable |
| 25 | + */ |
| 26 | +void arch_irq_enable(uint32_t irq) |
| 27 | +{ |
| 28 | + xlnx_intc_irq_enable(irq); |
| 29 | +} |
| 30 | + |
| 31 | +/** |
| 32 | + * @brief Override arch_irq_disable with a call to Xintc driver |
| 33 | + * |
| 34 | + * @param irq irq number to disable |
| 35 | + */ |
| 36 | +void arch_irq_disable(uint32_t irq) |
| 37 | +{ |
| 38 | + xlnx_intc_irq_disable(irq); |
| 39 | +} |
| 40 | + |
| 41 | +/** |
| 42 | + * @brief Override arch_irq_is_enabled with a call to Xintc driver |
| 43 | + * |
| 44 | + * @param irq irq number to see if enabled |
| 45 | + */ |
| 46 | +int arch_irq_is_enabled(unsigned int irq) |
| 47 | +{ |
| 48 | + return BIT(irq) & xlnx_intc_irq_get_enabled(); |
| 49 | +} |
| 50 | + |
| 51 | +/** |
| 52 | + * @brief Returns the currently pending interrupts. |
| 53 | + * |
| 54 | + * @return Pending IRQ bitmask. Pending IRQs will have their bitfield set to 1. 0 if no interrupt is |
| 55 | + * pending. |
| 56 | + */ |
| 57 | +uint32_t arch_irq_pending(void) |
| 58 | +{ |
| 59 | + return xlnx_intc_irq_pending(); |
| 60 | +}; |
| 61 | + |
| 62 | +/** |
| 63 | + * @brief Returns the vector for highest pending interrupt. |
| 64 | + * |
| 65 | + * @return Returns the vector for (i.e. index) for highest-prio/lowest-num pending interrupt to be |
| 66 | + * used in a jump table. This is used used for sw_isr_table. |
| 67 | + */ |
| 68 | +uint32_t arch_irq_pending_vector(uint32_t ipending) |
| 69 | +{ |
| 70 | + ARG_UNUSED(ipending); |
| 71 | + return xlnx_intc_irq_pending_vector(); |
| 72 | +} |
| 73 | + |
| 74 | +#endif /* #ifdef CONFIG_XLNX_INTC */ |
| 75 | + |
| 76 | +/** |
| 77 | + * |
| 78 | + * @brief Perform basic hardware initialization |
| 79 | + * |
| 80 | + * @return 0 |
| 81 | + */ |
| 82 | +static int soc_init(void) |
| 83 | +{ |
| 84 | + return 0; |
| 85 | +} |
| 86 | + |
| 87 | +SYS_INIT(soc_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); |
0 commit comments