mpc832x_mds.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
  3. *
  4. * Description:
  5. * MPC832xE MDS board specific routines.
  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/init.h>
  15. #include <linux/errno.h>
  16. #include <linux/reboot.h>
  17. #include <linux/pci.h>
  18. #include <linux/kdev_t.h>
  19. #include <linux/major.h>
  20. #include <linux/console.h>
  21. #include <linux/delay.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/root_dev.h>
  24. #include <linux/initrd.h>
  25. #include <asm/of_device.h>
  26. #include <asm/of_platform.h>
  27. #include <asm/system.h>
  28. #include <asm/atomic.h>
  29. #include <asm/time.h>
  30. #include <asm/io.h>
  31. #include <asm/machdep.h>
  32. #include <asm/ipic.h>
  33. #include <asm/irq.h>
  34. #include <asm/prom.h>
  35. #include <asm/udbg.h>
  36. #include <sysdev/fsl_soc.h>
  37. #include <asm/qe.h>
  38. #include <asm/qe_ic.h>
  39. #include "mpc83xx.h"
  40. #undef DEBUG
  41. #ifdef DEBUG
  42. #define DBG(fmt...) udbg_printf(fmt)
  43. #else
  44. #define DBG(fmt...)
  45. #endif
  46. static u8 *bcsr_regs = NULL;
  47. /* ************************************************************************
  48. *
  49. * Setup the architecture
  50. *
  51. */
  52. static void __init mpc832x_sys_setup_arch(void)
  53. {
  54. struct device_node *np;
  55. if (ppc_md.progress)
  56. ppc_md.progress("mpc832x_sys_setup_arch()", 0);
  57. /* Map BCSR area */
  58. np = of_find_node_by_name(NULL, "bcsr");
  59. if (np != 0) {
  60. struct resource res;
  61. of_address_to_resource(np, 0, &res);
  62. bcsr_regs = ioremap(res.start, res.end - res.start +1);
  63. of_node_put(np);
  64. }
  65. #ifdef CONFIG_PCI
  66. for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  67. mpc83xx_add_bridge(np);
  68. #endif
  69. #ifdef CONFIG_QUICC_ENGINE
  70. qe_reset();
  71. if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
  72. par_io_init(np);
  73. of_node_put(np);
  74. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  75. par_io_of_config(np);
  76. }
  77. if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
  78. != NULL){
  79. /* Reset the Ethernet PHYs */
  80. #define BCSR8_FETH_RST 0x50
  81. bcsr_regs[8] &= ~BCSR8_FETH_RST;
  82. udelay(1000);
  83. bcsr_regs[8] |= BCSR8_FETH_RST;
  84. iounmap(bcsr_regs);
  85. of_node_put(np);
  86. }
  87. #endif /* CONFIG_QUICC_ENGINE */
  88. }
  89. static struct of_device_id mpc832x_ids[] = {
  90. { .type = "soc", },
  91. { .compatible = "soc", },
  92. { .type = "qe", },
  93. {},
  94. };
  95. static int __init mpc832x_declare_of_platform_devices(void)
  96. {
  97. if (!machine_is(mpc832x_mds))
  98. return 0;
  99. /* Publish the QE devices */
  100. of_platform_bus_probe(NULL, mpc832x_ids, NULL);
  101. return 0;
  102. }
  103. device_initcall(mpc832x_declare_of_platform_devices);
  104. static void __init mpc832x_sys_init_IRQ(void)
  105. {
  106. struct device_node *np;
  107. np = of_find_node_by_type(NULL, "ipic");
  108. if (!np)
  109. return;
  110. ipic_init(np, 0);
  111. /* Initialize the default interrupt mapping priorities,
  112. * in case the boot rom changed something on us.
  113. */
  114. ipic_set_default_priority();
  115. of_node_put(np);
  116. #ifdef CONFIG_QUICC_ENGINE
  117. np = of_find_node_by_type(NULL, "qeic");
  118. if (!np)
  119. return;
  120. qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
  121. of_node_put(np);
  122. #endif /* CONFIG_QUICC_ENGINE */
  123. }
  124. /*
  125. * Called very early, MMU is off, device-tree isn't unflattened
  126. */
  127. static int __init mpc832x_sys_probe(void)
  128. {
  129. unsigned long root = of_get_flat_dt_root();
  130. return of_flat_dt_is_compatible(root, "MPC832xMDS");
  131. }
  132. define_machine(mpc832x_mds) {
  133. .name = "MPC832x MDS",
  134. .probe = mpc832x_sys_probe,
  135. .setup_arch = mpc832x_sys_setup_arch,
  136. .init_IRQ = mpc832x_sys_init_IRQ,
  137. .get_irq = ipic_get_irq,
  138. .restart = mpc83xx_restart,
  139. .time_init = mpc83xx_time_init,
  140. .calibrate_decr = generic_calibrate_decr,
  141. .progress = udbg_progress,
  142. };