km83xx.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 <linux/atomic.h>
  29. #include <asm/time.h>
  30. #include <asm/io.h>
  31. #include <asm/machdep.h>
  32. #include <asm/ipic.h>
  33. #include <asm/irq.h>
  34. #include <asm/prom.h>
  35. #include <asm/udbg.h>
  36. #include <sysdev/fsl_soc.h>
  37. #include <sysdev/fsl_pci.h>
  38. #include <asm/qe.h>
  39. #include <asm/qe_ic.h>
  40. #include "mpc83xx.h"
  41. #define SVR_REV(svr) (((svr) >> 0) & 0xFFFF) /* Revision field */
  42. /* ************************************************************************
  43. *
  44. * Setup the architecture
  45. *
  46. */
  47. static void __init mpc83xx_km_setup_arch(void)
  48. {
  49. #ifdef CONFIG_QUICC_ENGINE
  50. struct device_node *np;
  51. #endif
  52. if (ppc_md.progress)
  53. ppc_md.progress("kmpbec83xx_setup_arch()", 0);
  54. mpc83xx_setup_pci();
  55. #ifdef CONFIG_QUICC_ENGINE
  56. qe_reset();
  57. np = of_find_node_by_name(NULL, "par_io");
  58. if (np != NULL) {
  59. par_io_init(np);
  60. of_node_put(np);
  61. for_each_node_by_name(np, "spi")
  62. par_io_of_config(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, resource_size(&res));
  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. machine_device_initcall(mpc83xx_km, mpc83xx_declare_of_platform_devices);
  108. /* list of the supported boards */
  109. static char *board[] __initdata = {
  110. "Keymile,KMETER1",
  111. "Keymile,kmpbec8321",
  112. NULL
  113. };
  114. /*
  115. * Called very early, MMU is off, device-tree isn't unflattened
  116. */
  117. static int __init mpc83xx_km_probe(void)
  118. {
  119. unsigned long node = of_get_flat_dt_root();
  120. int i = 0;
  121. while (board[i]) {
  122. if (of_flat_dt_is_compatible(node, board[i]))
  123. break;
  124. i++;
  125. }
  126. return (board[i] != NULL);
  127. }
  128. define_machine(mpc83xx_km) {
  129. .name = "mpc83xx-km-platform",
  130. .probe = mpc83xx_km_probe,
  131. .setup_arch = mpc83xx_km_setup_arch,
  132. .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ,
  133. .get_irq = ipic_get_irq,
  134. .restart = mpc83xx_restart,
  135. .time_init = mpc83xx_time_init,
  136. .calibrate_decr = generic_calibrate_decr,
  137. .progress = udbg_progress,
  138. };