mpc85xx_cds.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. /*
  2. * MPC85xx setup and early boot code plus other random bits.
  3. *
  4. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  5. *
  6. * Copyright 2005 Freescale Semiconductor Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  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/major.h>
  22. #include <linux/console.h>
  23. #include <linux/delay.h>
  24. #include <linux/seq_file.h>
  25. #include <linux/root_dev.h>
  26. #include <linux/initrd.h>
  27. #include <linux/module.h>
  28. #include <linux/fsl_devices.h>
  29. #include <asm/system.h>
  30. #include <asm/pgtable.h>
  31. #include <asm/page.h>
  32. #include <asm/atomic.h>
  33. #include <asm/time.h>
  34. #include <asm/io.h>
  35. #include <asm/machdep.h>
  36. #include <asm/ipic.h>
  37. #include <asm/bootinfo.h>
  38. #include <asm/pci-bridge.h>
  39. #include <asm/mpc85xx.h>
  40. #include <asm/irq.h>
  41. #include <mm/mmu_decl.h>
  42. #include <asm/prom.h>
  43. #include <asm/udbg.h>
  44. #include <asm/mpic.h>
  45. #include <asm/i8259.h>
  46. #include <sysdev/fsl_soc.h>
  47. #include "mpc85xx.h"
  48. #ifndef CONFIG_PCI
  49. unsigned long isa_io_base = 0;
  50. unsigned long isa_mem_base = 0;
  51. #endif
  52. static int cds_pci_slot = 2;
  53. static volatile u8 *cadmus;
  54. #ifdef CONFIG_PCI
  55. #define ARCADIA_HOST_BRIDGE_IDSEL 17
  56. #define ARCADIA_2ND_BRIDGE_IDSEL 3
  57. extern int mpc85xx_pci2_busno;
  58. int
  59. mpc85xx_exclude_device(u_char bus, u_char devfn)
  60. {
  61. if (bus == 0 && PCI_SLOT(devfn) == 0)
  62. return PCIBIOS_DEVICE_NOT_FOUND;
  63. if (mpc85xx_pci2_busno)
  64. if (bus == (mpc85xx_pci2_busno) && PCI_SLOT(devfn) == 0)
  65. return PCIBIOS_DEVICE_NOT_FOUND;
  66. /* We explicitly do not go past the Tundra 320 Bridge */
  67. if ((bus == 1) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL))
  68. return PCIBIOS_DEVICE_NOT_FOUND;
  69. if ((bus == 0) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL))
  70. return PCIBIOS_DEVICE_NOT_FOUND;
  71. else
  72. return PCIBIOS_SUCCESSFUL;
  73. }
  74. void __init
  75. mpc85xx_cds_pcibios_fixup(void)
  76. {
  77. struct pci_dev *dev;
  78. u_char c;
  79. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  80. PCI_DEVICE_ID_VIA_82C586_1, NULL))) {
  81. /*
  82. * U-Boot does not set the enable bits
  83. * for the IDE device. Force them on here.
  84. */
  85. pci_read_config_byte(dev, 0x40, &c);
  86. c |= 0x03; /* IDE: Chip Enable Bits */
  87. pci_write_config_byte(dev, 0x40, c);
  88. /*
  89. * Since only primary interface works, force the
  90. * IDE function to standard primary IDE interrupt
  91. * w/ 8259 offset
  92. */
  93. dev->irq = 14;
  94. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  95. pci_dev_put(dev);
  96. }
  97. /*
  98. * Force legacy USB interrupt routing
  99. */
  100. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  101. PCI_DEVICE_ID_VIA_82C586_2, NULL))) {
  102. dev->irq = 10;
  103. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 10);
  104. pci_dev_put(dev);
  105. }
  106. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  107. PCI_DEVICE_ID_VIA_82C586_2, dev))) {
  108. dev->irq = 11;
  109. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11);
  110. pci_dev_put(dev);
  111. }
  112. /* Now map all the PCI irqs */
  113. dev = NULL;
  114. for_each_pci_dev(dev)
  115. pci_read_irq_line(dev);
  116. }
  117. #ifdef CONFIG_PPC_I8259
  118. #warning The i8259 PIC support is currently broken
  119. static void mpc85xx_8259_cascade(unsigned int irq, struct
  120. irq_desc *desc, struct pt_regs *regs)
  121. {
  122. unsigned int cascade_irq = i8259_irq(regs);
  123. if (cascade_irq != NO_IRQ)
  124. generic_handle_irq(cascade_irq, regs);
  125. desc->chip->eoi(irq);
  126. }
  127. #endif /* PPC_I8259 */
  128. #endif /* CONFIG_PCI */
  129. void __init mpc85xx_cds_pic_init(void)
  130. {
  131. struct mpic *mpic;
  132. struct resource r;
  133. struct device_node *np = NULL;
  134. struct device_node *cascade_node = NULL;
  135. int cascade_irq;
  136. np = of_find_node_by_type(np, "open-pic");
  137. if (np == NULL) {
  138. printk(KERN_ERR "Could not find open-pic node\n");
  139. return;
  140. }
  141. if (of_address_to_resource(np, 0, &r)) {
  142. printk(KERN_ERR "Failed to map mpic register space\n");
  143. of_node_put(np);
  144. return;
  145. }
  146. mpic = mpic_alloc(np, r.start,
  147. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  148. 4, 0, " OpenPIC ");
  149. BUG_ON(mpic == NULL);
  150. /* Return the mpic node */
  151. of_node_put(np);
  152. mpic_assign_isu(mpic, 0, r.start + 0x10200);
  153. mpic_assign_isu(mpic, 1, r.start + 0x10280);
  154. mpic_assign_isu(mpic, 2, r.start + 0x10300);
  155. mpic_assign_isu(mpic, 3, r.start + 0x10380);
  156. mpic_assign_isu(mpic, 4, r.start + 0x10400);
  157. mpic_assign_isu(mpic, 5, r.start + 0x10480);
  158. mpic_assign_isu(mpic, 6, r.start + 0x10500);
  159. mpic_assign_isu(mpic, 7, r.start + 0x10580);
  160. /* Used only for 8548 so far, but no harm in
  161. * allocating them for everyone */
  162. mpic_assign_isu(mpic, 8, r.start + 0x10600);
  163. mpic_assign_isu(mpic, 9, r.start + 0x10680);
  164. mpic_assign_isu(mpic, 10, r.start + 0x10700);
  165. mpic_assign_isu(mpic, 11, r.start + 0x10780);
  166. /* External Interrupts */
  167. mpic_assign_isu(mpic, 12, r.start + 0x10000);
  168. mpic_assign_isu(mpic, 13, r.start + 0x10080);
  169. mpic_assign_isu(mpic, 14, r.start + 0x10100);
  170. mpic_init(mpic);
  171. #ifdef CONFIG_PPC_I8259
  172. /* Initialize the i8259 controller */
  173. for_each_node_by_type(np, "interrupt-controller")
  174. if (device_is_compatible(np, "chrp,iic")) {
  175. cascade_node = np;
  176. break;
  177. }
  178. if (cascade_node == NULL) {
  179. printk(KERN_DEBUG "Could not find i8259 PIC\n");
  180. return;
  181. }
  182. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  183. if (cascade_irq == NO_IRQ) {
  184. printk(KERN_ERR "Failed to map cascade interrupt\n");
  185. return;
  186. }
  187. i8259_init(cascade_node, 0);
  188. of_node_put(cascade_node);
  189. set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade);
  190. #endif /* CONFIG_PPC_I8259 */
  191. }
  192. /*
  193. * Setup the architecture
  194. */
  195. static void __init
  196. mpc85xx_cds_setup_arch(void)
  197. {
  198. struct device_node *cpu;
  199. #ifdef CONFIG_PCI
  200. struct device_node *np;
  201. #endif
  202. if (ppc_md.progress)
  203. ppc_md.progress("mpc85xx_cds_setup_arch()", 0);
  204. cpu = of_find_node_by_type(NULL, "cpu");
  205. if (cpu != 0) {
  206. const unsigned int *fp;
  207. fp = get_property(cpu, "clock-frequency", NULL);
  208. if (fp != 0)
  209. loops_per_jiffy = *fp / HZ;
  210. else
  211. loops_per_jiffy = 500000000 / HZ;
  212. of_node_put(cpu);
  213. }
  214. cadmus = ioremap(CADMUS_BASE, CADMUS_SIZE);
  215. cds_pci_slot = ((cadmus[CM_CSR] >> 6) & 0x3) + 1;
  216. if (ppc_md.progress) {
  217. char buf[40];
  218. snprintf(buf, 40, "CDS Version = 0x%x in slot %d\n",
  219. cadmus[CM_VER], cds_pci_slot);
  220. ppc_md.progress(buf, 0);
  221. }
  222. #ifdef CONFIG_PCI
  223. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  224. add_bridge(np);
  225. ppc_md.pcibios_fixup = mpc85xx_cds_pcibios_fixup;
  226. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  227. #endif
  228. #ifdef CONFIG_ROOT_NFS
  229. ROOT_DEV = Root_NFS;
  230. #else
  231. ROOT_DEV = Root_HDA1;
  232. #endif
  233. }
  234. void
  235. mpc85xx_cds_show_cpuinfo(struct seq_file *m)
  236. {
  237. uint pvid, svid, phid1;
  238. uint memsize = total_memory;
  239. pvid = mfspr(SPRN_PVR);
  240. svid = mfspr(SPRN_SVR);
  241. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  242. seq_printf(m, "Machine\t\t: MPC85xx CDS (0x%x)\n", cadmus[CM_VER]);
  243. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  244. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  245. /* Display cpu Pll setting */
  246. phid1 = mfspr(SPRN_HID1);
  247. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  248. /* Display the amount of memory */
  249. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  250. }
  251. /*
  252. * Called very early, device-tree isn't unflattened
  253. */
  254. static int __init mpc85xx_cds_probe(void)
  255. {
  256. /* We always match for now, eventually we should look at
  257. * the flat dev tree to ensure this is the board we are
  258. * supposed to run on
  259. */
  260. return 1;
  261. }
  262. define_machine(mpc85xx_cds) {
  263. .name = "MPC85xx CDS",
  264. .probe = mpc85xx_cds_probe,
  265. .setup_arch = mpc85xx_cds_setup_arch,
  266. .init_IRQ = mpc85xx_cds_pic_init,
  267. .show_cpuinfo = mpc85xx_cds_show_cpuinfo,
  268. .get_irq = mpic_get_irq,
  269. .restart = mpc85xx_restart,
  270. .calibrate_decr = generic_calibrate_decr,
  271. .progress = udbg_progress,
  272. };