Mike Frysinger | 8f86001 | 2009-06-08 12:49:48 -0400 | [diff] [blame^] | 1 | /* |
| 2 | * interface to Blackfin CEC |
| 3 | * |
| 4 | * Copyright 2009 Analog Devices Inc. |
| 5 | * Licensed under the GPL-2 or later. |
| 6 | */ |
| 7 | |
| 8 | #ifndef __ASM_BFIN_IRQFLAGS_H__ |
| 9 | #define __ASM_BFIN_IRQFLAGS_H__ |
| 10 | |
| 11 | #ifdef CONFIG_SMP |
| 12 | # include <asm/pda.h> |
| 13 | # include <asm/processor.h> |
| 14 | /* Forward decl needed due to cdef inter dependencies */ |
| 15 | static inline uint32_t __pure bfin_dspid(void); |
| 16 | # define blackfin_core_id() (bfin_dspid() & 0xff) |
| 17 | # define bfin_irq_flags cpu_pda[blackfin_core_id()].imask |
| 18 | #else |
| 19 | extern unsigned long bfin_irq_flags; |
| 20 | #endif |
| 21 | |
| 22 | static inline void bfin_sti(unsigned long flags) |
| 23 | { |
| 24 | asm volatile("sti %0;" : : "d" (flags)); |
| 25 | } |
| 26 | |
| 27 | static inline unsigned long bfin_cli(void) |
| 28 | { |
| 29 | unsigned long flags; |
| 30 | asm volatile("cli %0;" : "=d" (flags)); |
| 31 | return flags; |
| 32 | } |
| 33 | |
| 34 | static inline void raw_local_irq_disable(void) |
| 35 | { |
| 36 | bfin_cli(); |
| 37 | } |
| 38 | static inline void raw_local_irq_enable(void) |
| 39 | { |
| 40 | bfin_sti(bfin_irq_flags); |
| 41 | } |
| 42 | |
| 43 | #define raw_local_save_flags(flags) do { (flags) = bfin_read_IMASK(); } while (0) |
| 44 | |
| 45 | #define raw_irqs_disabled_flags(flags) (((flags) & ~0x3f) == 0) |
| 46 | |
| 47 | static inline void raw_local_irq_restore(unsigned long flags) |
| 48 | { |
| 49 | if (!raw_irqs_disabled_flags(flags)) |
| 50 | raw_local_irq_enable(); |
| 51 | } |
| 52 | |
| 53 | static inline unsigned long __raw_local_irq_save(void) |
| 54 | { |
| 55 | unsigned long flags = bfin_cli(); |
| 56 | #ifdef CONFIG_DEBUG_HWERR |
| 57 | bfin_sti(0x3f); |
| 58 | #endif |
| 59 | return flags; |
| 60 | } |
| 61 | #define raw_local_irq_save(flags) do { (flags) = __raw_local_irq_save(); } while (0) |
| 62 | |
| 63 | #endif |