p1010rdb.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /*
  2. * Copyright 2010-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 <asm/processor.h>
  24. #include <asm/mmu.h>
  25. #include <asm/cache.h>
  26. #include <asm/immap_85xx.h>
  27. #include <asm/io.h>
  28. #include <miiphy.h>
  29. #include <libfdt.h>
  30. #include <fdt_support.h>
  31. #include <fsl_mdio.h>
  32. #include <tsec.h>
  33. #include <mmc.h>
  34. #include <netdev.h>
  35. #include <pci.h>
  36. #include <asm/fsl_serdes.h>
  37. #include <asm/fsl_ifc.h>
  38. #include <asm/fsl_pci.h>
  39. #ifndef CONFIG_SDCARD
  40. #include <hwconfig.h>
  41. #endif
  42. DECLARE_GLOBAL_DATA_PTR;
  43. #define GPIO4_PCIE_RESET_SET 0x08000000
  44. #define MUX_CPLD_CAN_UART 0x00
  45. #define MUX_CPLD_TDM 0x01
  46. #define MUX_CPLD_SPICS0_FLASH 0x00
  47. #define MUX_CPLD_SPICS0_SLIC 0x02
  48. #ifndef CONFIG_SDCARD
  49. struct cpld_data {
  50. u8 cpld_ver; /* cpld revision */
  51. u8 pcba_ver; /* pcb revision number */
  52. u8 twindie_ddr3;
  53. u8 res1[6];
  54. u8 bank_sel; /* NOR Flash bank */
  55. u8 res2[5];
  56. u8 usb2_sel;
  57. u8 res3[1];
  58. u8 porsw_sel;
  59. u8 tdm_can_sel;
  60. u8 spi_cs0_sel; /* SPI CS0 SLIC/SPI Flash */
  61. u8 por0; /* POR Options */
  62. u8 por1; /* POR Options */
  63. u8 por2; /* POR Options */
  64. u8 por3; /* POR Options */
  65. };
  66. void cpld_show(void)
  67. {
  68. struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
  69. printf("CPLD: V%x.%x PCBA: V%x.0\n",
  70. in_8(&cpld_data->cpld_ver) & 0xF0,
  71. in_8(&cpld_data->cpld_ver) & 0x0F,
  72. in_8(&cpld_data->pcba_ver) & 0x0F);
  73. #ifdef CONFIG_DEBUG
  74. printf("twindie_ddr =%x\n",
  75. in_8(&cpld_data->twindie_ddr3));
  76. printf("bank_sel =%x\n",
  77. in_8(&cpld_data->bank_sel));
  78. printf("usb2_sel =%x\n",
  79. in_8(&cpld_data->usb2_sel));
  80. printf("porsw_sel =%x\n",
  81. in_8(&cpld_data->porsw_sel));
  82. printf("tdm_can_sel =%x\n",
  83. in_8(&cpld_data->tdm_can_sel));
  84. printf("tdm_can_sel =%x\n",
  85. in_8(&cpld_data->tdm_can_sel));
  86. printf("spi_cs0_sel =%x\n",
  87. in_8(&cpld_data->spi_cs0_sel));
  88. printf("bcsr0 =%x\n",
  89. in_8(&cpld_data->bcsr0));
  90. printf("bcsr1 =%x\n",
  91. in_8(&cpld_data->bcsr1));
  92. printf("bcsr2 =%x\n",
  93. in_8(&cpld_data->bcsr2));
  94. printf("bcsr3 =%x\n",
  95. in_8(&cpld_data->bcsr3));
  96. #endif
  97. }
  98. #endif
  99. int board_early_init_f(void)
  100. {
  101. ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
  102. #ifndef CONFIG_SDCARD
  103. struct fsl_ifc *ifc = (void *)CONFIG_SYS_IFC_ADDR;
  104. /* Clock configuration to access CPLD using IFC(GPCM) */
  105. setbits_be32(&ifc->ifc_gcr, 1 << IFC_GCR_TBCTL_TRN_TIME_SHIFT);
  106. #endif
  107. /*
  108. * Reset PCIe slots via GPIO4
  109. */
  110. setbits_be32(&pgpio->gpdir, GPIO4_PCIE_RESET_SET);
  111. setbits_be32(&pgpio->gpdat, GPIO4_PCIE_RESET_SET);
  112. return 0;
  113. }
  114. int board_early_init_r(void)
  115. {
  116. #ifndef CONFIG_SDCARD
  117. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  118. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  119. /*
  120. * Remap Boot flash region to caching-inhibited
  121. * so that flash can be erased properly.
  122. */
  123. /* Flush d-cache and invalidate i-cache of any FLASH data */
  124. flush_dcache();
  125. invalidate_icache();
  126. /* invalidate existing TLB entry for flash */
  127. disable_tlb(flash_esel);
  128. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  129. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  130. 0, flash_esel, BOOKE_PAGESZ_16M, 1);
  131. set_tlb(1, flashbase + 0x1000000,
  132. CONFIG_SYS_FLASH_BASE_PHYS + 0x1000000,
  133. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  134. 0, flash_esel+1, BOOKE_PAGESZ_16M, 1);
  135. #endif
  136. return 0;
  137. }
  138. #ifdef CONFIG_PCI
  139. void pci_init_board(void)
  140. {
  141. fsl_pcie_init_board(0);
  142. }
  143. #endif /* ifdef CONFIG_PCI */
  144. int checkboard(void)
  145. {
  146. struct cpu_type *cpu;
  147. cpu = gd->cpu;
  148. printf("Board: %sRDB ", cpu->name);
  149. #ifdef CONFIG_PHYS_64BIT
  150. puts("(36-bit addrmap)");
  151. #endif
  152. puts("\n");
  153. return 0;
  154. }
  155. #ifdef CONFIG_TSEC_ENET
  156. int board_eth_init(bd_t *bis)
  157. {
  158. struct fsl_pq_mdio_info mdio_info;
  159. struct tsec_info_struct tsec_info[4];
  160. struct cpu_type *cpu;
  161. int num = 0;
  162. cpu = gd->cpu;
  163. #ifdef CONFIG_TSEC1
  164. SET_STD_TSEC_INFO(tsec_info[num], 1);
  165. num++;
  166. #endif
  167. #ifdef CONFIG_TSEC2
  168. SET_STD_TSEC_INFO(tsec_info[num], 2);
  169. num++;
  170. #endif
  171. #ifdef CONFIG_TSEC3
  172. /* P1014 and it's derivatives do not support eTSEC3 */
  173. if (cpu->soc_ver != SVR_P1014 && cpu->soc_ver != SVR_P1014_E) {
  174. SET_STD_TSEC_INFO(tsec_info[num], 3);
  175. num++;
  176. }
  177. #endif
  178. if (!num) {
  179. printf("No TSECs initialized\n");
  180. return 0;
  181. }
  182. mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
  183. mdio_info.name = DEFAULT_MII_NAME;
  184. fsl_pq_mdio_init(bis, &mdio_info);
  185. tsec_eth_init(bis, tsec_info, num);
  186. return pci_eth_init(bis);
  187. }
  188. #endif
  189. #if defined(CONFIG_OF_BOARD_SETUP)
  190. void fdt_del_flexcan(void *blob)
  191. {
  192. int nodeoff = 0;
  193. while ((nodeoff = fdt_node_offset_by_compatible(blob, 0,
  194. "fsl,flexcan-v1.0")) >= 0) {
  195. fdt_del_node(blob, nodeoff);
  196. }
  197. }
  198. void fdt_del_spi_flash(void *blob)
  199. {
  200. int nodeoff = 0;
  201. while ((nodeoff = fdt_node_offset_by_compatible(blob, 0,
  202. "spansion,s25sl12801")) >= 0) {
  203. fdt_del_node(blob, nodeoff);
  204. }
  205. }
  206. void fdt_del_spi_slic(void *blob)
  207. {
  208. int nodeoff = 0;
  209. while ((nodeoff = fdt_node_offset_by_compatible(blob, 0,
  210. "zarlink,le88266")) >= 0) {
  211. fdt_del_node(blob, nodeoff);
  212. }
  213. }
  214. void fdt_del_tdm(void *blob)
  215. {
  216. int nodeoff = 0;
  217. while ((nodeoff = fdt_node_offset_by_compatible(blob, 0,
  218. "fsl,starlite-tdm")) >= 0) {
  219. fdt_del_node(blob, nodeoff);
  220. }
  221. }
  222. void ft_board_setup(void *blob, bd_t *bd)
  223. {
  224. phys_addr_t base;
  225. phys_size_t size;
  226. struct cpu_type *cpu;
  227. cpu = gd->cpu;
  228. ft_cpu_setup(blob, bd);
  229. base = getenv_bootm_low();
  230. size = getenv_bootm_size();
  231. #if defined(CONFIG_PCI)
  232. FT_FSL_PCI_SETUP;
  233. #endif
  234. fdt_fixup_memory(blob, (u64)base, (u64)size);
  235. fdt_fixup_dr_usb(blob, bd);
  236. /* P1014 and it's derivatives don't support CAN and eTSEC3 */
  237. if (cpu->soc_ver == SVR_P1014 || cpu->soc_ver == SVR_P1014_E) {
  238. fdt_del_flexcan(blob);
  239. fdt_del_node_and_alias(blob, "ethernet2");
  240. }
  241. #ifndef CONFIG_SDCARD
  242. if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "can")) {
  243. printf("fdt CAN");
  244. fdt_del_tdm(blob);
  245. fdt_del_spi_slic(blob);
  246. }
  247. #ifndef CONFIG_SPIFLASH
  248. else if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "tdm")) {
  249. printf("fdt TDM");
  250. fdt_del_flexcan(blob);
  251. fdt_del_spi_flash(blob);
  252. }
  253. #endif
  254. #endif
  255. }
  256. #endif
  257. #ifndef CONFIG_SDCARD
  258. int misc_init_r(void)
  259. {
  260. struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
  261. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  262. if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "can")) {
  263. clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_CAN1_TDM |
  264. MPC85xx_PMUXCR_CAN1_UART |
  265. MPC85xx_PMUXCR_CAN2_TDM |
  266. MPC85xx_PMUXCR_CAN2_UART);
  267. out_8(&cpld_data->tdm_can_sel, MUX_CPLD_CAN_UART);
  268. }
  269. #ifndef CONFIG_SPIFLASH
  270. if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "tdm")) {
  271. printf("TDM");
  272. clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_CAN2_UART |
  273. MPC85xx_PMUXCR_CAN1_UART);
  274. setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_CAN2_TDM |
  275. MPC85xx_PMUXCR_CAN1_TDM);
  276. clrbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_GPIO);
  277. setbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_TDM);
  278. out_8(&cpld_data->tdm_can_sel, MUX_CPLD_TDM);
  279. out_8(&cpld_data->spi_cs0_sel, MUX_CPLD_SPICS0_SLIC);
  280. }
  281. #endif
  282. return 0;
  283. }
  284. #endif