p2041rdb.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * Copyright 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. extern void pci_of_setup(void *blob, bd_t *bd);
  36. #include "cpld.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: %sRDB, ", cpu->name);
  45. printf("CPLD version: %d.%d ", CPLD_READ(cpld_ver),
  46. CPLD_READ(cpld_ver_sub));
  47. sw = CPLD_READ(fbank_sel);
  48. printf("vBank: %d\n", sw & 0x1);
  49. #ifdef CONFIG_PHYS_64BIT
  50. puts("36-bit Addressing\n");
  51. #endif
  52. /*
  53. * Display the RCW, so that no one gets confused as to what RCW
  54. * we're actually using for this boot.
  55. */
  56. puts("Reset Configuration Word (RCW):");
  57. for (i = 0; i < ARRAY_SIZE(gur->rcwsr); i++) {
  58. u32 rcw = in_be32(&gur->rcwsr[i]);
  59. if ((i % 4) == 0)
  60. printf("\n %08x:", i * 4);
  61. printf(" %08x", rcw);
  62. }
  63. puts("\n");
  64. /*
  65. * Display the actual SERDES reference clocks as configured by the
  66. * dip switches on the board. Note that the SWx registers could
  67. * technically be set to force the reference clocks to match the
  68. * values that the SERDES expects (or vice versa). For now, however,
  69. * we just display both values and hope the user notices when they
  70. * don't match.
  71. */
  72. puts("SERDES Reference Clocks: ");
  73. sw = in_8(&CPLD_SW(2)) >> 2;
  74. for (i = 0; i < 2; i++) {
  75. static const char * const freq[] = {"0", "100", "125"};
  76. unsigned int clock = (sw >> (2 * i)) & 3;
  77. printf("Bank%u=%sMhz ", i+1, freq[clock]);
  78. }
  79. puts("\n");
  80. return 0;
  81. }
  82. int board_early_init_f(void)
  83. {
  84. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  85. /* board only uses the DDR_MCK0/1, so disable the DDR_MCK2/3 */
  86. setbits_be32(&gur->ddrclkdr, 0x000f000f);
  87. return 0;
  88. }
  89. int board_early_init_r(void)
  90. {
  91. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  92. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  93. /*
  94. * Remap Boot flash + PROMJET region to caching-inhibited
  95. * so that flash can be erased properly.
  96. */
  97. /* Flush d-cache and invalidate i-cache of any FLASH data */
  98. flush_dcache();
  99. invalidate_icache();
  100. /* invalidate existing TLB entry for flash + promjet */
  101. disable_tlb(flash_esel);
  102. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  103. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  104. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  105. set_liodns();
  106. setup_portals();
  107. return 0;
  108. }
  109. unsigned long get_board_sys_clk(unsigned long dummy)
  110. {
  111. u8 sysclk_conf = CPLD_READ(sysclk_sw1);
  112. switch (sysclk_conf & 0x7) {
  113. case CPLD_SYSCLK_83:
  114. return 83333333;
  115. case CPLD_SYSCLK_100:
  116. return 100000000;
  117. default:
  118. return 66666666;
  119. }
  120. }
  121. static const char *serdes_clock_to_string(u32 clock)
  122. {
  123. switch (clock) {
  124. case SRDS_PLLCR0_RFCK_SEL_100:
  125. return "100";
  126. case SRDS_PLLCR0_RFCK_SEL_125:
  127. return "125";
  128. case SRDS_PLLCR0_RFCK_SEL_156_25:
  129. return "156.25";
  130. default:
  131. return "150";
  132. }
  133. }
  134. #define NUM_SRDS_BANKS 2
  135. int misc_init_r(void)
  136. {
  137. serdes_corenet_t *regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
  138. u32 actual[NUM_SRDS_BANKS];
  139. unsigned int i;
  140. u8 sw;
  141. sw = in_8(&CPLD_SW(2)) >> 2;
  142. for (i = 0; i < NUM_SRDS_BANKS; i++) {
  143. unsigned int clock = (sw >> (2 * i)) & 3;
  144. switch (clock) {
  145. case 1:
  146. actual[i] = SRDS_PLLCR0_RFCK_SEL_100;
  147. break;
  148. case 2:
  149. actual[i] = SRDS_PLLCR0_RFCK_SEL_125;
  150. break;
  151. default:
  152. printf("Warning: SDREFCLK%u switch setting of '11' is "
  153. "unsupported\n", i + 1);
  154. break;
  155. }
  156. }
  157. for (i = 0; i < NUM_SRDS_BANKS; i++) {
  158. u32 expected = in_be32(&regs->bank[i].pllcr0);
  159. expected &= SRDS_PLLCR0_RFCK_SEL_MASK;
  160. if (expected != actual[i]) {
  161. printf("Warning: SERDES bank %u expects reference clock"
  162. " %sMHz, but actual is %sMHz\n", i + 1,
  163. serdes_clock_to_string(expected),
  164. serdes_clock_to_string(actual[i]));
  165. }
  166. }
  167. return 0;
  168. }
  169. void ft_board_setup(void *blob, bd_t *bd)
  170. {
  171. phys_addr_t base;
  172. phys_size_t size;
  173. ft_cpu_setup(blob, bd);
  174. base = getenv_bootm_low();
  175. size = getenv_bootm_size();
  176. fdt_fixup_memory(blob, (u64)base, (u64)size);
  177. #ifdef CONFIG_PCI
  178. pci_of_setup(blob, bd);
  179. #endif
  180. fdt_fixup_liodn(blob);
  181. #ifdef CONFIG_SYS_DPAA_FMAN
  182. fdt_fixup_fman_ethernet(blob);
  183. #endif
  184. }