socrates.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. #include <libfdt.h>
  36. #include <fdt_support.h>
  37. DECLARE_GLOBAL_DATA_PTR;
  38. extern flash_info_t flash_info[]; /* FLASH chips info */
  39. void local_bus_init (void);
  40. ulong flash_get_size (ulong base, int banknum);
  41. int checkboard (void)
  42. {
  43. char *s = getenv("serial#");
  44. puts("Board: Socrates");
  45. if (s != NULL) {
  46. puts(", serial# ");
  47. puts(s);
  48. }
  49. putc('\n');
  50. #ifdef CONFIG_PCI
  51. printf ("PCI1: 32 bit, %d MHz (compiled)\n",
  52. CONFIG_SYS_CLK_FREQ / 1000000);
  53. #else
  54. printf ("PCI1: disabled\n");
  55. #endif
  56. /*
  57. * Initialize local bus.
  58. */
  59. local_bus_init ();
  60. return 0;
  61. }
  62. int misc_init_r (void)
  63. {
  64. volatile ccsr_lbc_t *memctl = (void *)(CFG_MPC85xx_LBC_ADDR);
  65. /*
  66. * Adjust flash start and offset to detected values
  67. */
  68. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  69. gd->bd->bi_flashoffset = 0;
  70. /*
  71. * Check if boot FLASH isn't max size
  72. */
  73. if (gd->bd->bi_flashsize < (0 - CFG_FLASH0)) {
  74. memctl->or0 = gd->bd->bi_flashstart | (CFG_OR0_PRELIM & 0x00007fff);
  75. memctl->br0 = gd->bd->bi_flashstart | (CFG_BR0_PRELIM & 0x00007fff);
  76. /*
  77. * Re-check to get correct base address
  78. */
  79. flash_get_size(gd->bd->bi_flashstart, CFG_MAX_FLASH_BANKS - 1);
  80. }
  81. /*
  82. * Check if only one FLASH bank is available
  83. */
  84. if (gd->bd->bi_flashsize != CFG_MAX_FLASH_BANKS * (0 - CFG_FLASH0)) {
  85. memctl->or1 = 0;
  86. memctl->br1 = 0;
  87. /*
  88. * Re-do flash protection upon new addresses
  89. */
  90. flash_protect (FLAG_PROTECT_CLEAR,
  91. gd->bd->bi_flashstart, 0xffffffff,
  92. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  93. /* Monitor protection ON by default */
  94. flash_protect (FLAG_PROTECT_SET,
  95. CFG_MONITOR_BASE, CFG_MONITOR_BASE + monitor_flash_len - 1,
  96. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  97. /* Environment protection ON by default */
  98. flash_protect (FLAG_PROTECT_SET,
  99. CFG_ENV_ADDR,
  100. CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
  101. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  102. /* Redundant environment protection ON by default */
  103. flash_protect (FLAG_PROTECT_SET,
  104. CFG_ENV_ADDR_REDUND,
  105. CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
  106. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  107. }
  108. return 0;
  109. }
  110. /*
  111. * Initialize Local Bus
  112. */
  113. void local_bus_init (void)
  114. {
  115. volatile ccsr_lbc_t *lbc = (void *)(CFG_MPC85xx_LBC_ADDR);
  116. volatile ccsr_local_ecm_t *ecm = (void *)(CFG_MPC85xx_ECM_ADDR);
  117. lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
  118. lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
  119. ecm->eedr = 0xffffffff; /* Clear ecm errors */
  120. ecm->eeer = 0xffffffff; /* Enable ecm errors */
  121. }
  122. #if defined(CONFIG_PCI)
  123. /*
  124. * Initialize PCI Devices, report devices found.
  125. */
  126. #ifndef CONFIG_PCI_PNP
  127. static struct pci_config_table pci_mpc85xxads_config_table[] = {
  128. {PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  129. PCI_IDSEL_NUMBER, PCI_ANY_ID,
  130. pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
  131. PCI_ENET0_MEMADDR,
  132. PCI_COMMAND_MEMORY |
  133. PCI_COMMAND_MASTER}},
  134. {}
  135. };
  136. #endif
  137. static struct pci_controller hose = {
  138. #ifndef CONFIG_PCI_PNP
  139. config_table:pci_mpc85xxads_config_table,
  140. #endif
  141. };
  142. #endif /* CONFIG_PCI */
  143. void pci_init_board (void)
  144. {
  145. #ifdef CONFIG_PCI
  146. pci_mpc85xx_init (&hose);
  147. #endif /* CONFIG_PCI */
  148. }
  149. #ifdef CONFIG_BOARD_EARLY_INIT_R
  150. int board_early_init_r (void)
  151. {
  152. #ifdef CONFIG_PS2MULT
  153. ps2mult_early_init();
  154. #endif /* CONFIG_PS2MULT */
  155. return (0);
  156. }
  157. #endif /* CONFIG_BOARD_EARLY_INIT_R */
  158. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  159. void
  160. ft_board_setup(void *blob, bd_t *bd)
  161. {
  162. u32 val[4];
  163. int rc;
  164. ft_cpu_setup(blob, bd);
  165. /* Fixup NOR mapping */
  166. val[0] = 0; /* chip select number */
  167. val[1] = 0; /* always 0 */
  168. val[2] = gd->bd->bi_flashstart;
  169. val[3] = gd->bd->bi_flashsize;
  170. rc = fdt_find_and_setprop(blob, "/localbus", "ranges",
  171. val, sizeof(val), 1);
  172. if (rc)
  173. printf("Unable to update property NOR mapping, err=%s\n",
  174. fdt_strerror(rc));
  175. }
  176. #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */