Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:22:49

0001 /**
0002  * @file
0003  *
0004  * @ingroup csb337_at91rm9200
0005  *
0006  * @brief Atmel AT91RM9200 Register Definitions
0007  */
0008 
0009 /*
0010  * Atmel AT91RM9200 Register definitions, used in KIT637_V6 (CSB637)
0011  *
0012  * Copyright (c) 2003 by Cogent Computer Systems
0013  * Written by Mike Kelly <mike@cogcomp.com>
0014  *
0015  * Modified by Fernando Nicodemos <fgnicodemos@terra.com.br>
0016  * from NCB - Sistemas Embarcados Ltda. (Brazil)
0017  *
0018  *  The license and distribution terms for this file may be
0019  *  found in the file LICENSE in this distribution or at
0020  *  http://www.rtems.org/license/LICENSE.
0021 */
0022 
0023 
0024 #ifndef __AT91RM9200_H__
0025 #define __AT91RM9200_H__
0026 
0027 #include "bits.h"
0028 
0029 typedef volatile unsigned long vulong;
0030 
0031 /* Source Mode Register - 32 of them */
0032 #define AIC_SMR_BASE            0xFFFFF000
0033 #define AIC_SMR_REG(_x_)        *(vulong *)(AIC_SMR_BASE + (_x_ & 0x7c))
0034 
0035 /* Source Vector Register - 32 of them */
0036 #define AIC_SVR_BASE            0xFFFFF080
0037 #define AIC_SVR_REG(_x_)        *(vulong *)(AIC_SVR_BASE + (_x_ & 0x7c))
0038 
0039 /* Control Register - 32 of them */
0040 #define AIC_CTL_BASE            0xFFFFF100
0041 #define AIC_CTL_REG(_x_)        *(vulong *)(AIC_CTL_BASE + (_x_ & 0x7f))
0042 
0043 /* Register Offsets */
0044 /* offsets from AIC_SMR_BASE and AIC_SVR_BASE */
0045 #define AIC_SMR_FIQ             0x00    /* Advanced Interrupt Controller FIQ */
0046 #define AIC_SMR_SYSIRQ          0x04    /* Advanced Interrupt Controller SYSIRQ */
0047 #define AIC_SMR_PIOA            0x08    /* Parallel I/O Controller A */
0048 #define AIC_SMR_PIOB            0x0c    /* Parallel I/O Controller B */
0049 #define AIC_SMR_PIOC            0x10    /* Parallel I/O Controller C */
0050 #define AIC_SMR_PIOD            0x14    /* Parallel I/O Controller D */
0051 #define AIC_SMR_US0             0x18    /* USART 0 */
0052 #define AIC_SMR_US1             0x1c    /* USART 1 */
0053 #define AIC_SMR_US2             0x20    /* USART 2 */
0054 #define AIC_SMR_US3             0x24    /* USART 3 */
0055 #define AIC_SMR_MCI             0x28    /* Multimedia Card Interface */
0056 #define AIC_SMR_UDP             0x2c    /* USB Device Port */
0057 #define AIC_SMR_TWI             0x30    /* Two-wire Interface */
0058 #define AIC_SMR_SPI             0x34    /* Serial Peripheral Interface */
0059 #define AIC_SMR_SSC0            0x38    /* Synchronous Serial Controller 0 */
0060 #define AIC_SMR_SSC1            0x3c    /* Synchronous Serial Controller 1 */
0061 #define AIC_SMR_SSC2            0x40    /* Synchronous Serial Controller 2 */
0062 #define AIC_SMR_TC0             0x44    /* Timer/Counter 0 */
0063 #define AIC_SMR_TC1             0x48    /* Timer/Counter 1 */
0064 #define AIC_SMR_TC2             0x4c    /* Timer/Counter 2 */
0065 #define AIC_SMR_TC3             0x50    /* Timer/Counter 3 */
0066 #define AIC_SMR_TC4             0x54    /* Timer/Counter 4 */
0067 #define AIC_SMR_TC5             0x58    /* Timer/Counter 5 */
0068 #define AIC_SMR_UHP             0x5c    /* USB Host Port */
0069 #define AIC_SMR_EMAC            0x60    /* Ethernet MAC */
0070 #define AIC_SMR_IRQ0            0x64    /* Advanced Interrupt Controller IRQ0 */
0071 #define AIC_SMR_IRQ1            0x68    /* Advanced Interrupt Controller IRQ1 */
0072 #define AIC_SMR_IRQ2            0x6c    /* Advanced Interrupt Controller IRQ2 */
0073 #define AIC_SMR_IRQ3            0x70    /* Advanced Interrupt Controller IRQ3 */
0074 #define AIC_SMR_IRQ4            0x74    /* Advanced Interrupt Controller IRQ4 */
0075 #define AIC_SMR_IRQ5            0x78    /* Advanced Interrupt Controller IRQ5 */
0076 #define AIC_SMR_IRQ6            0x7c    /* Advanced Interrupt Controller IRQ6 */
0077 
0078 /* from AIC_CTL_BASE */
0079 #define AIC_IVR                 0x00    /* IRQ Vector Register */
0080 #define AIC_FVR                 0x04    /* FIQ Vector Register */
0081 #define AIC_ISR                 0x08    /* Interrupt Status Register */
0082 #define AIC_IPR                 0x0C    /* Interrupt Pending Register */
0083 #define AIC_IMR                 0x10    /* Interrupt Mask Register */
0084 #define AIC_CISR                0x14    /* Core Interrupt Status Register */
0085 #define AIC_IECR                0x20    /* Interrupt Enable Command Register */
0086 #define AIC_IDCR                0x24    /* Interrupt Disable Command Register */
0087 #define AIC_ICCR                0x28    /* Interrupt Clear Command Register */
0088 #define AIC_ISCR                0x2C    /* Interrupt Set Command Register */
0089 #define AIC_EOICR               0x30    /* End of Interrupt Command Register */
0090 #define AIC_SPU                 0x34    /* Spurious Vector Register */
0091 #define AIC_DCR                 0x38    /* Debug Control Register (Protect) */
0092 #define AIC_FFER                0x40    /* Fast Forcing Enable Register */
0093 #define AIC_FFDR                0x44    /* Fast Forcing Disable Register */
0094 #define AIC_FFSR                0x48    /* Fast Forcing Status Register */
0095 
0096 /* Bit Defines */
0097 /* AIC_ISR - Interrupt Status Register */
0098 #define AIC_ISR_IRQID_MASK      0x1f    /* current interrupt ID          */
0099 
0100 /* AIC_CISR - Core Interrupt Status Register */
0101 #define AIC_CISR_IRQ            BIT1    /* 1 = Core IRQ is active */
0102 #define AIC_CISR_FIQ            BIT0    /* 1 = Core FIQ is active */
0103 
0104 /* AIC_DCR - Debug Control Register (Protect) */
0105 #define AIC_DCR_GMSK            BIT1    /* 0 = AIC controls IRQ and FIQ */
0106 #define AIC_DCR_PROT            BIT0    /* 1 = enable protection mode */
0107 
0108 /* AIC_SMR */
0109 #define AIC_SMR_PRIOR(_x_)      ((_x_ & 0x07) << 0)
0110 #define AIC_SMR_SRC_LVL_LOW     (0 << 5)        /* Are these right? docs don't say which is high/low     */
0111 #define AIC_SMR_SRC_EDGE_LOW    (1 << 5)
0112 #define AIC_SMR_SRC_LVL_HI      (2 << 5)
0113 #define AIC_SMR_SRC_EDGE_HI     (3 << 5)
0114 
0115 /**************************************************************************/
0116 /* Debug Unit                                                         */
0117 /**************************************************************************/
0118 #define DBGU_BASE               0xFFFFF200
0119 #define DBGU_REG(_x_)   *(vulong *)(DBGU_BASE + _x_)
0120 
0121 /* Register Offsets */
0122 #define DBGU_CR                 0x00    /* Control Register */
0123 #define DBGU_MR                 0x04    /* Mode Register */
0124 #define DBGU_IER                0x08    /* Interrupt Enable Register */
0125 #define DBGU_IDR                0x0C    /* Interrupt Disable Register */
0126 #define DBGU_IMR                0x10    /* Interrupt Mask Register */
0127 #define DBGU_CSR                0x14    /* Channel Status Register */
0128 #define DBGU_RHR                0x18    /* Receiver Holding Register */
0129 #define DBGU_THR                0x1C    /* Transmitter Holding Register */
0130 #define DBGU_BRGR               0x20    /* Baud Rate Generator Register */
0131 #define DBGU_C1R                0x40    /* Chip ID1 Register */
0132 #define DBGU_C2R                0x44    /* Chip ID2 Register */
0133 #define DBGU_FNTR               0x48    /* Force NTRST Register */
0134 
0135 /**************************************************************************/
0136 /* USART 0-3                                      */
0137 /**************************************************************************/
0138 #define USART0_BASE             0xFFFC0000
0139 #define USART1_BASE             0xFFFC4000
0140 #define USART2_BASE             0xFFFC8000
0141 #define USART3_BASE             0xFFFCC000
0142 /*
0143  *  WARNING: The USART3_BASE at the AT91RM9200 Manual is wrong!!!
0144  *  Manual revision: Rev. 1768H-ATARM–16-Jun-09
0145  *  USART3_BASE is NOT 0xFFECC000
0146  */
0147 
0148 /****************/
0149 /* System Timer */
0150 /****************/
0151 #define ST_BASE                 0xFFFFFD00
0152 #define ST_REG(_x_)             *(vulong *)(ST_BASE + _x_)
0153 
0154 /* Register Offsets */
0155 #define ST_CR                   0x00    /* Control Register */
0156 #define ST_PIMR                 0x04    /* Period Interval Mode Register */
0157 #define ST_WDMR                 0x08    /* Watchdog Mode Register */
0158 #define ST_RTMR                 0x0C    /* Real-time Mode Register */
0159 #define ST_SR                   0x10    /* Status Register */
0160 #define ST_IER                  0x14    /* Interrupt Enable Register */
0161 #define ST_IDR                  0x18    /* Interrupt Disable Register */
0162 #define ST_IMR                  0x1C    /* Interrupt Mask Register */
0163 #define ST_RTAR                 0x20    /* Real-time Alarm Register */
0164 #define ST_CRTR                 0x24    /* Current Real-time Register */
0165 
0166 /* Bit Defines */
0167 /* ST_CR - Control Register */
0168 #define ST_CR_WDRST                     BIT0    /* write 1 to reload WD counter  */
0169 
0170 /* ST_PIMR - Period Interval Mode Register */
0171 #define ST_PIMR_PIV_MASK        0x0000ffff
0172 
0173 /* ST_WDMR - Watchdog Mode Register */
0174 #define ST_WDMR_EXTEN           BIT17   /* WDOVF is not implemented on AT91RM9200 */
0175 #define ST_WDMR_RSTEN           BIT16   /* 1 = reset the AT91RM9200 when WD overflows */
0176 #define ST_WDMR_WDV_MASK        0x0000ffff      /* WD counter is in the lower 16-bits */
0177 
0178 /* ST_RTMR - Real-time Mode Register */
0179 #define ST_RTMR_RTPRES_MASK     0x0000ffff      /* Real-Time Prescaler */
0180 
0181 /* ST_SR - Status Register - Read Only */
0182 /* ST_IER - Interrupt Enable Register - Write Only */
0183 /* ST_IDR - Interrupt Disable Register - Write Only */
0184 /* ST_IMR - Interrupt Mask Register - Read Only */
0185 #define ST_SR_ALMS                      BIT3
0186 #define ST_SR_RTTINC            BIT2
0187 #define ST_SR_WDOVF                     BIT1
0188 #define ST_SR_PITS                      BIT0
0189 
0190 /* ST_RTAR - Real-time Alarm Register */
0191 #define ST_RTAR_ALMV_MASK       0x000fffff
0192 
0193 /* ST_CRTR - Current Real-time Register */
0194 #define ST_CRTR_CRTV_MASK       0x000fffff
0195 
0196 
0197 /**************************************************************************
0198  * Peripheral Data Control (DMA)
0199  * Note that each of the following peripherals has it's own
0200  * set of these registers starting at offset 0x100 from it's
0201  * base address: DBGU, SPI, USART and SSC
0202  * To access the DMA for a peripheral, use the macro for that
0203  * peripheral but with these register offsets
0204  **************************************************************************/
0205 /* Register Offsets */
0206 #define PDC_RPR         0x100   /* Receive Pointer Register */
0207 #define PDC_RCR         0x104   /* Receive Counter Register */
0208 #define PDC_TPR         0x108   /* Transmit Pointer Register */
0209 #define PDC_TCR         0x10c   /* Transmit Counter Register */
0210 #define PDC_RNPR        0x110   /* Receive Next Pointer Register */
0211 #define PDC_RNCR        0x114   /* Receive Next Counter Register */
0212 #define PDC_TNPR        0x118   /* Transmit Next Pointer Register */
0213 #define PDC_TNCR        0x11c   /* Transmit Next Counter Register */
0214 #define PDC_PTCR        0x120   /* PDC Transfer Control Register */
0215 #define PDC_PTSR        0x124   /* PDC Transfer Status Register */
0216 
0217 /**************************************************************************
0218  * Parallel I/O Unit
0219  * There are four PIO blocks - A, B, C and D.  They all have the
0220  * same register set, but different base addresses
0221  **************************************************************************/
0222 /* Port A */
0223 #define PIOA_BASE               0xFFFFF400
0224 #define PIOA_REG(_x_)   *(vulong *)(PIOA_BASE + _x_)
0225 
0226 /* Port B */
0227 #define PIOB_BASE               0xFFFFF600
0228 #define PIOB_REG(_x_)   *(vulong *)(PIOB_BASE + _x_)
0229 
0230 /* Port C */
0231 #define PIOC_BASE               0xFFFFF800
0232 #define PIOC_REG(_x_)   *(vulong *)(PIOC_BASE + _x_)
0233 
0234 /* Port D */
0235 #define PIOD_BASE               0xFFFFFA00
0236 #define PIOD_REG(_x_)   *(vulong *)(PIOD_BASE + _x_)
0237 
0238 /**************************************************************************
0239  * Power Management and Clock Control
0240  *************************************************************************/
0241 #define PMC_BASE                0xFFFFFC00
0242 #define PMC_REG(_x_)    *(vulong *)(PMC_BASE + _x_)
0243 
0244 /**************************************************************************
0245  * MAC Unit
0246  *************************************************************************/
0247 #define EMAC_BASE               0xFFFBC000
0248 #define EMAC_REG(_x_)   *(vulong *)(EMAC_BASE + _x_)
0249 
0250 /**************************************************************************
0251  * Timer/Counter Unit
0252  **************************************************************************/
0253 #define TC_BASE         0xFFFA0000
0254 #define TC_REG(_x_)     *(vulong *)(TC_BASE + 0x00 + _x_)
0255 #define TC_TC0_REG(_x_) *(vulong *)(TC_BASE + 0x00 + _x_)
0256 #define TC_TC1_REG(_x_) *(vulong *)(TC_BASE + 0x40 + _x_)
0257 #define TC_TC2_REG(_x_) *(vulong *)(TC_BASE + 0x80 + _x_)
0258 
0259 /* Offsets from TC_TC?_REG  */
0260 #define TC_CCR      0x00    /* Channel Control Register  */
0261 #define TC_CMR      0x04    /* Channel Mode Register  */
0262 #define TC_CV       0x10    /* Counter Value  */
0263 #define TC_RA       0x14    /* Register A  */
0264 #define TC_RB       0x18    /* Register B  */
0265 #define TC_RC       0x1C    /* Register C  */
0266 #define TC_SR       0x20    /* Status Register  */
0267 #define TC_IER      0x24    /* Interrupt Enable Register  */
0268 #define TC_IDR      0x28    /* Interrupt Disable Register  */
0269 #define TC_IMR      0x2C    /* Interrupt Mask Register  */
0270 
0271 /* Offsets from TC_BASE */
0272 #define TC_BCR      0xc0    /* Channel Control Register  */
0273 #define TC_BMR      0xc4    /* Channel Control Register  */
0274 
0275 /* Block control register */
0276 #define TC_BCR_SYNC    BIT1       /* Set to syncronize channels */
0277 
0278 /* Block mode register */
0279 #define TC_BMR_TC0(_x_)    ((_x_ & 0x3) << 0)   /* TC0 clock source */
0280 #define TC_BMR_TC1(_x_)    ((_x_ & 0x3) << 2)   /* TC1 clock source */
0281 #define TC_BMR_TC2(_x_)    ((_x_ & 0x3) << 4)   /* TC2 clock source */
0282 
0283 /* Channel Control register */
0284 #define TC_CCR_CLKEN     BIT0       /* Enable clock */
0285 #define TC_CCR_CLKDIS    BIT1       /* Disable clock */
0286 #define TC_CCR_SWTRG     BIT2       /* Software trigger command */
0287 
0288 /* Channel mode register */
0289 #define TC_CMR_TCCLKS(_x_)   ((_x_ & 0x7) << 0)  /* Clock source */
0290 #define TC_CMR_CLKI          BIT3                /* Clock invert */
0291 #define TC_BURST(_x_)        ((_x_ & 0x3 << 4)   /* Burst signal selection */
0292 #define TC_WAVE              BIT15               /* 0 for catpure, 1 for wave */
0293 
0294 /* Channel mode register - capture mode (TC_WAVE = 0) */
0295 #define TC_CMR_LDBSTOP       BIT6                /* Set to stop clock when RB loads */
0296 #define TC_CMR_LDBDIS        BIT7                /* Set to disable clock when RB loads */
0297 #define TC_CMR_ETRGEDG(_x_)  ((_x_ & 0x3) << 8)  /* Select edge triggering mode */
0298 #define TC_CMR_ABETRG        BIT10               /* Select ext trigger source */
0299 #define TC_CMR_CPCTRG        BIT14               /* RC Compare trigger enable */
0300 #define TC_CMR_LDRA(_x_)     ((_x_ & 0x3) << 16) /* RA loading selection */
0301 #define TC_CMR_LDRB(_x_)     ((_x_ & 0x3) << 18) /* RB loading selection */
0302 
0303 /* Channel mode register - wave mode (TC_WAVE = 1) */
0304 #define TC_CMR_CPCSTOP       BIT6                 /* Clock stopped w/ RC compare */
0305 #define TC_CMR_CPCDIS        BIT7                 /* Clock disabled w/ RC compare */
0306 #define TC_CMR_EEVTEDG(_x_)  ((_x_ & 0x3) << 8)   /* Ext event edge selection */
0307 #define TC_CMR_EEVT(_x_)     ((_x_ & 0x3) << 10)  /* Ext event selection */
0308 #define TC_CMR_ENETRG        BIT12                /* Ext event trigger enable */
0309 #define TC_CMR_WAVESEL(_x_)  ((_x_ & 0x3) << 13)  /* Waveform selection */
0310 #define TC_CMR_ACPA(_x_)     ((_x_ & 0x3) << 16)  /* RA compare effect on TIOA */
0311 #define TC_CMR_ACPC(_x_)     ((_x_ & 0x3) << 18)  /* RC compare effect on TIOA */
0312 #define TC_CMR_AEEVT(_x_)    ((_x_ & 0x3) << 20)  /* Ext event effect on TIOA */
0313 #define TC_CMR_ASWTRG(_x_)   ((_x_ & 0x3) << 22)  /* SW trigger effect on TIOA */
0314 #define TC_CMR_BCPB(_x_)     ((_x_ & 0x3) << 24)  /* RB compare effect on TIOB */
0315 #define TC_CMR_BCPC(_x_)     ((_x_ & 0x3) << 26)  /* RC compare effect on TIOB */
0316 #define TC_CMR_BEEVT(_x_)    ((_x_ & 0x3) << 28)  /* Ext event effect on TIOB */
0317 #define TC_CMR_BSWTRG(_x_)   ((_x_ & 0x3) << 30)  /* SW trigger effect on TIOB */
0318 
0319 /* Counter value */
0320 #define TC_CV_MASK            0xffff              /* Timer counter mask */
0321 
0322 /* Status, Interrupt enable, Interrupt disable, and Interrupt mask registers */
0323 #define TC_SR_COVFS     BIT0        /* Counter overflow status */
0324 #define TC_SR_LOVRS     BIT1        /* Load overrun status */
0325 #define TC_SR_CPAS      BIT2        /* RA compare status */
0326 #define TC_SR_CPBS      BIT3        /* RB compare status */
0327 #define TC_SR_CPCS      BIT4        /* RC compare status */
0328 #define TC_SR_LDRAS     BIT5        /* RA loading status */
0329 #define TC_SR_LDRBS     BIT6        /* RB loading  status */
0330 #define TC_SR_ETRGS     BIT7        /* External trigger status */
0331 #define TC_SR_CLKSTA    BIT16       /* Clock enabling status */
0332 #define TC_SR_MTIOA     BIT17       /* TIOA Mirror */
0333 #define TC_SR_MTIOB     BIT18       /* TIOB Mirror */
0334 
0335 /***************************************************************************
0336  * External Bus Interface Unit
0337  **************************************************************************/
0338 #define EBI_BASE                        0xFFFFFF60
0339 #define EBI_REG(_x_)            *(vulong *)(EBI_BASE + _x_)
0340 
0341 /***************************************************************************
0342  * Static Memory Interface Unit
0343  ***************************************************************************/
0344 #define SMC_REG(_x_)            *(vulong *)(EBI_BASE + 0x10 + _x_)
0345 
0346 /**************************************************************************
0347  * SDRAM Memory Interface Unit
0348  **************************************************************************/
0349 #define SDRC_REG(_x_)           *(vulong *)(EBI_BASE + 0x30 + _x_)
0350 
0351 #endif /* __AT91RM9200_H__ */
0352 
0353 /**
0354  * @defgroup csb337_at91rm9200 AT91RM9200
0355  *
0356  * @ingroup RTEMSBSPsARMCSB337
0357  *
0358  * @brief Atmel Register Definitions, Used In KIT637_V6 (CSB637)
0359  */
0360