mpc8315erdb.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*
  2. * Copyright (C) 2007 Freescale Semiconductor, Inc.
  3. *
  4. * Author: Scott Wood <scottwood@freescale.com>
  5. * Dave Liu <daveliu@freescale.com>
  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 <hwconfig.h>
  27. #include <i2c.h>
  28. #include <libfdt.h>
  29. #include <fdt_support.h>
  30. #include <pci.h>
  31. #include <mpc83xx.h>
  32. #include <netdev.h>
  33. #include <asm/io.h>
  34. #include <ns16550.h>
  35. #include <nand.h>
  36. DECLARE_GLOBAL_DATA_PTR;
  37. int board_early_init_f(void)
  38. {
  39. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  40. if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
  41. gd->flags |= GD_FLG_SILENT;
  42. return 0;
  43. }
  44. #ifndef CONFIG_NAND_SPL
  45. static u8 read_board_info(void)
  46. {
  47. u8 val8;
  48. i2c_set_bus_num(0);
  49. if (i2c_read(CONFIG_SYS_I2C_PCF8574A_ADDR, 0, 0, &val8, 1) == 0)
  50. return val8;
  51. else
  52. return 0;
  53. }
  54. int checkboard(void)
  55. {
  56. static const char * const rev_str[] = {
  57. "0.0",
  58. "0.1",
  59. "1.0",
  60. "1.1",
  61. "<unknown>",
  62. };
  63. u8 info;
  64. int i;
  65. info = read_board_info();
  66. i = (!info) ? 4: info & 0x03;
  67. printf("Board: Freescale MPC8315ERDB Rev %s\n", rev_str[i]);
  68. return 0;
  69. }
  70. static struct pci_region pci_regions[] = {
  71. {
  72. bus_start: CONFIG_SYS_PCI_MEM_BASE,
  73. phys_start: CONFIG_SYS_PCI_MEM_PHYS,
  74. size: CONFIG_SYS_PCI_MEM_SIZE,
  75. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  76. },
  77. {
  78. bus_start: CONFIG_SYS_PCI_MMIO_BASE,
  79. phys_start: CONFIG_SYS_PCI_MMIO_PHYS,
  80. size: CONFIG_SYS_PCI_MMIO_SIZE,
  81. flags: PCI_REGION_MEM
  82. },
  83. {
  84. bus_start: CONFIG_SYS_PCI_IO_BASE,
  85. phys_start: CONFIG_SYS_PCI_IO_PHYS,
  86. size: CONFIG_SYS_PCI_IO_SIZE,
  87. flags: PCI_REGION_IO
  88. }
  89. };
  90. static struct pci_region pcie_regions_0[] = {
  91. {
  92. .bus_start = CONFIG_SYS_PCIE1_MEM_BASE,
  93. .phys_start = CONFIG_SYS_PCIE1_MEM_PHYS,
  94. .size = CONFIG_SYS_PCIE1_MEM_SIZE,
  95. .flags = PCI_REGION_MEM,
  96. },
  97. {
  98. .bus_start = CONFIG_SYS_PCIE1_IO_BASE,
  99. .phys_start = CONFIG_SYS_PCIE1_IO_PHYS,
  100. .size = CONFIG_SYS_PCIE1_IO_SIZE,
  101. .flags = PCI_REGION_IO,
  102. },
  103. };
  104. static struct pci_region pcie_regions_1[] = {
  105. {
  106. .bus_start = CONFIG_SYS_PCIE2_MEM_BASE,
  107. .phys_start = CONFIG_SYS_PCIE2_MEM_PHYS,
  108. .size = CONFIG_SYS_PCIE2_MEM_SIZE,
  109. .flags = PCI_REGION_MEM,
  110. },
  111. {
  112. .bus_start = CONFIG_SYS_PCIE2_IO_BASE,
  113. .phys_start = CONFIG_SYS_PCIE2_IO_PHYS,
  114. .size = CONFIG_SYS_PCIE2_IO_SIZE,
  115. .flags = PCI_REGION_IO,
  116. },
  117. };
  118. void pci_init_board(void)
  119. {
  120. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  121. volatile sysconf83xx_t *sysconf = &immr->sysconf;
  122. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  123. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  124. volatile law83xx_t *pcie_law = sysconf->pcielaw;
  125. struct pci_region *reg[] = { pci_regions };
  126. struct pci_region *pcie_reg[] = { pcie_regions_0, pcie_regions_1, };
  127. /* Enable all 3 PCI_CLK_OUTPUTs. */
  128. clk->occr |= 0xe0000000;
  129. /*
  130. * Configure PCI Local Access Windows
  131. */
  132. pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
  133. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  134. pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
  135. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  136. mpc83xx_pci_init(1, reg);
  137. /* Configure the clock for PCIE controller */
  138. clrsetbits_be32(&clk->sccr, SCCR_PCIEXP1CM | SCCR_PCIEXP2CM,
  139. SCCR_PCIEXP1CM_1 | SCCR_PCIEXP2CM_1);
  140. /* Deassert the resets in the control register */
  141. out_be32(&sysconf->pecr1, 0xE0008000);
  142. out_be32(&sysconf->pecr2, 0xE0008000);
  143. udelay(2000);
  144. /* Configure PCI Express Local Access Windows */
  145. out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR);
  146. out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB);
  147. out_be32(&pcie_law[1].bar, CONFIG_SYS_PCIE2_BASE & LAWBAR_BAR);
  148. out_be32(&pcie_law[1].ar, LBLAWAR_EN | LBLAWAR_512MB);
  149. mpc83xx_pcie_init(2, pcie_reg);
  150. }
  151. #if defined(CONFIG_OF_BOARD_SETUP)
  152. void fdt_tsec1_fixup(void *fdt, bd_t *bd)
  153. {
  154. const char disabled[] = "disabled";
  155. const char *path;
  156. int ret;
  157. if (hwconfig_arg_cmp("board_type", "tsec1")) {
  158. return;
  159. } else if (!hwconfig_arg_cmp("board_type", "ulpi")) {
  160. printf("NOTICE: No or unknown board_type hwconfig specified.\n"
  161. " Assuming board with TSEC1.\n");
  162. return;
  163. }
  164. ret = fdt_path_offset(fdt, "/aliases");
  165. if (ret < 0) {
  166. printf("WARNING: can't find /aliases node\n");
  167. return;
  168. }
  169. path = fdt_getprop(fdt, ret, "ethernet0", NULL);
  170. if (!path) {
  171. printf("WARNING: can't find ethernet0 alias\n");
  172. return;
  173. }
  174. do_fixup_by_path(fdt, path, "status", disabled, sizeof(disabled), 1);
  175. }
  176. void ft_board_setup(void *blob, bd_t *bd)
  177. {
  178. ft_cpu_setup(blob, bd);
  179. #ifdef CONFIG_PCI
  180. ft_pci_setup(blob, bd);
  181. #endif
  182. fdt_fixup_dr_usb(blob, bd);
  183. fdt_tsec1_fixup(blob, bd);
  184. }
  185. #endif
  186. int board_eth_init(bd_t *bis)
  187. {
  188. cpu_eth_init(bis); /* Initialize TSECs first */
  189. return pci_eth_init(bis);
  190. }
  191. #else /* CONFIG_NAND_SPL */
  192. int checkboard(void)
  193. {
  194. puts("Board: Freescale MPC8315ERDB\n");
  195. return 0;
  196. }
  197. void board_init_f(ulong bootflag)
  198. {
  199. board_early_init_f();
  200. NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
  201. CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
  202. puts("NAND boot... ");
  203. init_timebase();
  204. initdram(0);
  205. relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC + 0x10000, (gd_t *)gd,
  206. CONFIG_SYS_NAND_U_BOOT_RELOC);
  207. }
  208. void board_init_r(gd_t *gd, ulong dest_addr)
  209. {
  210. nand_boot();
  211. }
  212. void putc(char c)
  213. {
  214. if (gd->flags & GD_FLG_SILENT)
  215. return;
  216. if (c == '\n')
  217. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
  218. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
  219. }
  220. #endif /* CONFIG_NAND_SPL */