tty/serial/sirf: fix MODULE_DEVICE_TABLE
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / staging / comedi / drivers / addi-data / addi_common.h
1 /*
2  *  Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
3  *
4  *      ADDI-DATA GmbH
5  *      Dieselstrasse 3
6  *      D-77833 Ottersweier
7  *      Tel: +19(0)7223/9493-0
8  *      Fax: +49(0)7223/9493-92
9  *      http://www.addi-data.com
10  *      info@addi-data.com
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the Free
14  * Software Foundation; either version 2 of the License, or (at your option)
15  * any later version.
16  */
17
18 #include <linux/sched.h>
19 #include <linux/interrupt.h>
20
21 #define LOBYTE(W)       (unsigned char)((W) & 0xFF)
22 #define HIBYTE(W)       (unsigned char)(((W) >> 8) & 0xFF)
23 #define MAKEWORD(H, L)  (unsigned short)((L) | ((H) << 8))
24 #define LOWORD(W)       (unsigned short)((W) & 0xFFFF)
25 #define HIWORD(W)       (unsigned short)(((W) >> 16) & 0xFFFF)
26 #define MAKEDWORD(H, L) (unsigned int)((L) | ((H) << 16))
27
28 #define ADDI_ENABLE             1
29 #define ADDI_DISABLE            0
30 #define APCI1710_SAVE_INTERRUPT 1
31
32 #define ADDIDATA_EEPROM         1
33 #define ADDIDATA_NO_EEPROM      0
34 #define ADDIDATA_93C76          "93C76"
35 #define ADDIDATA_S5920          "S5920"
36 #define ADDIDATA_S5933          "S5933"
37 #define ADDIDATA_9054           "9054"
38
39 /* ADDIDATA Enable Disable */
40 #define ADDIDATA_ENABLE         1
41 #define ADDIDATA_DISABLE        0
42
43 /* Structures */
44
45 /* structure for the boardtype */
46 struct addi_board {
47         const char *pc_DriverName;      /*  driver name */
48         int i_VendorId;         /* PCI vendor a device ID of card */
49         int i_DeviceId;
50         int i_IorangeBase0;
51         int i_IorangeBase1;
52         int i_IorangeBase2;     /*   base 2 range */
53         int i_IorangeBase3;     /*   base 3 range */
54         int i_PCIEeprom;        /*  eeprom present or not */
55         char *pc_EepromChip;    /*  type of chip */
56         int i_NbrAiChannel;     /*  num of A/D chans */
57         int i_NbrAiChannelDiff; /*  num of A/D chans in diff mode */
58         int i_AiChannelList;    /*  len of chanlist */
59         int i_NbrAoChannel;     /*  num of D/A chans */
60         int i_AiMaxdata;        /*  resolution of A/D */
61         int i_AoMaxdata;        /*  resolution of D/A */
62         const struct comedi_lrange *pr_AiRangelist;     /* rangelist for A/D */
63         const struct comedi_lrange *pr_AoRangelist;     /* rangelist for D/A */
64
65         int i_NbrDiChannel;     /*  Number of DI channels */
66         int i_NbrDoChannel;     /*  Number of DO channels */
67         int i_DoMaxdata;        /*  data to set all channels high */
68
69         int i_NbrTTLChannel;    /*  Number of TTL channels */
70
71         int i_Dma;              /*  dma present or not */
72         int i_Timer;            /*    timer subdevice present or not */
73         unsigned char b_AvailableConvertUnit;
74         unsigned int ui_MinAcquisitiontimeNs;   /*  Minimum Acquisition in Nano secs */
75         unsigned int ui_MinDelaytimeNs; /*  Minimum Delay in Nano secs */
76
77         /* interrupt and reset */
78         void (*interrupt)(int irq, void *d);
79         int (*reset)(struct comedi_device *);
80
81         /* Subdevice functions */
82
83         /* ANALOG INPUT */
84         int (*ai_config)(struct comedi_device *, struct comedi_subdevice *,
85                          struct comedi_insn *, unsigned int *);
86         int (*ai_read)(struct comedi_device *, struct comedi_subdevice *,
87                        struct comedi_insn *, unsigned int *);
88         int (*ai_write)(struct comedi_device *, struct comedi_subdevice *,
89                         struct comedi_insn *, unsigned int *);
90         int (*ai_bits)(struct comedi_device *, struct comedi_subdevice *,
91                        struct comedi_insn *, unsigned int *);
92         int (*ai_cmdtest)(struct comedi_device *, struct comedi_subdevice *,
93                           struct comedi_cmd *);
94         int (*ai_cmd)(struct comedi_device *, struct comedi_subdevice *);
95         int (*ai_cancel)(struct comedi_device *, struct comedi_subdevice *);
96
97         /* Analog Output */
98         int (*ao_config)(struct comedi_device *, struct comedi_subdevice *,
99                          struct comedi_insn *, unsigned int *);
100         int (*ao_write)(struct comedi_device *, struct comedi_subdevice *,
101                         struct comedi_insn *, unsigned int *);
102         int (*ao_bits)(struct comedi_device *, struct comedi_subdevice *,
103                        struct comedi_insn *, unsigned int *);
104
105         /* Digital Input */
106         int (*di_config)(struct comedi_device *, struct comedi_subdevice *,
107                          struct comedi_insn *, unsigned int *);
108         int (*di_read)(struct comedi_device *, struct comedi_subdevice *,
109                        struct comedi_insn *, unsigned int *);
110         int (*di_write)(struct comedi_device *, struct comedi_subdevice *,
111                         struct comedi_insn *, unsigned int *);
112         int (*di_bits)(struct comedi_device *, struct comedi_subdevice *,
113                        struct comedi_insn *, unsigned int *);
114
115         /* Digital Output */
116         int (*do_config)(struct comedi_device *, struct comedi_subdevice *,
117                          struct comedi_insn *, unsigned int *);
118         int (*do_write)(struct comedi_device *, struct comedi_subdevice *,
119                         struct comedi_insn *, unsigned int *);
120         int (*do_bits)(struct comedi_device *, struct comedi_subdevice *,
121                        struct comedi_insn *, unsigned int *);
122         int (*do_read)(struct comedi_device *, struct comedi_subdevice *,
123                        struct comedi_insn *, unsigned int *);
124
125         /* TIMER */
126         int (*timer_config)(struct comedi_device *, struct comedi_subdevice *,
127                             struct comedi_insn *, unsigned int *);
128         int (*timer_write)(struct comedi_device *, struct comedi_subdevice *,
129                            struct comedi_insn *, unsigned int *);
130         int (*timer_read)(struct comedi_device *, struct comedi_subdevice *,
131                           struct comedi_insn *, unsigned int *);
132         int (*timer_bits)(struct comedi_device *, struct comedi_subdevice *,
133                           struct comedi_insn *, unsigned int *);
134
135         /* TTL IO */
136         int (*ttl_config)(struct comedi_device *, struct comedi_subdevice *,
137                           struct comedi_insn *, unsigned int *);
138         int (*ttl_bits)(struct comedi_device *, struct comedi_subdevice *,
139                         struct comedi_insn *, unsigned int *);
140         int (*ttl_read)(struct comedi_device *, struct comedi_subdevice *,
141                         struct comedi_insn *, unsigned int *);
142         int (*ttl_write)(struct comedi_device *, struct comedi_subdevice *,
143                          struct comedi_insn *, unsigned int *);
144 };
145
146 /* MODULE INFO STRUCTURE */
147
148 union str_ModuleInfo {
149         /* Incremental counter infos */
150         struct {
151                 union {
152                         struct {
153                                 unsigned char b_ModeRegister1;
154                                 unsigned char b_ModeRegister2;
155                                 unsigned char b_ModeRegister3;
156                                 unsigned char b_ModeRegister4;
157                         } s_ByteModeRegister;
158                         unsigned int dw_ModeRegister1_2_3_4;
159                 } s_ModeRegister;
160
161                 struct {
162                         unsigned int b_IndexInit:1;
163                         unsigned int b_CounterInit:1;
164                         unsigned int b_ReferenceInit:1;
165                         unsigned int b_IndexInterruptOccur:1;
166                         unsigned int b_CompareLogicInit:1;
167                         unsigned int b_FrequencyMeasurementInit:1;
168                         unsigned int b_FrequencyMeasurementEnable:1;
169                 } s_InitFlag;
170
171         } s_SiemensCounterInfo;
172
173         /* SSI infos */
174         struct {
175                 unsigned char b_SSIProfile;
176                 unsigned char b_PositionTurnLength;
177                 unsigned char b_TurnCptLength;
178                 unsigned char b_SSIInit;
179         } s_SSICounterInfo;
180
181         /* TTL I/O infos */
182         struct {
183                 unsigned char b_TTLInit;
184                 unsigned char b_PortConfiguration[4];
185         } s_TTLIOInfo;
186
187         /* Digital I/O infos */
188         struct {
189                 unsigned char b_DigitalInit;
190                 unsigned char b_ChannelAMode;
191                 unsigned char b_ChannelBMode;
192                 unsigned char b_OutputMemoryEnabled;
193                 unsigned int dw_OutputMemory;
194         } s_DigitalIOInfo;
195
196       /*********************/
197         /* 82X54 timer infos */
198       /*********************/
199
200         struct {
201                 struct {
202                         unsigned char b_82X54Init;
203                         unsigned char b_InputClockSelection;
204                         unsigned char b_InputClockLevel;
205                         unsigned char b_OutputLevel;
206                         unsigned char b_HardwareGateLevel;
207                         unsigned int dw_ConfigurationWord;
208                 } s_82X54TimerInfo[3];
209                 unsigned char b_InterruptMask;
210         } s_82X54ModuleInfo;
211
212       /*********************/
213         /* Chronometer infos */
214       /*********************/
215
216         struct {
217                 unsigned char b_ChronoInit;
218                 unsigned char b_InterruptMask;
219                 unsigned char b_PCIInputClock;
220                 unsigned char b_TimingUnit;
221                 unsigned char b_CycleMode;
222                 double d_TimingInterval;
223                 unsigned int dw_ConfigReg;
224         } s_ChronoModuleInfo;
225
226       /***********************/
227         /* Pulse encoder infos */
228       /***********************/
229
230         struct {
231                 struct {
232                         unsigned char b_PulseEncoderInit;
233                 } s_PulseEncoderInfo[4];
234                 unsigned int dw_SetRegister;
235                 unsigned int dw_ControlRegister;
236                 unsigned int dw_StatusRegister;
237         } s_PulseEncoderModuleInfo;
238
239         /* Tor conter infos */
240         struct {
241                 struct {
242                         unsigned char b_TorCounterInit;
243                         unsigned char b_TimingUnit;
244                         unsigned char b_InterruptEnable;
245                         double d_TimingInterval;
246                         unsigned int ul_RealTimingInterval;
247                 } s_TorCounterInfo[2];
248                 unsigned char b_PCIInputClock;
249         } s_TorCounterModuleInfo;
250
251         /* PWM infos */
252         struct {
253                 struct {
254                         unsigned char b_PWMInit;
255                         unsigned char b_TimingUnit;
256                         unsigned char b_InterruptEnable;
257                         double d_LowTiming;
258                         double d_HighTiming;
259                         unsigned int ul_RealLowTiming;
260                         unsigned int ul_RealHighTiming;
261                 } s_PWMInfo[2];
262                 unsigned char b_ClockSelection;
263         } s_PWMModuleInfo;
264
265         /* ETM infos */
266         struct {
267                 struct {
268                         unsigned char b_ETMEnable;
269                         unsigned char b_ETMInterrupt;
270                 } s_ETMInfo[2];
271                 unsigned char b_ETMInit;
272                 unsigned char b_TimingUnit;
273                 unsigned char b_ClockSelection;
274                 double d_TimingInterval;
275                 unsigned int ul_Timing;
276         } s_ETMModuleInfo;
277
278         /* CDA infos */
279         struct {
280                 unsigned char b_CDAEnable;
281                 unsigned char b_CDAInterrupt;
282                 unsigned char b_CDAInit;
283                 unsigned char b_FctSelection;
284                 unsigned char b_CDAReadFIFOOverflow;
285         } s_CDAModuleInfo;
286
287 };
288
289 /* Private structure for the addi_apci3120 driver */
290 struct addi_private {
291
292         int iobase;
293         int i_IobaseAmcc;       /*  base+size for AMCC chip */
294         int i_IobaseAddon;      /* addon base address */
295         int i_IobaseReserved;
296         void __iomem *dw_AiBase;
297         unsigned char b_AiContinuous;   /*  we do unlimited AI */
298         unsigned char b_AiInitialisation;
299         unsigned int ui_AiActualScan;   /* how many scans we finished */
300         unsigned int ui_AiBufferPtr;    /*  data buffer ptr in samples */
301         unsigned int ui_AiNbrofChannels;        /*  how many channels is measured */
302         unsigned int ui_AiScanLength;   /*  Length of actual scanlist */
303         unsigned int ui_AiActualScanPosition;   /*  position in actual scan */
304         unsigned int *pui_AiChannelList;        /*  actual chanlist */
305         unsigned int ui_AiChannelList[32];      /*  actual chanlist */
306         unsigned char b_AiChannelConfiguration[32];     /*  actual chanlist */
307         unsigned int ui_AiReadData[32];
308         unsigned int dw_AiInitialised;
309         unsigned int ui_AiTimer0;       /* Timer Constant for Timer0 */
310         unsigned int ui_AiTimer1;       /* Timer constant for Timer1 */
311         unsigned int ui_AiFlags;
312         unsigned int ui_AiDataLength;
313         short *AiData;  /*  Pointer to sample data */
314         unsigned int ui_AiNbrofScans;   /*  number of scans to do */
315         unsigned short us_UseDma;       /*  To use Dma or not */
316         unsigned char b_DmaDoubleBuffer;        /*  we can use double buffering */
317         unsigned int ui_DmaActualBuffer;        /*  which buffer is used now */
318         /* UPDATE-0.7.57->0.7.68 */
319         /* unsigned int               ul_DmaBufferVirtual[2]; pointers to begin of DMA buffer */
320         short *ul_DmaBufferVirtual[2];  /*  pointers to begin of DMA buffer */
321         unsigned int ul_DmaBufferHw[2]; /*  hw address of DMA buff */
322         unsigned int ui_DmaBufferSize[2];       /*  size of dma buffer in bytes */
323         unsigned int ui_DmaBufferUsesize[2];    /*  which size we may now used for transfer */
324         unsigned int ui_DmaBufferSamples[2];    /*  size in samples */
325         unsigned int ui_DmaBufferPages[2];      /*  number of pages in buffer */
326         unsigned char b_DigitalOutputRegister;  /*  Digital Output Register */
327         unsigned char b_OutputMemoryStatus;
328         unsigned char b_AnalogInputChannelNbr;  /*  Analog input channel Nbr */
329         unsigned char b_AnalogOutputChannelNbr; /*  Analog input Output  Nbr */
330         unsigned char b_TimerSelectMode;        /*  Contain data written at iobase + 0C */
331         unsigned char b_ModeSelectRegister;     /*  Contain data written at iobase + 0E */
332         unsigned short us_OutputRegister;       /*  Contain data written at iobase + 0 */
333         unsigned char b_InterruptState;
334         unsigned char b_TimerInit;      /*  Specify if InitTimerWatchdog was load */
335         unsigned char b_TimerStarted;   /*  Specify if timer 2 is running or not */
336         unsigned char b_Timer2Mode;     /*  Specify the timer 2 mode */
337         unsigned char b_Timer2Interrupt;        /* Timer2  interrupt enable or disable */
338         unsigned char b_AiCyclicAcquisition;    /*  indicate cyclic acquisition */
339         unsigned char b_InterruptMode;  /*  eoc eos or dma */
340         unsigned char b_EocEosInterrupt;        /*  Enable disable eoc eos interrupt */
341         unsigned int ui_EocEosConversionTime;
342         unsigned char b_EocEosConversionTimeBase;
343         unsigned char b_SingelDiff;
344         unsigned char b_ExttrigEnable;  /* To enable or disable external trigger */
345
346         /* Pointer to the current process */
347         struct task_struct *tsk_Current;
348
349         /* Hardware board infos for 1710 */
350         struct {
351                 unsigned int ui_Address;        /* Board address */
352                 unsigned int ui_FlashAddress;
353                 unsigned char b_InterruptNbr;   /* Board interrupt number */
354                 unsigned char b_SlotNumber;     /* PCI slot number */
355                 unsigned char b_BoardVersion;
356                 unsigned int dw_MolduleConfiguration[4];        /* Module config */
357         } s_BoardInfos;
358
359         /* Interrupt infos */
360         struct {
361                 unsigned int ul_InterruptOccur; /* 0   : No interrupt occur */
362                                                 /* > 0 : Interrupt occur */
363                 unsigned int ui_Read;   /* Read FIFO */
364                 unsigned int ui_Write;  /* Write FIFO */
365                 struct {
366                         unsigned char b_OldModuleMask;
367                         unsigned int ul_OldInterruptMask;       /* Interrupt mask */
368                         unsigned int ul_OldCounterLatchValue;   /* Interrupt counter value */
369                 } s_FIFOInterruptParameters[APCI1710_SAVE_INTERRUPT];
370         } s_InterruptParameters;
371
372         union str_ModuleInfo s_ModuleInfo[4];
373         unsigned int ul_TTLPortConfiguration[10];
374
375         /* Parameters read from EEPROM overriding static board info */
376         struct {
377                 int i_NbrAiChannel;     /*  num of A/D chans */
378                 int i_NbrAoChannel;     /*  num of D/A chans */
379                 int i_AiMaxdata;        /*  resolution of A/D */
380                 int i_AoMaxdata;        /*  resolution of D/A */
381                 int i_NbrDiChannel;     /*  Number of DI channels */
382                 int i_NbrDoChannel;     /*  Number of DO channels */
383                 int i_DoMaxdata;        /*  data to set all channels high */
384                 int i_Dma;              /*  dma present or not */
385                 int i_Timer;            /*  timer subdevice present or not */
386                 unsigned int ui_MinAcquisitiontimeNs;
387                                         /*  Minimum Acquisition in Nano secs */
388                 unsigned int ui_MinDelaytimeNs;
389                                         /*  Minimum Delay in Nano secs */
390         } s_EeParameters;
391 };