platsmp.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (C) 2002 ARM Ltd.
  3. * Copyright (C) 2008 STMicroelctronics.
  4. * Copyright (C) 2009 ST-Ericsson.
  5. * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
  6. *
  7. * This file is based on arm realview platform
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/errno.h>
  15. #include <linux/delay.h>
  16. #include <linux/device.h>
  17. #include <linux/smp.h>
  18. #include <linux/io.h>
  19. #include <linux/of.h>
  20. #include <linux/of_address.h>
  21. #include <asm/cacheflush.h>
  22. #include <asm/smp_plat.h>
  23. #include <asm/smp_scu.h>
  24. #include "setup.h"
  25. #include "db8500-regs.h"
  26. #include "id.h"
  27. /* Magic triggers in backup RAM */
  28. #define UX500_CPU1_JUMPADDR_OFFSET 0x1FF4
  29. #define UX500_CPU1_WAKEMAGIC_OFFSET 0x1FF0
  30. static void wakeup_secondary(void)
  31. {
  32. struct device_node *np;
  33. static void __iomem *backupram;
  34. np = of_find_compatible_node(NULL, NULL, "ste,dbx500-backupram");
  35. if (!np) {
  36. pr_err("No backupram base address\n");
  37. return;
  38. }
  39. backupram = of_iomap(np, 0);
  40. of_node_put(np);
  41. if (!backupram) {
  42. pr_err("No backupram remap\n");
  43. return;
  44. }
  45. /*
  46. * write the address of secondary startup into the backup ram register
  47. * at offset 0x1FF4, then write the magic number 0xA1FEED01 to the
  48. * backup ram register at offset 0x1FF0, which is what boot rom code
  49. * is waiting for. This will wake up the secondary core from WFE.
  50. */
  51. writel(virt_to_phys(secondary_startup),
  52. backupram + UX500_CPU1_JUMPADDR_OFFSET);
  53. writel(0xA1FEED01,
  54. backupram + UX500_CPU1_WAKEMAGIC_OFFSET);
  55. /* make sure write buffer is drained */
  56. mb();
  57. iounmap(backupram);
  58. }
  59. static void __init ux500_smp_prepare_cpus(unsigned int max_cpus)
  60. {
  61. struct device_node *np;
  62. static void __iomem *scu_base;
  63. unsigned int ncores;
  64. int i;
  65. np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
  66. if (!np) {
  67. pr_err("No SCU base address\n");
  68. return;
  69. }
  70. scu_base = of_iomap(np, 0);
  71. of_node_put(np);
  72. if (!scu_base) {
  73. pr_err("No SCU remap\n");
  74. return;
  75. }
  76. scu_enable(scu_base);
  77. ncores = scu_get_core_count(scu_base);
  78. for (i = 0; i < ncores; i++)
  79. set_cpu_possible(i, true);
  80. iounmap(scu_base);
  81. }
  82. static int ux500_boot_secondary(unsigned int cpu, struct task_struct *idle)
  83. {
  84. wakeup_secondary();
  85. arch_send_wakeup_ipi_mask(cpumask_of(cpu));
  86. return 0;
  87. }
  88. struct smp_operations ux500_smp_ops __initdata = {
  89. .smp_prepare_cpus = ux500_smp_prepare_cpus,
  90. .smp_boot_secondary = ux500_boot_secondary,
  91. #ifdef CONFIG_HOTPLUG_CPU
  92. .cpu_die = ux500_cpu_die,
  93. #endif
  94. };
  95. CPU_METHOD_OF_DECLARE(ux500_smp, "ste,dbx500-smp", &ux500_smp_ops);