blob: c38e1f34460d44847473d17f297af2f4a3a14d6b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
19#include <linux/init.h>
20#include <linux/delay.h>
21#include <linux/interrupt.h>
22#include <linux/smp.h>
23#include <linux/kernel_stat.h>
24
25#include <asm/mmu_context.h>
26#include <asm/io.h>
27#include <asm/sibyte/sb1250.h>
28#include <asm/sibyte/sb1250_regs.h>
29#include <asm/sibyte/sb1250_int.h>
30
31static void *mailbox_set_regs[] = {
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +000032 IOADDR(A_IMR_CPU0_BASE + R_IMR_MAILBOX_SET_CPU),
33 IOADDR(A_IMR_CPU1_BASE + R_IMR_MAILBOX_SET_CPU)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034};
35
36static void *mailbox_clear_regs[] = {
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +000037 IOADDR(A_IMR_CPU0_BASE + R_IMR_MAILBOX_CLR_CPU),
38 IOADDR(A_IMR_CPU1_BASE + R_IMR_MAILBOX_CLR_CPU)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039};
40
41static void *mailbox_regs[] = {
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +000042 IOADDR(A_IMR_CPU0_BASE + R_IMR_MAILBOX_CPU),
43 IOADDR(A_IMR_CPU1_BASE + R_IMR_MAILBOX_CPU)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044};
45
46/*
47 * SMP init and finish on secondary CPUs
48 */
49void sb1250_smp_init(void)
50{
51 unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 |
52 STATUSF_IP1 | STATUSF_IP0;
53
54 /* Set interrupt mask, but don't enable */
55 change_c0_status(ST0_IM, imask);
56}
57
58void sb1250_smp_finish(void)
59{
60 extern void sb1250_time_init(void);
61 sb1250_time_init();
62 local_irq_enable();
63}
64
65/*
66 * These are routines for dealing with the sb1250 smp capabilities
67 * independent of board/firmware
68 */
69
70/*
71 * Simple enough; everything is set up, so just poke the appropriate mailbox
72 * register, and we should be set
73 */
74void core_send_ipi(int cpu, unsigned int action)
75{
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +000076 __raw_writeq((((u64)action) << 48), mailbox_set_regs[cpu]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077}
78
Ralf Baechle937a8012006-10-07 19:44:33 +010079void sb1250_mailbox_interrupt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080{
81 int cpu = smp_processor_id();
82 unsigned int action;
83
84 kstat_this_cpu.irqs[K_INT_MBOX_0]++;
85 /* Load the mailbox register to figure out what we're supposed to do */
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +000086 action = (____raw_readq(mailbox_regs[cpu]) >> 48) & 0xffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88 /* Clear the mailbox to clear the interrupt */
Maciej W. Rozycki65bda1a2005-02-22 21:51:30 +000089 ____raw_writeq(((u64)action) << 48, mailbox_clear_regs[cpu]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91 /*
92 * Nothing to do for SMP_RESCHEDULE_YOURSELF; returning from the
93 * interrupt will do the reschedule for us
94 */
95
96 if (action & SMP_CALL_FUNCTION)
97 smp_call_function_interrupt();
98}