misc.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * misc setup functions for MPC83xx
  4. *
  5. * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  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 <asm/fixmap.h>
  16. #include <sysdev/fsl_soc.h>
  17. #include <sysdev/fsl_pci.h>
  18. #include <mm/mmu_decl.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 __noreturn 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. static const struct of_device_id of_bus_ids[] __initconst = {
  72. { .type = "soc", },
  73. { .compatible = "soc", },
  74. { .compatible = "simple-bus" },
  75. { .compatible = "gianfar" },
  76. { .compatible = "gpio-leds", },
  77. { .type = "qe", },
  78. { .compatible = "fsl,qe", },
  79. {},
  80. };
  81. int __init mpc83xx_declare_of_platform_devices(void)
  82. {
  83. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  84. return 0;
  85. }
  86. #ifdef CONFIG_PCI
  87. void __init mpc83xx_setup_pci(void)
  88. {
  89. struct device_node *np;
  90. for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
  91. mpc83xx_add_bridge(np);
  92. for_each_compatible_node(np, "pci", "fsl,mpc8314-pcie")
  93. mpc83xx_add_bridge(np);
  94. }
  95. #endif
  96. void __init mpc83xx_setup_arch(void)
  97. {
  98. phys_addr_t immrbase = get_immrbase();
  99. int immrsize = IS_ALIGNED(immrbase, SZ_2M) ? SZ_2M : SZ_1M;
  100. unsigned long va = fix_to_virt(FIX_IMMR_BASE);
  101. if (ppc_md.progress)
  102. ppc_md.progress("mpc83xx_setup_arch()", 0);
  103. setbat(-1, va, immrbase, immrsize, PAGE_KERNEL_NCG);
  104. update_bats();
  105. }
  106. int machine_check_83xx(struct pt_regs *regs)
  107. {
  108. u32 mask = 1 << (31 - IPIC_MCP_WDT);
  109. if (!(regs->msr & SRR1_MCE_MCP) || !(ipic_get_mcp_status() & mask))
  110. return machine_check_generic(regs);
  111. ipic_clear_mcp_status(mask);
  112. if (debugger_fault_handler(regs))
  113. return 1;
  114. die("Watchdog NMI Reset", regs, 0);
  115. return 1;
  116. }