]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - drivers/staging/comedi/drivers/plx9080.h
staging: comedi: drivers: re-do PLX PCI 9080 LBRDx register values
[mirror_ubuntu-hirsute-kernel.git] / drivers / staging / comedi / drivers / plx9080.h
CommitLineData
e554840c
MK
1/*
2 * plx9080.h
3d9f0739
DC
3 *
4 * Copyright (C) 2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net>
5 *
6 * I modified this file from the plx9060.h header for the
7 * wanXL device driver in the linux kernel,
8 * for the register offsets and bit definitions. Made minor modifications,
9 * added plx9080 registers and
10 * stripped out stuff that was specifically for the wanXL driver.
11 * Note: I've only made sure the definitions are correct as far
12 * as I make use of them. There are still various plx9060-isms
13 * left in this header file.
14 *
15 ********************************************************************
16 *
631dd1a8 17 * Copyright (C) 1999 RG Studio s.c.
3d9f0739
DC
18 * Written by Krzysztof Halasa <khc@rgstudio.com.pl>
19 *
20 * Portions (C) SBE Inc., used by permission.
21 *
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * as published by the Free Software Foundation; either version
25 * 2 of the License, or (at your option) any later version.
26 */
27
28#ifndef __COMEDI_PLX9080_H
29#define __COMEDI_PLX9080_H
30
b6c77757 31/* descriptor block used for chained dma transfers */
3d9f0739 32struct plx_dma_desc {
5c7895c0
HS
33 __le32 pci_start_addr;
34 __le32 local_start_addr;
3d9f0739 35 /* transfer_size is in bytes, only first 23 bits of register are used */
5c7895c0 36 __le32 transfer_size;
e554840c
MK
37 /*
38 * address of next descriptor (quad word aligned), plus some
c644a11a 39 * additional bits (see PLX_REG_DMADPR)
e554840c 40 */
5c7895c0 41 __le32 next;
3d9f0739
DC
42};
43
44/**********************************************************************
45** Register Offsets and Bit Definitions
46**
47** Note: All offsets zero relative. IE. Some standard base address
48** must be added to the Register Number to properly access the register.
49**
50**********************************************************************/
51
c644a11a
IA
52/* Local Address Space 0 Range Register */
53#define PLX_REG_LAS0RR 0x0000
54/* Local Address Space 1 Range Register */
55#define PLX_REG_LAS1RR 0x00f0
56
be13e14e
IA
57#define PLX_LASRR_IO BIT(0) /* Map to: 1=I/O, 0=Mem */
58#define PLX_LASRR_ANY32 (BIT(1) * 0) /* Locate anywhere in 32 bit */
59#define PLX_LASRR_LT1MB (BIT(1) * 1) /* Locate in 1st meg */
60#define PLX_LASRR_ANY64 (BIT(1) * 2) /* Locate anywhere in 64 bit */
61#define PLX_LASRR_MLOC_MASK GENMASK(2, 1) /* Memory location bits */
62#define PLX_LASRR_PREFETCH BIT(3) /* Memory is prefetchable */
63/* bits that specify range for memory space decode bits */
64#define PLX_LASRR_MEM_MASK GENMASK(31, 4)
65/* bits that specify range for i/o space decode bits */
66#define PLX_LASRR_IO_MASK GENMASK(31, 2)
c644a11a
IA
67
68/* Local Address Space 0 Local Base Address (Remap) Register */
69#define PLX_REG_LAS0BA 0x0004
70/* Local Address Space 1 Local Base Address (Remap) Register */
71#define PLX_REG_LAS1BA 0x00f4
72
5eaa593d
IA
73#define PLX_LASBA_EN BIT(0) /* Enable slave decode */
74/* bits that specify local base address for memory space */
75#define PLX_LASBA_MEM_MASK GENMASK(31, 4)
76/* bits that specify local base address for i/o space */
77#define PLX_LASBA_IO_MASK GENMASK(31, 2)
3d9f0739 78
c644a11a
IA
79/* Mode/Arbitration Register */
80#define PLX_REG_MARBR 0x0008
81/* DMA Arbitration Register (alias of MARBR). */
82#define PLX_REG_DMAARB 0x00ac
83
b5dcdcea
IA
84/* Local Bus Latency Timer */
85#define PLX_MARBR_LT(x) (BIT(0) * ((x) & 0xff))
86#define PLX_MARBR_LT_MASK GENMASK(7, 0)
87#define PLX_MARBR_LT_SHIFT 0
88/* Local Bus Pause Timer */
89#define PLX_MARBR_PT(x) (BIT(8) * ((x) & 0xff))
90#define PLX_MARBR_PT_MASK GENMASK(15, 8)
91#define PLX_MARBR_PT_SHIFT 8
92/* Local Bus Latency Timer Enable */
93#define PLX_MARBR_LTEN BIT(16)
94/* Local Bus Pause Timer Enable */
95#define PLX_MARBR_PTEN BIT(17)
96/* Local Bus BREQ Enable */
97#define PLX_MARBR_BREQEN BIT(18)
98/* DMA Channel Priority */
99#define PLX_MARBR_PRIO_ROT (BIT(19) * 0) /* Rotational priority */
100#define PLX_MARBR_PRIO_DMA0 (BIT(19) * 1) /* DMA channel 0 has priority */
101#define PLX_MARBR_PRIO_DMA1 (BIT(19) * 2) /* DMA channel 1 has priority */
102#define PLX_MARBR_PRIO_MASK GENMASK(20, 19)
103/* Local Bus Direct Slave Give Up Bus Mode */
104#define PLX_MARBR_DSGUBM BIT(21)
105/* Direct Slace LLOCKo# Enable */
106#define PLX_MARBR_DSLLOCKOEN BIT(22)
107/* PCI Request Mode */
108#define PLX_MARBR_PCIREQM BIT(23)
109/* PCI Specification v2.1 Mode */
110#define PLX_MARBR_PCIV21M BIT(24)
111/* PCI Read No Write Mode */
112#define PLX_MARBR_PCIRNWM BIT(25)
113/* PCI Read with Write Flush Mode */
114#define PLX_MARBR_PCIRWFM BIT(26)
115/* Gate Local Bus Latency Timer with BREQ */
116#define PLX_MARBR_GLTBREQ BIT(27)
117/* PCI Read No Flush Mode */
118#define PLX_MARBR_PCIRNFM BIT(28)
119/*
120 * Make reads from PCI Configuration register 0 return Subsystem ID and
121 * Subsystem Vendor ID instead of Device ID and Vendor ID
122 */
123#define PLX_MARBR_SUBSYSIDS BIT(29)
3d9f0739 124
c644a11a
IA
125/* Big/Little Endian Descriptor Register */
126#define PLX_REG_BIGEND 0x000c
127
a9c254a7
IA
128/* Configuration Register Big Endian Mode */
129#define PLX_BIGEND_CONFIG BIT(0)
130/* Direct Master Big Endian Mode */
131#define PLX_BIGEND_DM BIT(1)
132/* Direct Slave Address Space 0 Big Endian Mode */
133#define PLX_BIGEND_DSAS0 BIT(2)
134/* Direct Slave Expansion ROM Big Endian Mode */
135#define PLX_BIGEND_EROM BIT(3)
136/* Big Endian Byte Lane Mode - use most significant byte lanes */
137#define PLX_BIGEND_BEBLM BIT(4)
138/* Direct Slave Address Space 1 Big Endian Mode */
139#define PLX_BIGEND_DSAS1 BIT(5)
140/* DMA Channel 1 Big Endian Mode */
141#define PLX_BIGEND_DMA1 BIT(6)
142/* DMA Channel 0 Big Endian Mode */
143#define PLX_BIGEND_DMA0 BIT(7)
144/* DMA Channel N Big Endian Mode (N <= 1) */
145#define PLX_BIGEND_DMA(n) ((n) ? PLX_BIGEND_DMA1 : PLX_BIGEND_DMA0)
3d9f0739 146
e554840c
MK
147/*
148** Note: The Expansion ROM stuff is only relevant to the PC environment.
3d9f0739
DC
149** This expansion ROM code is executed by the host CPU at boot time.
150** For this reason no bit definitions are provided here.
e554840c 151 */
c644a11a
IA
152/* Expansion ROM Range Register */
153#define PLX_REG_EROMRR 0x0010
154/* Expansion ROM Local Base Address (Remap) Register */
155#define PLX_REG_EROMBA 0x0014
156
157/* Local Address Space 0/Expansion ROM Bus Region Descriptor Register */
158#define PLX_REG_LBRD0 0x0018
159/* Local Address Space 1 Bus Region Descriptor Register */
160#define PLX_REG_LBRD1 0x00f8
3d9f0739 161
1ddb95d3
IA
162/* Memory Space Local Bus Width */
163#define PLX_LBRD_MSWIDTH8 (BIT(0) * 0) /* 8 bits wide */
164#define PLX_LBRD_MSWIDTH16 (BIT(0) * 1) /* 16 bits wide */
165#define PLX_LBRD_MSWIDTH32 (BIT(0) * 2) /* 32 bits wide */
166#define PLX_LBRD_MSWIDTH32A (BIT(0) * 3) /* 32 bits wide */
167#define PLX_LBRD_MSWIDTH_MASK GENMASK(1, 0)
168#define PLX_LBRD_MSWIDTH_SHIFT 0
169/* Memory Space Internal Wait States */
170#define PLX_LBRD_MSIWS(x) (BIT(2) * ((x) & 0xf))
171#define PLX_LBRD_MSIWS_MASK GENMASK(5, 2)
172#define PLX_LBRD_MSIWS_SHIFT 2
173/* Memory Space Ready Input Enable */
174#define PLX_LBRD_MSREADYIEN BIT(6)
175/* Memory Space BTERM# Input Enable */
176#define PLX_LBRD_MSBTERMIEN BIT(7)
177/* Memory Space 0 Prefetch Disable (LBRD0 only) */
178#define PLX_LBRD0_MSPREDIS BIT(8)
179/* Memory Space 1 Burst Enable (LBRD1 only) */
180#define PLX_LBRD1_MSBURSTEN BIT(8)
181/* Expansion ROM Space Prefetch Disable (LBRD0 only) */
182#define PLX_LBRD0_EROMPREDIS BIT(9)
183/* Memory Space 1 Prefetch Disable (LBRD1 only) */
184#define PLX_LBRD1_MSPREDIS BIT(9)
185/* Read Prefetch Count Enable */
186#define PLX_LBRD_RPFCOUNTEN BIT(10)
187/* Prefetch Counter */
188#define PLX_LBRD_PFCOUNT(x) (BIT(11) * ((x) & 0xf))
189#define PLX_LBRD_PFCOUNT_MASK GENMASK(14, 11)
190#define PLX_LBRD_PFCOUNT_SHIFT 11
191/* Expansion ROM Space Local Bus Width (LBRD0 only) */
192#define PLX_LBRD0_EROMWIDTH8 (BIT(16) * 0) /* 8 bits wide */
193#define PLX_LBRD0_EROMWIDTH16 (BIT(16) * 1) /* 16 bits wide */
194#define PLX_LBRD0_EROMWIDTH32 (BIT(16) * 2) /* 32 bits wide */
195#define PLX_LBRD0_EROMWIDTH32A (BIT(16) * 3) /* 32 bits wide */
196#define PLX_LBRD0_EROMWIDTH_MASK GENMASK(17, 16)
197#define PLX_LBRD0_EROMWIDTH_SHIFT 16
198/* Expansion ROM Space Internal Wait States (LBRD0 only) */
199#define PLX_LBRD0_EROMIWS(x) (BIT(18) * ((x) & 0xf))
200#define PLX_LBRD0_EROMIWS_MASK GENMASK(21, 18)
201#define PLX_LBRD0_EROMIWS_SHIFT 18
202/* Expansion ROM Space Ready Input Enable (LBDR0 only) */
203#define PLX_LBRD0_EROMREADYIEN BIT(22)
204/* Expansion ROM Space BTERM# Input Enable (LBRD0 only) */
205#define PLX_LBRD0_EROMBTERMIEN BIT(23)
206/* Memory Space 0 Burst Enable (LBRD0 only) */
207#define PLX_LBRD0_MSBURSTEN BIT(24)
208/* Extra Long Load From Serial EEPROM (LBRD0 only) */
209#define PLX_LBRD0_EELONGLOAD BIT(25)
210/* Expansion ROM Space Burst Enable (LBRD0 only) */
211#define PLX_LBRD0_EROMBURSTEN BIT(26)
212/* Direct Slave PCI Write Mode - assert TRDY# when FIFO full (LBRD0 only) */
213#define PLX_LBRD0_DSWMTRDY BIT(27)
214/* PCI Target Retry Delay Clocks / 8 (LBRD0 only) */
215#define PLX_LBRD0_TRDELAY(x) (BIT(28) * ((x) & 0xF))
216#define PLX_LBRD0_TRDELAY_MASK GENMASK(31, 28)
217#define PLX_LBRD0_TRDELAY_SHIFT 28
3d9f0739 218
c644a11a
IA
219/* Local Range Register for Direct Master to PCI */
220#define PLX_REG_DMRR 0x001c
3d9f0739 221
c644a11a
IA
222/* Local Bus Base Address Register for Direct Master to PCI Memory */
223#define PLX_REG_DMLBAM 0x0020
3d9f0739 224
c644a11a
IA
225/* Local Base Address Register for Direct Master to PCI IO/CFG */
226#define PLX_REG_DMLBAI 0x0024
3d9f0739 227
c644a11a
IA
228/* PCI Base Address (Remap) Register for Direct Master to PCI Memory */
229#define PLX_REG_DMPBAM 0x0028
3d9f0739 230
3d9f0739
DC
231#define DMM_MAE 0x00000001 /* Direct Mstr Memory Acc Enable */
232#define DMM_IAE 0x00000002 /* Direct Mstr I/O Acc Enable */
233#define DMM_LCK 0x00000004 /* LOCK Input Enable */
234#define DMM_PF4 0x00000008 /* Prefetch 4 Mode Enable */
235#define DMM_THROT 0x00000010 /* Assert IRDY when read FIFO full */
236#define DMM_PAF0 0x00000000 /* Programmable Almost fill level */
237#define DMM_PAF1 0x00000020 /* Programmable Almost fill level */
238#define DMM_PAF2 0x00000040 /* Programmable Almost fill level */
239#define DMM_PAF3 0x00000060 /* Programmable Almost fill level */
240#define DMM_PAF4 0x00000080 /* Programmable Almost fill level */
241#define DMM_PAF5 0x000000A0 /* Programmable Almost fill level */
242#define DMM_PAF6 0x000000C0 /* Programmable Almost fill level */
243#define DMM_PAF7 0x000000D0 /* Programmable Almost fill level */
244#define DMM_MAP 0xFFFF0000 /* Remap Address Bits */
245
c644a11a
IA
246/* PCI Configuration Address Register for Direct Master to PCI IO/CFG */
247#define PLX_REG_DMCFGA 0x002c
248
3d9f0739
DC
249#define CAR_CT0 0x00000000 /* Config Type 0 */
250#define CAR_CT1 0x00000001 /* Config Type 1 */
251#define CAR_REG 0x000000FC /* Register Number Bits */
252#define CAR_FUN 0x00000700 /* Function Number Bits */
253#define CAR_DEV 0x0000F800 /* Device Number Bits */
254#define CAR_BUS 0x00FF0000 /* Bus Number Bits */
255#define CAR_CFG 0x80000000 /* Config Spc Access Enable */
256
c644a11a
IA
257/*
258 * Mailbox Register N (N <= 7)
259 *
260 * Note that if the I2O feature is enabled (QSR[0] is set), Mailbox Register 0
261 * is replaced by the Inbound Queue Port, and Mailbox Register 1 is replaced
262 * by the Outbound Queue Port. However, Mailbox Register 0 and 1 are always
263 * accessible at alternative offsets if the I2O feature is enabled.
264 */
265#define PLX_REG_MBOX(n) (0x0040 + (n) * 4)
266#define PLX_REG_MBOX0 PLX_REG_MBOX(0)
267#define PLX_REG_MBOX1 PLX_REG_MBOX(1)
268#define PLX_REG_MBOX2 PLX_REG_MBOX(2)
269#define PLX_REG_MBOX3 PLX_REG_MBOX(3)
270#define PLX_REG_MBOX4 PLX_REG_MBOX(4)
271#define PLX_REG_MBOX5 PLX_REG_MBOX(5)
272#define PLX_REG_MBOX6 PLX_REG_MBOX(6)
273#define PLX_REG_MBOX7 PLX_REG_MBOX(7)
274
275/* Alternative offsets for Mailbox Registers 0 and 1 (in case I2O is enabled) */
276#define PLX_REG_ALT_MBOX(n) ((n) < 2 ? 0x0078 + (n) * 4 : PLX_REG_MBOX(n))
277#define PLX_REG_ALT_MBOX0 PLX_REG_ALT_MBOX(0)
278#define PLX_REG_ALT_MBOX1 PLX_REG_ALT_MBOX(1)
279
280/* PCI-to-Local Doorbell Register */
281#define PLX_REG_P2LDBELL 0x0060
282
283/* Local-to-PCI Doorbell Register */
284#define PLX_REG_L2PDBELL 0x0064
285
286/* Interrupt Control/Status Register */
287#define PLX_REG_INTCSR 0x0068
3d9f0739 288
3d9f0739
DC
289#define ICS_AERR 0x00000001 /* Assert LSERR on ABORT */
290#define ICS_PERR 0x00000002 /* Assert LSERR on Parity Error */
291#define ICS_SERR 0x00000004 /* Generate PCI SERR# */
b6c77757 292#define ICS_MBIE 0x00000008 /* mailbox interrupt enable */
3d9f0739
DC
293#define ICS_PIE 0x00000100 /* PCI Interrupt Enable */
294#define ICS_PDIE 0x00000200 /* PCI Doorbell Interrupt Enable */
295#define ICS_PAIE 0x00000400 /* PCI Abort Interrupt Enable */
296#define ICS_PLIE 0x00000800 /* PCI Local Int Enable */
297#define ICS_RAE 0x00001000 /* Retry Abort Enable */
298#define ICS_PDIA 0x00002000 /* PCI Doorbell Interrupt Active */
299#define ICS_PAIA 0x00004000 /* PCI Abort Interrupt Active */
300#define ICS_LIA 0x00008000 /* Local Interrupt Active */
301#define ICS_LIE 0x00010000 /* Local Interrupt Enable */
302#define ICS_LDIE 0x00020000 /* Local Doorbell Int Enable */
303#define ICS_DMA0_E 0x00040000 /* DMA #0 Interrupt Enable */
304#define ICS_DMA1_E 0x00080000 /* DMA #1 Interrupt Enable */
305#define ICS_LDIA 0x00100000 /* Local Doorbell Int Active */
306#define ICS_DMA0_A 0x00200000 /* DMA #0 Interrupt Active */
307#define ICS_DMA1_A 0x00400000 /* DMA #1 Interrupt Active */
308#define ICS_BIA 0x00800000 /* BIST Interrupt Active */
309#define ICS_TA_DM 0x01000000 /* Target Abort - Direct Master */
310#define ICS_TA_DMA0 0x02000000 /* Target Abort - DMA #0 */
311#define ICS_TA_DMA1 0x04000000 /* Target Abort - DMA #1 */
312#define ICS_TA_RA 0x08000000 /* Target Abort - Retry Timeout */
e554840c
MK
313/* mailbox x is active */
314#define ICS_MBIA(x) (0x10000000 << ((x) & 0x3))
3d9f0739 315
c644a11a
IA
316/*
317 * Serial EEPROM Control, PCI Command Codes, User I/O Control,
318 * Init Control Register
319 */
320#define PLX_REG_CNTRL 0x006c
321
3d9f0739
DC
322#define CTL_RDMA 0x0000000E /* DMA Read Command */
323#define CTL_WDMA 0x00000070 /* DMA Write Command */
324#define CTL_RMEM 0x00000600 /* Memory Read Command */
325#define CTL_WMEM 0x00007000 /* Memory Write Command */
326#define CTL_USERO 0x00010000 /* USERO output pin control bit */
327#define CTL_USERI 0x00020000 /* USERI input pin bit */
328#define CTL_EE_CLK 0x01000000 /* EEPROM Clock line */
329#define CTL_EE_CS 0x02000000 /* EEPROM Chip Select */
330#define CTL_EE_W 0x04000000 /* EEPROM Write bit */
331#define CTL_EE_R 0x08000000 /* EEPROM Read bit */
332#define CTL_EECHK 0x10000000 /* EEPROM Present bit */
333#define CTL_EERLD 0x20000000 /* EEPROM Reload Register */
334#define CTL_RESET 0x40000000 /* !! Adapter Reset !! */
335#define CTL_READY 0x80000000 /* Local Init Done */
336
c644a11a
IA
337/* PCI Permanent Configuration ID Register (hard-coded PLX vendor and device) */
338#define PLX_REG_PCIHIDR 0x0070
339
340/* PCI Permanent Revision ID Register (hard-coded silicon revision) (8-bit). */
341#define PLX_REG_PCIHREV 0x0074
3d9f0739 342
c644a11a
IA
343/* DMA Channel N Mode Register (N <= 1) */
344#define PLX_REG_DMAMODE(n) ((n) ? PLX_REG_DMAMODE1 : PLX_REG_DMAMODE0)
345#define PLX_REG_DMAMODE0 0x0080
346#define PLX_REG_DMAMODE1 0x0094
3d9f0739 347
3d9f0739
DC
348#define PLX_LOCAL_BUS_16_WIDE_BITS 0x1
349#define PLX_LOCAL_BUS_32_WIDE_BITS 0x3
350#define PLX_LOCAL_BUS_WIDTH_MASK 0x3
b6c77757
BP
351#define PLX_DMA_EN_READYIN_BIT 0x40 /* enable ready in input */
352#define PLX_EN_BTERM_BIT 0x80 /* enable BTERM# input */
353#define PLX_DMA_LOCAL_BURST_EN_BIT 0x100 /* enable local burst mode */
354#define PLX_EN_CHAIN_BIT 0x200 /* enables chaining */
e554840c
MK
355/* enables interrupt on dma done */
356#define PLX_EN_DMA_DONE_INTR_BIT 0x400
357/* hold local address constant (don't increment) */
358#define PLX_LOCAL_ADDR_CONST_BIT 0x800
359/* enables demand-mode for dma transfer */
360#define PLX_DEMAND_MODE_BIT 0x1000
3d9f0739
DC
361#define PLX_EOT_ENABLE_BIT 0x4000
362#define PLX_STOP_MODE_BIT 0x8000
e554840c
MK
363/* routes dma interrupt to pci bus (instead of local bus) */
364#define PLX_DMA_INTR_PCI_BIT 0x20000
3d9f0739 365
c644a11a
IA
366/* DMA Channel N PCI Address Register (N <= 1) */
367#define PLX_REG_DMAPADR(n) ((n) ? PLX_REG_DMAPADR1 : PLX_REG_DMAPADR0)
368#define PLX_REG_DMAPADR0 0x0084
369#define PLX_REG_DMAPADR1 0x0098
370
371/* DMA Channel N Local Address Register (N <= 1) */
372#define PLX_REG_DMALADR(n) ((n) ? PLX_REG_DMALADR1 : PLX_REG_DMALADR0)
373#define PLX_REG_DMALADR0 0x0088
374#define PLX_REG_DMALADR1 0x009c
3d9f0739 375
c644a11a
IA
376/* DMA Channel N Transfer Size (Bytes) Register (N <= 1) (first 23 bits) */
377#define PLX_REG_DMASIZ(n) ((n) ? PLX_REG_DMASIZ1 : PLX_REG_DMASIZ0)
378#define PLX_REG_DMASIZ0 0x008c
379#define PLX_REG_DMASIZ1 0x00a0
3d9f0739 380
c644a11a
IA
381/* DMA Channel N Descriptor Pointer Register (N <= 1) */
382#define PLX_REG_DMADPR(n) ((n) ? PLX_REG_DMADPR1 : PLX_REG_DMADPR0)
383#define PLX_REG_DMADPR0 0x0090
384#define PLX_REG_DMADPR1 0x00a4
3d9f0739 385
e554840c
MK
386/* descriptor is located in pci space (not local space) */
387#define PLX_DESC_IN_PCI_BIT 0x1
b6c77757 388#define PLX_END_OF_CHAIN_BIT 0x2 /* end of chain bit */
e554840c
MK
389/* interrupt when this descriptor's transfer is finished */
390#define PLX_INTR_TERM_COUNT 0x4
391/* transfer from local to pci bus (not pci to local) */
392#define PLX_XFER_LOCAL_TO_PCI 0x8
3d9f0739 393
c644a11a
IA
394/* DMA Channel N Command/Status Register (N <= 1) (8-bit) */
395#define PLX_REG_DMACSR(n) ((n) ? PLX_REG_DMACSR1 : PLX_REG_DMACSR0)
396#define PLX_REG_DMACSR0 0x00a8
397#define PLX_REG_DMACSR1 0x00a9
398
b6c77757
BP
399#define PLX_DMA_EN_BIT 0x1 /* enable dma channel */
400#define PLX_DMA_START_BIT 0x2 /* start dma transfer */
401#define PLX_DMA_ABORT_BIT 0x4 /* abort dma transfer */
402#define PLX_CLEAR_DMA_INTR_BIT 0x8 /* clear dma interrupt */
403#define PLX_DMA_DONE_BIT 0x10 /* transfer done status bit */
3d9f0739 404
c644a11a
IA
405/* DMA Threshold Register */
406#define PLX_REG_DMATHR 0x00b0
407
408/*
409 * Messaging Queue Registers OPLFIS, OPLFIM, IQP, OQP, MQCR, QBAR, IFHPR,
410 * IFTPR, IPHPR, IPTPR, OFHPR, OFTPR, OPHPR, OPTPR, and QSR have been omitted.
411 * They are used by the I2O feature. (IQP and OQP occupy the usual offsets of
412 * the MBOX0 and MBOX1 registers if the I2O feature is enabled, but MBOX0 and
413 * MBOX1 are accessible via alternative offsets.
414 */
415
416/* Queue Status/Control Register */
417#define PLX_REG_QSR 0x00e8
418
419/* Value of QSR after reset - disables I2O feature completely. */
420#define PLX_QSR_VALUE_AFTER_RESET 0x00000050
3d9f0739
DC
421
422/*
423 * Accesses near the end of memory can cause the PLX chip
424 * to pre-fetch data off of end-of-ram. Limit the size of
425 * memory so host-side accesses cannot occur.
426 */
427
428#define PLX_PREFETCH 32
429
b74a9670 430static inline int plx9080_abort_dma(void __iomem *iobase, unsigned int channel)
3d9f0739 431{
b74a9670 432 void __iomem *dma_cs_addr;
f6e9b914 433 u8 dma_status;
3d9f0739
DC
434 const int timeout = 10000;
435 unsigned int i;
436
c644a11a 437 dma_cs_addr = iobase + PLX_REG_DMACSR(channel);
3d9f0739 438
b6c77757 439 /* abort dma transfer if necessary */
3d9f0739 440 dma_status = readb(dma_cs_addr);
82675f35 441 if ((dma_status & PLX_DMA_EN_BIT) == 0)
3d9f0739 442 return 0;
82675f35 443
b6c77757 444 /* wait to make sure done bit is zero */
3d9f0739 445 for (i = 0; (dma_status & PLX_DMA_DONE_BIT) && i < timeout; i++) {
5f74ea14 446 udelay(1);
3d9f0739
DC
447 dma_status = readb(dma_cs_addr);
448 }
3c643061 449 if (i == timeout)
3d9f0739 450 return -ETIMEDOUT;
3c643061 451
b6c77757 452 /* disable and abort channel */
3d9f0739 453 writeb(PLX_DMA_ABORT_BIT, dma_cs_addr);
b6c77757 454 /* wait for dma done bit */
3d9f0739
DC
455 dma_status = readb(dma_cs_addr);
456 for (i = 0; (dma_status & PLX_DMA_DONE_BIT) == 0 && i < timeout; i++) {
5f74ea14 457 udelay(1);
3d9f0739
DC
458 dma_status = readb(dma_cs_addr);
459 }
3c643061 460 if (i == timeout)
3d9f0739 461 return -ETIMEDOUT;
3d9f0739
DC
462
463 return 0;
464}
465
466#endif /* __COMEDI_PLX9080_H */