PageRenderTime 43ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/powerpc/platforms/83xx/kmeter1.c

https://bitbucket.org/abioy/linux
C | 191 lines | 132 code | 25 blank | 34 comment | 16 complexity | ed9e1d6e924828ce8334da1d5c036793 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /*
  2. * Copyright 2008 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 kmeter1_setup_arch(void)
  49. {
  50. struct device_node *np;
  51. if (ppc_md.progress)
  52. ppc_md.progress("kmeter1_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 (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  64. par_io_of_config(np);
  65. }
  66. np = of_find_compatible_node(NULL, "network", "ucc_geth");
  67. if (np != NULL) {
  68. uint svid;
  69. /* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */
  70. svid = mfspr(SPRN_SVR);
  71. if (SVR_REV(svid) == 0x0021) {
  72. struct device_node *np_par;
  73. struct resource res;
  74. void __iomem *base;
  75. int ret;
  76. np_par = of_find_node_by_name(NULL, "par_io");
  77. if (np_par == NULL) {
  78. printk(KERN_WARNING "%s couldn;t find par_io node\n",
  79. __func__);
  80. return;
  81. }
  82. /* Map Parallel I/O ports registers */
  83. ret = of_address_to_resource(np_par, 0, &res);
  84. if (ret) {
  85. printk(KERN_WARNING "%s couldn;t map par_io registers\n",
  86. __func__);
  87. return;
  88. }
  89. base = ioremap(res.start, res.end - res.start + 1);
  90. /*
  91. * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
  92. * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
  93. */
  94. setbits32((base + 0xa8), 0x0c003000);
  95. /*
  96. * IMMR + 0x14AC[20:27] = 10101010
  97. * (data delay for both UCC's)
  98. */
  99. clrsetbits_be32((base + 0xac), 0xff0, 0xaa0);
  100. iounmap(base);
  101. of_node_put(np_par);
  102. }
  103. of_node_put(np);
  104. }
  105. #endif /* CONFIG_QUICC_ENGINE */
  106. }
  107. static struct of_device_id kmeter_ids[] = {
  108. { .type = "soc", },
  109. { .compatible = "soc", },
  110. { .compatible = "simple-bus", },
  111. { .type = "qe", },
  112. { .compatible = "fsl,qe", },
  113. {},
  114. };
  115. static int __init kmeter_declare_of_platform_devices(void)
  116. {
  117. /* Publish the QE devices */
  118. of_platform_bus_probe(NULL, kmeter_ids, NULL);
  119. return 0;
  120. }
  121. machine_device_initcall(kmeter1, kmeter_declare_of_platform_devices);
  122. static void __init kmeter1_init_IRQ(void)
  123. {
  124. struct device_node *np;
  125. np = of_find_compatible_node(NULL, NULL, "fsl,pq2pro-pic");
  126. if (!np) {
  127. np = of_find_node_by_type(NULL, "ipic");
  128. if (!np)
  129. return;
  130. }
  131. ipic_init(np, 0);
  132. /* Initialize the default interrupt mapping priorities,
  133. * in case the boot rom changed something on us.
  134. */
  135. ipic_set_default_priority();
  136. of_node_put(np);
  137. #ifdef CONFIG_QUICC_ENGINE
  138. np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  139. if (!np) {
  140. np = of_find_node_by_type(NULL, "qeic");
  141. if (!np)
  142. return;
  143. }
  144. qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
  145. of_node_put(np);
  146. #endif /* CONFIG_QUICC_ENGINE */
  147. }
  148. /*
  149. * Called very early, MMU is off, device-tree isn't unflattened
  150. */
  151. static int __init kmeter1_probe(void)
  152. {
  153. unsigned long root = of_get_flat_dt_root();
  154. return of_flat_dt_is_compatible(root, "keymile,KMETER1");
  155. }
  156. define_machine(kmeter1) {
  157. .name = "KMETER1",
  158. .probe = kmeter1_probe,
  159. .setup_arch = kmeter1_setup_arch,
  160. .init_IRQ = kmeter1_init_IRQ,
  161. .get_irq = ipic_get_irq,
  162. .restart = mpc83xx_restart,
  163. .time_init = mpc83xx_time_init,
  164. .calibrate_decr = generic_calibrate_decr,
  165. .progress = udbg_progress,
  166. };