source: rtems/bsps/arm/lpc24xx/start/start-config-emc-dynamic.c @ cf5d5d80

5
Last change on this file since cf5d5d80 was cf5d5d80, checked in by Sebastian Huber <sebastian.huber@…>, on 05/09/19 at 10:31:31

bsp/lpc24xx: Fix dynamic EMC configurations

  • Property mode set to 100644
File size: 7.1 KB
RevLine 
[4f609eec]1/**
2 * @file
3 *
[c991eeec]4 * @ingroup RTEMSBSPsARMLPC24XX
[4f609eec]5 *
6 * @brief BSP start EMC dynamic memory configuration.
7 */
8
9/*
[2ffbc4d]10 * Copyright (c) 2011, 2019 embedded brains GmbH.  All rights reserved.
[4f609eec]11 *
12 *  embedded brains GmbH
[2ffbc4d]13 *  Dornierstr. 4
[4f609eec]14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
[c499856]20 * http://www.rtems.org/license/LICENSE.
[4f609eec]21 */
22
23#include <bsp/start-config.h>
24#include <bsp/lpc24xx.h>
25
[e4bda046]26/*
[2ffbc4d]27 * FIXME: The NXP example code uses different values for the following two
[e4bda046]28 * defines.  In the NXP example code they depend on the EMCCLK.  It is unclear
29 * how these values are determined.  The values from the NXP example code do
30 * not work.
31 */
32
33/* Use command delayed strategy */
34#define LPC24XX_EMC_DYNAMIC_READCONFIG_DEFAULT 0x1
35
36#define LPC24XX_EMCDLYCTL_DEFAULT 0x1112
37
[4a6cc2a]38BSP_START_DATA_SECTION const lpc24xx_emc_dynamic_config
[4f609eec]39  lpc24xx_start_config_emc_dynamic [] = {
[4a6cc2a]40#if defined(LPC24XX_EMC_MT48LC4M16A2)
[4f609eec]41  /* Dynamic Memory 0: Micron M T48LC 4M16 A2 P 75 IT */
42  {
[f7deb58]43    /* 15.6 us */
44    .refresh = LPC24XX_PS_TO_EMCCLK(15600000, 0) / 16,
[4f609eec]45
[e4bda046]46    .readconfig = LPC24XX_EMC_DYNAMIC_READCONFIG_DEFAULT,
[4f609eec]47
48    /* Precharge command period 20 ns */
[2ffbc4d]49    .trp = LPC24XX_PS_TO_EMCCLK(20000, 1),
[4f609eec]50
51    /* Active to precharge command period 44 ns */
[2ffbc4d]52    .tras = LPC24XX_PS_TO_EMCCLK(44000, 1),
53
54    /*
55     * UM: "devices without this parameter you use the same value as tXSR"
56     *
57     * The tXSR is 75 ns.
58     */
59    .tsrex = LPC24XX_PS_TO_EMCCLK(75000, 1),
60
61    /*
62     * Forum: "tAPR, not in datasheet, if fail, use tRCD val"
63     *
64     * The tRCD is 20 ns */
65    .tapr = LPC24XX_PS_TO_EMCCLK(20000, 1),
[4f609eec]66
67    /* Data-in to active command period tWR + tRP */
[2ffbc4d]68    .tdal = LPC24XX_PS_TO_EMCCLK(15000 + 20000, 0),
[4f609eec]69
[2ffbc4d]70    /* Write recovery time 15 ns or 1 CLK + 7.5ns */
71    .twr = LPC24XX_PS_TO_EMCCLK(15000, 1),
[4f609eec]72
73    /* Active to active command period 66 ns */
[2ffbc4d]74    .trc = LPC24XX_PS_TO_EMCCLK(66000, 1),
[4f609eec]75
76    /* Auto refresh period 66 ns */
[2ffbc4d]77    .trfc = LPC24XX_PS_TO_EMCCLK(66000, 1),
[4f609eec]78
79    /* Exit self refresh to active command period 75 ns */
[2ffbc4d]80    .txsr = LPC24XX_PS_TO_EMCCLK(75000, 1),
[4f609eec]81
82    /* Active bank a to active bank b command period 15 ns */
[2ffbc4d]83    .trrd = LPC24XX_PS_TO_EMCCLK(15000, 1),
[4f609eec]84
85    /* Load mode register to active or refresh command period 2 tCK */
[cf5d5d80]86    .tmrd = 1, /* + 1 */
87
88    .emcdlyctl = LPC24XX_EMCDLYCTL_DEFAULT
[4f609eec]89  }
[4868c771]90#elif defined(LPC24XX_EMC_IS42S32800D7)
[f7deb58]91  /* Dynamic Memory 0: ISSI IS42S32800D7 */
[4868c771]92  {
[f7deb58]93    /* 15.6 us */
94    .refresh = LPC24XX_PS_TO_EMCCLK(15600000, 0) / 16,
[4868c771]95
[e4bda046]96    .readconfig = LPC24XX_EMC_DYNAMIC_READCONFIG_DEFAULT,
[4868c771]97
[f7deb58]98    /* 20ns */
99    .trp = LPC24XX_PS_TO_EMCCLK(20000, 1),
[4868c771]100
[f7deb58]101    /* 45ns */
102    .tras = LPC24XX_PS_TO_EMCCLK(45000, 1),
[4868c771]103
[f7deb58]104    /* 70ns (tXSR) */
105    .tsrex = LPC24XX_PS_TO_EMCCLK(70000, 1),
[4868c771]106
[f7deb58]107    /* 20ns (tRCD) */
108    .tapr = LPC24XX_PS_TO_EMCCLK(20000, 1),
[4868c771]109
110    /* n clock cycles -> 38.8ns >= 35ns */
[f7deb58]111    .tdal = LPC24XX_PS_TO_EMCCLK(35000, 0),
[4868c771]112
[f7deb58]113    /* 14ns (tDPL) */
114    .twr = LPC24XX_PS_TO_EMCCLK(14000, 1),
[4868c771]115
[f7deb58]116    /* 67.5ns */
117    .trc = LPC24XX_PS_TO_EMCCLK(67500, 1),
[4868c771]118
[f7deb58]119    /* 67.5ns (tRC) */
120    .trfc = LPC24XX_PS_TO_EMCCLK(67500, 1),
[4868c771]121
[f7deb58]122    /* 70ns */
123    .txsr = LPC24XX_PS_TO_EMCCLK(70000, 1),
[4868c771]124
[f7deb58]125    /* 14ns */
126    .trrd = LPC24XX_PS_TO_EMCCLK(14000, 1),
[4868c771]127
[f7deb58]128    /* 14ns */
[e4bda046]129    .tmrd = LPC24XX_PS_TO_EMCCLK(14000, 1),
130
131    .emcdlyctl = LPC24XX_EMCDLYCTL_DEFAULT
[4868c771]132  }
[4a6cc2a]133#elif defined(LPC24XX_EMC_W9825G2JB75I)
[f7deb58]134  /* Dynamic Memory 0: Winbond W9825G2JB75I */
[4a6cc2a]135  {
[f7deb58]136    /* 15.6 us */
137    .refresh = LPC24XX_PS_TO_EMCCLK(15600000, 0) / 16,
[4a6cc2a]138
[e4bda046]139    .readconfig = LPC24XX_EMC_DYNAMIC_READCONFIG_DEFAULT,
[4a6cc2a]140
[f7deb58]141    /* 20ns */
142    .trp = LPC24XX_PS_TO_EMCCLK(20000, 1),
[4a6cc2a]143
[f7deb58]144    /* 45ns */
145    .tras = LPC24XX_PS_TO_EMCCLK(45000, 1),
[4a6cc2a]146
[f7deb58]147    /* 75ns (tXSR) */
148    .tsrex = LPC24XX_PS_TO_EMCCLK(75000, 1),
[4a6cc2a]149
[f7deb58]150    /* 20ns (tRCD) */
151    .tapr = LPC24XX_PS_TO_EMCCLK(20000, 1),
[4a6cc2a]152
[f7deb58]153    /* tWR + tRP -> 2 * tCK + 20ns */
154    .tdal = 2 + LPC24XX_PS_TO_EMCCLK(20000, 0),
[4a6cc2a]155
156    /* (n + 1) clock cycles == 2 * tCK */
157    .twr = 1,
158
[f7deb58]159    /* 65ns */
160    .trc = LPC24XX_PS_TO_EMCCLK(65000, 1),
[4a6cc2a]161
[f7deb58]162    /* 65ns (tRC) */
163    .trfc = LPC24XX_PS_TO_EMCCLK(65000, 1),
[4a6cc2a]164
[f7deb58]165    /* 75ns */
166    .txsr = LPC24XX_PS_TO_EMCCLK(50000, 1),
[4a6cc2a]167
168    /* (n + 1) clock cycles == 2 * tCK */
169    .trrd = 1,
170
171    /* (n + 1) clock cycles == 2 * tCK (tRSC)*/
[e4bda046]172    .tmrd = 1,
173
174    .emcdlyctl = LPC24XX_EMCDLYCTL_DEFAULT
[4a6cc2a]175  }
[4f609eec]176#elif defined(LPC24XX_EMC_K4S561632E)
177  {
178    .refresh = 35,
[e4bda046]179    .readconfig = LPC24XX_EMC_DYNAMIC_READCONFIG_DEFAULT,
[4f609eec]180    .trp = 2,
181    .tras = 4,
182    .tsrex = 5,
183    .tapr = 1,
184    .tdal = 5,
185    .twr = 3,
186    .trc = 5,
187    .trfc = 5,
188    .txsr = 5,
189    .trrd = 3,
[cf5d5d80]190    .tmrd = 2,
191    .emcdlyctl = LPC24XX_EMCDLYCTL_DEFAULT
[4f609eec]192  }
[4a6cc2a]193#elif defined(LPC24XX_EMC_IS42S32800B)
[f7deb58]194  {
195    /* 15.6us */
196    .refresh = LPC24XX_PS_TO_EMCCLK(15600000, 0) / 16,
197
[e4bda046]198    .readconfig = LPC24XX_EMC_DYNAMIC_READCONFIG_DEFAULT,
[f7deb58]199
200    /* 20ns */
201    .trp = LPC24XX_PS_TO_EMCCLK(20000, 1),
202
203    /* 45ns */
204    .tras = LPC24XX_PS_TO_EMCCLK(45000, 1),
205
206    /* 70ns (tRC) */
207    .tsrex = LPC24XX_PS_TO_EMCCLK(70000, 1),
208
209    /* FIXME */
210    .tapr = LPC24XX_PS_TO_EMCCLK(40000, 1),
211
212    /* tWR + tRP -> 2 * tCK + 20ns */
213    .tdal = 2 + LPC24XX_PS_TO_EMCCLK(20000, 0),
214
215    /* (n + 1) clock cycles == 2 * tCK */
216    .twr = 1,
217
218    /* 70ns */
219    .trc = LPC24XX_PS_TO_EMCCLK(70000, 1),
220
221    /* 70ns */
222    .trfc = LPC24XX_PS_TO_EMCCLK(70000, 1),
223
224    /* 70ns (tRC) */
225    .txsr = LPC24XX_PS_TO_EMCCLK(70000, 1),
226
227    /* 14ns */
228    .trrd = LPC24XX_PS_TO_EMCCLK(14000, 1),
229
230    /* (n + 1) clock cycles == 2 * tCK */
231    .tmrd = 1,
232
[e4bda046]233    .emcdlyctl = LPC24XX_EMCDLYCTL_DEFAULT
[f7deb58]234  }
[4f609eec]235#endif
236};
237
[6cad529]238/*
239 * Mode shift is determined for RBC by:
240 *
241 *   bus width in bits / 16 + bank bits + column bits
242 *
243 * Mode shift is determined for BRC by:
244 *
245 *   bus width in bits / 16 + column bits
246 */
[4a6cc2a]247BSP_START_DATA_SECTION const lpc24xx_emc_dynamic_chip_config
[4f609eec]248  lpc24xx_start_config_emc_dynamic_chip [] = {
[4a6cc2a]249#if defined(LPC24XX_EMC_MT48LC4M16A2)
[4f609eec]250  {
251    .chip_select = (volatile lpc_emc_dynamic *) &EMC_DYN_CFG0,
252
253    /*
254     * Use SDRAM, 0 0 001 01 address mapping, disabled buffer, unprotected
[6cad529]255     * writes.  4 banks, 12 row lines, 8 column lines, RBC.
[4f609eec]256     */
257    .config = 0x280,
258
259    .rascas = EMC_DYN_RASCAS_RAS(2) | EMC_DYN_RASCAS_CAS(2, 0),
260    .mode = 0xa0000000 | (0x23 << (1 + 2 + 8))
261  }
[4868c771]262#elif defined(LPC24XX_EMC_W9825G2JB75I) \
[3e600b2]263  || defined(LPC24XX_EMC_IS42S32800D7) \
264  || defined(LPC24XX_EMC_IS42S32800B)
[4a6cc2a]265  {
266    .chip_select = (volatile lpc_emc_dynamic *) &EMC_DYN_CFG0,
267
268    /* 32-bit data bus, 4 banks, 12 row lines, 9 column lines, RBC */
[4868c771]269    .config = 0x4480,
[4a6cc2a]270
271    /* RAS based on tRCD = 20ns */
272    .rascas = EMC_DYN_RASCAS_RAS(2) | EMC_DYN_RASCAS_CAS(2, 0),
273
[4868c771]274    /* CAS 2, burst length 4 */
275    .mode = 0xa0000000 | (0x22 << (2 + 2 + 9))
[4a6cc2a]276  }
[4f609eec]277#elif defined(LPC24XX_EMC_K4S561632E)
278  {
279    .chip_select = (volatile lpc_emc_dynamic *) &EMC_DYN_CFG0,
280    .config = 0x680,
281    .rascas = EMC_DYN_RASCAS_RAS(3) | EMC_DYN_RASCAS_CAS(3, 0),
282    .mode = 0xa0000000 | (0x33 << 12)
283  }
284#endif
285};
286
[4a6cc2a]287BSP_START_DATA_SECTION const size_t
[4f609eec]288  lpc24xx_start_config_emc_dynamic_chip_count =
289    sizeof(lpc24xx_start_config_emc_dynamic_chip)
290      / sizeof(lpc24xx_start_config_emc_dynamic_chip [0]);
Note: See TracBrowser for help on using the repository browser.