p1022ds.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * Copyright 2010 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 <asm/mp.h>
  27. #include <netdev.h>
  28. #include <i2c.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. printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  47. in_8(&pixis->id), in_8(&pixis->arch), in_8(&pixis->scver));
  48. sw = in_8(&PIXIS_SW(PIXIS_LBMAP_SWITCH));
  49. switch ((sw & PIXIS_LBMAP_MASK) >> 6) {
  50. case 0:
  51. printf ("vBank: %u\n", ((sw & 0x30) >> 4));
  52. break;
  53. case 1:
  54. printf ("NAND\n");
  55. break;
  56. case 2:
  57. case 3:
  58. puts ("Promjet\n");
  59. break;
  60. }
  61. return 0;
  62. }
  63. phys_size_t initdram(int board_type)
  64. {
  65. phys_size_t dram_size = 0;
  66. puts("Initializing....\n");
  67. dram_size = fsl_ddr_sdram();
  68. dram_size = setup_ddr_tlbs(dram_size / 0x100000) * 0x100000;
  69. puts(" DDR: ");
  70. return dram_size;
  71. }
  72. #define CONFIG_TFP410_I2C_ADDR 0x38
  73. int misc_init_r(void)
  74. {
  75. u8 temp;
  76. /* Enable the TFP410 Encoder */
  77. temp = 0xBF;
  78. if (i2c_write(CONFIG_TFP410_I2C_ADDR, 0x08, 1, &temp, sizeof(temp)) < 0)
  79. return -1;
  80. /* Verify if enabled */
  81. temp = 0;
  82. if (i2c_read(CONFIG_TFP410_I2C_ADDR, 0x08, 1, &temp, sizeof(temp)) < 0)
  83. return -1;
  84. debug("DVI Encoder Read: 0x%02x\n", temp);
  85. temp = 0x10;
  86. if (i2c_write(CONFIG_TFP410_I2C_ADDR, 0x0A, 1, &temp, sizeof(temp)) < 0)
  87. return -1;
  88. /* Verify if enabled */
  89. temp = 0;
  90. if (i2c_read(CONFIG_TFP410_I2C_ADDR, 0x0A, 1, &temp, sizeof(temp)) < 0)
  91. return -1;
  92. debug("DVI Encoder Read: 0x%02x\n",temp);
  93. return 0;
  94. }
  95. static void configure_pcie(struct fsl_pci_info *info,
  96. struct pci_controller *hose,
  97. const char *connected)
  98. {
  99. static int bus_number = 0;
  100. int is_endpoint;
  101. set_next_law(info->mem_phys, law_size_bits(info->mem_size), info->law);
  102. set_next_law(info->io_phys, law_size_bits(info->io_size), info->law);
  103. is_endpoint = fsl_setup_hose(hose, info->regs);
  104. printf(" PCIE%u connected to %s as %s (base addr %lx)\n",
  105. info->pci_num, connected,
  106. is_endpoint ? "Endpoint" : "Root Complex", info->regs);
  107. bus_number = fsl_pci_init_port(info, hose, bus_number);
  108. }
  109. #ifdef CONFIG_PCIE1
  110. static struct pci_controller pcie1_hose;
  111. #endif
  112. #ifdef CONFIG_PCIE2
  113. static struct pci_controller pcie2_hose;
  114. #endif
  115. #ifdef CONFIG_PCIE3
  116. static struct pci_controller pcie3_hose;
  117. #endif
  118. #ifdef CONFIG_PCI
  119. void pci_init_board(void)
  120. {
  121. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  122. struct fsl_pci_info pci_info;
  123. u32 devdisr = in_be32(&gur->devdisr);
  124. #ifdef CONFIG_PCIE1
  125. if (is_serdes_configured(PCIE1) && !(devdisr & MPC85xx_DEVDISR_PCIE)) {
  126. SET_STD_PCIE_INFO(pci_info, 1);
  127. configure_pcie(&pci_info, &pcie1_hose, serdes_slot_name(PCIE1));
  128. } else {
  129. printf(" PCIE1: disabled\n");
  130. }
  131. #else
  132. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */
  133. #endif
  134. #ifdef CONFIG_PCIE2
  135. if (is_serdes_configured(PCIE2) && !(devdisr & MPC85xx_DEVDISR_PCIE2)) {
  136. SET_STD_PCIE_INFO(pci_info, 2);
  137. configure_pcie(&pci_info, &pcie2_hose, serdes_slot_name(PCIE2));
  138. } else {
  139. printf(" PCIE2: disabled\n");
  140. }
  141. #else
  142. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE2); /* disable */
  143. #endif
  144. #ifdef CONFIG_PCIE3
  145. if (is_serdes_configured(PCIE3) && !(devdisr & MPC85xx_DEVDISR_PCIE3)) {
  146. SET_STD_PCIE_INFO(pci_info, 3);
  147. configure_pcie(&pci_info, &pcie3_hose, serdes_slot_name(PCIE3));
  148. } else {
  149. printf(" PCIE3: disabled\n");
  150. }
  151. #else
  152. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE3); /* disable */
  153. #endif
  154. }
  155. #endif
  156. int board_early_init_r(void)
  157. {
  158. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  159. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  160. /*
  161. * Remap Boot flash + PROMJET region to caching-inhibited
  162. * so that flash can be erased properly.
  163. */
  164. /* Flush d-cache and invalidate i-cache of any FLASH data */
  165. flush_dcache();
  166. invalidate_icache();
  167. /* invalidate existing TLB entry for flash + promjet */
  168. disable_tlb(flash_esel);
  169. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  170. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  171. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  172. return 0;
  173. }
  174. /*
  175. * Initialize on-board and/or PCI Ethernet devices
  176. *
  177. * Returns:
  178. * <0, error
  179. * 0, no ethernet devices found
  180. * >0, number of ethernet devices initialized
  181. */
  182. int board_eth_init(bd_t *bis)
  183. {
  184. struct tsec_info_struct tsec_info[2];
  185. unsigned int num = 0;
  186. #ifdef CONFIG_TSEC1
  187. SET_STD_TSEC_INFO(tsec_info[num], 1);
  188. num++;
  189. #endif
  190. #ifdef CONFIG_TSEC2
  191. SET_STD_TSEC_INFO(tsec_info[num], 2);
  192. num++;
  193. #endif
  194. return tsec_eth_init(bis, tsec_info, num) + pci_eth_init(bis);
  195. }
  196. #ifdef CONFIG_OF_BOARD_SETUP
  197. void ft_board_setup(void *blob, bd_t *bd)
  198. {
  199. phys_addr_t base;
  200. phys_size_t size;
  201. ft_cpu_setup(blob, bd);
  202. base = getenv_bootm_low();
  203. size = getenv_bootm_size();
  204. fdt_fixup_memory(blob, (u64)base, (u64)size);
  205. #ifdef CONFIG_PCIE1
  206. ft_fsl_pci_setup(blob, "pci0", &pcie1_hose);
  207. #else
  208. ft_fsl_pci_setup(blob, "pci0", NULL);
  209. #endif
  210. #ifdef CONFIG_PCIE2
  211. ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
  212. #else
  213. ft_fsl_pci_setup(blob, "pci1", NULL);
  214. #endif
  215. #ifdef CONFIG_PCIE3
  216. ft_fsl_pci_setup(blob, "pci2", &pcie3_hose);
  217. #else
  218. ft_fsl_pci_setup(blob, "pci2", NULL);
  219. #endif
  220. #ifdef CONFIG_FSL_SGMII_RISER
  221. fsl_sgmii_riser_fdt_fixup(blob);
  222. #endif
  223. }
  224. #endif
  225. #ifdef CONFIG_MP
  226. void board_lmb_reserve(struct lmb *lmb)
  227. {
  228. cpu_mp_lmb_reserve(lmb);
  229. }
  230. #endif