blob: 61443aab841987bfa33615b74f9df7f0392cfea7 [file] [log] [blame]
Peter Tyseredb9d592009-06-30 17:26:01 -05001/*
2 * Copyright 2009 Extreme Engineering Solutions, Inc.
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
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.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23#include <common.h>
24#include <asm/processor.h>
Becky Bruce5e35d8a2010-12-17 17:17:56 -060025#include <asm/fsl_ddr_sdram.h>
Peter Tyseredb9d592009-06-30 17:26:01 -050026#include <asm/mmu.h>
27#include <asm/io.h>
28#include <fdt_support.h>
29#include <pca953x.h>
John Schmollerd9c2dd52010-10-22 00:20:24 -050030#include "../common/fsl_8xxx_misc.h"
Peter Tyseredb9d592009-06-30 17:26:01 -050031
32#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_PCI)
33extern void ft_board_pci_setup(void *blob, bd_t *bd);
34#endif
35
Peter Tyseredb9d592009-06-30 17:26:01 -050036/*
37 * Print out which flash was booted from and if booting from the 2nd flash,
38 * swap flash chip selects to maintain consistent flash numbering/addresses.
39 */
40static void flash_cs_fixup(void)
41{
Peter Tyseredb9d592009-06-30 17:26:01 -050042 int flash_sel;
43
44 /*
45 * Print boot dev and swap flash flash chip selects if booted from 2nd
46 * flash. Swapping chip selects presents user with a common memory
47 * map regardless of which flash was booted from.
48 */
49 flash_sel = !((pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) &
50 CONFIG_SYS_PCA953X_C0_FLASH_PASS_CS));
Peter Tyser0b5a2632010-12-28 18:12:05 -060051 printf("Flash: Executed from flash%d\n", flash_sel ? 2 : 1);
Peter Tyseredb9d592009-06-30 17:26:01 -050052
53 if (flash_sel) {
Becky Bruce0d4cee12010-06-17 11:37:20 -050054 set_lbc_br(0, CONFIG_SYS_BR1_PRELIM);
55 set_lbc_or(0, CONFIG_SYS_OR1_PRELIM);
Peter Tyseredb9d592009-06-30 17:26:01 -050056
Becky Bruce0d4cee12010-06-17 11:37:20 -050057 set_lbc_br(1, CONFIG_SYS_BR0_PRELIM);
58 set_lbc_or(1, CONFIG_SYS_OR0_PRELIM);
Peter Tyseredb9d592009-06-30 17:26:01 -050059 }
60}
61
62int board_early_init_r(void)
63{
64 /* Initialize PCA9557 devices */
65 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0);
66 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0);
67 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR2, 0xff, 0);
68 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR3, 0xff, 0);
69
70 flash_cs_fixup();
71
72 return 0;
73}
74
Becky Bruce5e35d8a2010-12-17 17:17:56 -060075phys_size_t initdram(int board_type)
76{
77 phys_size_t dram_size = fsl_ddr_sdram();
78
79#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
80 /* Initialize and enable DDR ECC */
81 ddr_enable_ecc(dram_size);
82#endif
83
84 return dram_size;
85}
86
Peter Tyseredb9d592009-06-30 17:26:01 -050087#if defined(CONFIG_OF_BOARD_SETUP)
88void ft_board_setup(void *blob, bd_t *bd)
89{
90#ifdef CONFIG_PCI
91 ft_board_pci_setup(blob, bd);
92#endif
93 ft_cpu_setup(blob, bd);
94}
95#endif
96
97#ifdef CONFIG_MP
98extern void cpu_mp_lmb_reserve(struct lmb *lmb);
99
100void board_lmb_reserve(struct lmb *lmb)
101{
102 cpu_mp_lmb_reserve(lmb);
103}
104#endif