Peter Tyser | ccf0fdd | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 1 | /* |
| 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 Gala | c851462 | 2009-04-02 13:22:48 -0500 | [diff] [blame] | 28 | #include <asm/fsl_pci.h> |
Peter Tyser | ccf0fdd | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 29 | #include <asm/io.h> |
| 30 | #include <asm/cache.h> |
| 31 | #include <libfdt.h> |
| 32 | #include <fdt_support.h> |
| 33 | #include <pca953x.h> |
| 34 | |
| 35 | DECLARE_GLOBAL_DATA_PTR; |
| 36 | |
| 37 | extern void ft_board_pci_setup(void *blob, bd_t *bd); |
| 38 | |
| 39 | int checkboard(void) |
| 40 | { |
| 41 | char *s; |
| 42 | |
| 43 | printf("Board: X-ES %s 3U VPX SBC\n", CONFIG_SYS_BOARD_NAME); |
| 44 | printf(" "); |
| 45 | s = getenv("board_rev"); |
| 46 | if (s) |
| 47 | printf("Rev %s, ", s); |
| 48 | s = getenv("serial#"); |
| 49 | if (s) |
| 50 | printf("Serial# %s, ", s); |
| 51 | s = getenv("board_cfg"); |
| 52 | if (s) |
| 53 | printf("Cfg %s", s); |
| 54 | printf("\n"); |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | static void flash_cs_fixup(void) |
| 60 | { |
| 61 | volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR); |
| 62 | int flash_sel; |
| 63 | |
| 64 | /* |
| 65 | * Print boot dev and swap flash flash chip selects if booted from 2nd |
| 66 | * flash. Swapping chip selects presents user with a common memory |
| 67 | * map regardless of which flash was booted from. |
| 68 | */ |
| 69 | flash_sel = !((pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) & |
| 70 | CONFIG_SYS_PCA953X_C0_FLASH_PASS_CS)); |
| 71 | printf("FLASH: Executed from FLASH%d\n", flash_sel ? 2 : 1); |
| 72 | |
| 73 | if (flash_sel) { |
Peter Tyser | 1bb61b6 | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 74 | out_be32(&lbc->br0, CONFIG_SYS_BR1_PRELIM); |
| 75 | out_be32(&lbc->or0, CONFIG_SYS_OR1_PRELIM); |
Peter Tyser | ccf0fdd | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 76 | |
Peter Tyser | 1bb61b6 | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 77 | out_be32(&lbc->br1, CONFIG_SYS_BR0_PRELIM); |
| 78 | out_be32(&lbc->or1, CONFIG_SYS_OR0_PRELIM); |
Peter Tyser | ccf0fdd | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 79 | } |
| 80 | } |
| 81 | |
| 82 | int board_early_init_r(void) |
| 83 | { |
| 84 | /* Initialize PCA9557 devices */ |
| 85 | pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0); |
| 86 | pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0); |
Peter Tyser | 58f31b6 | 2009-07-19 19:17:41 -0500 | [diff] [blame] | 87 | pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR2, 0xff, 0); |
| 88 | pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR3, 0xff, 0); |
Peter Tyser | ccf0fdd | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 89 | |
| 90 | /* |
| 91 | * Remap NOR flash region to caching-inhibited |
| 92 | * so that flash can be erased/programmed properly. |
| 93 | */ |
| 94 | |
| 95 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 96 | flush_dcache(); |
| 97 | invalidate_icache(); |
| 98 | |
| 99 | /* Invalidate existing TLB entry for NOR flash */ |
| 100 | disable_tlb(0); |
| 101 | set_tlb(1, (CONFIG_SYS_FLASH_BASE2 & 0xf0000000), |
| 102 | (CONFIG_SYS_FLASH_BASE2 & 0xf0000000), |
| 103 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 104 | 0, 0, BOOKE_PAGESZ_256M, 1); |
| 105 | |
| 106 | flash_cs_fixup(); |
| 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 112 | void ft_board_setup(void *blob, bd_t *bd) |
| 113 | { |
| 114 | #ifdef CONFIG_PCI |
| 115 | ft_board_pci_setup(blob, bd); |
| 116 | #endif |
| 117 | ft_cpu_setup(blob, bd); |
| 118 | } |
| 119 | #endif |
| 120 | |
| 121 | #ifdef CONFIG_MP |
| 122 | extern void cpu_mp_lmb_reserve(struct lmb *lmb); |
| 123 | |
| 124 | void board_lmb_reserve(struct lmb *lmb) |
| 125 | { |
| 126 | cpu_mp_lmb_reserve(lmb); |
| 127 | } |
| 128 | #endif |