Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / drivers / char / xilinx_hwicap / xilinx_hwicap.h
blob56fdbf19d8acdd9ee5a2755bd1c33c952987416f
1 /*****************************************************************************
3 * Author: Xilinx, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
10 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
11 * AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
12 * SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
13 * OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
14 * APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
15 * THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
16 * AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
17 * FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
18 * WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
19 * IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
20 * REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
21 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE.
24 * Xilinx products are not intended for use in life support appliances,
25 * devices, or systems. Use in such applications is expressly prohibited.
27 * (c) Copyright 2003-2007 Xilinx Inc.
28 * All rights reserved.
30 * You should have received a copy of the GNU General Public License along
31 * with this program; if not, write to the Free Software Foundation, Inc.,
32 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 *****************************************************************************/
36 #ifndef XILINX_HWICAP_H_ /* prevent circular inclusions */
37 #define XILINX_HWICAP_H_ /* by using protection macros */
39 #include <linux/types.h>
40 #include <linux/cdev.h>
41 #include <linux/version.h>
42 #include <linux/platform_device.h>
44 #include <asm/io.h>
46 struct hwicap_drvdata {
47 u32 write_buffer_in_use; /* Always in [0,3] */
48 u8 write_buffer[4];
49 u32 read_buffer_in_use; /* Always in [0,3] */
50 u8 read_buffer[4];
51 <<<<<<< HEAD:drivers/char/xilinx_hwicap/xilinx_hwicap.h
52 u32 mem_start; /* phys. address of the control registers */
53 u32 mem_end; /* phys. address of the control registers */
54 u32 mem_size;
55 =======
56 resource_size_t mem_start;/* phys. address of the control registers */
57 resource_size_t mem_end; /* phys. address of the control registers */
58 resource_size_t mem_size;
59 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/char/xilinx_hwicap/xilinx_hwicap.h
60 void __iomem *base_address;/* virt. address of the control registers */
62 struct device *dev;
63 struct cdev cdev; /* Char device structure */
64 dev_t devt;
66 const struct hwicap_driver_config *config;
67 const struct config_registers *config_regs;
68 void *private_data;
69 bool is_open;
70 <<<<<<< HEAD:drivers/char/xilinx_hwicap/xilinx_hwicap.h
71 struct semaphore sem;
72 =======
73 struct mutex sem;
74 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/char/xilinx_hwicap/xilinx_hwicap.h
77 struct hwicap_driver_config {
78 int (*get_configuration)(struct hwicap_drvdata *drvdata, u32 *data,
79 u32 size);
80 int (*set_configuration)(struct hwicap_drvdata *drvdata, u32 *data,
81 u32 size);
82 void (*reset)(struct hwicap_drvdata *drvdata);
85 /* Number of times to poll the done regsiter */
86 #define XHI_MAX_RETRIES 10
88 /************ Constant Definitions *************/
90 #define XHI_PAD_FRAMES 0x1
92 /* Mask for calculating configuration packet headers */
93 #define XHI_WORD_COUNT_MASK_TYPE_1 0x7FFUL
94 #define XHI_WORD_COUNT_MASK_TYPE_2 0x1FFFFFUL
95 #define XHI_TYPE_MASK 0x7
96 #define XHI_REGISTER_MASK 0xF
97 #define XHI_OP_MASK 0x3
99 #define XHI_TYPE_SHIFT 29
100 #define XHI_REGISTER_SHIFT 13
101 #define XHI_OP_SHIFT 27
103 #define XHI_TYPE_1 1
104 #define XHI_TYPE_2 2
105 #define XHI_OP_WRITE 2
106 #define XHI_OP_READ 1
108 /* Address Block Types */
109 #define XHI_FAR_CLB_BLOCK 0
110 #define XHI_FAR_BRAM_BLOCK 1
111 #define XHI_FAR_BRAM_INT_BLOCK 2
113 struct config_registers {
114 u32 CRC;
115 u32 FAR;
116 u32 FDRI;
117 u32 FDRO;
118 u32 CMD;
119 u32 CTL;
120 u32 MASK;
121 u32 STAT;
122 u32 LOUT;
123 u32 COR;
124 u32 MFWR;
125 u32 FLR;
126 u32 KEY;
127 u32 CBC;
128 u32 IDCODE;
129 u32 AXSS;
130 u32 C0R_1;
131 u32 CSOB;
132 u32 WBSTAR;
133 u32 TIMER;
134 u32 BOOTSTS;
135 u32 CTL_1;
138 /* Configuration Commands */
139 #define XHI_CMD_NULL 0
140 #define XHI_CMD_WCFG 1
141 #define XHI_CMD_MFW 2
142 #define XHI_CMD_DGHIGH 3
143 #define XHI_CMD_RCFG 4
144 #define XHI_CMD_START 5
145 #define XHI_CMD_RCAP 6
146 #define XHI_CMD_RCRC 7
147 #define XHI_CMD_AGHIGH 8
148 #define XHI_CMD_SWITCH 9
149 #define XHI_CMD_GRESTORE 10
150 #define XHI_CMD_SHUTDOWN 11
151 #define XHI_CMD_GCAPTURE 12
152 #define XHI_CMD_DESYNCH 13
153 #define XHI_CMD_IPROG 15 /* Only in Virtex5 */
154 #define XHI_CMD_CRCC 16 /* Only in Virtex5 */
155 #define XHI_CMD_LTIMER 17 /* Only in Virtex5 */
157 /* Packet constants */
158 #define XHI_SYNC_PACKET 0xAA995566UL
159 #define XHI_DUMMY_PACKET 0xFFFFFFFFUL
160 #define XHI_NOOP_PACKET (XHI_TYPE_1 << XHI_TYPE_SHIFT)
161 #define XHI_TYPE_2_READ ((XHI_TYPE_2 << XHI_TYPE_SHIFT) | \
162 (XHI_OP_READ << XHI_OP_SHIFT))
164 #define XHI_TYPE_2_WRITE ((XHI_TYPE_2 << XHI_TYPE_SHIFT) | \
165 (XHI_OP_WRITE << XHI_OP_SHIFT))
167 #define XHI_TYPE2_CNT_MASK 0x07FFFFFF
169 #define XHI_TYPE_1_PACKET_MAX_WORDS 2047UL
170 #define XHI_TYPE_1_HEADER_BYTES 4
171 #define XHI_TYPE_2_HEADER_BYTES 8
173 /* Constant to use for CRC check when CRC has been disabled */
174 #define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL
177 <<<<<<< HEAD:drivers/char/xilinx_hwicap/xilinx_hwicap.h
178 * hwicap_type_1_read: Generates a Type 1 read packet header.
179 * @parameter: Register is the address of the register to be read back.
180 =======
181 * hwicap_type_1_read - Generates a Type 1 read packet header.
182 * @reg: is the address of the register to be read back.
183 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/char/xilinx_hwicap/xilinx_hwicap.h
185 * Generates a Type 1 read packet header, which is used to indirectly
186 * read registers in the configuration logic. This packet must then
187 * be sent through the icap device, and a return packet received with
188 * the information.
190 <<<<<<< HEAD:drivers/char/xilinx_hwicap/xilinx_hwicap.h
191 static inline u32 hwicap_type_1_read(u32 Register)
192 =======
193 static inline u32 hwicap_type_1_read(u32 reg)
194 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/char/xilinx_hwicap/xilinx_hwicap.h
196 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |
197 <<<<<<< HEAD:drivers/char/xilinx_hwicap/xilinx_hwicap.h
198 (Register << XHI_REGISTER_SHIFT) |
199 =======
200 (reg << XHI_REGISTER_SHIFT) |
201 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/char/xilinx_hwicap/xilinx_hwicap.h
202 (XHI_OP_READ << XHI_OP_SHIFT);
206 <<<<<<< HEAD:drivers/char/xilinx_hwicap/xilinx_hwicap.h
207 * hwicap_type_1_write: Generates a Type 1 write packet header
208 * @parameter: Register is the address of the register to be read back.
209 =======
210 * hwicap_type_1_write - Generates a Type 1 write packet header
211 * @reg: is the address of the register to be read back.
212 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/char/xilinx_hwicap/xilinx_hwicap.h
214 <<<<<<< HEAD:drivers/char/xilinx_hwicap/xilinx_hwicap.h
215 static inline u32 hwicap_type_1_write(u32 Register)
216 =======
217 static inline u32 hwicap_type_1_write(u32 reg)
218 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/char/xilinx_hwicap/xilinx_hwicap.h
220 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |
221 <<<<<<< HEAD:drivers/char/xilinx_hwicap/xilinx_hwicap.h
222 (Register << XHI_REGISTER_SHIFT) |
223 =======
224 (reg << XHI_REGISTER_SHIFT) |
225 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/char/xilinx_hwicap/xilinx_hwicap.h
226 (XHI_OP_WRITE << XHI_OP_SHIFT);
229 #endif