xref: /openbmc/linux/arch/sh/kernel/irq_32.c (revision 03fdb708)
103fdb708SPaul Mundt /*
203fdb708SPaul Mundt  * SHcompact irqflags support
303fdb708SPaul Mundt  *
403fdb708SPaul Mundt  * Copyright (C) 2006 - 2009 Paul Mundt
503fdb708SPaul Mundt  *
603fdb708SPaul Mundt  * This file is subject to the terms and conditions of the GNU General Public
703fdb708SPaul Mundt  * License. See the file "COPYING" in the main directory of this archive
803fdb708SPaul Mundt  * for more details.
903fdb708SPaul Mundt  */
1003fdb708SPaul Mundt #include <linux/irqflags.h>
1103fdb708SPaul Mundt #include <linux/module.h>
1203fdb708SPaul Mundt 
1303fdb708SPaul Mundt void raw_local_irq_restore(unsigned long flags)
1403fdb708SPaul Mundt {
1503fdb708SPaul Mundt 	unsigned long __dummy0, __dummy1;
1603fdb708SPaul Mundt 
1703fdb708SPaul Mundt 	if (flags == RAW_IRQ_DISABLED) {
1803fdb708SPaul Mundt 		__asm__ __volatile__ (
1903fdb708SPaul Mundt 			"stc	sr, %0\n\t"
2003fdb708SPaul Mundt 			"or	#0xf0, %0\n\t"
2103fdb708SPaul Mundt 			"ldc	%0, sr\n\t"
2203fdb708SPaul Mundt 			: "=&z" (__dummy0)
2303fdb708SPaul Mundt 			: /* no inputs */
2403fdb708SPaul Mundt 			: "memory"
2503fdb708SPaul Mundt 		);
2603fdb708SPaul Mundt 	} else {
2703fdb708SPaul Mundt 		__asm__ __volatile__ (
2803fdb708SPaul Mundt 			"stc	sr, %0\n\t"
2903fdb708SPaul Mundt 			"and	%1, %0\n\t"
3003fdb708SPaul Mundt #ifdef CONFIG_CPU_HAS_SR_RB
3103fdb708SPaul Mundt 			"stc	r6_bank, %1\n\t"
3203fdb708SPaul Mundt 			"or	%1, %0\n\t"
3303fdb708SPaul Mundt #endif
3403fdb708SPaul Mundt 			"ldc	%0, sr\n\t"
3503fdb708SPaul Mundt 			: "=&r" (__dummy0), "=r" (__dummy1)
3603fdb708SPaul Mundt 			: "1" (~RAW_IRQ_DISABLED)
3703fdb708SPaul Mundt 			: "memory"
3803fdb708SPaul Mundt 		);
3903fdb708SPaul Mundt 	}
4003fdb708SPaul Mundt }
4103fdb708SPaul Mundt EXPORT_SYMBOL(raw_local_irq_restore);
4203fdb708SPaul Mundt 
4303fdb708SPaul Mundt unsigned long __raw_local_save_flags(void)
4403fdb708SPaul Mundt {
4503fdb708SPaul Mundt 	unsigned long flags;
4603fdb708SPaul Mundt 
4703fdb708SPaul Mundt 	__asm__ __volatile__ (
4803fdb708SPaul Mundt 		"stc	sr, %0\n\t"
4903fdb708SPaul Mundt 		"and	#0xf0, %0\n\t"
5003fdb708SPaul Mundt 		: "=&z" (flags)
5103fdb708SPaul Mundt 		: /* no inputs */
5203fdb708SPaul Mundt 		: "memory"
5303fdb708SPaul Mundt 	);
5403fdb708SPaul Mundt 
5503fdb708SPaul Mundt 	return flags;
5603fdb708SPaul Mundt }
5703fdb708SPaul Mundt EXPORT_SYMBOL(__raw_local_save_flags);
58