MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / fc4 / socal.h
blob2ff386b9f5fff47e0c7edc4927fa2a990726f171
1 /* socal.h: Definitions for Sparc SUNW,socal (SOC+) Fibre Channel Sbus driver.
3 * Copyright (C) 1998,1999 Jakub Jelinek (jj@ultra.linux.cz)
4 */
6 #ifndef __SOCAL_H
7 #define __SOCAL_H
9 #include "fc.h"
10 #include "fcp.h"
11 #include "fcp_impl.h"
13 /* Hardware register offsets and constants first {{{ */
14 #define CFG 0x00UL
15 #define SAE 0x04UL
16 #define CMD 0x08UL
17 #define IMASK 0x0cUL
18 #define REQP 0x10UL
19 #define RESP 0x14UL
21 /* Config Register */
22 #define SOCAL_CFG_EXT_RAM_BANK_MASK 0x07000000
23 #define SOCAL_CFG_EEPROM_BANK_MASK 0x00030000
24 #define SOCAL_CFG_BURST64_MASK 0x00000700
25 #define SOCAL_CFG_SBUS_PARITY_TEST 0x00000020
26 #define SOCAL_CFG_SBUS_PARITY_CHECK 0x00000010
27 #define SOCAL_CFG_SBUS_ENHANCED 0x00000008
28 #define SOCAL_CFG_BURST_MASK 0x00000007
29 /* Bursts */
30 #define SOCAL_CFG_BURST_4 0x00000000
31 #define SOCAL_CFG_BURST_8 0x00000003
32 #define SOCAL_CFG_BURST_16 0x00000004
33 #define SOCAL_CFG_BURST_32 0x00000005
34 #define SOCAL_CFG_BURST_64 0x00000006
35 #define SOCAL_CFG_BURST_128 0x00000007
37 /* Slave Access Error Register */
38 #define SOCAL_SAE_ALIGNMENT 0x00000004
39 #define SOCAL_SAE_UNSUPPORTED 0x00000002
40 #define SOCAL_SAE_PARITY 0x00000001
42 /* Command & Status Register */
43 #define SOCAL_CMD_RSP_QALL 0x000f0000
44 #define SOCAL_CMD_RSP_Q0 0x00010000
45 #define SOCAL_CMD_RSP_Q1 0x00020000
46 #define SOCAL_CMD_RSP_Q2 0x00040000
47 #define SOCAL_CMD_RSP_Q3 0x00080000
48 #define SOCAL_CMD_REQ_QALL 0x00000f00
49 #define SOCAL_CMD_REQ_Q0 0x00000100
50 #define SOCAL_CMD_REQ_Q1 0x00000200
51 #define SOCAL_CMD_REQ_Q2 0x00000400
52 #define SOCAL_CMD_REQ_Q3 0x00000800
53 #define SOCAL_CMD_SAE 0x00000080
54 #define SOCAL_CMD_INTR_PENDING 0x00000008
55 #define SOCAL_CMD_NON_QUEUED 0x00000004
56 #define SOCAL_CMD_IDLE 0x00000002
57 #define SOCAL_CMD_SOFT_RESET 0x00000001
59 /* Interrupt Mask Register */
60 #define SOCAL_IMASK_RSP_QALL 0x000f0000
61 #define SOCAL_IMASK_RSP_Q0 0x00010000
62 #define SOCAL_IMASK_RSP_Q1 0x00020000
63 #define SOCAL_IMASK_RSP_Q2 0x00040000
64 #define SOCAL_IMASK_RSP_Q3 0x00080000
65 #define SOCAL_IMASK_REQ_QALL 0x00000f00
66 #define SOCAL_IMASK_REQ_Q0 0x00000100
67 #define SOCAL_IMASK_REQ_Q1 0x00000200
68 #define SOCAL_IMASK_REQ_Q2 0x00000400
69 #define SOCAL_IMASK_REQ_Q3 0x00000800
70 #define SOCAL_IMASK_SAE 0x00000080
71 #define SOCAL_IMASK_NON_QUEUED 0x00000004
73 #define SOCAL_INTR(s, cmd) \
74 (((cmd & SOCAL_CMD_RSP_QALL) | ((~cmd) & SOCAL_CMD_REQ_QALL)) \
75 & s->imask)
77 #define SOCAL_SETIMASK(s, i) \
78 do { (s)->imask = (i); \
79 sbus_writel((i), (s)->regs + IMASK); \
80 } while (0)
82 #define SOCAL_MAX_EXCHANGES 1024
84 /* XRAM
86 * This is a 64KB register area.
87 * From the documentation, it seems like it is finally able to cope
88 * at least with 1,2,4 byte accesses for read and 2,4 byte accesses for write.
91 /* Circular Queue */
93 #define SOCAL_CQ_REQ_OFFSET 0x200
94 #define SOCAL_CQ_RSP_OFFSET 0x220
96 typedef struct {
97 u32 address;
98 u8 in;
99 u8 out;
100 u8 last;
101 u8 seqno;
102 } socal_hw_cq;
104 #define SOCAL_PORT_A 0x0000 /* From/To Port A */
105 #define SOCAL_PORT_B 0x0001 /* From/To Port A */
106 #define SOCAL_FC_HDR 0x0002 /* Contains FC Header */
107 #define SOCAL_NORSP 0x0004 /* Don't generate response nor interrupt */
108 #define SOCAL_NOINT 0x0008 /* Generate response but not interrupt */
109 #define SOCAL_XFERRDY 0x0010 /* Generate XFERRDY */
110 #define SOCAL_IGNOREPARAM 0x0020 /* Ignore PARAM field in the FC header */
111 #define SOCAL_COMPLETE 0x0040 /* Command completed */
112 #define SOCAL_UNSOLICITED 0x0080 /* For request this is the packet to establish unsolicited pools, */
113 /* for rsp this is unsolicited packet */
114 #define SOCAL_STATUS 0x0100 /* State change (on/off line) */
115 #define SOCAL_RSP_HDR 0x0200 /* Return frame header in any case */
117 typedef struct {
118 u32 token;
119 u16 flags;
120 u8 class;
121 u8 segcnt;
122 u32 bytecnt;
123 } socal_hdr;
125 typedef struct {
126 u32 base;
127 u32 count;
128 } socal_data;
130 #define SOCAL_CQTYPE_NOP 0x00
131 #define SOCAL_CQTYPE_OUTBOUND 0x01
132 #define SOCAL_CQTYPE_INBOUND 0x02
133 #define SOCAL_CQTYPE_SIMPLE 0x03
134 #define SOCAL_CQTYPE_IO_WRITE 0x04
135 #define SOCAL_CQTYPE_IO_READ 0x05
136 #define SOCAL_CQTYPE_UNSOLICITED 0x06
137 #define SOCAL_CQTYPE_BYPASS_DEV 0x06
138 #define SOCAL_CQTYPE_DIAG 0x07
139 #define SOCAL_CQTYPE_OFFLINE 0x08
140 #define SOCAL_CQTYPE_ADD_POOL 0x09
141 #define SOCAL_CQTYPE_DELETE_POOL 0x0a
142 #define SOCAL_CQTYPE_ADD_BUFFER 0x0b
143 #define SOCAL_CQTYPE_ADD_POOL_BUFFER 0x0c
144 #define SOCAL_CQTYPE_REQUEST_ABORT 0x0d
145 #define SOCAL_CQTYPE_REQUEST_LIP 0x0e
146 #define SOCAL_CQTYPE_REPORT_MAP 0x0f
147 #define SOCAL_CQTYPE_RESPONSE 0x10
148 #define SOCAL_CQTYPE_INLINE 0x20
150 #define SOCAL_CQFLAGS_CONT 0x01
151 #define SOCAL_CQFLAGS_FULL 0x02
152 #define SOCAL_CQFLAGS_BADHDR 0x04
153 #define SOCAL_CQFLAGS_BADPKT 0x08
155 typedef struct {
156 socal_hdr shdr;
157 socal_data data[3];
158 fc_hdr fchdr;
159 u8 count;
160 u8 type;
161 u8 flags;
162 u8 seqno;
163 } socal_req;
165 #define SOCAL_OK 0
166 #define SOCAL_P_RJT 2
167 #define SOCAL_F_RJT 3
168 #define SOCAL_P_BSY 4
169 #define SOCAL_F_BSY 5
170 #define SOCAL_ONLINE 0x10
171 #define SOCAL_OFFLINE 0x11
172 #define SOCAL_TIMEOUT 0x12
173 #define SOCAL_OVERRUN 0x13
174 #define SOCAL_ONLINE_LOOP 0x14
175 #define SOCAL_OLD_PORT 0x15
176 #define SOCAL_AL_PORT 0x16
177 #define SOCAL_UNKOWN_CQ_TYPE 0x20
178 #define SOCAL_BAD_SEG_CNT 0x21
179 #define SOCAL_MAX_XCHG_EXCEEDED 0x22
180 #define SOCAL_BAD_XID 0x23
181 #define SOCAL_XCHG_BUSY 0x24
182 #define SOCAL_BAD_POOL_ID 0x25
183 #define SOCAL_INSUFFICIENT_CQES 0x26
184 #define SOCAL_ALLOC_FAIL 0x27
185 #define SOCAL_BAD_SID 0x28
186 #define SOCAL_NO_SEG_INIT 0x29
187 #define SOCAL_BAD_DID 0x2a
188 #define SOCAL_ABORTED 0x30
189 #define SOCAL_ABORT_FAILED 0x31
191 typedef struct {
192 socal_hdr shdr;
193 u32 status;
194 socal_data data;
195 u8 xxx1[10];
196 u16 ncmds;
197 fc_hdr fchdr;
198 u8 count;
199 u8 type;
200 u8 flags;
201 u8 seqno;
202 } socal_rsp;
204 typedef struct {
205 socal_hdr shdr;
206 u8 xxx1[48];
207 u8 count;
208 u8 type;
209 u8 flags;
210 u8 seqno;
211 } socal_cmdonly;
213 #define SOCAL_DIAG_NOP 0x00
214 #define SOCAL_DIAG_INT_LOOP 0x01
215 #define SOCAL_DIAG_EXT_LOOP 0x02
216 #define SOCAL_DIAG_REM_LOOP 0x03
217 #define SOCAL_DIAG_XRAM_TEST 0x04
218 #define SOCAL_DIAG_SOC_TEST 0x05
219 #define SOCAL_DIAG_HCB_TEST 0x06
220 #define SOCAL_DIAG_SOCLB_TEST 0x07
221 #define SOCAL_DIAG_SRDSLB_TEST 0x08
222 #define SOCAL_DIAG_EXTOE_TEST 0x09
224 typedef struct {
225 socal_hdr shdr;
226 u32 cmd;
227 u8 xxx1[44];
228 u8 count;
229 u8 type;
230 u8 flags;
231 u8 seqno;
232 } socal_diag_req;
234 #define SOCAL_POOL_MASK_RCTL 0x800000
235 #define SOCAL_POOL_MASK_DID 0x700000
236 #define SOCAL_POOL_MASK_SID 0x070000
237 #define SOCAL_POOL_MASK_TYPE 0x008000
238 #define SOCAL_POOL_MASK_F_CTL 0x007000
239 #define SOCAL_POOL_MASK_SEQ_ID 0x000800
240 #define SOCAL_POOL_MASK_D_CTL 0x000400
241 #define SOCAL_POOL_MASK_SEQ_CNT 0x000300
242 #define SOCAL_POOL_MASK_OX_ID 0x0000f0
243 #define SOCAL_POOL_MASK_PARAM 0x00000f
245 typedef struct {
246 socal_hdr shdr;
247 u32 pool_id;
248 u32 header_mask;
249 u32 buf_size;
250 u32 entries;
251 u8 xxx1[8];
252 fc_hdr fchdr;
253 u8 count;
254 u8 type;
255 u8 flags;
256 u8 seqno;
257 } socal_pool_req;
259 /* }}} */
261 /* Now our software structures and constants we use to drive the beast {{{ */
263 #define SOCAL_CQ_REQ0_SIZE 4
264 #define SOCAL_CQ_REQ1_SIZE 256
265 #define SOCAL_CQ_RSP0_SIZE 8
266 #define SOCAL_CQ_RSP1_SIZE 4
267 #define SOCAL_CQ_RSP2_SIZE 4
269 #define SOCAL_SOLICITED_RSP_Q 0
270 #define SOCAL_SOLICITED_BAD_RSP_Q 1
271 #define SOCAL_UNSOLICITED_RSP_Q 2
273 struct socal;
275 typedef struct {
276 /* This must come first */
277 fc_channel fc;
278 struct socal *s;
279 u16 flags;
280 u16 mask;
281 } socal_port;
283 typedef struct {
284 socal_hw_cq *hw_cq; /* Related XRAM cq */
285 socal_req *pool;
286 u8 in;
287 u8 out;
288 u8 last;
289 u8 seqno;
290 } socal_cq;
292 struct socal {
293 spinlock_t lock;
294 socal_port port[2]; /* Every SOCAL has one or two FC ports */
295 socal_cq req[4]; /* Request CQs */
296 socal_cq rsp[4]; /* Response CQs */
297 int socal_no;
298 void __iomem *regs;
299 void __iomem *xram;
300 void __iomem *eeprom;
301 fc_wwn wwn;
302 u32 imask; /* Our copy of regs->imask */
303 u32 cfg; /* Our copy of regs->cfg */
304 char serv_params[80];
305 struct socal *next;
306 int curr_port; /* Which port will have priority to fcp_queue_empty */
308 socal_req * req_cpu;
309 u32 req_dvma;
312 /* }}} */
314 #endif /* !(__SOCAL_H) */