socrates.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Copyright (c) 2008 Emcraft Systems
  3. * Sergei Poselenov <sposelenov@emcraft.com>
  4. *
  5. * Based on MPC8560 ADS and arch/ppc tqm85xx ports
  6. *
  7. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  8. *
  9. * Copyright 2008 Freescale Semiconductor Inc.
  10. *
  11. * Copyright (c) 2005-2006 DENX Software Engineering
  12. * Stefan Roese <sr@denx.de>
  13. *
  14. * Based on original work by
  15. * Kumar Gala <kumar.gala@freescale.com>
  16. * Copyright 2004 Freescale Semiconductor Inc.
  17. *
  18. * This program is free software; you can redistribute it and/or modify it
  19. * under the terms of the GNU General Public License as published by the
  20. * Free Software Foundation; either version 2 of the License, or (at your
  21. * option) any later version.
  22. */
  23. #include <linux/stddef.h>
  24. #include <linux/kernel.h>
  25. #include <linux/pci.h>
  26. #include <linux/kdev_t.h>
  27. #include <linux/delay.h>
  28. #include <linux/seq_file.h>
  29. #include <linux/of_platform.h>
  30. #include <asm/system.h>
  31. #include <asm/time.h>
  32. #include <asm/machdep.h>
  33. #include <asm/pci-bridge.h>
  34. #include <asm/mpic.h>
  35. #include <asm/prom.h>
  36. #include <mm/mmu_decl.h>
  37. #include <asm/udbg.h>
  38. #include <sysdev/fsl_soc.h>
  39. #include <sysdev/fsl_pci.h>
  40. #include "socrates_fpga_pic.h"
  41. static void __init socrates_pic_init(void)
  42. {
  43. struct mpic *mpic;
  44. struct resource r;
  45. struct device_node *np;
  46. np = of_find_node_by_type(NULL, "open-pic");
  47. if (!np) {
  48. printk(KERN_ERR "Could not find open-pic node\n");
  49. return;
  50. }
  51. if (of_address_to_resource(np, 0, &r)) {
  52. printk(KERN_ERR "Could not map mpic register space\n");
  53. of_node_put(np);
  54. return;
  55. }
  56. mpic = mpic_alloc(np, r.start,
  57. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  58. 0, 256, " OpenPIC ");
  59. BUG_ON(mpic == NULL);
  60. of_node_put(np);
  61. mpic_init(mpic);
  62. np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic");
  63. if (!np) {
  64. printk(KERN_ERR "Could not find socrates-fpga-pic node\n");
  65. return;
  66. }
  67. socrates_fpga_pic_init(np);
  68. of_node_put(np);
  69. }
  70. /*
  71. * Setup the architecture
  72. */
  73. static void __init socrates_setup_arch(void)
  74. {
  75. #ifdef CONFIG_PCI
  76. struct device_node *np;
  77. #endif
  78. if (ppc_md.progress)
  79. ppc_md.progress("socrates_setup_arch()", 0);
  80. #ifdef CONFIG_PCI
  81. for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
  82. fsl_add_bridge(np, 1);
  83. #endif
  84. }
  85. static struct of_device_id __initdata socrates_of_bus_ids[] = {
  86. { .compatible = "simple-bus", },
  87. { .compatible = "gianfar", },
  88. {},
  89. };
  90. static int __init socrates_publish_devices(void)
  91. {
  92. return of_platform_bus_probe(NULL, socrates_of_bus_ids, NULL);
  93. }
  94. machine_device_initcall(socrates, socrates_publish_devices);
  95. /*
  96. * Called very early, device-tree isn't unflattened
  97. */
  98. static int __init socrates_probe(void)
  99. {
  100. unsigned long root = of_get_flat_dt_root();
  101. if (of_flat_dt_is_compatible(root, "abb,socrates"))
  102. return 1;
  103. return 0;
  104. }
  105. define_machine(socrates) {
  106. .name = "Socrates",
  107. .probe = socrates_probe,
  108. .setup_arch = socrates_setup_arch,
  109. .init_IRQ = socrates_pic_init,
  110. .get_irq = mpic_get_irq,
  111. .restart = fsl_rstcr_restart,
  112. .calibrate_decr = generic_calibrate_decr,
  113. .progress = udbg_progress,
  114. };