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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [armnommu/] [drivers/] [scsi/] [ecoscsi.c] - Blame information for rev 199

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

Line No. Rev Author Line
1 199 simons
#define AUTOSENSE
2
/* #define PSEUDO_DMA */
3
 
4
/*
5
 * EcoSCSI 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
 * Options :
26
 *
27
 * PARITY - enable parity checking.  Not supported.
28
 *
29
 * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
30
 *
31
 * USLEEP - enable support for devices that don't disconnect.  Untested.
32
 */
33
 
34
/*
35
 * $Log: not supported by cvs2svn $
36
 * Revision 1.1.1.1  2001/07/02 17:58:40  simons
37
 * Initial revision
38
 *
39
 * Revision 1.1.1.1  1999/11/15 13:42:32  vadim
40
 * Initial import
41
 *
42
 */
43
 
44
#include <linux/module.h>
45
#include <asm/system.h>
46
#include <asm/io.h>
47
#include <linux/signal.h>
48
#include <linux/sched.h>
49
#include <linux/ioport.h>
50
#include "../block/blk.h"
51
#include "scsi.h"
52
#include "hosts.h"
53
#include "ecoscsi.h"
54
#include "NCR5380.h"
55
#include "constants.h"
56
 
57
static struct proc_dir_entry proc_scsi_ecoscsi = {
58
        PROC_SCSI_GENERIC_NCR5380, 7, "ecoscsi", S_IFDIR | S_IRUGO | S_IXUGO, 2
59
};
60
 
61
static char ecoscsi_read(struct Scsi_Host *instance, int reg)
62
{
63
  int iobase = instance->io_port;
64
  outb(reg | 8, iobase);
65
  return inb(iobase + 1);
66
}
67
 
68
static void ecoscsi_write(struct Scsi_Host *instance, int reg, int value)
69
{
70
  int iobase = instance->io_port;
71
  outb(reg | 8, iobase);
72
  outb(value, iobase + 1);
73
}
74
 
75
/*
76
 * Function : ecoscsi_setup(char *str, int *ints)
77
 *
78
 * Purpose : LILO command line initialization of the overrides array,
79
 *
80
 * Inputs : str - unused, ints - array of integer parameters with ints[0]
81
 *      equal to the number of ints.
82
 *
83
 */
84
 
85
void ecoscsi_setup(char *str, int *ints) {
86
}
87
 
88
/*
89
 * Function : int ecoscsi_detect(Scsi_Host_Template * tpnt)
90
 *
91
 * Purpose : initializes ecoscsi NCR5380 driver based on the
92
 *      command line / compile time port and irq definitions.
93
 *
94
 * Inputs : tpnt - template for this SCSI adapter.
95
 *
96
 * Returns : 1 if a host adapter was found, 0 if not.
97
 *
98
 */
99
 
100
int ecoscsi_detect(Scsi_Host_Template * tpnt)
101
{
102
    struct Scsi_Host *instance;
103
 
104
    tpnt->proc_dir = &proc_scsi_ecoscsi;
105
 
106
    instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
107
    instance->io_port = 0x80ce8000;
108
    instance->n_io_port = 144;
109
    instance->irq = IRQ_NONE;
110
 
111
    if (check_region (instance->io_port, instance->n_io_port)) {
112
        scsi_unregister (instance);
113
        return 0;
114
    }
115
 
116
    ecoscsi_write (instance, MODE_REG, 0x20);           /* Is it really SCSI? */
117
    if (ecoscsi_read (instance, MODE_REG) != 0x20) {    /* Write to a reg.    */
118
        scsi_unregister(instance);
119
        return 0;                                        /* and try to read    */
120
    }
121
    ecoscsi_write( instance, MODE_REG, 0x00 );          /* it back.           */
122
    if (ecoscsi_read (instance, MODE_REG) != 0x00) {
123
        scsi_unregister(instance);
124
        return 0;
125
    }
126
 
127
    NCR5380_init(instance, 0);
128
    request_region (instance->io_port, instance->n_io_port, "ecoscsi");
129
 
130
    if (instance->irq != IRQ_NONE)
131
        if (request_irq(instance->irq, ecoscsi_intr, SA_INTERRUPT, "ecoscsi", NULL)) {
132
            printk("scsi%d: IRQ%d not free, interrupts disabled\n",
133
            instance->host_no, instance->irq);
134
            instance->irq = IRQ_NONE;
135
        }
136
 
137
    if (instance->irq != IRQ_NONE) {
138
        printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no);
139
        printk("scsi%d: that the board had an interrupt!\n", instance->host_no);
140
    }
