mpc8313erdb.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (C) Freescale Semiconductor, Inc. 2006-2007
  3. *
  4. * Author: Scott Wood <scottwood@freescale.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #if defined(CONFIG_OF_LIBFDT)
  26. #include <libfdt.h>
  27. #endif
  28. #include <pci.h>
  29. #include <mpc83xx.h>
  30. #include <vsc7385.h>
  31. #include <ns16550.h>
  32. #include <nand.h>
  33. #if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_NAND_SPL)
  34. #include <asm/gpio.h>
  35. #endif
  36. DECLARE_GLOBAL_DATA_PTR;
  37. int board_early_init_f(void)
  38. {
  39. #ifndef CONFIG_SYS_8313ERDB_BROKEN_PMC
  40. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  41. if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
  42. gd->flags |= GD_FLG_SILENT;
  43. #endif
  44. #if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_NAND_SPL)
  45. mpc83xx_gpio_init_f();
  46. #endif
  47. return 0;
  48. }
  49. int board_early_init_r(void)
  50. {
  51. #if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_NAND_SPL)
  52. mpc83xx_gpio_init_r();
  53. #endif
  54. return 0;
  55. }
  56. int checkboard(void)
  57. {
  58. puts("Board: Freescale MPC8313ERDB\n");
  59. return 0;
  60. }
  61. #ifndef CONFIG_NAND_SPL
  62. static struct pci_region pci_regions[] = {
  63. {
  64. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  65. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  66. size: CONFIG_SYS_PCI1_MEM_SIZE,
  67. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  68. },
  69. {
  70. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  71. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  72. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  73. flags: PCI_REGION_MEM
  74. },
  75. {
  76. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  77. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  78. size: CONFIG_SYS_PCI1_IO_SIZE,
  79. flags: PCI_REGION_IO
  80. }
  81. };
  82. void pci_init_board(void)
  83. {
  84. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  85. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  86. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  87. struct pci_region *reg[] = { pci_regions };
  88. /* Enable all 3 PCI_CLK_OUTPUTs. */
  89. clk->occr |= 0xe0000000;
  90. /*
  91. * Configure PCI Local Access Windows
  92. */
  93. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  94. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  95. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  96. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  97. mpc83xx_pci_init(1, reg);
  98. }
  99. /*
  100. * Miscellaneous late-boot configurations
  101. *
  102. * If a VSC7385 microcode image is present, then upload it.
  103. */
  104. int misc_init_r(void)
  105. {
  106. int rc = 0;
  107. #ifdef CONFIG_VSC7385_IMAGE
  108. if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE,
  109. CONFIG_VSC7385_IMAGE_SIZE)) {
  110. puts("Failure uploading VSC7385 microcode.\n");
  111. rc = 1;
  112. }
  113. #endif
  114. return rc;
  115. }
  116. #if defined(CONFIG_OF_BOARD_SETUP)
  117. void ft_board_setup(void *blob, bd_t *bd)
  118. {
  119. ft_cpu_setup(blob, bd);
  120. #ifdef CONFIG_PCI
  121. ft_pci_setup(blob, bd);
  122. #endif
  123. }
  124. #endif
  125. #else /* CONFIG_NAND_SPL */
  126. void board_init_f(ulong bootflag)
  127. {
  128. board_early_init_f();
  129. NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
  130. CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
  131. puts("NAND boot... ");
  132. init_timebase();
  133. initdram(0);
  134. relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, (gd_t *)gd,
  135. CONFIG_SYS_NAND_U_BOOT_RELOC);
  136. }
  137. void board_init_r(gd_t *gd, ulong dest_addr)
  138. {
  139. nand_boot();
  140. }
  141. void putc(char c)
  142. {
  143. if (gd->flags & GD_FLG_SILENT)
  144. return;
  145. if (c == '\n')
  146. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
  147. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
  148. }
  149. #endif