socrates.c 5.5 KB

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