mpc832x_mds.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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/bootinfo.h>
  34. #include <asm/irq.h>
  35. #include <asm/prom.h>
  36. #include <asm/udbg.h>
  37. #include <sysdev/fsl_soc.h>
  38. #include <asm/qe.h>
  39. #include <asm/qe_ic.h>
  40. #include "mpc83xx.h"
  41. #include "mpc832x_mds.h"
  42. #undef DEBUG
  43. #ifdef DEBUG
  44. #define DBG(fmt...) udbg_printf(fmt)
  45. #else
  46. #define DBG(fmt...)
  47. #endif
  48. #ifndef CONFIG_PCI
  49. unsigned long isa_io_base = 0;
  50. unsigned long isa_mem_base = 0;
  51. #endif
  52. static u8 *bcsr_regs = NULL;
  53. /* ************************************************************************
  54. *
  55. * Setup the architecture
  56. *
  57. */
  58. static void __init mpc832x_sys_setup_arch(void)
  59. {
  60. struct device_node *np;
  61. if (ppc_md.progress)
  62. ppc_md.progress("mpc832x_sys_setup_arch()", 0);
  63. /* Map BCSR area */
  64. np = of_find_node_by_name(NULL, "bcsr");
  65. if (np != 0) {
  66. struct resource res;
  67. of_address_to_resource(np, 0, &res);
  68. bcsr_regs = ioremap(res.start, res.end - res.start +1);
  69. of_node_put(np);
  70. }
  71. #ifdef CONFIG_PCI
  72. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  73. add_bridge(np);
  74. ppc_md.pci_exclude_device = mpc83xx_exclude_device;
  75. #endif
  76. #ifdef CONFIG_QUICC_ENGINE
  77. qe_reset();
  78. if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
  79. par_io_init(np);
  80. of_node_put(np);
  81. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  82. par_io_of_config(np);
  83. }
  84. if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
  85. != NULL){
  86. /* Reset the Ethernet PHY */
  87. bcsr_regs[9] &= ~0x20;
  88. udelay(1000);
  89. bcsr_regs[9] |= 0x20;
  90. iounmap(bcsr_regs);
  91. of_node_put(np);
  92. }
  93. #endif /* CONFIG_QUICC_ENGINE */
  94. }
  95. static int __init mpc832x_declare_of_platform_devices(void)
  96. {
  97. struct device_node *np;
  98. if (!machine_is(mpc832x_mds))
  99. return 0;
  100. for (np = NULL; (np = of_find_compatible_node(np, "network",
  101. "ucc_geth")) != NULL;) {
  102. int ucc_num;
  103. char bus_id[BUS_ID_SIZE];
  104. ucc_num = *((uint *) get_property(np, "device-id", NULL)) - 1;
  105. snprintf(bus_id, BUS_ID_SIZE, "ucc_geth.%u", ucc_num);
  106. of_platform_device_create(np, bus_id, NULL);
  107. }
  108. return 0;
  109. }
  110. device_initcall(mpc832x_declare_of_platform_devices);
  111. static void __init mpc832x_sys_init_IRQ(void)
  112. {
  113. struct device_node *np;
  114. np = of_find_node_by_type(NULL, "ipic");
  115. if (!np)
  116. return;
  117. ipic_init(np, 0);
  118. /* Initialize the default interrupt mapping priorities,
  119. * in case the boot rom changed something on us.
  120. */
  121. ipic_set_default_priority();
  122. of_node_put(np);
  123. #ifdef CONFIG_QUICC_ENGINE
  124. np = of_find_node_by_type(NULL, "qeic");
  125. if (!np)
  126. return;
  127. qe_ic_init(np, 0);
  128. of_node_put(np);
  129. #endif /* CONFIG_QUICC_ENGINE */
  130. }
  131. #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
  132. extern ulong ds1374_get_rtc_time(void);
  133. extern int ds1374_set_rtc_time(ulong);
  134. static int __init mpc832x_rtc_hookup(void)
  135. {
  136. struct timespec tv;
  137. if (!machine_is(mpc832x_mds))
  138. return 0;
  139. ppc_md.get_rtc_time = ds1374_get_rtc_time;
  140. ppc_md.set_rtc_time = ds1374_set_rtc_time;
  141. tv.tv_nsec = 0;
  142. tv.tv_sec = (ppc_md.get_rtc_time) ();
  143. do_settimeofday(&tv);
  144. return 0;
  145. }
  146. late_initcall(mpc832x_rtc_hookup);
  147. #endif
  148. /*
  149. * Called very early, MMU is off, device-tree isn't unflattened
  150. */
  151. static int __init mpc832x_sys_probe(void)
  152. {
  153. unsigned long root = of_get_flat_dt_root();
  154. return of_flat_dt_is_compatible(root, "MPC832xMDS");
  155. }
  156. define_machine(mpc832x_mds) {
  157. .name = "MPC832x MDS",
  158. .probe = mpc832x_sys_probe,
  159. .setup_arch = mpc832x_sys_setup_arch,
  160. .init_IRQ = mpc832x_sys_init_IRQ,
  161. .get_irq = ipic_get_irq,
  162. .restart = mpc83xx_restart,
  163. .time_init = mpc83xx_time_init,
  164. .calibrate_decr = generic_calibrate_decr,
  165. .progress = udbg_progress,
  166. };