platsmp.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * linux/arch/arm/mach-tegra/platsmp.c
  3. *
  4. * Copyright (C) 2002 ARM Ltd.
  5. * All Rights Reserved
  6. *
  7. * Copyright (C) 2009 Palm
  8. * All Rights Reserved
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/errno.h>
  16. #include <linux/delay.h>
  17. #include <linux/device.h>
  18. #include <linux/jiffies.h>
  19. #include <linux/smp.h>
  20. #include <linux/io.h>
  21. #include <asm/cacheflush.h>
  22. #include <asm/hardware/gic.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/smp_scu.h>
  25. #include <mach/powergate.h>
  26. #include "fuse.h"
  27. #include "flowctrl.h"
  28. #include "reset.h"
  29. #include "tegra_cpu_car.h"
  30. #include "common.h"
  31. #include "iomap.h"
  32. extern void tegra_secondary_startup(void);
  33. #define EVP_CPU_RESET_VECTOR \
  34. (IO_ADDRESS(TEGRA_EXCEPTION_VECTORS_BASE) + 0x100)
  35. static void __cpuinit tegra_secondary_init(unsigned int cpu)
  36. {
  37. /*
  38. * if any interrupts are already enabled for the primary
  39. * core (e.g. timer irq), then they will not have been enabled
  40. * for us: do so
  41. */
  42. gic_secondary_init(0);
  43. }
  44. static int tegra20_power_up_cpu(unsigned int cpu)
  45. {
  46. /* Enable the CPU clock. */
  47. tegra_enable_cpu_clock(cpu);
  48. /* Clear flow controller CSR. */
  49. flowctrl_write_cpu_csr(cpu, 0);
  50. return 0;
  51. }
  52. static int tegra30_power_up_cpu(unsigned int cpu)
  53. {
  54. int ret, pwrgateid;
  55. unsigned long timeout;
  56. pwrgateid = tegra_cpu_powergate_id(cpu);
  57. if (pwrgateid < 0)
  58. return pwrgateid;
  59. /* If this is the first boot, toggle powergates directly. */
  60. if (!tegra_powergate_is_powered(pwrgateid)) {
  61. ret = tegra_powergate_power_on(pwrgateid);
  62. if (ret)
  63. return ret;
  64. /* Wait for the power to come up. */
  65. timeout = jiffies + 10*HZ;
  66. while (tegra_powergate_is_powered(pwrgateid)) {
  67. if (time_after(jiffies, timeout))
  68. return -ETIMEDOUT;
  69. udelay(10);
  70. }
  71. }
  72. /* CPU partition is powered. Enable the CPU clock. */
  73. tegra_enable_cpu_clock(cpu);
  74. udelay(10);
  75. /* Remove I/O clamps. */
  76. ret = tegra_powergate_remove_clamping(pwrgateid);
  77. udelay(10);
  78. /* Clear flow controller CSR. */
  79. flowctrl_write_cpu_csr(cpu, 0);
  80. return 0;
  81. }
  82. static int __cpuinit tegra_boot_secondary(unsigned int cpu, struct task_struct *idle)
  83. {
  84. int status;
  85. /*
  86. * Force the CPU into reset. The CPU must remain in reset when the
  87. * flow controller state is cleared (which will cause the flow
  88. * controller to stop driving reset if the CPU has been power-gated
  89. * via the flow controller). This will have no effect on first boot
  90. * of the CPU since it should already be in reset.
  91. */
  92. tegra_put_cpu_in_reset(cpu);
  93. /*
  94. * Unhalt the CPU. If the flow controller was used to power-gate the
  95. * CPU this will cause the flow controller to stop driving reset.
  96. * The CPU will remain in reset because the clock and reset block
  97. * is now driving reset.
  98. */
  99. flowctrl_write_cpu_halt(cpu, 0);
  100. switch (tegra_chip_id) {
  101. case TEGRA20:
  102. status = tegra20_power_up_cpu(cpu);
  103. break;
  104. case TEGRA30:
  105. status = tegra30_power_up_cpu(cpu);
  106. break;
  107. default:
  108. status = -EINVAL;
  109. break;
  110. }
  111. if (status)
  112. goto done;
  113. /* Take the CPU out of reset. */
  114. tegra_cpu_out_of_reset(cpu);
  115. done:
  116. return status;
  117. }
  118. static void __init tegra_smp_init_cpus(void)
  119. {
  120. set_smp_cross_call(gic_raise_softirq);
  121. }
  122. static void __init tegra_smp_prepare_cpus(unsigned int max_cpus)
  123. {
  124. tegra_cpu_reset_handler_init();
  125. if (scu_a9_has_base())
  126. scu_enable(IO_ADDRESS(scu_a9_get_base()));
  127. }
  128. struct smp_operations tegra_smp_ops __initdata = {
  129. .smp_init_cpus = tegra_smp_init_cpus,
  130. .smp_prepare_cpus = tegra_smp_prepare_cpus,
  131. .smp_secondary_init = tegra_secondary_init,
  132. .smp_boot_secondary = tegra_boot_secondary,
  133. #ifdef CONFIG_HOTPLUG_CPU
  134. .cpu_die = tegra_cpu_die,
  135. .cpu_disable = tegra_cpu_disable,
  136. #endif
  137. };