2016-03-01 01:13:51 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* arch/arm/src/armv7-a/gic.h
|
|
|
|
* Generic Interrupt Controller Definitions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
2016-03-01 15:21:26 +01:00
|
|
|
* Reference:
|
|
|
|
* Cortex™-A9 MPCore, Revision: r4p1, Technical Reference Manual, ARM DDI
|
|
|
|
* 0407I (ID091612).
|
|
|
|
*
|
2016-03-01 19:55:48 +01:00
|
|
|
* Includes some removed registers from the r2p2 version as well. ARM DDI
|
|
|
|
* 0407F (ID050110)
|
|
|
|
*
|
2016-03-01 01:13:51 +01:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __ARCH_ARM_SRC_ARMV7_A_GIC_H
|
|
|
|
#define __ARCH_ARM_SRC_ARMV7_A_GIC_H
|
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-03-02 21:56:54 +01:00
|
|
|
#include "nuttx/config.h"
|
2016-03-03 15:50:25 +01:00
|
|
|
#include <stdint.h>
|
2016-03-01 15:21:26 +01:00
|
|
|
#include "mpcore.h"
|
|
|
|
|
2016-03-02 21:56:54 +01:00
|
|
|
#ifdef CONFIG_ARMV7A_HAVE_GIC
|
|
|
|
|
2016-03-01 01:13:51 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Generic indexing helpers *************************************************/
|
|
|
|
/* 1x32 bit field per register */
|
|
|
|
|
|
|
|
#define GIC_INDEX1(n) (n) /* 1 field per word */
|
|
|
|
#define GIC_OFFSET1(n) (GIC_INDEX1(n) << 2) /* 32-bit word offset */
|
|
|
|
#define GIC_SHIFT1(n) (0) /* No shift */
|
|
|
|
#define GIC_MASK1(n) (0xffffffff) /* Whole word */
|
|
|
|
|
|
|
|
/* 2x16 bit field per register */
|
|
|
|
|
|
|
|
#define GIC_INDEX2(n) (n >> 1) /* 2 fields per word */
|
|
|
|
#define GIC_OFFSET2(n) (GIC_INDEX2(n) << 2) /* 32-bit word offset */
|
|
|
|
#define GIC_SHIFT2(n) (((n) & 1) << 4) /* Shift 16-bits per field */
|
|
|
|
#define GIC_MASK2(n) (0xffff << GIC_SHIFT2(n)) /* 16-bit mask */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* 4x8 bit field per register */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_INDEX4(n) (n >> 2) /* 4 fields per word */
|
|
|
|
#define GIC_OFFSET4(n) (GIC_INDEX4(n) << 2) /* 32-bit word offset */
|
|
|
|
#define GIC_SHIFT4(n) (((n) & 3) << 3) /* Shift 8-bits per field */
|
|
|
|
#define GIC_MASK4(n) (0xff << GIC_SHIFT4(n)) /* 8-bit mask */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* 8x4 bit field per register */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_INDEX8(n) (n >> 3) /* 8 fields per word */
|
|
|
|
#define GIC_OFFSET8(n) (GIC_INDEX8(n) << 2) /* 32-bit word offset */
|
|
|
|
#define GIC_SHIFT8(n) (((n) & 7) << 2) /* Shift 4-bits per field */
|
|
|
|
#define GIC_MASK8(n) (15 << GIC_SHIFT8(n)) /* 4-bit mask */
|
|
|
|
|
|
|
|
/* 16x2 bit field per register */
|
|
|
|
|
|
|
|
#define GIC_INDEX16(n) (n >> 4) /* 16 fields per word */
|
|
|
|
#define GIC_OFFSET16(n) (GIC_INDEX16(n) << 2) /* 32-bit word offset */
|
|
|
|
#define GIC_SHIFT16(n) (((n) & 15) << 1) /* Shift 2-bits per field */
|
|
|
|
#define GIC_MASK16(n) (3 << GIC_SHIFT16(n)) /* 2-bit mask */
|
|
|
|
|
|
|
|
/* 32x1 bit field per register */
|
|
|
|
|
|
|
|
#define GIC_INDEX32(n) (n >> 5) /* 32 fields per word */
|
|
|
|
#define GIC_OFFSET32(n) (GIC_INDEX32(n) << 2) /* 32-bit word offset */
|
|
|
|
#define GIC_SHIFT32(n) ((n) & 31) /* Shift 1-bit per field */
|
|
|
|
#define GIC_MASK32(n) (1 << GIC_SHIFT32(n)) /* 1-bit mask */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
|
|
|
/* GIC Register Offsets *****************************************************/
|
2016-03-01 02:25:59 +01:00
|
|
|
/* Interrupt Interface registers */
|
|
|
|
|
|
|
|
#define GIC_ICCICR_OFFSET 0x0000 /* CPU Interface Control Register */
|
|
|
|
#define GIC_ICCPMR_OFFSET 0x0004 /* Interrupt Priority Mask Register */
|
|
|
|
#define GIC_ICCBPR_OFFSET 0x0008 /* Binary point Register */
|
|
|
|
#define GIC_ICCIAR_OFFSET 0x000c /* Interrupt Acknowledge */
|
|
|
|
#define GIC_ICCEOIR_OFFSET 0x0010 /* End of interrupt */
|
|
|
|
#define GIC_ICCRPR_OFFSET 0x0014 /* Running interrupt */
|
|
|
|
#define GIC_ICCHPIR_OFFSET 0x0018 /* Highest pending interrupt */
|
|
|
|
#define GIC_ICCABPR_OFFSET 0x001c /* Aliased Non-secure Binary Point Register */
|
|
|
|
#define GIC_ICCIDR_OFFSET 0x00fc /* CPU Interface Implementer ID Register */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
|
|
|
/* Distributor Registers */
|
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICDDCR_OFFSET 0x0000 /* Distributor Control Register */
|
|
|
|
#define GIC_ICDICTR_OFFSET 0x0004 /* Interrupt Controller Type Register */
|
|
|
|
#define GIC_ICDIIDR_OFFSET 0x0008 /* Distributor Implementer ID Register */
|
2016-03-01 15:21:26 +01:00
|
|
|
|
|
|
|
/* 0x000c-0x007c: Reserved */
|
|
|
|
/* Interrupt Security Registers: 0x0080-0x009c */
|
|
|
|
|
|
|
|
#define GIC_ICDISR_OFFSET(n) (0x0080 + GIC_OFFSET32(n))
|
|
|
|
|
|
|
|
/* Interrupt Set-Enable Registers: 0x0100-0x011c */
|
|
|
|
|
|
|
|
#define GIC_ICDISER_OFFSET(n) (0x0100 + GIC_OFFSET32(n))
|
|
|
|
|
|
|
|
/* Interrupt Clear-Enable Registers: 0x0180-0x019c */
|
|
|
|
|
|
|
|
#define GIC_ICDICER_OFFSET(n) (0x0180 + GIC_OFFSET32(n))
|
|
|
|
|
|
|
|
/* Interrupt Set-Pending Registers: 0x0200-0x027c */
|
|
|
|
|
|
|
|
#define GIC_ICDISPR_OFFSET(n) (0x0200 + GIC_OFFSET32(n))
|
|
|
|
|
|
|
|
/* Interrupt Clear-Pending Registers: 0x0280-0x02fc */
|
|
|
|
|
|
|
|
#define GIC_ICDICPR_OFFSET(n) (0x0280 + GIC_OFFSET32(n))
|
|
|
|
|
|
|
|
/* Interrupt Active Bit Registers: 0x0300-0x31c */
|
|
|
|
|
|
|
|
#define GIC_ICDABR_OFFSET(n) (0x0300 + GIC_OFFSET32(n))
|
|
|
|
|
|
|
|
/* 0x0380-0x03fc: Reserved */
|
|
|
|
/* Interrupt Priority Registers: 0x0400-0x04fc */
|
|
|
|
|
|
|
|
#define GIC_ICDIPR_OFFSET(n) (0x0400 + GIC_OFFSET4(n))
|
|
|
|
|
|
|
|
/* 0x0500-0x07fc: Reserved */
|
|
|
|
/* Interrupt Processor Target Registers: 0x0800-0x08fc */
|
|
|
|
|
|
|
|
#define GIC_ICDIPTR_OFFSET(n) (0x0800 + GIC_OFFSET4(n))
|
|
|
|
|
|
|
|
/* 0x0900-0x0bfc: Reserved */
|
|
|
|
/* Interrupt Configuration Registers: 0x0c00-0x0c3c */
|
|
|
|
|
|
|
|
#define GIC_ICDICFR_OFFSET(n) (0x0c00 + GIC_OFFSET16(n))
|
|
|
|
|
|
|
|
/* PPI Status Register: 0x0d00 */
|
|
|
|
|
2016-03-03 15:50:25 +01:00
|
|
|
#define GIC_ICDPPISR_OFFSET 0x0d00 /* PPI Status Register */
|
2016-03-01 15:21:26 +01:00
|
|
|
|
|
|
|
/* SPI Status Registers: 0x0d04-0x0d1c */
|
|
|
|
|
2016-03-03 15:50:25 +01:00
|
|
|
#define GIC_ICDSPISR_OFFSET(n) (0x0d04 + GIC_OFFSET32(n))
|
2016-03-01 15:21:26 +01:00
|
|
|
|
|
|
|
/* 0x0d80-0x0efc: Reserved */
|
|
|
|
/* Software Generated Interrupt Register: 0x0f00 */
|
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICDSGIR_OFFSET 0x0f00 /* Software Generated Interrupt Register */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* 0x0f0c-0x0fcc: Reserved */
|
|
|
|
/* Peripheral Identification Registers: 0x0fd0-0xfe8 */
|
2016-03-01 02:25:59 +01:00
|
|
|
|
2016-03-03 15:50:25 +01:00
|
|
|
#define GIC_ICDPIDR_OFFSET(n) (0x0fd0 + ((n) << 2))
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Component Identification Registers: 0x0ff0-0x0ffc */
|
|
|
|
|
2016-03-03 15:50:25 +01:00
|
|
|
#define GIC_ICDCIDR_OFFSET(n) (0x0ff0 + ((n) << 2))
|
2016-03-01 15:21:26 +01:00
|
|
|
|
|
|
|
/* 0x0f04-0x0ffc: Reserved */
|
|
|
|
|
|
|
|
/* GIC Register Addresses ***************************************************/
|
|
|
|
/* The Interrupt Controller is a single functional unit that is located in a
|
|
|
|
* Cortex-A9 MPCore design. There is one interrupt interface per Cortex-A9
|
|
|
|
* processor. Registers are memory mapped and accessed through a chip-
|
|
|
|
* specific private memory spaced (see mpcore.h).
|
|
|
|
*/
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Interrupt Interface registers */
|
|
|
|
|
|
|
|
#define GIC_ICCICR (MPCORE_ICC_VBASE+GIC_ICCICR_OFFSET)
|
|
|
|
#define GIC_ICCPMR (MPCORE_ICC_VBASE+GIC_ICCPMR_OFFSET)
|
|
|
|
#define GIC_ICCBPR (MPCORE_ICC_VBASE+GIC_ICCBPR_OFFSET)
|
|
|
|
#define GIC_ICCIAR (MPCORE_ICC_VBASE+GIC_ICCIAR_OFFSET)
|
|
|
|
#define GIC_ICCEOIR (MPCORE_ICC_VBASE+GIC_ICCEOIR_OFFSET)
|
|
|
|
#define GIC_ICCRPR (MPCORE_ICC_VBASE+GIC_ICCRPR_OFFSET)
|
|
|
|
#define GIC_ICCHPIR (MPCORE_ICC_VBASE+GIC_ICCHPIR_OFFSET)
|
|
|
|
#define GIC_ICCABPR (MPCORE_ICC_VBASE+GIC_ICCABPR_OFFSET)
|
2016-03-03 15:50:25 +01:00
|
|
|
#define GIC_ICCIDR (MPCORE_ICC_VBASE+GIC_ICCIDR_OFFSET)
|
2016-03-01 01:13:51 +01:00
|
|
|
|
|
|
|
/* Distributor Registers */
|
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDDCR (MPCORE_ICD_VBASE+GIC_ICDDCR_OFFSET)
|
|
|
|
#define GIC_ICDICTR (MPCORE_ICD_VBASE+GIC_ICDICTR_OFFSET)
|
|
|
|
#define GIC_ICDIIDR (MPCORE_ICD_VBASE+GIC_ICDIIDR_OFFSET)
|
2016-03-11 16:00:49 +01:00
|
|
|
#define GIC_ICDISR(n) (MPCORE_ICD_VBASE+GIC_ICDISR_OFFSET(n))
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDISER(n) (MPCORE_ICD_VBASE+GIC_ICDISER_OFFSET(n))
|
|
|
|
#define GIC_ICDICER(n) (MPCORE_ICD_VBASE+GIC_ICDICER_OFFSET(n))
|
|
|
|
#define GIC_ICDISPR(n) (MPCORE_ICD_VBASE+GIC_ICDISPR_OFFSET(n))
|
|
|
|
#define GIC_ICDICPR(n) (MPCORE_ICD_VBASE+GIC_ICDICPR_OFFSET(n))
|
|
|
|
#define GIC_ICDABR(n) (MPCORE_ICD_VBASE+GIC_ICDABR_OFFSET(n))
|
|
|
|
#define GIC_ICDIPR(n) (MPCORE_ICD_VBASE+GIC_ICDIPR_OFFSET(n))
|
|
|
|
#define GIC_ICDIPTR(n) (MPCORE_ICD_VBASE+GIC_ICDIPTR_OFFSET(n))
|
|
|
|
#define GIC_ICDICFR(n) (MPCORE_ICD_VBASE+GIC_ICDICFR_OFFSET(n))
|
2016-03-03 15:50:25 +01:00
|
|
|
#define GIC_ICDPPISR (MPCORE_ICD_VBASE+GIC_ICDPPISR_OFFSET)
|
|
|
|
#define GIC_ICDSPISR(n) (MPCORE_ICD_VBASE+GIC_ICDSPISR_OFFSET(n))
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDSGIR (MPCORE_ICD_VBASE+GIC_ICDSGIR_OFFSET)
|
2016-03-03 15:50:25 +01:00
|
|
|
#define GIC_ICDPIDR(n) (MPCORE_ICD_VBASE+GIC_ICDPIDR_OFFSET(n))
|
|
|
|
#define GIC_ICDCIDR(n) (MPCORE_ICD_VBASE+GIC_ICDCIDR_OFFSET(n))
|
2016-03-01 01:13:51 +01:00
|
|
|
|
|
|
|
/* GIC Register Bit Definitions *********************************************/
|
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
/* Interrupt Interface registers */
|
|
|
|
/* CPU Interface Control Register */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICCICR_ENABLE (1 << 0) /* Bit 0: Enable the CPU interface for this GIC */
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 1-31: Reserved */
|
2016-03-01 02:25:59 +01:00
|
|
|
/* Interrupt Priority Mask Register */
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 0-3: Reserved */
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICCPMR_SHIFT (4) /* Bits 4-7: Priority mask */
|
|
|
|
#define GIC_ICCPMR_MASK (15 << GIC_ICCPMR_SHIFT)
|
|
|
|
# define GIC_ICCPMR_VALUE(n) ((uint32_t)(n) << GIC_ICCPMR_SHIFT)
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 8-31: Reserved */
|
2016-03-01 19:55:48 +01:00
|
|
|
/* Binary point Register and liased Non-secure Binary Point Register */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICCBPR_SHIFT (0) /* Bits 0-2: Binary point */
|
|
|
|
#define GIC_ICCBPR_MASK (7 << GIC_ICCBPR_SHIFT)
|
|
|
|
# define GIC_ICCBPR_ALL (3 << GIC_ICCBPR_SHIFT) /* All priority bits are compared for pre-emption */
|
|
|
|
# define GIC_ICCBPR_5_7 (4 << GIC_ICCBPR_SHIFT) /* Priority bits [7:5] compared for pre-emption */
|
|
|
|
# define GIC_ICCBPR_6_7 (5 << GIC_ICCBPR_SHIFT) /* Priority bits [7:6] compared for pre-emption */
|
|
|
|
# define GIC_ICCBPR_7 (6 << GIC_ICCBPR_SHIFT) /* Priority bit [7] compared for pre-emption */
|
|
|
|
# define GIC_ICCBPR_NOPREMPT (7 << GIC_ICCBPR_SHIFT) /* No pre-emption is performed */
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 3-31: Reserved */
|
|
|
|
/* Interrupt Acknowledge Register */
|
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICCIAR_INTID_SHIFT (0) /* Bits 0-9: Interrupt ID */
|
|
|
|
#define GIC_ICCIAR_INTID_MASK (0x3ff << GIC_ICCIAR_INTID_SHIFT)
|
|
|
|
# define GIC_ICCIAR_INTID(n) ((uint32_t)(n) << GIC_ICCIAR_INTID_SHIFT)
|
|
|
|
#define GIC_ICCIAR_CPUSRC_SHIFT (10) /* Bits 10-12: CPU source ID */
|
|
|
|
#define GIC_ICCIAR_CPUSRC_MASK (7 << GIC_ICCIAR_CPUSRC_SHIFT)
|
|
|
|
# define GIC_ICCIAR_CPUSRC(n) ((uint32_t)(n) << GIC_ICCIAR_CPUSRC_SHIFT)
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 13-31: Reserved */
|
|
|
|
/* End of Interrupt Register */
|
|
|
|
|
2016-03-11 16:49:00 +01:00
|
|
|
#define GIC_ICCEOIR_SPURIOUS (0x3ff)
|
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICCEOIR_INTID_SHIFT (0) /* Bits 0-9: Interrupt ID */
|
|
|
|
#define GIC_ICCEOIR_INTID_MASK (0x3ff << GIC_ICCEOIR_INTID_SHIFT)
|
|
|
|
# define GIC_ICCEOIR_INTID(n) ((uint32_t)(n) << GIC_ICCEOIR_INTID_SHIFT)
|
|
|
|
#define GIC_ICCEOIR_CPUSRC_SHIFT (10) /* Bits 10-12: CPU source ID */
|
|
|
|
#define GIC_ICCEOIR_CPUSRC_MASK (7 << GIC_ICCEOIR_CPUSRC_SHIFT)
|
|
|
|
# define GIC_ICCEOIR_CPUSRC(n) ((uint32_t)(n) << GIC_ICCEOIR_CPUSRC_SHIFT)
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 13-31: Reserved */
|
|
|
|
/* Running Interrupt Register */
|
|
|
|
|
|
|
|
/* Bits 0-3: Reserved */
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICCRPR_PRIO_SHIFT (4) /* Bits 4-7: Priority mask */
|
|
|
|
#define GIC_ICCRPR_PRIO_MASK (15 << GIC_ICCRPR_PRIO_SHIFT)
|
|
|
|
# define GIC_ICCRPR_PRIO_VALUE(n) ((uint32_t)(n) << GIC_ICCRPR_PRIO_SHIFT)
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 8-31: Reserved */
|
|
|
|
/* Highest Pending Interrupt Register */
|
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICCHPIR_INTID_SHIFT (0) /* Bits 0-9: Interrupt ID */
|
|
|
|
#define GIC_ICCHPIR_INTID_MASK (0x3ff << GIC_ICCHPIR_INTID_SHIFT)
|
|
|
|
# define GIC_ICCHPIR_INTID(n) ((uint32_t)(n) << GIC_ICCHPIR_INTID_SHIFT)
|
|
|
|
#define GIC_ICCHPIR_CPUSRC_SHIFT (10) /* Bits 10-12: CPU source ID */
|
|
|
|
#define GIC_ICCHPIR_CPUSRC_MASK (7 << GIC_ICCHPIR_CPUSRC_SHIFT)
|
|
|
|
# define GIC_ICCHPIR_CPUSRC(n) ((uint32_t)(n) << GIC_ICCHPIR_CPUSRC_SHIFT)
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 13-31: Reserved */
|
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
/* CPU Interface Implementer ID Register */
|
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICCIDR_IMPL_SHIFT (0) /* Bits 0-11: Implementer */
|
|
|
|
#define GIC_ICCIDR_IMPL_MASK (0xfff << GIC_ICCIDR_IMPL_SHIFT)
|
|
|
|
#define GIC_ICCIDR_REVISION_SHIFT (12) /* Bits 12-15: Revision number */
|
|
|
|
#define GIC_ICCIDR_REVISION_MASK (15 << GIC_ICCIDR_REVISION_SHIFT)
|
|
|
|
#define GIC_ICCIDR_ARCHNO_SHIFT (16) /* Bits 16-19: Architecture number */
|
|
|
|
#define GIC_ICCIDR_ARCHNO_MASK (15 << GIC_ICCIDR_ARCHNO_SHIFT)
|
|
|
|
#define GIC_ICCIDR_PARTNO_SHIFT (20) /* Bits 20-31: Part number */
|
|
|
|
#define GIC_ICCIDR_PARTNO_MASK (0xfff << GIC_ICCIDR_PARTNO_SHIFT)
|
2016-03-01 02:25:59 +01:00
|
|
|
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Distributor Registers */
|
|
|
|
/* Distributor Control Register */
|
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDDCR_NONSECENAB (1 << 0) /* Bit 0: Enable distributor for Non-secure interrupts */
|
|
|
|
#define GIC_ICDDCR_SECENABLE (1 << 1) /* Bit 1: Enable distributor for Secure interrupts */
|
|
|
|
/* Bits 2-31: Reserved */
|
2016-03-01 02:25:59 +01:00
|
|
|
/* Interrupt Controller Type Register */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDICTR_ITLINES_SHIFT (0) /* Bits 0-4: It lines number */
|
|
|
|
#define GIC_ICDICTR_ITLINES_MASK (0x1f << GIC_ICDICTR_ITLINES_SHIFT)
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICDICTR_CPUNO_SHIFT (5) /* Bits 5-7: CPU number */
|
|
|
|
#define GIC_ICDICTR_CPUNO_MASK (7 << GIC_ICDICTR_CPUNO_SHIFT)
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Bits 8-9: Reserved */
|
|
|
|
#define GIC_ICDICTR_SECEXTNS (1 << 10) /* Bit 10: Number of security domains */
|
|
|
|
#define GIC_ICDICTR_LSPI_SHIFT (11) /* Bits 11-15: Number of Lockable Shared Peripheral Interrupts */
|
|
|
|
#define GIC_ICDICTR_LSPI_MASK (0x1f << GIC_ICDICTR_LSPI_SHIFT)
|
|
|
|
/* Bits 16-31: Reserved */
|
2016-03-01 02:25:59 +01:00
|
|
|
/* Distributor Implementer ID Register */
|
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDIIDR_IMPL_SHIFT (0) /* Bits 0-11: Implementer */
|
|
|
|
#define GIC_ICDIIDR_IMPL_MASK (0xfff << GIC_ICDIIDR_IMPL_SHIFT)
|
|
|
|
#define GIC_ICDIIDR_REVISION_SHIFT (12) /* Bits 12-23: Revision number */
|
|
|
|
#define GIC_ICDIIDR_REVISION_MASK (0xfff << GIC_ICDIIDR_REVISION_SHIFT)
|
|
|
|
#define GIC_ICDIIDR_VERSION_SHIFT (24) /* Bits 24-31: Iimplementer version */
|
|
|
|
#define GIC_ICDIIDR_VERSION_MASK (0xff << GIC_ICDIIDR_VERSION_SHIFT)
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-11 16:00:49 +01:00
|
|
|
/* Interrupt Security Registers: 0x0080-0x009c */
|
|
|
|
|
|
|
|
#define GIC_ICDISR_INT(n) GIC_MASK32(n)
|
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Interrupt Set-Enable.
|
|
|
|
*
|
|
|
|
* NOTE: In the Cortex-A9 MPCore, SGIs are always enabled. The corresponding bits
|
|
|
|
* in the ICDISERn are read as one, write ignored
|
|
|
|
*/
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDISER_INT(n) GIC_MASK32(n)
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Interrupt Clear-Enable.
|
|
|
|
*
|
|
|
|
* NOTE: In the Cortex-A9 MPCore, SGIs are always enabled. The corresponding bits
|
|
|
|
* in the ICDICERn are read as one, write ignored
|
|
|
|
*/
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDICER_INT(n) GIC_MASK32(n)
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Interrupt Set-Pending */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDISPR_INT(n) GIC_MASK32(n)
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Interrupt Clear-Pending */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDICPR_INT(n) GIC_MASK32(n)
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Interrupt Active Bit */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDABR_INT(n) GIC_MASK32(n)
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Interrupt Priority Registers */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDIPR_ID_SHIFT(n) GIC_SHIFT4(n)
|
|
|
|
#define GIC_ICDIPR_ID_MASK(n) GIC_MASK4(n)
|
|
|
|
# define GIC_ICDIPR_ID(n,p) ((uint32_t)(p) << GIC_SHIFT4(n))
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Interrupt Processor Target Registers */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
|
|
|
#define CPU0_TARGET (1 << 0)
|
|
|
|
#define CPU1_TARGET (1 << 1)
|
|
|
|
#define CPU2_TARGET (1 << 2)
|
|
|
|
#define CPU3_TARGET (1 << 3)
|
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
#define GIC_ICDIPTR_ID_SHIFT(n) GIC_SHIFT4(n)
|
|
|
|
#define GIC_ICDIPTR_ID_MASK(n) GIC_MASK4(n)
|
|
|
|
# define GIC_ICDIPTR_ID(n,t) ((uint32_t)(t) <<GIC_SHIFT4(n))
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 15:21:26 +01:00
|
|
|
/* Interrupt Configuration Register */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
#define INT_ICDICFR_NN 0 /* Bit n: 0= N-N Model */
|
|
|
|
#define INT_ICDICFR_1N 1 /* Bit n: 1= 1-N Model */
|
|
|
|
#define INT_ICDICFR_LEVEL 0 /* Bit n+1: 0=Level sensitive */
|
|
|
|
#define INT_ICDICFR_EDGE 2 /* Bit n+2: 1=Edge sensitive */
|
2016-03-01 15:21:26 +01:00
|
|
|
|
|
|
|
#define GIC_ICDICFR_ID_SHIFT(n) GIC_SHIFT16(n)
|
|
|
|
#define GIC_ICDICFR_ID_MASK(n) GIC_MASK16(n
|
|
|
|
# define GIC_ICDICFR_ID(n,c) ((uint32_t)(c) << GIC_SHIFT16(n))
|
2016-03-01 02:25:59 +01:00
|
|
|
|
|
|
|
/* PPI Status Register */
|
|
|
|
|
2016-03-03 15:50:25 +01:00
|
|
|
#define GIC_ICDPPISR_PPI(n) (1 << ((n) + 11)) /* Bits 11-15: PPI(n) status, n=0-4 */
|
|
|
|
# define GIC_ICDPPISR_GTM (1 << 11) /* Bit 11: PPI[0], Global Timer */
|
|
|
|
# define GIC_ICDPPISR_NFIQ (1 << 12) /* Bit 12: PPI[1], FIQ, active low */
|
|
|
|
# define GIC_ICDPPISR_PTM (1 << 13) /* Bit 13: PPI[2], Private Timer */
|
|
|
|
# define GIC_ICDPPISR_PWDT (1 << 14) /* Bit 14: PPI[3], Private Watchdog */
|
|
|
|
# define GIC_ICDPPISR_NIRQ (1 << 15) /* Bit 15: PPI[3], IRQ, active low */
|
2016-03-01 15:21:26 +01:00
|
|
|
|
2016-03-01 02:25:59 +01:00
|
|
|
/* SPI Status Registers */
|
|
|
|
|
2016-03-03 15:50:25 +01:00
|
|
|
#define GIC_ICDSPISR_INT(n) GIC_MASK32(n)
|
2016-03-01 02:25:59 +01:00
|
|
|
|
|
|
|
/* Software Generated Interrupt Register */
|
|
|
|
|
|
|
|
#define GIC_ICDSGIR_INTID_SHIFT (0) /* Bits 0-9: Interrupt ID */
|
|
|
|
#define GIC_ICDSGIR_INTID_MASK (0x3ff << GIC_ICDSGIR_INTID_SHIFT)
|
|
|
|
# define GIC_ICDSGIR_INTID(n) ((uint32_t)(n) << GIC_ICDSGIR_INTID_SHIFT)
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 10-15: Reserved */
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICDSGIR_CPUTARGET_SHIFT (16) /* Bits 16-23: CPU target */
|
|
|
|
#define GIC_ICDSGIR_CPUTARGET_MASK (0xff << GIC_ICDSGIR_CPUTARGET_SHIFT)
|
|
|
|
# define GIC_ICDSGIR_CPUTARGET(n) ((uint32_t)(n) << GIC_ICDSGIR_CPUTARGET_SHIFT)
|
2016-03-01 01:13:51 +01:00
|
|
|
/* Bits 26-31: Reserved */
|
2016-03-01 02:25:59 +01:00
|
|
|
#define GIC_ICDSGIR_TGTFILTER_SHIFT (24) /* Bits 24-25: Target filter */
|
|
|
|
#define GIC_ICDSGIR_TGTFILTER_MASK (3 << GIC_ICDSGIR_TGTFILTER_SHIFT)
|
|
|
|
# define GIC_ICDSGIR_TGTFILTER_LIST (0 << GIC_ICDSGIR_TGTFILTER_SHIFT) /* Interrupt sent to CPUs CPU target list */
|
|
|
|
# define GIC_ICDSGIR_TGTFILTER_OTHER (1 << GIC_ICDSGIR_TGTFILTER_SHIFT) /* Interrupt is sent to all but requesting CPU */
|
|
|
|
# define GIC_ICDSGIR_TGTFILTER_THIS (2 << GIC_ICDSGIR_TGTFILTER_SHIFT) /* Interrupt is sent to requesting CPU only */
|
2016-03-01 01:13:51 +01:00
|
|
|
|
2016-03-10 14:13:40 +01:00
|
|
|
/* Interrupt IDs ************************************************************/
|
|
|
|
/* The Global Interrupt Controller (GIC) collects up to 224 interrupt
|
|
|
|
* requests and provides a memory mapped interface to each of the CPU core.
|
|
|
|
*
|
|
|
|
* The first 32 interrupts are used for interrupts that are private to the
|
|
|
|
* CPUs interface. Other shared interrupts besides the also hooked up to
|
|
|
|
* the GIC in the same order. The shared interrupt sources are MCU-
|
|
|
|
* specific and documented in MCU-specific header files.
|
|
|
|
*
|
|
|
|
* Each interrupt can be configured as a normal or a secure interrupt.
|
|
|
|
* Software force registers and software priority masking are also
|
|
|
|
* supported. The following table describes the private RM interrupt
|
|
|
|
* sources.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Private Peripheral Interrupts (PPI) **************************************/
|
|
|
|
/* Each Cortex-A9 processor has private interrupts, ID0-ID15, that can only
|
|
|
|
* be triggered by software. These interrupts are aliased so that there is
|
|
|
|
* no requirement for a requesting Cortex-A9 processor to determine its own
|
|
|
|
* CPU ID when it deals with SGIs. The priority of an SGI depends on the
|
|
|
|
* value set by the receiving Cortex-A9 processor in the banked SGI priority
|
|
|
|
* registers, not the priority set by the sending Cortex-A9 processor.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define GIC_IRQ_SGI0 0 /* Sofware Generated Interrupt (SGI) 0 */
|
|
|
|
#define GIC_IRQ_SGI1 1 /* Sofware Generated Interrupt (SGI) 1 */
|
|
|
|
#define GIC_IRQ_SGI2 2 /* Sofware Generated Interrupt (SGI) 2 */
|
|
|
|
#define GIC_IRQ_SGI3 3 /* Sofware Generated Interrupt (SGI) 3 */
|
|
|
|
#define GIC_IRQ_SGI4 4 /* Sofware Generated Interrupt (SGI) 4 */
|
|
|
|
#define GIC_IRQ_SGI5 5 /* Sofware Generated Interrupt (SGI) 5 */
|
|
|
|
#define GIC_IRQ_SGI6 6 /* Sofware Generated Interrupt (SGI) 6 */
|
|
|
|
#define GIC_IRQ_SGI7 7 /* Sofware Generated Interrupt (SGI) 7 */
|
|
|
|
#define GIC_IRQ_SGI8 8 /* Sofware Generated Interrupt (SGI) 8 */
|
|
|
|
#define GIC_IRQ_SGI9 9 /* Sofware Generated Interrupt (SGI) 9 */
|
|
|
|
#define GIC_IRQ_SGI10 10 /* Sofware Generated Interrupt (SGI) 10 */
|
|
|
|
#define GIC_IRQ_SGI11 11 /* Sofware Generated Interrupt (SGI) 11 */
|
|
|
|
#define GIC_IRQ_SGI12 12 /* Sofware Generated Interrupt (SGI) 12 */
|
|
|
|
#define GIC_IRQ_SGI13 13 /* Sofware Generated Interrupt (SGI) 13 */
|
|
|
|
#define GIC_IRQ_SGI14 14 /* Sofware Generated Interrupt (SGI) 14 */
|
|
|
|
#define GIC_IRQ_SGI15 15 /* Sofware Generated Interrupt (SGI) 15 */
|
|
|
|
|
|
|
|
#define GIC_IRQ_GTM 27 /* Global Timer (GTM) PPI(0) */
|
|
|
|
#define GIC_IRQ_FIQ 28 /* Fast Interrupt Request (nFIQ) PPI(1) */
|
|
|
|
#define GIC_IRQ_PTM 29 /* Private Timer (PTM) PPI(2) */
|
|
|
|
#define GIC_IRQ_WDT 30 /* Watchdog Timer (WDT) PPI(3) */
|
|
|
|
#define GIC_IRQ_IRQ 31 /* Interrupt Request (nIRQ) PPI(4) */
|
|
|
|
|
|
|
|
/* Shared Peripheral Interrupts (SPI) follow */
|
|
|
|
|
2016-03-11 16:00:49 +01:00
|
|
|
#define GIC_IRQ_SPI 32 /* First SPI interrupt ID */
|
|
|
|
|
2016-03-02 21:56:54 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: arm_gic_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform basic GIC initialization for the current CPU
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void arm_gic_initialize(void);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: arm_decodeirq
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function is called from the IRQ vector handler in arm_vectors.S.
|
|
|
|
* At this point, the interrupt has been taken and the registers have
|
|
|
|
* been saved on the stack. This function simply needs to determine the
|
|
|
|
* the irq number of the interrupt and then to call arm_doirq to dispatch
|
|
|
|
* the interrupt.
|
|
|
|
*
|
|
|
|
* Input parameters:
|
|
|
|
* regs - A pointer to the register save area on the stack.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
uint32_t *arm_decodeirq(uint32_t *regs);
|
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#endif /* CONFIG_ARMV7A_HAVE_GIC */
|
2016-03-01 01:13:51 +01:00
|
|
|
#endif /* __ARCH_ARM_SRC_ARMV7_A_GIC_H */
|