xref: /linux/arch/sh/kernel/irq_32.c (revision 597473720f4dc69749542bfcfed4a927a43d935e)
1*5933f6d2SKuninori Morimoto // SPDX-License-Identifier: GPL-2.0
203fdb708SPaul Mundt /*
303fdb708SPaul Mundt  * SHcompact irqflags support
403fdb708SPaul Mundt  *
503fdb708SPaul Mundt  * Copyright (C) 2006 - 2009 Paul Mundt
603fdb708SPaul Mundt  */
703fdb708SPaul Mundt #include <linux/irqflags.h>
803fdb708SPaul Mundt #include <linux/module.h>
903fdb708SPaul Mundt 
arch_local_irq_restore(unsigned long flags)10df9ee292SDavid Howells void notrace arch_local_irq_restore(unsigned long flags)
1103fdb708SPaul Mundt {
1203fdb708SPaul Mundt 	unsigned long __dummy0, __dummy1;
1303fdb708SPaul Mundt 
14df9ee292SDavid Howells 	if (flags == ARCH_IRQ_DISABLED) {
1503fdb708SPaul Mundt 		__asm__ __volatile__ (
1603fdb708SPaul Mundt 			"stc	sr, %0\n\t"
1703fdb708SPaul Mundt 			"or	#0xf0, %0\n\t"
1803fdb708SPaul Mundt 			"ldc	%0, sr\n\t"
1903fdb708SPaul Mundt 			: "=&z" (__dummy0)
2003fdb708SPaul Mundt 			: /* no inputs */
2103fdb708SPaul Mundt 			: "memory"
2203fdb708SPaul Mundt 		);
2303fdb708SPaul Mundt 	} else {
2403fdb708SPaul Mundt 		__asm__ __volatile__ (
2503fdb708SPaul Mundt 			"stc	sr, %0\n\t"
2603fdb708SPaul Mundt 			"and	%1, %0\n\t"
2703fdb708SPaul Mundt #ifdef CONFIG_CPU_HAS_SR_RB
2803fdb708SPaul Mundt 			"stc	r6_bank, %1\n\t"
2903fdb708SPaul Mundt 			"or	%1, %0\n\t"
3003fdb708SPaul Mundt #endif
3103fdb708SPaul Mundt 			"ldc	%0, sr\n\t"
3203fdb708SPaul Mundt 			: "=&r" (__dummy0), "=r" (__dummy1)
33df9ee292SDavid Howells 			: "1" (~ARCH_IRQ_DISABLED)
3403fdb708SPaul Mundt 			: "memory"
3503fdb708SPaul Mundt 		);
3603fdb708SPaul Mundt 	}
3703fdb708SPaul Mundt }
38df9ee292SDavid Howells EXPORT_SYMBOL(arch_local_irq_restore);
3903fdb708SPaul Mundt 
arch_local_save_flags(void)40df9ee292SDavid Howells unsigned long notrace arch_local_save_flags(void)
4103fdb708SPaul Mundt {
4203fdb708SPaul Mundt 	unsigned long flags;
4303fdb708SPaul Mundt 
4403fdb708SPaul Mundt 	__asm__ __volatile__ (
4503fdb708SPaul Mundt 		"stc	sr, %0\n\t"
4603fdb708SPaul Mundt 		"and	#0xf0, %0\n\t"
4703fdb708SPaul Mundt 		: "=&z" (flags)
4803fdb708SPaul Mundt 		: /* no inputs */
4903fdb708SPaul Mundt 		: "memory"
5003fdb708SPaul Mundt 	);
5103fdb708SPaul Mundt 
5203fdb708SPaul Mundt 	return flags;
5303fdb708SPaul Mundt }
54df9ee292SDavid Howells EXPORT_SYMBOL(arch_local_save_flags);
55