mpc8360e_pb.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 PB 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/system.h>
  32. #include <asm/atomic.h>
  33. #include <asm/time.h>
  34. #include <asm/io.h>
  35. #include <asm/machdep.h>
  36. #include <asm/ipic.h>
  37. #include <asm/bootinfo.h>
  38. #include <asm/irq.h>
  39. #include <asm/prom.h>
  40. #include <asm/udbg.h>
  41. #include <sysdev/fsl_soc.h>
  42. #include <asm/qe.h>
  43. #include <asm/qe_ic.h>
  44. #include "mpc83xx.h"
  45. #undef DEBUG
  46. #ifdef DEBUG
  47. #define DBG(fmt...) udbg_printf(fmt)
  48. #else
  49. #define DBG(fmt...)
  50. #endif
  51. #ifndef CONFIG_PCI
  52. unsigned long isa_io_base = 0;
  53. unsigned long isa_mem_base = 0;
  54. #endif
  55. static u8 *bcsr_regs = NULL;
  56. u8 *get_bcsr(void)
  57. {
  58. return bcsr_regs;
  59. }
  60. /* ************************************************************************
  61. *
  62. * Setup the architecture
  63. *
  64. */
  65. static void __init mpc8360_sys_setup_arch(void)
  66. {
  67. struct device_node *np;
  68. if (ppc_md.progress)
  69. ppc_md.progress("mpc8360_sys_setup_arch()", 0);
  70. np = of_find_node_by_type(NULL, "cpu");
  71. if (np != 0) {
  72. const unsigned int *fp =
  73. get_property(np, "clock-frequency", NULL);
  74. if (fp != 0)
  75. loops_per_jiffy = *fp / HZ;
  76. else
  77. loops_per_jiffy = 50000000 / HZ;
  78. of_node_put(np);
  79. }
  80. /* Map BCSR area */
  81. np = of_find_node_by_name(NULL, "bcsr");
  82. if (np != 0) {
  83. struct resource res;
  84. of_address_to_resource(np, 0, &res);
  85. bcsr_regs = ioremap(res.start, res.end - res.start +1);
  86. of_node_put(np);
  87. }
  88. #ifdef CONFIG_PCI
  89. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  90. add_bridge(np);
  91. ppc_md.pci_swizzle = common_swizzle;
  92. ppc_md.pci_exclude_device = mpc83xx_exclude_device;
  93. #endif
  94. #ifdef CONFIG_QUICC_ENGINE
  95. qe_reset();
  96. if ((np = of_find_node_by_name(np, "par_io")) != NULL) {
  97. par_io_init(np);
  98. of_node_put(np);
  99. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  100. par_io_of_config(np);
  101. }
  102. if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
  103. != NULL){
  104. /* Reset the Ethernet PHY */
  105. bcsr_regs[9] &= ~0x20;
  106. udelay(1000);
  107. bcsr_regs[9] |= 0x20;
  108. iounmap(bcsr_regs);
  109. of_node_put(np);
  110. }
  111. #endif /* CONFIG_QUICC_ENGINE */
  112. #ifdef CONFIG_BLK_DEV_INITRD
  113. if (initrd_start)
  114. ROOT_DEV = Root_RAM0;
  115. else
  116. #endif
  117. #ifdef CONFIG_ROOT_NFS
  118. ROOT_DEV = Root_NFS;
  119. #else
  120. ROOT_DEV = Root_HDA1;
  121. #endif
  122. }
  123. void __init mpc8360_sys_init_IRQ(void)
  124. {
  125. struct device_node *np;
  126. np = of_find_node_by_type(NULL, "ipic");
  127. if (!np)
  128. return;
  129. ipic_init(np, 0);
  130. /* Initialize the default interrupt mapping priorities,
  131. * in case the boot rom changed something on us.
  132. */
  133. ipic_set_default_priority();
  134. of_node_put(np);
  135. #ifdef CONFIG_QUICC_ENGINE
  136. np = of_find_node_by_type(NULL, "qeic");
  137. if (!np)
  138. return;
  139. qe_ic_init(np, 0);
  140. of_node_put(np);
  141. #endif /* CONFIG_QUICC_ENGINE */
  142. }
  143. #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
  144. extern ulong ds1374_get_rtc_time(void);
  145. extern int ds1374_set_rtc_time(ulong);
  146. static int __init mpc8360_rtc_hookup(void)
  147. {
  148. struct timespec tv;
  149. ppc_md.get_rtc_time = ds1374_get_rtc_time;
  150. ppc_md.set_rtc_time = ds1374_set_rtc_time;
  151. tv.tv_nsec = 0;
  152. tv.tv_sec = (ppc_md.get_rtc_time) ();
  153. do_settimeofday(&tv);
  154. return 0;
  155. }
  156. late_initcall(mpc8360_rtc_hookup);
  157. #endif
  158. /*
  159. * Called very early, MMU is off, device-tree isn't unflattened
  160. */
  161. static int __init mpc8360_sys_probe(void)
  162. {
  163. char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
  164. "model", NULL);
  165. if (model == NULL)
  166. return 0;
  167. if (strcmp(model, "MPC8360EPB"))
  168. return 0;
  169. DBG("MPC8360EMDS-PB found\n");
  170. return 1;
  171. }
  172. define_machine(mpc8360_sys) {
  173. .name = "MPC8360E PB",
  174. .probe = mpc8360_sys_probe,
  175. .setup_arch = mpc8360_sys_setup_arch,
  176. .init_IRQ = mpc8360_sys_init_IRQ,
  177. .get_irq = ipic_get_irq,
  178. .restart = mpc83xx_restart,
  179. .time_init = mpc83xx_time_init,
  180. .calibrate_decr = generic_calibrate_decr,
  181. .progress = udbg_progress,
  182. };