00001
00039 #ifndef REGS_XMEGA_EBI_H_INCLUDED
00040 #define REGS_XMEGA_EBI_H_INCLUDED
00041
00042 #include <chip/memory-map.h>
00043 #include <io.h>
00044
00051
00052
00053 #define EBI_CTRL 0x00 //!< Control register
00054 #define EBI_SDRAMCTRLA 0x01 //!< SDRAM control register A
00055 #define EBI_SDRAMCTRLB 0x08 //!< SDRAM control register B
00056 #define EBI_SDRAMCTRLC 0x09 //!< SDRAM control register C
00057 #define EBI_REFRESHL 0x04 //!< SDRAM refresh period low byte
00058 #define EBI_REFRESHH 0x05 //!< SDRAM refresh period high byte
00059 #define EBI_INITDLYL 0x06 //!< SDRAM init. delay low byte
00060 #define EBI_INITDLYH 0x07 //!< SDRAM init. delay high byte
00061
00062
00064
00065 #define EBI_IFMODE_START 0 //!< EBI mode
00066 #define EBI_IFMODE_SIZE 2 //!< EBI mode
00067 #define EBI_SRMODE_START 2 //!< SRAM mode
00068 #define EBI_SRMODE_SIZE 2 //!< SRAM mode
00069 #define EBI_LPCMODE_START 4 //!< SRAM Low Pin-Count mode
00070 #define EBI_LPCMODE_SIZE 2 //!< SRAM Low Pin-Count mode
00071 #define EBI_SDDATAW_START 6 //!< SDRAM data width setting
00072 #define EBI_SDDATAW_SIZE 2 //!< SDRAM data width setting
00073
00074
00076
00077 #define EBI_IFMODE_DISABLED 0 //!< EBI disabled
00078 #define EBI_IFMODE_3PORT 1 //!< EBI enabled w/ 3-port interface
00079 #define EBI_IFMODE_4PORT 2 //!< EBI enabled w/ 4-port interface
00080 #define EBI_IFMODE_2PORT 3 //!< EBI enabled w/ 2-port interface
00081
00082
00084
00085 #define EBI_SRMODE_ALE1 0 //!< Address bytes 0 and 1 multiplexed
00086 #define EBI_SRMODE_ALE2 1 //!< Address bytes 0 and 2 multiplexed
00087 #define EBI_SRMODE_ALE12 2 //!< Address bytes 0, 1 and 2 multiplexed
00088 #define EBI_SRMODE_NOALE 3 //!< No address multiplexing
00089
00090
00092
00093
00094 #define EBI_LPCMODE_ALE1 0
00095
00096 #define EBI_LPCMODE_ALE12 2
00097
00098
00100
00101 #define EBI_SDDATAW_4BIT 0 //!< 4-bit data bus
00102 #define EBI_SDDATAW_8BIT 1 //!< 8-bit data bus
00103
00104
00105
00107
00108 #define EBI_SDCOL_START 0 //!< SDRAM column bits
00109 #define EBI_SDCOL_SIZE 2 //!< SDRAM column bits
00110 #define EBI_SDROW_BIT 2 //!< SDRAM row bits (11/12 bits)
00111 #define EBI_SDCAS_BIT 3 //!< SDRAM CAS latency (2/3 cycles)
00112
00113
00115
00116 #define EBI_SDCOL_8BIT 0 //!< 8 column bits
00117 #define EBI_SDCOL_9BIT 1 //!< 9 column bits
00118 #define EBI_SDCOL_10BIT 2 //!< 10 column bits
00119 #define EBI_SDCOL_11BIT 3 //!< 11 column bits
00120
00121
00122
00124
00125
00126 #define EBI_RPDLY_START 0
00127
00128 #define EBI_RPDLY_SIZE 3
00129
00130 #define EBI_ROWCYCDLY_START 3
00131
00132 #define EBI_ROWCYCDLY_SIZE 3
00133
00134 #define EBI_MRDLY_START 6
00135
00136 #define EBI_MRDLY_SIZE 2
00137
00138
00140
00141
00142 #define EBI_ROWCOLDLY_START 0
00143
00144 #define EBI_ROWCOLDLY_SIZE 3
00145
00146 #define EBI_ESRDLY_START 3
00147
00148 #define EBI_ESRDLY_SIZE 3
00149
00150 #define EBI_WRDLY_START 6
00151
00152 #define EBI_WRDLY_SIZE 2
00153
00154
00156
00157
00158 #define EBI_REFRESH_START 0
00159
00160 #define EBI_REFRESH_SIZE 10
00161
00162
00164
00165
00166 #define EBI_REFRESHL_START 0
00167
00168 #define EBI_REFRESHL_SIZE 8
00169
00170
00172
00173
00174 #define EBI_REFRESHH_START 0
00175
00176 #define EBI_REFRESHH_SIZE 2
00177
00178
00180
00181
00182 #define EBI_INITDLY_START 0
00183
00184 #define EBI_INITDLY_SIZE 14
00185
00186
00188
00189
00190 #define EBI_INITDLYL_START 0
00191
00192 #define EBI_INITDLYL_SIZE 8
00193
00194
00196
00197
00198 #define EBI_INITDLYH_START 0
00199
00200 #define EBI_INITDLYH_SIZE 6
00201
00202
00204
00205
00206 #define EBI_BIT(name) \
00207 (1U << EBI_##name##_BIT)
00208
00209 #define EBI_BF(name, value) \
00210 ((value) << EBI_##name##_START)
00211
00212 #define EBI_BFMASK(name) \
00213 (((1U << EBI_##name##_SIZE) - 1) << EBI_##name##_START)
00214
00215 #define EBI_BFEXT(name, regval) \
00216 (((regval) >> EBI_##name##_START) \
00217 & ((1U << EBI_##name##_SIZE) - 1))
00218
00219 #define EBI_BFINS(name, value, regval) \
00220 (((regval) & ~(((1U << EBI_##name##_SIZE) - 1) \
00221 << EBI_##name##_START)) \
00222 | EBI_BF(name, value))
00223
00224
00226
00227
00228 #define ebi_read_reg(reg) \
00229 mmio_read8((void *)((uintptr_t)(EBI_BASE) + EBI_##reg))
00230
00231 #define ebi_write_reg(reg, value) \
00232 mmio_write8((void *)((uintptr_t)(EBI_BASE) + EBI_##reg), (value))
00233
00238 #define ebi_read_word_reg(reg) \
00239 mmio_read16((void *)((uintptr_t)(EBI_BASE) + EBI_##reg##L))
00240
00245 #define ebi_write_word_reg(reg, value) \
00246 mmio_write16((void *)((uintptr_t)(EBI_BASE) + EBI_##reg##L), (value))
00247
00248
00250
00251
00258
00259
00260 #define EBICS_CS0 0x10 //!< EBI Chip Select 0
00261 #define EBICS_CS1 0x14 //!< EBI Chip Select 1
00262 #define EBICS_CS2 0x18 //!< EBI Chip Select 2
00263 #define EBICS_CS3 0x1c //!< EBI Chip Select 3
00264
00265
00267
00268 #define EBICS_CTRLA 0x00 //!< Control register A
00269 #define EBICS_CTRLB 0x01 //!< Control register B
00270 #define EBICS_BASEADDRL 0x02 //!< Base address low byte
00271 #define EBICS_BASEADDRH 0x03 //!< Base address high byte
00272
00273
00274
00276
00277
00278 #define EBICS_MODE_START 0
00279
00280 #define EBICS_MODE_SIZE 2
00281
00282 #define EBICS_ASIZE_START 2
00283
00284 #define EBICS_ASIZE_SIZE 5
00285
00286
00288
00289 #define EBICS_MODE_DISABLE 0 //!< CS disabled
00290 #define EBICS_MODE_SRAM 1 //!< CS enabled for SRAM
00291 #define EBICS_MODE_LPC 2 //!< CS enabled for low pin-count SRAM
00292 #define EBICS_MODE_SDRAM 3 //!< CS enabled for SDRAM
00293
00294
00296
00297
00298 #define EBICS_SRWS_START 0
00299
00300 #define EBICS_SRWS_SIZE 3
00301
00302
00304
00305 #define EBICS_SDMODE_START 0 //!< SDRAM mode
00306 #define EBICS_SDMODE_SIZE 2 //!< SDRAM mode
00307 #define EBICS_SDSREN_BIT 2 //!< SDRAM self-refresh enable
00308 #define EBICS_SDINITDONE_BIT 7 //!< SDRAM initialization done
00309
00310
00312
00313 #define EBICS_SDMODE_NORMAL 0 //!< Normal mode
00314 #define EBICS_SDMODE_LOAD 1 //!< Load mode
00315
00316
00318
00319
00320 #define EBICS_BASEADDR_START 4
00321
00322 #define EBICS_BASEADDR_SIZE 12
00323
00324
00326
00327
00328 #define EBICS_BASEADDRL_START 4
00329
00330 #define EBICS_BASEADDRL_SIZE 4
00331
00332
00334
00335
00336 #define EBICS_BASEADDRH_START 0
00337
00338 #define EBICS_BASEADDRH_SIZE 8
00339
00340
00342
00343
00344 #define EBICS_BIT(name) \
00345 (1U << EBICS_##name##_BIT)
00346
00347 #define EBICS_BF(name, value) \
00348 ((value) << EBICS_##name##_START)
00349
00350 #define EBICS_BFMASK(name) \
00351 (((1U << EBICS_##name##_SIZE) - 1) << EBICS_##name##_START)
00352
00353 #define EBICS_BFEXT(name, regval) \
00354 (((regval) >> EBICS_##name##_START) \
00355 & ((1U << EBICS_##name##_SIZE) - 1))
00356
00357 #define EBICS_BFINS(name, value, regval) \
00358 (((regval) & ~(((1U << EBICS_##name##_SIZE) - 1) \
00359 << EBICS_##name##_START)) \
00360 | EBICS_BF(name, value))
00361
00362
00364
00365
00366 #define ebics_read_reg(cs, reg) \
00367 mmio_read8((void *)((uintptr_t)(EBI_BASE) + EBICS_##cs + EBICS_##reg))
00368
00369 #define ebics_write_reg(cs, reg, value) \
00370 mmio_write8((void *)((uintptr_t)(EBI_BASE) + EBICS_##cs \
00371 + EBICS_##reg), (value))
00372
00377 #define ebics_read_word_reg(cs, reg) \
00378 mmio_read16((void *)((uintptr_t)(EBI_BASE) + EBICS_##cs \
00379 + EBICS_##reg##L))
00380
00385 #define ebics_write_word_reg(cs, reg, value) \
00386 mmio_write16((void *)((uintptr_t)(EBI_BASE) + EBICS_##cs \
00387 + EBICS_##reg##L), (value))
00388
00389
00391
00392 #endif