misc.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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/debug.h>
  16. #include <asm/io.h>
  17. #include <asm/hw_irq.h>
  18. #include <asm/ipic.h>
  19. #include <soc/fsl/qe/qe_ic.h>
  20. #include <sysdev/fsl_soc.h>
  21. #include <sysdev/fsl_pci.h>
  22. #include "mpc83xx.h"
  23. static __be32 __iomem *restart_reg_base;
  24. static int __init mpc83xx_restart_init(void)
  25. {
  26. /* map reset restart_reg_baseister space */
  27. restart_reg_base = ioremap(get_immrbase() + 0x900, 0xff);
  28. return 0;
  29. }
  30. arch_initcall(mpc83xx_restart_init);
  31. void __noreturn mpc83xx_restart(char *cmd)
  32. {
  33. #define RST_OFFSET 0x00000900
  34. #define RST_PROT_REG 0x00000018
  35. #define RST_CTRL_REG 0x0000001c
  36. local_irq_disable();
  37. if (restart_reg_base) {
  38. /* enable software reset "RSTE" */
  39. out_be32(restart_reg_base + (RST_PROT_REG >> 2), 0x52535445);
  40. /* set software hard reset */
  41. out_be32(restart_reg_base + (RST_CTRL_REG >> 2), 0x2);
  42. } else {
  43. printk (KERN_EMERG "Error: Restart registers not mapped, spinning!\n");
  44. }
  45. for (;;) ;
  46. }
  47. long __init mpc83xx_time_init(void)
  48. {
  49. #define SPCR_OFFSET 0x00000110
  50. #define SPCR_TBEN 0x00400000
  51. __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4);
  52. __be32 tmp;
  53. tmp = in_be32(spcr);
  54. out_be32(spcr, tmp | SPCR_TBEN);
  55. iounmap(spcr);
  56. return 0;
  57. }
  58. void __init mpc83xx_ipic_init_IRQ(void)
  59. {
  60. struct device_node *np;
  61. /* looking for fsl,pq2pro-pic which is asl compatible with fsl,ipic */
  62. np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
  63. if (!np)
  64. np = of_find_node_by_type(NULL, "ipic");
  65. if (!np)
  66. return;
  67. ipic_init(np, 0);
  68. of_node_put(np);
  69. /* Initialize the default interrupt mapping priorities,
  70. * in case the boot rom changed something on us.
  71. */
  72. ipic_set_default_priority();
  73. }
  74. #ifdef CONFIG_QUICC_ENGINE
  75. void __init mpc83xx_qe_init_IRQ(void)
  76. {
  77. struct device_node *np;
  78. np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
  79. if (!np) {
  80. np = of_find_node_by_type(NULL, "qeic");
  81. if (!np)
  82. return;
  83. }
  84. qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
  85. of_node_put(np);
  86. }
  87. void __init mpc83xx_ipic_and_qe_init_IRQ(void)
  88. {
  89. mpc83xx_ipic_init_IRQ();
  90. mpc83xx_qe_init_IRQ();
  91. }
  92. #endif /* CONFIG_QUICC_ENGINE */
  93. static const struct of_device_id of_bus_ids[] __initconst = {
  94. { .type = "soc", },
  95. { .compatible = "soc", },
  96. { .compatible = "simple-bus" },
  97. { .compatible = "gianfar" },
  98. { .compatible = "gpio-leds", },
  99. { .type = "qe", },
  100. { .compatible = "fsl,qe", },
  101. {},
  102. };
  103. int __init mpc83xx_declare_of_platform_devices(void)
  104. {
  105. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  106. return 0;
  107. }
  108. #ifdef CONFIG_PCI
  109. void __init mpc83xx_setup_pci(void)
  110. {
  111. struct device_node *np;
  112. for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  113. mpc83xx_add_bridge(np);
  114. for_each_compatible_node(np, "pci", "fsl,mpc8314-pcie")
  115. mpc83xx_add_bridge(np);
  116. }
  117. #endif
  118. void __init mpc83xx_setup_arch(void)
  119. {
  120. if (ppc_md.progress)
  121. ppc_md.progress("mpc83xx_setup_arch()", 0);
  122. mpc83xx_setup_pci();
  123. }
  124. int machine_check_83xx(struct pt_regs *regs)
  125. {
  126. u32 mask = 1 << (31 - IPIC_MCP_WDT);
  127. if (!(regs->msr & SRR1_MCE_MCP) || !(ipic_get_mcp_status() & mask))
  128. return machine_check_generic(regs);
  129. ipic_clear_mcp_status(mask);
  130. if (debugger_fault_handler(regs))
  131. return 1;
  132. die("Watchdog NMI Reset", regs, 0);
  133. return 1;
  134. }