mpc832x_mds.c 4.8 KB

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