simpc8313.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (C) Freescale Semiconductor, Inc. 2006-2007
  3. * Copyright (C) Sheldon Instruments, Inc. 2008
  4. *
  5. * Author: Ron Madrid <info@sheldoninst.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 <libfdt.h>
  27. #include <pci.h>
  28. #include <mpc83xx.h>
  29. #include <ns16550.h>
  30. #include <nand.h>
  31. #include <asm/io.h>
  32. DECLARE_GLOBAL_DATA_PTR;
  33. #ifndef CONFIG_NAND_SPL
  34. int checkboard(void)
  35. {
  36. puts("Board: Sheldon Instruments SIMPC8313\n");
  37. return 0;
  38. }
  39. static struct pci_region pci_regions[] = {
  40. {
  41. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  42. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  43. size: CONFIG_SYS_PCI1_MEM_SIZE,
  44. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  45. },
  46. {
  47. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  48. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  49. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  50. flags: PCI_REGION_MEM
  51. },
  52. {
  53. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  54. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  55. size: CONFIG_SYS_PCI1_IO_SIZE,
  56. flags: PCI_REGION_IO
  57. }
  58. };
  59. void pci_init_board(void)
  60. {
  61. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  62. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  63. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  64. struct pci_region *reg[] = { pci_regions };
  65. /* Enable all 3 PCI_CLK_OUTPUTs. */
  66. clk->occr |= 0xe0000000;
  67. /*
  68. * Configure PCI Local Access Windows
  69. */
  70. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  71. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  72. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  73. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  74. mpc83xx_pci_init(1, reg);
  75. }
  76. /*
  77. * Miscellaneous late-boot configurations
  78. */
  79. int misc_init_r(void)
  80. {
  81. int rc = 0;
  82. immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  83. fsl_lbc_t *lbus = &immap->im_lbc;
  84. u32 *mxmr = &lbus->mamr; /* Pointer to mamr */
  85. /* UPM Table Configuration Code */
  86. static uint UPMATable[] = {
  87. /* Read Single-Beat (RSS) */
  88. 0x0fff0c00, 0x0fffdc00, 0x0fff0c05, 0xfffffc00,
  89. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  90. /* Read Burst (RBS) */
  91. 0x0fff0c00, 0x0ffcdc00, 0x0ffc0c00, 0x0ffc0f0c,
  92. 0x0ffccf0c, 0x0ffc0f0c, 0x0ffcce0c, 0x3ffc0c05,
  93. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
  94. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  95. /* Write Single-Beat (WSS) */
  96. 0x0ffc0c00, 0x0ffcdc00, 0x0ffc0c05, 0xfffffc00,
  97. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  98. /* Write Burst (WBS) */
  99. 0x0ffc0c00, 0x0fffcc0c, 0x0fff0c00, 0x0fffcc00,
  100. 0x0fff1c00, 0x0fffcf0c, 0x0fff0f0c, 0x0fffcf0c,
  101. 0x0fff0c0c, 0x0fffcc0c, 0x0fff0c05, 0xfffffc00,
  102. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  103. /* Refresh Timer (RTS) */
  104. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
  105. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
  106. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  107. /* Exception Condition (EXS) */
  108. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01
  109. };
  110. upmconfig(UPMA, UPMATable, sizeof(UPMATable) / sizeof(UPMATable[0]));
  111. /* Set LUPWAIT to be active low and enabled */
  112. out_be32(mxmr, MxMR_UWPL | MxMR_GPL_x4DIS);
  113. return rc;
  114. }
  115. #if defined(CONFIG_OF_BOARD_SETUP)
  116. void ft_board_setup(void *blob, bd_t *bd)
  117. {
  118. ft_cpu_setup(blob, bd);
  119. #ifdef CONFIG_PCI
  120. ft_pci_setup(blob, bd);
  121. #endif
  122. }
  123. #endif
  124. #else /* CONFIG_NAND_SPL */
  125. void board_init_f(ulong bootflag)
  126. {
  127. NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
  128. CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
  129. puts("NAND boot... ");
  130. init_timebase();
  131. initdram(0);
  132. relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, (gd_t *)gd,
  133. CONFIG_SYS_NAND_U_BOOT_RELOC);
  134. }
  135. void board_init_r(gd_t *gd, ulong dest_addr)
  136. {
  137. nand_boot();
  138. }
  139. void putc(char c)
  140. {
  141. if (gd->flags & GD_FLG_SILENT)
  142. return;
  143. if (c == '\n')
  144. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
  145. NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
  146. }
  147. #endif