Changeset 4f609eec in rtems


Ignore:
Timestamp:
Oct 17, 2011, 10:40:00 AM (10 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
38cc8d53
Parents:
a17ec5c
Message:

2011-10-17 Sebastian Huber <sebastian.huber@…>

  • include/start-config.h, make/custom/lpc24xx_plx800_rom_int.cfg, startup/linkcmds.lpc24xx_plx800_rom_int, startup/start-config-emc-dynamic.c, startup/start-config-emc-static.c, startup/start-config-pinsel.c: New files.
  • Makefile.am, configure.ac, preinstall.am: Reflect changes above.
  • startup/bspstarthooks.c: Use configuration tables for EMC initialization.
Location:
c/src/lib/libbsp/arm/lpc24xx
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/lpc24xx/ChangeLog

    ra17ec5c r4f609eec  
     12011-10-17      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * include/start-config.h, make/custom/lpc24xx_plx800_rom_int.cfg,
     4        startup/linkcmds.lpc24xx_plx800_rom_int,
     5        startup/start-config-emc-dynamic.c, startup/start-config-emc-static.c,
     6        startup/start-config-pinsel.c: New files.
     7        * Makefile.am, configure.ac, preinstall.am: Reflect changes above.
     8        * startup/bspstarthooks.c: Use configuration tables for EMC
     9        initialization.
     10
    1112011-08-08      Sebastian Huber <sebastian.huber@embedded-brains.de>
    212
  • c/src/lib/libbsp/arm/lpc24xx/Makefile.am

    ra17ec5c r4f609eec  
    4040include_bsp_HEADERS += ../shared/lpc/include/lpc-dma.h
    4141include_bsp_HEADERS += ../shared/lpc/include/lpc-lcd.h
    42 include_bsp_HEADERS += include/irq.h
    43 include_bsp_HEADERS += include/lpc24xx.h
    44 include_bsp_HEADERS += include/system-clocks.h
    45 include_bsp_HEADERS += include/ssp.h
    4642include_bsp_HEADERS += include/dma.h
    4743include_bsp_HEADERS += include/i2c.h
    4844include_bsp_HEADERS += include/io.h
     45include_bsp_HEADERS += include/irq.h
    4946include_bsp_HEADERS += include/lcd.h
     47include_bsp_HEADERS += include/lpc24xx.h
    5048include_bsp_HEADERS += include/lpc-clock-config.h
    5149include_bsp_HEADERS += include/lpc-ethernet-config.h
     50include_bsp_HEADERS += include/ssp.h
     51include_bsp_HEADERS += include/start-config.h
     52include_bsp_HEADERS += include/system-clocks.h
    5253
    5354include_HEADERS += ../../shared/include/tm27.h
     
    6465
    6566project_lib_DATA += startup/linkcmds
    66 EXTRA_DIST = startup/linkcmds.lpc24xx_ea
    67 EXTRA_DIST += startup/linkcmds.lpc24xx_ncs_rom_int
    68 EXTRA_DIST += startup/linkcmds.lpc24xx_ncs_rom_ext
    69 EXTRA_DIST += startup/linkcmds.lpc24xx_ncs_ram
     67EXTRA_DIST =
    7068EXTRA_DIST += startup/linkcmds.lpc2362
    7169EXTRA_DIST += startup/linkcmds.lpc23xx_tli800
     70EXTRA_DIST += startup/linkcmds.lpc24xx_ea
     71EXTRA_DIST += startup/linkcmds.lpc24xx_ncs_ram
     72EXTRA_DIST += startup/linkcmds.lpc24xx_ncs_rom_ext
     73EXTRA_DIST += startup/linkcmds.lpc24xx_ncs_rom_int
     74EXTRA_DIST += startup/linkcmds.lpc24xx_plx800_rom_int
    7275
    7376###############################################################################
     
    143146# Start hooks
    144147libbsp_a_SOURCES += startup/bspstarthooks.c
     148libbsp_a_SOURCES += startup/start-config-emc-dynamic.c
     149libbsp_a_SOURCES += startup/start-config-emc-static.c
     150libbsp_a_SOURCES += startup/start-config-pinsel.c
    145151
    146152###############################################################################
  • c/src/lib/libbsp/arm/lpc24xx/configure.ac

    ra17ec5c r4f609eec  
    3434
    3535RTEMS_BSPOPTS_SET([LPC24XX_CCLK],[lpc23*],[58982400U])
     36RTEMS_BSPOPTS_SET([LPC24XX_CCLK],[lpc24xx_plx800*],[51612800U])
    3637RTEMS_BSPOPTS_SET([LPC24XX_CCLK],[*],[72000000U])
    3738RTEMS_BSPOPTS_HELP([LPC24XX_CCLK],[CPU clock in Hz])
     
    4445RTEMS_BSPOPTS_HELP([LPC24XX_ETHERNET_RMII],[enable RMII for Ethernet])
    4546
     47RTEMS_BSPOPTS_SET([LPC24XX_EMC_MICRON],[lpc24xx_plx800_rom_*],[1])
    4648RTEMS_BSPOPTS_SET([LPC24XX_EMC_MICRON],[lpc24xx_ncs_rom_*],[1])
    4749RTEMS_BSPOPTS_HELP([LPC24XX_EMC_MICRON],[enable Micron configuration for EMC])
     
    4951RTEMS_BSPOPTS_SET([LPC24XX_EMC_NUMONYX],[lpc24xx_ncs_rom_*],[1])
    5052RTEMS_BSPOPTS_HELP([LPC24XX_EMC_NUMONYX],[enable Numonyx configuration for EMC])
     53
     54RTEMS_BSPOPTS_SET([LPC24XX_EMC_W9825G2JB],[lpc24xx_plx800_rom_*],[1])
     55RTEMS_BSPOPTS_HELP([LPC24XX_EMC_W9825G2JB],[enable Winbond W9825G2JB configuration for EMC])
    5156
    5257RTEMS_BSPOPTS_SET([LPC24XX_EMC_TEST],[*],[])
  • c/src/lib/libbsp/arm/lpc24xx/preinstall.am

    ra17ec5c r4f609eec  
    102102PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/lpc-lcd.h
    103103
    104 $(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    105         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
    106 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
    107 
    108 $(PROJECT_INCLUDE)/bsp/lpc24xx.h: include/lpc24xx.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    109         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/lpc24xx.h
    110 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/lpc24xx.h
    111 
    112 $(PROJECT_INCLUDE)/bsp/system-clocks.h: include/system-clocks.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    113         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/system-clocks.h
    114 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/system-clocks.h
    115 
    116 $(PROJECT_INCLUDE)/bsp/ssp.h: include/ssp.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    117         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/ssp.h
    118 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/ssp.h
    119 
    120104$(PROJECT_INCLUDE)/bsp/dma.h: include/dma.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    121105        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/dma.h
     
    130114PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/io.h
    131115
     116$(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     117        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
     118PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
     119
    132120$(PROJECT_INCLUDE)/bsp/lcd.h: include/lcd.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    133121        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/lcd.h
    134122PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/lcd.h
     123
     124$(PROJECT_INCLUDE)/bsp/lpc24xx.h: include/lpc24xx.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     125        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/lpc24xx.h
     126PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/lpc24xx.h
    135127
    136128$(PROJECT_INCLUDE)/bsp/lpc-clock-config.h: include/lpc-clock-config.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     
    141133        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/lpc-ethernet-config.h
    142134PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/lpc-ethernet-config.h
     135
     136$(PROJECT_INCLUDE)/bsp/ssp.h: include/ssp.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     137        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/ssp.h
     138PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/ssp.h
     139
     140$(PROJECT_INCLUDE)/bsp/start-config.h: include/start-config.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     141        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/start-config.h
     142PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/start-config.h
     143
     144$(PROJECT_INCLUDE)/bsp/system-clocks.h: include/system-clocks.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     145        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/system-clocks.h
     146PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/system-clocks.h
    143147
    144148$(PROJECT_INCLUDE)/tm27.h: ../../shared/include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
  • c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c

    ra17ec5c r4f609eec  
    2828#include <bsp/lpc24xx.h>
    2929#include <bsp/lpc-emc.h>
    30 
    31 #if defined(LPC24XX_EMC_MICRON) || defined(LPC24XX_EMC_NUMONYX)
    32   #define LPC24XX_EMC_INIT
    33 #endif
    34 
    35 static volatile lpc_emc *const emc = (lpc_emc *) EMC_BASE_ADDR;
    36 
    37 typedef struct {
    38   uint32_t refresh;
    39   uint32_t readconfig;
    40   uint32_t trp;
    41   uint32_t tras;
    42   uint32_t tsrex;
    43   uint32_t tapr;
    44   uint32_t tdal;
    45   uint32_t twr;
    46   uint32_t trc;
    47   uint32_t trfc;
    48   uint32_t txsr;
    49   uint32_t trrd;
    50   uint32_t tmrd;
    51 } lpc24xx_emc_dynamic_config;
    52 
    53 typedef struct {
    54   uint32_t config;
    55   uint32_t rascas;
    56   uint32_t mode;
    57 } lpc24xx_emc_dynamic_chip_config;
    58 
    59 typedef struct {
    60   uint32_t config;
    61   uint32_t waitwen;
    62   uint32_t waitoen;
    63   uint32_t waitrd;
    64   uint32_t waitpage;
    65   uint32_t waitwr;
    66   uint32_t waitrun;
    67 } lpc24xx_emc_static_chip_config;
    68 
    69 #ifdef LPC24XX_EMC_MICRON
    70   static void BSP_START_TEXT_SECTION lpc24xx_ram_test_32(void)
    71   {
    72     #ifdef LPC24XX_EMC_TEST
    73       int *begin = (int *) 0xa0000000;
    74       const int *end = (const int *) 0xa0800000;
    75       int *out = begin;
    76 
    77       while (out != end) {
    78         *out = (int) out;
    79         ++out;
    80       }
    81 
    82       out = begin;
    83       while (out != end) {
    84         if (*out != (int) out) {
    85           while (true) {
    86             /* Do nothing */
    87           }
    88         }
    89         ++out;
    90       }
    91     #endif
    92   }
    93 
    94   static void BSP_START_TEXT_SECTION lpc24xx_cpu_delay(unsigned ticks)
    95   {
    96     unsigned i = 0;
    97 
    98     /* One loop execution needs four instructions */
    99     ticks /= 4;
    100 
    101     for (i = 0; i <= ticks; ++i) {
    102       __asm__ volatile ("nop");
    103     }
    104   }
    105 
    106   static void BSP_START_TEXT_SECTION lpc24xx_udelay(unsigned us)
    107   {
    108     lpc24xx_cpu_delay(us * (LPC24XX_CCLK / 1000000));
    109   }
    110 #endif
     30#include <bsp/start-config.h>
     31
     32static void BSP_START_TEXT_SECTION lpc24xx_cpu_delay(unsigned ticks)
     33{
     34  unsigned i = 0;
     35
     36  /* One loop execution needs four instructions */
     37  ticks /= 4;
     38
     39  for (i = 0; i <= ticks; ++i) {
     40    __asm__ volatile ("nop");
     41  }
     42}
     43
     44static void BSP_START_TEXT_SECTION lpc24xx_udelay(unsigned us)
     45{
     46  lpc24xx_cpu_delay(us * (LPC24XX_CCLK / 1000000));
     47}
    11148
    11249static void BSP_START_TEXT_SECTION lpc24xx_init_emc_pinsel(void)
    11350{
    114   #ifdef LPC24XX_EMC_INIT
    115     static const BSP_START_DATA_SECTION uint32_t pinsel_5_9 [5] = {
    116       0x05010115,
    117       0x55555555,
    118       0x0,
    119       0x55555555,
    120       0x40050155
    121     };
     51  bsp_start_memcpy(
     52    (int *) &PINSEL5,
     53    (const int *) &lpc24xx_start_config_pinsel_5_9,
     54    lpc24xx_start_config_pinsel_5_9_size
     55  );
     56}
     57
     58static void BSP_START_TEXT_SECTION lpc24xx_init_emc_static(void)
     59{
     60  size_t i = 0;
     61  size_t chip_count = lpc24xx_start_config_emc_static_chip_count;
     62
     63  for (i = 0; i < chip_count; ++i) {
     64    const lpc24xx_emc_static_chip_config *chip_config =
     65      &lpc24xx_start_config_emc_static_chip [i];
     66    lpc24xx_emc_static_chip_config chip_config_on_stack;
     67    size_t config_size = sizeof(chip_config_on_stack.config);
    12268
    12369    bsp_start_memcpy(
    124       (int *) &PINSEL5,
    125       (const int *) &pinsel_5_9,
    126       sizeof(pinsel_5_9)
    127     );
    128   #endif
    129 }
    130 
    131 static void BSP_START_TEXT_SECTION lpc24xx_init_emc_static(void)
    132 {
    133   #ifdef LPC24XX_EMC_NUMONYX
    134     /*
    135      * Static Memory 1: Numonyx M29W160EB
    136      *
    137      * 1 clock cycle = 1/72MHz = 13.9ns
    138      */
    139     static const BSP_START_DATA_SECTION lpc24xx_emc_static_chip_config chip_config = {
    140       /*
    141        * 16 bit, page mode disabled, active LOW chip select, extended wait
    142        * disabled, writes not protected, byte lane state LOW/LOW (!).
    143        */
    144       .config = 0x81,
    145 
    146       /* 1 clock cycles delay from the chip select 1 to the write enable */
    147       .waitwen = 0,
    148 
    149       /*
    150        * 0 clock cycles delay from the chip select 1 or address change
    151        * (whichever is later) to the output enable
    152        */
    153       .waitoen = 0,
    154 
    155       /* 7 clock cycles delay from the chip select 1 to the read access */
    156       .waitrd = 0x6,
    157 
    158       /*
    159        * 32 clock cycles delay for asynchronous page mode sequential accesses
    160        */
    161       .waitpage = 0x1f,
    162 
    163       /* 5 clock cycles delay from the chip select 1 to the write access */
    164       .waitwr = 0x3,
    165 
    166       /* 16 bus turnaround cycles */
    167       .waitrun = 0xf
    168     };
    169     lpc24xx_emc_static_chip_config chip_config_on_stack;
    170 
    171     bsp_start_memcpy(
    172       (int *) &chip_config_on_stack,
    173       (const int *) &chip_config,
    174       sizeof(chip_config_on_stack)
     70      (int *) &chip_config_on_stack.config,
     71      (const int *) &chip_config->config,
     72      config_size
    17573    );
    17674    bsp_start_memcpy(
    177       (int *) EMC_STA_BASE_1,
    178       (const int *) &chip_config_on_stack,
    179       sizeof(chip_config_on_stack)
     75      (int *) chip_config->chip_select,
     76      (const int *) &chip_config_on_stack.config,
     77      config_size
    18078    );
    181   #endif
     79  }
    18280}
    18381
    18482static void BSP_START_TEXT_SECTION lpc24xx_init_emc_memory_map(void)
    18583{
    186   #ifdef LPC24XX_EMC_INIT
    187     /* Use normal memory map */
    188     EMC_CTRL &= ~0x2U;
    189   #endif
     84  /* Use normal memory map */
     85  EMC_CTRL &= ~0x2U;
    19086}
    19187
    19288static void BSP_START_TEXT_SECTION lpc24xx_init_emc_dynamic(void)
    19389{
    194   #ifdef LPC24XX_EMC_MICRON
    195     /* Dynamic Memory 0: Micron M T48LC 4M16 A2 P 75 IT */
    196 
    197     static const BSP_START_DATA_SECTION lpc24xx_emc_dynamic_config dynamic_config = {
    198       /* Auto-refresh command every 15.6 us */
    199       .refresh = 0x46,
    200 
    201       /* Use command delayed strategy */
    202       .readconfig = 1,
    203 
    204       /* Precharge command period 20 ns */
    205       .trp = 1,
    206 
    207       /* Active to precharge command period 44 ns */
    208       .tras = 3,
    209 
    210       /* FIXME */
    211       .tsrex = 5,
    212 
    213       /* FIXME */
    214       .tapr = 2,
    215 
    216       /* Data-in to active command period tWR + tRP */
    217       .tdal = 4,
    218 
    219       /* Write recovery time 15 ns */
    220       .twr = 1,
    221 
    222       /* Active to active command period 66 ns */
    223       .trc = 4,
    224 
    225       /* Auto refresh period 66 ns */
    226       .trfc = 4,
    227 
    228       /* Exit self refresh to active command period 75 ns */
    229       .txsr = 5,
    230 
    231       /* Active bank a to active bank b command period 15 ns */
    232       .trrd = 1,
    233 
    234       /* Load mode register to active or refresh command period 2 tCK */
    235       .tmrd = 1,
    236     };
    237     static const BSP_START_DATA_SECTION lpc24xx_emc_dynamic_chip_config chip_config = {
    238       /*
    239        * Use SDRAM, 0 0 001 01 address mapping, disabled buffer, unprotected writes
    240        */
    241       .config = 0x280,
    242 
    243       .rascas = EMC_DYN_RASCAS_RAS(2) | EMC_DYN_RASCAS_CAS(2, 0),
    244       .mode = 0xa0000000 | (0x23 << (1 + 2 + 8))
    245     };
    246 
    247     volatile lpc_emc_dynamic *chip = &emc->dynamic [0];
    248     uint32_t dynamiccontrol = EMC_DYN_CTRL_CE | EMC_DYN_CTRL_CS;
    249 
    250     /* Check if we need to initialize it */
    251     if ((chip->config & EMC_DYN_CFG_B) == 0) {
    252       /*
    253        * The buffer enable bit is not set.  Now we assume that the controller
    254        * is not properly initialized.
    255        */
    256 
    257       /* Global dynamic settings */
    258       emc->dynamicreadconfig = dynamic_config.readconfig;
    259       emc->dynamictrp = dynamic_config.trp;
    260       emc->dynamictras = dynamic_config.tras;
    261       emc->dynamictsrex = dynamic_config.tsrex;
    262       emc->dynamictapr = dynamic_config.tapr;
    263       emc->dynamictdal = dynamic_config.tdal;
    264       emc->dynamictwr = dynamic_config.twr;
    265       emc->dynamictrc = dynamic_config.trc;
    266       emc->dynamictrfc = dynamic_config.trfc;
    267       emc->dynamictxsr = dynamic_config.txsr;
    268       emc->dynamictrrd = dynamic_config.trrd;
    269       emc->dynamictmrd = dynamic_config.tmrd;
    270 
    271       /* Wait 100us after the power is applied and the clocks have stabilized */
    272       lpc24xx_udelay(100);
    273 
    274       /* NOP period, disable self-refresh */
     90  size_t chip_count = lpc24xx_start_config_emc_dynamic_chip_count;
     91
     92  if (chip_count > 0) {
     93    bool do_initialization = true;
     94    size_t i = 0;
     95
     96    for (i = 0; do_initialization && i < chip_count; ++i) {
     97      const lpc24xx_emc_dynamic_chip_config *chip_cfg =
     98        &lpc24xx_start_config_emc_dynamic_chip [i];
     99      volatile lpc_emc_dynamic *chip_select = chip_cfg->chip_select;
     100
     101      do_initialization = (chip_select->config & EMC_DYN_CFG_B) == 0;
     102    }
     103
     104    if (do_initialization) {
     105      volatile lpc_emc *emc = (volatile lpc_emc *) EMC_BASE_ADDR;
     106      const lpc24xx_emc_dynamic_config *cfg =
     107        &lpc24xx_start_config_emc_dynamic [0];
     108      uint32_t dynamiccontrol = EMC_DYN_CTRL_CE | EMC_DYN_CTRL_CS;
     109
     110      emc->dynamicreadconfig = cfg->readconfig;
     111
     112      /* Timings */
     113      emc->dynamictrp = cfg->trp;
     114      emc->dynamictras = cfg->tras;
     115      emc->dynamictsrex = cfg->tsrex;
     116      emc->dynamictapr = cfg->tapr;
     117      emc->dynamictdal = cfg->tdal;
     118      emc->dynamictwr = cfg->twr;
     119      emc->dynamictrc = cfg->trc;
     120      emc->dynamictrfc = cfg->trfc;
     121      emc->dynamictxsr = cfg->txsr;
     122      emc->dynamictrrd = cfg->trrd;
     123      emc->dynamictmrd = cfg->tmrd;
     124
     125      /* NOP period */
    275126      emc->dynamiccontrol = dynamiccontrol | EMC_DYN_CTRL_I_NOP;
    276127      lpc24xx_udelay(200);
    277128
    278       /* Precharge all */
     129      /* Precharge */
    279130      emc->dynamiccontrol = dynamiccontrol | EMC_DYN_CTRL_I_PALL;
     131      emc->dynamicrefresh = 1;
    280132
    281133      /*
     
    284136       * (128 AHB clock cycles).
    285137       */
    286       emc->dynamicrefresh = 1;
    287138      lpc24xx_cpu_delay(128);
    288139
    289       /* Set refresh period */
    290       emc->dynamicrefresh = dynamic_config.refresh;
    291 
    292       /* Operational values for the chip */
    293       chip->rascas = chip_config.rascas;
    294       chip->config = chip_config.config;
    295 
    296       /* Mode */
    297       emc->dynamiccontrol = dynamiccontrol | EMC_DYN_CTRL_I_MODE;
    298       *((volatile uint32_t *) chip_config.mode);
    299 
    300       /* Normal operation */
    301       emc->dynamiccontrol = 0;
    302 
    303       /* Enable buffer */
    304       chip->config |= EMC_DYN_CFG_B;
    305 
    306       /* Test RAM */
    307       lpc24xx_ram_test_32();
    308     }
    309   #endif
     140      /* Refresh timing */
     141      emc->dynamicrefresh = cfg->refresh;
     142      lpc24xx_cpu_delay(128);
     143
     144      for (i = 0; i < chip_count; ++i) {
     145        const lpc24xx_emc_dynamic_chip_config *chip_cfg =
     146          &lpc24xx_start_config_emc_dynamic_chip [i];
     147        volatile lpc_emc_dynamic *chip_select = chip_cfg->chip_select;
     148        uint32_t config = chip_cfg->config;
     149
     150        /* Chip select */
     151        chip_select->config = config;
     152        chip_select->rascas = chip_cfg->rascas;
     153
     154        /* Set modes */
     155        emc->dynamiccontrol = dynamiccontrol | EMC_DYN_CTRL_I_MODE;
     156        *(volatile uint32_t *)(chip_cfg->address + chip_cfg->mode);
     157
     158        /* Enable buffer */
     159        chip_select->config = config | EMC_DYN_CFG_B;
     160      }
     161
     162      emc->dynamiccontrol = dynamiccontrol;
     163    }
     164  }
    310165}
    311166
     
    401256  /* Set PLL */
    402257  #if LPC24XX_OSCILLATOR_MAIN == 12000000U
    403     lpc24xx_set_pll(1, 0, 11, 3);
     258    #if LPC24XX_CCLK == 72000000U
     259      lpc24xx_set_pll(1, 0, 11, 3);
     260    #elif LPC24XX_CCLK == 51612800U
     261      lpc24xx_set_pll(1, 30, 399, 5);
     262    #else
     263      #error "unexpected CCLK"
     264    #endif
    404265  #elif LPC24XX_OSCILLATOR_MAIN == 3686400U
    405     lpc24xx_set_pll(1, 0, 47, 5);
     266    #if LPC24XX_CCLK == 58982400U
     267      lpc24xx_set_pll(1, 0, 47, 5);
     268    #else
     269      #error "unexpected CCLK"
     270    #endif
    406271  #else
    407272    #error "unexpected main oscillator frequency"
Note: See TracChangeset for help on using the changeset viewer.