xpedite550x.c 1.9 KB

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