atum8548.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*
  2. * Copyright 2007
  3. * Robert Lazarski, Instituto Atlantico, robertlazarski@gmail.com
  4. *
  5. * Copyright 2007 Freescale Semiconductor, Inc.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <command.h>
  27. #include <pci.h>
  28. #include <asm/processor.h>
  29. #include <asm/immap_85xx.h>
  30. #include <asm/fsl_pci.h>
  31. #include <asm/fsl_ddr_sdram.h>
  32. #include <asm/io.h>
  33. #include <asm/mmu.h>
  34. #include <spd_sdram.h>
  35. #include <miiphy.h>
  36. #include <libfdt.h>
  37. #include <fdt_support.h>
  38. long int fixed_sdram(void);
  39. int board_early_init_f (void)
  40. {
  41. return 0;
  42. }
  43. int checkboard (void)
  44. {
  45. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  46. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  47. volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
  48. if ((uint)&gur->porpllsr != 0xe00e0000) {
  49. printf("immap size error %lx\n",(ulong)&gur->porpllsr);
  50. }
  51. printf ("Board: ATUM8548\n");
  52. lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
  53. lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
  54. ecm->eedr = 0xffffffff; /* Clear ecm errors */
  55. ecm->eeer = 0xffffffff; /* Enable ecm errors */
  56. return 0;
  57. }
  58. #if !defined(CONFIG_SPD_EEPROM)
  59. /*************************************************************************
  60. * fixed sdram init -- doesn't use serial presence detect.
  61. ************************************************************************/
  62. long int fixed_sdram (void)
  63. {
  64. volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
  65. ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
  66. ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
  67. ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  68. ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  69. ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  70. ddr->sdram_mode = CONFIG_SYS_DDR_MODE;
  71. ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  72. #if defined (CONFIG_DDR_ECC)
  73. ddr->err_disable = 0x0000000D;
  74. ddr->err_sbe = 0x00ff0000;
  75. #endif
  76. asm("sync;isync;msync");
  77. udelay(500);
  78. #if defined (CONFIG_DDR_ECC)
  79. /* Enable ECC checking */
  80. ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
  81. #else
  82. ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
  83. #endif
  84. asm("sync; isync; msync");
  85. udelay(500);
  86. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  87. }
  88. #endif /* !defined(CONFIG_SPD_EEPROM) */
  89. phys_size_t
  90. initdram(int board_type)
  91. {
  92. long dram_size = 0;
  93. puts("Initializing\n");
  94. #if defined(CONFIG_SPD_EEPROM)
  95. puts("fsl_ddr_sdram\n");
  96. dram_size = fsl_ddr_sdram();
  97. dram_size = setup_ddr_tlbs(dram_size / 0x100000);
  98. dram_size *= 0x100000;
  99. #else
  100. puts("fixed_sdram\n");
  101. dram_size = fixed_sdram ();
  102. #endif
  103. puts(" DDR: ");
  104. return dram_size;
  105. }
  106. #if defined(CONFIG_SYS_DRAM_TEST)
  107. int
  108. testdram(void)
  109. {
  110. uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
  111. uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
  112. uint *p;
  113. printf("Testing DRAM from 0x%08x to 0x%08x\n",
  114. CONFIG_SYS_MEMTEST_START,
  115. CONFIG_SYS_MEMTEST_END);
  116. printf("DRAM test phase 1:\n");
  117. for (p = pstart; p < pend; p++) {
  118. printf ("DRAM test attempting to write 0xaaaaaaaa at: %08x\n", (uint) p);
  119. *p = 0xaaaaaaaa;
  120. }
  121. for (p = pstart; p < pend; p++) {
  122. if (*p != 0xaaaaaaaa) {
  123. printf ("DRAM test fails at: %08x\n", (uint) p);
  124. return 1;
  125. }
  126. }
  127. printf("DRAM test phase 2:\n");
  128. for (p = pstart; p < pend; p++)
  129. *p = 0x55555555;
  130. for (p = pstart; p < pend; p++) {
  131. if (*p != 0x55555555) {
  132. printf ("DRAM test fails at: %08x\n", (uint) p);
  133. return 1;
  134. }
  135. }
  136. printf("DRAM test passed.\n");
  137. return 0;
  138. }
  139. #endif
  140. #ifdef CONFIG_PCI1
  141. static struct pci_controller pci1_hose;
  142. #endif
  143. #ifdef CONFIG_PCI2
  144. static struct pci_controller pci2_hose;
  145. #endif
  146. #ifdef CONFIG_PCIE1
  147. static struct pci_controller pcie1_hose;
  148. #endif
  149. void pci_init_board(void)
  150. {
  151. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  152. struct fsl_pci_info pci_info[3];
  153. u32 devdisr, pordevsr, io_sel;
  154. u32 porpllsr, pci_agent, pci_speed, pci_32, pci_arb, pci_clk_sel;
  155. int first_free_busno = 0;
  156. int num = 0;
  157. int pcie_ep, pcie_configured;
  158. devdisr = in_be32(&gur->devdisr);
  159. pordevsr = in_be32(&gur->pordevsr);
  160. porpllsr = in_be32(&gur->porpllsr);
  161. io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  162. debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
  163. /* explicitly set 'Clock out select register' to echo SYSCLK input to our CPLD */
  164. setbits_be32(&gur->clkocr, MPC85xx_ATUM_CLKOCR);
  165. if (io_sel & 1) {
  166. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS))
  167. printf (" eTSEC1 is in sgmii mode.\n");
  168. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS))
  169. printf (" eTSEC2 is in sgmii mode.\n");
  170. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS))
  171. printf (" eTSEC3 is in sgmii mode.\n");
  172. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII4_DIS))
  173. printf (" eTSEC4 is in sgmii mode.\n");
  174. }
  175. #ifdef CONFIG_PCIE1
  176. pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_1, io_sel);
  177. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  178. SET_STD_PCIE_INFO(pci_info[num], 1);
  179. pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs);
  180. #ifdef CONFIG_SYS_PCIE1_MEM_BUS2
  181. /* outbound memory */
  182. pci_set_region(&pcie1_hose.regions[0],
  183. CONFIG_SYS_PCIE1_MEM_BUS2,
  184. CONFIG_SYS_PCIE1_MEM_PHYS2,
  185. CONFIG_SYS_PCIE1_MEM_SIZE2,
  186. PCI_REGION_MEM);
  187. pcie1_hose.region_count = 1;
  188. #endif
  189. printf (" PCIE1 connected to Slot as %s (base addr %lx)\n",
  190. pcie_ep ? "Endpoint" : "Root Complex",
  191. pci_info[num].regs);
  192. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  193. &pcie1_hose, first_free_busno);
  194. } else {
  195. printf (" PCIE1: disabled\n");
  196. }
  197. puts("\n");
  198. #else
  199. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */
  200. #endif
  201. #ifdef CONFIG_PCI1
  202. pci_speed = 33333000; /*get_clock_freq (); PCI PSPEED in [4:5] */
  203. pci_32 = pordevsr & MPC85xx_PORDEVSR_PCI1_PCI32; /* PORDEVSR[15] */
  204. pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;
  205. pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD;
  206. if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
  207. SET_STD_PCI_INFO(pci_info[num], 1);
  208. pci_agent = fsl_setup_hose(&pci1_hose, pci_info[num].regs);
  209. printf ("\n PCI1: %d bit, %s MHz, %s, %s, %s (base address %lx)\n",
  210. (pci_32) ? 32 : 64,
  211. (pci_speed == 33333000) ? "33" :
  212. (pci_speed == 66666000) ? "66" : "unknown",
  213. pci_clk_sel ? "sync" : "async",
  214. pci_agent ? "agent" : "host",
  215. pci_arb ? "arbiter" : "external-arbiter",
  216. pci_info[num].regs);
  217. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  218. &pci1_hose, first_free_busno);
  219. } else {
  220. printf (" PCI: disabled\n");
  221. }
  222. puts("\n");
  223. #else
  224. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */
  225. #endif
  226. #ifdef CONFIG_PCI2
  227. if (!(devdisr & MPC85xx_DEVDISR_PCI2)) {
  228. SET_STD_PCI_INFO(pci_info[num], 2);
  229. pci_agent = fsl_setup_hose(&pci2_hose, pci_info[num].regs);
  230. puts (" PCI2\n");
  231. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  232. &pci1_hose, first_free_busno);
  233. } else {
  234. printf (" PCI2: disabled\n");
  235. }
  236. puts("\n");
  237. #else
  238. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI2); /* disable */
  239. #endif
  240. }
  241. int last_stage_init(void)
  242. {
  243. int ic = icache_status ();
  244. printf ("icache_status: %d\n", ic);
  245. return 0;
  246. }
  247. #if defined(CONFIG_OF_BOARD_SETUP)
  248. void ft_board_setup(void *blob, bd_t *bd)
  249. {
  250. ft_cpu_setup(blob, bd);
  251. FT_FSL_PCI_SETUP;
  252. }
  253. #endif