km83xx.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 <linux/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. #ifdef CONFIG_QUICC_ENGINE
  51. struct device_node *np;
  52. #endif
  53. if (ppc_md.progress)
  54. ppc_md.progress("kmpbec83xx_setup_arch()", 0);
  55. mpc83xx_setup_pci();
  56. #ifdef CONFIG_QUICC_ENGINE
  57. qe_reset();
  58. np = of_find_node_by_name(NULL, "par_io");
  59. if (np != NULL) {
  60. par_io_init(np);
  61. of_node_put(np);
  62. for_each_node_by_name(np, "spi")
  63. par_io_of_config(np);
  64. for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
  65. par_io_of_config(np);
  66. }
  67. np = of_find_compatible_node(NULL, "network", "ucc_geth");
  68. if (np != NULL) {
  69. uint svid;
  70. /* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */
  71. svid = mfspr(SPRN_SVR);
  72. if (SVR_REV(svid) == 0x0021) {
  73. struct device_node *np_par;
  74. struct resource res;
  75. void __iomem *base;
  76. int ret;
  77. np_par = of_find_node_by_name(NULL, "par_io");
  78. if (np_par == NULL) {
  79. printk(KERN_WARNING "%s couldn;t find par_io node\n",
  80. __func__);
  81. return;
  82. }
  83. /* Map Parallel I/O ports registers */
  84. ret = of_address_to_resource(np_par, 0, &res);
  85. if (ret) {
  86. printk(KERN_WARNING "%s couldn;t map par_io registers\n",
  87. __func__);
  88. return;
  89. }
  90. base = ioremap(res.start, resource_size(&res));
  91. /*
  92. * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
  93. * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
  94. */
  95. setbits32((base + 0xa8), 0x0c003000);
  96. /*
  97. * IMMR + 0x14AC[20:27] = 10101010
  98. * (data delay for both UCC's)
  99. */
  100. clrsetbits_be32((base + 0xac), 0xff0, 0xaa0);
  101. iounmap(base);
  102. of_node_put(np_par);
  103. }
  104. of_node_put(np);
  105. }
  106. #endif /* CONFIG_QUICC_ENGINE */
  107. }
  108. machine_device_initcall(mpc83xx_km, mpc83xx_declare_of_platform_devices);
  109. /* list of the supported boards */
  110. static char *board[] __initdata = {
  111. "Keymile,KMETER1",
  112. "Keymile,kmpbec8321",
  113. NULL
  114. };
  115. /*
  116. * Called very early, MMU is off, device-tree isn't unflattened
  117. */
  118. static int __init mpc83xx_km_probe(void)
  119. {
  120. unsigned long node = of_get_flat_dt_root();
  121. int i = 0;
  122. while (board[i]) {
  123. if (of_flat_dt_is_compatible(node, board[i]))
  124. break;
  125. i++;
  126. }
  127. return (board[i] != NULL);
  128. }
  129. define_machine(mpc83xx_km) {
  130. .name = "mpc83xx-km-platform",
  131. .probe = mpc83xx_km_probe,
  132. .setup_arch = mpc83xx_km_setup_arch,
  133. .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ,
  134. .get_irq = ipic_get_irq,
  135. .restart = mpc83xx_restart,
  136. .time_init = mpc83xx_time_init,
  137. .calibrate_decr = generic_calibrate_decr,
  138. .progress = udbg_progress,
  139. };