|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Renesas Electronics Corporation |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#include <bsp_api.h> |
| 8 | +#include <zephyr/init.h> |
| 9 | +#include <zephyr/sys/barrier.h> |
| 10 | +#include <zephyr/drivers/interrupt_controller/gic.h> |
| 11 | +#include <zephyr/irq.h> |
| 12 | + |
| 13 | +extern void bsp_global_system_counter_init(void); |
| 14 | + |
| 15 | +void *gp_renesas_isr_context[BSP_ICU_VECTOR_MAX_ENTRIES + BSP_CORTEX_VECTOR_TABLE_ENTRIES]; |
| 16 | +IRQn_Type g_current_interrupt_num[32]; |
| 17 | +uint8_t g_current_interrupt_pointer; |
| 18 | + |
| 19 | +void soc_reset_hook(void) |
| 20 | +{ |
| 21 | + /* Enable peripheral port access at EL1 and EL0 */ |
| 22 | + __asm__ volatile("mrc p15, 0, r0, c15, c0, 0\n"); |
| 23 | + __asm__ volatile("orr r0, #1\n"); |
| 24 | + __asm__ volatile("mcr p15, 0, r0, c15, c0, 0\n"); |
| 25 | + barrier_dsync_fence_full(); |
| 26 | + barrier_isync_fence_full(); |
| 27 | +} |
| 28 | + |
| 29 | +void soc_early_init_hook(void) |
| 30 | +{ |
| 31 | + /* Configure system clocks. */ |
| 32 | + bsp_clock_init(); |
| 33 | + |
| 34 | + /* Initialize SystemCoreClock variable. */ |
| 35 | + SystemCoreClockUpdate(); |
| 36 | + |
| 37 | + /* Initialize global system counter. The counter is enabled and is incrementing. */ |
| 38 | + bsp_global_system_counter_init(); |
| 39 | +} |
| 40 | + |
| 41 | +unsigned int z_soc_irq_get_active(void) |
| 42 | +{ |
| 43 | + int intid = arm_gic_get_active(); |
| 44 | + |
| 45 | + g_current_interrupt_num[g_current_interrupt_pointer++] = intid; |
| 46 | + |
| 47 | + return intid; |
| 48 | +} |
| 49 | + |
| 50 | +void z_soc_irq_eoi(unsigned int intid) |
| 51 | +{ |
| 52 | + g_current_interrupt_pointer--; |
| 53 | + arm_gic_eoi(intid); |
| 54 | +} |
| 55 | + |
| 56 | +void z_soc_irq_enable(unsigned int irq) |
| 57 | +{ |
| 58 | + arm_gic_irq_enable(irq); |
| 59 | +} |
| 60 | + |
| 61 | +void z_soc_irq_disable(unsigned int irq) |
| 62 | +{ |
| 63 | + arm_gic_irq_disable(irq); |
| 64 | +} |
| 65 | + |
| 66 | +int z_soc_irq_is_enabled(unsigned int irq) |
| 67 | +{ |
| 68 | + return arm_gic_irq_is_enabled(irq); |
| 69 | +} |
| 70 | + |
| 71 | +void z_soc_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags) |
| 72 | +{ |
| 73 | + arm_gic_irq_set_priority(irq, prio, flags); |
| 74 | +} |
| 75 | + |
| 76 | +void z_soc_irq_init(void) |
| 77 | +{ |
| 78 | + g_current_interrupt_pointer = 0; |
| 79 | +} |
| 80 | + |
| 81 | +/* Porting FSP IRQ configuration by an empty function */ |
| 82 | +/* Let Zephyr handle IRQ configuration */ |
| 83 | +void bsp_irq_core_cfg(void) |
| 84 | +{ |
| 85 | + /* Do nothing */ |
| 86 | +} |
0 commit comments