Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2008 Extreme Engineering Solutions, Inc. |
| 4 | * Copyright 2004, 2007 Freescale Semiconductor, Inc. |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <command.h> |
| 9 | #include <pci.h> |
| 10 | #include <asm/processor.h> |
| 11 | #include <asm/immap_85xx.h> |
Kumar Gala | c851462 | 2009-04-02 13:22:48 -0500 | [diff] [blame] | 12 | #include <asm/fsl_pci.h> |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 13 | #include <asm/io.h> |
| 14 | #include <asm/cache.h> |
| 15 | #include <asm/mmu.h> |
Masahiro Yamada | b08c8c4 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 16 | #include <linux/libfdt.h> |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 17 | #include <fdt_support.h> |
| 18 | #include <pca953x.h> |
| 19 | |
| 20 | extern void ft_board_pci_setup(void *blob, bd_t *bd); |
| 21 | |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 22 | static void flash_cs_fixup(void) |
| 23 | { |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 24 | int flash_sel; |
| 25 | |
| 26 | /* |
| 27 | * Print boot dev and swap flash flash chip selects if booted from 2nd |
| 28 | * flash. Swapping chip selects presents user with a common memory |
| 29 | * map regardless of which flash was booted from. |
| 30 | */ |
| 31 | flash_sel = !((pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) & |
| 32 | CONFIG_SYS_PCA953X_FLASH_PASS_CS)); |
Peter Tyser | eddf52b | 2010-12-28 18:12:05 -0600 | [diff] [blame] | 33 | printf("Flash: Executed from flash%d\n", flash_sel ? 2 : 1); |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 34 | |
| 35 | if (flash_sel) { |
Becky Bruce | f51cdaf | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 36 | set_lbc_br(0, CONFIG_SYS_BR1_PRELIM); |
| 37 | set_lbc_or(0, CONFIG_SYS_OR1_PRELIM); |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 38 | |
Becky Bruce | f51cdaf | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 39 | set_lbc_br(1, CONFIG_SYS_BR0_PRELIM); |
| 40 | set_lbc_or(1, CONFIG_SYS_OR0_PRELIM); |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 41 | } |
| 42 | } |
| 43 | |
| 44 | int board_early_init_r(void) |
| 45 | { |
| 46 | /* Initialize PCA9557 devices */ |
| 47 | pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0); |
| 48 | pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0); |
| 49 | |
| 50 | /* |
| 51 | * Remap NOR flash region to caching-inhibited |
| 52 | * so that flash can be erased/programmed properly. |
| 53 | */ |
| 54 | |
| 55 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 56 | flush_dcache(); |
| 57 | invalidate_icache(); |
| 58 | |
| 59 | /* Invalidate existing TLB entry for NOR flash */ |
| 60 | disable_tlb(0); |
| 61 | set_tlb(1, (CONFIG_SYS_FLASH_BASE2 & 0xf0000000), |
| 62 | (CONFIG_SYS_FLASH_BASE2 & 0xf0000000), |
| 63 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 64 | 0, 0, BOOKE_PAGESZ_256M, 1); |
| 65 | |
| 66 | flash_cs_fixup(); |
| 67 | |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | #if defined(CONFIG_OF_BOARD_SETUP) |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 72 | int ft_board_setup(void *blob, bd_t *bd) |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 73 | { |
| 74 | #ifdef CONFIG_PCI |
| 75 | ft_board_pci_setup(blob, bd); |
| 76 | #endif |
| 77 | ft_cpu_setup(blob, bd); |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 78 | |
| 79 | return 0; |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 80 | } |
| 81 | #endif |