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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [scsi/] [megaraid.h] - Blame information for rev 1626

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
#ifndef __MEGARAID_H__
2
#define __MEGARAID_H__
3
 
4
#ifndef LINUX_VERSION_CODE
5
#include <linux/version.h>
6
#endif
7
 
8
#define IN_ISR                  0x80000000L
9
#define NO_INTR                 0x40000000L
10
#define IN_TIMEOUT              0x20000000L
11
#define PENDING                 0x10000000L
12
#define BOARD_QUARTZ            0x08000000L
13
 
14
#define SCB_ACTIVE 0x1
15
#define SCB_WAITQ  0x2
16
#define SCB_ISSUED 0x4
17
 
18
#define SCB_FREE                -1
19
#define SCB_RESET               -2
20
#define SCB_ABORT               -3
21
#define SCB_LOCKED              -4
22
 
23
#define MEGA_CMD_TIMEOUT        10
24
 
25
#define MAX_SGLIST              17
26
#define MAX_COMMANDS            254
27
 
28
#define MAX_LOGICAL_DRIVES      8
29
#define MAX_CHANNEL             5
30
#define MAX_TARGET              15
31
#define MAX_PHYSICAL_DRIVES     MAX_CHANNEL*MAX_TARGET
32
 
33
#define INQUIRY_DATA_SIZE       0x24
34
#define MAX_CDB_LEN             0x0A
35
#define MAX_REQ_SENSE_LEN       0x20
36
 
37
#define INTR_VALID              0x40
38
 
39
/* Mailbox commands */
40
#define MEGA_MBOXCMD_LREAD      0x01
41
#define MEGA_MBOXCMD_LWRITE     0x02
42
#define MEGA_MBOXCMD_PASSTHRU   0x03
43
#define MEGA_MBOXCMD_ADAPTERINQ 0x05
44
 
45
/* Offsets into Mailbox */
46
#define COMMAND_PORT       0x00
47
#define COMMAND_ID_PORT    0x01
48
#define SG_LIST_PORT0      0x08
49
#define SG_LIST_PORT1      0x09
50
#define SG_LIST_PORT2      0x0a
51
#define SG_LIST_PORT3      0x0b
52
#define SG_ELEMENT_PORT    0x0d
53
#define NO_FIRED_PORT      0x0f
54
 
55
/* I/O Port offsets */
56
#define I_CMD_PORT         0x00
57
#define I_ACK_PORT         0x00
58
#define I_TOGGLE_PORT      0x01
59
#define INTR_PORT          0x0a
60
 
61
#define MAILBOX_SIZE       70
62
#define MBOX_BUSY_PORT     0x00
63
#define MBOX_PORT0         0x04
64
#define MBOX_PORT1         0x05
65
#define MBOX_PORT2         0x06
66
#define MBOX_PORT3         0x07
67
#define ENABLE_MBOX_REGION 0x0B
68
 
69
/* I/O Port Values */
70
#define ISSUE_BYTE         0x10
71
#define ACK_BYTE           0x08
72
#define ENABLE_INTR_BYTE   0xc0
73
#define DISABLE_INTR_BYTE  0x00
74
#define VALID_INTR_BYTE    0x40
75
#define MBOX_BUSY_BYTE     0x10
76
#define ENABLE_MBOX_BYTE   0x00
77
 
78
/* Setup some port macros here */
79
#define WRITE_MAILBOX(base,offset,value)   *(base+offset)=value
80
#define READ_MAILBOX(base,offset)          *(base+offset)
81
 
82
#define WRITE_PORT(base,offset,value)      outb_p(value,base+offset)
83
#define READ_PORT(base,offset)             inb_p(base+offset)
84
 
85
#define ISSUE_COMMAND(base)   WRITE_PORT(base,I_CMD_PORT,ISSUE_BYTE)
86
#define CLEAR_INTR(base)      WRITE_PORT(base,I_ACK_PORT,ACK_BYTE)
87
#define ENABLE_INTR(base)     WRITE_PORT(base,I_TOGGLE_PORT,ENABLE_INTR_BYTE)
88
#define DISABLE_INTR(base)    WRITE_PORT(base,I_TOGGLE_PORT,DISABLE_INTR_BYTE)
89
 
90
/* Define AMI's PCI codes */
91
#undef PCI_VENDOR_ID_AMI
92
#undef PCI_DEVICE_ID_AMI_MEGARAID
93
 
94
#ifndef PCI_VENDOR_ID_AMI
95
#define PCI_VENDOR_ID_AMI          0x101E
96
#define PCI_DEVICE_ID_AMI_MEGARAID 0x9010
97
#endif
98
 
