blob: 77afdbcbf825eb5b358bc81285026c73ffa01210 [file] [log] [blame]
Peter Tyser1f03cbf2008-12-23 16:32:00 -06001/*
2 * Copyright 2008 Extreme Engineering Solutions, Inc.
3 * Copyright 2004, 2007 Freescale Semiconductor, Inc.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <command.h>
26#include <pci.h>
27#include <asm/processor.h>
28#include <asm/immap_85xx.h>
Kumar Galac8514622009-04-02 13:22:48 -050029#include <asm/fsl_pci.h>
Peter Tyser1f03cbf2008-12-23 16:32:00 -060030#include <asm/io.h>
31#include <asm/cache.h>
32#include <asm/mmu.h>
33#include <libfdt.h>
34#include <fdt_support.h>
35#include <pca953x.h>
36
37extern void ft_board_pci_setup(void *blob, bd_t *bd);
38
39int checkboard(void)
40{
41 volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
42 volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
43
44 char *s;
45
46 printf("Board: X-ES %s PMC\n", CONFIG_SYS_BOARD_NAME);
47 printf(" ");
48 s = getenv("board_rev");
49 if (s)
50 printf("Rev %s, ", s);
51 s = getenv("serial#");
52 if (s)
53 printf("Serial# %s, ", s);
54 s = getenv("board_cfg");
55 if (s)
56 printf("Cfg %s", s);
57 printf("\n");
58
59 lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
60 lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
61 ecm->eedr = 0xffffffff; /* Clear ecm errors */
62 ecm->eeer = 0xffffffff; /* Enable ecm errors */
63
64 return 0;
65}
66
67static void flash_cs_fixup(void)
68{
69 volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
70 int flash_sel;
71
72 /*
73 * Print boot dev and swap flash flash chip selects if booted from 2nd
74 * flash. Swapping chip selects presents user with a common memory
75 * map regardless of which flash was booted from.
76 */
77 flash_sel = !((pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) &
78 CONFIG_SYS_PCA953X_FLASH_PASS_CS));
79 printf("FLASH: Executed from FLASH%d\n", flash_sel ? 2 : 1);
80
81 if (flash_sel) {
82 lbc->br0 = CONFIG_SYS_BR1_PRELIM;
83 lbc->or0 = CONFIG_SYS_OR1_PRELIM;
84
85 lbc->br1 = CONFIG_SYS_BR0_PRELIM;
86 lbc->or1 = CONFIG_SYS_OR0_PRELIM;
87 }
88}
89
90int board_early_init_r(void)
91{
92 /* Initialize PCA9557 devices */
93 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0);
94 pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0);
95
96 /*
97 * Remap NOR flash region to caching-inhibited
98 * so that flash can be erased/programmed properly.
99 */
100
101 /* Flush d-cache and invalidate i-cache of any FLASH data */
102 flush_dcache();
103 invalidate_icache();
104
105 /* Invalidate existing TLB entry for NOR flash */
106 disable_tlb(0);
107 set_tlb(1, (CONFIG_SYS_FLASH_BASE2 & 0xf0000000),
108 (CONFIG_SYS_FLASH_BASE2 & 0xf0000000),
109 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
110 0, 0, BOOKE_PAGESZ_256M, 1);
111
112 flash_cs_fixup();
113
114 return 0;
115}
116
117#if defined(CONFIG_OF_BOARD_SETUP)
118void ft_board_setup(void *blob, bd_t *bd)
119{
120#ifdef CONFIG_PCI
121 ft_board_pci_setup(blob, bd);
122#endif
123 ft_cpu_setup(blob, bd);
124}
125#endif