]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/edma3_lld.git/blob - packages/ti/sdo/edma3/rm/sample/src/platforms/sample_ti816x_m3vpss_int_reg.c
79347dc020f105c03f9630daa5003f1fdb6fe122
[keystone-rtos/edma3_lld.git] / packages / ti / sdo / edma3 / rm / sample / src / platforms / sample_ti816x_m3vpss_int_reg.c
1 /*
2  * sample_dm740_int_reg.c
3  *
4  * Platform specific interrupt registration and un-registration routines.
5  *
6  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
7  *
8  *
9  *  Redistribution and use in source and binary forms, with or without
10  *  modification, are permitted provided that the following conditions
11  *  are met:
12  *
13  *    Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  *
16  *    Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the
19  *    distribution.
20  *
21  *    Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37 */
39 #include <ti/sysbios/knl/Semaphore.h>
41 #include <ti/sysbios/hal/Hwi.h>
42 #include <xdc/runtime/Error.h>
43 #include <xdc/runtime/System.h>
45 #include <ti/sdo/edma3/rm/sample/bios6_edma3_rm_sample.h>
47 // #include <stdio.h>
48 /**
49   * EDMA3 TC ISRs which need to be registered with the underlying OS by the user
50   * (Not all TC error ISRs need to be registered, register only for the
51   * available Transfer Controllers).
52   */
53 void (*ptrEdma3TcIsrHandler[EDMA3_MAX_TC])(unsigned int arg) =
54                                                 {
55                                                 &lisrEdma3TC0ErrHandler0,
56                                                 &lisrEdma3TC1ErrHandler0,
57                                                 &lisrEdma3TC2ErrHandler0,
58                                                 &lisrEdma3TC3ErrHandler0,
59                                                 &lisrEdma3TC4ErrHandler0,
60                                                 &lisrEdma3TC5ErrHandler0,
61                                                 &lisrEdma3TC6ErrHandler0,
62                                                 &lisrEdma3TC7ErrHandler0,
63                                                 };
65 extern unsigned int ccXferCompInt[][EDMA3_MAX_REGIONS];
66 extern unsigned int ccErrorInt[];
67 extern unsigned int tcErrorInt[][EDMA3_MAX_TC];
68 extern unsigned int numEdma3Tc[];
70 /**
71  * Variables which will be used internally for referring the hardware interrupt
72  * for various EDMA3 interrupts.
73  */
74 extern unsigned int hwIntXferComp;
75 extern unsigned int hwIntCcErr;
76 extern unsigned int hwIntTcErr;
78 extern unsigned int dsp_num;
79 /* This variable has to be used as an extern */
80 //unsigned int gpp_num = 4;
82 Hwi_Handle hwiCCXferCompInt;
83 Hwi_Handle hwiCCErrInt;
84 Hwi_Handle hwiTCErrInt[EDMA3_MAX_TC];
86 /**  To Register the ISRs with the underlying OS, if required. */
87 void registerEdma3Interrupts (unsigned int edma3Id)
88     {
89     static UInt32 cookie = 0;
90     unsigned int numTc = 0;
91     Hwi_Params hwiParams; 
92     Error_Block      eb;
94     /* Initialize the Error Block                                             */
95     Error_init(&eb);
96         
97     /* Disabling the global interrupts */
98     cookie = Hwi_disable();
100     /* Initialize the HWI parameters with user specified values */
101     Hwi_Params_init(&hwiParams);
102     
103     /* argument for the ISR */
104     hwiParams.arg = edma3Id;
105         /* set the priority ID     */
106         hwiParams.priority = hwIntXferComp;
107         //hwiParams.enableInt = TRUE;
108     
109     hwiCCXferCompInt = Hwi_create( ccXferCompInt[edma3Id][dsp_num],
110                                         (&lisrEdma3ComplHandler0),
111                                         (const Hwi_Params *) (&hwiParams),
112                                         &eb);
113     if (TRUE == Error_check(&eb))
114     {
115         System_printf("HWI Create Failed\n",Error_getCode(&eb));
116     }
118         #if 0
119     /* Initialize the HWI parameters with user specified values */
120     Hwi_Params_init(&hwiParams);
121     /* argument for the ISR */
122     hwiParams.arg = edma3Id;
123         /* set the priority ID     */
124         hwiParams.priority = hwIntCcErr;
125         //hwiParams.enableInt = TRUE;
126         
127         hwiCCErrInt = Hwi_create( ccErrorInt[edma3Id],
128                 (&lisrEdma3CCErrHandler0),
129                 (const Hwi_Params *) (&hwiParams),
130                 &eb);
132     if (TRUE == Error_check(&eb))
133     {
134         System_printf("HWI Create Failed\n",Error_getCode(&eb));
135     }
137     while (numTc < numEdma3Tc[edma3Id])
138             {
139         /* Initialize the HWI parameters with user specified values */
140         Hwi_Params_init(&hwiParams);
141         /* argument for the ISR */
142         hwiParams.arg = edma3Id;
143         /* set the priority ID     */
144         hwiParams.priority = hwIntTcErr;
145                 //hwiParams.enableInt = TRUE;
146         
147         hwiTCErrInt[numTc] = Hwi_create( tcErrorInt[edma3Id][numTc],
148                     (ptrEdma3TcIsrHandler[numTc]),
149                     (const Hwi_Params *) (&hwiParams),
150                     &eb);
151         if (TRUE == Error_check(&eb))
152         {
153             System_printf("HWI Create Failed\n",Error_getCode(&eb));
154         }
155         numTc++;
156         }
157    /**
158     * Enabling the HWI_ID.
159     * EDMA3 interrupts (transfer completion, CC error etc.)
160     * correspond to different ECM events (SoC specific). These ECM events come
161     * under ECM block XXX (handling those specific ECM events). Normally, block
162     * 0 handles events 4-31 (events 0-3 are reserved), block 1 handles events
163     * 32-63 and so on. This ECM block XXX (or interrupt selection number XXX)
164     * is mapped to a specific HWI_INT YYY in the tcf file. So to enable this
165     * mapped HWI_INT YYY, one should use the corresponding bitmask in the
166     * API C64_enableIER(), in which the YYY bit is SET.
167     */
168     Hwi_enableInterrupt(ccErrorInt[edma3Id]);
169 #if 0
170     Hwi_enableInterrupt(13);
171 #endif
172     Hwi_enableInterrupt(ccXferCompInt[edma3Id][dsp_num]);
173     numTc = 0;
174     while (numTc < numEdma3Tc[edma3Id])
175             {
176         Hwi_enableInterrupt(tcErrorInt[edma3Id][numTc]);
177         numTc++;
178         }
179         #endif
181     /* Restore interrupts */
182     Hwi_restore(cookie);
183     }
185 /**  To Unregister the ISRs with the underlying OS, if previously registered. */
186 void unregisterEdma3Interrupts (unsigned int edma3Id)
187     {
188         static UInt32 cookie = 0;
189     unsigned int numTc = 0;
191     /* Disabling the global interrupts */
192     cookie = Hwi_disable();
194     Hwi_delete(&hwiCCXferCompInt);
195     Hwi_delete(&hwiCCErrInt);
196     while (numTc < numEdma3Tc[edma3Id])
197             {
198         Hwi_delete(&hwiTCErrInt[numTc]);
199         numTc++;
200         }
201     /* Restore interrupts */
202     Hwi_restore(cookie);
203     }