xpedite517x.c 1.9 KB

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