mpc8313erdb.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. DECLARE_GLOBAL_DATA_PTR;
  34. int board_early_init_f(void)
  35. {
  36. #ifndef CONFIG_SYS_8313ERDB_BROKEN_PMC
  37. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  38. if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
  39. gd->flags |= GD_FLG_SILENT;
  40. #endif
  41. return 0;
  42. }
  43. int checkboard(void)
  44. {
  45. puts("Board: Freescale MPC8313ERDB\n");
  46. return 0;
  47. }
  48. #ifndef CONFIG_NAND_SPL
  49. static struct pci_region pci_regions[] = {
  50. {
  51. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  52. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  53. size: CONFIG_SYS_PCI1_MEM_SIZE,
  54. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  55. },
  56. {
  57. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  58. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  59. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  60. flags: PCI_REGION_MEM
  61. },
  62. {
  63. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  64. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  65. size: CONFIG_SYS_PCI1_IO_SIZE,
  66. flags: PCI_REGION_IO
  67. }
  68. };
  69. void pci_init_board(void)
  70. {
  71. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  72. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  73. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  74. struct pci_region *reg[] = { pci_regions };
  75. int warmboot;
  76. /* Enable all 3 PCI_CLK_OUTPUTs. */
  77. clk->occr |= 0xe0000000;
  78. /*
  79. * Configure PCI Local Access Windows
  80. */
  81. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  82. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  83. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  84. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  85. warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM;
  86. #ifndef CONFIG_SYS_8313ERDB_BROKEN_PMC
  87. warmboot |= immr->pmc.pmccr1 & PMCCR1_POWER_OFF;
  88. #endif
  89. mpc83xx_pci_init(1, reg, warmboot);
  90. }
  91. /*
  92. * Miscellaneous late-boot configurations
  93. *
  94. * If a VSC7385 microcode image is present, then upload it.
  95. */
  96. int misc_init_r(void)
  97. {
  98. int rc = 0;
  99. #ifdef CONFIG_VSC7385_IMAGE
  100. if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE,
  101. CONFIG_VSC7385_IMAGE_SIZE)) {
  102. puts("Failure uploading VSC7385 microcode.\n");
  103. rc = 1;
  104. }
  105. #endif
  106. return rc;
  107. }
  108. #if defined(CONFIG_OF_BOARD_SETUP)
  109. void ft_board_setup(void *blob, bd_t *bd)
  110. {
  111. ft_cpu_setup(blob, bd);
  112. #ifdef CONFIG_PCI
  113. ft_pci_setup(blob, bd);
  114. #endif
  115. }
  116. #endif
  117. #else /* CONFIG_NAND_SPL */
  118. void board_init_f(ulong bootflag)
  119. {
  120. board_early_init_f();
  121. NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
  122. CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
  123. puts("NAND boot... ");
  124. init_timebase();
  125. initdram(0);
  126. relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC + 0x10000, (gd_t *)gd,
  127. CONFIG_SYS_NAND_U_BOOT_RELOC);
  128. }
  129. void board_init_r(gd_t *gd, ulong dest_addr)
  130. {
  131. nand_boot();
  132. }
  133. void putc(char c)
  134. {
  135. if (gd->flags & GD_FLG_SILENT)
  136. return;
  137. if (c == '\n')
  138. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
  139. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
  140. }
  141. #endif