pmsu.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Power Management Service Unit(PMSU) support for Armada 370/XP platforms.
  3. *
  4. * Copyright (C) 2012 Marvell
  5. *
  6. * Yehuda Yitschak <yehuday@marvell.com>
  7. * Gregory Clement <gregory.clement@free-electrons.com>
  8. * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  9. *
  10. * This file is licensed under the terms of the GNU General Public
  11. * License version 2. This program is licensed "as is" without any
  12. * warranty of any kind, whether express or implied.
  13. *
  14. * The Armada 370 and Armada XP SOCs have a power management service
  15. * unit which is responsible for powering down and waking up CPUs and
  16. * other SOC units
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/of_address.h>
  21. #include <linux/io.h>
  22. #include <linux/smp.h>
  23. #include <asm/smp_plat.h>
  24. static void __iomem *pmsu_mp_base;
  25. static void __iomem *pmsu_reset_base;
  26. #define PMSU_BOOT_ADDR_REDIRECT_OFFSET(cpu) ((cpu * 0x100) + 0x24)
  27. #define PMSU_RESET_CTL_OFFSET(cpu) (cpu * 0x8)
  28. static struct of_device_id of_pmsu_table[] = {
  29. {.compatible = "marvell,armada-370-xp-pmsu"},
  30. { /* end of list */ },
  31. };
  32. #ifdef CONFIG_SMP
  33. int armada_xp_boot_cpu(unsigned int cpu_id, void *boot_addr)
  34. {
  35. int reg, hw_cpu;
  36. if (!pmsu_mp_base || !pmsu_reset_base) {
  37. pr_warn("Can't boot CPU. PMSU is uninitialized\n");
  38. return 1;
  39. }
  40. hw_cpu = cpu_logical_map(cpu_id);
  41. writel(virt_to_phys(boot_addr), pmsu_mp_base +
  42. PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu));
  43. /* Release CPU from reset by clearing reset bit*/
  44. reg = readl(pmsu_reset_base + PMSU_RESET_CTL_OFFSET(hw_cpu));
  45. reg &= (~0x1);
  46. writel(reg, pmsu_reset_base + PMSU_RESET_CTL_OFFSET(hw_cpu));
  47. return 0;
  48. }
  49. #endif
  50. int __init armada_370_xp_pmsu_init(void)
  51. {
  52. struct device_node *np;
  53. np = of_find_matching_node(NULL, of_pmsu_table);
  54. if (np) {
  55. pr_info("Initializing Power Management Service Unit\n");
  56. pmsu_mp_base = of_iomap(np, 0);
  57. pmsu_reset_base = of_iomap(np, 1);
  58. }
  59. return 0;
  60. }
  61. early_initcall(armada_370_xp_pmsu_init);