]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5_bsp/psu_cortexr5_0/libsrc/scugic_v3_9/src/xscugic_hw.c
Update Zynq, MPSoc Cortex-A53 and MPSoc Cortex-R5 demo projects to build with the...
[freertos] / FreeRTOS / Demo / CORTEX_R5_UltraScale_MPSoC / RTOSDemo_R5_bsp / psu_cortexr5_0 / libsrc / scugic_v3_9 / src / xscugic_hw.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 2015 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xscugic_hw.c
36 * @addtogroup scugic_v3_8
37 * @{
38 *
39 * This file contains low-level driver functions that can be used to access the
40 * device.  The user should refer to the hardware device specification for more
41 * details of the device operation.
42 * These routines are used when the user does not want to create an instance of
43 * XScuGic structure but still wants to use the ScuGic device. Hence the
44 * routines provided here take device id or scugic base address as arguments.
45 * Separate static versions of DistInit and CPUInit are provided to implement
46 * the low level driver routines.
47 *
48 * <pre>
49 * MODIFICATION HISTORY:
50 *
51 * Ver   Who  Date     Changes
52 * ----- ---- -------- -------------------------------------------------------
53 * 1.01a sdm  07/18/11 First release
54 * 1.03a srt  02/27/13 Moved Offset calculation macros from *_hw.c (CR
55 *                     702687).
56 *                                         Added support to direct interrupts to the appropriate CPU.
57 *                         Earlier interrupts were directed to CPU1 (hard coded). Now
58 *                         depending upon the CPU selected by the user (xparameters.h),
59 *                         interrupts will be directed to the relevant CPU.
60 *                         This fixes CR 699688.
61 * 1.04a hk   05/04/13 Fix for CR#705621. Moved functions
62 *                         XScuGic_SetPriTrigTypeByDistAddr and
63 *             XScuGic_GetPriTrigTypeByDistAddr here from xscugic.c
64 * 3.00  kvn  02/13/15 Modified code for MISRA-C:2012 compliance.
65 * 3.6   kvn  02/17/17 Add support for changing GIC CPU master at run time.
66 *       kvn  02/28/17 Make the CpuId as static variable and Added new
67 *                     XScugiC_GetCpuId to access CpuId.
68 * 3.9   mus  02/21/18 Added new API's XScuGic_InterruptUnmapFromCpuByDistAddr
69 *                                         and XScuGic_UnmapAllInterruptsFromCpuByDistAddr, These
70 *                                         API's can be used by applications to unmap specific/all
71 *                                         interrupts from target CPU. It fixes CR#992490.
72 *
73 * </pre>
74 *
75 ******************************************************************************/
76
77
78 /***************************** Include Files *********************************/
79
80 #include "xil_types.h"
81 #include "xil_assert.h"
82 #include "xscugic.h"
83 #include "xparameters.h"
84
85 /************************** Constant Definitions *****************************/
86
87 /**************************** Type Definitions *******************************/
88
89 /***************** Macros (Inline Functions) Definitions *********************/
90
91 /************************** Function Prototypes ******************************/
92
93 static void DistInit(XScuGic_Config *Config, u32 CpuID);
94 static void CPUInit(XScuGic_Config *Config);
95 static XScuGic_Config *LookupConfigByBaseAddress(u32 CpuBaseAddress);
96
97 /************************** Variable Definitions *****************************/
98
99 extern XScuGic_Config XScuGic_ConfigTable[XPAR_XSCUGIC_NUM_INSTANCES];
100 extern u32 CpuId;
101
102 /*****************************************************************************/
103 /**
104 *
105 * DistInit initializes the distributor of the GIC. The
106 * initialization entails:
107 *
108 * - Write the trigger mode, priority and target CPU
109 * - All interrupt sources are disabled
110 * - Enable the distributor
111 *
112 * @param        InstancePtr is a pointer to the XScuGic instance.
113 * @param        CpuID is the Cpu ID to be initialized.
114 *
115 * @return       None
116 *
117 * @note         None.
118 *
119 ******************************************************************************/
120 static void DistInit(XScuGic_Config *Config, u32 CpuID)
121 {
122         u32 Int_Id;
123         u32 LocalCpuID = CpuID;
124
125 #if USE_AMP==1
126         #warning "Building GIC for AMP"
127
128         /*
129          * The distrubutor should not be initialized by FreeRTOS in the case of
130          * AMP -- it is assumed that Linux is the master of this device in that
131          * case.
132          */
133         return;
134 #endif
135
136         XScuGic_WriteReg(Config->DistBaseAddress, XSCUGIC_DIST_EN_OFFSET, 0U);
137
138         /*
139          * Set the security domains in the int_security registers for non-secure
140          * interrupts. All are secure, so leave at the default. Set to 1 for
141          * non-secure interrupts.
142          */
143
144
145         /*
146          * For the Shared Peripheral Interrupts INT_ID[MAX..32], set:
147          */
148
149         /*
150          * 1. The trigger mode in the int_config register
151          * Only write to the SPI interrupts, so start at 32
152          */
153         for (Int_Id = 32U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id=Int_Id+16U) {
154         /*
155          * Each INT_ID uses two bits, or 16 INT_ID per register
156          * Set them all to be level sensitive, active HIGH.
157          */
158                 XScuGic_WriteReg(Config->DistBaseAddress,
159                         XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id), 0U);
160         }
161
162
163 #define DEFAULT_PRIORITY        0xa0a0a0a0U
164         for (Int_Id = 0U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id=Int_Id+4U) {
165                 /*
166                  * 2. The priority using int the priority_level register
167                  * The priority_level and spi_target registers use one byte per
168                  * INT_ID.
169                  * Write a default value that can be changed elsewhere.
170                  */
171                 XScuGic_WriteReg(Config->DistBaseAddress,
172                                 XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id),
173                                 DEFAULT_PRIORITY);
174         }
175
176         for (Int_Id = 32U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id=Int_Id+4U) {
177                 /*
178                  * 3. The CPU interface in the spi_target register
179                  * Only write to the SPI interrupts, so start at 32
180                  */
181                 LocalCpuID |= LocalCpuID << 8U;
182                 LocalCpuID |= LocalCpuID << 16U;
183
184                 XScuGic_WriteReg(Config->DistBaseAddress,
185                                 XSCUGIC_SPI_TARGET_OFFSET_CALC(Int_Id), LocalCpuID);
186         }
187
188         for (Int_Id = 0U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id=Int_Id+32U) {
189         /*
190          * 4. Enable the SPI using the enable_set register. Leave all disabled
191          * for now.
192          */
193                 XScuGic_WriteReg(Config->DistBaseAddress,
194                 XSCUGIC_EN_DIS_OFFSET_CALC(XSCUGIC_DISABLE_OFFSET,
195                 Int_Id),
196                 0xFFFFFFFFU);
197
198         }
199
200         XScuGic_WriteReg(Config->DistBaseAddress, XSCUGIC_DIST_EN_OFFSET,
201                                                 XSCUGIC_EN_INT_MASK);
202
203 }
204
205 /*****************************************************************************/
206 /**
207 *
208 * CPUInit initializes the CPU Interface of the GIC. The initialization entails:
209 *
210 * - Set the priority of the CPU.
211 * - Enable the CPU interface
212 *
213 * @param        ConfigPtr is a pointer to a config table for the particular
214 *               device this driver is associated with.
215 *
216 * @return       None
217 *
218 * @note         None.
219 *
220 ******************************************************************************/
221 static void CPUInit(XScuGic_Config *Config)
222 {
223         /*
224          * Program the priority mask of the CPU using the Priority mask
225          * register
226          */
227         XScuGic_WriteReg(Config->CpuBaseAddress, XSCUGIC_CPU_PRIOR_OFFSET,
228                                                                         0xF0U);
229
230         /*
231          * If the CPU operates in both security domains, set parameters in the
232          * control_s register.
233          * 1. Set FIQen=1 to use FIQ for secure interrupts,
234          * 2. Program the AckCtl bit
235          * 3. Program the SBPR bit to select the binary pointer behavior
236          * 4. Set EnableS = 1 to enable secure interrupts
237          * 5. Set EnbleNS = 1 to enable non secure interrupts
238          */
239
240         /*
241          * If the CPU operates only in the secure domain, setup the
242          * control_s register.
243          * 1. Set FIQen=1,
244          * 2. Set EnableS=1, to enable the CPU interface to signal secure .
245          * interrupts Only enable the IRQ output unless secure interrupts
246          * are needed.
247          */
248         XScuGic_WriteReg(Config->CpuBaseAddress, XSCUGIC_CONTROL_OFFSET, 0x07U);
249
250 }
251
252 /*****************************************************************************/
253 /**
254 *
255 * CfgInitialize a specific interrupt controller instance/driver. The
256 * initialization entails:
257 *
258 * - Initialize fields of the XScuGic structure
259 * - Initial vector table with stub function calls
260 * - All interrupt sources are disabled
261 *
262 * @param InstancePtr is a pointer to the XScuGic instance to be worked on.
263 * @param ConfigPtr is a pointer to a config table for the particular device
264 *        this driver is associated with.
265 * @param EffectiveAddr is the device base address in the virtual memory address
266 *        space. The caller is responsible for keeping the address mapping
267 *        from EffectiveAddr to the device physical base address unchanged
268 *        once this function is invoked. Unexpected errors may occur if the
269 *        address mapping changes after this function is called. If address
270 *        translation is not used, use Config->BaseAddress for this parameters,
271 *        passing the physical address instead.
272 *
273 * @return
274 *
275 * - XST_SUCCESS if initialization was successful
276 *
277 * @note
278 *
279 * None.
280 *
281 ******************************************************************************/
282 s32 XScuGic_DeviceInitialize(u32 DeviceId)
283 {
284         XScuGic_Config *Config;
285         u32 Cpu_Id = XScuGic_GetCpuID() + (u32)1;
286
287         Config = &XScuGic_ConfigTable[(u32 )DeviceId];
288
289         DistInit(Config, Cpu_Id);
290
291         CPUInit(Config);
292
293         return XST_SUCCESS;
294 }
295
296 /*****************************************************************************/
297 /**
298 * This function is the primary interrupt handler for the driver.  It must be
299 * connected to the interrupt source such that it is called when an interrupt of
300 * the interrupt controller is active. It will resolve which interrupts are
301 * active and enabled and call the appropriate interrupt handler. It uses
302 * the Interrupt Type information to determine when to acknowledge the
303 * interrupt.Highest priority interrupts are serviced first.
304 *
305 * This function assumes that an interrupt vector table has been previously
306 * initialized.  It does not verify that entries in the table are valid before
307 * calling an interrupt handler.
308 *
309 * @param        DeviceId is the unique identifier for the ScuGic device.
310 *
311 * @return       None.
312 *
313 * @note         None.
314 *
315 ******************************************************************************/
316 void XScuGic_DeviceInterruptHandler(void *DeviceId)
317 {
318
319         u32 InterruptID;
320         u32 IntIDFull;
321         XScuGic_VectorTableEntry *TablePtr;
322         XScuGic_Config *CfgPtr;
323
324         CfgPtr = &XScuGic_ConfigTable[(INTPTR )DeviceId];
325
326         /*
327          * Read the int_ack register to identify the highest priority
328          * interrupt ID and make sure it is valid. Reading Int_Ack will
329          * clear the interrupt in the GIC.
330          */
331         IntIDFull = XScuGic_ReadReg(CfgPtr->CpuBaseAddress, XSCUGIC_INT_ACK_OFFSET);
332         InterruptID = IntIDFull & XSCUGIC_ACK_INTID_MASK;
333         if(XSCUGIC_MAX_NUM_INTR_INPUTS < InterruptID){
334                 goto IntrExit;
335         }
336
337         /*
338          * If the interrupt is shared, do some locking here if there are
339          * multiple processors.
340          */
341         /*
342          * If pre-eption is required:
343          * Re-enable pre-emption by setting the CPSR I bit for non-secure ,
344          * interrupts or the F bit for secure interrupts
345          */
346
347         /*
348          * If we need to change security domains, issue a SMC instruction here.
349          */
350
351         /*
352          * Execute the ISR. Jump into the Interrupt service routine based on
353          * the IRQSource. A software trigger is cleared by the ACK.
354          */
355         TablePtr = &(CfgPtr->HandlerTable[InterruptID]);
356         if(TablePtr != NULL) {
357                 TablePtr->Handler(TablePtr->CallBackRef);
358         }
359
360 IntrExit:
361         /*
362          * Write to the EOI register, we are all done here.
363          * Let this function return, the boot code will restore the stack.
364          */
365         XScuGic_WriteReg(CfgPtr->CpuBaseAddress, XSCUGIC_EOI_OFFSET, IntIDFull);
366
367         /*
368          * Return from the interrupt. Change security domains could happen
369          * here.
370          */
371 }
372
373 /*****************************************************************************/
374 /**
375 *
376 * Register a handler function for a specific interrupt ID.  The vector table
377 * of the interrupt controller is updated, overwriting any previous handler.
378 * The handler function will be called when an interrupt occurs for the given
379 * interrupt ID.
380 *
381 * @param        BaseAddress is the CPU Interface Register base address of the
382 *               interrupt controller whose vector table will be modified.
383 * @param        InterruptId is the interrupt ID to be associated with the input
384 *               handler.
385 * @param        Handler is the function pointer that will be added to
386 *               the vector table for the given interrupt ID.
387 * @param        CallBackRef is the argument that will be passed to the new
388 *               handler function when it is called. This is user-specific.
389 *
390 * @return       None.
391 *
392 * @note
393 *
394 * Note that this function has no effect if the input base address is invalid.
395 *
396 ******************************************************************************/
397 void XScuGic_RegisterHandler(u32 BaseAddress, s32 InterruptID,
398                              Xil_InterruptHandler IntrHandler, void *CallBackRef)
399 {
400         XScuGic_Config *CfgPtr;
401         CfgPtr = LookupConfigByBaseAddress(BaseAddress);
402
403         if(CfgPtr != NULL) {
404                 if( IntrHandler != NULL) {
405                         CfgPtr->HandlerTable[InterruptID].Handler = IntrHandler;
406                 }
407                 if( CallBackRef != NULL) {
408                         CfgPtr->HandlerTable[InterruptID].CallBackRef = CallBackRef;
409                 }
410         }
411 }
412
413 /*****************************************************************************/
414 /**
415 *
416 * Looks up the device configuration based on the CPU interface base address of
417 * the device. A table contains the configuration info for each device in the
418 * system.
419 *
420 * @param        CpuBaseAddress is the CPU Interface Register base address.
421 *
422 * @return       A pointer to the configuration structure for the specified
423 *               device, or NULL if the device was not found.
424 *
425 * @note         None.
426 *
427 ******************************************************************************/
428 static XScuGic_Config *LookupConfigByBaseAddress(u32 CpuBaseAddress)
429 {
430         XScuGic_Config *CfgPtr = NULL;
431         u32 Index;
432
433         for (Index = 0U; Index < XPAR_SCUGIC_NUM_INSTANCES; Index++) {
434                 if (XScuGic_ConfigTable[Index].CpuBaseAddress ==
435                                 CpuBaseAddress) {
436                         CfgPtr = &XScuGic_ConfigTable[Index];
437                         break;
438                 }
439         }
440
441         return (XScuGic_Config *)CfgPtr;
442 }
443
444 /****************************************************************************/
445 /**
446 * Sets the interrupt priority and trigger type for the specificd IRQ source.
447 *
448 * @param        BaseAddr is the device base address
449 * @param        Int_Id is the IRQ source number to modify
450 * @param        Priority is the new priority for the IRQ source. 0 is highest
451 *                       priority, 0xF8 (248) is lowest. There are 32 priority levels
452 *                       supported with a step of 8. Hence the supported priorities are
453 *                       0, 8, 16, 32, 40 ..., 248.
454 * @param        Trigger is the new trigger type for the IRQ source.
455 * Each bit pair describes the configuration for an INT_ID.
456 * SFI    Read Only    b10 always
457 * PPI    Read Only    depending on how the PPIs are configured.
458 *                    b01    Active HIGH level sensitive
459 *                    b11 Rising edge sensitive
460 * SPI                LSB is read only.
461 *                    b01    Active HIGH level sensitive
462 *                    b11 Rising edge sensitive/
463 *
464 * @return       None.
465 *
466 * @note         This API has the similar functionality of XScuGic_SetPriority
467 *               TriggerType() and should be used when there is no InstancePtr.
468 *
469 *****************************************************************************/
470 void XScuGic_SetPriTrigTypeByDistAddr(u32 DistBaseAddress, u32 Int_Id,
471                                         u8 Priority, u8 Trigger)
472 {
473         u32 RegValue;
474         u8 LocalPriority = Priority;
475
476         Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
477         Xil_AssertVoid(Trigger <= XSCUGIC_INT_CFG_MASK);
478         Xil_AssertVoid(LocalPriority <= XSCUGIC_MAX_INTR_PRIO_VAL);
479
480         /*
481          * Determine the register to write to using the Int_Id.
482          */
483         RegValue = XScuGic_ReadReg(DistBaseAddress,
484                         XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id));
485
486         /*
487          * The priority bits are Bits 7 to 3 in GIC Priority Register. This
488          * means the number of priority levels supported are 32 and they are
489          * in steps of 8. The priorities can be 0, 8, 16, 32, 48, ... etc.
490          * The lower order 3 bits are masked before putting it in the register.
491          */
492         LocalPriority = LocalPriority & XSCUGIC_INTR_PRIO_MASK;
493         /*
494          * Shift and Mask the correct bits for the priority and trigger in the
495          * register
496          */
497         RegValue &= ~(XSCUGIC_PRIORITY_MASK << ((Int_Id%4U)*8U));
498         RegValue |= (u32)LocalPriority << ((Int_Id%4U)*8U);
499
500         /*
501          * Write the value back to the register.
502          */
503         XScuGic_WriteReg(DistBaseAddress, XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id),
504                                         RegValue);
505         /*
506          * Determine the register to write to using the Int_Id.
507          */
508         RegValue = XScuGic_ReadReg(DistBaseAddress,
509                         XSCUGIC_INT_CFG_OFFSET_CALC (Int_Id));
510
511         /*
512          * Shift and Mask the correct bits for the priority and trigger in the
513          * register
514          */
515         RegValue &= ~(XSCUGIC_INT_CFG_MASK << ((Int_Id%16U)*2U));
516         RegValue |= (u32)Trigger << ((Int_Id%16U)*2U);
517
518         /*
519          * Write the value back to the register.
520          */
521         XScuGic_WriteReg(DistBaseAddress, XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id),
522                                 RegValue);
523 }
524
525 /****************************************************************************/
526 /**
527 * Gets the interrupt priority and trigger type for the specificd IRQ source.
528 *
529 * @param        BaseAddr is the device base address
530 * @param        Int_Id is the IRQ source number to modify
531 * @param        Priority is a pointer to the value of the priority of the IRQ
532 *               source. This is a return value.
533 * @param        Trigger is pointer to the value of the trigger of the IRQ
534 *               source. This is a return value.
535 *
536 * @return       None.
537 *
538 * @note         This API has the similar functionality of XScuGic_GetPriority
539 *               TriggerType() and should be used when there is no InstancePtr.
540 *
541 *****************************************************************************/
542 void XScuGic_GetPriTrigTypeByDistAddr(u32 DistBaseAddress, u32 Int_Id,
543                                         u8 *Priority, u8 *Trigger)
544 {
545         u32 RegValue;
546
547         Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
548         Xil_AssertVoid(Priority != NULL);
549         Xil_AssertVoid(Trigger != NULL);
550
551         /*
552          * Determine the register to read to using the Int_Id.
553          */
554         RegValue = XScuGic_ReadReg(DistBaseAddress,
555             XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id));
556
557         /*
558          * Shift and Mask the correct bits for the priority and trigger in the
559          * register
560          */
561         RegValue = RegValue >> ((Int_Id%4U)*8U);
562         *Priority = (u8)(RegValue & XSCUGIC_PRIORITY_MASK);
563
564         /*
565          * Determine the register to read to using the Int_Id.
566          */
567         RegValue = XScuGic_ReadReg(DistBaseAddress,
568             XSCUGIC_INT_CFG_OFFSET_CALC (Int_Id));
569
570         /*
571          * Shift and Mask the correct bits for the priority and trigger in the
572          * register
573          */
574         RegValue = RegValue >> ((Int_Id%16U)*2U);
575
576         *Trigger = (u8)(RegValue & XSCUGIC_INT_CFG_MASK);
577 }
578
579 /****************************************************************************/
580 /**
581 * Unmaps specific SPI interrupt from the target CPU
582 *
583 * @param        DistBaseAddress is the device base address
584 * @param        Cpu_Id is a CPU number from which the interrupt has to be
585 *                       unmapped
586 * @param        Int_Id is the IRQ source number to modify
587 *
588 * @return       None.
589 *
590 * @note         None
591 *
592 *****************************************************************************/
593 void XScuGic_InterruptUnmapFromCpuByDistAddr(u32 DistBaseAddress,
594                                                                                          u8 Cpu_Id, u32 Int_Id)
595 {
596         u32 RegValue;
597         u8 BitPos;
598
599         Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
600
601         RegValue = XScuGic_ReadReg(DistBaseAddress,
602                                 XSCUGIC_SPI_TARGET_OFFSET_CALC(Int_Id));
603
604         /*
605          * Identify bit position corresponding to  Int_Id and Cpu_Id,
606          * in interrupt target register and clear it
607          */
608         BitPos = ((Int_Id % 4U) * 8U) + Cpu_Id;
609         RegValue &= (~ ( 1U << BitPos ));
610         XScuGic_WriteReg(DistBaseAddress,
611                         XSCUGIC_SPI_TARGET_OFFSET_CALC(Int_Id), RegValue);
612 }
613
614 /****************************************************************************/
615 /**
616 * Unmaps all SPI interrupts from the target CPU
617 *
618 * @param        DistBaseAddress is the device base address
619 * @param        Cpu_Id is a CPU number from which the interrupts has to be
620 *                       unmapped
621 *
622 * @return       None.
623 *
624 * @note         None
625 *
626 *****************************************************************************/
627 void XScuGic_UnmapAllInterruptsFromCpuByDistAddr(u32 DistBaseAddress,
628                                                                                                  u8 Cpu_Id)
629 {
630         u32 Int_Id;
631         u32 Target_Cpu;
632         u32 LocalCpuID = (1U << Cpu_Id);
633
634         LocalCpuID |= LocalCpuID << 8U;
635         LocalCpuID |= LocalCpuID << 16U;
636
637         for (Int_Id = 32U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id=Int_Id+4U)
638         {
639
640                 Target_Cpu = XScuGic_ReadReg(DistBaseAddress,
641                                 XSCUGIC_SPI_TARGET_OFFSET_CALC(Int_Id));
642                 /* Remove LocalCpuID from interrupt target register */
643                 Target_Cpu &= (~LocalCpuID);
644                 XScuGic_WriteReg(DistBaseAddress,
645                         XSCUGIC_SPI_TARGET_OFFSET_CALC(Int_Id), Target_Cpu);
646
647         }
648 }
649 /** @} */