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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [armnommu/] [drivers/] [scsi/] [acornscsi.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1622 jcastillo
#ifndef ACORNSCSI_H
2
#define ACORNSCSI_H
3
 
4
#ifndef ASM
5
extern int acornscsi_detect (Scsi_Host_Template *);
6
extern int acornscsi_release (struct Scsi_Host *);
7
extern const char *acornscsi_info (struct Scsi_Host *);
8
extern int acornscsi_queuecmd (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
9
extern int acornscsi_abort (Scsi_Cmnd *);
10
extern int acornscsi_reset (Scsi_Cmnd *, unsigned int);
11
extern int acornscsi_proc_info (char *, char **, off_t, int, int, int);
12
extern int acornscsi_biosparam (Disk *, kdev_t, int []);
13
 
14
#ifndef NULL
15
#define NULL 0
16
#endif
17
 
18
#ifndef CMD_PER_LUN
19
#define CMD_PER_LUN 2
20
#endif
21
 
22
#ifndef CAN_QUEUE
23
#define CAN_QUEUE 16
24
#endif
25
 
26
#ifndef PROC_SCSI_AKA30
27
#include "linux/proc_fs.h"
28
#define PROC_SCSI_AKA30 PROC_SCSI_EATA
29
#endif
30
 
31
#include <scsi/scsicam.h>
32
 
33
#define ACORNSCSI_3 {                                           \
34
        NULL,                   /* Ptr for modules */           \
35
        NULL,                   /* usage count for modules */   \
36
        NULL,                                                   \
37
        acornscsi_proc_info,                                    \
38
        "AcornSCSI",                                            \
39
        acornscsi_detect,                                       \
40
        acornscsi_release,      /* Release */                   \
41
        acornscsi_info,                                         \
42
        NULL,                                                   \
43
        acornscsi_queuecmd,                                     \
44
        acornscsi_abort,                                        \
45
        acornscsi_reset,                                        \
46
        NULL,                                                   \
47
        scsicam_bios_param,                                     \
48
        CAN_QUEUE,              /* can_queue */                 \
49
        7,                      /* this id */                   \
50
        SG_ALL,                 /* sg_tablesize */              \
51
        CMD_PER_LUN,            /* cmd_per_lun */               \
52
        0,                       /* number of boards */          \
53
        0,                       /* unchecked isa dma */         \
54
        DISABLE_CLUSTERING                                      \
55
        }
56
 
57
#ifndef HOSTS_C
58
 
59
/* SBIC registers */
60
#define OWNID                   0
61
#define OWNID_FS1               (1<<7)
62
#define OWNID_FS2               (1<<6)
63
#define OWNID_EHP               (1<<4)
64
#define OWNID_EAF               (1<<3)
65
 
66
#define CTRL                    1
67
#define CTRL_DMAMODE            (1<<7)
68
#define CTRL_DMADBAMODE         (1<<6)
69
#define CTRL_DMABURST           (1<<5)
70
#define CTRL_DMAPOLLED          0
71
#define CTRL_HHP                (1<<4)
72
#define CTRL_EDI                (1<<3)
73
#define CTRL_IDI                (1<<2)
74
#define CTRL_HA                 (1<<1)
75
#define CTRL_HSP                (1<<0)
76
 
77
#define TIMEOUT                 2
78
#define TOTSECTS                3
79
#define TOTHEADS                4
80
#define TOTCYLH                 5
81
#define TOTCYLL                 6
82
#define LOGADDRH                7
83
#define LOGADDRM2               8
84
#define LOGADDRM1               9
85
#define LOGADDRL                10
86
#define SECTORNUM               11
87
#define HEADNUM                 12
88
#define CYLH                    13
89
#define CYLL                    14
90
#define TARGETLUN               15
91
#define TARGETLUN_TLV           (1<<7)
92
#define TARGETLUN_DOK           (1<<6)
93
 
94
#define CMNDPHASE               16
95
#define SYNCHTRANSFER           17
96
#define SYNCHTRANSFER_OF0       0x00
97
#define SYNCHTRANSFER_OF1       0x01
98
#define SYNCHTRANSFER_OF2       0x02
99
#define SYNCHTRANSFER_OF3       0x03
100
#define SYNCHTRANSFER_OF4       0x04
101
#define SYNCHTRANSFER_OF5       0x05
102
#define SYNCHTRANSFER_OF6       0x06
103
#define SYNCHTRANSFER_OF7       0x07
104
#define SYNCHTRANSFER_OF8       0x08
105
#define SYNCHTRANSFER_OF9       0x09
106
#define SYNCHTRANSFER_OF10      0x0A
107
#define SYNCHTRANSFER_OF11      0x0B
108
#define SYNCHTRANSFER_OF12      0x0C
109
#define SYNCHTRANSFER_8DBA      0x00
110
#define SYNCHTRANSFER_2DBA      0x20
111
#define SYNCHTRANSFER_3DBA      0x30
112
#define SYNCHTRANSFER_4DBA      0x40
113
#define SYNCHTRANSFER_5DBA      0x50
114
#define SYNCHTRANSFER_6DBA      0x60
115
#define SYNCHTRANSFER_7DBA      0x70
116
 
117
#define TRANSCNTH               18
118
#define TRANSCNTM               19
119
#define TRANSCNTL               20
120
#define DESTID                  21
121
#define DESTID_SCC              (1<<7)
122
#define DESTID_DPD              (1<<6)
123
 
124
#define SOURCEID                22
125
#define SOURCEID_ER             (1<<7)
126
#define SOURCEID_ES             (1<<6)
127
#define SOURCEID_DSP            (1<<5)
128
#define SOURCEID_SIV            (1<<4)
129
 
130
#define SSR                     23
131
#define CMND                    24
132
#define CMND_RESET              0x00
133
#define CMND_ABORT              0x01
134
#define CMND_ASSERTATN          0x02
135
#define CMND_NEGATEACK          0x03
136
#define CMND_DISCONNECT         0x04
137
#define CMND_RESELECT           0x05
138
#define CMND_SELWITHATN         0x06
139
#define CMND_SELECT             0x07
140
#define CMND_SELECTATNTRANSFER  0x08
141
#define CMND_SELECTTRANSFER     0x09
142
#define CMND_RESELECTRXDATA     0x0A
143
#define CMND_RESELECTTXDATA     0x0B
144
#define CMND_WAITFORSELRECV     0x0C
145
#define CMND_SENDSTATCMD        0x0D
146
#define CMND_SENDDISCONNECT     0x0E
147
#define CMND_SETIDI             0x0F
148
#define CMND_RECEIVECMD         0x10
149
#define CMND_RECEIVEDTA         0x11
150
#define CMND_RECEIVEMSG         0x12
151
#define CMND_RECEIVEUSP         0x13
152
#define CMND_SENDCMD            0x14
153
#define CMND_SENDDATA           0x15
154
#define CMND_SENDMSG            0x16
155
#define CMND_SENDUSP            0x17
156
#define CMND_TRANSLATEADDR      0x18
157
#define CMND_XFERINFO           0x20
158
#define CMND_SBT                (1<<7)
159
 
160
#define DATA                    25
161
#define ASR                     26
162
#define ASR_INT                 (1<<7)
163
#define ASR_LCI                 (1<<6)
164
#define ASR_BSY                 (1<<5)
165
#define ASR_CIP                 (1<<4)
166
#define ASR_PE                  (1<<1)
167
#define ASR_DBR                 (1<<0)
168
 
169
/* DMAC registers */
170
#define INIT                    0x00
171
#define INIT_8BIT               (1)
172
 
173
#define CHANNEL                 0x80
174
#define CHANNEL_0               0x00
175
#define CHANNEL_1               0x01
176
#define CHANNEL_2               0x02
177
#define CHANNEL_3               0x03
178
 
179
#define TXCNTLO                 0x01
180
#define TXCNTHI                 0x81
181
#define TXADRLO                 0x02
182
#define TXADRMD                 0x82
183
#define TXADRHI                 0x03
184
 
185
#define DEVCON0                 0x04
186
#define DEVCON0_AKL             (1<<7)
187
#define DEVCON0_RQL             (1<<6)
188
#define DEVCON0_EXW             (1<<5)
189
#define DEVCON0_ROT             (1<<4)
190
#define DEVCON0_CMP             (1<<3)
191
#define DEVCON0_DDMA            (1<<2)
192
#define DEVCON0_AHLD            (1<<1)
193
#define DEVCON0_MTM             (1<<0)
194
 
195
#define DEVCON1                 0x84
196
#define DEVCON1_WEV             (1<<1)
197
#define DEVCON1_BHLD            (1<<0)
198
 
199
#define MODECON                 0x05
200
#define MODECON_WOED            0x01
201
#define MODECON_VERIFY          0x00
202
#define MODECON_READ            0x04
203
#define MODECON_WRITE           0x08
204
#define MODECON_AUTOINIT        0x10
205
#define MODECON_ADDRDIR         0x20
206
#define MODECON_DEMAND          0x00
207
#define MODECON_SINGLE          0x40
208
#define MODECON_BLOCK           0x80
209
#define MODECON_CASCADE         0xC0
210
 
211
#define STATUS                  0x85
212
#define STATUS_TC0              (1<<0)
213
#define STATUS_RQ0              (1<<4)
214
 
215
#define TEMPLO                  0x06
216
#define TEMPHI                  0x86
217
#define REQREG                  0x07
218
#define MASKREG                 0x87
219
#define MASKREG_M0              0x01
220
#define MASKREG_M1              0x02
221
#define MASKREG_M2              0x04
222
#define MASKREG_M3              0x08
223
 
224
/* miscellaneous internal variables */
225
 
226
#define POD_SPACE(x)    ((x) + 0xd0000)
227
#define MASK_ON         (MASKREG_M3|MASKREG_M2|MASKREG_M1|MASKREG_M0)
228
#define MASK_OFF        (MASKREG_M3|MASKREG_M2|MASKREG_M1)
229
 
230
#define min(x,y) ((x) < (y) ? (x) : (y))
231
#define max(x,y) ((x) < (y) ? (y) : (x))
232
 
233
/*
234
 * SCSI driver phases
235
 */
236
typedef enum {
237
    PHASE_IDLE,                                 /* we're not planning on doing anything  */
238
    PHASE_CONNECTING,                           /* connecting to a target                */
239
    PHASE_CONNECTED,                            /* connected to a target                 */
240
    PHASE_MSGOUT,                               /* message out to device                 */
241
    PHASE_RECONNECTED,                          /* reconnected                           */
242
    PHASE_COMMANDPAUSED,                        /* command partly sent                   */
243
    PHASE_COMMAND,                              /* command all sent                      */
244
    PHASE_DATAOUT,                              /* data out to device                    */
245
    PHASE_DATAIN,                               /* data in from device                   */
246
    PHASE_STATUSIN,                             /* status in from device                 */
247
    PHASE_MSGIN,                                /* message in from device                */
248
    PHASE_DONE,                                 /* finished                              */
249
    PHASE_ABORTED,                              /* aborted                               */
250
    PHASE_DISCONNECT,                           /* disconnecting                         */
251
} phase_t;
252
 
253
/*
254
 * After interrupt, what to do now
255
 */
256
typedef enum {
257
    INTR_IDLE,                                  /* not expecting another IRQ             */
258
    INTR_NEXT_COMMAND,                          /* start next command                    */
259
    INTR_PROCESSING,                            /* interrupt routine still processing    */
260
} intr_ret_t;
261
 
262
/*
263
 * DMA direction
264
 */
265
typedef enum {
266
    DMA_OUT,                                    /* DMA from memory to chip              */
267
    DMA_IN                                      /* DMA from chip to memory              */
268
} dmadir_t;
269
 
270
/*
271
 * Synchronous transfer state
272
 */
273
typedef enum {                                  /* Synchronous transfer state           */
274
    SYNC_ASYNCHRONOUS,                          /* don't negociate synchronous transfers*/
275
    SYNC_NEGOCIATE,                             /* start negociation                    */
276
    SYNC_SENT_REQUEST,                          /* sent SDTR message                    */
277
    SYNC_COMPLETED,                             /* received SDTR reply                  */
278
} syncxfer_t;
279
 
280
/*
281
 * Command type
282
 */
283
typedef enum {                                  /* command type                         */
284
    CMD_READ,                                   /* READ_6, READ_10, READ_12             */
285
    CMD_WRITE,                                  /* WRITE_6, WRITE_10, WRITE_12          */
286
    CMD_MISC,                                   /* Others                               */
287
} cmdtype_t;
288
 
289
/*
290
 * Data phase direction
291
 */
292
typedef enum {                                  /* Data direction                       */
293
    DATADIR_IN,                                 /* Data in phase expected               */
294
    DATADIR_OUT                                 /* Data out phase expected              */
295
} datadir_t;
296
 
297
#include "queue.h"
298
#include "msgqueue.h"
299
 
300
#define STATUS_BUFFER_SIZE      32
301
/*
302
 * This is used to dump the previous states of the SBIC
303
 */
304
struct status_entry {
305
        unsigned long   when;
306
        unsigned char   ssr;
307
        unsigned char   ph;
308
        unsigned char   irq;
309
        unsigned char   unused;
310
};
311
 
312
#define ADD_STATUS(_q,_ssr,_ph,_irq) \
313
({                                                              \
314
        host->status[(_q)][host->status_ptr[(_q)]].when = jiffies;      \
315
        host->status[(_q)][host->status_ptr[(_q)]].ssr  = (_ssr);       \
316
        host->status[(_q)][host->status_ptr[(_q)]].ph   = (_ph);        \
317
        host->status[(_q)][host->status_ptr[(_q)]].irq  = (_irq);       \
318
        host->status_ptr[(_q)] = (host->status_ptr[(_q)] + 1) & (STATUS_BUFFER_SIZE - 1);       \
319
})
320
 
321
/*
322
 * AcornSCSI host specific data
323
 */
324
typedef struct acornscsi_hostdata {
325
    /* miscellaneous */
326
    struct Scsi_Host    *host;                  /* host                                 */
327
    Scsi_Cmnd           *SCpnt;                 /* currently processing command         */
328
    Scsi_Cmnd           *origSCpnt;             /* original connecting command          */
329
 
330
    /* driver information */
331
    struct {
332
        unsigned int    io_port;                /* base address of WD33C93              */
333
        unsigned char   irq;                    /* interrupt                            */
334
        phase_t         phase;                  /* current phase                        */
335
 
336
        struct {
337
            unsigned char       target;         /* reconnected target                   */
338
            unsigned char       lun;            /* reconnected lun                      */
339
            unsigned char       tag;            /* reconnected tag                      */
340
        } reconnected;
341
 
342
        Scsi_Pointer    SCp;                    /* current commands data pointer        */
343
 
344
        MsgQueue_t      msgs;
345
 
346
        unsigned short  last_message;           /* last message to be sent              */
347
        unsigned char   disconnectable:1;       /* this command can be disconnected     */
348
        unsigned char   interrupt:1;            /* interrupt active                     */
349
    } scsi;
350
 
351
    /* statistics information */
352
    struct {
353
        unsigned int    queues;
354
        unsigned int    removes;
355
        unsigned int    fins;
356
        unsigned int    reads;
357
        unsigned int    writes;
358
        unsigned int    miscs;
359
        unsigned int    disconnects;
360
        unsigned int    aborts;
361
        unsigned int    resets;
362
    } stats;
363
 
364
    /* queue handling */
365
    struct {
366
        Queue_t         issue;                  /* issue queue                          */
367
        Queue_t         disconnected;           /* disconnected command queue           */
368
    } queues;
369
 
370
    /* per-device info */
371
    struct {
372
        unsigned char   sync_xfer;              /* synchronous transfer (SBIC value)    */
373
        syncxfer_t      sync_state;             /* sync xfer negociation state          */
374
        unsigned char   disconnect_ok:1;        /* device can disconnect                */
375
    } device[8];
376
    unsigned char       busyluns[8];            /* array of bits indicating LUNs busy   */
377
 
378
    /* DMA info */
379
    struct {
380
        unsigned int    io_port;                /* base address of DMA controller       */
381
        unsigned int    io_intr_clear;          /* address of DMA interrupt clear       */
382
        unsigned int    free_addr;              /* next free address                    */
383
        unsigned int    start_addr;             /* start address of current transfer    */
384
        dmadir_t        direction;              /* dma direction                        */
385
        unsigned int    transferred;            /* number of bytes transferred          */
386
        unsigned int    xfer_start;             /* scheduled DMA transfer start         */
387
        unsigned int    xfer_length;            /* scheduled DMA transfer length        */
388
        char            *xfer_ptr;              /* pointer to area                      */
389
        unsigned char   xfer_required:1;        /* set if we need to transfer something */
390
        unsigned char   xfer_setup:1;           /* set if DMA is setup                  */
391
        unsigned char   xfer_done:1;            /* set if DMA reached end of BH list    */
392
    } dma;
393
 
394
    /* card info */
395
    struct {
396
        unsigned int    io_intr;                /* base address of interrupt id reg     */
397
        unsigned int    io_page;                /* base address of page reg             */
398
        unsigned int    io_ram;                 /* base address of RAM access           */
399
        unsigned char   page_reg;               /* current setting of page reg          */
400
    } card;
401
 
402
    unsigned char status_ptr[9];
403
    struct status_entry status[9][STATUS_BUFFER_SIZE];
404
} AS_Host;
405
 
406
#endif /* ndef HOSTS_C */
407
 
408
#endif /* ndef ASM */
409
#endif /* ACORNSCSI_H */

powered by: WebSVN 2.1.0

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