[6319] | 1 | /***************************************************************** |
---|
| 2 | * File: w3_sw_intr.c |
---|
| 3 | * Copyright (c) 2019 Mango Communications, all rights reserved |
---|
| 4 | *****************************************************************/ |
---|
| 5 | |
---|
| 6 | #include "wlan_platform_high.h" |
---|
| 7 | #include "wlan_mac_high.h" |
---|
| 8 | #include "w3_sw_intr.h" |
---|
| 9 | #include "sw_intr_util.h" |
---|
| 10 | #include "xparameters.h" |
---|
| 11 | |
---|
| 12 | // Base address of sw_intr_util pcore for software-generated interrupts |
---|
| 13 | #define SW_INTR_BASEADDR XPAR_HIGH_SW_INTR_UTIL_BASEADDR |
---|
| 14 | |
---|
| 15 | void _sw_intr_A_handler(); |
---|
| 16 | |
---|
| 17 | int w3_sw_intr_init() { |
---|
| 18 | sw_intr_init(SW_INTR_BASEADDR); |
---|
| 19 | |
---|
| 20 | // Configure sw_intr_A to assert for one-hot interrupt IDs |
---|
| 21 | sw_intr_set_mask_A0(SW_INTR_BASEADDR, (SW_INTR_ID_PORTAL_ETH_RX | SW_INTR_ID_PORTAL_ETH_TX | SW_INTR_ID_WLAN_EXP_ETH_TX)); |
---|
| 22 | |
---|
| 23 | // Connect the ISR - sw_intr_util outputs are low after sw_intr_init() |
---|
| 24 | // Core has two interrupt outputs |
---|
| 25 | // W3 project connects INTRA to high priority, INTRB to low-priority |
---|
| 26 | wlan_platform_interrupt_connect(XPAR_INTC_0_SW_INTR_UTIL_0_INTRA_OUT_VEC_ID, (wlan_intr_handler_t)_sw_intr_A_handler, NULL); |
---|
| 27 | wlan_platform_interrupt_enable(XPAR_INTC_0_SW_INTR_UTIL_0_INTRA_OUT_VEC_ID); |
---|
| 28 | |
---|
| 29 | return WLAN_SUCCESS; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | void wlan_platform_assert_sw_intr(u32 intr_mask) { |
---|
| 33 | u32 x = sw_intr_get_state0(SW_INTR_BASEADDR); |
---|
| 34 | |
---|
| 35 | sw_intr_set_state0(SW_INTR_BASEADDR, x | intr_mask); |
---|
| 36 | } |
---|
| 37 | void wlan_platform_clear_sw_intr(u32 intr_mask) { |
---|
| 38 | u32 x = sw_intr_get_state0(SW_INTR_BASEADDR); |
---|
| 39 | |
---|
| 40 | sw_intr_set_state0(SW_INTR_BASEADDR, x & ~intr_mask); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | void wlan_platform_set_sw_intr_mask(u32 intr_mask) { |
---|
| 44 | sw_intr_set_mask_A0(SW_INTR_BASEADDR, sw_intr_get_mask_A0(SW_INTR_BASEADDR)|intr_mask); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | void wlan_platform_clear_sw_intr_mask(u32 intr_mask) { |
---|
| 48 | sw_intr_set_mask_A0(SW_INTR_BASEADDR, sw_intr_get_mask_A0(SW_INTR_BASEADDR)&~intr_mask); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | // Local functions |
---|
| 52 | void _sw_intr_A_handler(void *InstancePtr) { |
---|
| 53 | // InstancePtr is NULL for sw_intr_util interrupts |
---|
| 54 | u32 intr_state = sw_intr_get_state0(SW_INTR_BASEADDR); |
---|
| 55 | |
---|
| 56 | wlan_mac_high_sw_intr_callback(intr_state); |
---|
| 57 | } |
---|