1 /*
2  * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /******************************************************************************
18  * @file     isr.c
19  * @brief    source file for the interrupt server route
20  * @version  V1.0
21  * @date     02. June 2017
22  ******************************************************************************/
23 #include <drv_common.h>
24 #include "config.h"
25 #include "soc.h"
26 
27 extern void dw_usart_irqhandler(int32_t idx);
28 extern void dw_timer_irqhandler(int32_t idx);
29 extern void dw_gpio_irqhandler(int32_t idx);
30 extern void dw_iic_irqhandler(int32_t idx);
31 extern void ck_rtc_irqhandler(int32_t idx);
32 extern void dw_spi_irqhandler(int32_t idx);
33 extern void dw_wdt_irqhandler(int32_t idx);
34 extern void ck_dma_irqhandler(int32_t idx);
35 extern void ck_aes_irqhandler(int32_t idx);
36 extern void ck_sha_irqhandler(int32_t idx);
37 #ifdef CONFIG_KERNEL_FREERTOS
38 extern void CKTimer1Isr(void);
39 extern void CKPendSVIsr(void);
40 #endif
41 
42 #define readl(addr) \
43     ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
44 
CORET_IRQHandler(void)45 __attribute__((isr)) void CORET_IRQHandler(void)
46 {
47     readl(0xE000E010);
48 }
49 
50 #if defined(CONFIG_USART)
51 /*
52 __attribute__((isr)) void USART0_IRQHandler(void)
53 {
54     dw_usart_irqhandler(0);
55 }
56 
57 
58 __attribute__((isr)) void USART1_IRQHandler(void)
59 {
60     dw_usart_irqhandler(1);
61 }
62 
63 
64 __attribute__((isr)) void USART2_IRQHandler(void)
65 {
66     dw_usart_irqhandler(2);
67 }
68 
69 __attribute__((isr)) void USART3_IRQHandler(void)
70 {
71     dw_usart_irqhandler(3);
72 }
73 */
74 #endif
75 
76 #if defined(CONFIG_TIMER)
TIMA0_IRQHandler(void)77 __attribute__((isr)) void TIMA0_IRQHandler(void)
78 {
79     dw_timer_irqhandler(0);
80 }
81 
TIMA1_IRQHandler(void)82 __attribute__((isr)) void TIMA1_IRQHandler(void)
83 {
84     dw_timer_irqhandler(1);
85 }
TIMB0_IRQHandler(void)86 __attribute__((isr)) void TIMB0_IRQHandler(void)
87 {
88     dw_timer_irqhandler(2);
89 }
90 
TIMB1_IRQHandler(void)91 __attribute__((isr)) void TIMB1_IRQHandler(void)
92 {
93     dw_timer_irqhandler(3);
94 }
95 
96 #endif
97 
98 #if defined(CONFIG_GPIO)
99 
GPIOA_IRQHandler(void)100 __attribute__((isr)) void GPIOA_IRQHandler(void)
101 {
102     dw_gpio_irqhandler(0);
103 }
104 
GPIOB_IRQHandler(void)105 __attribute__((isr)) void GPIOB_IRQHandler(void)
106 {
107     dw_gpio_irqhandler(1);
108 }
109 #endif
110 
111 #if defined(CONFIG_IIC)
I2C0_IRQHandler(void)112 __attribute__((isr)) void I2C0_IRQHandler(void)
113 {
114     dw_iic_irqhandler(0);
115 }
116 
I2C1_IRQHandler(void)117 __attribute__((isr)) void I2C1_IRQHandler(void)
118 {
119     dw_iic_irqhandler(1);
120 }
121 #endif
122 
123 #if defined(CONFIG_RTC)
124 
RTC_IRQHandler(void)125 __attribute__((isr)) void RTC_IRQHandler(void)
126 {
127     ck_rtc_irqhandler(0);
128 }
129 
130 #endif
131 
132 #if defined(CONFIG_AES)
133 
AES_IRQHandler(void)134 __attribute__((isr)) void AES_IRQHandler(void)
135 {
136     ck_aes_irqhandler(0);
137 }
138 
139 #endif
140 
141 #if defined(CONFIG_SHA)
142 
SHA_IRQHandler(void)143 __attribute__((isr)) void SHA_IRQHandler(void)
144 {
145     ck_sha_irqhandler(0);
146 }
147 
148 #endif
149 
150 #if defined(CONFIG_SPI) && defined(CONFIG_GPIO)
SPI0_IRQHandler(void)151 __attribute__((isr)) void SPI0_IRQHandler(void)
152 {
153     dw_spi_irqhandler(0);
154 }
155 
SPI1_IRQHandler(void)156 __attribute__((isr)) void SPI1_IRQHandler(void)
157 {
158     dw_spi_irqhandler(1);
159 }
160 #endif
161 
162 #if defined(CONFIG_WDT)
WDT_IRQHandler(void)163 __attribute__((isr)) void WDT_IRQHandler(void)
164 {
165     dw_wdt_irqhandler(0);
166 }
167 #endif
168 
169 #if defined(CONFIG_DMAC)
DMAC_IRQHandler(void)170 __attribute__((isr)) void DMAC_IRQHandler(void)
171 {
172     ck_dma_irqhandler(0);
173 }
174 #endif
175