corenet_ds.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * Copyright 2009-2011 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <command.h>
  24. #include <netdev.h>
  25. #include <linux/compiler.h>
  26. #include <asm/mmu.h>
  27. #include <asm/processor.h>
  28. #include <asm/cache.h>
  29. #include <asm/immap_85xx.h>
  30. #include <asm/fsl_law.h>
  31. #include <asm/fsl_serdes.h>
  32. #include <asm/fsl_portals.h>
  33. #include <asm/fsl_liodn.h>
  34. #include <fm_eth.h>
  35. #include "../common/ngpixis.h"
  36. #include "corenet_ds.h"
  37. DECLARE_GLOBAL_DATA_PTR;
  38. int checkboard (void)
  39. {
  40. u8 sw;
  41. struct cpu_type *cpu = gd->cpu;
  42. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  43. unsigned int i;
  44. printf("Board: %sDS, ", cpu->name);
  45. printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  46. in_8(&pixis->id), in_8(&pixis->arch), in_8(&pixis->scver));
  47. sw = in_8(&PIXIS_SW(PIXIS_LBMAP_SWITCH));
  48. sw = (sw & PIXIS_LBMAP_MASK) >> PIXIS_LBMAP_SHIFT;
  49. if (sw < 0x8)
  50. printf("vBank: %d\n", sw);
  51. else if (sw == 0x8)
  52. puts("Promjet\n");
  53. else if (sw == 0x9)
  54. puts("NAND\n");
  55. else
  56. printf("invalid setting of SW%u\n", PIXIS_LBMAP_SWITCH);
  57. /* Display the RCW, so that no one gets confused as to what RCW
  58. * we're actually using for this boot.
  59. */
  60. puts("Reset Configuration Word (RCW):");
  61. for (i = 0; i < ARRAY_SIZE(gur->rcwsr); i++) {
  62. u32 rcw = in_be32(&gur->rcwsr[i]);
  63. if ((i % 4) == 0)
  64. printf("\n %08x:", i * 4);
  65. printf(" %08x", rcw);
  66. }
  67. puts("\n");
  68. /* Display the actual SERDES reference clocks as configured by the
  69. * dip switches on the board. Note that the SWx registers could
  70. * technically be set to force the reference clocks to match the
  71. * values that the SERDES expects (or vice versa). For now, however,
  72. * we just display both values and hope the user notices when they
  73. * don't match.
  74. */
  75. puts("SERDES Reference Clocks: ");
  76. #if defined(CONFIG_P3041DS) || defined(CONFIG_P5020DS)
  77. sw = in_8(&PIXIS_SW(5));
  78. for (i = 0; i < 3; i++) {
  79. static const char *freq[] = {"100", "125", "156.25", "212.5" };
  80. unsigned int clock = (sw >> (6 - (2 * i))) & 3;
  81. printf("Bank%u=%sMhz ", i+1, freq[clock]);
  82. }
  83. puts("\n");
  84. #else
  85. sw = in_8(&PIXIS_SW(3));
  86. printf("Bank1=%uMHz ", (sw & 0x40) ? 125 : 100);
  87. printf("Bank2=%sMHz ", (sw & 0x20) ? "156.25" : "125");
  88. printf("Bank3=%sMHz\n", (sw & 0x10) ? "156.25" : "125");
  89. #endif
  90. return 0;
  91. }
  92. int board_early_init_f(void)
  93. {
  94. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  95. /*
  96. * P4080 DS board only uses the DDR1_MCK0/3 and DDR2_MCK0/3
  97. * disable the DDR1_MCK1/2/4/5 and DDR2_MCK1/2/4/5 to reduce
  98. * the noise introduced by these unterminated and unused clock pairs.
  99. */
  100. setbits_be32(&gur->ddrclkdr, 0x001B001B);
  101. return 0;
  102. }
  103. int board_early_init_r(void)
  104. {
  105. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  106. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  107. /*
  108. * Remap Boot flash + PROMJET region to caching-inhibited
  109. * so that flash can be erased properly.
  110. */
  111. /* Flush d-cache and invalidate i-cache of any FLASH data */
  112. flush_dcache();
  113. invalidate_icache();
  114. /* invalidate existing TLB entry for flash + promjet */
  115. disable_tlb(flash_esel);
  116. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, /* tlb, epn, rpn */
  117. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */
  118. 0, flash_esel, BOOKE_PAGESZ_256M, 1); /* ts, esel, tsize, iprot */
  119. set_liodns();
  120. #ifdef CONFIG_SYS_DPAA_QBMAN
  121. setup_portals();
  122. #endif
  123. return 0;
  124. }
  125. static const char *serdes_clock_to_string(u32 clock)
  126. {
  127. switch(clock) {
  128. case SRDS_PLLCR0_RFCK_SEL_100:
  129. return "100";
  130. case SRDS_PLLCR0_RFCK_SEL_125:
  131. return "125";
  132. case SRDS_PLLCR0_RFCK_SEL_156_25:
  133. return "156.25";
  134. default:
  135. return "150";
  136. }
  137. }
  138. #define NUM_SRDS_BANKS 3
  139. int misc_init_r(void)
  140. {
  141. serdes_corenet_t *srds_regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
  142. u32 actual[NUM_SRDS_BANKS];
  143. unsigned int i;
  144. u8 sw;
  145. #if defined(CONFIG_P3041DS) || defined(CONFIG_P5020DS)
  146. sw = in_8(&PIXIS_SW(5));
  147. for (i = 0; i < 3; i++) {
  148. unsigned int clock = (sw >> (6 - (2 * i))) & 3;
  149. switch (clock) {
  150. case 0:
  151. actual[i] = SRDS_PLLCR0_RFCK_SEL_100;
  152. break;
  153. case 1:
  154. actual[i] = SRDS_PLLCR0_RFCK_SEL_125;
  155. break;
  156. case 2:
  157. actual[i] = SRDS_PLLCR0_RFCK_SEL_156_25;
  158. break;
  159. default:
  160. printf("Warning: SDREFCLK%u switch setting of '11' is "
  161. "unsupported\n", i + 1);
  162. break;
  163. }
  164. }
  165. #else
  166. /* Warn if the expected SERDES reference clocks don't match the
  167. * actual reference clocks. This needs to be done after calling
  168. * p4080_erratum_serdes8(), since that function may modify the clocks.
  169. */
  170. sw = in_8(&PIXIS_SW(3));
  171. actual[0] = (sw & 0x40) ?
  172. SRDS_PLLCR0_RFCK_SEL_125 : SRDS_PLLCR0_RFCK_SEL_100;
  173. actual[1] = (sw & 0x20) ?
  174. SRDS_PLLCR0_RFCK_SEL_156_25 : SRDS_PLLCR0_RFCK_SEL_125;
  175. actual[2] = (sw & 0x10) ?
  176. SRDS_PLLCR0_RFCK_SEL_156_25 : SRDS_PLLCR0_RFCK_SEL_125;
  177. #endif
  178. for (i = 0; i < NUM_SRDS_BANKS; i++) {
  179. u32 expected = srds_regs->bank[i].pllcr0 & SRDS_PLLCR0_RFCK_SEL_MASK;
  180. if (expected != actual[i]) {
  181. printf("Warning: SERDES bank %u expects reference clock"
  182. " %sMHz, but actual is %sMHz\n", i + 1,
  183. serdes_clock_to_string(expected),
  184. serdes_clock_to_string(actual[i]));
  185. }
  186. }
  187. return 0;
  188. }
  189. void ft_board_setup(void *blob, bd_t *bd)
  190. {
  191. phys_addr_t base;
  192. phys_size_t size;
  193. ft_cpu_setup(blob, bd);
  194. base = getenv_bootm_low();
  195. size = getenv_bootm_size();
  196. fdt_fixup_memory(blob, (u64)base, (u64)size);
  197. #ifdef CONFIG_PCI
  198. pci_of_setup(blob, bd);
  199. #endif
  200. fdt_fixup_liodn(blob);
  201. fdt_fixup_dr_usb(blob, bd);
  202. #ifdef CONFIG_SYS_DPAA_FMAN
  203. fdt_fixup_fman_ethernet(blob);
  204. fdt_fixup_board_enet(blob);
  205. #endif
  206. }