ls1012afrdm.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2017-2018 NXP
  4. */
  5. #include <common.h>
  6. #include <i2c.h>
  7. #include <asm/io.h>
  8. #include <asm/arch/clock.h>
  9. #include <asm/arch/fsl_serdes.h>
  10. #ifdef CONFIG_FSL_LS_PPA
  11. #include <asm/arch/ppa.h>
  12. #endif
  13. #include <asm/arch/mmu.h>
  14. #include <asm/arch/soc.h>
  15. #include <fsl_esdhc.h>
  16. #include <hwconfig.h>
  17. #include <environment.h>
  18. #include <fsl_mmdc.h>
  19. #include <netdev.h>
  20. #include <fsl_sec.h>
  21. DECLARE_GLOBAL_DATA_PTR;
  22. static inline int get_board_version(void)
  23. {
  24. uint32_t val;
  25. #ifdef CONFIG_TARGET_LS1012AFRDM
  26. val = 0;
  27. #else
  28. struct ccsr_gpio *pgpio = (void *)(GPIO2_BASE_ADDR);
  29. val = in_be32(&pgpio->gpdat) & BOARD_REV_MASK;/*Get GPIO2 11,12,14*/
  30. #endif
  31. return val;
  32. }
  33. int checkboard(void)
  34. {
  35. #ifdef CONFIG_TARGET_LS1012AFRDM
  36. puts("Board: LS1012AFRDM ");
  37. #else
  38. int rev;
  39. rev = get_board_version();
  40. puts("Board: FRWY-LS1012A ");
  41. puts("Version");
  42. switch (rev) {
  43. case BOARD_REV_A_B:
  44. puts(": RevA/B ");
  45. break;
  46. case BOARD_REV_C:
  47. puts(": RevC ");
  48. break;
  49. default:
  50. puts(": unknown");
  51. break;
  52. }
  53. #endif
  54. return 0;
  55. }
  56. #ifdef CONFIG_TARGET_LS1012AFRWY
  57. int esdhc_status_fixup(void *blob, const char *compat)
  58. {
  59. char esdhc0_path[] = "/soc/esdhc@1560000";
  60. char esdhc1_path[] = "/soc/esdhc@1580000";
  61. do_fixup_by_path(blob, esdhc0_path, "status", "okay",
  62. sizeof("okay"), 1);
  63. do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
  64. sizeof("disabled"), 1);
  65. return 0;
  66. }
  67. #endif
  68. int dram_init(void)
  69. {
  70. #ifdef CONFIG_TARGET_LS1012AFRWY
  71. int board_rev;
  72. #endif
  73. struct fsl_mmdc_info mparam = {
  74. 0x04180000, /* mdctl */
  75. 0x00030035, /* mdpdc */
  76. 0x12554000, /* mdotc */
  77. 0xbabf7954, /* mdcfg0 */
  78. 0xdb328f64, /* mdcfg1 */
  79. 0x01ff00db, /* mdcfg2 */
  80. 0x00001680, /* mdmisc */
  81. 0x0f3c8000, /* mdref */
  82. 0x00002000, /* mdrwd */
  83. 0x00bf1023, /* mdor */
  84. 0x0000003f, /* mdasp */
  85. 0x0000022a, /* mpodtctrl */
  86. 0xa1390003, /* mpzqhwctrl */
  87. };
  88. #ifdef CONFIG_TARGET_LS1012AFRWY
  89. board_rev = get_board_version();
  90. if (board_rev == BOARD_REV_C) {
  91. mparam.mdctl = 0x05180000;
  92. gd->ram_size = SYS_SDRAM_SIZE_1024;
  93. } else {
  94. gd->ram_size = SYS_SDRAM_SIZE_512;
  95. }
  96. #else
  97. gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
  98. #endif
  99. mmdc_init(&mparam);
  100. #if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
  101. /* This will break-before-make MMU for DDR */
  102. update_early_mmu_table();
  103. #endif
  104. return 0;
  105. }
  106. int board_early_init_f(void)
  107. {
  108. fsl_lsch2_early_init_f();
  109. return 0;
  110. }
  111. int board_init(void)
  112. {
  113. struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
  114. CONFIG_SYS_CCI400_OFFSET);
  115. /*
  116. * Set CCI-400 control override register to enable barrier
  117. * transaction
  118. */
  119. out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
  120. #ifdef CONFIG_ENV_IS_NOWHERE
  121. gd->env_addr = (ulong)&default_environment[0];
  122. #endif
  123. #ifdef CONFIG_FSL_CAAM
  124. sec_init();
  125. #endif
  126. #ifdef CONFIG_FSL_LS_PPA
  127. ppa_init();
  128. #endif
  129. return 0;
  130. }
  131. int ft_board_setup(void *blob, bd_t *bd)
  132. {
  133. arch_fixup_fdt(blob);
  134. ft_cpu_setup(blob, bd);
  135. return 0;
  136. }