blob: 9d9afaefbcc34a2fe46cfc299cf57ccc03291922 [file] [log] [blame]
Peter Tyserccf0fdd2008-12-17 16:36:23 -06001/*
2 * Copyright 2008 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 <command.h>
25#include <asm/processor.h>
26#include <asm/mmu.h>
27#include <asm/immap_85xx.h>
Kumar Galac8514622009-04-02 13:22:48 -050028#include <asm/fsl_pci.h>
Peter Tyserccf0fdd2008-12-17 16:36:23 -060029#include <asm/io.h>
30#include <asm/cache.h>
31#include <libfdt.h>
32#include <fdt_support.h>
33#include <pca953x.h>
34
35DECLARE_GLOBAL_DATA_PTR;
36
37extern void ft_board_pci_setup(void *blob, bd_t *bd);
38
Peter Tyserccf0fdd2008-12-17 16:36:23 -060039static void flash_cs_fixup(void)
40{
Peter Tyserccf0fdd2008-12-17 16:36:23 -060041 int flash_sel;
42
43 /*
44 * Print boot dev and swap flash flash chip selects if booted from 2nd
45 * flash. Swapping chip selects presents user with a common memory
46 * map regardless of which flash was booted from.
47 */
48 flash_sel = !((pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) &
49 CONFIG_SYS_PCA953X_C0_FLASH_PASS_CS));
Peter Tysereddf52b2010-12-28 18:12:05 -060050 printf("Flash: Executed from flash%d\n", flash_sel ? 2 : 1);
Peter Tyserccf0fdd2008-12-17 16:36:23 -060051
52 if (flash_sel) {
Becky Brucef51cdaf2010-06-17 11:37:20 -050053 set_lbc_br(0, CONFIG_SYS_BR1_PRELIM);
54 set_lbc_or(0, CONFIG_SYS_OR1_PRELIM);
Peter Tyserccf0fdd2008-12-17 16:36:23 -060055
Becky Brucef51cdaf2010-06-17 11:37:20 -050056 set_lbc_br(1, CONFIG_SYS_BR0_PRELIM);
57 set_lbc_or(1, CONFIG_SYS_OR0_PRELIM);
Peter Tyserccf0fdd2008-12-17 16:36:23 -060058 }
59}
60
61int board_early_init_r(void)
62{
63 /* Initialize PCA9557 devices */
64 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0);
65 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0);
Peter Tyser58f31b62009-07-19 19:17:41 -050066 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR2, 0xff, 0);
67 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR3, 0xff, 0);
Peter Tyserccf0fdd2008-12-17 16:36:23 -060068
69 /*
70 * Remap NOR flash region to caching-inhibited
71 * so that flash can be erased/programmed properly.
72 */
73
74 /* Flush d-cache and invalidate i-cache of any FLASH data */
75 flush_dcache();
76 invalidate_icache();
77
78 /* Invalidate existing TLB entry for NOR flash */
79 disable_tlb(0);
80 set_tlb(1, (CONFIG_SYS_FLASH_BASE2 & 0xf0000000),
81 (CONFIG_SYS_FLASH_BASE2 & 0xf0000000),
82 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
83 0, 0, BOOKE_PAGESZ_256M, 1);
84
85 flash_cs_fixup();
86
87 return 0;
88}
89
90#if defined(CONFIG_OF_BOARD_SETUP)
91void ft_board_setup(void *blob, bd_t *bd)
92{
93#ifdef CONFIG_PCI
94 ft_board_pci_setup(blob, bd);
95#endif
96 ft_cpu_setup(blob, bd);
97}
98#endif