2 * Copyright (C) 2007 Freescale Semiconductor, Inc.
3 * Dave Liu <daveliu@freescale.com>
5 * CREDITS: Kim Phillips contribute to LIBFDT code
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
15 #include <spd_sdram.h>
16 #if defined(CONFIG_OF_LIBFDT)
19 #if defined(CONFIG_PQ_MDS_PIB)
20 #include "../common/pq-mds-pib.h"
23 int board_early_init_f(void)
25 u8 *bcsr = (u8 *)CFG_BCSR;
27 /* Enable flash write */
29 /* Clear all of the interrupt of BCSR */
35 int board_early_init_r(void)
37 #ifdef CONFIG_PQ_MDS_PIB
43 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
44 extern void ddr_enable_ecc(unsigned int dram_size);
46 int fixed_sdram(void);
48 long int initdram(int board_type)
50 volatile immap_t *im = (immap_t *) CFG_IMMR;
53 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
56 #if defined(CONFIG_SPD_EEPROM)
59 msize = fixed_sdram();
62 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
63 /* Initialize DDR ECC byte */
64 ddr_enable_ecc(msize * 1024 * 1024);
67 /* return total bus DDR size(bytes) */
68 return (msize * 1024 * 1024);
71 #if !defined(CONFIG_SPD_EEPROM)
72 /*************************************************************************
73 * fixed sdram init -- doesn't use serial presence detect.
74 ************************************************************************/
77 volatile immap_t *im = (immap_t *) CFG_IMMR;
78 u32 msize = CFG_DDR_SIZE * 1024 * 1024;
79 u32 msize_log2 = __ilog2(msize);
81 im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE >> 12;
82 im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
84 #if (CFG_DDR_SIZE != 512)
85 #warning Currenly any ddr size other than 512 is not supported
87 im->sysconf.ddrcdr = CFG_DDRCDR_VALUE;
90 im->ddr.sdram_clk_cntl = CFG_DDR_SDRAM_CLK_CNTL;
93 im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
94 im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
97 im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
98 im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
99 im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
100 im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
101 im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
102 im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
103 im->ddr.sdram_mode = CFG_DDR_MODE;
104 im->ddr.sdram_mode2 = CFG_DDR_MODE2;
105 im->ddr.sdram_interval = CFG_DDR_INTERVAL;
106 __asm__ __volatile__("sync");
109 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
113 #endif /*!CFG_SPD_EEPROM */
117 puts("Board: Freescale MPC837xEMDS\n");
121 #if defined(CONFIG_OF_BOARD_SETUP)
122 void ft_board_setup(void *blob, bd_t *bd)
124 ft_cpu_setup(blob, bd);
126 ft_pci_setup(blob, bd);
129 #endif /* CONFIG_OF_BOARD_SETUP */