mpc86xx_hpcn.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * MPC86xx HPCN board specific routines
  3. *
  4. * Recode: ZHANG WEI <wei.zhang@freescale.com>
  5. * Initial author: Xianghua Xiao <x.xiao@freescale.com>
  6. *
  7. * Copyright 2006 Freescale Semiconductor Inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/stddef.h>
  15. #include <linux/kernel.h>
  16. #include <linux/pci.h>
  17. #include <linux/kdev_t.h>
  18. #include <linux/delay.h>
  19. #include <linux/seq_file.h>
  20. #include <asm/system.h>
  21. #include <asm/time.h>
  22. #include <asm/machdep.h>
  23. #include <asm/pci-bridge.h>
  24. #include <asm/mpc86xx.h>
  25. #include <asm/prom.h>
  26. #include <mm/mmu_decl.h>
  27. #include <asm/udbg.h>
  28. #include <asm/i8259.h>
  29. #include <asm/mpic.h>
  30. #include <sysdev/fsl_pci.h>
  31. #include <sysdev/fsl_soc.h>
  32. #include "mpc86xx.h"
  33. #undef DEBUG
  34. #ifdef DEBUG
  35. #define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0)
  36. #else
  37. #define DBG(fmt...) do { } while(0)
  38. #endif
  39. #ifdef CONFIG_PCI
  40. static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
  41. {
  42. unsigned int cascade_irq = i8259_irq();
  43. if (cascade_irq != NO_IRQ)
  44. generic_handle_irq(cascade_irq);
  45. desc->chip->eoi(irq);
  46. }
  47. #endif /* CONFIG_PCI */
  48. void __init
  49. mpc86xx_hpcn_init_irq(void)
  50. {
  51. struct mpic *mpic1;
  52. struct device_node *np;
  53. struct resource res;
  54. #ifdef CONFIG_PCI
  55. struct device_node *cascade_node = NULL;
  56. int cascade_irq;
  57. #endif
  58. /* Determine PIC address. */
  59. np = of_find_node_by_type(NULL, "open-pic");
  60. if (np == NULL)
  61. return;
  62. of_address_to_resource(np, 0, &res);
  63. /* Alloc mpic structure and per isu has 16 INT entries. */
  64. mpic1 = mpic_alloc(np, res.start,
  65. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  66. 0, 256, " MPIC ");
  67. BUG_ON(mpic1 == NULL);
  68. mpic_init(mpic1);
  69. #ifdef CONFIG_PCI
  70. /* Initialize i8259 controller */
  71. for_each_node_by_type(np, "interrupt-controller")
  72. if (of_device_is_compatible(np, "chrp,iic")) {
  73. cascade_node = np;
  74. break;
  75. }
  76. if (cascade_node == NULL) {
  77. printk(KERN_DEBUG "mpc86xxhpcn: no ISA interrupt controller\n");
  78. return;
  79. }
  80. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  81. if (cascade_irq == NO_IRQ) {
  82. printk(KERN_ERR "mpc86xxhpcn: failed to map cascade interrupt");
  83. return;
  84. }
  85. DBG("mpc86xxhpcn: cascade mapped to irq %d\n", cascade_irq);
  86. i8259_init(cascade_node, 0);
  87. of_node_put(cascade_node);
  88. set_irq_chained_handler(cascade_irq, mpc86xx_8259_cascade);
  89. #endif
  90. }
  91. #ifdef CONFIG_PCI
  92. extern int uses_fsl_uli_m1575;
  93. extern int uli_exclude_device(struct pci_controller *hose,
  94. u_char bus, u_char devfn);
  95. static int mpc86xx_exclude_device(struct pci_controller *hose,
  96. u_char bus, u_char devfn)
  97. {
  98. struct device_node* node;
  99. struct resource rsrc;
  100. node = (struct device_node *)hose->arch_data;
  101. of_address_to_resource(node, 0, &rsrc);
  102. if ((rsrc.start & 0xfffff) == 0x8000) {
  103. return uli_exclude_device(hose, bus, devfn);
  104. }
  105. return PCIBIOS_SUCCESSFUL;
  106. }
  107. #endif /* CONFIG_PCI */
  108. static void __init
  109. mpc86xx_hpcn_setup_arch(void)
  110. {
  111. #ifdef CONFIG_PCI
  112. struct device_node *np;
  113. #endif
  114. if (ppc_md.progress)
  115. ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
  116. #ifdef CONFIG_PCI
  117. for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
  118. struct resource rsrc;
  119. of_address_to_resource(np, 0, &rsrc);
  120. if ((rsrc.start & 0xfffff) == 0x8000)
  121. fsl_add_bridge(np, 1);
  122. else
  123. fsl_add_bridge(np, 0);
  124. }
  125. uses_fsl_uli_m1575 = 1;
  126. ppc_md.pci_exclude_device = mpc86xx_exclude_device;
  127. #endif
  128. printk("MPC86xx HPCN board from Freescale Semiconductor\n");
  129. #ifdef CONFIG_SMP
  130. mpc86xx_smp_init();
  131. #endif
  132. }
  133. void
  134. mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
  135. {
  136. struct device_node *root;
  137. uint memsize = total_memory;
  138. const char *model = "";
  139. uint svid = mfspr(SPRN_SVR);
  140. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  141. root = of_find_node_by_path("/");
  142. if (root)
  143. model = of_get_property(root, "model", NULL);
  144. seq_printf(m, "Machine\t\t: %s\n", model);
  145. of_node_put(root);
  146. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  147. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  148. }
  149. /*
  150. * Called very early, device-tree isn't unflattened
  151. */
  152. static int __init mpc86xx_hpcn_probe(void)
  153. {
  154. unsigned long root = of_get_flat_dt_root();
  155. if (of_flat_dt_is_compatible(root, "mpc86xx"))
  156. return 1; /* Looks good */
  157. return 0;
  158. }
  159. long __init
  160. mpc86xx_time_init(void)
  161. {
  162. unsigned int temp;
  163. /* Set the time base to zero */
  164. mtspr(SPRN_TBWL, 0);
  165. mtspr(SPRN_TBWU, 0);
  166. temp = mfspr(SPRN_HID0);
  167. temp |= HID0_TBEN;
  168. mtspr(SPRN_HID0, temp);
  169. asm volatile("isync");
  170. return 0;
  171. }
  172. define_machine(mpc86xx_hpcn) {
  173. .name = "MPC86xx HPCN",
  174. .probe = mpc86xx_hpcn_probe,
  175. .setup_arch = mpc86xx_hpcn_setup_arch,
  176. .init_IRQ = mpc86xx_hpcn_init_irq,
  177. .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
  178. .get_irq = mpic_get_irq,
  179. .restart = fsl_rstcr_restart,
  180. .time_init = mpc86xx_time_init,
  181. .calibrate_decr = generic_calibrate_decr,
  182. .progress = udbg_progress,
  183. #ifdef CONFIG_PCI
  184. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  185. #endif
  186. };