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/] [cumana_1.c] - Blame information for rev 1622

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

Line No. Rev Author Line
1 1622 jcastillo
#define AUTOSENSE
2
#define PSEUDO_DMA
3
 
4
/*
5
 * Generic Generic NCR5380 driver
6
 *
7
 * Copyright 1995, Russell King
8
 *
9
 * ALPHA RELEASE 1.
10
 *
11
 * For more information, please consult
12
 *
13
 * NCR 5380 Family
14
 * SCSI Protocol Controller
15
 * Databook
16
 *
17
 * NCR Microelectronics
18
 * 1635 Aeroplaza Drive
19
 * Colorado Springs, CO 80916
20
 * 1+ (719) 578-3400
21
 * 1+ (800) 334-5454
22
 */
23
 
24
 
25
/*
26
 * Options :
27
 *
28
 * PARITY - enable parity checking.  Not supported.
29
 *
30
 * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
31
 *
32
 * USLEEP - enable support for devices that don't disconnect.  Untested.
33
 */
34
 
35
/*
36
 * $Log: not supported by cvs2svn $
37
 * Revision 1.1.1.1  2001/09/10 07:43:54  simons
38
 * Initial import
39
 *
40
 * Revision 1.1.1.1  2001/07/02 17:58:40  simons
41
 * Initial revision
42
 *
43
 * Revision 1.1.1.1  1999/11/15 13:42:32  vadim
44
 * Initial import
45
 *
46
 */
47
 
48
#include <linux/module.h>
49
#include <asm/system.h>
50
#include <asm/io.h>
51
#include <linux/signal.h>
52
#include <linux/sched.h>
53
#include <linux/ioport.h>
54
#include "../block/blk.h"
55
#include "scsi.h"
56
#include "hosts.h"
57
#include "cumana_1.h"
58
#include "NCR5380.h"
59
#include "constants.h"
60
 
61
#include <asm/ecard.h>
62
 
63
static const card_ids cumanascsi_cids[] = {
64
        { MANU_CUMANA, PROD_CUMANA_SCSI_1 },
65
        { 0xffff, 0xffff }
66
};
67
 
68
static struct proc_dir_entry proc_scsi_cumana1 = {
69
        PROC_SCSI_T128, 12, "CumanaSCSI-1", S_IFDIR | S_IRUGO, S_IXUGO, 2
70
};
71
 
72
/*
73
 * Function : cumanascsi_setup(char *str, int *ints)
74
 *
75
 * Purpose : LILO command line initialization of the overrides array,
76
 *
77
 * Inputs : str - unused, ints - array of integer parameters with ints[0]
78
 *      equal to the number of ints.
79
 *
80
 */
81
 
82
void cumanascsi_setup(char *str, int *ints) {
83
}
84
 
85
#define CUMANA_ADDRESS(card) (ecard_address((card), ECARD_IOC, ECARD_SLOW) + 0x800)
86
#define CUMANA_IRQ(card)     ((card)->irq)
87
/*
88
 * Function : int cumanascsi_detect(Scsi_Host_Template * tpnt)
89
 *
90
 * Purpose : initializes cumana NCR5380 driver based on the
91
 *      command line / compile time port and irq definitions.
92
 *
93
 * Inputs : tpnt - template for this SCSI adapter.
94
 *
95
 * Returns : 1 if a host adapter was found, 0 if not.
96
 *
97
 */
98
static struct expansion_card *ecs[4];
99
 
