smp.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright (C) 2001, 2002, 2003 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (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. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/delay.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/smp.h>
  22. #include <linux/kernel_stat.h>
  23. #include <asm/mmu_context.h>
  24. #include <asm/io.h>
  25. #include <asm/sibyte/sb1250.h>
  26. #include <asm/sibyte/sb1250_regs.h>
  27. #include <asm/sibyte/sb1250_int.h>
  28. static void *mailbox_set_regs[] = {
  29. IOADDR(A_IMR_CPU0_BASE + R_IMR_MAILBOX_SET_CPU),
  30. IOADDR(A_IMR_CPU1_BASE + R_IMR_MAILBOX_SET_CPU)
  31. };
  32. static void *mailbox_clear_regs[] = {
  33. IOADDR(A_IMR_CPU0_BASE + R_IMR_MAILBOX_CLR_CPU),
  34. IOADDR(A_IMR_CPU1_BASE + R_IMR_MAILBOX_CLR_CPU)
  35. };
  36. static void *mailbox_regs[] = {
  37. IOADDR(A_IMR_CPU0_BASE + R_IMR_MAILBOX_CPU),
  38. IOADDR(A_IMR_CPU1_BASE + R_IMR_MAILBOX_CPU)
  39. };
  40. /*
  41. * SMP init and finish on secondary CPUs
  42. */
  43. void sb1250_smp_init(void)
  44. {
  45. unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 |
  46. STATUSF_IP1 | STATUSF_IP0;
  47. /* Set interrupt mask, but don't enable */
  48. change_c0_status(ST0_IM, imask);
  49. }
  50. void sb1250_smp_finish(void)
  51. {
  52. extern void sb1250_time_init(void);
  53. sb1250_time_init();
  54. local_irq_enable();
  55. }
  56. /*
  57. * These are routines for dealing with the sb1250 smp capabilities
  58. * independent of board/firmware
  59. */
  60. /*
  61. * Simple enough; everything is set up, so just poke the appropriate mailbox
  62. * register, and we should be set
  63. */
  64. void core_send_ipi(int cpu, unsigned int action)
  65. {
  66. __raw_writeq((((u64)action) << 48), mailbox_set_regs[cpu]);
  67. }
  68. void sb1250_mailbox_interrupt(void)
  69. {
  70. int cpu = smp_processor_id();
  71. unsigned int action;
  72. kstat_this_cpu.irqs[K_INT_MBOX_0]++;
  73. /* Load the mailbox register to figure out what we're supposed to do */
  74. action = (____raw_readq(mailbox_regs[cpu]) >> 48) & 0xffff;
  75. /* Clear the mailbox to clear the interrupt */
  76. ____raw_writeq(((u64)action) << 48, mailbox_clear_regs[cpu]);
  77. /*
  78. * Nothing to do for SMP_RESCHEDULE_YOURSELF; returning from the
  79. * interrupt will do the reschedule for us
  80. */
  81. if (action & SMP_CALL_FUNCTION)
  82. smp_call_function_interrupt();
  83. }