]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - packages/ti/sdo/ipc/family/dm6446/InterruptDsp.c
Added linux-side executable, libraries and object files to the .gitignore list
[ipc/ipcdev.git] / packages / ti / sdo / ipc / family / dm6446 / InterruptDsp.c
1 /*
2  * Copyright (c) 2012-2013, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  *  ======== InterruptDsp.c ========
34  *  DM6446 based interrupt manager.
35  */
37 #include <xdc/std.h>
38 #include <xdc/runtime/Assert.h>
40 #include <ti/sysbios/family/c64p/Hwi.h>
42 #include <ti/sdo/ipc/Ipc.h>
43 #include <ti/sdo/ipc/notifyDrivers/IInterrupt.h>
45 #include "package/internal/InterruptDsp.xdc.h"
47 /* Bit mask operations */
48 #define SET_BIT(num,pos)    ((num) |= (1u << (pos)))
49 #define CLEAR_BIT(num,pos)  ((num) &= ~(1u << (pos)))
51 /* register use to generate interrupt between cores */
52 #define INTGENREG   0x01C40010
54 /* event ids associated with inter-core interrupts */
55 #define DSP_INT0 16
56 #define DSP_INT1 17
57 #define DSP_INT2 18
58 #define DSP_INT3 19
60 #define ARM_INT0 46
61 #define ARM_INT1 47
63 /*
64  *************************************************************************
65  *                      Module functions
66  *************************************************************************
67  */
69 /*!
70  *  ======== InterruptDsp_intEnable ========
71  *  Enable GPP interrupt
72  */
73 Void InterruptDsp_intEnable(UInt16 remoteProcId, IInterrupt_IntInfo *intInfo)
74 {
75     Hwi_enableInterrupt(intInfo->intVectorId);
76 }
78 /*!
79  *  ======== InterruptDsp_intDisable ========
80  *  Disables GPP interrupt
81  */
82 Void InterruptDsp_intDisable(UInt16 remoteProcId, IInterrupt_IntInfo *intInfo)
83 {
84     Hwi_disableInterrupt(intInfo->intVectorId);
85 }
87 /*!
88  *  ======== InterruptDsp_intRegister ========
89  *  Register ISR for remote processor interrupt
90  */
91 Void InterruptDsp_intRegister(UInt16 remoteProcId, IInterrupt_IntInfo *intInfo,
92                               Fxn func, UArg arg)
93 {
94     Hwi_Params  hwiAttrs;
95     UInt        key;
97     Assert_isTrue(intInfo->intVectorId <= 15,
98                   ti_sdo_ipc_Ipc_A_internal);
100     Assert_isTrue(intInfo->localIntId >= DSP_INT0 &&
101                   intInfo->localIntId <= DSP_INT3,
102                   ti_sdo_ipc_Ipc_A_internal);
104     Assert_isTrue(intInfo->remoteIntId == ARM_INT0 ||
105                   intInfo->remoteIntId == ARM_INT1,
106                   ti_sdo_ipc_Ipc_A_internal);
108     /* Disable global interrupts */
109     key = Hwi_disable();
111     InterruptDsp_intClear(remoteProcId, intInfo);
113     /* Register interrupt for communication between ARM and DSP */
114     Hwi_Params_init(&hwiAttrs);
115     hwiAttrs.maskSetting = Hwi_MaskingOption_SELF;
116     hwiAttrs.arg         = arg;
117     hwiAttrs.eventId     = intInfo->localIntId;
119     Hwi_create(intInfo->intVectorId,
120                (Hwi_FuncPtr)func,
121                &hwiAttrs,
122                NULL);
124     /* Restore global interrupts */
125     Hwi_restore(key);
127     /* enable the interrupt vector */
128     Hwi_enableInterrupt(intInfo->intVectorId);
131 /*!
132  *  ======== InterruptDsp_intUnregister ========
133  *  Register ISR for remote processor interrupt
134  */
135 Void InterruptDsp_intUnregister(UInt16 remoteProcId,
136                                 IInterrupt_IntInfo *intInfo)
138     Hwi_Handle  hwiHandle;
140     /* Delete the Hwi (and disable the corresponding interrupt) */
141     hwiHandle = Hwi_getHandle(intInfo->intVectorId);
142     Hwi_delete(&hwiHandle);
145 /*!
146  *  ======== InterruptDsp_intSend ========
147  *  Send interrupt to the remote processor
148  */
149 Void InterruptDsp_intSend(UInt16 remoteProcId, IInterrupt_IntInfo *intInfo,
150                           UArg arg)
152     UInt16 intBitPos;
154     switch(intInfo->remoteIntId) {
155         case ARM_INT0:
156             intBitPos = 12;
157             break;
158         case ARM_INT1:
159             intBitPos = 13;
160             break;
161     }
163     SET_BIT(*((volatile Uint32 *)INTGENREG), (intBitPos));
166 /*!
167  *  ======== InterruptDsp_intPost ========
168  */
169 Void InterruptDsp_intPost(UInt16 srcProcId, IInterrupt_IntInfo *intInfo,
170                           UArg arg)
172     UInt16 intBitPos;
174     switch(intInfo->localIntId) {
175         case DSP_INT0:
176             intBitPos = 4;
177             break;
178         case DSP_INT1:
179             intBitPos = 5;
180             break;
181         case DSP_INT2:
182             intBitPos = 6;
183             break;
184         case DSP_INT3:
185             intBitPos = 7;
186             break;
187     }
189     SET_BIT(*((volatile Uint32 *)INTGENREG), (intBitPos));
192 /*!
193  *  ======== InterruptDsp_intClear ========
194  *  Clear interrupt
195  */
196 UInt InterruptDsp_intClear(UInt16 remoteProcId, IInterrupt_IntInfo *intInfo)
198     UInt16 statBitPos;
200     switch(intInfo->localIntId) {
201         case DSP_INT0:
202             statBitPos = 20;
203             break;
204         case DSP_INT1:
205             statBitPos = 21;
206             break;
207         case DSP_INT2:
208             statBitPos = 22;
209             break;
210         case DSP_INT3:
211             statBitPos = 23;
212             break;
213     }
215     CLEAR_BIT(*((volatile Uint32 *)INTGENREG), statBitPos);
217     return (0);