misc.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 <asm/io.h>
  15. #include <asm/hw_irq.h>
  16. #include <asm/ipic.h>
  17. #include <asm/qe_ic.h>
  18. #include <sysdev/fsl_soc.h>
  19. #include "mpc83xx.h"
  20. static __be32 __iomem *restart_reg_base;
  21. static int __init mpc83xx_restart_init(void)
  22. {
  23. /* map reset restart_reg_baseister space */
  24. restart_reg_base = ioremap(get_immrbase() + 0x900, 0xff);
  25. return 0;
  26. }
  27. arch_initcall(mpc83xx_restart_init);
  28. void mpc83xx_restart(char *cmd)
  29. {
  30. #define RST_OFFSET 0x00000900
  31. #define RST_PROT_REG 0x00000018
  32. #define RST_CTRL_REG 0x0000001c
  33. local_irq_disable();
  34. if (restart_reg_base) {
  35. /* enable software reset "RSTE" */
  36. out_be32(restart_reg_base + (RST_PROT_REG >> 2), 0x52535445);
  37. /* set software hard reset */
  38. out_be32(restart_reg_base + (RST_CTRL_REG >> 2), 0x2);
  39. } else {
  40. printk (KERN_EMERG "Error: Restart registers not mapped, spinning!\n");
  41. }
  42. for (;;) ;
  43. }
  44. long __init mpc83xx_time_init(void)
  45. {
  46. #define SPCR_OFFSET 0x00000110
  47. #define SPCR_TBEN 0x00400000
  48. __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4);
  49. __be32 tmp;
  50. tmp = in_be32(spcr);
  51. out_be32(spcr, tmp | SPCR_TBEN);
  52. iounmap(spcr);
  53. return 0;
  54. }
  55. void __init mpc83xx_ipic_init_IRQ(void)
  56. {
  57. struct device_node *np;
  58. /* looking for fsl,pq2pro-pic which is asl compatible with fsl,ipic */
  59. np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
  60. if (!np)
  61. np = of_find_node_by_type(NULL, "ipic");
  62. if (!np)
  63. return;
  64. ipic_init(np, 0);
  65. of_node_put(np);
  66. /* Initialize the default interrupt mapping priorities,
  67. * in case the boot rom changed something on us.
  68. */
  69. ipic_set_default_priority();
  70. }
  71. #ifdef CONFIG_QUICC_ENGINE
  72. void __init mpc83xx_qe_init_IRQ(void)
  73. {
  74. struct device_node *np;
  75. np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  76. if (!np) {
  77. np = of_find_node_by_type(NULL, "qeic");
  78. if (!np)
  79. return;
  80. }
  81. qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
  82. of_node_put(np);
  83. }
  84. void __init mpc83xx_ipic_and_qe_init_IRQ(void)
  85. {
  86. mpc83xx_ipic_init_IRQ();
  87. mpc83xx_qe_init_IRQ();
  88. }
  89. #endif /* CONFIG_QUICC_ENGINE */
  90. static struct of_device_id __initdata of_bus_ids[] = {
  91. { .type = "soc", },
  92. { .compatible = "soc", },
  93. { .compatible = "simple-bus" },
  94. { .compatible = "gianfar" },
  95. { .compatible = "gpio-leds", },
  96. { .type = "qe", },
  97. { .compatible = "fsl,qe", },
  98. {},
  99. };
  100. int __init mpc83xx_declare_of_platform_devices(void)
  101. {
  102. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  103. return 0;
  104. }