socrates.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * (C) Copyright 2008
  3. * Sergei Poselenov, Emcraft Systems, sposelenov@emcraft.com.
  4. *
  5. * Copyright 2004 Freescale Semiconductor.
  6. * (C) Copyright 2002,2003, Motorola Inc.
  7. * Xianghua Xiao, (X.Xiao@motorola.com)
  8. *
  9. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. #include <common.h>
  30. #include <pci.h>
  31. #include <asm/processor.h>
  32. #include <asm/immap_85xx.h>
  33. #include <ioports.h>
  34. #include <flash.h>
  35. DECLARE_GLOBAL_DATA_PTR;
  36. extern flash_info_t flash_info[]; /* FLASH chips info */
  37. void local_bus_init (void);
  38. ulong flash_get_size (ulong base, int banknum);
  39. int checkboard (void)
  40. {
  41. char *s = getenv("serial#");
  42. puts("Board: Socrates");
  43. if (s != NULL) {
  44. puts(", serial# ");
  45. puts(s);
  46. }
  47. putc('\n');
  48. #ifdef CONFIG_PCI
  49. printf ("PCI1: 32 bit, %d MHz (compiled)\n",
  50. CONFIG_SYS_CLK_FREQ / 1000000);
  51. #else
  52. printf ("PCI1: disabled\n");
  53. #endif
  54. /*
  55. * Initialize local bus.
  56. */
  57. local_bus_init ();
  58. return 0;
  59. }
  60. int misc_init_r (void)
  61. {
  62. volatile ccsr_lbc_t *memctl = (void *)(CFG_MPC85xx_LBC_ADDR);
  63. /*
  64. * Adjust flash start and offset to detected values
  65. */
  66. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  67. gd->bd->bi_flashoffset = 0;
  68. /*
  69. * Check if boot FLASH isn't max size
  70. */
  71. if (gd->bd->bi_flashsize < (0 - CFG_FLASH0)) {
  72. memctl->or0 = gd->bd->bi_flashstart | (CFG_OR0_PRELIM & 0x00007fff);
  73. memctl->br0 = gd->bd->bi_flashstart | (CFG_BR0_PRELIM & 0x00007fff);
  74. /*
  75. * Re-check to get correct base address
  76. */
  77. flash_get_size(gd->bd->bi_flashstart, CFG_MAX_FLASH_BANKS - 1);
  78. }
  79. /*
  80. * Check if only one FLASH bank is available
  81. */
  82. if (gd->bd->bi_flashsize != CFG_MAX_FLASH_BANKS * (0 - CFG_FLASH0)) {
  83. memctl->or1 = 0;
  84. memctl->br1 = 0;
  85. /*
  86. * Re-do flash protection upon new addresses
  87. */
  88. flash_protect (FLAG_PROTECT_CLEAR,
  89. gd->bd->bi_flashstart, 0xffffffff,
  90. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  91. /* Monitor protection ON by default */
  92. flash_protect (FLAG_PROTECT_SET,
  93. CFG_MONITOR_BASE, CFG_MONITOR_BASE + monitor_flash_len - 1,
  94. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  95. /* Environment protection ON by default */
  96. flash_protect (FLAG_PROTECT_SET,
  97. CFG_ENV_ADDR,
  98. CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
  99. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  100. /* Redundant environment protection ON by default */
  101. flash_protect (FLAG_PROTECT_SET,
  102. CFG_ENV_ADDR_REDUND,
  103. CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
  104. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  105. }
  106. return 0;
  107. }
  108. /*
  109. * Initialize Local Bus
  110. */
  111. void local_bus_init (void)
  112. {
  113. volatile ccsr_lbc_t *lbc = (void *)(CFG_MPC85xx_LBC_ADDR);
  114. volatile ccsr_local_ecm_t *ecm = (void *)(CFG_MPC85xx_ECM_ADDR);
  115. lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
  116. lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
  117. ecm->eedr = 0xffffffff; /* Clear ecm errors */
  118. ecm->eeer = 0xffffffff; /* Enable ecm errors */
  119. }
  120. #if defined(CONFIG_PCI)
  121. /*
  122. * Initialize PCI Devices, report devices found.
  123. */
  124. #ifndef CONFIG_PCI_PNP
  125. static struct pci_config_table pci_mpc85xxads_config_table[] = {
  126. {PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  127. PCI_IDSEL_NUMBER, PCI_ANY_ID,
  128. pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
  129. PCI_ENET0_MEMADDR,
  130. PCI_COMMAND_MEMORY |
  131. PCI_COMMAND_MASTER}},
  132. {}
  133. };
  134. #endif
  135. static struct pci_controller hose = {
  136. #ifndef CONFIG_PCI_PNP
  137. config_table:pci_mpc85xxads_config_table,
  138. #endif
  139. };
  140. #endif /* CONFIG_PCI */
  141. void pci_init_board (void)
  142. {
  143. #ifdef CONFIG_PCI
  144. pci_mpc85xx_init (&hose);
  145. #endif /* CONFIG_PCI */
  146. }
  147. #ifdef CONFIG_BOARD_EARLY_INIT_R
  148. int board_early_init_r (void)
  149. {
  150. #ifdef CONFIG_PS2MULT
  151. ps2mult_early_init();
  152. #endif /* CONFIG_PS2MULT */
  153. return (0);
  154. }
  155. #endif /* CONFIG_BOARD_EARLY_INIT_R */