xpedite537x.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2008 Extreme Engineering Solutions, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <asm/processor.h>
  9. #include <asm/mmu.h>
  10. #include <asm/immap_85xx.h>
  11. #include <asm/fsl_pci.h>
  12. #include <asm/io.h>
  13. #include <asm/cache.h>
  14. #include <libfdt.h>
  15. #include <fdt_support.h>
  16. #include <pca953x.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. extern void ft_board_pci_setup(void *blob, bd_t *bd);
  19. static void flash_cs_fixup(void)
  20. {
  21. int flash_sel;
  22. /*
  23. * Print boot dev and swap flash flash chip selects if booted from 2nd
  24. * flash. Swapping chip selects presents user with a common memory
  25. * map regardless of which flash was booted from.
  26. */
  27. flash_sel = !((pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) &
  28. CONFIG_SYS_PCA953X_C0_FLASH_PASS_CS));
  29. printf("Flash: Executed from flash%d\n", flash_sel ? 2 : 1);
  30. if (flash_sel) {
  31. set_lbc_br(0, CONFIG_SYS_BR1_PRELIM);
  32. set_lbc_or(0, CONFIG_SYS_OR1_PRELIM);
  33. set_lbc_br(1, CONFIG_SYS_BR0_PRELIM);
  34. set_lbc_or(1, CONFIG_SYS_OR0_PRELIM);
  35. }
  36. }
  37. int board_early_init_r(void)
  38. {
  39. /* Initialize PCA9557 devices */
  40. pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0);
  41. pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0);
  42. pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR2, 0xff, 0);
  43. pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR3, 0xff, 0);
  44. /*
  45. * Remap NOR flash region to caching-inhibited
  46. * so that flash can be erased/programmed properly.
  47. */
  48. /* Flush d-cache and invalidate i-cache of any FLASH data */
  49. flush_dcache();
  50. invalidate_icache();
  51. /* Invalidate existing TLB entry for NOR flash */
  52. disable_tlb(0);
  53. set_tlb(1, (CONFIG_SYS_FLASH_BASE2 & 0xf0000000),
  54. (CONFIG_SYS_FLASH_BASE2 & 0xf0000000),
  55. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  56. 0, 0, BOOKE_PAGESZ_256M, 1);
  57. flash_cs_fixup();
  58. return 0;
  59. }
  60. #if defined(CONFIG_OF_BOARD_SETUP)
  61. int ft_board_setup(void *blob, bd_t *bd)
  62. {
  63. #ifdef CONFIG_PCI
  64. ft_board_pci_setup(blob, bd);
  65. #endif
  66. ft_cpu_setup(blob, bd);
  67. return 0;
  68. }
  69. #endif