smp.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2015 MediaTek Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef __MT_SMP_H
  15. #define __MT_SMP_H
  16. #include <linux/cpumask.h>
  17. #include <mach/irqs.h>
  18. #include <asm/cputype.h>
  19. #include <mt-plat/sync_write.h>
  20. #include "hotplug.h"
  21. extern void irq_raise_softirq(const struct cpumask *mask, unsigned int irq);
  22. /* use Soft IRQ1 as the IPI */
  23. static inline void smp_cross_call(const struct cpumask *mask)
  24. {
  25. irq_raise_softirq(mask, CPU_BRINGUP_SGI);
  26. }
  27. #ifdef CONFIG_ARM64
  28. static inline int get_HW_cpuid(void)
  29. {
  30. u64 mpidr;
  31. u32 id;
  32. mpidr = read_cpuid_mpidr();
  33. id = (mpidr & 0xff) + ((mpidr & 0xff00) >> 6);
  34. return id;
  35. }
  36. #else
  37. static inline int get_HW_cpuid(void)
  38. {
  39. int id;
  40. asm("mrc p15, 0, %0, c0, c0, 5 @ Get CPUID\n":"=r"(id));
  41. return (id & 0x3) + ((id & 0xF00) >> 6);
  42. }
  43. #endif
  44. static inline void mt_smp_set_boot_addr(u32 addr, int cpu)
  45. {
  46. mt_reg_sync_writel(addr, BOOTROM_BOOT_ADDR);
  47. }
  48. #endif