mpc836x_mds.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
  3. *
  4. * Author: Li Yang <LeoLi@freescale.com>
  5. * Yin Olivia <Hong-hua.Yin@freescale.com>
  6. *
  7. * Description:
  8. * MPC8360E MDS board specific routines.
  9. *
  10. * Changelog:
  11. * Jun 21, 2006 Initial version
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. */
  18. #include <linux/stddef.h>
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/errno.h>
  22. #include <linux/reboot.h>
  23. #include <linux/pci.h>
  24. #include <linux/kdev_t.h>
  25. #include <linux/major.h>
  26. #include <linux/console.h>
  27. #include <linux/delay.h>
  28. #include <linux/seq_file.h>
  29. #include <linux/root_dev.h>
  30. #include <linux/initrd.h>
  31. #include <asm/of_device.h>
  32. #include <asm/of_platform.h>
  33. #include <asm/system.h>
  34. #include <asm/atomic.h>
  35. #include <asm/time.h>
  36. #include <asm/io.h>
  37. #include <asm/machdep.h>
  38. #include <asm/ipic.h>
  39. #include <asm/bootinfo.h>
  40. #include <asm/irq.h>
  41. #include <asm/prom.h>
  42. #include <asm/udbg.h>
  43. #include <sysdev/fsl_soc.h>
  44. #include <asm/qe.h>
  45. #include <asm/qe_ic.h>
  46. #include "mpc83xx.h"
  47. #undef DEBUG
  48. #ifdef DEBUG
  49. #define DBG(fmt...) udbg_printf(fmt)
  50. #else
  51. #define DBG(fmt...)
  52. #endif
  53. static u8 *bcsr_regs = NULL;
  54. /* ************************************************************************
  55. *
  56. * Setup the architecture
  57. *
  58. */
  59. static void __init mpc836x_mds_setup_arch(void)
  60. {
  61. struct device_node *np;
  62. if (ppc_md.progress)
  63. ppc_md.progress("mpc836x_mds_setup_arch()", 0);
  64. /* Map BCSR area */
  65. np = of_find_node_by_name(NULL, "bcsr");
  66. if (np != 0) {
  67. struct resource res;
  68. of_address_to_resource(np, 0, &res);
  69. bcsr_regs = ioremap(res.start, res.end - res.start +1);
  70. of_node_put(np);
  71. }
  72. #ifdef CONFIG_PCI
  73. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  74. mpc83xx_add_bridge(np);
  75. ppc_md.pci_exclude_device = mpc83xx_exclude_device;
  76. #endif
  77. #ifdef CONFIG_QUICC_ENGINE
  78. qe_reset();
  79. if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
  80. par_io_init(np);
  81. of_node_put(np);
  82. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  83. par_io_of_config(np);
  84. }
  85. if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
  86. != NULL){
  87. /* Reset the Ethernet PHY */
  88. bcsr_regs[9] &= ~0x20;
  89. udelay(1000);
  90. bcsr_regs[9] |= 0x20;
  91. iounmap(bcsr_regs);
  92. of_node_put(np);
  93. }
  94. #endif /* CONFIG_QUICC_ENGINE */
  95. }
  96. static struct of_device_id mpc836x_ids[] = {
  97. { .type = "soc", },
  98. { .compatible = "soc", },
  99. { .type = "qe", },
  100. { .type = "mdio", },
  101. {},
  102. };
  103. static int __init mpc836x_declare_of_platform_devices(void)
  104. {
  105. if (!machine_is(mpc836x_mds))
  106. return 0;
  107. /* Publish the QE devices */
  108. of_platform_bus_probe(NULL, mpc836x_ids, NULL);
  109. return 0;
  110. }
  111. device_initcall(mpc836x_declare_of_platform_devices);
  112. static void __init mpc836x_mds_init_IRQ(void)
  113. {
  114. struct device_node *np;
  115. np = of_find_node_by_type(NULL, "ipic");
  116. if (!np)
  117. return;
  118. ipic_init(np, 0);
  119. /* Initialize the default interrupt mapping priorities,
  120. * in case the boot rom changed something on us.
  121. */
  122. ipic_set_default_priority();
  123. of_node_put(np);
  124. #ifdef CONFIG_QUICC_ENGINE
  125. np = of_find_node_by_type(NULL, "qeic");
  126. if (!np)
  127. return;
  128. qe_ic_init(np, 0);
  129. of_node_put(np);
  130. #endif /* CONFIG_QUICC_ENGINE */
  131. }
  132. #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
  133. extern ulong ds1374_get_rtc_time(void);
  134. extern int ds1374_set_rtc_time(ulong);
  135. static int __init mpc8360_rtc_hookup(void)
  136. {
  137. struct timespec tv;
  138. if (!machine_is(mpc836x_mds))
  139. return 0;
  140. ppc_md.get_rtc_time = ds1374_get_rtc_time;
  141. ppc_md.set_rtc_time = ds1374_set_rtc_time;
  142. tv.tv_nsec = 0;
  143. tv.tv_sec = (ppc_md.get_rtc_time) ();
  144. do_settimeofday(&tv);
  145. return 0;
  146. }
  147. late_initcall(mpc8360_rtc_hookup);
  148. #endif
  149. /*
  150. * Called very early, MMU is off, device-tree isn't unflattened
  151. */
  152. static int __init mpc836x_mds_probe(void)
  153. {
  154. unsigned long root = of_get_flat_dt_root();
  155. return of_flat_dt_is_compatible(root, "MPC836xMDS");
  156. }
  157. define_machine(mpc836x_mds) {
  158. .name = "MPC836x MDS",
  159. .probe = mpc836x_mds_probe,
  160. .setup_arch = mpc836x_mds_setup_arch,
  161. .init_IRQ = mpc836x_mds_init_IRQ,
  162. .get_irq = ipic_get_irq,
  163. .restart = mpc83xx_restart,
  164. .time_init = mpc83xx_time_init,
  165. .calibrate_decr = generic_calibrate_decr,
  166. .progress = udbg_progress,
  167. };