]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/edma3_lld.git/blob - packages/ti/sdo/edma3/drv/sample/src/platforms/sample_omapl137_arm_int_reg.c
OMAPL137 Integration: Config files for OMAPL137EVM
[keystone-rtos/edma3_lld.git] / packages / ti / sdo / edma3 / drv / sample / src / platforms / sample_omapl137_arm_int_reg.c
1 /*
2  * sample_omapl137_int_reg.c
3  *
4  * Platform specific interrupt registration and un-registration routines.
5  *
6  * Copyright (C) 2017 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>
40 #include <ti/sysbios/hal/Hwi.h>
42 #include <ti/sdo/edma3/drv/sample/bios6_edma3_drv_sample.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 /* This variable has to be used as an extern */
75 unsigned int gpp_num = 0;
77 Hwi_Handle hwiCCXferCompInt;
78 Hwi_Handle hwiCCErrInt;
79 Hwi_Handle hwiTCErrInt[EDMA3_MAX_TC];
81 /**  To Register the ISRs with the underlying OS, if required. */
82 void registerEdma3Interrupts (unsigned int edma3Id)
83     {
84     static UInt32 cookie = 0;
85     unsigned int numTc = 0;
86     Hwi_Params hwiParams; 
87         
88     /* Disabling the global interrupts */
89     cookie = Hwi_disable();
91     /* Initialize the HWI parameters with user specified values */
92     Hwi_Params_init(&hwiParams);
93     
94     /* argument for the ISR */
95     hwiParams.arg = edma3Id;
96         /* set the priority ID     */
97         hwiParams.priority = hwIntXferComp[edma3Id];
98     
99     hwiCCXferCompInt = Hwi_create( ccXferCompInt[edma3Id][gpp_num],
100                                         (&lisrEdma3ComplHandler0),
101                                         (const Hwi_Params *) (&hwiParams),
102                                         NULL);
103     /* Initialize the HWI parameters with user specified values */
104     Hwi_Params_init(&hwiParams);
105     /* argument for the ISR */
106     hwiParams.arg = edma3Id;
107         /* set the priority ID     */
108         hwiParams.priority = hwIntCcErr[edma3Id];
109         
110         hwiCCErrInt = Hwi_create( ccErrorInt[edma3Id],
111                 (&lisrEdma3CCErrHandler0),
112                 (const Hwi_Params *) (&hwiParams),
113                 NULL);
115     while (numTc < numEdma3Tc[edma3Id])
116             {
117         /* Initialize the HWI parameters with user specified values */
118         Hwi_Params_init(&hwiParams);
119         /* argument for the ISR */
120         hwiParams.arg = edma3Id;
121         /* set the priority ID     */
122         hwiParams.priority = hwIntTcErr[edma3Id];
123         
124         hwiTCErrInt[numTc] = Hwi_create( tcErrorInt[edma3Id][numTc],
125                     (ptrEdma3TcIsrHandler[numTc]),
126                     (const Hwi_Params *) (&hwiParams),
127                     NULL);
128         numTc++;
129         }
130    /**
131     * Enabling the HWI_ID.
132     * EDMA3 interrupts (transfer completion, CC error etc.)
133     * correspond to different ECM events (SoC specific). These ECM events come
134     * under ECM block XXX (handling those specific ECM events). Normally, block
135     * 0 handles events 4-31 (events 0-3 are reserved), block 1 handles events
136     * 32-63 and so on. This ECM block XXX (or interrupt selection number XXX)
137     * is mapped to a specific HWI_INT YYY in the tcf file. So to enable this
138     * mapped HWI_INT YYY, one should use the corresponding bitmask in the
139     * API C64_enableIER(), in which the YYY bit is SET.
140     */
141     Hwi_enableInterrupt(hwIntXferComp[edma3Id]);
142     Hwi_enableInterrupt(hwIntCcErr[edma3Id]);
143     Hwi_enableInterrupt(hwIntTcErr[edma3Id]);
145     /* Restore interrupts */
146     Hwi_restore(cookie);
147     }
149 /**  To Unregister the ISRs with the underlying OS, if previously registered. */
150 void unregisterEdma3Interrupts (unsigned int edma3Id)
151     {
152         static UInt32 cookie = 0;
153     unsigned int numTc = 0;
155     /* Disabling the global interrupts */
156     cookie = Hwi_disable();
158     Hwi_delete(&hwiCCXferCompInt);
159     Hwi_delete(&hwiCCErrInt);
160     while (numTc < numEdma3Tc[edma3Id])
161             {
162         Hwi_delete(&hwiTCErrInt[numTc]);
163         numTc++;
164         }
165     /* Restore interrupts */
166     Hwi_restore(cookie);
167     }