xpedite537x.c 2.0 KB

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