blob: 5b25c8060fd67a8ff1ec2ff290af5ec740b6376f [file] [log] [blame]
Kumar Gala620165f2009-02-12 13:54:53 +00001/*
2 * Author: Kumar Gala <galak@kernel.crashing.org>
3 *
4 * Copyright 2009 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/smp.h>
15#include <linux/threads.h>
Milton Miller23d72bf2011-05-10 19:29:39 +000016#include <linux/hardirq.h>
Kumar Gala620165f2009-02-12 13:54:53 +000017
18#include <asm/dbell.h>
David Gibson0e37d252010-07-09 15:32:30 +100019#include <asm/irq_regs.h>
Kumar Gala620165f2009-02-12 13:54:53 +000020
21#ifdef CONFIG_SMP
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100022void doorbell_setup_this_cpu(void)
Kumar Gala620165f2009-02-12 13:54:53 +000023{
Milton Miller23d72bf2011-05-10 19:29:39 +000024 unsigned long tag = mfspr(SPRN_PIR) & 0x3fff;
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100025
Milton Miller23d72bf2011-05-10 19:29:39 +000026 smp_muxed_ipi_set_data(smp_processor_id(), tag);
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100027}
28
Milton Miller23d72bf2011-05-10 19:29:39 +000029void doorbell_cause_ipi(int cpu, unsigned long data)
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100030{
Milton Miller23d72bf2011-05-10 19:29:39 +000031 ppc_msgsnd(PPC_DBELL, 0, data);
Kumar Gala620165f2009-02-12 13:54:53 +000032}
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100033
34void doorbell_exception(struct pt_regs *regs)
35{
David Gibson0e37d252010-07-09 15:32:30 +100036 struct pt_regs *old_regs = set_irq_regs(regs);
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100037
Milton Miller23d72bf2011-05-10 19:29:39 +000038 irq_enter();
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100039
Benjamin Herrenschmidt7230c562012-03-06 18:27:59 +110040 may_hard_irq_enable();
41
Milton Miller23d72bf2011-05-10 19:29:39 +000042 smp_ipi_demux();
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100043
Milton Miller23d72bf2011-05-10 19:29:39 +000044 irq_exit();
David Gibson0e37d252010-07-09 15:32:30 +100045 set_irq_regs(old_regs);
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100046}
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100047#else /* CONFIG_SMP */
48void doorbell_exception(struct pt_regs *regs)
49{
50 printk(KERN_WARNING "Received doorbell on non-smp system\n");
51}
52#endif /* CONFIG_SMP */
53