2006-03-12 01:12:27 +00:00
|
|
|
/*
|
2016-02-06 03:30:11 +00:00
|
|
|
* U-Boot - system.h
|
2006-03-12 01:12:27 +00:00
|
|
|
*
|
2007-04-05 10:31:18 +00:00
|
|
|
* Copyright (c) 2005-2007 Analog Devices Inc.
|
2006-03-12 01:12:27 +00:00
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2006-03-12 01:12:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BLACKFIN_SYSTEM_H
|
|
|
|
#define _BLACKFIN_SYSTEM_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupt configuring macros.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern int irq_flags;
|
|
|
|
|
2008-02-05 00:26:55 +00:00
|
|
|
#define local_irq_enable() \
|
|
|
|
__asm__ __volatile__ ( \
|
|
|
|
"sti %0;" \
|
|
|
|
: \
|
|
|
|
: "d" (irq_flags) \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define local_irq_disable() \
|
|
|
|
do { \
|
|
|
|
int __tmp_dummy; \
|
|
|
|
__asm__ __volatile__ ( \
|
|
|
|
"cli %0;" \
|
|
|
|
: "=d" (__tmp_dummy) \
|
|
|
|
); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
# define local_irq_save(x) \
|
|
|
|
__asm__ __volatile__ ( \
|
|
|
|
"cli %0;" \
|
|
|
|
: "=&d" (x) \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define local_save_flags(x) \
|
|
|
|
__asm__ __volatile__ ( \
|
|
|
|
"cli %0;" \
|
|
|
|
"sti %0;" \
|
|
|
|
: "=d" (x) \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define irqs_enabled_from_flags(x) ((x) != 0x1f)
|
|
|
|
|
|
|
|
#define local_irq_restore(x) \
|
|
|
|
do { \
|
|
|
|
if (irqs_enabled_from_flags(x)) \
|
|
|
|
local_irq_enable(); \
|
|
|
|
} while (0)
|
2006-03-12 01:12:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Force strict CPU ordering.
|
|
|
|
*/
|
|
|
|
#define nop() asm volatile ("nop;\n\t"::)
|
|
|
|
#define mb() asm volatile ("" : : :"memory")
|
|
|
|
#define rmb() asm volatile ("" : : :"memory")
|
|
|
|
#define wmb() asm volatile ("" : : :"memory")
|
|
|
|
#define set_rmb(var, value) do { xchg(&var, value); } while (0)
|
|
|
|
#define set_mb(var, value) set_rmb(var, value)
|
|
|
|
#define set_wmb(var, value) do { var = value; wmb(); } while (0)
|
|
|
|
|
2008-02-05 00:26:55 +00:00
|
|
|
#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
|
2006-03-12 01:12:27 +00:00
|
|
|
|
|
|
|
struct __xchg_dummy {
|
|
|
|
unsigned long a[100];
|
|
|
|
};
|
2008-02-05 00:26:55 +00:00
|
|
|
#define __xg(x) ((volatile struct __xchg_dummy *)(x))
|
2006-03-12 01:12:27 +00:00
|
|
|
|
|
|
|
static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
|
|
|
|
int size)
|
|
|
|
{
|
2008-02-05 00:26:55 +00:00
|
|
|
unsigned long tmp = 0;
|
2006-03-12 01:12:27 +00:00
|
|
|
unsigned long flags = 0;
|
|
|
|
|
2008-02-05 00:26:55 +00:00
|
|
|
local_irq_save(flags);
|
2006-03-12 01:12:27 +00:00
|
|
|
|
|
|
|
switch (size) {
|
|
|
|
case 1:
|
2008-02-05 00:26:55 +00:00
|
|
|
__asm__ __volatile__
|
|
|
|
("%0 = b%2 (z);\n\t"
|
|
|
|
"b%2 = %1;\n\t"
|
|
|
|
: "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
|
2006-03-12 01:12:27 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2008-02-05 00:26:55 +00:00
|
|
|
__asm__ __volatile__
|
|
|
|
("%0 = w%2 (z);\n\t"
|
|
|
|
"w%2 = %1;\n\t"
|
|
|
|
: "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
|
2006-03-12 01:12:27 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2008-02-05 00:26:55 +00:00
|
|
|
__asm__ __volatile__
|
|
|
|
("%0 = %2;\n\t"
|
|
|
|
"%2 = %1;\n\t"
|
|
|
|
: "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
|
2006-03-12 01:12:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-02-05 00:26:55 +00:00
|
|
|
local_irq_restore(flags);
|
2006-03-12 01:12:27 +00:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2010-06-02 08:17:26 +00:00
|
|
|
void bfin_reset_boot_spi_cs(unsigned short pin);
|
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
#endif /* _BLACKFIN_SYSTEM_H */
|