p1022ds.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /*
  2. * Copyright 2010-2011 Freescale Semiconductor, Inc.
  3. * Authors: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
  4. * Timur Tabi <timur@freescale.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. */
  11. #include <common.h>
  12. #include <command.h>
  13. #include <pci.h>
  14. #include <asm/processor.h>
  15. #include <asm/mmu.h>
  16. #include <asm/cache.h>
  17. #include <asm/immap_85xx.h>
  18. #include <asm/fsl_pci.h>
  19. #include <asm/fsl_ddr_sdram.h>
  20. #include <asm/fsl_serdes.h>
  21. #include <asm/io.h>
  22. #include <libfdt.h>
  23. #include <fdt_support.h>
  24. #include <tsec.h>
  25. #include <asm/fsl_law.h>
  26. #include <netdev.h>
  27. #include <i2c.h>
  28. #include <hwconfig.h>
  29. #include "../common/ngpixis.h"
  30. DECLARE_GLOBAL_DATA_PTR;
  31. int board_early_init_f(void)
  32. {
  33. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  34. /* Set pmuxcr to allow both i2c1 and i2c2 */
  35. setbits_be32(&gur->pmuxcr, 0x1000);
  36. /* Read back the register to synchronize the write. */
  37. in_be32(&gur->pmuxcr);
  38. /* Set the pin muxing to enable ETSEC2. */
  39. clrbits_be32(&gur->pmuxcr2, 0x001F8000);
  40. return 0;
  41. }
  42. int checkboard(void)
  43. {
  44. u8 sw;
  45. puts("Board: P1022DS ");
  46. #ifdef CONFIG_PHYS_64BIT
  47. puts("(36-bit addrmap) ");
  48. #endif
  49. printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  50. in_8(&pixis->id), in_8(&pixis->arch), in_8(&pixis->scver));
  51. sw = in_8(&PIXIS_SW(PIXIS_LBMAP_SWITCH));
  52. switch ((sw & PIXIS_LBMAP_MASK) >> 6) {
  53. case 0:
  54. printf ("vBank: %u\n", ((sw & 0x30) >> 4));
  55. break;
  56. case 1:
  57. printf ("NAND\n");
  58. break;
  59. case 2:
  60. case 3:
  61. puts ("Promjet\n");
  62. break;
  63. }
  64. return 0;
  65. }
  66. #define CONFIG_TFP410_I2C_ADDR 0x38
  67. /* Masks for the SSI_TDM and AUDCLK bits of the ngPIXIS BRDCFG1 register. */
  68. #define CONFIG_PIXIS_BRDCFG1_SSI_TDM_MASK 0x0c
  69. #define CONFIG_PIXIS_BRDCFG1_AUDCLK_MASK 0x03
  70. /* Route the I2C1 pins to the SSI port instead. */
  71. #define CONFIG_PIXIS_BRDCFG1_SSI_TDM_SSI 0x08
  72. /* Choose the 12.288Mhz codec reference clock */
  73. #define CONFIG_PIXIS_BRDCFG1_AUDCLK_12 0x02
  74. /* Choose the 11.2896Mhz codec reference clock */
  75. #define CONFIG_PIXIS_BRDCFG1_AUDCLK_11 0x01
  76. int misc_init_r(void)
  77. {
  78. u8 temp;
  79. const char *audclk;
  80. size_t arglen;
  81. /* For DVI, enable the TFP410 Encoder. */
  82. temp = 0xBF;
  83. if (i2c_write(CONFIG_TFP410_I2C_ADDR, 0x08, 1, &temp, sizeof(temp)) < 0)
  84. return -1;
  85. if (i2c_read(CONFIG_TFP410_I2C_ADDR, 0x08, 1, &temp, sizeof(temp)) < 0)
  86. return -1;
  87. debug("DVI Encoder Read: 0x%02x\n", temp);
  88. temp = 0x10;
  89. if (i2c_write(CONFIG_TFP410_I2C_ADDR, 0x0A, 1, &temp, sizeof(temp)) < 0)
  90. return -1;
  91. if (i2c_read(CONFIG_TFP410_I2C_ADDR, 0x0A, 1, &temp, sizeof(temp)) < 0)
  92. return -1;
  93. debug("DVI Encoder Read: 0x%02x\n",temp);
  94. /*
  95. * Enable the reference clock for the WM8776 codec, and route the MUX
  96. * pins for SSI. The default is the 12.288 MHz clock
  97. */
  98. temp = in_8(&pixis->brdcfg1) & ~(CONFIG_PIXIS_BRDCFG1_SSI_TDM_MASK |
  99. CONFIG_PIXIS_BRDCFG1_AUDCLK_MASK);
  100. temp |= CONFIG_PIXIS_BRDCFG1_SSI_TDM_SSI;
  101. audclk = hwconfig_arg("audclk", &arglen);
  102. /* Check the first two chars only */
  103. if (audclk && (strncmp(audclk, "11", 2) == 0))
  104. temp |= CONFIG_PIXIS_BRDCFG1_AUDCLK_11;
  105. else
  106. temp |= CONFIG_PIXIS_BRDCFG1_AUDCLK_12;
  107. out_8(&pixis->brdcfg1, temp);
  108. return 0;
  109. }
  110. /*
  111. * A list of PCI and SATA slots
  112. */
  113. enum slot_id {
  114. SLOT_PCIE1 = 1,
  115. SLOT_PCIE2,
  116. SLOT_PCIE3,
  117. SLOT_PCIE4,
  118. SLOT_PCIE5,
  119. SLOT_SATA1,
  120. SLOT_SATA2
  121. };
  122. /*
  123. * This array maps the slot identifiers to their names on the P1022DS board.
  124. */
  125. static const char *slot_names[] = {
  126. [SLOT_PCIE1] = "Slot 1",
  127. [SLOT_PCIE2] = "Slot 2",
  128. [SLOT_PCIE3] = "Slot 3",
  129. [SLOT_PCIE4] = "Slot 4",
  130. [SLOT_PCIE5] = "Mini-PCIe",
  131. [SLOT_SATA1] = "SATA 1",
  132. [SLOT_SATA2] = "SATA 2",
  133. };
  134. /*
  135. * This array maps a given SERDES configuration and SERDES device to the PCI or
  136. * SATA slot that it connects to. This mapping is hard-coded in the FPGA.
  137. */
  138. static u8 serdes_dev_slot[][SATA2 + 1] = {
  139. [0x01] = { [PCIE3] = SLOT_PCIE4, [PCIE2] = SLOT_PCIE5 },
  140. [0x02] = { [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
  141. [0x09] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE4,
  142. [PCIE2] = SLOT_PCIE5 },
  143. [0x16] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE2,
  144. [PCIE2] = SLOT_PCIE3,
  145. [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
  146. [0x17] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE2,
  147. [PCIE2] = SLOT_PCIE3 },
  148. [0x1a] = { [PCIE1] = SLOT_PCIE1, [PCIE2] = SLOT_PCIE3,
  149. [PCIE2] = SLOT_PCIE3,
  150. [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
  151. [0x1c] = { [PCIE1] = SLOT_PCIE1,
  152. [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
  153. [0x1e] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE3 },
  154. [0x1f] = { [PCIE1] = SLOT_PCIE1 },
  155. };
  156. /*
  157. * Returns the name of the slot to which the PCIe or SATA controller is
  158. * connected
  159. */
  160. const char *board_serdes_name(enum srds_prtcl device)
  161. {
  162. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  163. u32 pordevsr = in_be32(&gur->pordevsr);
  164. unsigned int srds_cfg = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >>
  165. MPC85xx_PORDEVSR_IO_SEL_SHIFT;
  166. enum slot_id slot = serdes_dev_slot[srds_cfg][device];
  167. const char *name = slot_names[slot];
  168. if (name)
  169. return name;
  170. else
  171. return "Nothing";
  172. }
  173. #ifdef CONFIG_PCI
  174. void pci_init_board(void)
  175. {
  176. fsl_pcie_init_board(0);
  177. }
  178. #endif
  179. int board_early_init_r(void)
  180. {
  181. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  182. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  183. /*
  184. * Remap Boot flash + PROMJET region to caching-inhibited
  185. * so that flash can be erased properly.
  186. */
  187. /* Flush d-cache and invalidate i-cache of any FLASH data */
  188. flush_dcache();
  189. invalidate_icache();
  190. /* invalidate existing TLB entry for flash + promjet */
  191. disable_tlb(flash_esel);
  192. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  193. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  194. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  195. return 0;
  196. }
  197. /*
  198. * Initialize on-board and/or PCI Ethernet devices
  199. *
  200. * Returns:
  201. * <0, error
  202. * 0, no ethernet devices found
  203. * >0, number of ethernet devices initialized
  204. */
  205. int board_eth_init(bd_t *bis)
  206. {
  207. struct tsec_info_struct tsec_info[2];
  208. unsigned int num = 0;
  209. #ifdef CONFIG_TSEC1
  210. SET_STD_TSEC_INFO(tsec_info[num], 1);
  211. num++;
  212. #endif
  213. #ifdef CONFIG_TSEC2
  214. SET_STD_TSEC_INFO(tsec_info[num], 2);
  215. num++;
  216. #endif
  217. return tsec_eth_init(bis, tsec_info, num) + pci_eth_init(bis);
  218. }
  219. #ifdef CONFIG_OF_BOARD_SETUP
  220. /**
  221. * ft_codec_setup - fix up the clock-frequency property of the codec node
  222. *
  223. * Update the clock-frequency property based on the value of the 'audclk'
  224. * hwconfig option. If audclk is not specified, then default to 12.288MHz.
  225. */
  226. static void ft_codec_setup(void *blob, const char *compatible)
  227. {
  228. const char *audclk;
  229. size_t arglen;
  230. u32 freq;
  231. audclk = hwconfig_arg("audclk", &arglen);
  232. if (audclk && (strncmp(audclk, "11", 2) == 0))
  233. freq = 11289600;
  234. else
  235. freq = 12288000;
  236. do_fixup_by_compat_u32(blob, compatible, "clock-frequency", freq, 1);
  237. }
  238. void ft_board_setup(void *blob, bd_t *bd)
  239. {
  240. phys_addr_t base;
  241. phys_size_t size;
  242. ft_cpu_setup(blob, bd);
  243. base = getenv_bootm_low();
  244. size = getenv_bootm_size();
  245. fdt_fixup_memory(blob, (u64)base, (u64)size);
  246. FT_FSL_PCI_SETUP;
  247. #ifdef CONFIG_FSL_SGMII_RISER
  248. fsl_sgmii_riser_fdt_fixup(blob);
  249. #endif
  250. /* Update the WM8776 node's clock frequency property */
  251. ft_codec_setup(blob, "wlf,wm8776");
  252. }
  253. #endif