mpc8313erdb.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) Freescale Semiconductor, Inc. 2006-2007
  4. *
  5. * Author: Scott Wood <scottwood@freescale.com>
  6. */
  7. #include <common.h>
  8. #if defined(CONFIG_OF_LIBFDT)
  9. #include <linux/libfdt.h>
  10. #endif
  11. #include <pci.h>
  12. #include <mpc83xx.h>
  13. #include <vsc7385.h>
  14. #include <ns16550.h>
  15. #include <nand.h>
  16. #if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
  17. #include <asm/gpio.h>
  18. #endif
  19. DECLARE_GLOBAL_DATA_PTR;
  20. int board_early_init_f(void)
  21. {
  22. #ifndef CONFIG_SYS_8313ERDB_BROKEN_PMC
  23. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  24. if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
  25. gd->flags |= GD_FLG_SILENT;
  26. #endif
  27. #if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
  28. mpc83xx_gpio_init_f();
  29. #endif
  30. return 0;
  31. }
  32. int board_early_init_r(void)
  33. {
  34. #if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
  35. mpc83xx_gpio_init_r();
  36. #endif
  37. return 0;
  38. }
  39. int checkboard(void)
  40. {
  41. puts("Board: Freescale MPC8313ERDB\n");
  42. return 0;
  43. }
  44. #ifndef CONFIG_SPL_BUILD
  45. static struct pci_region pci_regions[] = {
  46. {
  47. .bus_start = CONFIG_SYS_PCI1_MEM_BASE,
  48. .phys_start = CONFIG_SYS_PCI1_MEM_PHYS,
  49. .size = CONFIG_SYS_PCI1_MEM_SIZE,
  50. .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH
  51. },
  52. {
  53. .bus_start = CONFIG_SYS_PCI1_MMIO_BASE,
  54. .phys_start = CONFIG_SYS_PCI1_MMIO_PHYS,
  55. .size = CONFIG_SYS_PCI1_MMIO_SIZE,
  56. .flags = PCI_REGION_MEM
  57. },
  58. {
  59. .bus_start = CONFIG_SYS_PCI1_IO_BASE,
  60. .phys_start = CONFIG_SYS_PCI1_IO_PHYS,
  61. .size = CONFIG_SYS_PCI1_IO_SIZE,
  62. .flags = PCI_REGION_IO
  63. }
  64. };
  65. void pci_init_board(void)
  66. {
  67. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  68. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  69. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  70. struct pci_region *reg[] = { pci_regions };
  71. /* Enable all 3 PCI_CLK_OUTPUTs. */
  72. clk->occr |= 0xe0000000;
  73. /*
  74. * Configure PCI Local Access Windows
  75. */
  76. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  77. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  78. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  79. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  80. mpc83xx_pci_init(1, reg);
  81. }
  82. /*
  83. * Miscellaneous late-boot configurations
  84. *
  85. * If a VSC7385 microcode image is present, then upload it.
  86. */
  87. int misc_init_r(void)
  88. {
  89. int rc = 0;
  90. #ifdef CONFIG_VSC7385_IMAGE
  91. if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE,
  92. CONFIG_VSC7385_IMAGE_SIZE)) {
  93. puts("Failure uploading VSC7385 microcode.\n");
  94. rc = 1;
  95. }
  96. #endif
  97. return rc;
  98. }
  99. #if defined(CONFIG_OF_BOARD_SETUP)
  100. int ft_board_setup(void *blob, bd_t *bd)
  101. {
  102. ft_cpu_setup(blob, bd);
  103. #ifdef CONFIG_PCI
  104. ft_pci_setup(blob, bd);
  105. #endif
  106. return 0;
  107. }
  108. #endif
  109. #else /* CONFIG_SPL_BUILD */
  110. void board_init_f(ulong bootflag)
  111. {
  112. board_early_init_f();
  113. NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
  114. CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
  115. puts("NAND boot... ");
  116. timer_init();
  117. dram_init();
  118. relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, (gd_t *)gd,
  119. CONFIG_SYS_NAND_U_BOOT_RELOC);
  120. }
  121. void board_init_r(gd_t *gd, ulong dest_addr)
  122. {
  123. nand_boot();
  124. }
  125. void putc(char c)
  126. {
  127. if (gd->flags & GD_FLG_SILENT)
  128. return;
  129. if (c == '\n')
  130. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
  131. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
  132. }
  133. #endif