blob: e09cdc4ada68c8cb2593568396d1af8eac1be9bf [file] [log] [blame]
Kuninori Morimoto5933f6d2018-12-28 00:32:24 -08001// SPDX-License-Identifier: GPL-2.0
Paul Mundt03fdb702009-10-17 21:06:39 +09002/*
3 * SHcompact irqflags support
4 *
5 * Copyright (C) 2006 - 2009 Paul Mundt
Paul Mundt03fdb702009-10-17 21:06:39 +09006 */
7#include <linux/irqflags.h>
8#include <linux/module.h>
9
David Howellsdf9ee292010-10-07 14:08:55 +010010void notrace arch_local_irq_restore(unsigned long flags)
Paul Mundt03fdb702009-10-17 21:06:39 +090011{
12 unsigned long __dummy0, __dummy1;
13
David Howellsdf9ee292010-10-07 14:08:55 +010014 if (flags == ARCH_IRQ_DISABLED) {
Paul Mundt03fdb702009-10-17 21:06:39 +090015 __asm__ __volatile__ (
16 "stc sr, %0\n\t"
17 "or #0xf0, %0\n\t"
18 "ldc %0, sr\n\t"
19 : "=&z" (__dummy0)
20 : /* no inputs */
21 : "memory"
22 );
23 } else {
24 __asm__ __volatile__ (
25 "stc sr, %0\n\t"
26 "and %1, %0\n\t"
27#ifdef CONFIG_CPU_HAS_SR_RB
28 "stc r6_bank, %1\n\t"
29 "or %1, %0\n\t"
30#endif
31 "ldc %0, sr\n\t"
32 : "=&r" (__dummy0), "=r" (__dummy1)
David Howellsdf9ee292010-10-07 14:08:55 +010033 : "1" (~ARCH_IRQ_DISABLED)
Paul Mundt03fdb702009-10-17 21:06:39 +090034 : "memory"
35 );
36 }
37}
David Howellsdf9ee292010-10-07 14:08:55 +010038EXPORT_SYMBOL(arch_local_irq_restore);
Paul Mundt03fdb702009-10-17 21:06:39 +090039
David Howellsdf9ee292010-10-07 14:08:55 +010040unsigned long notrace arch_local_save_flags(void)
Paul Mundt03fdb702009-10-17 21:06:39 +090041{
42 unsigned long flags;
43
44 __asm__ __volatile__ (
45 "stc sr, %0\n\t"
46 "and #0xf0, %0\n\t"
47 : "=&z" (flags)
48 : /* no inputs */
49 : "memory"
50 );
51
52 return flags;
53}
David Howellsdf9ee292010-10-07 14:08:55 +010054EXPORT_SYMBOL(arch_local_save_flags);