misc.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * misc setup functions for MPC83xx
  3. *
  4. * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/stddef.h>
  12. #include <linux/kernel.h>
  13. #include <linux/of_platform.h>
  14. #include <linux/pci.h>
  15. #include <asm/io.h>
  16. #include <asm/hw_irq.h>
  17. #include <asm/ipic.h>
  18. #include <asm/qe_ic.h>
  19. #include <sysdev/fsl_soc.h>
  20. #include <sysdev/fsl_pci.h>
  21. #include "mpc83xx.h"
  22. static __be32 __iomem *restart_reg_base;
  23. static int __init mpc83xx_restart_init(void)
  24. {
  25. /* map reset restart_reg_baseister space */
  26. restart_reg_base = ioremap(get_immrbase() + 0x900, 0xff);
  27. return 0;
  28. }
  29. arch_initcall(mpc83xx_restart_init);
  30. void mpc83xx_restart(char *cmd)
  31. {
  32. #define RST_OFFSET 0x00000900
  33. #define RST_PROT_REG 0x00000018
  34. #define RST_CTRL_REG 0x0000001c
  35. local_irq_disable();
  36. if (restart_reg_base) {
  37. /* enable software reset "RSTE" */
  38. out_be32(restart_reg_base + (RST_PROT_REG >> 2), 0x52535445);
  39. /* set software hard reset */
  40. out_be32(restart_reg_base + (RST_CTRL_REG >> 2), 0x2);
  41. } else {
  42. printk (KERN_EMERG "Error: Restart registers not mapped, spinning!\n");
  43. }
  44. for (;;) ;
  45. }
  46. long __init mpc83xx_time_init(void)
  47. {
  48. #define SPCR_OFFSET 0x00000110
  49. #define SPCR_TBEN 0x00400000
  50. __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4);
  51. __be32 tmp;
  52. tmp = in_be32(spcr);
  53. out_be32(spcr, tmp | SPCR_TBEN);
  54. iounmap(spcr);
  55. return 0;
  56. }
  57. void __init mpc83xx_ipic_init_IRQ(void)
  58. {
  59. struct device_node *np;
  60. /* looking for fsl,pq2pro-pic which is asl compatible with fsl,ipic */
  61. np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
  62. if (!np)
  63. np = of_find_node_by_type(NULL, "ipic");
  64. if (!np)
  65. return;
  66. ipic_init(np, 0);
  67. of_node_put(np);
  68. /* Initialize the default interrupt mapping priorities,
  69. * in case the boot rom changed something on us.
  70. */
  71. ipic_set_default_priority();
  72. }
  73. #ifdef CONFIG_QUICC_ENGINE
  74. void __init mpc83xx_qe_init_IRQ(void)
  75. {
  76. struct device_node *np;
  77. np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  78. if (!np) {
  79. np = of_find_node_by_type(NULL, "qeic");
  80. if (!np)
  81. return;
  82. }
  83. qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
  84. of_node_put(np);
  85. }
  86. void __init mpc83xx_ipic_and_qe_init_IRQ(void)
  87. {
  88. mpc83xx_ipic_init_IRQ();
  89. mpc83xx_qe_init_IRQ();
  90. }
  91. #endif /* CONFIG_QUICC_ENGINE */
  92. static const struct of_device_id of_bus_ids[] __initconst = {
  93. { .type = "soc", },
  94. { .compatible = "soc", },
  95. { .compatible = "simple-bus" },
  96. { .compatible = "gianfar" },
  97. { .compatible = "gpio-leds", },
  98. { .type = "qe", },
  99. { .compatible = "fsl,qe", },
  100. {},
  101. };
  102. int __init mpc83xx_declare_of_platform_devices(void)
  103. {
  104. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  105. return 0;
  106. }
  107. #ifdef CONFIG_PCI
  108. void __init mpc83xx_setup_pci(void)
  109. {
  110. struct device_node *np;
  111. for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  112. mpc83xx_add_bridge(np);
  113. for_each_compatible_node(np, "pci", "fsl,mpc8314-pcie")
  114. mpc83xx_add_bridge(np);
  115. }
  116. #endif