mrfioc2  2.3.0
mrf.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2014 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * Copyright (c) 2015 Paul Scherrer Institute (PSI), Villigen, Switzerland
5 * mrfioc2 is distributed subject to a Software License Agreement found
6 * in file LICENSE that is included with this distribution.
7 \*************************************************************************/
8 
9 #ifndef MRF_H
10 #define MRF_H
11 
12 #include <linux/version.h>
13 #include <linux/device.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/uio_driver.h>
17 #include <linux/io.h>
18 #include <linux/interrupt.h>
19 #include <linux/pci.h>
20 #include <linux/msi.h>
21 #include <linux/delay.h>
22 #ifdef CONFIG_GENERIC_GPIO
23 # include <linux/gpio.h>
24 #endif
25 #ifdef CONFIG_PARPORT_NOT_PC
26 # include <linux/parport.h>
27 #endif
28 #include <linux/aer.h>
29 
30 
31 /************************ Register definitions ****************************/
32 
33 /*
34  * A selection of registers for the PLX PCI9030
35  *
36  * This device is exposed as BAR #0 on PCI and PMC
37  * versions of the EVR
38  */
39 
40 /* Address space #0 is exposed as BAR #2 */
41 #define LAS0BRD 0x28
42 /* Set for big endian, clear for little endian (swapped) */
43 # define LAS0BRD_ENDIAN 0x01000000
44 
45 /* Interrupt control */
46 #define INTCSR 0x4c
47 # define INTCSR_INT1_Enable 0x01
48 # define INTCSR_INT1_Polarity 0x02
49 # define INTCSR_INT1_Status 0x04
50 # define INTCSR_INT2_Enable 0x08
51 # define INTCSR_INT2_Polarity 0x10
52 # define INTCSR_INT2_Status 0x20
53 # define INTCSR_PCI_Enable 0x40
54 # define INTCSR_SW_INTR 0x80
55 
56 #define GPIOC 0x54
57 # define GPIOC_pin0_fn 1
58 # define GPIOC_pin0_dir 2
59 # define GPIOC_pin0_data 4
60 # define GPIOC_pin_fn(N) (GPIOC_pin0_fn<<(3*(N)))
61 # define GPIOC_pin_dir(N) (GPIOC_pin0_dir<<(3*(N)))
62 # define GPIOC_pin_data(N) (GPIOC_pin0_data<<(3*(N)))
63 /* 8 are supported, but only 4 are used.
64  * 0 - TCLK, 1 - TMS, 2 - TDO, 3 - TDI
65  */
66 # define GPIOC_num_pins 4
67 
68 /*
69  * A selection of registers for the PLX PCI9056
70  *
71  * This device is exposed as BAR #0
72  */
73 
74 #define BIGEND9056 0x0C // 8 bit
75 # define BIGEND9056_BIG (1<<2)
76 
77 #define INTCSR9056 0x68 // 32 bit
78 # define INTCSR9056_PCI_Enable (1<<8)
79 
80 # define INTCSR9056_DBL_Enable (1<<9)
81 # define INTCSR9056_ABT_Enable (1<<10)
82 # define INTCSR9056_LCL_Enable (1<<11)
83 # define INTCSR9056_DBL_Status (1<<13) /* PCI doorbell */
84 # define INTCSR9056_ABT_Status (1<<14) /* PCI abort */
85 # define INTCSR9056_LCL_Status (1<<15) /* local */
86 
87 # define INTCSR9056_LBL_Enable (1<<17)
88 # define INTCSR9056_DM0_Enable (1<<18)
89 # define INTCSR9056_DM1_Enable (1<<19)
90 # define INTCSR9056_LBL_Status (1<<20) /* Local doorbell */
91 # define INTCSR9056_DM0_Status (1<<21) /* DMA 0 */
92 # define INTCSR9056_DM1_Status (1<<22) /* DMA 1 */
93 
94 # define INTCSR9056_Status (INTCSR9056_DBL_Status| \
95  INTCSR9056_ABT_Status|INTCSR9056_LCL_Status|INTCSR9056_LBL_Status| \
96  INTCSR9056_DM0_Status|INTCSR9056_DM1_Status)
97 
98 /* For MRM EVR 230 and 300 series
99  * FPGA register and flag values
100  */
101 
102 #define CTRLMain 0x004
103 # define CTRL_BeEnd 0x02000000
104 # define CTRL_LeEnd 0x00000040
105 
106 #define IRQFlag 0x008
107 # define IRQ_LinkChg 0x40
108 # define IRQ_BufFull 0x20
109 # define IRQ_HWMapped 0x10
110 # define IRQ_Event 0x08
111 # define IRQ_Heartbeat 0x04
112 # define IRQ_FIFOFull 0x02
113 # define IRQ_RXErr 0x01
114 
115 #define IRQEnable 0x00c
116 /* Same bits as IRQFlag plus */
117 # define IRQ_Enable 0x80000000
118 /* present for w/ FW version <8 */
119 # define IRQ_PCIee 0x40000000
120 
121 #define IRQ_Enable_ALL (IRQ_Enable|IRQ_PCIee)
122 
123 #define PCIMIE 0x01c
124 /* w/ FW version >=8, IRQ_PCIee moves to PCIMIE */
125 
126 /* The expected value (form factor and 0x1 for EVR) that is
127  * stored in FPGA of EVR300 @ first byte of FPGAVersion register.
128  *
129  * This value is used to test enianness of the EVR 300 PCIe card.
130  */
131 #define FPGAVER_EVR300 0x17
132 
133 #define FPGAVersion 0x02c
134 # define FPGAVer_FF 0xff000000
135 
136 /* driver private struct */
137 
138 struct mrf_priv {
139  struct uio_info uio;
140  struct pci_dev *pdev;
141  unsigned int mrftype; /* MSB from version register */
142  unsigned int irqmode;
143  unsigned int intrcount;
144  unsigned int usemie:1;
145  unsigned int msienabled:1;
146 
147 #if defined(CONFIG_GENERIC_GPIO) || defined(CONFIG_PARPORT_NOT_PC)
148  spinlock_t lock;
149 #endif
150 #ifdef CONFIG_GENERIC_GPIO
151  struct gpio_chip gpio;
152  int gpio_cleanup;
153 #endif
154 #ifdef CONFIG_PARPORT_NOT_PC
155  unsigned int ppenable;
156  const struct ppcable *cable;
157  struct parport *port;
158 #endif
159 };
160 
161 #ifdef CONFIG_PARPORT_NOT_PC
162 void mrf_pp_setup(struct mrf_priv* dev);
163 void mrf_pp_cleanup(struct mrf_priv* priv);
164 #endif
165 #ifdef CONFIG_GENERIC_GPIO
166 void mrf_gpio_setup(struct mrf_priv *priv);
167 void mrf_gpio_cleanup(struct mrf_priv *priv);
168 #endif
169 
170 #endif // MRF_H
unsigned int msienabled
Definition: mrf.h:145
Definition: mrf.h:138
struct pci_dev * pdev
Definition: mrf.h:140
unsigned int mrftype
Definition: mrf.h:141
unsigned int intrcount
Definition: mrf.h:143
unsigned int irqmode
Definition: mrf.h:142
unsigned int usemie
Definition: mrf.h:144
struct uio_info uio
Definition: mrf.h:139