mpc8544_ds.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. mpic = mpic_alloc(np, r.start,
  54. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  55. 0, 256, " OpenPIC ");
  56. BUG_ON(mpic == NULL);
  57. mpic_init(mpic);
  58. #ifdef CONFIG_PPC_I8259
  59. /* Initialize the i8259 controller */
  60. for_each_node_by_type(np, "interrupt-controller")
  61. if (of_device_is_compatible(np, "chrp,iic")) {
  62. cascade_node = np;
  63. break;
  64. }
  65. if (cascade_node == NULL) {
  66. printk(KERN_DEBUG "Could not find i8259 PIC\n");
  67. return;
  68. }
  69. cascade_irq = irq_of_parse_and_map(cascade_node, 0);
  70. if (cascade_irq == NO_IRQ) {
  71. printk(KERN_ERR "Failed to map cascade interrupt\n");
  72. return;
  73. }
  74. DBG("mpc8544ds: cascade mapped to irq %d\n", cascade_irq);
  75. i8259_init(cascade_node, 0);
  76. of_node_put(cascade_node);
  77. set_irq_chained_handler(cascade_irq, mpc8544_8259_cascade);
  78. #endif /* CONFIG_PPC_I8259 */
  79. }
  80. /*
  81. * Setup the architecture
  82. */
  83. static void __init mpc8544_ds_setup_arch(void)
  84. {
  85. if (ppc_md.progress)
  86. ppc_md.progress("mpc8544_ds_setup_arch()", 0);
  87. printk("MPC8544 DS board from Freescale Semiconductor\n");
  88. }
  89. /*
  90. * Called very early, device-tree isn't unflattened
  91. */
  92. static int __init mpc8544_ds_probe(void)
  93. {
  94. unsigned long root = of_get_flat_dt_root();
  95. return of_flat_dt_is_compatible(root, "MPC8544DS");
  96. }
  97. define_machine(mpc8544_ds) {
  98. .name = "MPC8544 DS",
  99. .probe = mpc8544_ds_probe,
  100. .setup_arch = mpc8544_ds_setup_arch,
  101. .init_IRQ = mpc8544_ds_pic_init,
  102. .get_irq = mpic_get_irq,
  103. .restart = mpc85xx_restart,
  104. .calibrate_decr = generic_calibrate_decr,
  105. .progress = udbg_progress,
  106. };