misc.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * misc setup functions for MPC83xx
  4. *
  5. * Maintainer: Kumar Gala <[email protected]>
  6. */
  7. #include <linux/stddef.h>
  8. #include <linux/kernel.h>
  9. #include <linux/of_platform.h>
  10. #include <linux/pci.h>
  11. #include <asm/debug.h>
  12. #include <asm/io.h>
  13. #include <asm/hw_irq.h>
  14. #include <asm/ipic.h>
  15. #include <sysdev/fsl_soc.h>
  16. #include <sysdev/fsl_pci.h>
  17. #include <mm/mmu_decl.h>
  18. #include "mpc83xx.h"
  19. static __be32 __iomem *restart_reg_base;
  20. static int __init mpc83xx_restart_init(void)
  21. {
  22. /* map reset restart_reg_baseister space */
  23. restart_reg_base = ioremap(get_immrbase() + 0x900, 0xff);
  24. return 0;
  25. }
  26. arch_initcall(mpc83xx_restart_init);
  27. void __noreturn mpc83xx_restart(char *cmd)
  28. {
  29. #define RST_OFFSET 0x00000900
  30. #define RST_PROT_REG 0x00000018
  31. #define RST_CTRL_REG 0x0000001c
  32. local_irq_disable();
  33. if (restart_reg_base) {
  34. /* enable software reset "RSTE" */
  35. out_be32(restart_reg_base + (RST_PROT_REG >> 2), 0x52535445);
  36. /* set software hard reset */
  37. out_be32(restart_reg_base + (RST_CTRL_REG >> 2), 0x2);
  38. } else {
  39. printk (KERN_EMERG "Error: Restart registers not mapped, spinning!\n");
  40. }
  41. for (;;) ;
  42. }
  43. long __init mpc83xx_time_init(void)
  44. {
  45. #define SPCR_OFFSET 0x00000110
  46. #define SPCR_TBEN 0x00400000
  47. __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4);
  48. __be32 tmp;
  49. tmp = in_be32(spcr);
  50. out_be32(spcr, tmp | SPCR_TBEN);
  51. iounmap(spcr);
  52. return 0;
  53. }
  54. void __init mpc83xx_ipic_init_IRQ(void)
  55. {
  56. struct device_node *np;
  57. /* looking for fsl,pq2pro-pic which is asl compatible with fsl,ipic */
  58. np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
  59. if (!np)
  60. np = of_find_node_by_type(NULL, "ipic");
  61. if (!np)
  62. return;
  63. ipic_init(np, 0);
  64. of_node_put(np);
  65. /* Initialize the default interrupt mapping priorities,
  66. * in case the boot rom changed something on us.
  67. */
  68. ipic_set_default_priority();
  69. }
  70. static const struct of_device_id of_bus_ids[] __initconst = {
  71. { .type = "soc", },
  72. { .compatible = "soc", },
  73. { .compatible = "simple-bus" },
  74. { .compatible = "gianfar" },
  75. { .compatible = "gpio-leds", },
  76. { .type = "qe", },
  77. { .compatible = "fsl,qe", },
  78. {},
  79. };
  80. int __init mpc83xx_declare_of_platform_devices(void)
  81. {
  82. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  83. return 0;
  84. }
  85. #ifdef CONFIG_PCI
  86. void __init mpc83xx_setup_pci(void)
  87. {
  88. struct device_node *np;
  89. for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  90. mpc83xx_add_bridge(np);
  91. for_each_compatible_node(np, "pci", "fsl,mpc8314-pcie")
  92. mpc83xx_add_bridge(np);
  93. }
  94. #endif
  95. void __init mpc83xx_setup_arch(void)
  96. {
  97. phys_addr_t immrbase = get_immrbase();
  98. int immrsize = IS_ALIGNED(immrbase, SZ_2M) ? SZ_2M : SZ_1M;
  99. unsigned long va = fix_to_virt(FIX_IMMR_BASE);
  100. if (ppc_md.progress)
  101. ppc_md.progress("mpc83xx_setup_arch()", 0);
  102. setbat(-1, va, immrbase, immrsize, PAGE_KERNEL_NCG);
  103. update_bats();
  104. }
  105. int machine_check_83xx(struct pt_regs *regs)
  106. {
  107. u32 mask = 1 << (31 - IPIC_MCP_WDT);
  108. if (!(regs->msr & SRR1_MCE_MCP) || !(ipic_get_mcp_status() & mask))
  109. return machine_check_generic(regs);
  110. ipic_clear_mcp_status(mask);
  111. if (debugger_fault_handler(regs))
  112. return 1;
  113. die("Watchdog NMI Reset", regs, 0);
  114. return 1;
  115. }