99
#define PCI_CONF_BASE_ADDR_OFFSET  0x10
100
#define PCI_CONF_IRQ_OFFSET        0x3c
101
#define PCI_CONF_AMISIG            0xa0
102
#define AMI_SIGNATURE              0x11223344
103
 
104
#if LINUX_VERSION_CODE < 0x20100
105
#define MEGARAID \
106
  { NULL,                               /* Next                      */\
107
    NULL,                               /* Usage Count Pointer       */\
108
    NULL,                               /* /proc Directory Entry     */\
109
    megaraid_proc_info,                 /* /proc Info Function       */\
110
    "MegaRAID",                         /* Driver Name               */\
111
    megaraid_detect,                    /* Detect Host Adapter       */\
112
    megaraid_release,                   /* Release Host Adapter      */\
113
    megaraid_info,                      /* Driver Info Function      */\
114
    megaraid_command,                   /* Command Function          */\
115
    megaraid_queue,                     /* Queue Command Function    */\
116
    megaraid_abort,                     /* Abort Command Function    */\
117
    megaraid_reset,                     /* Reset Command Function    */\
118
    NULL,                               /* Slave Attach Function     */\
119
    megaraid_biosparam,                 /* Disk BIOS Parameters      */\
120
    254,                                /* # of cmds that can be\
121
                                           outstanding at any time */\
122
    7,                                  /* HBA Target ID             */\
123
    MAX_SGLIST,                         /* Scatter/Gather Table Size */\
124
    64,                                 /* SCSI Commands per LUN     */\
125
    0,                                  /* Present                   */\
126
    0,                                  /* Default Unchecked ISA DMA */\
127
    ENABLE_CLUSTERING }         /* Enable Clustering         */
128
#else
129
#define MEGARAID \
130
  {\
131
    name:            "MegaRAID",               /* Driver Name               */\
132
    proc_info:        megaraid_proc_info,      /* /proc driver info         */\
133
    detect:           megaraid_detect,         /* Detect Host Adapter       */\
134
    release:          megaraid_release,        /* Release Host Adapter      */\
135
    info:             megaraid_info,           /* Driver Info Function      */\
136
    command:          megaraid_command,        /* Command Function          */\
137
    queuecommand:     megaraid_queue,          /* Queue Command Function    */\
138
    abort:            megaraid_abort,          /* Abort Command Function    */\
139
    reset:            megaraid_reset,          /* Reset Command Function    */\
140
    bios_param:       megaraid_biosparam,      /* Disk BIOS Parameters      */\
141
    can_queue:        254,                     /* Can Queue                 */\
142
    this_id:          7,                       /* HBA Target ID             */\
143
    sg_tablesize:     MAX_SGLIST,              /* Scatter/Gather Table Size */\
144
    cmd_per_lun:      64,                      /* SCSI Commands per LUN     */\
145
    present:          0,                       /* Present                   */\
146
    unchecked_isa_dma:0,                       /* Default Unchecked ISA DMA */\
147
    use_clustering:   ENABLE_CLUSTERING       /* Enable Clustering         */\
148
  }
149
#endif
150
 
151
/* Structures */
152
typedef struct _mega_ADP_INFO {
153
    u_char MaxConcCmds;
154
    u_char RbldRate;
155
    u_char MaxTargPerChan;
156
    u_char ChanPresent;
157
    u_char FwVer[4];
158
    u_short AgeOfFlash;
159
    u_char ChipSet;
160
    u_char DRAMSize;
161
    u_char CacheFlushInterval;
162
    u_char BiosVer[4];
163
    u_char resvd[7];
164
} mega_ADP_INFO;
165
 
166
typedef struct _mega_LDRV_INFO {
167
    u_char NumLDrv;
168
    u_char resvd[3];
169
    u_long LDrvSize[MAX_LOGICAL_DRIVES];
170
    u_char LDrvProp[MAX_LOGICAL_DRIVES];
171
    u_char LDrvState[MAX_LOGICAL_DRIVES];
172
} mega_LDRV_INFO;
173
 
174
typedef struct _mega_PDRV_INFO {
175
    u_char PDrvState[MAX_PHYSICAL_DRIVES];
176
    u_char resvd;
177
} mega_PDRV_INFO;
178
 
179
// RAID inquiry: Mailbox command 0x5
180
typedef struct _mega_RAIDINQ {
181
    mega_ADP_INFO AdpInfo;
182
    mega_LDRV_INFO LogdrvInfo;
183
    mega_PDRV_INFO PhysdrvInfo;
184
} mega_RAIDINQ;
185
 
