Wolfgang Denk | 7b64fef | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 Atmel Corporation |
| 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | 7b64fef | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 5 | */ |
| 6 | #include <common.h> |
| 7 | |
| 8 | #include <asm/sysreg.h> |
| 9 | |
| 10 | void enable_interrupts(void) |
| 11 | { |
| 12 | asm volatile("csrf %0" : : "n"(SYSREG_GM_OFFSET)); |
| 13 | } |
| 14 | |
| 15 | int disable_interrupts(void) |
| 16 | { |
| 17 | unsigned long sr; |
| 18 | |
| 19 | sr = sysreg_read(SR); |
| 20 | asm volatile("ssrf %0" : : "n"(SYSREG_GM_OFFSET)); |
| 21 | |
Olav Morken | b423f94 | 2009-01-23 12:56:32 +0100 | [diff] [blame] | 22 | #ifdef CONFIG_AT32UC3A0xxx |
| 23 | /* Two NOPs are required after masking interrupts on the |
| 24 | * AT32UC3A0512ES. See errata 41.4.5.5. */ |
| 25 | asm("nop"); |
| 26 | asm("nop"); |
| 27 | #endif |
| 28 | |
Haavard Skinnemoen | df9c25e | 2007-12-17 11:02:44 +0100 | [diff] [blame] | 29 | return !SYSREG_BFEXT(GM, sr); |
Wolfgang Denk | 7b64fef | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 30 | } |