[go: nahoru, domu]

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
21struct addi_board {
22	const char *pc_DriverName;	/*  driver name */
23	int i_IorangeBase1;
24	int i_PCIEeprom;	/*  eeprom present or not */
25	char *pc_EepromChip;	/*  type of chip */
26	int i_NbrAiChannel;	/*  num of A/D chans */
27	int i_NbrAiChannelDiff;	/*  num of A/D chans in diff mode */
28	int i_AiChannelList;	/*  len of chanlist */
29	int i_NbrAoChannel;	/*  num of D/A chans */
30	int i_AiMaxdata;	/*  resolution of A/D */
31	int i_AoMaxdata;	/*  resolution of D/A */
32	const struct comedi_lrange *pr_AiRangelist;	/* rangelist for A/D */
33
34	int i_NbrDiChannel;	/*  Number of DI channels */
35	int i_NbrDoChannel;	/*  Number of DO channels */
36	int i_DoMaxdata;	/*  data to set all channels high */
37
38	int i_Timer;		/*    timer subdevice present or not */
39	unsigned int ui_MinAcquisitiontimeNs;	/*  Minimum Acquisition in Nano secs */
40	unsigned int ui_MinDelaytimeNs;	/*  Minimum Delay in Nano secs */
41
42	/* interrupt and reset */
43	void (*interrupt)(int irq, void *d);
44	int (*reset)(struct comedi_device *);
45
46	/* Subdevice functions */
47
48	/* ANALOG INPUT */
49	int (*ai_config)(struct comedi_device *, struct comedi_subdevice *,
50			 struct comedi_insn *, unsigned int *);
51	int (*ai_read)(struct comedi_device *, struct comedi_subdevice *,
52		       struct comedi_insn *, unsigned int *);
53	int (*ai_write)(struct comedi_device *, struct comedi_subdevice *,
54			struct comedi_insn *, unsigned int *);
55	int (*ai_bits)(struct comedi_device *, struct comedi_subdevice *,
56		       struct comedi_insn *, unsigned int *);
57	int (*ai_cmdtest)(struct comedi_device *, struct comedi_subdevice *,
58			  struct comedi_cmd *);
59	int (*ai_cmd)(struct comedi_device *, struct comedi_subdevice *);
60	int (*ai_cancel)(struct comedi_device *, struct comedi_subdevice *);
61
62	/* Analog Output */
63	int (*ao_write)(struct comedi_device *, struct comedi_subdevice *,
64			struct comedi_insn *, unsigned int *);
65
66	/* Digital Input */
67	int (*di_config)(struct comedi_device *, struct comedi_subdevice *,
68			 struct comedi_insn *, unsigned int *);
69	int (*di_read)(struct comedi_device *, struct comedi_subdevice *,
70		       struct comedi_insn *, unsigned int *);
71	int (*di_write)(struct comedi_device *, struct comedi_subdevice *,
72			struct comedi_insn *, unsigned int *);
73	int (*di_bits)(struct comedi_device *, struct comedi_subdevice *,
74		       struct comedi_insn *, unsigned int *);
75
76	/* Digital Output */
77	int (*do_config)(struct comedi_device *, struct comedi_subdevice *,
78			 struct comedi_insn *, unsigned int *);
79	int (*do_write)(struct comedi_device *, struct comedi_subdevice *,
80			struct comedi_insn *, unsigned int *);
81	int (*do_bits)(struct comedi_device *, struct comedi_subdevice *,
82		       struct comedi_insn *, unsigned int *);
83	int (*do_read)(struct comedi_device *, struct comedi_subdevice *,
84		       struct comedi_insn *, unsigned int *);
85
86	/* TIMER */
87	int (*timer_config)(struct comedi_device *, struct comedi_subdevice *,
88			    struct comedi_insn *, unsigned int *);
89	int (*timer_write)(struct comedi_device *, struct comedi_subdevice *,
90			   struct comedi_insn *, unsigned int *);
91	int (*timer_read)(struct comedi_device *, struct comedi_subdevice *,
92			  struct comedi_insn *, unsigned int *);
93	int (*timer_bits)(struct comedi_device *, struct comedi_subdevice *,
94			  struct comedi_insn *, unsigned int *);
95};
96
97struct addi_private {
98	int iobase;
99	int i_IobaseAmcc;	/*  base+size for AMCC chip */
100	int i_IobaseAddon;	/* addon base address */
101	int i_IobaseReserved;
102	unsigned int ui_AiActualScan;	/* how many scans we finished */
103	unsigned int ui_AiNbrofChannels;	/*  how many channels is measured */
104	unsigned int ui_AiChannelList[32];	/*  actual chanlist */
105	unsigned int ui_AiReadData[32];
106	unsigned short us_UseDma;	/*  To use Dma or not */
107	unsigned char b_DmaDoubleBuffer;	/*  we can use double buffering */
108	unsigned int ui_DmaActualBuffer;	/*  which buffer is used now */
109	unsigned short *ul_DmaBufferVirtual[2];	/*  pointers to DMA buffer */
110	dma_addr_t ul_DmaBufferHw[2];		/*  hw address of DMA buff */
111	unsigned int ui_DmaBufferSize[2];	/*  size of dma buffer in bytes */
112	unsigned int ui_DmaBufferUsesize[2];	/*  which size we may now used for transfer */
113	unsigned char b_DigitalOutputRegister;	/*  Digital Output Register */
114	unsigned char b_OutputMemoryStatus;
115	unsigned char b_TimerSelectMode;	/*  Contain data written at iobase + 0C */
116	unsigned char b_ModeSelectRegister;	/*  Contain data written at iobase + 0E */
117	unsigned short us_OutputRegister;	/*  Contain data written at iobase + 0 */
118	unsigned char b_Timer2Mode;	/*  Specify the timer 2 mode */
119	unsigned char b_Timer2Interrupt;	/* Timer2  interrupt enable or disable */
120	unsigned int ai_running:1;
121	unsigned char b_InterruptMode;	/*  eoc eos or dma */
122	unsigned char b_EocEosInterrupt;	/*  Enable disable eoc eos interrupt */
123	unsigned int ui_EocEosConversionTime;
124	unsigned char b_ExttrigEnable;	/* To enable or disable external trigger */
125
126	/* Pointer to the current process */
127	struct task_struct *tsk_Current;
128
129	/* Parameters read from EEPROM overriding static board info */
130	struct {
131		int i_NbrAiChannel;	/*  num of A/D chans */
132		int i_NbrAoChannel;	/*  num of D/A chans */
133		int i_AiMaxdata;	/*  resolution of A/D */
134		int i_AoMaxdata;	/*  resolution of D/A */
135		int i_NbrDiChannel;	/*  Number of DI channels */
136		int i_NbrDoChannel;	/*  Number of DO channels */
137		int i_DoMaxdata;	/*  data to set all channels high */
138		int i_Timer;		/*  timer subdevice present or not */
139		unsigned int ui_MinAcquisitiontimeNs;
140					/*  Minimum Acquisition in Nano secs */
141		unsigned int ui_MinDelaytimeNs;
142					/*  Minimum Delay in Nano secs */
143	} s_EeParameters;
144};
145