simpc8313.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. int checkboard(void)
  34. {
  35. puts("Board: Sheldon Instruments SIMPC8313\n");
  36. return 0;
  37. }
  38. #ifndef CONFIG_NAND_SPL
  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. int warmboot;
  66. /* Enable all 3 PCI_CLK_OUTPUTs. */
  67. clk->occr |= 0xe0000000;
  68. /*
  69. * Configure PCI Local Access Windows
  70. */
  71. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  72. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  73. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  74. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  75. warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM;
  76. mpc83xx_pci_init(1, reg, warmboot);
  77. }
  78. /*
  79. * Miscellaneous late-boot configurations
  80. */
  81. int misc_init_r(void)
  82. {
  83. int rc = 0;
  84. immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  85. fsl_lbus_t *lbus = &immap->lbus;
  86. u32 *mxmr = &lbus->mamr; /* Pointer to mamr */
  87. /* UPM Table Configuration Code */
  88. static uint UPMATable[] = {
  89. /* Read Single-Beat (RSS) */
  90. 0x0fff0c00, 0x0fffdc00, 0x0fff0c05, 0xfffffc00,
  91. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  92. /* Read Burst (RBS) */
  93. 0x0fff0c00, 0x0ffcdc00, 0x0ffc0c00, 0x0ffc0f0c,
  94. 0x0ffccf0c, 0x0ffc0f0c, 0x0ffcce0c, 0x3ffc0c05,
  95. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
  96. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  97. /* Write Single-Beat (WSS) */
  98. 0x0ffc0c00, 0x0ffcdc00, 0x0ffc0c05, 0xfffffc00,
  99. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  100. /* Write Burst (WBS) */
  101. 0x0ffc0c00, 0x0fffcc0c, 0x0fff0c00, 0x0fffcc00,
  102. 0x0fff1c00, 0x0fffcf0c, 0x0fff0f0c, 0x0fffcf0c,
  103. 0x0fff0c0c, 0x0fffcc0c, 0x0fff0c05, 0xfffffc00,
  104. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  105. /* Refresh Timer (RTS) */
  106. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
  107. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
  108. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
  109. /* Exception Condition (EXS) */
  110. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01
  111. };
  112. upmconfig(UPMA, UPMATable, sizeof(UPMATable) / sizeof(UPMATable[0]));
  113. /* Set LUPWAIT to be active low and enabled */
  114. out_be32(mxmr, MxMR_UWPL | MxMR_GPL_x4DIS);
  115. return rc;
  116. }
  117. #if defined(CONFIG_OF_BOARD_SETUP)
  118. void ft_board_setup(void *blob, bd_t *bd)
  119. {
  120. ft_cpu_setup(blob, bd);
  121. #ifdef CONFIG_PCI
  122. ft_pci_setup(blob, bd);
  123. #endif
  124. }
  125. #endif
  126. #else /* CONFIG_NAND_SPL */
  127. void board_init_f(ulong bootflag)
  128. {
  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