socrates.c 5.3 KB

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