xpedite517x.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright 2009 Extreme Engineering Solutions, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/processor.h>
  8. #include <fsl_ddr_sdram.h>
  9. #include <asm/mmu.h>
  10. #include <asm/io.h>
  11. #include <fdt_support.h>
  12. #include <pca953x.h>
  13. #include "../common/fsl_8xxx_misc.h"
  14. #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_PCI)
  15. extern void ft_board_pci_setup(void *blob, bd_t *bd);
  16. #endif
  17. /*
  18. * Print out which flash was booted from and if booting from the 2nd flash,
  19. * swap flash chip selects to maintain consistent flash numbering/addresses.
  20. */
  21. static void flash_cs_fixup(void)
  22. {
  23. int flash_sel;
  24. /*
  25. * Print boot dev and swap flash flash chip selects if booted from 2nd
  26. * flash. Swapping chip selects presents user with a common memory
  27. * map regardless of which flash was booted from.
  28. */
  29. flash_sel = !((pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) &
  30. CONFIG_SYS_PCA953X_C0_FLASH_PASS_CS));
  31. printf("Flash: Executed from flash%d\n", flash_sel ? 2 : 1);
  32. if (flash_sel) {
  33. set_lbc_br(0, CONFIG_SYS_BR1_PRELIM);
  34. set_lbc_or(0, CONFIG_SYS_OR1_PRELIM);
  35. set_lbc_br(1, CONFIG_SYS_BR0_PRELIM);
  36. set_lbc_or(1, CONFIG_SYS_OR0_PRELIM);
  37. }
  38. }
  39. int board_early_init_r(void)
  40. {
  41. /* Initialize PCA9557 devices */
  42. pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0);
  43. pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0);
  44. pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR2, 0xff, 0);
  45. pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR3, 0xff, 0);
  46. flash_cs_fixup();
  47. return 0;
  48. }
  49. phys_size_t initdram(int board_type)
  50. {
  51. phys_size_t dram_size = fsl_ddr_sdram();
  52. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  53. /* Initialize and enable DDR ECC */
  54. ddr_enable_ecc(dram_size);
  55. #endif
  56. return dram_size;
  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