eXalion.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /*
  2. * (C) Copyright 2000-2004
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2002
  6. * Torsten Demke, FORCE Computers GmbH. torsten.demke@fci.com
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <mpc824x.h>
  28. #include <asm/processor.h>
  29. #include <asm/io.h>
  30. #include <pci.h>
  31. #include <ide.h>
  32. #include <netdev.h>
  33. #include <timestamp.h>
  34. #include "piix_pci.h"
  35. #include "eXalion.h"
  36. int checkboard (void)
  37. {
  38. ulong busfreq = get_bus_freq (0);
  39. char buf[32];
  40. printf ("Board: eXalion MPC824x - CHRP (MAP B)\n");
  41. printf ("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
  42. printf ("Local Bus: %s MHz\n", strmhz (buf, busfreq));
  43. return 0;
  44. }
  45. int checkflash (void)
  46. {
  47. printf ("checkflash\n");
  48. flash_init ();
  49. return (0);
  50. }
  51. phys_size_t initdram (int board_type)
  52. {
  53. int i, cnt;
  54. volatile uchar *base = CONFIG_SYS_SDRAM_BASE;
  55. volatile ulong *addr;
  56. ulong save[32];
  57. ulong val, ret = 0;
  58. for (i = 0, cnt = (CONFIG_SYS_MAX_RAM_SIZE / sizeof (long)) >> 1; cnt > 0;
  59. cnt >>= 1) {
  60. addr = (volatile ulong *) base + cnt;
  61. save[i++] = *addr;
  62. *addr = ~cnt;
  63. }
  64. addr = (volatile ulong *) base;
  65. save[i] = *addr;
  66. *addr = 0;
  67. if (*addr != 0) {
  68. *addr = save[i];
  69. goto Done;
  70. }
  71. for (cnt = 1; cnt <= CONFIG_SYS_MAX_RAM_SIZE / sizeof (long); cnt <<= 1) {
  72. addr = (volatile ulong *) base + cnt;
  73. val = *addr;
  74. *addr = save[--i];
  75. if (val != ~cnt) {
  76. ulong new_bank0_end = cnt * sizeof (long) - 1;
  77. ulong mear1 = mpc824x_mpc107_getreg (MEAR1);
  78. ulong emear1 = mpc824x_mpc107_getreg (EMEAR1);
  79. mear1 = (mear1 & 0xFFFFFF00) |
  80. ((new_bank0_end & MICR_ADDR_MASK) >>
  81. MICR_ADDR_SHIFT);
  82. emear1 = (emear1 & 0xFFFFFF00) |
  83. ((new_bank0_end & MICR_ADDR_MASK) >>
  84. MICR_EADDR_SHIFT);
  85. mpc824x_mpc107_setreg (MEAR1, mear1);
  86. mpc824x_mpc107_setreg (EMEAR1, emear1);
  87. ret = cnt * sizeof (long);
  88. goto Done;
  89. }
  90. }
  91. ret = CONFIG_SYS_MAX_RAM_SIZE;
  92. Done:
  93. return ret;
  94. }
  95. int misc_init_r (void)
  96. {
  97. pci_dev_t bdf;
  98. u32 val32;
  99. u8 val8;
  100. puts ("ISA: ");
  101. bdf = pci_find_device (PIIX4_VENDOR_ID, PIIX4_ISA_DEV_ID, 0);
  102. if (bdf == -1) {
  103. puts ("Unable to find PIIX4 ISA bridge !\n");
  104. hang ();
  105. }
  106. /* set device for normal ISA instead EIO */
  107. pci_read_config_dword (bdf, PCI_CFG_PIIX4_GENCFG, &val32);
  108. val32 |= 0x00000001;
  109. pci_write_config_dword (bdf, PCI_CFG_PIIX4_GENCFG, val32);
  110. printf ("PIIX4 ISA bridge (%d,%d,%d)\n", PCI_BUS (bdf),
  111. PCI_DEV (bdf), PCI_FUNC (bdf));
  112. puts ("ISA: ");
  113. bdf = pci_find_device (PIIX4_VENDOR_ID, PIIX4_IDE_DEV_ID, 0);
  114. if (bdf == -1) {
  115. puts ("Unable to find PIIX4 IDE controller !\n");
  116. hang ();
  117. }
  118. /* Init BMIBA register */
  119. /* pci_read_config_dword(bdf, PCI_CFG_PIIX4_BMIBA, &val32); */
  120. /* val32 |= 0x1000; */
  121. /* pci_write_config_dword(bdf, PCI_CFG_PIIX4_BMIBA, val32); */
  122. /* Enable BUS master and IO access */
  123. val32 = PCI_COMMAND_MASTER | PCI_COMMAND_IO;
  124. pci_write_config_dword (bdf, PCI_COMMAND, val32);
  125. /* Set latency */
  126. pci_read_config_byte (bdf, PCI_LATENCY_TIMER, &val8);
  127. val8 = 0x40;
  128. pci_write_config_byte (bdf, PCI_LATENCY_TIMER, val8);
  129. /* Enable Primary ATA/IDE */
  130. pci_read_config_dword (bdf, PCI_CFG_PIIX4_IDETIM, &val32);
  131. /* val32 = 0xa307a307; */
  132. val32 = 0x00008000;
  133. pci_write_config_dword (bdf, PCI_CFG_PIIX4_IDETIM, val32);
  134. printf ("PIIX4 IDE controller (%d,%d,%d)\n", PCI_BUS (bdf),
  135. PCI_DEV (bdf), PCI_FUNC (bdf));
  136. /* Try to get FAT working... */
  137. /* fat_register_read(ide_read); */
  138. return (0);
  139. }
  140. /*
  141. * Show/Init PCI devices on the specified bus number.
  142. */
  143. void pci_eXalion_fixup_irq (struct pci_controller *hose, pci_dev_t dev)
  144. {
  145. unsigned char line;
  146. switch (PCI_DEV (dev)) {
  147. case 16:
  148. line = PCI_INT_A;
  149. break;
  150. case 17:
  151. line = PCI_INT_B;
  152. break;
  153. case 18:
  154. line = PCI_INT_C;
  155. break;
  156. case 19:
  157. line = PCI_INT_D;
  158. break;
  159. #if defined (CONFIG_MPC8245)
  160. case 20:
  161. line = PCI_INT_A;
  162. break;
  163. case 21:
  164. line = PCI_INT_B;
  165. break;
  166. case 22:
  167. line = PCI_INT_NA;
  168. break;
  169. #endif
  170. default:
  171. line = PCI_INT_A;
  172. break;
  173. }
  174. pci_hose_write_config_byte (hose, dev, PCI_INTERRUPT_LINE, line);
  175. }
  176. /*
  177. * Initialize PCI Devices, report devices found.
  178. */
  179. #ifndef CONFIG_PCI_PNP
  180. #if defined (CONFIG_MPC8240)
  181. static struct pci_config_table pci_eXalion_config_table[] = {
  182. {
  183. /* Intel 82559ER ethernet controller */
  184. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 18, 0x00,
  185. pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
  186. PCI_ENET0_MEMADDR,
  187. PCI_COMMAND_MEMORY |
  188. PCI_COMMAND_MASTER}},
  189. {
  190. /* Intel 82371AB PIIX4 PCI to ISA bridge */
  191. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 20, 0x00,
  192. pci_cfgfunc_config_device, {0,
  193. 0,
  194. PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
  195. {
  196. /* Intel 82371AB PIIX4 IDE controller */
  197. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 20, 0x01,
  198. pci_cfgfunc_config_device, {0,
  199. 0,
  200. PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
  201. {}
  202. };
  203. #elif defined (CONFIG_MPC8245)
  204. static struct pci_config_table pci_eXalion_config_table[] = {
  205. {
  206. /* Intel 82559ER ethernet controller */
  207. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 17, 0x00,
  208. pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
  209. PCI_ENET0_MEMADDR,
  210. PCI_COMMAND_MEMORY |
  211. PCI_COMMAND_MASTER}},
  212. {
  213. /* Intel 82559ER ethernet controller */
  214. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 18, 0x00,
  215. pci_cfgfunc_config_device, {PCI_ENET1_IOADDR,
  216. PCI_ENET1_MEMADDR,
  217. PCI_COMMAND_MEMORY |
  218. PCI_COMMAND_MASTER}},
  219. {
  220. /* Broadcom BCM5690 Gigabit switch */
  221. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 20, 0x00,
  222. pci_cfgfunc_config_device, {PCI_ENET2_IOADDR,
  223. PCI_ENET2_MEMADDR,
  224. PCI_COMMAND_MEMORY |
  225. PCI_COMMAND_MASTER}},
  226. {
  227. /* Broadcom BCM5690 Gigabit switch */
  228. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 21, 0x00,
  229. pci_cfgfunc_config_device, {PCI_ENET3_IOADDR,
  230. PCI_ENET3_MEMADDR,
  231. PCI_COMMAND_MEMORY |
  232. PCI_COMMAND_MASTER}},
  233. {
  234. /* Intel 82371AB PIIX4 PCI to ISA bridge */
  235. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 22, 0x00,
  236. pci_cfgfunc_config_device, {0,
  237. 0,
  238. PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
  239. {
  240. /* Intel 82371AB PIIX4 IDE controller */
  241. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 22, 0x01,
  242. pci_cfgfunc_config_device, {0,
  243. 0,
  244. PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
  245. {}
  246. };
  247. #else
  248. #error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240)
  249. #endif
  250. #endif /* #ifndef CONFIG_PCI_PNP */
  251. struct pci_controller hose = {
  252. #ifndef CONFIG_PCI_PNP
  253. config_table:pci_eXalion_config_table,
  254. fixup_irq:pci_eXalion_fixup_irq,
  255. #endif
  256. };
  257. void pci_init_board (void)
  258. {
  259. pci_mpc824x_init (&hose);
  260. }
  261. int board_eth_init(bd_t *bis)
  262. {
  263. return pci_eth_init(bis);
  264. }