4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2011 Develer S.r.l. (http://www.develer.com/)
33 * \brief SAM3 SDRAM controller definitions.
39 #include <cfg/macros.h>
44 /** SDRAMC registers base. */
45 #define SDRAMC_BASE 0x400E0200
49 * SDRAMC register offsets.
52 #define SDRAMC_MR_OFF 0x00 ///< Mode Register
53 #define SDRAMC_TR_OFF 0x04 ///< Refresh Timer Register
54 #define SDRAMC_CR_OFF 0x08 ///< Configuration Register
55 #define SDRAMC_LPR_OFF 0x10 ///< Low Power Register
56 #define SDRAMC_IER_OFF 0x14 ///< Interrupt Enable Register
57 #define SDRAMC_IDR_OFF 0x18 ///< Interrupt Disable Register
58 #define SDRAMC_IMR_OFF 0x1C ///< Interrupt Mask Register
59 #define SDRAMC_ISR_OFF 0x20 ///< Interrupt Status Register
60 #define SDRAMC_MDR_OFF 0x24 ///< Memory Device Register
61 #define SDRAMC_CR1_OFF 0x28 ///< Configuration Register 1
62 #define SDRAMC_OCMS_OFF 0x2C ///< OCMS Register 1
69 #define SDRAMC_MR (*(reg32_t *)(SDRAMC_BASE + SDRAMC_MR_OFF ))
70 #define SDRAMC_TR (*(reg32_t *)(SDRAMC_BASE + SDRAMC_TR_OFF ))
71 #define SDRAMC_CR (*(reg32_t *)(SDRAMC_BASE + SDRAMC_CR_OFF ))
72 #define SDRAMC_LPR (*(reg32_t *)(SDRAMC_BASE + SDRAMC_LPR_OFF ))
73 #define SDRAMC_IER (*(reg32_t *)(SDRAMC_BASE + SDRAMC_IER_OFF ))
74 #define SDRAMC_IDR (*(reg32_t *)(SDRAMC_BASE + SDRAMC_IDR_OFF ))
75 #define SDRAMC_IMR (*(reg32_t *)(SDRAMC_BASE + SDRAMC_IMR_OFF ))
76 #define SDRAMC_ISR (*(reg32_t *)(SDRAMC_BASE + SDRAMC_ISR_OFF ))
77 #define SDRAMC_MDR (*(reg32_t *)(SDRAMC_BASE + SDRAMC_MDR_OFF ))
78 #define SDRAMC_CR1 (*(reg32_t *)(SDRAMC_BASE + SDRAMC_CR1_OFF ))
79 #define SDRAMC_OCMS (*(reg32_t *)(SDRAMC_BASE + SDRAMC_OCMS_OFF))
84 * Defines for bit fields in SDRAMC_MR register.
87 #define SDRAMC_MR_MODE_MASK 0x7
88 #define SDRAMC_MR_MODE_NORMAL 0x0 ///< Normal mode. Any access to the SDRAM is decoded normally. To activate this mode, command must be followed by a write to the SDRAM.
89 #define SDRAMC_MR_MODE_NOP 0x1 ///< The SDRAM Controller issues a NOP command when the SDRAM device is accessed regardless of the cycle. To activate this mode, command must be followed by a write to the SDRAM.
90 #define SDRAMC_MR_MODE_ALLBANKS_PRECHARGE 0x2 ///< The SDRAM Controller issues an "All Banks Precharge" command when the SDRAM device is accessed regardless of the cycle. To activate this mode, command must be followed by a write to the SDRAM.
91 #define SDRAMC_MR_MODE_LOAD_MODEREG 0x3 ///< The SDRAM Controller issues a "Load Mode Register" command when the SDRAM device is accessed regardless of the cycle. To activate this mode, command must be followed by a write to the SDRAM.
92 #define SDRAMC_MR_MODE_AUTO_REFRESH 0x4 ///< The SDRAM Controller issues an "Auto-Refresh" Command when the SDRAM device is accessed regardless of the cycle. Previously, an "All Banks Precharge" command must be issued. To activate this mode, command must be followed by a write to the SDRAM.
93 #define SDRAMC_MR_MODE_EXT_LOAD_MODEREG 0x5 ///< The SDRAM Controller issues an "Extended Load Mode Register" command when the SDRAM device is accessed regardless of the cycle. To activate this mode, the "Extended Load Mode Register" command must be followed by a write to the SDRAM. The write in the SDRAM must be done in the appropriate bank; most low-power SDRAM devices use the bank 1.
94 #define SDRAMC_MR_MODE_DEEP_POWERDOWN 0x6 ///< Deep power-down mode. Enters deep power-down mode.
98 * Defines for bit fields in SDRAMC_TR register.
101 #define SDRAMC_TR_COUNT_MASK 0xfff
102 #define SDRAMC_TR_COUNT(value) (SDRAMC_TR_COUNT_MASK & (value))
106 * Defines for bit fields in SDRAMC_CR register.
109 #define SDRAMC_CR_NC_SHIFT 0
110 #define SDRAMC_CR_NC_MASK 0x3 ///< Number of Column Bits
111 #define SDRAMC_CR_NC_COL8 0x0 ///< 8 column bits
112 #define SDRAMC_CR_NC_COL9 0x1 ///< 9 column bits
113 #define SDRAMC_CR_NC_COL10 0x2 ///< 10 column bits
114 #define SDRAMC_CR_NC_COL11 0x3 ///< 11 column bits
115 #define SDRAMC_CR_NR_SHIFT 2
116 #define SDRAMC_CR_NR_MASK (0x3 << 2) ///< Number of Row Bits
117 #define SDRAMC_CR_NR_ROW11 (0x0 << 2) ///< 11 row bits
118 #define SDRAMC_CR_NR_ROW12 (0x1 << 2) ///< 12 row bits
119 #define SDRAMC_CR_NR_ROW13 (0x2 << 2) ///< 13 row bits
120 #define SDRAMC_CR_NB (0x1 << 4) ///< Number of Banks
121 #define SDRAMC_CR_NB_BANK2 (0x0 << 4) ///< 2 banks
122 #define SDRAMC_CR_NB_BANK4 (0x1 << 4) ///< 4 banks
123 #define SDRAMC_CR_CAS_SHIFT 5
124 #define SDRAMC_CR_CAS_MASK (0x3 << SDRAMC_CR_CAS_SHIFT) ///< CAS Latency
125 #define SDRAMC_CR_CAS_LATENCY1 (0x1 << 5) ///< 1 cycle CAS latency
126 #define SDRAMC_CR_CAS_LATENCY2 (0x2 << 5) ///< 2 cycle CAS latency
127 #define SDRAMC_CR_CAS_LATENCY3 (0x3 << 5) ///< 3 cycle CAS latency
128 #define SDRAMC_CR_DBW (0x1 << 7) ///< Data Bus Width
129 #define SDRAMC_CR_TWR_SHIFT 8
130 #define SDRAMC_CR_TWR_MASK (0xf << SDRAMC_CR_TWR_SHIFT) ///< Write Recovery Delay
131 #define SDRAMC_CR_TWR(value) (SDRAMC_CR_TWR_MASK & ((value) << SDRAMC_CR_TWR_SHIFT))
132 #define SDRAMC_CR_TRC_TRFC_SHIFT 12
133 #define SDRAMC_CR_TRC_TRFC_MASK (0xf << SDRAMC_CR_TRC_TRFC_SHIFT) ///< Row Cycle Delay and Row Refresh Cycle
134 #define SDRAMC_CR_TRC_TRFC(value) (SDRAMC_CR_TRC_TRFC_MASK & ((value) << SDRAMC_CR_TRC_TRFC_SHIFT))
135 #define SDRAMC_CR_TRP_SHIFT 16
136 #define SDRAMC_CR_TRP_MASK (0xf << SDRAMC_CR_TRP_SHIFT) ///< Row Precharge Delay
137 #define SDRAMC_CR_TRP(value) (SDRAMC_CR_TRP_MASK & ((value) << SDRAMC_CR_TRP_SHIFT))
138 #define SDRAMC_CR_TRCD_SHIFT 20
139 #define SDRAMC_CR_TRCD_MASK (0xf << SDRAMC_CR_TRCD_SHIFT) ///< Row to Column Delay
140 #define SDRAMC_CR_TRCD(value) (SDRAMC_CR_TRCD_MASK & ((value) << SDRAMC_CR_TRCD_SHIFT))
141 #define SDRAMC_CR_TRAS_SHIFT 24
142 #define SDRAMC_CR_TRAS_MASK (0xf << SDRAMC_CR_TRAS_SHIFT) ///< Active to Precharge Delay
143 #define SDRAMC_CR_TRAS(value) (SDRAMC_CR_TRAS_MASK & ((value) << SDRAMC_CR_TRAS_SHIFT))
144 #define SDRAMC_CR_TXSR_SHIFT 28
145 #define SDRAMC_CR_TXSR_MASK (0xf << SDRAMC_CR_TXSR_SHIFT) ///< Exit Self Refresh to Active Delay
146 #define SDRAMC_CR_TXSR(value) (SDRAMC_CR_TXSR_MASK & ((value) << SDRAMC_CR_TXSR_SHIFT))
150 * Defines for bit fields in SDRAMC_MDR register.
153 #define SDRAMC_MDR_MD_MASK 0x3
154 #define SDRAMC_MDR_MD_SDRAM 0x0
155 #define SDRAMC_MDR_MD_LPSDRAM 0x1
158 #endif /* CPU_CM_SAM3X */
160 #endif /* SAM3_SDRAMC_H */