mpc8323erdb.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * Copyright (C) 2007 Freescale Semiconductor, Inc.
  3. *
  4. * Michael Barkowski <michael.barkowski@freescale.com>
  5. * Based on mpc832xmds file by Dave Liu <daveliu@freescale.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <common.h>
  12. #include <ioports.h>
  13. #include <mpc83xx.h>
  14. #include <i2c.h>
  15. #include <spd.h>
  16. #include <miiphy.h>
  17. #include <command.h>
  18. #include <libfdt.h>
  19. #include <libfdt_env.h>
  20. #if defined(CONFIG_PCI)
  21. #include <pci.h>
  22. #endif
  23. #if defined(CONFIG_SPD_EEPROM)
  24. #include <spd_sdram.h>
  25. #else
  26. #include <asm/mmu.h>
  27. #endif
  28. const qe_iop_conf_t qe_iop_conf_tab[] = {
  29. /* UCC3 */
  30. {1, 0, 1, 0, 1}, /* TxD0 */
  31. {1, 1, 1, 0, 1}, /* TxD1 */
  32. {1, 2, 1, 0, 1}, /* TxD2 */
  33. {1, 3, 1, 0, 1}, /* TxD3 */
  34. {1, 9, 1, 0, 1}, /* TxER */
  35. {1, 12, 1, 0, 1}, /* TxEN */
  36. {3, 24, 2, 0, 1}, /* TxCLK->CLK10 */
  37. {1, 4, 2, 0, 1}, /* RxD0 */
  38. {1, 5, 2, 0, 1}, /* RxD1 */
  39. {1, 6, 2, 0, 1}, /* RxD2 */
  40. {1, 7, 2, 0, 1}, /* RxD3 */
  41. {1, 8, 2, 0, 1}, /* RxER */
  42. {1, 10, 2, 0, 1}, /* RxDV */
  43. {0, 13, 2, 0, 1}, /* RxCLK->CLK9 */
  44. {1, 11, 2, 0, 1}, /* COL */
  45. {1, 13, 2, 0, 1}, /* CRS */
  46. /* UCC2 */
  47. {0, 18, 1, 0, 1}, /* TxD0 */
  48. {0, 19, 1, 0, 1}, /* TxD1 */
  49. {0, 20, 1, 0, 1}, /* TxD2 */
  50. {0, 21, 1, 0, 1}, /* TxD3 */
  51. {0, 27, 1, 0, 1}, /* TxER */
  52. {0, 30, 1, 0, 1}, /* TxEN */
  53. {3, 23, 2, 0, 1}, /* TxCLK->CLK3 */
  54. {0, 22, 2, 0, 1}, /* RxD0 */
  55. {0, 23, 2, 0, 1}, /* RxD1 */
  56. {0, 24, 2, 0, 1}, /* RxD2 */
  57. {0, 25, 2, 0, 1}, /* RxD3 */
  58. {0, 26, 1, 0, 1}, /* RxER */
  59. {0, 28, 2, 0, 1}, /* Rx_DV */
  60. {3, 21, 2, 0, 1}, /* RxCLK->CLK16 */
  61. {0, 29, 2, 0, 1}, /* COL */
  62. {0, 31, 2, 0, 1}, /* CRS */
  63. {3, 4, 3, 0, 2}, /* MDIO */
  64. {3, 5, 1, 0, 2}, /* MDC */
  65. {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
  66. };
  67. int board_early_init_f(void)
  68. {
  69. return 0;
  70. }
  71. int fixed_sdram(void);
  72. long int initdram(int board_type)
  73. {
  74. volatile immap_t *im = (immap_t *) CFG_IMMR;
  75. u32 msize = 0;
  76. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
  77. return -1;
  78. /* DDR SDRAM - Main SODIMM */
  79. im->sysconf.ddrlaw[0].bar = CFG_DDR_BASE & LAWBAR_BAR;
  80. msize = fixed_sdram();
  81. puts("\n DDR RAM: ");
  82. /* return total bus SDRAM size(bytes) -- DDR */
  83. return (msize * 1024 * 1024);
  84. }
  85. /*************************************************************************
  86. * fixed sdram init -- doesn't use serial presence detect.
  87. ************************************************************************/
  88. int fixed_sdram(void)
  89. {
  90. volatile immap_t *im = (immap_t *) CFG_IMMR;
  91. u32 msize = 0;
  92. u32 ddr_size;
  93. u32 ddr_size_log2;
  94. msize = CFG_DDR_SIZE;
  95. for (ddr_size = msize << 20, ddr_size_log2 = 0;
  96. (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
  97. if (ddr_size & 1) {
  98. return -1;
  99. }
  100. }
  101. im->sysconf.ddrlaw[0].ar =
  102. LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
  103. im->ddr.sdram_clk_cntl = CFG_DDR_CLK_CNTL;
  104. im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
  105. im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
  106. im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
  107. im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
  108. im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
  109. im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
  110. im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
  111. im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
  112. im->ddr.sdram_mode = CFG_DDR_MODE;
  113. im->ddr.sdram_mode2 = CFG_DDR_MODE2;
  114. im->ddr.sdram_interval = CFG_DDR_INTERVAL;
  115. __asm__ __volatile__ ("sync");
  116. udelay(200);
  117. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  118. __asm__ __volatile__ ("sync");
  119. return msize;
  120. }
  121. int checkboard(void)
  122. {
  123. puts("Board: Freescale MPC8323ERDB\n");
  124. return 0;
  125. }
  126. static struct pci_region pci_regions[] = {
  127. {
  128. bus_start: CFG_PCI1_MEM_BASE,
  129. phys_start: CFG_PCI1_MEM_PHYS,
  130. size: CFG_PCI1_MEM_SIZE,
  131. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  132. },
  133. {
  134. bus_start: CFG_PCI1_MMIO_BASE,
  135. phys_start: CFG_PCI1_MMIO_PHYS,
  136. size: CFG_PCI1_MMIO_SIZE,
  137. flags: PCI_REGION_MEM
  138. },
  139. {
  140. bus_start: CFG_PCI1_IO_BASE,
  141. phys_start: CFG_PCI1_IO_PHYS,
  142. size: CFG_PCI1_IO_SIZE,
  143. flags: PCI_REGION_IO
  144. }
  145. };
  146. void pci_init_board(void)
  147. {
  148. volatile immap_t *immr = (volatile immap_t *)CFG_IMMR;
  149. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  150. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  151. struct pci_region *reg[] = { pci_regions };
  152. /* Enable all 3 PCI_CLK_OUTPUTs. */
  153. clk->occr |= 0xe0000000;
  154. /* Configure PCI Local Access Windows */
  155. pci_law[0].bar = CFG_PCI1_MEM_PHYS & LAWBAR_BAR;
  156. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  157. pci_law[1].bar = CFG_PCI1_IO_PHYS & LAWBAR_BAR;
  158. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  159. mpc83xx_pci_init(1, reg, 0);
  160. }
  161. #if defined(CONFIG_OF_BOARD_SETUP)
  162. /*
  163. * Prototypes of functions that we use.
  164. */
  165. void ft_cpu_setup(void *blob, bd_t *bd);
  166. #ifdef CONFIG_PCI
  167. void ft_pci_setup(void *blob, bd_t *bd);
  168. #endif
  169. void
  170. ft_board_setup(void *blob, bd_t *bd)
  171. {
  172. int nodeoffset;
  173. int tmp[2];
  174. nodeoffset = fdt_find_node_by_path(blob, "/memory");
  175. if (nodeoffset >= 0) {
  176. tmp[0] = cpu_to_be32(bd->bi_memstart);
  177. tmp[1] = cpu_to_be32(bd->bi_memsize);
  178. fdt_setprop(blob, nodeoffset, "reg", tmp, sizeof(tmp));
  179. }
  180. ft_cpu_setup(blob, bd);
  181. #ifdef CONFIG_PCI
  182. ft_pci_setup(blob, bd);
  183. #endif
  184. }
  185. #endif /* CONFIG_OF_BOARD_SETUP */