platsmp.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * linux/arch/arm/mach-realview/platsmp.c
  3. *
  4. * Copyright (C) 2002 ARM Ltd.
  5. * All Rights Reserved
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/errno.h>
  13. #include <linux/smp.h>
  14. #include <linux/io.h>
  15. #include <mach/hardware.h>
  16. #include <asm/mach-types.h>
  17. #include <asm/smp_scu.h>
  18. #include <mach/board-eb.h>
  19. #include <mach/board-pb11mp.h>
  20. #include <mach/board-pbx.h>
  21. #include <plat/platsmp.h>
  22. #include "core.h"
  23. static void __iomem *scu_base_addr(void)
  24. {
  25. if (machine_is_realview_eb_mp())
  26. return __io_address(REALVIEW_EB11MP_SCU_BASE);
  27. else if (machine_is_realview_pb11mp())
  28. return __io_address(REALVIEW_TC11MP_SCU_BASE);
  29. else if (machine_is_realview_pbx() &&
  30. (core_tile_pbx11mp() || core_tile_pbxa9mp()))
  31. return __io_address(REALVIEW_PBX_TILE_SCU_BASE);
  32. else
  33. return (void __iomem *)0;
  34. }
  35. /*
  36. * Initialise the CPU possible map early - this describes the CPUs
  37. * which may be present or become present in the system.
  38. */
  39. static void __init realview_smp_init_cpus(void)
  40. {
  41. void __iomem *scu_base = scu_base_addr();
  42. unsigned int i, ncores;
  43. ncores = scu_base ? scu_get_core_count(scu_base) : 1;
  44. /* sanity check */
  45. if (ncores > nr_cpu_ids) {
  46. pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
  47. ncores, nr_cpu_ids);
  48. ncores = nr_cpu_ids;
  49. }
  50. for (i = 0; i < ncores; i++)
  51. set_cpu_possible(i, true);
  52. }
  53. static void __init realview_smp_prepare_cpus(unsigned int max_cpus)
  54. {
  55. scu_enable(scu_base_addr());
  56. /*
  57. * Write the address of secondary startup into the
  58. * system-wide flags register. The BootMonitor waits
  59. * until it receives a soft interrupt, and then the
  60. * secondary CPU branches to this address.
  61. */
  62. __raw_writel(virt_to_phys(versatile_secondary_startup),
  63. __io_address(REALVIEW_SYS_FLAGSSET));
  64. }
  65. struct smp_operations realview_smp_ops __initdata = {
  66. .smp_init_cpus = realview_smp_init_cpus,
  67. .smp_prepare_cpus = realview_smp_prepare_cpus,
  68. .smp_secondary_init = versatile_secondary_init,
  69. .smp_boot_secondary = versatile_boot_secondary,
  70. #ifdef CONFIG_HOTPLUG_CPU
  71. .cpu_die = realview_cpu_die,
  72. #endif
  73. };