[media] coda: add Freescale firmware compatibility location
[linux-2.6-block.git] / include / drm / drm_os_linux.h
CommitLineData
1da177e4
LT
1/**
2 * \file drm_os_linux.h
3 * OS abstraction macros.
4 */
5
1da177e4
LT
6#include <linux/interrupt.h> /* For task queue support */
7#include <linux/delay.h>
8
87f0da55 9#ifndef readq
522b5cc7 10static inline u64 readq(void __iomem *reg)
87f0da55
DA
11{
12 return ((u64) readl(reg)) | (((u64) readl(reg + 4UL)) << 32);
13}
14
522b5cc7 15static inline void writeq(u64 val, void __iomem *reg)
87f0da55
DA
16{
17 writel(val & 0xffffffff, reg);
18 writel(val >> 32, reg + 0x4UL);
19}
20#endif
21
1da177e4 22/** Current process ID */
ba25f9dc 23#define DRM_CURRENTPID task_pid_nr(current)
1da177e4
LT
24#define DRM_UDELAY(d) udelay(d)
25/** Read a byte from a MMIO region */
26#define DRM_READ8(map, offset) readb(((void __iomem *)(map)->handle) + (offset))
27/** Read a word from a MMIO region */
28#define DRM_READ16(map, offset) readw(((void __iomem *)(map)->handle) + (offset))
29/** Read a dword from a MMIO region */
30#define DRM_READ32(map, offset) readl(((void __iomem *)(map)->handle) + (offset))
31/** Write a byte into a MMIO region */
32#define DRM_WRITE8(map, offset, val) writeb(val, ((void __iomem *)(map)->handle) + (offset))
33/** Write a word into a MMIO region */
34#define DRM_WRITE16(map, offset, val) writew(val, ((void __iomem *)(map)->handle) + (offset))
35/** Write a dword into a MMIO region */
36#define DRM_WRITE32(map, offset, val) writel(val, ((void __iomem *)(map)->handle) + (offset))
87f0da55
DA
37
38/** Read a qword from a MMIO region - be careful using these unless you really understand them */
39#define DRM_READ64(map, offset) readq(((void __iomem *)(map)->handle) + (offset))
40/** Write a qword into a MMIO region */
41#define DRM_WRITE64(map, offset, val) writeq(val, ((void __iomem *)(map)->handle) + (offset))
42
1da177e4
LT
43#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
44do { \
45 DECLARE_WAITQUEUE(entry, current); \
46 unsigned long end = jiffies + (timeout); \
47 add_wait_queue(&(queue), &entry); \
48 \
49 for (;;) { \
50 __set_current_state(TASK_INTERRUPTIBLE); \
51 if (condition) \
52 break; \
53 if (time_after_eq(jiffies, end)) { \
54 ret = -EBUSY; \
55 break; \
56 } \
57 schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \
58 if (signal_pending(current)) { \
59 ret = -EINTR; \
60 break; \
61 } \
62 } \
63 __set_current_state(TASK_RUNNING); \
64 remove_wait_queue(&(queue), &entry); \
65} while (0)