corenet_ds.c 5.5 KB

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