mpc832x_mds.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. np = of_find_node_by_type(NULL, "cpu");
  64. if (np != 0) {
  65. unsigned int *fp =
  66. (int *)get_property(np, "clock-frequency", NULL);
  67. if (fp != 0)
  68. loops_per_jiffy = *fp / HZ;
  69. else
  70. loops_per_jiffy = 50000000 / HZ;
  71. of_node_put(np);
  72. }
  73. /* Map BCSR area */
  74. np = of_find_node_by_name(NULL, "bcsr");
  75. if (np != 0) {
  76. struct resource res;
  77. of_address_to_resource(np, 0, &res);
  78. bcsr_regs = ioremap(res.start, res.end - res.start +1);
  79. of_node_put(np);
  80. }
  81. #ifdef CONFIG_PCI
  82. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  83. add_bridge(np);
  84. ppc_md.pci_exclude_device = mpc83xx_exclude_device;
  85. #endif
  86. #ifdef CONFIG_QUICC_ENGINE
  87. qe_reset();
  88. if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
  89. par_io_init(np);
  90. of_node_put(np);
  91. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  92. par_io_of_config(np);
  93. }
  94. if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
  95. != NULL){
  96. /* Reset the Ethernet PHY */
  97. bcsr_regs[9] &= ~0x20;
  98. udelay(1000);
  99. bcsr_regs[9] |= 0x20;
  100. iounmap(bcsr_regs);
  101. of_node_put(np);
  102. }
  103. #endif /* CONFIG_QUICC_ENGINE */
  104. #ifdef CONFIG_BLK_DEV_INITRD
  105. if (initrd_start)
  106. ROOT_DEV = Root_RAM0;
  107. else
  108. #endif
  109. #ifdef CONFIG_ROOT_NFS
  110. ROOT_DEV = Root_NFS;
  111. #else
  112. ROOT_DEV = Root_HDA1;
  113. #endif
  114. }
  115. static int __init mpc832x_declare_of_platform_devices(void)
  116. {
  117. struct device_node *np;
  118. if (!machine_is(mpc832x_mds))
  119. return 0;
  120. for (np = NULL; (np = of_find_compatible_node(np, "network",
  121. "ucc_geth")) != NULL;) {
  122. int ucc_num;
  123. char bus_id[BUS_ID_SIZE];
  124. ucc_num = *((uint *) get_property(np, "device-id", NULL)) - 1;
  125. snprintf(bus_id, BUS_ID_SIZE, "ucc_geth.%u", ucc_num);
  126. of_platform_device_create(np, bus_id, NULL);
  127. }
  128. return 0;
  129. }
  130. device_initcall(mpc832x_declare_of_platform_devices);
  131. static void __init mpc832x_sys_init_IRQ(void)
  132. {
  133. struct device_node *np;
  134. np = of_find_node_by_type(NULL, "ipic");
  135. if (!np)
  136. return;
  137. ipic_init(np, 0);
  138. /* Initialize the default interrupt mapping priorities,
  139. * in case the boot rom changed something on us.
  140. */
  141. ipic_set_default_priority();
  142. of_node_put(np);
  143. #ifdef CONFIG_QUICC_ENGINE
  144. np = of_find_node_by_type(NULL, "qeic");
  145. if (!np)
  146. return;
  147. qe_ic_init(np, 0);
  148. of_node_put(np);
  149. #endif /* CONFIG_QUICC_ENGINE */
  150. }
  151. #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
  152. extern ulong ds1374_get_rtc_time(void);
  153. extern int ds1374_set_rtc_time(ulong);
  154. static int __init mpc832x_rtc_hookup(void)
  155. {
  156. struct timespec tv;
  157. if (!machine_is(mpc832x_mds))
  158. return 0;
  159. ppc_md.get_rtc_time = ds1374_get_rtc_time;
  160. ppc_md.set_rtc_time = ds1374_set_rtc_time;
  161. tv.tv_nsec = 0;
  162. tv.tv_sec = (ppc_md.get_rtc_time) ();
  163. do_settimeofday(&tv);
  164. return 0;
  165. }
  166. late_initcall(mpc832x_rtc_hookup);
  167. #endif
  168. /*
  169. * Called very early, MMU is off, device-tree isn't unflattened
  170. */
  171. static int __init mpc832x_sys_probe(void)
  172. {
  173. unsigned long root = of_get_flat_dt_root();
  174. return of_flat_dt_is_compatible(root, "MPC832xMDS");
  175. }
  176. define_machine(mpc832x_mds) {
  177. .name = "MPC832x MDS",
  178. .probe = mpc832x_sys_probe,
  179. .setup_arch = mpc832x_sys_setup_arch,
  180. .init_IRQ = mpc832x_sys_init_IRQ,
  181. .get_irq = ipic_get_irq,
  182. .restart = mpc83xx_restart,
  183. .time_init = mpc83xx_time_init,
  184. .calibrate_decr = generic_calibrate_decr,
  185. .progress = udbg_progress,
  186. };