Peter Tyser | f3c970c | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 1 | /* |
| 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 Gala | 9bbd643 | 2009-04-02 13:22:48 -0500 | [diff] [blame] | 29 | #include <asm/fsl_pci.h> |
Peter Tyser | f3c970c | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 30 | #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 | |
| 37 | extern void ft_board_pci_setup(void *blob, bd_t *bd); |
| 38 | |
| 39 | int checkboard(void) |
| 40 | { |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 41 | volatile fsl_lbc_t *lbc = LBC_BASE_ADDR; |
Peter Tyser | f3c970c | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 42 | volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR); |
Peter Tyser | f3c970c | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 43 | char *s; |
| 44 | |
| 45 | printf("Board: X-ES %s PMC\n", CONFIG_SYS_BOARD_NAME); |
| 46 | printf(" "); |
| 47 | s = getenv("board_rev"); |
| 48 | if (s) |
| 49 | printf("Rev %s, ", s); |
| 50 | s = getenv("serial#"); |
| 51 | if (s) |
| 52 | printf("Serial# %s, ", s); |
| 53 | s = getenv("board_cfg"); |
| 54 | if (s) |
| 55 | printf("Cfg %s", s); |
| 56 | printf("\n"); |
| 57 | |
Peter Tyser | 2b1a48d | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 58 | out_be32(&lbc->ltesr, 0xffffffff); /* Clear LBC error IRQs */ |
| 59 | out_be32(&lbc->lteir, 0xffffffff); /* Enable LBC error IRQs */ |
| 60 | out_be32(&ecm->eedr, 0xffffffff); /* Clear ecm errors */ |
| 61 | out_be32(&ecm->eeer, 0xffffffff); /* Enable ecm errors */ |
Peter Tyser | f3c970c | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | static void flash_cs_fixup(void) |
| 67 | { |
Peter Tyser | f3c970c | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 68 | int flash_sel; |
| 69 | |
| 70 | /* |
| 71 | * Print boot dev and swap flash flash chip selects if booted from 2nd |
| 72 | * flash. Swapping chip selects presents user with a common memory |
| 73 | * map regardless of which flash was booted from. |
| 74 | */ |
| 75 | flash_sel = !((pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) & |
| 76 | CONFIG_SYS_PCA953X_FLASH_PASS_CS)); |
| 77 | printf("FLASH: Executed from FLASH%d\n", flash_sel ? 2 : 1); |
| 78 | |
| 79 | if (flash_sel) { |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 80 | set_lbc_br(0, CONFIG_SYS_BR1_PRELIM); |
| 81 | set_lbc_or(0, CONFIG_SYS_OR1_PRELIM); |
Peter Tyser | f3c970c | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 82 | |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 83 | set_lbc_br(1, CONFIG_SYS_BR0_PRELIM); |
| 84 | set_lbc_or(1, CONFIG_SYS_OR0_PRELIM); |
Peter Tyser | f3c970c | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 85 | } |
| 86 | } |
| 87 | |
| 88 | int board_early_init_r(void) |
| 89 | { |
| 90 | /* Initialize PCA9557 devices */ |
| 91 | pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0); |
| 92 | pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0); |
| 93 | |
| 94 | /* |
| 95 | * Remap NOR flash region to caching-inhibited |
| 96 | * so that flash can be erased/programmed properly. |
| 97 | */ |
| 98 | |
| 99 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 100 | flush_dcache(); |
| 101 | invalidate_icache(); |
| 102 | |
| 103 | /* Invalidate existing TLB entry for NOR flash */ |
| 104 | disable_tlb(0); |
| 105 | set_tlb(1, (CONFIG_SYS_FLASH_BASE2 & 0xf0000000), |
| 106 | (CONFIG_SYS_FLASH_BASE2 & 0xf0000000), |
| 107 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 108 | 0, 0, BOOKE_PAGESZ_256M, 1); |
| 109 | |
| 110 | flash_cs_fixup(); |
| 111 | |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 116 | void ft_board_setup(void *blob, bd_t *bd) |
| 117 | { |
| 118 | #ifdef CONFIG_PCI |
| 119 | ft_board_pci_setup(blob, bd); |
| 120 | #endif |
| 121 | ft_cpu_setup(blob, bd); |
| 122 | } |
| 123 | #endif |