p3060qds.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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. #include <configs/P3060QDS.h>
  36. #include <libfdt.h>
  37. #include <fdt_support.h>
  38. #include "../common/qixis.h"
  39. #include "p3060qds.h"
  40. #include "p3060qds_qixis.h"
  41. DECLARE_GLOBAL_DATA_PTR;
  42. int checkboard(void)
  43. {
  44. u8 sw;
  45. struct cpu_type *cpu = gd->cpu;
  46. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  47. unsigned int i;
  48. printf("Board: %s", cpu->name);
  49. puts("QDS, ");
  50. printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  51. QIXIS_READ(id), QIXIS_READ(arch), QIXIS_READ(scver));
  52. sw = QIXIS_READ(brdcfg[0]);
  53. sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
  54. if (sw < 0x8)
  55. printf("vBank: %d\n", sw);
  56. else if (sw == 0x8)
  57. puts("Promjet\n");
  58. else if (sw == 0x9)
  59. puts("NAND\n");
  60. else
  61. printf("invalid setting of SW%u\n", PIXIS_LBMAP_SWITCH);
  62. puts("Reset Configuration Word (RCW):");
  63. for (i = 0; i < ARRAY_SIZE(gur->rcwsr); i++) {
  64. u32 rcw = in_be32(&gur->rcwsr[i]);
  65. if ((i % 4) == 0)
  66. printf("\n %08x:", i * 4);
  67. printf(" %08x", rcw);
  68. }
  69. puts("\n");
  70. puts("SERDES Reference Clocks: ");
  71. sw = QIXIS_READ(brdcfg[2]);
  72. for (i = 0; i < 3; i++) {
  73. static const char * const freq[] = {"100", "125", "Reserved",
  74. "156.25"};
  75. unsigned int clock = (sw >> (2 * i)) & 3;
  76. printf("Bank%u=%sMhz ", i+1, freq[clock]);
  77. }
  78. puts("\n");
  79. return 0;
  80. }
  81. int board_early_init_f(void)
  82. {
  83. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  84. /* only single DDR controller on QDS board, disable DDR1_MCK4/5 */
  85. setbits_be32(&gur->ddrclkdr, 0x00030000);
  86. return 0;
  87. }
  88. void board_config_serdes_mux(void)
  89. {
  90. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  91. int cfg = (in_be32(&gur->rcwsr[4]) &
  92. FSL_CORENET_RCWSR4_SRDS_PRTCL) >> 26;
  93. switch (cfg) {
  94. case 0x03:
  95. case 0x06:
  96. /* set Lane I,J as SGMII */
  97. QIXIS_WRITE(brdcfg[6], BRDCFG6_SD4MX_B | BRDCFG6_SD3MX_A |
  98. BRDCFG6_SD2MX_B | BRDCFG6_SD1MX_A);
  99. break;
  100. case 0x16:
  101. case 0x19:
  102. case 0x1c:
  103. /* set Lane I,J as Aurora Debug */
  104. QIXIS_WRITE(brdcfg[6], BRDCFG6_SD4MX_A | BRDCFG6_SD3MX_B |
  105. BRDCFG6_SD2MX_A | BRDCFG6_SD1MX_B);
  106. break;
  107. default:
  108. puts("Invalid SerDes protocol for P3060QDS\n");
  109. break;
  110. }
  111. }
  112. void board_config_usb_mux(void)
  113. {
  114. u8 brdcfg4, brdcfg5, brdcfg7;
  115. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  116. u32 rcwsr11 = in_be32(&gur->rcwsr[11]);
  117. u32 ec1 = rcwsr11 & FSL_CORENET_RCWSR11_EC1;
  118. u32 ec2 = rcwsr11 & FSL_CORENET_RCWSR11_EC2;
  119. brdcfg4 = QIXIS_READ(brdcfg[4]);
  120. brdcfg4 &= ~BRDCFG4_EC_MODE_MASK;
  121. if ((ec1 == FSL_CORENET_RCWSR11_EC1_FM1_USB1) &&
  122. (ec2 == FSL_CORENET_RCWSR11_EC2_USB2)) {
  123. brdcfg4 |= BRDCFG4_EC2_USB_EC1_USB;
  124. } else if ((ec1 == FSL_CORENET_RCWSR11_EC1_FM1_USB1) &&
  125. ((ec2 == FSL_CORENET_RCWSR11_EC2_FM1_DTSEC2) ||
  126. (ec2 == FSL_CORENET_RCWSR11_EC2_FM2_DTSEC1))) {
  127. brdcfg4 |= BRDCFG4_EC2_RGMII_EC1_USB;
  128. } else if ((ec1 == FSL_CORENET_RCWSR11_EC1_FM1_DTSEC1) &&
  129. (ec2 == FSL_CORENET_RCWSR11_EC2_USB2)) {
  130. brdcfg4 |= BRDCFG4_EC2_USB_EC1_RGMII;
  131. } else if ((ec1 == FSL_CORENET_RCWSR11_EC1_FM1_DTSEC1) &&
  132. ((ec2 == FSL_CORENET_RCWSR11_EC2_FM1_DTSEC2) ||
  133. (ec2 == FSL_CORENET_RCWSR11_EC2_FM2_DTSEC1))) {
  134. brdcfg4 |= BRDCFG4_EC2_RGMII_EC1_RGMII;
  135. } else {
  136. brdcfg4 |= BRDCFG4_EC2_MII_EC1_MII;
  137. }
  138. QIXIS_WRITE(brdcfg[4], brdcfg4);
  139. brdcfg5 = QIXIS_READ(brdcfg[5]);
  140. brdcfg5 &= ~(BRDCFG5_USB1ID_MASK | BRDCFG5_USB2ID_MASK);
  141. brdcfg5 |= (BRDCFG5_USB1ID_CTRL | BRDCFG5_USB2ID_CTRL);
  142. QIXIS_WRITE(brdcfg[5], brdcfg5);
  143. brdcfg7 = BRDCFG7_JTAGMX_COP_JTAG | BRDCFG7_IQ1MX_IRQ_EVT |
  144. BRDCFG7_G1MX_USB1 | BRDCFG7_D1MX_TSEC3USB | BRDCFG7_I3MX_USB1;
  145. QIXIS_WRITE(brdcfg[7], brdcfg7);
  146. }
  147. int board_early_init_r(void)
  148. {
  149. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  150. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  151. /*
  152. * Remap Boot flash + PROMJET region to caching-inhibited
  153. * so that flash can be erased properly.
  154. */
  155. /* Flush d-cache and invalidate i-cache of any FLASH data */
  156. flush_dcache();
  157. invalidate_icache();
  158. /* invalidate existing TLB entry for flash + promjet */
  159. disable_tlb(flash_esel);
  160. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  161. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  162. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  163. set_liodns();
  164. #ifdef CONFIG_SYS_DPAA_QBMAN
  165. setup_portals();
  166. #endif
  167. board_config_serdes_mux();
  168. board_config_usb_mux();
  169. return 0;
  170. }
  171. static const char *serdes_clock_to_string(u32 clock)
  172. {
  173. switch (clock) {
  174. case SRDS_PLLCR0_RFCK_SEL_100:
  175. return "100";
  176. case SRDS_PLLCR0_RFCK_SEL_125:
  177. return "125";
  178. case SRDS_PLLCR0_RFCK_SEL_156_25:
  179. return "156.25";
  180. default:
  181. return "150";
  182. }
  183. }
  184. #define NUM_SRDS_BANKS 3
  185. int misc_init_r(void)
  186. {
  187. serdes_corenet_t *srds_regs;
  188. u32 actual[NUM_SRDS_BANKS];
  189. unsigned int i;
  190. u8 sw;
  191. sw = QIXIS_READ(brdcfg[2]);
  192. for (i = 0; i < 3; i++) {
  193. unsigned int clock = (sw >> (2 * i)) & 3;
  194. switch (clock) {
  195. case 0:
  196. actual[i] = SRDS_PLLCR0_RFCK_SEL_100;
  197. break;
  198. case 1:
  199. actual[i] = SRDS_PLLCR0_RFCK_SEL_125;
  200. break;
  201. case 3:
  202. actual[i] = SRDS_PLLCR0_RFCK_SEL_156_25;
  203. break;
  204. default:
  205. printf("Warning: SDREFCLK%u switch setting of '10' is "
  206. "unsupported\n", i + 1);
  207. break;
  208. }
  209. }
  210. srds_regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
  211. for (i = 0; i < NUM_SRDS_BANKS; i++) {
  212. u32 pllcr0 = in_be32(&srds_regs->bank[i].pllcr0);
  213. u32 expected = pllcr0 & SRDS_PLLCR0_RFCK_SEL_MASK;
  214. if (expected != actual[i]) {
  215. printf("Warning: SERDES bank %u expects reference clock"
  216. " %sMHz, but actual is %sMHz\n", i + 1,
  217. serdes_clock_to_string(expected),
  218. serdes_clock_to_string(actual[i]));
  219. }
  220. }
  221. return 0;
  222. }
  223. /*
  224. * This is map of CVDD values. 33 means CVDD is 3.3v, 25 means CVDD is 2.5v,
  225. * 18 means CVDD is 1.8v.
  226. */
  227. static u8 IO_VSEL[] = {
  228. 33, 33, 33, 25, 25, 25, 18, 18, 18,
  229. 33, 33, 33, 25, 25, 25, 18, 18, 18,
  230. 33, 33, 33, 25, 25, 25, 18, 18, 18,
  231. 33, 33, 33, 33, 33
  232. };
  233. #define IO_VSEL_MASK 0x1f
  234. /*
  235. * different CVDD selects diffenert spi flashs, read dutcfg[3] to get CVDD,
  236. * then set status of spi flash nodes to 'disabled' according to CVDD.
  237. * CVDD '33' will select spi flash0 and flash1, CVDD '25' will select spi
  238. * flash2, CVDD '18' will select spi flash3.
  239. */
  240. void fdt_fixup_board_spi(void *blob)
  241. {
  242. u8 sw5 = QIXIS_READ(dutcfg[3]);
  243. switch (IO_VSEL[sw5 & IO_VSEL_MASK]) {
  244. /* 3.3v */
  245. case 33:
  246. do_fixup_by_compat(blob, "atmel,at45db081d", "status",
  247. "disabled", strlen("disabled") + 1, 1);
  248. do_fixup_by_compat(blob, "spansion,sst25wf040", "status",
  249. "disabled", strlen("disabled") + 1, 1);
  250. break;
  251. /* 2.5v */
  252. case 25:
  253. do_fixup_by_compat(blob, "spansion,s25sl12801", "status",
  254. "disabled", strlen("disabled") + 1, 1);
  255. do_fixup_by_compat(blob, "spansion,en25q32", "status",
  256. "disabled", strlen("disabled") + 1, 1);
  257. do_fixup_by_compat(blob, "spansion,sst25wf040", "status",
  258. "disabled", strlen("disabled") + 1, 1);
  259. break;
  260. /* 1.8v */
  261. case 18:
  262. do_fixup_by_compat(blob, "spansion,s25sl12801", "status",
  263. "disabled", strlen("disabled") + 1, 1);
  264. do_fixup_by_compat(blob, "spansion,en25q32", "status",
  265. "disabled", strlen("disabled") + 1, 1);
  266. do_fixup_by_compat(blob, "atmel,at45db081d", "status",
  267. "disabled", strlen("disabled") + 1, 1);
  268. break;
  269. }
  270. }
  271. void ft_board_setup(void *blob, bd_t *bd)
  272. {
  273. phys_addr_t base;
  274. phys_size_t size;
  275. ft_cpu_setup(blob, bd);
  276. base = getenv_bootm_low();
  277. size = getenv_bootm_size();
  278. fdt_fixup_memory(blob, (u64)base, (u64)size);
  279. #ifdef CONFIG_PCI
  280. pci_of_setup(blob, bd);
  281. #endif
  282. fdt_fixup_liodn(blob);
  283. fdt_fixup_dr_usb(blob, bd);
  284. fdt_fixup_board_spi(blob);
  285. #ifdef CONFIG_SYS_DPAA_FMAN
  286. fdt_fixup_fman_ethernet(blob);
  287. fdt_fixup_board_enet(blob);
  288. #endif
  289. }