platsmp.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * SMP support for R-Mobile / SH-Mobile
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. *
  6. * Based on vexpress, Copyright (C) 2002 ARM Ltd, All Rights Reserved
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/errno.h>
  14. #include <linux/delay.h>
  15. #include <linux/device.h>
  16. #include <linux/smp.h>
  17. #include <linux/io.h>
  18. #include <asm/localtimer.h>
  19. #include <asm/mach-types.h>
  20. #include <mach/common.h>
  21. static unsigned int __init shmobile_smp_get_core_count(void)
  22. {
  23. if (machine_is_ag5evm())
  24. return sh73a0_get_core_count();
  25. return 1;
  26. }
  27. static void __init shmobile_smp_prepare_cpus(void)
  28. {
  29. if (machine_is_ag5evm())
  30. sh73a0_smp_prepare_cpus();
  31. }
  32. void __cpuinit platform_secondary_init(unsigned int cpu)
  33. {
  34. trace_hardirqs_off();
  35. if (machine_is_ag5evm())
  36. sh73a0_secondary_init(cpu);
  37. }
  38. int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
  39. {
  40. if (machine_is_ag5evm())
  41. return sh73a0_boot_secondary(cpu);
  42. return -ENOSYS;
  43. }
  44. void __init smp_init_cpus(void)
  45. {
  46. unsigned int ncores = shmobile_smp_get_core_count();
  47. unsigned int i;
  48. for (i = 0; i < ncores; i++)
  49. set_cpu_possible(i, true);
  50. }
  51. void __init smp_prepare_cpus(unsigned int max_cpus)
  52. {
  53. unsigned int ncores = shmobile_smp_get_core_count();
  54. unsigned int cpu = smp_processor_id();
  55. int i;
  56. smp_store_cpu_info(cpu);
  57. if (max_cpus > ncores)
  58. max_cpus = ncores;
  59. for (i = 0; i < max_cpus; i++)
  60. set_cpu_present(i, true);
  61. if (max_cpus > 1) {
  62. shmobile_smp_prepare_cpus();
  63. /*
  64. * Enable the local timer or broadcast device for the
  65. * boot CPU, but only if we have more than one CPU.
  66. */
  67. percpu_timer_setup();
  68. }
  69. }