corenet_ds.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2009-2011 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. #include <netdev.h>
  8. #include <linux/compiler.h>
  9. #include <asm/mmu.h>
  10. #include <asm/processor.h>
  11. #include <asm/cache.h>
  12. #include <asm/immap_85xx.h>
  13. #include <asm/fsl_law.h>
  14. #include <asm/fsl_serdes.h>
  15. #include <asm/fsl_liodn.h>
  16. #include <fm_eth.h>
  17. #include "../common/ngpixis.h"
  18. #include "corenet_ds.h"
  19. DECLARE_GLOBAL_DATA_PTR;
  20. int checkboard (void)
  21. {
  22. u8 sw;
  23. struct cpu_type *cpu = gd->arch.cpu;
  24. #if defined(CONFIG_TARGET_P3041DS) || defined(CONFIG_TARGET_P5020DS) || \
  25. defined(CONFIG_TARGET_P5040DS)
  26. unsigned int i;
  27. #endif
  28. static const char * const freq[] = {"100", "125", "156.25", "212.5" };
  29. printf("Board: %sDS, ", cpu->name);
  30. printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  31. in_8(&pixis->id), in_8(&pixis->arch), in_8(&pixis->scver));
  32. sw = in_8(&PIXIS_SW(PIXIS_LBMAP_SWITCH));
  33. sw = (sw & PIXIS_LBMAP_MASK) >> PIXIS_LBMAP_SHIFT;
  34. if (sw < 0x8)
  35. printf("vBank: %d\n", sw);
  36. else if (sw == 0x8)
  37. puts("Promjet\n");
  38. else if (sw == 0x9)
  39. puts("NAND\n");
  40. else
  41. printf("invalid setting of SW%u\n", PIXIS_LBMAP_SWITCH);
  42. /* Display the actual SERDES reference clocks as configured by the
  43. * dip switches on the board. Note that the SWx registers could
  44. * technically be set to force the reference clocks to match the
  45. * values that the SERDES expects (or vice versa). For now, however,
  46. * we just display both values and hope the user notices when they
  47. * don't match.
  48. */
  49. puts("SERDES Reference Clocks: ");
  50. #if defined(CONFIG_TARGET_P3041DS) || defined(CONFIG_TARGET_P5020DS) || \
  51. defined(CONFIG_TARGET_P5040DS)
  52. sw = in_8(&PIXIS_SW(5));
  53. for (i = 0; i < 3; i++) {
  54. unsigned int clock = (sw >> (6 - (2 * i))) & 3;
  55. printf("Bank%u=%sMhz ", i+1, freq[clock]);
  56. }
  57. #ifdef CONFIG_TARGET_P5040DS
  58. /* On P5040DS, SW11[7:8] determines the Bank 4 frequency */
  59. sw = in_8(&PIXIS_SW(9));
  60. printf("Bank4=%sMhz ", freq[sw & 3]);
  61. #endif
  62. puts("\n");
  63. #else
  64. sw = in_8(&PIXIS_SW(3));
  65. /* SW3[2]: 0 = 100 Mhz, 1 = 125 MHz */
  66. /* SW3[3]: 0 = 125 Mhz, 1 = 156.25 MHz */
  67. /* SW3[4]: 0 = 125 Mhz, 1 = 156.25 MHz */
  68. printf("Bank1=%sMHz ", freq[!!(sw & 0x40)]);
  69. printf("Bank2=%sMHz ", freq[1 + !!(sw & 0x20)]);
  70. printf("Bank3=%sMHz\n", freq[1 + !!(sw & 0x10)]);
  71. #endif
  72. return 0;
  73. }
  74. int board_early_init_f(void)
  75. {
  76. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  77. /*
  78. * P4080 DS board only uses the DDR1_MCK0/3 and DDR2_MCK0/3
  79. * disable the DDR1_MCK1/2/4/5 and DDR2_MCK1/2/4/5 to reduce
  80. * the noise introduced by these unterminated and unused clock pairs.
  81. */
  82. setbits_be32(&gur->ddrclkdr, 0x001B001B);
  83. return 0;
  84. }
  85. int board_early_init_r(void)
  86. {
  87. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  88. int flash_esel = find_tlb_idx((void *)flashbase, 1);
  89. /*
  90. * Remap Boot flash + PROMJET region to caching-inhibited
  91. * so that flash can be erased properly.
  92. */
  93. /* Flush d-cache and invalidate i-cache of any FLASH data */
  94. flush_dcache();
  95. invalidate_icache();
  96. if (flash_esel == -1) {
  97. /* very unlikely unless something is messed up */
  98. puts("Error: Could not find TLB for FLASH BASE\n");
  99. flash_esel = 2; /* give our best effort to continue */
  100. } else {
  101. /* invalidate existing TLB entry for flash + promjet */
  102. disable_tlb(flash_esel);
  103. }
  104. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, /* tlb, epn, rpn */
  105. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */
  106. 0, flash_esel, BOOKE_PAGESZ_256M, 1); /* ts, esel, tsize, iprot */
  107. return 0;
  108. }
  109. #define NUM_SRDS_BANKS 3
  110. int misc_init_r(void)
  111. {
  112. serdes_corenet_t *srds_regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
  113. u32 actual[NUM_SRDS_BANKS];
  114. unsigned int i;
  115. u8 sw;
  116. #if defined(CONFIG_TARGET_P3041DS) || defined(CONFIG_TARGET_P5020DS) || \
  117. defined(CONFIG_TARGET_P5040DS)
  118. sw = in_8(&PIXIS_SW(5));
  119. for (i = 0; i < 3; i++) {
  120. unsigned int clock = (sw >> (6 - (2 * i))) & 3;
  121. switch (clock) {
  122. case 0:
  123. actual[i] = SRDS_PLLCR0_RFCK_SEL_100;
  124. break;
  125. case 1:
  126. actual[i] = SRDS_PLLCR0_RFCK_SEL_125;
  127. break;
  128. case 2:
  129. actual[i] = SRDS_PLLCR0_RFCK_SEL_156_25;
  130. break;
  131. default:
  132. printf("Warning: SDREFCLK%u switch setting of '11' is "
  133. "unsupported\n", i + 1);
  134. break;
  135. }
  136. }
  137. #else
  138. /* Warn if the expected SERDES reference clocks don't match the
  139. * actual reference clocks. This needs to be done after calling
  140. * p4080_erratum_serdes8(), since that function may modify the clocks.
  141. */
  142. sw = in_8(&PIXIS_SW(3));
  143. actual[0] = (sw & 0x40) ?
  144. SRDS_PLLCR0_RFCK_SEL_125 : SRDS_PLLCR0_RFCK_SEL_100;
  145. actual[1] = (sw & 0x20) ?
  146. SRDS_PLLCR0_RFCK_SEL_156_25 : SRDS_PLLCR0_RFCK_SEL_125;
  147. actual[2] = (sw & 0x10) ?
  148. SRDS_PLLCR0_RFCK_SEL_156_25 : SRDS_PLLCR0_RFCK_SEL_125;
  149. #endif
  150. for (i = 0; i < NUM_SRDS_BANKS; i++) {
  151. u32 expected = srds_regs->bank[i].pllcr0 & SRDS_PLLCR0_RFCK_SEL_MASK;
  152. if (expected != actual[i]) {
  153. printf("Warning: SERDES bank %u expects reference clock"
  154. " %sMHz, but actual is %sMHz\n", i + 1,
  155. serdes_clock_to_string(expected),
  156. serdes_clock_to_string(actual[i]));
  157. }
  158. }
  159. return 0;
  160. }
  161. int ft_board_setup(void *blob, bd_t *bd)
  162. {
  163. phys_addr_t base;
  164. phys_size_t size;
  165. ft_cpu_setup(blob, bd);
  166. base = env_get_bootm_low();
  167. size = env_get_bootm_size();
  168. fdt_fixup_memory(blob, (u64)base, (u64)size);
  169. #ifdef CONFIG_PCI
  170. pci_of_setup(blob, bd);
  171. #endif
  172. fdt_fixup_liodn(blob);
  173. fsl_fdt_fixup_dr_usb(blob, bd);
  174. #ifdef CONFIG_SYS_DPAA_FMAN
  175. fdt_fixup_fman_ethernet(blob);
  176. fdt_fixup_board_enet(blob);
  177. #endif
  178. return 0;
  179. }