100
int cumanascsi_detect(Scsi_Host_Template * tpnt)
101
{
102
    int count = 0;
103
    struct Scsi_Host *instance;
104
 
105
    tpnt->proc_dir = &proc_scsi_cumana1;
106
 
107
    memset (ecs, 0, sizeof (ecs));
108
 
109
    while(1) {
110
        if((ecs[count] = ecard_find(0, cumanascsi_cids)) == NULL)
111
                break;
112
 
113
        instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
114
        instance->io_port = CUMANA_ADDRESS(ecs[count]);
115
        instance->irq = CUMANA_IRQ(ecs[count]);
116
 
117
        NCR5380_init(instance, 0);
118
        ecard_claim(ecs[count]);
119
 
120
        instance->n_io_port = 255;
121
        request_region (instance->io_port, instance->n_io_port, "CumanaSCSI-1");
122
 
123
        ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
124
        outb(0x00, instance->io_port - 577);
125
 
126
        if (instance->irq != IRQ_NONE)
127
            if (request_irq(instance->irq, cumanascsi_intr, SA_INTERRUPT, "CumanaSCSI-1", NULL)) {
128
                printk("scsi%d: IRQ%d not free, interrupts disabled\n",
129
                    instance->host_no, instance->irq);
130
                instance->irq = IRQ_NONE;
131
            }
132
 
133
        if (instance->irq == IRQ_NONE) {
134
            printk("scsi%d: interrupts not enabled. for better interactive performance,\n", instance->host_no);
135
            printk("scsi%d: please jumper the board for a free IRQ.\n", instance->host_no);
136
        }
137
 
138
        printk("scsi%d: at port %X irq", instance->host_no, instance->io_port);
139
        if (instance->irq == IRQ_NONE)
140
            printk ("s disabled");
141
        else
142
            printk (" %d", instance->irq);
143
        printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
144
            CAN_QUEUE, CMD_PER_LUN, CUMANASCSI_PUBLIC_RELEASE);
145
        printk("\nscsi%d:", instance->host_no);
146
        NCR5380_print_options(instance);
147
        printk("\n");
148
 
149
        ++count;
150
    }
151
    return count;
152
}
153
 
154
int cumanascsi_release (struct Scsi_Host *shpnt)
155
{
156
        int i;
157
 
158
        if (shpnt->irq != IRQ_NONE)
159
                free_irq (shpnt->irq, NULL);
160
        if (shpnt->io_port)
161
                release_region (shpnt->io_port, shpnt->n_io_port);
162
 
163
        for (i = 0; i < 4; i++)
164
                if (shpnt->io_port == CUMANA_ADDRESS(ecs[i]))
165
                        ecard_release (ecs[i]);
166
        return 0;
167
}
168
 
169
const char * cumanascsi_info (struct Scsi_Host *spnt) {
170
    return "";
171
}
172
 
173
#ifdef NOT_EFFICIENT
174
#define CTRL(p,v)     outb(*ctrl = (v), (p) - 577)
175
#define STAT(p)       inb((p)+1)
176
#define IN(p)         inb((p))
177
#define OUT(v,p)      outb((v), (p))
178
#else
179
#define CTRL(p,v)       (p[-2308] = (*ctrl = (v)))
180
#define STAT(p)         (p[4])
181
#define IN(p)           (*(p))
182
#define IN2(p)          ((unsigned short)(*(volatile unsigned long *)(p)))
183
#define OUT(v,p)        (*(p) = (v))
184
#define OUT2(v,p)       (*((volatile unsigned long *)(p)) = (v))
185
#endif
186
#define L(v)            (((v)<<16)|((v) & 0x0000ffff))
187
#define H(v)            (((v)>>16)|((v) & 0xffff0000))
188
 
189
static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr,
190
              int len)
191
{
192
  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
193
  int oldctrl = *ctrl;
194
  unsigned long *laddr;
195
#ifdef NOT_EFFICIENT
196
  int iobase = instance->io_port;
197
  int dma_io = iobase & ~(0x3C0000>>2);
198
#else
199
  volatile unsigned char *iobase = (unsigned char *)ioaddr(instance->io_port);
200
  volatile unsigned char *dma_io = (unsigned char *)((int)iobase & ~0x3C0000);
201
#endif
202
 
203
  if(!len) return 0;
204
 
205
  CTRL(iobase, 0x02);
206
  laddr = (unsigned long *)addr;
207
  while(len >= 32)
208
  {
209
    int status;
210
    unsigned long v;
211
    status = STAT(iobase);
212
    if(status & 0x80)
213
      goto end;
214
    if(!(status & 0x40))
215
      continue;
216
    v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
217
    v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
218
    v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
219
    v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
220
    v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
221
    v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
222
    v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
223
    v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io);
224
    len -= 32;
225
    if(len == 0)
226
      break;
227
  }
