km83xx.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Copyright 2008-2011 DENX Software Engineering GmbH
  3. * Author: Heiko Schocher <hs@denx.de>
  4. *
  5. * Description:
  6. * Keymile KMETER1 board specific routines.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #include <linux/stddef.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/errno.h>
  17. #include <linux/reboot.h>
  18. #include <linux/pci.h>
  19. #include <linux/kdev_t.h>
  20. #include <linux/major.h>
  21. #include <linux/console.h>
  22. #include <linux/delay.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/root_dev.h>
  25. #include <linux/initrd.h>
  26. #include <linux/of_platform.h>
  27. #include <linux/of_device.h>
  28. #include <asm/system.h>
  29. #include <asm/atomic.h>
  30. #include <asm/time.h>
  31. #include <asm/io.h>
  32. #include <asm/machdep.h>
  33. #include <asm/ipic.h>
  34. #include <asm/irq.h>
  35. #include <asm/prom.h>
  36. #include <asm/udbg.h>
  37. #include <sysdev/fsl_soc.h>
  38. #include <sysdev/fsl_pci.h>
  39. #include <asm/qe.h>
  40. #include <asm/qe_ic.h>
  41. #include "mpc83xx.h"
  42. #define SVR_REV(svr) (((svr) >> 0) & 0xFFFF) /* Revision field */
  43. /* ************************************************************************
  44. *
  45. * Setup the architecture
  46. *
  47. */
  48. static void __init mpc83xx_km_setup_arch(void)
  49. {
  50. struct device_node *np;
  51. if (ppc_md.progress)
  52. ppc_md.progress("kmpbec83xx_setup_arch()", 0);
  53. #ifdef CONFIG_PCI
  54. for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  55. mpc83xx_add_bridge(np);
  56. #endif
  57. #ifdef CONFIG_QUICC_ENGINE
  58. qe_reset();
  59. np = of_find_node_by_name(NULL, "par_io");
  60. if (np != NULL) {
  61. par_io_init(np);
  62. of_node_put(np);
  63. for_each_node_by_name(np, "spi")
  64. par_io_of_config(np);
  65. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  66. par_io_of_config(np);
  67. }
  68. np = of_find_compatible_node(NULL, "network", "ucc_geth");
  69. if (np != NULL) {
  70. uint svid;
  71. /* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */
  72. svid = mfspr(SPRN_SVR);
  73. if (SVR_REV(svid) == 0x0021) {
  74. struct device_node *np_par;
  75. struct resource res;
  76. void __iomem *base;
  77. int ret;
  78. np_par = of_find_node_by_name(NULL, "par_io");
  79. if (np_par == NULL) {
  80. printk(KERN_WARNING "%s couldn;t find par_io node\n",
  81. __func__);
  82. return;
  83. }
  84. /* Map Parallel I/O ports registers */
  85. ret = of_address_to_resource(np_par, 0, &res);
  86. if (ret) {
  87. printk(KERN_WARNING "%s couldn;t map par_io registers\n",
  88. __func__);
  89. return;
  90. }
  91. base = ioremap(res.start, res.end - res.start + 1);
  92. /*
  93. * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
  94. * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
  95. */
  96. setbits32((base + 0xa8), 0x0c003000);
  97. /*
  98. * IMMR + 0x14AC[20:27] = 10101010
  99. * (data delay for both UCC's)
  100. */
  101. clrsetbits_be32((base + 0xac), 0xff0, 0xaa0);
  102. iounmap(base);
  103. of_node_put(np_par);
  104. }
  105. of_node_put(np);
  106. }
  107. #endif /* CONFIG_QUICC_ENGINE */
  108. }
  109. static struct of_device_id kmpbec83xx_ids[] = {
  110. { .type = "soc", },
  111. { .compatible = "soc", },
  112. { .compatible = "simple-bus", },
  113. { .type = "qe", },
  114. { .compatible = "fsl,qe", },
  115. {},
  116. };
  117. static int __init kmeter_declare_of_platform_devices(void)
  118. {
  119. /* Publish the QE devices */
  120. of_platform_bus_probe(NULL, kmpbec83xx_ids, NULL);
  121. return 0;
  122. }
  123. machine_device_initcall(mpc83xx_km, kmeter_declare_of_platform_devices);
  124. static void __init mpc83xx_km_init_IRQ(void)
  125. {
  126. struct device_node *np;
  127. np = of_find_compatible_node(NULL, NULL, "fsl,pq2pro-pic");
  128. if (!np) {
  129. np = of_find_node_by_type(NULL, "ipic");
  130. if (!np)
  131. return;
  132. }
  133. ipic_init(np, 0);
  134. /* Initialize the default interrupt mapping priorities,
  135. * in case the boot rom changed something on us.
  136. */
  137. ipic_set_default_priority();
  138. of_node_put(np);
  139. #ifdef CONFIG_QUICC_ENGINE
  140. np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  141. if (!np) {
  142. np = of_find_node_by_type(NULL, "qeic");
  143. if (!np)
  144. return;
  145. }
  146. qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
  147. of_node_put(np);
  148. #endif /* CONFIG_QUICC_ENGINE */
  149. }
  150. /* list of the supported boards */
  151. static char *board[] __initdata = {
  152. "Keymile,KMETER1",
  153. "Keymile,kmpbec8321",
  154. NULL
  155. };
  156. /*
  157. * Called very early, MMU is off, device-tree isn't unflattened
  158. */
  159. static int __init mpc83xx_km_probe(void)
  160. {
  161. unsigned long node = of_get_flat_dt_root();
  162. int i = 0;
  163. while (board[i]) {
  164. if (of_flat_dt_is_compatible(node, board[i]))
  165. break;
  166. i++;
  167. }
  168. return (board[i] != NULL);
  169. }
  170. define_machine(mpc83xx_km) {
  171. .name = "mpc83xx-km-platform",
  172. .probe = mpc83xx_km_probe,
  173. .setup_arch = mpc83xx_km_setup_arch,
  174. .init_IRQ = mpc83xx_km_init_IRQ,
  175. .get_irq = ipic_get_irq,
  176. .restart = mpc83xx_restart,
  177. .time_init = mpc83xx_time_init,
  178. .calibrate_decr = generic_calibrate_decr,
  179. .progress = udbg_progress,
  180. };