eXalion.c 7.1 KB

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