mpc8360e_pb.c 5.0 KB

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