eXalion.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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 "piix_pci.h"
  34. #include "eXalion.h"
  35. int checkboard (void)
  36. {
  37. ulong busfreq = get_bus_freq (0);
  38. char buf[32];
  39. printf ("Board: eXalion MPC824x - CHRP (MAP B)\n");
  40. printf ("Built: %s at %s\n", __DATE__, __TIME__);
  41. printf ("Local Bus: %s MHz\n", strmhz (buf, busfreq));
  42. return 0;
  43. }
  44. int checkflash (void)
  45. {
  46. printf ("checkflash\n");
  47. flash_init ();
  48. return (0);
  49. }
  50. phys_size_t initdram (int board_type)
  51. {
  52. int i, cnt;
  53. volatile uchar *base = CFG_SDRAM_BASE;
  54. volatile ulong *addr;
  55. ulong save[32];
  56. ulong val, ret = 0;
  57. for (i = 0, cnt = (CFG_MAX_RAM_SIZE / sizeof (long)) >> 1; cnt > 0;
  58. cnt >>= 1) {
  59. addr = (volatile ulong *) base + cnt;
  60. save[i++] = *addr;
  61. *addr = ~cnt;
  62. }
  63. addr = (volatile ulong *) base;
  64. save[i] = *addr;
  65. *addr = 0;
  66. if (*addr != 0) {
  67. *addr = save[i];
  68. goto Done;
  69. }
  70. for (cnt = 1; cnt <= CFG_MAX_RAM_SIZE / sizeof (long); cnt <<= 1) {
  71. addr = (volatile ulong *) base + cnt;
  72. val = *addr;
  73. *addr = save[--i];
  74. if (val != ~cnt) {
  75. ulong new_bank0_end = cnt * sizeof (long) - 1;
  76. ulong mear1 = mpc824x_mpc107_getreg (MEAR1);
  77. ulong emear1 = mpc824x_mpc107_getreg (EMEAR1);
  78. mear1 = (mear1 & 0xFFFFFF00) |
  79. ((new_bank0_end & MICR_ADDR_MASK) >>
  80. MICR_ADDR_SHIFT);
  81. emear1 = (emear1 & 0xFFFFFF00) |
  82. ((new_bank0_end & MICR_ADDR_MASK) >>
  83. MICR_EADDR_SHIFT);
  84. mpc824x_mpc107_setreg (MEAR1, mear1);
  85. mpc824x_mpc107_setreg (EMEAR1, emear1);
  86. ret = cnt * sizeof (long);
  87. goto Done;
  88. }
  89. }
  90. ret = CFG_MAX_RAM_SIZE;
  91. Done:
  92. return ret;
  93. }
  94. int misc_init_r (void)
  95. {
  96. pci_dev_t bdf;
  97. u32 val32;
  98. u8 val8;
  99. puts ("ISA: ");
  100. bdf = pci_find_device (PIIX4_VENDOR_ID, PIIX4_ISA_DEV_ID, 0);
  101. if (bdf == -1) {
  102. puts ("Unable to find PIIX4 ISA bridge !\n");
  103. hang ();
  104. }
  105. /* set device for normal ISA instead EIO */
  106. pci_read_config_dword (bdf, PCI_CFG_PIIX4_GENCFG, &val32);
  107. val32 |= 0x00000001;
  108. pci_write_config_dword (bdf, PCI_CFG_PIIX4_GENCFG, val32);
  109. printf ("PIIX4 ISA bridge (%d,%d,%d)\n", PCI_BUS (bdf),
  110. PCI_DEV (bdf), PCI_FUNC (bdf));
  111. puts ("ISA: ");
  112. bdf = pci_find_device (PIIX4_VENDOR_ID, PIIX4_IDE_DEV_ID, 0);
  113. if (bdf == -1) {
  114. puts ("Unable to find PIIX4 IDE controller !\n");
  115. hang ();
  116. }
  117. /* Init BMIBA register */
  118. /* pci_read_config_dword(bdf, PCI_CFG_PIIX4_BMIBA, &val32); */
  119. /* val32 |= 0x1000; */
  120. /* pci_write_config_dword(bdf, PCI_CFG_PIIX4_BMIBA, val32); */
  121. /* Enable BUS master and IO access */
  122. val32 = PCI_COMMAND_MASTER | PCI_COMMAND_IO;
  123. pci_write_config_dword (bdf, PCI_COMMAND, val32);
  124. /* Set latency */
  125. pci_read_config_byte (bdf, PCI_LATENCY_TIMER, &val8);
  126. val8 = 0x40;
  127. pci_write_config_byte (bdf, PCI_LATENCY_TIMER, val8);
  128. /* Enable Primary ATA/IDE */
  129. pci_read_config_dword (bdf, PCI_CFG_PIIX4_IDETIM, &val32);
  130. /* val32 = 0xa307a307; */
  131. val32 = 0x00008000;
  132. pci_write_config_dword (bdf, PCI_CFG_PIIX4_IDETIM, val32);
  133. printf ("PIIX4 IDE controller (%d,%d,%d)\n", PCI_BUS (bdf),
  134. PCI_DEV (bdf), PCI_FUNC (bdf));
  135. /* Try to get FAT working... */
  136. /* fat_register_read(ide_read); */
  137. return (0);
  138. }
  139. /*
  140. * Show/Init PCI devices on the specified bus number.
  141. */
  142. void pci_eXalion_fixup_irq (struct pci_controller *hose, pci_dev_t dev)
  143. {
  144. unsigned char line;
  145. switch (PCI_DEV (dev)) {
  146. case 16:
  147. line = PCI_INT_A;
  148. break;
  149. case 17:
  150. line = PCI_INT_B;
  151. break;
  152. case 18:
  153. line = PCI_INT_C;
  154. break;
  155. case 19:
  156. line = PCI_INT_D;
  157. break;
  158. #if defined (CONFIG_MPC8245)
  159. case 20:
  160. line = PCI_INT_A;
  161. break;
  162. case 21:
  163. line = PCI_INT_B;
  164. break;
  165. case 22:
  166. line = PCI_INT_NA;
  167. break;
  168. #endif
  169. default:
  170. line = PCI_INT_A;
  171. break;
  172. }
  173. pci_hose_write_config_byte (hose, dev, PCI_INTERRUPT_LINE, line);
  174. }
  175. /*
  176. * Initialize PCI Devices, report devices found.
  177. */
  178. #ifndef CONFIG_PCI_PNP
  179. #if defined (CONFIG_MPC8240)
  180. static struct pci_config_table pci_eXalion_config_table[] = {
  181. {
  182. /* Intel 82559ER ethernet controller */
  183. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 18, 0x00,
  184. pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
  185. PCI_ENET0_MEMADDR,
  186. PCI_COMMAND_MEMORY |
  187. PCI_COMMAND_MASTER}},
  188. {
  189. /* Intel 82371AB PIIX4 PCI to ISA bridge */
  190. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 20, 0x00,
  191. pci_cfgfunc_config_device, {0,
  192. 0,
  193. PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
  194. {
  195. /* Intel 82371AB PIIX4 IDE controller */
  196. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 20, 0x01,
  197. pci_cfgfunc_config_device, {0,
  198. 0,
  199. PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
  200. {}
  201. };
  202. #elif defined (CONFIG_MPC8245)
  203. static struct pci_config_table pci_eXalion_config_table[] = {
  204. {
  205. /* Intel 82559ER ethernet controller */
  206. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 17, 0x00,
  207. pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
  208. PCI_ENET0_MEMADDR,
  209. PCI_COMMAND_MEMORY |
  210. PCI_COMMAND_MASTER}},
  211. {
  212. /* Intel 82559ER ethernet controller */
  213. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 18, 0x00,
  214. pci_cfgfunc_config_device, {PCI_ENET1_IOADDR,
  215. PCI_ENET1_MEMADDR,
  216. PCI_COMMAND_MEMORY |
  217. PCI_COMMAND_MASTER}},
  218. {
  219. /* Broadcom BCM5690 Gigabit switch */
  220. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 20, 0x00,
  221. pci_cfgfunc_config_device, {PCI_ENET2_IOADDR,
  222. PCI_ENET2_MEMADDR,
  223. PCI_COMMAND_MEMORY |
  224. PCI_COMMAND_MASTER}},
  225. {
  226. /* Broadcom BCM5690 Gigabit switch */
  227. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 21, 0x00,
  228. pci_cfgfunc_config_device, {PCI_ENET3_IOADDR,
  229. PCI_ENET3_MEMADDR,
  230. PCI_COMMAND_MEMORY |
  231. PCI_COMMAND_MASTER}},
  232. {
  233. /* Intel 82371AB PIIX4 PCI to ISA bridge */
  234. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 22, 0x00,
  235. pci_cfgfunc_config_device, {0,
  236. 0,
  237. PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
  238. {
  239. /* Intel 82371AB PIIX4 IDE controller */
  240. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 22, 0x01,
  241. pci_cfgfunc_config_device, {0,
  242. 0,
  243. PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
  244. {}
  245. };
  246. #else
  247. #error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240)
  248. #endif
  249. #endif /* #ifndef CONFIG_PCI_PNP */
  250. struct pci_controller hose = {
  251. #ifndef CONFIG_PCI_PNP
  252. config_table:pci_eXalion_config_table,
  253. fixup_irq:pci_eXalion_fixup_irq,
  254. #endif
  255. };
  256. void pci_init_board (void)
  257. {
  258. pci_mpc824x_init (&hose);
  259. }
  260. int board_eth_init(bd_t *bis)
  261. {
  262. return pci_eth_init(bis);
  263. }