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.
16 #include <asm/fsl_serdes.h>
17 #include <spd_sdram.h>
18 #if defined(CONFIG_OF_LIBFDT)
21 #if defined(CONFIG_PQ_MDS_PIB)
22 #include "../common/pq-mds-pib.h"
25 int board_early_init_f(void)
27 u8 *bcsr = (u8 *)CONFIG_SYS_BCSR;
29 /* Enable flash write */
31 /* Clear all of the interrupt of BCSR */
34 #ifdef CONFIG_FSL_SERDES
35 immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
36 u32 spridr = in_be32(&immr->sysconf.spridr);
38 /* we check only part num, and don't look for CPU revisions */
39 switch (PARTID_NO_E(spridr)) {
41 fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
42 FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
43 fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_PEX,
44 FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
47 fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_PEX,
48 FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
51 fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
52 FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
53 fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_SATA,
54 FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
57 printf("serdes not configured: unknown CPU part number: "
58 "%04x\n", spridr >> 16);
61 #endif /* CONFIG_FSL_SERDES */
65 int board_early_init_r(void)
67 #ifdef CONFIG_PQ_MDS_PIB
73 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
74 extern void ddr_enable_ecc(unsigned int dram_size);
76 int fixed_sdram(void);
78 phys_size_t initdram(int board_type)
80 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
83 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
86 #if defined(CONFIG_SPD_EEPROM)
89 msize = fixed_sdram();
92 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
93 /* Initialize DDR ECC byte */
94 ddr_enable_ecc(msize * 1024 * 1024);
97 /* return total bus DDR size(bytes) */
98 return (msize * 1024 * 1024);
101 #if !defined(CONFIG_SPD_EEPROM)
102 /*************************************************************************
103 * fixed sdram init -- doesn't use serial presence detect.
104 ************************************************************************/
105 int fixed_sdram(void)
107 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
108 u32 msize = CONFIG_SYS_DDR_SIZE * 1024 * 1024;
109 u32 msize_log2 = __ilog2(msize);
111 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000;
112 im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
114 #if (CONFIG_SYS_DDR_SIZE != 512)
115 #warning Currenly any ddr size other than 512 is not supported
117 im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR_VALUE;
120 im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_SDRAM_CLK_CNTL;
123 im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
124 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
127 im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
128 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
129 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
130 im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
131 im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
132 im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
133 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
134 im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
135 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
136 __asm__ __volatile__("sync");
139 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
141 return CONFIG_SYS_DDR_SIZE;
143 #endif /*!CONFIG_SYS_SPD_EEPROM */
147 puts("Board: Freescale MPC837xEMDS\n");
151 #if defined(CONFIG_OF_BOARD_SETUP)
152 void ft_board_setup(void *blob, bd_t *bd)
154 ft_cpu_setup(blob, bd);
156 ft_pci_setup(blob, bd);
159 #endif /* CONFIG_OF_BOARD_SETUP */