socrates.c 5.3 KB

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