mpc85xx_cds.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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/stddef.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/errno.h>
  17. #include <linux/reboot.h>
  18. #include <linux/pci.h>
  19. #include <linux/kdev_t.h>
  20. #include <linux/major.h>
  21. #include <linux/console.h>
  22. #include <linux/delay.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/initrd.h>
  25. #include <linux/module.h>
  26. #include <linux/fsl_devices.h>
  27. #include <asm/system.h>
  28. #include <asm/pgtable.h>
  29. #include <asm/page.h>
  30. #include <asm/atomic.h>
  31. #include <asm/time.h>
  32. #include <asm/io.h>
  33. #include <asm/machdep.h>
  34. #include <asm/ipic.h>
  35. #include <asm/bootinfo.h>
  36. #include <asm/pci-bridge.h>
  37. #include <asm/mpc85xx.h>
  38. #include <asm/irq.h>
  39. #include <mm/mmu_decl.h>
  40. #include <asm/prom.h>
  41. #include <asm/udbg.h>
  42. #include <asm/mpic.h>
  43. #include <asm/i8259.h>
  44. #include <sysdev/fsl_soc.h>
  45. #include "mpc85xx.h"
  46. static int cds_pci_slot = 2;
  47. static volatile u8 *cadmus;
  48. #ifdef CONFIG_PCI
  49. #define ARCADIA_HOST_BRIDGE_IDSEL 17
  50. #define ARCADIA_2ND_BRIDGE_IDSEL 3
  51. static int mpc85xx_exclude_device(struct pci_controller *hose,
  52. u_char bus, u_char devfn)
  53. {
  54. if ((bus == hose->first_busno) && PCI_SLOT(devfn) == 0)
  55. return PCIBIOS_DEVICE_NOT_FOUND;
  56. /* We explicitly do not go past the Tundra 320 Bridge */
  57. if ((bus == 1) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL))
  58. return PCIBIOS_DEVICE_NOT_FOUND;
  59. if ((bus == 0) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL))
  60. return PCIBIOS_DEVICE_NOT_FOUND;
  61. else
  62. return PCIBIOS_SUCCESSFUL;
  63. }
  64. static void __init mpc85xx_cds_pcibios_fixup(void)
  65. {
  66. struct pci_dev *dev;
  67. u_char c;
  68. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  69. PCI_DEVICE_ID_VIA_82C586_1, NULL))) {
  70. /*
  71. * U-Boot does not set the enable bits
  72. * for the IDE device. Force them on here.
  73. */
  74. pci_read_config_byte(dev, 0x40, &c);
  75. c |= 0x03; /* IDE: Chip Enable Bits */
  76. pci_write_config_byte(dev, 0x40, c);
  77. /*
  78. * Since only primary interface works, force the
  79. * IDE function to standard primary IDE interrupt
  80. * w/ 8259 offset
  81. */
  82. dev->irq = 14;
  83. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  84. pci_dev_put(dev);
  85. }
  86. /*
  87. * Force legacy USB interrupt routing
  88. */
  89. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  90. PCI_DEVICE_ID_VIA_82C586_2, NULL))) {
  91. dev->irq = 10;
  92. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 10);
  93. pci_dev_put(dev);
  94. }
  95. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  96. PCI_DEVICE_ID_VIA_82C586_2, dev))) {
  97. dev->irq = 11;
  98. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11);
  99. pci_dev_put(dev);
  100. }
  101. /* Now map all the PCI irqs */
  102. dev = NULL;
  103. for_each_pci_dev(dev)
  104. pci_read_irq_line(dev);
  105. }
  106. #ifdef CONFIG_PPC_I8259
  107. #warning The i8259 PIC support is currently broken
  108. static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
  109. {
  110. unsigned int cascade_irq = i8259_irq();
  111. if (cascade_irq != NO_IRQ)
  112. generic_handle_irq(cascade_irq);
  113. desc->chip->eoi(irq);
  114. }
  115. #endif /* PPC_I8259 */
  116. #endif /* CONFIG_PCI */
  117. static void __init mpc85xx_cds_pic_init(void)
  118. {
  119. struct mpic *mpic;
  120. struct resource r;
  121. struct device_node *np = NULL;
  122. #ifdef CONFIG_PPC_I8259
  123. struct device_node *cascade_node = NULL;
  124. int cascade_irq;
  125. #endif
  126. np = of_find_node_by_type(np, "open-pic");
  127. if (np == NULL) {
  128. printk(KERN_ERR "Could not find open-pic node\n");
  129. return;
  130. }
  131. if (of_address_to_resource(np, 0, &r)) {
  132. printk(KERN_ERR "Failed to map mpic register space\n");
  133. of_node_put(np);
  134. return;
  135. }
  136. mpic = mpic_alloc(np, r.start,
  137. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  138. 0, 256, " OpenPIC ");
  139. BUG_ON(mpic == NULL);
  140. /* Return the mpic node */
  141. of_node_put(np);
  142. mpic_init(mpic);
  143. #ifdef CONFIG_PPC_I8259
  144. /* Initialize the i8259 controller */
  145. for_each_node_by_type(np, "interrupt-controller")
  146. if (of_device_is_compatible(np, "chrp,iic")) {
  147. cascade_node = np;
  148. break;
  149. }
  150. if (cascade_node == NULL) {
  151. printk(KERN_DEBUG "Could not find i8259 PIC\n");
  152. return;
  153. }
  154. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  155. if (cascade_irq == NO_IRQ) {
  156. printk(KERN_ERR "Failed to map cascade interrupt\n");
  157. return;
  158. }
  159. i8259_init(cascade_node, 0);
  160. of_node_put(cascade_node);
  161. set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade);
  162. #endif /* CONFIG_PPC_I8259 */
  163. }
  164. /*
  165. * Setup the architecture
  166. */
  167. static void __init mpc85xx_cds_setup_arch(void)
  168. {
  169. struct device_node *cpu;
  170. #ifdef CONFIG_PCI
  171. struct device_node *np;
  172. #endif
  173. if (ppc_md.progress)
  174. ppc_md.progress("mpc85xx_cds_setup_arch()", 0);
  175. cpu = of_find_node_by_type(NULL, "cpu");
  176. if (cpu != 0) {
  177. const unsigned int *fp;
  178. fp = of_get_property(cpu, "clock-frequency", NULL);
  179. if (fp != 0)
  180. loops_per_jiffy = *fp / HZ;
  181. else
  182. loops_per_jiffy = 500000000 / HZ;
  183. of_node_put(cpu);
  184. }
  185. cadmus = ioremap(CADMUS_BASE, CADMUS_SIZE);
  186. cds_pci_slot = ((cadmus[CM_CSR] >> 6) & 0x3) + 1;
  187. if (ppc_md.progress) {
  188. char buf[40];
  189. snprintf(buf, 40, "CDS Version = 0x%x in slot %d\n",
  190. cadmus[CM_VER], cds_pci_slot);
  191. ppc_md.progress(buf, 0);
  192. }
  193. #ifdef CONFIG_PCI
  194. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  195. mpc85xx_add_bridge(np);
  196. ppc_md.pcibios_fixup = mpc85xx_cds_pcibios_fixup;
  197. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  198. #endif
  199. }
  200. static void mpc85xx_cds_show_cpuinfo(struct seq_file *m)
  201. {
  202. uint pvid, svid, phid1;
  203. uint memsize = total_memory;
  204. pvid = mfspr(SPRN_PVR);
  205. svid = mfspr(SPRN_SVR);
  206. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  207. seq_printf(m, "Machine\t\t: MPC85xx CDS (0x%x)\n", cadmus[CM_VER]);
  208. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  209. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  210. /* Display cpu Pll setting */
  211. phid1 = mfspr(SPRN_HID1);
  212. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  213. /* Display the amount of memory */
  214. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  215. }
  216. /*
  217. * Called very early, device-tree isn't unflattened
  218. */
  219. static int __init mpc85xx_cds_probe(void)
  220. {
  221. unsigned long root = of_get_flat_dt_root();
  222. return of_flat_dt_is_compatible(root, "MPC85xxCDS");
  223. }
  224. define_machine(mpc85xx_cds) {
  225. .name = "MPC85xx CDS",
  226. .probe = mpc85xx_cds_probe,
  227. .setup_arch = mpc85xx_cds_setup_arch,
  228. .init_IRQ = mpc85xx_cds_pic_init,
  229. .show_cpuinfo = mpc85xx_cds_show_cpuinfo,
  230. .get_irq = mpic_get_irq,
  231. .restart = mpc85xx_restart,
  232. .calibrate_decr = generic_calibrate_decr,
  233. .progress = udbg_progress,
  234. };