pcore.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. /*
  2. * arch/ppc/platforms/pcore_setup.c
  3. *
  4. * Setup routines for Force PCORE boards
  5. *
  6. * Author: Matt Porter <mporter@mvista.com>
  7. *
  8. * 2001 (c) MontaVista, Software, Inc. This file is licensed under
  9. * the terms of the GNU General Public License version 2. This program
  10. * is licensed "as is" without any warranty of any kind, whether express
  11. * or implied.
  12. */
  13. #include <linux/config.h>
  14. #include <linux/stddef.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/errno.h>
  18. #include <linux/reboot.h>
  19. #include <linux/pci.h>
  20. #include <linux/kdev_t.h>
  21. #include <linux/types.h>
  22. #include <linux/major.h>
  23. #include <linux/initrd.h>
  24. #include <linux/console.h>
  25. #include <linux/irq.h>
  26. #include <linux/seq_file.h>
  27. #include <linux/root_dev.h>
  28. #include <asm/io.h>
  29. #include <asm/machdep.h>
  30. #include <asm/time.h>
  31. #include <asm/i8259.h>
  32. #include <asm/mpc10x.h>
  33. #include <asm/todc.h>
  34. #include <asm/bootinfo.h>
  35. #include <asm/kgdb.h>
  36. #include "pcore.h"
  37. extern unsigned long loops_per_jiffy;
  38. static int board_type;
  39. static inline int __init
  40. pcore_6750_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  41. {
  42. static char pci_irq_table[][4] =
  43. /*
  44. * PCI IDSEL/INTPIN->INTLINE
  45. * A B C D
  46. */
  47. {
  48. {9, 10, 11, 12}, /* IDSEL 24 - DEC 21554 */
  49. {10, 0, 0, 0}, /* IDSEL 25 - DEC 21143 */
  50. {11, 12, 9, 10}, /* IDSEL 26 - PMC I */
  51. {12, 9, 10, 11}, /* IDSEL 27 - PMC II */
  52. {0, 0, 0, 0}, /* IDSEL 28 - unused */
  53. {0, 0, 9, 0}, /* IDSEL 29 - unused */
  54. {0, 0, 0, 0}, /* IDSEL 30 - Winbond */
  55. };
  56. const long min_idsel = 24, max_idsel = 30, irqs_per_slot = 4;
  57. return PCI_IRQ_TABLE_LOOKUP;
  58. };
  59. static inline int __init
  60. pcore_680_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  61. {
  62. static char pci_irq_table[][4] =
  63. /*
  64. * PCI IDSEL/INTPIN->INTLINE
  65. * A B C D
  66. */
  67. {
  68. {9, 10, 11, 12}, /* IDSEL 24 - Sentinel */
  69. {10, 0, 0, 0}, /* IDSEL 25 - i82559 #1 */
  70. {11, 12, 9, 10}, /* IDSEL 26 - PMC I */
  71. {12, 9, 10, 11}, /* IDSEL 27 - PMC II */
  72. {9, 0, 0, 0}, /* IDSEL 28 - i82559 #2 */
  73. {0, 0, 0, 0}, /* IDSEL 29 - unused */
  74. {0, 0, 0, 0}, /* IDSEL 30 - Winbond */
  75. };
  76. const long min_idsel = 24, max_idsel = 30, irqs_per_slot = 4;
  77. return PCI_IRQ_TABLE_LOOKUP;
  78. };
  79. void __init
  80. pcore_pcibios_fixup(void)
  81. {
  82. struct pci_dev *dev;
  83. if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
  84. PCI_DEVICE_ID_WINBOND_83C553,
  85. 0)))
  86. {
  87. /* Reroute interrupts both IDE channels to 15 */
  88. pci_write_config_byte(dev,
  89. PCORE_WINBOND_IDE_INT,
  90. 0xff);
  91. /* Route INTA-D to IRQ9-12, respectively */
  92. pci_write_config_word(dev,
  93. PCORE_WINBOND_PCI_INT,
  94. 0x9abc);
  95. /*
  96. * Set up 8259 edge/level triggering
  97. */
  98. outb(0x00, PCORE_WINBOND_PRI_EDG_LVL);
  99. outb(0x1e, PCORE_WINBOND_SEC_EDG_LVL);
  100. pci_dev_put(dev);
  101. }
  102. }
  103. int __init
  104. pcore_find_bridges(void)
  105. {
  106. struct pci_controller* hose;
  107. int host_bridge, board_type;
  108. hose = pcibios_alloc_controller();
  109. if (!hose)
  110. return 0;
  111. mpc10x_bridge_init(hose,
  112. MPC10X_MEM_MAP_B,
  113. MPC10X_MEM_MAP_B,
  114. MPC10X_MAPB_EUMB_BASE);
  115. /* Determine board type */
  116. early_read_config_dword(hose,
  117. 0,
  118. PCI_DEVFN(0,0),
  119. PCI_VENDOR_ID,
  120. &host_bridge);
  121. if (host_bridge == MPC10X_BRIDGE_106)
  122. board_type = PCORE_TYPE_6750;
  123. else /* MPC10X_BRIDGE_107 */
  124. board_type = PCORE_TYPE_680;
  125. hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
  126. ppc_md.pcibios_fixup = pcore_pcibios_fixup;
  127. ppc_md.pci_swizzle = common_swizzle;
  128. if (board_type == PCORE_TYPE_6750)
  129. ppc_md.pci_map_irq = pcore_6750_map_irq;
  130. else /* PCORE_TYPE_680 */
  131. ppc_md.pci_map_irq = pcore_680_map_irq;
  132. return board_type;
  133. }
  134. /* Dummy variable to satisfy mpc10x_common.o */
  135. void *OpenPIC_Addr;
  136. static int
  137. pcore_show_cpuinfo(struct seq_file *m)
  138. {
  139. seq_printf(m, "vendor\t\t: Force Computers\n");
  140. if (board_type == PCORE_TYPE_6750)
  141. seq_printf(m, "machine\t\t: PowerCore 6750\n");
  142. else /* PCORE_TYPE_680 */
  143. seq_printf(m, "machine\t\t: PowerCore 680\n");
  144. seq_printf(m, "L2\t\t: " );
  145. if (board_type == PCORE_TYPE_6750)
  146. switch (readb(PCORE_DCCR_REG) & PCORE_DCCR_L2_MASK)
  147. {
  148. case PCORE_DCCR_L2_0KB:
  149. seq_printf(m, "nocache");
  150. break;
  151. case PCORE_DCCR_L2_256KB:
  152. seq_printf(m, "256KB");
  153. break;
  154. case PCORE_DCCR_L2_1MB:
  155. seq_printf(m, "1MB");
  156. break;
  157. case PCORE_DCCR_L2_512KB:
  158. seq_printf(m, "512KB");
  159. break;
  160. default:
  161. seq_printf(m, "error");
  162. break;
  163. }
  164. else /* PCORE_TYPE_680 */
  165. switch (readb(PCORE_DCCR_REG) & PCORE_DCCR_L2_MASK)
  166. {
  167. case PCORE_DCCR_L2_2MB:
  168. seq_printf(m, "2MB");
  169. break;
  170. case PCORE_DCCR_L2_256KB:
  171. seq_printf(m, "reserved");
  172. break;
  173. case PCORE_DCCR_L2_1MB:
  174. seq_printf(m, "1MB");
  175. break;
  176. case PCORE_DCCR_L2_512KB:
  177. seq_printf(m, "512KB");
  178. break;
  179. default:
  180. seq_printf(m, "error");
  181. break;
  182. }
  183. seq_printf(m, "\n");
  184. return 0;
  185. }
  186. static void __init
  187. pcore_setup_arch(void)
  188. {
  189. /* init to some ~sane value until calibrate_delay() runs */
  190. loops_per_jiffy = 50000000/HZ;
  191. /* Lookup PCI host bridges */
  192. board_type = pcore_find_bridges();
  193. #ifdef CONFIG_BLK_DEV_INITRD
  194. if (initrd_start)
  195. ROOT_DEV = Root_RAM0;
  196. else
  197. #endif
  198. #ifdef CONFIG_ROOT_NFS
  199. ROOT_DEV = Root_NFS;
  200. #else
  201. ROOT_DEV = Root_SDA2;
  202. #endif
  203. printk(KERN_INFO "Force PowerCore ");
  204. if (board_type == PCORE_TYPE_6750)
  205. printk("6750\n");
  206. else
  207. printk("680\n");
  208. printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
  209. _set_L2CR(L2CR_L2E | _get_L2CR());
  210. }
  211. static void
  212. pcore_restart(char *cmd)
  213. {
  214. local_irq_disable();
  215. /* Hard reset */
  216. writeb(0x11, 0xfe000332);
  217. while(1);
  218. }
  219. static void
  220. pcore_halt(void)
  221. {
  222. local_irq_disable();
  223. /* Turn off user LEDs */
  224. writeb(0x00, 0xfe000300);
  225. while (1);
  226. }
  227. static void
  228. pcore_power_off(void)
  229. {
  230. pcore_halt();
  231. }
  232. static void __init
  233. pcore_init_IRQ(void)
  234. {
  235. int i;
  236. for ( i = 0 ; i < 16 ; i++ )
  237. irq_desc[i].handler = &i8259_pic;
  238. i8259_init(0);
  239. }
  240. /*
  241. * Set BAT 3 to map 0xf0000000 to end of physical memory space.
  242. */
  243. static __inline__ void
  244. pcore_set_bat(void)
  245. {
  246. mb();
  247. mtspr(SPRN_DBAT3U, 0xf0001ffe);
  248. mtspr(SPRN_DBAT3L, 0xfe80002a);
  249. mb();
  250. }
  251. static unsigned long __init
  252. pcore_find_end_of_memory(void)
  253. {
  254. return mpc10x_get_mem_size(MPC10X_MEM_MAP_B);
  255. }
  256. static void __init
  257. pcore_map_io(void)
  258. {
  259. io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
  260. }
  261. TODC_ALLOC();
  262. void __init
  263. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  264. unsigned long r6, unsigned long r7)
  265. {
  266. parse_bootinfo(find_bootinfo());
  267. /* Cover I/O space with a BAT */
  268. /* yuck, better hope your ram size is a power of 2 -- paulus */
  269. pcore_set_bat();
  270. isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
  271. isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
  272. pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
  273. ppc_md.setup_arch = pcore_setup_arch;
  274. ppc_md.show_cpuinfo = pcore_show_cpuinfo;
  275. ppc_md.init_IRQ = pcore_init_IRQ;
  276. ppc_md.get_irq = i8259_irq;
  277. ppc_md.find_end_of_memory = pcore_find_end_of_memory;
  278. ppc_md.setup_io_mappings = pcore_map_io;
  279. ppc_md.restart = pcore_restart;
  280. ppc_md.power_off = pcore_power_off;
  281. ppc_md.halt = pcore_halt;
  282. TODC_INIT(TODC_TYPE_MK48T59,
  283. PCORE_NVRAM_AS0,
  284. PCORE_NVRAM_AS1,
  285. PCORE_NVRAM_DATA,
  286. 8);
  287. ppc_md.time_init = todc_time_init;
  288. ppc_md.get_rtc_time = todc_get_rtc_time;
  289. ppc_md.set_rtc_time = todc_set_rtc_time;
  290. ppc_md.calibrate_decr = todc_calibrate_decr;
  291. ppc_md.nvram_read_val = todc_m48txx_read_val;
  292. ppc_md.nvram_write_val = todc_m48txx_write_val;
  293. #ifdef CONFIG_SERIAL_TEXT_DEBUG
  294. ppc_md.progress = gen550_progress;
  295. #endif
  296. #ifdef CONFIG_KGDB
  297. ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
  298. #endif
  299. }