socfpga.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2012-2015 Altera Corporation
  4. */
  5. #include <linux/irqchip.h>
  6. #include <linux/of_address.h>
  7. #include <linux/of_irq.h>
  8. #include <linux/of_platform.h>
  9. #include <linux/reboot.h>
  10. #include <linux/reset/socfpga.h>
  11. #include <asm/hardware/cache-l2x0.h>
  12. #include <asm/mach/arch.h>
  13. #include <asm/mach/map.h>
  14. #include <asm/cacheflush.h>
  15. #include "core.h"
  16. void __iomem *sys_manager_base_addr;
  17. void __iomem *rst_manager_base_addr;
  18. void __iomem *sdr_ctl_base_addr;
  19. unsigned long socfpga_cpu1start_addr;
  20. static void __init socfpga_sysmgr_init(void)
  21. {
  22. struct device_node *np;
  23. np = of_find_compatible_node(NULL, NULL, "altr,sys-mgr");
  24. if (of_property_read_u32(np, "cpu1-start-addr",
  25. (u32 *) &socfpga_cpu1start_addr))
  26. pr_err("SMP: Need cpu1-start-addr in device tree.\n");
  27. /* Ensure that socfpga_cpu1start_addr is visible to other CPUs */
  28. smp_wmb();
  29. sync_cache_w(&socfpga_cpu1start_addr);
  30. sys_manager_base_addr = of_iomap(np, 0);
  31. np = of_find_compatible_node(NULL, NULL, "altr,rst-mgr");
  32. rst_manager_base_addr = of_iomap(np, 0);
  33. np = of_find_compatible_node(NULL, NULL, "altr,sdr-ctl");
  34. sdr_ctl_base_addr = of_iomap(np, 0);
  35. }
  36. static void __init socfpga_init_irq(void)
  37. {
  38. irqchip_init();
  39. socfpga_sysmgr_init();
  40. if (IS_ENABLED(CONFIG_EDAC_ALTERA_L2C))
  41. socfpga_init_l2_ecc();
  42. if (IS_ENABLED(CONFIG_EDAC_ALTERA_OCRAM))
  43. socfpga_init_ocram_ecc();
  44. socfpga_reset_init();
  45. }
  46. static void __init socfpga_arria10_init_irq(void)
  47. {
  48. irqchip_init();
  49. socfpga_sysmgr_init();
  50. if (IS_ENABLED(CONFIG_EDAC_ALTERA_L2C))
  51. socfpga_init_arria10_l2_ecc();
  52. if (IS_ENABLED(CONFIG_EDAC_ALTERA_OCRAM))
  53. socfpga_init_arria10_ocram_ecc();
  54. socfpga_reset_init();
  55. }
  56. static void socfpga_cyclone5_restart(enum reboot_mode mode, const char *cmd)
  57. {
  58. u32 temp;
  59. temp = readl(rst_manager_base_addr + SOCFPGA_RSTMGR_CTRL);
  60. if (mode == REBOOT_WARM)
  61. temp |= RSTMGR_CTRL_SWWARMRSTREQ;
  62. else
  63. temp |= RSTMGR_CTRL_SWCOLDRSTREQ;
  64. writel(temp, rst_manager_base_addr + SOCFPGA_RSTMGR_CTRL);
  65. }
  66. static void socfpga_arria10_restart(enum reboot_mode mode, const char *cmd)
  67. {
  68. u32 temp;
  69. temp = readl(rst_manager_base_addr + SOCFPGA_A10_RSTMGR_CTRL);
  70. if (mode == REBOOT_WARM)
  71. temp |= RSTMGR_CTRL_SWWARMRSTREQ;
  72. else
  73. temp |= RSTMGR_CTRL_SWCOLDRSTREQ;
  74. writel(temp, rst_manager_base_addr + SOCFPGA_A10_RSTMGR_CTRL);
  75. }
  76. static const char *altera_dt_match[] = {
  77. "altr,socfpga",
  78. NULL
  79. };
  80. DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA")
  81. .l2c_aux_val = 0,
  82. .l2c_aux_mask = ~0,
  83. .init_irq = socfpga_init_irq,
  84. .restart = socfpga_cyclone5_restart,
  85. .dt_compat = altera_dt_match,
  86. MACHINE_END
  87. static const char *altera_a10_dt_match[] = {
  88. "altr,socfpga-arria10",
  89. NULL
  90. };
  91. DT_MACHINE_START(SOCFPGA_A10, "Altera SOCFPGA Arria10")
  92. .l2c_aux_val = 0,
  93. .l2c_aux_mask = ~0,
  94. .init_irq = socfpga_arria10_init_irq,
  95. .restart = socfpga_arria10_restart,
  96. .dt_compat = altera_a10_dt_match,
  97. MACHINE_END