228
 
229
  addr = (unsigned char *)laddr;
230
  CTRL(iobase, 0x12);
231
  while(len > 0)
232
  {
233
    int status;
234
    status = STAT(iobase);
235
    if(status & 0x80)
236
      goto end;
237
    if(status & 0x40)
238
    {
239
      OUT(*addr++, dma_io);
240
      if(--len == 0)
241
        break;
242
    }
243
 
244
    status = STAT(iobase);
245
    if(status & 0x80)
246
      goto end;
247
    if(status & 0x40)
248
    {
249
      OUT(*addr++, dma_io);
250
      if(--len == 0)
251
        break;
252
    }
253
  }
254
end:
255
  CTRL(iobase, oldctrl|0x40);
256
  return len;
257
}
258
 
259
static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr,
260
              int len)
261
{
262
  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
263
  int oldctrl = *ctrl;
264
  unsigned long *laddr;
265
#ifdef NOT_EFFICIENT
266
  int iobase = instance->io_port;
267
  int dma_io = iobase & ~(0x3C0000>>2);
268
#else
269
  volatile unsigned char *iobase = (unsigned char *)ioaddr(instance->io_port);
270
  volatile unsigned char *dma_io = (unsigned char *)((int)iobase & ~0x3C0000);
271
#endif
272
 
273
  if(!len) return 0;
274
 
275
  CTRL(iobase, 0x00);
276
  laddr = (unsigned long *)addr;
277
  while(len >= 32)
278
  {
279
    int status;
280
    status = STAT(iobase);
281
    if(status & 0x80)
282
      goto end;
283
    if(!(status & 0x40))
284
      continue;
285
    *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
286
    *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
287
    *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
288
    *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
289
    *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
290
    *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
291
    *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
292
    *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16);
293
    len -= 32;
294
    if(len == 0)
295
      break;
296
  }
297
 
298
  addr = (unsigned char *)laddr;
299
  CTRL(iobase, 0x10);
300
  while(len > 0)
301
  {
302
    int status;
303
    status = STAT(iobase);
304
    if(status & 0x80)
305
      goto end;
306
    if(status & 0x40)
307
    {
308
      *addr++ = IN(dma_io);
309
      if(--len == 0)
310
        break;
311
    }
312
 
313
    status = STAT(iobase);
314
    if(status & 0x80)
315
      goto end;
316
    if(status & 0x40)
317
    {
318
      *addr++ = IN(dma_io);
319
      if(--len == 0)
320
        break;
321
    }
322
  }
323
end:
324
  CTRL(iobase, oldctrl|0x40);
325
  return len;
326
}
327
 
328
#undef STAT
329
#undef CTRL
330
#undef IN
331
#undef OUT
332
 
333
#define CTRL(p,v) outb(*ctrl = (v), (p) - 577)
334
 
335
static char cumanascsi_read(struct Scsi_Host *instance, int reg)
336
{
337
  int iobase = instance->io_port;
338
  int i;
339
  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
340
 
341
  CTRL(iobase, 0);
342
  i = inb(iobase + 64 + reg);
343
  CTRL(iobase, 0x40);
344
 
345
  return i;
346
}
347
 
348
static void cumanascsi_write(struct Scsi_Host *instance, int reg, int value)
349
{
350
  int iobase = instance->io_port;
351
  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
352
 
353
  CTRL(iobase, 0);
354
  outb(value, iobase + 64 + reg);
355
  CTRL(iobase, 0x40);
356
}
357
 
358
#undef CTRL
359
 
360
#include "NCR5380.c"
361
 
362
#ifdef MODULE
363
 
364
Scsi_Host_Template driver_template = CUMANA_NCR5380;
365
 
366
#include "scsi_module.c"
367
#endif

powered by: WebSVN 2.1.0

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