Merge branch 'for-2.6.31' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6
[pandora-kernel.git] / drivers / staging / cpc-usb / cpc_int.h
1 /*
2  * CPCLIB
3  *
4  * Copyright (C) 2000-2008 EMS Dr. Thomas Wuensche
5  *
6  * This program is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9  *
10  */
11 #ifndef CPC_INT_H
12 #define CPC_INT_H
13
14 #include <linux/wait.h>
15
16 #define CPC_MSG_BUF_CNT 1500
17
18 #define CPC_PROC_DIR "driver/"
19
20 #undef dbg
21 #undef err
22 #undef info
23
24 /* Use our own dbg macro */
25 #define dbg(format, arg...) do { if (debug) printk( KERN_INFO format "\n" , ## arg); } while (0)
26 #define err(format, arg...) do { printk( KERN_INFO "ERROR " format "\n" , ## arg); } while (0)
27 #define info(format, arg...) do { printk( KERN_INFO format "\n" , ## arg); } while (0)
28
29 /* Macros help using of our buffers */
30 #define IsBufferFull(x)     (!(x)->WnR) && ((x)->iidx == (x)->oidx)
31 #define IsBufferEmpty(x)    ((x)->WnR) && ((x)->iidx == (x)->oidx)
32 #define IsBufferNotEmpty(x) (!(x)->WnR) || ((x)->iidx != (x)->oidx)
33 #define ResetBuffer(x)      do { (x)->oidx = (x)->iidx=0; (x)->WnR = 1; } while(0);
34
35 #define CPC_BufWriteAllowed ((chan->oidx != chan->iidx) || chan->WnR)
36
37 typedef void (*chan_write_byte_t) (void *chan, unsigned int reg,
38                                    unsigned char val);
39 typedef unsigned char (*chan_read_byte_t) (void *chan, unsigned int reg);
40
41 typedef struct CPC_CHAN {
42         void __iomem * canBase; // base address of SJA1000
43         chan_read_byte_t read_byte;     // CAN controller read access routine
44         chan_write_byte_t write_byte;   // CAN controller write access routine
45         CPC_MSG_T *buf;         // buffer for CPC msg
46         unsigned int iidx;
47         unsigned int oidx;
48         unsigned int WnR;
49         unsigned int minor;
50         unsigned int locked;
51         unsigned int irqDisabled;
52
53         unsigned char cpcCtrlCANMessage;
54         unsigned char cpcCtrlCANState;
55         unsigned char cpcCtrlBUSState;
56
57         unsigned char controllerType;
58
59         unsigned long ovrTimeSec;
60         unsigned long ovrTimeNSec;
61         unsigned long ovrLockedBuffer;
62         CPC_OVERRUN_T ovr;
63
64         /* for debugging only */
65         unsigned int handledIrqs;
66         unsigned int lostMessages;
67
68         unsigned int sentStdCan;
69         unsigned int sentExtCan;
70         unsigned int sentStdRtr;
71         unsigned int sentExtRtr;
72
73         unsigned int recvStdCan;
74         unsigned int recvExtCan;
75         unsigned int recvStdRtr;
76         unsigned int recvExtRtr;
77
78         wait_queue_head_t *CPCWait_q;
79
80         void *private;
81 } CPC_CHAN_T;
82
83 #endif