]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/staging/sxg/sxg_os.h
backlight: Add driver for Tabletkiosk Sahara TouchIT-213 Tablet PC
[linux-2.6-omap-h63xx.git] / drivers / staging / sxg / sxg_os.h
1 /**************************************************************************
2  *
3  * Copyright (C) 2000-2008 Alacritech, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above
12  *    copyright notice, this list of conditions and the following
13  *    disclaimer in the documentation and/or other materials provided
14  *    with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY ALACRITECH, INC. ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ALACRITECH, INC. OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * The views and conclusions contained in the software and documentation
30  * are those of the authors and should not be interpreted as representing
31  * official policies, either expressed or implied, of Alacritech, Inc.
32  *
33  **************************************************************************/
34
35 /*
36  * FILENAME: sxg_os.h
37  *
38  * These are the Linux-specific definitions required for the SLICOSS
39  * driver, which should allow for greater portability to other OSes.
40  */
41 #ifndef _SLIC_OS_SPECIFIC_H_
42 #define _SLIC_OS_SPECIFIC_H_
43
44 #define FALSE   (0)
45 #define TRUE    (1)
46
47
48 typedef struct _LIST_ENTRY {
49         struct _LIST_ENTRY *nle_flink;
50         struct _LIST_ENTRY *nle_blink;
51 } list_entry, LIST_ENTRY, *PLIST_ENTRY;
52
53 #define InitializeListHead(l)                   \
54         (l)->nle_flink = (l)->nle_blink = (l)
55
56 #define IsListEmpty(h)                          \
57         ((h)->nle_flink == (h))
58
59 #define RemoveEntryList(e)                      \
60         do {                                    \
61                 list_entry              *b;     \
62                 list_entry              *f;     \
63                                                 \
64                 f = (e)->nle_flink;             \
65                 b = (e)->nle_blink;             \
66                 b->nle_flink = f;               \
67                 f->nle_blink = b;               \
68         } while (0)
69
70 /* These two have to be inlined since they return things. */
71
72 static __inline PLIST_ENTRY
73 RemoveHeadList(list_entry *l)
74 {
75         list_entry              *f;
76         list_entry              *e;
77
78         e = l->nle_flink;
79         f = e->nle_flink;
80         l->nle_flink = f;
81         f->nle_blink = l;
82
83         return (e);
84 }
85
86 static __inline PLIST_ENTRY
87 RemoveTailList(list_entry *l)
88 {
89         list_entry              *b;
90         list_entry              *e;
91
92         e = l->nle_blink;
93         b = e->nle_blink;
94         l->nle_blink = b;
95         b->nle_flink = l;
96
97         return (e);
98 }
99
100
101 #define InsertTailList(l, e)                    \
102         do {                                    \
103                 list_entry              *b;     \
104                                                 \
105                 b = (l)->nle_blink;             \
106                 (e)->nle_flink = (l);           \
107                 (e)->nle_blink = b;             \
108                 b->nle_flink = (e);             \
109                 (l)->nle_blink = (e);           \
110         } while (0)
111
112 #define InsertHeadList(l, e)                    \
113         do {                                    \
114                 list_entry              *f;     \
115                                                 \
116                 f = (l)->nle_flink;             \
117                 (e)->nle_flink = f;             \
118                 (e)->nle_blink = l;             \
119                 f->nle_blink = (e);             \
120                 (l)->nle_flink = (e);           \
121         } while (0)
122
123
124 #define ATK_DEBUG  1
125
126 #if ATK_DEBUG
127 #define SLIC_TIMESTAMP(value) {                                             \
128         struct timeval  timev;                                              \
129         do_gettimeofday(&timev);                                            \
130         value = timev.tv_sec*1000000 + timev.tv_usec;                       \
131 }
132 #else
133 #define SLIC_TIMESTAMP(value)
134 #endif
135
136
137 /******************  SXG DEFINES  *****************************************/
138
139 #ifdef  ATKDBG
140 #define SXG_TIMESTAMP(value) {                                             \
141         struct timeval  timev;                                              \
142         do_gettimeofday(&timev);                                            \
143         value = timev.tv_sec*1000000 + timev.tv_usec;                       \
144 }
145 #else
146 #define SXG_TIMESTAMP(value)
147 #endif
148
149 #define WRITE_REG(reg,value,flush)                  sxg_reg32_write((&reg), (value), (flush))
150 #define WRITE_REG64(a,reg,value,cpu)                sxg_reg64_write((a),(&reg),(value),(cpu))
151 #define READ_REG(reg,value)   (value) = readl((void __iomem *)(&reg))
152
153 #endif  /* _SLIC_OS_SPECIFIC_H_  */
154