141
 
142
    printk("scsi%d: at port %X irq", instance->host_no, instance->io_port);
143
    if (instance->irq == IRQ_NONE)
144
        printk ("s disabled");
145
    else
146
        printk (" %d", instance->irq);
147
    printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
148
        CAN_QUEUE, CMD_PER_LUN, ECOSCSI_PUBLIC_RELEASE);
149
    printk("\nscsi%d:", instance->host_no);
150
    NCR5380_print_options(instance);
151
    printk("\n");
152
    return 1;
153
}
154
 
155
int ecoscsi_release (struct Scsi_Host *shpnt)
156
{
157
        if (shpnt->irq != IRQ_NONE)
158
                free_irq (shpnt->irq, NULL);
159
        if (shpnt->io_port)
160
                release_region (shpnt->io_port, shpnt->n_io_port);
161
        return 0;
162
}
163
 
164
const char * ecoscsi_info (struct Scsi_Host *spnt) {
165
    return "";
166
}
167
 
168
#if 0
169
#define STAT(p) inw(p + 144)
170
 
171
static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr,
172
              int len)
173
{
174
  int iobase = instance->io_port;
175
printk("writing %p len %d\n",addr, len);
176
  if(!len) return -1;
177
 
178
  while(1)
179
  {
180
    int status;
181
    while(((status = STAT(iobase)) & 0x100)==0);
182
  }
183
}
184
 
185
static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr,
186
              int len)
187
{
188
  int iobase = instance->io_port;
189
  int iobase2= instance->io_port + 0x100;
190
  unsigned char *start = addr;
191
  int s;
192
printk("reading %p len %d\n",addr, len);
193
  outb(inb(iobase + 128), iobase + 135);
194
  while(len > 0)
195
  {
196
    int status,b,i, timeout;
197
    timeout = 0x07FFFFFF;
198
    while(((status = STAT(iobase)) & 0x100)==0)
199
    {
200
      timeout--;
201
      if(status & 0x200 || !timeout)
202
      {
203
        printk("status = %p\n",status);
204
        outb(0, iobase + 135);
205
        return 1;
206
      }
207
    }
208
    if(len >= 128)
209
    {
210
      for(i=0; i<64; i++)
211
      {
212
        b = inw(iobase + 136);
213
        *addr++ = b;
214
        *addr++ = b>>8;
215
      }
216
      len -= 128;
217
    }
218
    else
219
    {
220
      b = inw(iobase + 136);
221
      *addr ++ = b;
222
      len -= 1;
223
      if(len)
224
        *addr ++ = b>>8;
225
      len -= 1;
226
    }
227
  }
228
  outb(0, iobase + 135);
229
  printk("first bytes = %02X %02X %02X %20X %02X %02X %02X\n",*start, start[1], start[2], start[3], start[4], start[5], start[6]);
230
  return 1;
231
}
232
#endif
233
#undef STAT
234
 
235
#include "NCR5380.c"
236
 
237
#ifdef MODULE
238
 
239
Scsi_Host_Template driver_template = ECOSCSI_NCR5380;
240
 
241
#include "scsi_module.c"
242
#endif

powered by: WebSVN 2.1.0

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