Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 1 | /* |
| 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 Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 16 | #include <linux/hardirq.h> |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 17 | |
| 18 | #include <asm/dbell.h> |
David Gibson | 0e37d25 | 2010-07-09 15:32:30 +1000 | [diff] [blame] | 19 | #include <asm/irq_regs.h> |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 20 | |
| 21 | #ifdef CONFIG_SMP |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 22 | void doorbell_setup_this_cpu(void) |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 23 | { |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 24 | unsigned long tag = mfspr(SPRN_PIR) & 0x3fff; |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 25 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 26 | smp_muxed_ipi_set_data(smp_processor_id(), tag); |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 27 | } |
| 28 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 29 | void doorbell_cause_ipi(int cpu, unsigned long data) |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 30 | { |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 31 | ppc_msgsnd(PPC_DBELL, 0, data); |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 32 | } |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 33 | |
| 34 | void doorbell_exception(struct pt_regs *regs) |
| 35 | { |
David Gibson | 0e37d25 | 2010-07-09 15:32:30 +1000 | [diff] [blame] | 36 | struct pt_regs *old_regs = set_irq_regs(regs); |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 37 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 38 | irq_enter(); |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 39 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 40 | may_hard_irq_enable(); |
| 41 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 42 | smp_ipi_demux(); |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 43 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 44 | irq_exit(); |
David Gibson | 0e37d25 | 2010-07-09 15:32:30 +1000 | [diff] [blame] | 45 | set_irq_regs(old_regs); |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 46 | } |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 47 | #else /* CONFIG_SMP */ |
| 48 | void doorbell_exception(struct pt_regs *regs) |
| 49 | { |
| 50 | printk(KERN_WARNING "Received doorbell on non-smp system\n"); |
| 51 | } |
| 52 | #endif /* CONFIG_SMP */ |
| 53 | |