src.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. * Copyright 2011 Linaro Ltd.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/of.h>
  15. #include <linux/of_address.h>
  16. #include <linux/smp.h>
  17. #include <asm/smp_plat.h>
  18. #define SRC_SCR 0x000
  19. #define SRC_GPR1 0x020
  20. #define BP_SRC_SCR_WARM_RESET_ENABLE 0
  21. #define BP_SRC_SCR_CORE1_RST 14
  22. #define BP_SRC_SCR_CORE1_ENABLE 22
  23. static void __iomem *src_base;
  24. void imx_enable_cpu(int cpu, bool enable)
  25. {
  26. u32 mask, val;
  27. cpu = cpu_logical_map(cpu);
  28. mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1);
  29. val = readl_relaxed(src_base + SRC_SCR);
  30. val = enable ? val | mask : val & ~mask;
  31. writel_relaxed(val, src_base + SRC_SCR);
  32. }
  33. void imx_set_cpu_jump(int cpu, void *jump_addr)
  34. {
  35. cpu = cpu_logical_map(cpu);
  36. writel_relaxed(virt_to_phys(jump_addr),
  37. src_base + SRC_GPR1 + cpu * 8);
  38. }
  39. void imx_src_prepare_restart(void)
  40. {
  41. u32 val;
  42. /* clear enable bits of secondary cores */
  43. val = readl_relaxed(src_base + SRC_SCR);
  44. val &= ~(0x7 << BP_SRC_SCR_CORE1_ENABLE);
  45. writel_relaxed(val, src_base + SRC_SCR);
  46. /* clear persistent entry register of primary core */
  47. writel_relaxed(0, src_base + SRC_GPR1);
  48. }
  49. void __init imx_src_init(void)
  50. {
  51. struct device_node *np;
  52. u32 val;
  53. np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-src");
  54. src_base = of_iomap(np, 0);
  55. WARN_ON(!src_base);
  56. /*
  57. * force warm reset sources to generate cold reset
  58. * for a more reliable restart
  59. */
  60. val = readl_relaxed(src_base + SRC_SCR);
  61. val &= ~(1 << BP_SRC_SCR_WARM_RESET_ENABLE);
  62. writel_relaxed(val, src_base + SRC_SCR);
  63. }