186
// Passthrough command: Mailbox command 0x3
187
typedef struct mega_passthru {
188
    u_char timeout:3;           /* 0=6sec/1=60sec/2=10min/3=3hrs */
189
    u_char ars:1;
190
    u_char reserved:3;
191
    u_char islogical:1;
192
    u_char logdrv;              /* if islogical == 1 */
193
    u_char channel;             /* if islogical == 0 */
194
    u_char target;              /* if islogical == 0 */
195
    u_char queuetag;            /* unused */
196
    u_char queueaction;         /* unused */
197
    u_char cdb[MAX_CDB_LEN];
198
    u_char cdblen;
199
    u_char reqsenselen;
200
    u_char reqsensearea[MAX_REQ_SENSE_LEN];
201
    u_char numsgelements;
202
    u_char scsistatus;
203
    u_long dataxferaddr;
204
    u_long dataxferlen;
205
} mega_passthru;
206
 
207
typedef struct _mega_mailbox {
208
    /* 0x0 */ u_char cmd;
209
    /* 0x1 */ u_char cmdid;
210
    /* 0x2 */ u_short numsectors;
211
    /* 0x4 */ u_long lba;
212
    /* 0x8 */ u_long xferaddr;
213
    /* 0xC */ u_char logdrv;
214
    /* 0xD */ u_char numsgelements;
215
    /* 0xE */ u_char resvd;
216
    /* 0xF */ u_char busy;
217
    /* 0x10 */ u_char numstatus;
218
    /* 0x11 */ u_char status;
219
    /* 0x12 */ u_char completed[46];
220
    u_char mraid_poll;
221
    u_char mraid_ack;
222
    u_char pad[16];
223
} mega_mailbox;
224
 
225
typedef struct _mega_ioctl_mbox {
226
    /* 0x0 */ u_char cmd;
227
    /* 0x1 */ u_char cmdid;
228
    /* 0x2 */ u_char channel;
229
    /* 0x3 */ u_char param;
230
    /* 0x4 */ u_char pad[4];
231
    /* 0x8 */ u_long xferaddr;
232
    /* 0xC */ u_char logdrv;
233
    /* 0xD */ u_char numsgelements;
234
    /* 0xE */ u_char resvd;
235
    /* 0xF */ u_char busy;
236
    /* 0x10 */ u_char numstatus;
237
    /* 0x11 */ u_char status;
238
    /* 0x12 */ u_char completed[46];
239
    u_char mraid_poll;
240
    u_char mraid_ack;
241
    u_char malign[16];
242
} mega_ioctl_mbox;
243
 
244
typedef struct _mega_sglist {
245
    u_long address;
246
    u_long length;
247
} mega_sglist;
248
 
249
/* Queued command data */
250
typedef struct _mega_scb mega_scb;
251
 
252
struct _mega_scb {
253
    int idx;
254
    u_long flag;
255
    Scsi_Cmnd *SCpnt;
256
    u_char mboxData[16];
257
    mega_passthru pthru;
258
    mega_sglist *sgList;
259
    mega_scb *next;
260
};
261
 
262
/* Per-controller data */
263
typedef struct _mega_host_config {
264
    u_char numldrv;
265
    u_long flag;
266
    u_long base;
267
 
268
    struct tq_struct megaTq;
269
 
270
    /* Host adapter parameters */
271
    u_char fwVer[7];
272
    u_char biosVer[7];
273
 
274
    struct Scsi_Host *host;
275
 
276
    /* The following must be DMA-able!! */
277
    volatile mega_mailbox *mbox;
278
    volatile mega_mailbox mailbox;
279
    volatile u_char mega_buffer[2 * 1024L];
280
 
281
    u_char max_cmds;
282
    mega_scb scbList[MAX_COMMANDS];
283
} mega_host_config;
284
 
285
extern struct proc_dir_entry proc_scsi_megaraid;
286
 
287
const char *megaraid_info(struct Scsi_Host *);
288
int megaraid_detect(Scsi_Host_Template *);
289
int megaraid_release(struct Scsi_Host *);
290
int megaraid_command(Scsi_Cmnd *);
291
int megaraid_abort(Scsi_Cmnd *);
292
int megaraid_reset(Scsi_Cmnd *, unsigned int);
293
int megaraid_queue(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
294
int megaraid_biosparam(Disk *, kdev_t, int *);
295
int megaraid_proc_info(char *buffer, char **start, off_t offset,
296
                       int length, int hostno, int inout);
297
 
298
#endif

powered by: WebSVN 2.1.0

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