[keystone-rtos/edma3_lld.git] / packages / ti / sdo / edma3 / drv / sample / src / platforms / sample_da830_int_reg.c
1 /*
2 * bios6_int_register_tci_6498.c
3 *
4 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the
17 * distribution.
18 *
19 * Neither the name of Texas Instruments Incorporated nor the names of
20 * its contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 */
37 #include <ti/sysbios/ipc/Semaphore.h>
38 #include <ti/sysbios/family/c64p/EventCombiner.h>
39 #include <ti/sysbios/family/c64p/Hwi.h>
41 #include <ti/sdo/edma3/drv/sample/bios6_edma3_drv_sample.h>
43 // #include <stdio.h>
44 /**
45 * EDMA3 TC ISRs which need to be registered with the underlying OS by the user
46 * (Not all TC error ISRs need to be registered, register only for the
47 * available Transfer Controllers).
48 */
49 void (*ptrEdma3TcIsrHandler[EDMA3_MAX_TC])(unsigned int arg) =
50 {
51 &lisrEdma3TC0ErrHandler0,
52 &lisrEdma3TC1ErrHandler0,
53 &lisrEdma3TC2ErrHandler0,
54 &lisrEdma3TC3ErrHandler0,
55 &lisrEdma3TC4ErrHandler0,
56 &lisrEdma3TC5ErrHandler0,
57 &lisrEdma3TC6ErrHandler0,
58 &lisrEdma3TC7ErrHandler0,
59 };
61 extern unsigned int ccXferCompInt[][EDMA3_MAX_REGIONS];
62 extern unsigned int ccErrorInt[];
63 extern unsigned int tcErrorInt[][EDMA3_MAX_TC];
64 extern unsigned int numEdma3Tc[];
66 /**
67 * Variables which will be used internally for referring the hardware interrupt
68 * for various EDMA3 interrupts.
69 */
70 extern unsigned int hwIntXferComp;
71 extern unsigned int hwIntCcErr;
72 extern unsigned int hwIntTcErr;
74 extern unsigned int dsp_num;
76 /** To Register the ISRs with the underlying OS, if required. */
77 void registerEdma3Interrupts (unsigned int edma3Id)
78 {
79 static UInt32 cookie = 0;
80 unsigned int numTc = 0;
82 /* Disabling the global interrupts */
83 cookie = Hwi_disable();
85 /* Enable the Xfer Completion Event Interrupt */
86 EventCombiner_dispatchPlug(ccXferCompInt[edma3Id][dsp_num],
87 (EventCombiner_FuncPtr)(&lisrEdma3ComplHandler0),
88 NULL, 1);
89 EventCombiner_enableEvent(ccXferCompInt[edma3Id][dsp_num]);
91 /* Enable the CC Error Event Interrupt */
92 EventCombiner_dispatchPlug(ccErrorInt[edma3Id],
93 (EventCombiner_FuncPtr)(&lisrEdma3CCErrHandler0),
94 NULL, 1);
95 EventCombiner_enableEvent(ccErrorInt[edma3Id]);
97 /* Enable the TC Error Event Interrupt, according to the number of TCs. */
98 while (numTc < numEdma3Tc[edma3Id])
99 {
100 EventCombiner_dispatchPlug(tcErrorInt[edma3Id][numTc],
101 (EventCombiner_FuncPtr)(ptrEdma3TcIsrHandler[numTc]),
102 NULL, 1);
103 EventCombiner_enableEvent(tcErrorInt[edma3Id][numTc]);
104 numTc++;
105 }
107 /**
108 * Enabling the HWI_ID.
109 * EDMA3 interrupts (transfer completion, CC error etc.)
110 * correspond to different ECM events (SoC specific). These ECM events come
111 * under ECM block XXX (handling those specific ECM events). Normally, block
112 * 0 handles events 4-31 (events 0-3 are reserved), block 1 handles events
113 * 32-63 and so on. This ECM block XXX (or interrupt selection number XXX)
114 * is mapped to a specific HWI_INT YYY in the tcf file. So to enable this
115 * mapped HWI_INT YYY, one should use the corresponding bitmask in the
116 * API C64_enableIER(), in which the YYY bit is SET.
117 */
118 Hwi_enableInterrupt(hwIntXferComp);
119 Hwi_enableInterrupt(hwIntCcErr);
120 Hwi_enableInterrupt(hwIntTcErr);
122 /* Restore interrupts */
123 Hwi_restore(cookie);
124 }
126 /** To Unregister the ISRs with the underlying OS, if previously registered. */
127 void unregisterEdma3Interrupts (unsigned int edma3Id)
128 {
129 static UInt32 cookie = 0;
130 unsigned int numTc = 0;
132 /* Disabling the global interrupts */
133 cookie = Hwi_disable();
135 /* Disable the Xfer Completion Event Interrupt */
136 EventCombiner_disableEvent(ccXferCompInt[edma3Id][dsp_num]);
138 /* Disable the CC Error Event Interrupt */
139 EventCombiner_disableEvent(ccErrorInt[edma3Id]);
141 /* Enable the TC Error Event Interrupt, according to the number of TCs. */
142 while (numTc < numEdma3Tc[edma3Id])
143 {
144 EventCombiner_disableEvent(tcErrorInt[edma3Id][numTc]);
145 numTc++;
146 }
148 /* Restore interrupts */
149 Hwi_restore(cookie);
150 }