mpc8544_ds.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * MPC8544 DS Board Setup
  3. *
  4. * Author Xianghua Xiao (x.xiao@freescale.com)
  5. * Copyright 2007 Freescale Semiconductor Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #include <linux/stddef.h>
  13. #include <linux/kernel.h>
  14. #include <linux/kdev_t.h>
  15. #include <linux/delay.h>
  16. #include <linux/seq_file.h>
  17. #include <asm/system.h>
  18. #include <asm/time.h>
  19. #include <asm/machdep.h>
  20. #include <asm/mpc85xx.h>
  21. #include <mm/mmu_decl.h>
  22. #include <asm/prom.h>
  23. #include <asm/udbg.h>
  24. #include <asm/mpic.h>
  25. #include <asm/i8259.h>
  26. #include <sysdev/fsl_soc.h>
  27. #include "mpc85xx.h"
  28. #undef DEBUG
  29. #ifdef DEBUG
  30. #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
  31. #else
  32. #define DBG(fmt, args...)
  33. #endif
  34. void __init mpc8544_ds_pic_init(void)
  35. {
  36. struct mpic *mpic;
  37. struct resource r;
  38. struct device_node *np = NULL;
  39. #ifdef CONFIG_PPC_I8259
  40. struct device_node *cascade_node = NULL;
  41. int cascade_irq;
  42. #endif
  43. np = of_find_node_by_type(np, "open-pic");
  44. if (np == NULL) {
  45. printk(KERN_ERR "Could not find open-pic node\n");
  46. return;
  47. }
  48. if (of_address_to_resource(np, 0, &r)) {
  49. printk(KERN_ERR "Failed to map mpic register space\n");
  50. of_node_put(np);
  51. return;
  52. }
  53. /* Alloc mpic structure and per isu has 16 INT entries. */
  54. mpic = mpic_alloc(np, r.start,
  55. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  56. 16, 64, " OPENPIC ");
  57. BUG_ON(mpic == NULL);
  58. /*
  59. * 48 Internal Interrupts
  60. */
  61. mpic_assign_isu(mpic, 0, r.start + 0x10200);
  62. mpic_assign_isu(mpic, 1, r.start + 0x10400);
  63. mpic_assign_isu(mpic, 2, r.start + 0x10600);
  64. /*
  65. * 16 External interrupts
  66. */
  67. mpic_assign_isu(mpic, 3, r.start + 0x10000);
  68. mpic_init(mpic);
  69. #ifdef CONFIG_PPC_I8259
  70. /* Initialize the 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 "Could not find i8259 PIC\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 "Failed to map cascade interrupt\n");
  83. return;
  84. }
  85. DBG("mpc8544ds: 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, mpc8544_8259_cascade);
  89. #endif /* CONFIG_PPC_I8259 */
  90. }
  91. /*
  92. * Setup the architecture
  93. */
  94. static void __init mpc8544_ds_setup_arch(void)
  95. {
  96. if (ppc_md.progress)
  97. ppc_md.progress("mpc8544_ds_setup_arch()", 0);
  98. printk("MPC8544 DS board from Freescale Semiconductor\n");
  99. }
  100. /*
  101. * Called very early, device-tree isn't unflattened
  102. */
  103. static int __init mpc8544_ds_probe(void)
  104. {
  105. unsigned long root = of_get_flat_dt_root();
  106. return of_flat_dt_is_compatible(root, "MPC8544DS");
  107. }
  108. define_machine(mpc8544_ds) {
  109. .name = "MPC8544 DS",
  110. .probe = mpc8544_ds_probe,
  111. .setup_arch = mpc8544_ds_setup_arch,
  112. .init_IRQ = mpc8544_ds_pic_init,
  113. .get_irq = mpic_get_irq,
  114. .restart = mpc85xx_restart,
  115. .calibrate_decr = generic_calibrate_decr,
  116. .progress = udbg_progress,
  117. };