Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | <:copyright-BRCM:2016:DUAL/GPL:standard |
| 3 | |
| 4 | Broadcom Proprietary and Confidential.(c) 2016 Broadcom |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Unless you and Broadcom execute a separate written software license |
| 8 | agreement governing use of this software, this software is licensed |
| 9 | to you under the terms of the GNU General Public License version 2 |
| 10 | (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| 11 | with the following added to such license: |
| 12 | |
| 13 | As a special exception, the copyright holders of this software give |
| 14 | you permission to link this software with independent modules, and |
| 15 | to copy and distribute the resulting executable under terms of your |
| 16 | choice, provided that you also meet, for each linked independent |
| 17 | module, the terms and conditions of the license of that module. |
| 18 | An independent module is a module which is not derived from this |
| 19 | software. The special exception does not apply to any modifications |
| 20 | of the software. |
| 21 | |
| 22 | Not withstanding the above, under no circumstances may you combine |
| 23 | this software in any way with any other Broadcom software provided |
| 24 | under a license other than the GPL, without Broadcom's express prior |
| 25 | written consent. |
| 26 | |
| 27 | :> |
| 28 | */ |
| 29 | |
| 30 | #include "bcmos_system.h" |
| 31 | #include "bcmtr_pcie.h" |
| 32 | #include "bcmolt_tr_pcie_specific.h" |
| 33 | |
| 34 | extern f_bcmtr_int bcmtr_pcie_rx_irq_handler; |
| 35 | extern f_bcmtr_int bcmtr_pcie_tx_irq_handler; |
| 36 | static bcmos_fastlock isr_lock; |
| 37 | |
| 38 | /***************************************************************/ |
| 39 | /* need to pass thru all the devices - check if irq is SHARED */ |
| 40 | /***************************************************************/ |
| 41 | static int bcmtr_rx_isr(int irq, void *isr_info) |
| 42 | { |
| 43 | uint32_t isr_reg; |
| 44 | uint32_t mask_reg; |
| 45 | long flags; |
| 46 | int handled = 0; |
| 47 | bcm_pcied_isr_data *isr_data = (bcm_pcied_isr_data *)isr_info; |
| 48 | |
| 49 | flags = bcmos_fastlock_lock(&isr_lock); |
| 50 | |
| 51 | isr_reg = bcm_pci_read32((uint32_t*)(isr_data->pcie_reg_base + DMA_INTR_STATUS)); |
| 52 | mask_reg = ~bcm_pci_read32((uint32_t*)(isr_data->pcie_reg_base + DMA_INTR_MASK_STATUS)); |
| 53 | |
| 54 | if ((isr_reg & mask_reg)& DMA_TX_DONE_MASK) |
| 55 | { |
| 56 | /* handle TX DONE interrupt */ |
| 57 | isr_data->tx_done_num++; |
| 58 | |
| 59 | if (bcmtr_pcie_tx_irq_handler) |
| 60 | bcmtr_pcie_tx_irq_handler(isr_data->device); |
| 61 | |
| 62 | handled = 1; |
| 63 | } |
| 64 | |
| 65 | if ((isr_reg & mask_reg ) & DMA_RX_DONE_MASK) |
| 66 | { |
| 67 | /* handle RX DONE interrupt */ |
| 68 | isr_data->rx_done_num++; |
| 69 | |
| 70 | if (bcmtr_pcie_rx_irq_handler) |
| 71 | bcmtr_pcie_rx_irq_handler(isr_data->device); |
| 72 | |
| 73 | handled = 1; |
| 74 | } |
| 75 | |
| 76 | if (isr_reg & (DMA_RX_ERROR_MASK | DMA_TX_ERROR_MASK)) |
| 77 | { |
| 78 | if (isr_reg & DMA_RX_ERROR_MASK) |
| 79 | isr_data->rx_err_num++; |
| 80 | if (isr_reg & DMA_TX_ERROR_MASK) |
| 81 | isr_data->tx_err_num++; |
| 82 | /* clear interrupt error interrupt */ |
| 83 | bcm_pci_write32((uint32_t*)(isr_data->pcie_reg_base + DMA_INTR_CLEAR), DMA_RX_ERROR_MASK | DMA_TX_ERROR_MASK); |
| 84 | handled = 1; |
| 85 | } |
| 86 | |
| 87 | bcmos_fastlock_unlock(&isr_lock, flags); |
| 88 | |
| 89 | return handled; |
| 90 | } |
| 91 | |
| 92 | void bcmtr_connect_isr(void *isr_info) |
| 93 | { |
| 94 | uint32_t flags = 0; |
| 95 | |
| 96 | bcm_pcied_isr_data *isr_data = (bcm_pcied_isr_data *)isr_info; |
| 97 | bcmos_fastlock_init(&isr_lock, flags); |
| 98 | /* connect interrupt to system cpu - 0 */ |
| 99 | bcmos_int_connect((int)isr_data->rx_irq, 0, BCMOS_IRQ_SHARED, bcmtr_rx_isr, "dmaisr", isr_data); |
| 100 | } |
| 101 | |
| 102 | #ifdef __KERNEL__ |
| 103 | EXPORT_SYMBOL(bcmtr_connect_isr); |
| 104 | #endif |
| 105 | |
| 106 | |