OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [fc4/] [soc.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/* soc.h: Definitions for Sparc SUNW,soc Fibre Channel Sbus driver.
2
 *
3
 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
4
 */
5
 
6
#ifndef __SOC_H
7
#define __SOC_H
8
 
9
#include "fc.h"
10
#include "fcp.h"
11
#include "fcp_impl.h"
12
 
13
/* Hardware register offsets and constants first {{{ */
14
#define CFG     0x00UL          /* Config Register */
15
#define SAE     0x04UL          /* Slave Access Error Register */
16
#define CMD     0x08UL          /* Command and Status Register */
17
#define IMASK   0x0cUL          /* Interrupt Mask Register */
18
 
19
/* Config Register */
20
#define SOC_CFG_EXT_RAM_BANK_MASK       0x07000000
21
#define SOC_CFG_EEPROM_BANK_MASK        0x00030000
22
#define SOC_CFG_BURST64_MASK            0x00000700
23
#define SOC_CFG_SBUS_PARITY_TEST        0x00000020
24
#define SOC_CFG_SBUS_PARITY_CHECK       0x00000010
25
#define SOC_CFG_SBUS_ENHANCED           0x00000008
26
#define SOC_CFG_BURST_MASK              0x00000007
27
/* Bursts */
28
#define SOC_CFG_BURST_4                 0x00000000
29
#define SOC_CFG_BURST_16                0x00000004
30
#define SOC_CFG_BURST_32                0x00000005
31
#define SOC_CFG_BURST_64                0x00000006
32
 
33
/* Slave Access Error Register */
34
#define SOC_SAE_ALIGNMENT               0x00000004
35
#define SOC_SAE_UNSUPPORTED             0x00000002
36
#define SOC_SAE_PARITY                  0x00000001
37
 
38
/* Command & Status Register */
39
#define SOC_CMD_RSP_QALL                0x000f0000
40
#define SOC_CMD_RSP_Q0                  0x00010000
41
#define SOC_CMD_RSP_Q1                  0x00020000
42
#define SOC_CMD_RSP_Q2                  0x00040000
43
#define SOC_CMD_RSP_Q3                  0x00080000
44
#define SOC_CMD_REQ_QALL                0x00000f00
45
#define SOC_CMD_REQ_Q0                  0x00000100
46
#define SOC_CMD_REQ_Q1                  0x00000200
47
#define SOC_CMD_REQ_Q2                  0x00000400
48
#define SOC_CMD_REQ_Q3                  0x00000800
49
#define SOC_CMD_SAE                     0x00000080
50
#define SOC_CMD_INTR_PENDING            0x00000008
51
#define SOC_CMD_NON_QUEUED              0x00000004
52
#define SOC_CMD_IDLE                    0x00000002
53
#define SOC_CMD_SOFT_RESET              0x00000001
54
 
55
/* Interrupt Mask Register */
56
#define SOC_IMASK_RSP_QALL              0x000f0000
57
#define SOC_IMASK_RSP_Q0                0x00010000
58
#define SOC_IMASK_RSP_Q1                0x00020000
59
#define SOC_IMASK_RSP_Q2                0x00040000
60
#define SOC_IMASK_RSP_Q3                0x00080000
61
#define SOC_IMASK_REQ_QALL              0x00000f00
62
#define SOC_IMASK_REQ_Q0                0x00000100
63
#define SOC_IMASK_REQ_Q1                0x00000200
64
#define SOC_IMASK_REQ_Q2                0x00000400
65
#define SOC_IMASK_REQ_Q3                0x00000800
66
#define SOC_IMASK_SAE                   0x00000080
67
#define SOC_IMASK_NON_QUEUED            0x00000004
68
 
69
#define SOC_INTR(s, cmd) \
70
        (((cmd & SOC_CMD_RSP_QALL) | ((~cmd) & SOC_CMD_REQ_QALL)) \
71
         & s->imask)
72
 
73
#define SOC_SETIMASK(s, i) \
74
do {    (s)->imask = (i); \
75
        sbus_writel((i), (s)->regs + IMASK); \
76
} while(0)
77
 
78
/* XRAM
79
 *
80
 * This is a 64KB register area. It accepts only halfword access.
81
 * That's why here are the following inline functions...
82
 */
83
 
84
typedef unsigned long xram_p;
85
 
86
/* Get 32bit number from XRAM */
87
static inline u32 xram_get_32 (xram_p x)
88
{
89
        return ((sbus_readw(x + 0x00UL) << 16) |
90
                (sbus_readw(x + 0x02UL)));
91
}
92
 
93
/* Like the above, but when we don't care about the high 16 bits */
94
static inline u32 xram_get_32low (xram_p x)
95
{
96
        return (u32) sbus_readw(x + 0x02UL);
97
}
98
 
99
static inline u16 xram_get_16 (xram_p x)
100
{
101
        return sbus_readw(x);
102
}
103
 
104
static inline u8 xram_get_8 (xram_p x)
105
{
106
        if (x & (xram_p)0x1) {
107
                x = x - 1;
108
                return (u8) sbus_readw(x);
109
        } else {
110
                return (u8) (sbus_readw(x) >> 8);
111
        }
112
}
113
 
114
static inline void xram_copy_from (void *p, xram_p x, int len)
115
{
116
        for (len >>= 2; len > 0; len--, x += sizeof(u32)) {
117
                u32 val;
118
 
119
                val = ((sbus_readw(x + 0x00UL) << 16) |
120
                       (sbus_readw(x + 0x02UL)));
121
                *((u32 *)p)++ = val;
122
        }
123
}
124
 
125
static inline void xram_copy_to (xram_p x, void *p, int len)
126
{
127
        for (len >>= 2; len > 0; len--, x += sizeof(u32)) {
128
                u32 tmp = *((u32 *)p)++;
129
                sbus_writew(tmp >> 16, x + 0x00UL);
130
                sbus_writew(tmp, x + 0x02UL);
131
        }
132
}
133
 
134
static inline void xram_bzero (xram_p x, int len)
135
{
136
        for (len >>= 1; len > 0; len--, x += sizeof(u16))
137
                sbus_writew(0, x);
138
}
139
 
140
/* Circular Queue */
141
 
142
#define SOC_CQ_REQ_OFFSET       (0x100 * sizeof(u16))
143
#define SOC_CQ_RSP_OFFSET       (0x110 * sizeof(u16))
144
 
145
typedef struct {
146
        u32                     address;
147
        u8                      in;
148
        u8                      out;
149
        u8                      last;
150
        u8                      seqno;
151
} soc_hw_cq;
152
 
153
#define SOC_PORT_A      0x0000  /* From/To Port A */
154
#define SOC_PORT_B      0x0001  /* From/To Port A */
155
#define SOC_FC_HDR      0x0002  /* Contains FC Header */
156
#define SOC_NORSP       0x0004  /* Don't generate response nor interrupt */
157
#define SOC_NOINT       0x0008  /* Generate response but not interrupt */
158
#define SOC_XFERRDY     0x0010  /* Generate XFERRDY */
159
#define SOC_IGNOREPARAM 0x0020  /* Ignore PARAM field in the FC header */
160
#define SOC_COMPLETE    0x0040  /* Command completed */
161
#define SOC_UNSOLICITED 0x0080  /* For request this is the packet to establish unsolicited pools, */
162
                                /* for rsp this is unsolicited packet */
163
#define SOC_STATUS      0x0100  /* State change (on/off line) */
164
 
165
typedef struct {
166
        u32                     token;
167
        u16                     flags;
168
        u8                      class;
169
        u8                      segcnt;
170
        u32                     bytecnt;
171
} soc_hdr;
172
 
173
typedef struct {
174
        u32                     base;
175
        u32                     count;
176
} soc_data;
177
 
178
#define SOC_CQTYPE_OUTBOUND     0x01
179
#define SOC_CQTYPE_INBOUND      0x02
180
#define SOC_CQTYPE_SIMPLE       0x03
181
#define SOC_CQTYPE_IO_WRITE     0x04
182
#define SOC_CQTYPE_IO_READ      0x05
183
#define SOC_CQTYPE_UNSOLICITED  0x06
184
#define SOC_CQTYPE_DIAG         0x07
185
#define SOC_CQTYPE_OFFLINE      0x08
186
#define SOC_CQTYPE_RESPONSE     0x10
187
#define SOC_CQTYPE_INLINE       0x20
188
 
189
#define SOC_CQFLAGS_CONT        0x01
190
#define SOC_CQFLAGS_FULL        0x02
191
#define SOC_CQFLAGS_BADHDR      0x04
192
#define SOC_CQFLAGS_BADPKT      0x08
193
 
194
typedef struct {
195
        soc_hdr                 shdr;
196
        soc_data                data[3];
197
        fc_hdr                  fchdr;
198
        u8                      count;
199
        u8                      type;
200
        u8                      flags;
201
        u8                      seqno;
202
} soc_req;
203
 
204
#define SOC_OK                  0
205
#define SOC_P_RJT               2
206
#define SOC_F_RJT               3
207
#define SOC_P_BSY               4
208
#define SOC_F_BSY               5
209
#define SOC_ONLINE              0x10
210
#define SOC_OFFLINE             0x11
211
#define SOC_TIMEOUT             0x12
212
#define SOC_OVERRUN             0x13
213
#define SOC_UNKOWN_CQ_TYPE      0x20
214
#define SOC_BAD_SEG_CNT         0x21
215
#define SOC_MAX_XCHG_EXCEEDED   0x22
216
#define SOC_BAD_XID             0x23
217
#define SOC_XCHG_BUSY           0x24
218
#define SOC_BAD_POOL_ID         0x25
219
#define SOC_INSUFFICIENT_CQES   0x26
220
#define SOC_ALLOC_FAIL          0x27
221
#define SOC_BAD_SID             0x28
222
#define SOC_NO_SEG_INIT         0x29
223
 
224
typedef struct {
225
        soc_hdr                 shdr;
226
        u32                     status;
227
        soc_data                data;
228
        u8                      xxx1[12];
229
        fc_hdr                  fchdr;
230
        u8                      count;
231
        u8                      type;
232
        u8                      flags;
233
        u8                      seqno;
234
} soc_rsp;
235
 
236
/* }}} */
237
 
238
/* Now our software structures and constants we use to drive the beast {{{ */
239
 
240
#define SOC_CQ_REQ0_SIZE        4
241
#define SOC_CQ_REQ1_SIZE        64
242
#define SOC_CQ_RSP0_SIZE        8
243
#define SOC_CQ_RSP1_SIZE        4
244
 
245
#define SOC_SOLICITED_RSP_Q     0
246
#define SOC_UNSOLICITED_RSP_Q   1
247
 
248
struct soc;
249
 
250
typedef struct {
251
        /* This must come first */
252
        fc_channel              fc;
253
        struct soc              *s;
254
        u16                     flags;
255
        u16                     mask;
256
} soc_port;
257
 
258
typedef struct {
259
        soc_hw_cq               *hw_cq; /* Related XRAM cq */
260
        soc_req                 *pool;
261
        u8                      in;
262
        u8                      out;
263
        u8                      last;
264
        u8                      seqno;
265
} soc_cq;
266
 
267
struct soc {
268
        soc_port                port[2]; /* Every SOC has one or two FC ports */
269
        soc_cq                  req[2]; /* Request CQs */
270
        soc_cq                  rsp[2]; /* Response CQs */
271
        int                     soc_no;
272
        unsigned long           regs;
273
        xram_p                  xram;
274
        fc_wwn                  wwn;
275
        u32                     imask;  /* Our copy of regs->imask */
276
        u32                     cfg;    /* Our copy of regs->cfg */
277
        char                    serv_params[80];
278
        struct soc              *next;
279
        int                     curr_port; /* Which port will have priority to fcp_queue_empty */
280
 
281
        soc_req                 *req_cpu;
282
        u32                     req_dvma;
283
};
284
 
285
/* }}} */
286
 
287
#endif /* !(__SOC_H) */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.