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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [acorn/] [scsi/] [ecoscsi.c] - Blame information for rev 1779

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

Line No. Rev Author Line
1 1275 phoenix
#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.2  1998/03/08 05:49:47  davem
37
 * Merge to 2.1.89
38
 *
39
 * Revision 1.1  1998/02/23 02:45:24  davem
40
 * Merge to 2.1.88
41
 *
42
 */
43
 
44
#include <linux/module.h>
45
#include <linux/signal.h>
46
#include <linux/sched.h>
47
#include <linux/ioport.h>
48
#include <linux/init.h>
49
#include <linux/blk.h>
50
 
51
#include <asm/io.h>
52
#include <asm/system.h>
53
 
54
#include "../../scsi/scsi.h"
55
#include "../../scsi/hosts.h"
56
#include "../../scsi/NCR5380.h"
57
#include "../../scsi/constants.h"
58
 
59
#define ECOSCSI_PUBLIC_RELEASE 1
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_name = "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
    if (request_region (instance->io_port, instance->n_io_port, "ecoscsi") == NULL) {
129
        scsi_unregister(instance);
130
        return 0;
131
    }
132
 
133
    if (instance->irq != IRQ_NONE)
134
        if (request_irq(instance->irq, do_ecoscsi_intr, SA_INTERRUPT, "ecoscsi", NULL)) {
135
            printk("scsi%d: IRQ%d not free, interrupts disabled\n",
136
            instance->host_no, instance->irq);
137
            instance->irq = IRQ_NONE;
138
        }
139
 
140
    if (instance->irq != IRQ_NONE) {
141
        printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no);
142
        printk("scsi%d: that the board had an interrupt!\n", instance->host_no);
143
    }
144
 
145
    printk("scsi%d: at port %X irq", instance->host_no, instance->io_port);
146
    if (instance->irq == IRQ_NONE)
147
        printk ("s disabled");
148
    else
149
        printk (" %d", instance->irq);
150
    printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
151
        CAN_QUEUE, CMD_PER_LUN, ECOSCSI_PUBLIC_RELEASE);
152
    printk("\nscsi%d:", instance->host_no);
153
    NCR5380_print_options(instance);
154
    printk("\n");
155
    return 1;
156
}
157
 
158
int ecoscsi_release (struct Scsi_Host *shpnt)
159
{
160
        if (shpnt->irq != IRQ_NONE)
161
                free_irq (shpnt->irq, NULL);
162
        if (shpnt->io_port)
163
                release_region (shpnt->io_port, shpnt->n_io_port);
164
        return 0;
165
}
166
 
167
const char * ecoscsi_info (struct Scsi_Host *spnt) {
168
    return "";
169
}
170
 
171
#if 0
172
#define STAT(p) inw(p + 144)
173
 
174
static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr,
175
              int len)
176
{
177
  int iobase = instance->io_port;
178
printk("writing %p len %d\n",addr, len);
179
  if(!len) return -1;
180
 
181
  while(1)
182
  {
183
    int status;
184
    while(((status = STAT(iobase)) & 0x100)==0);
185
  }
186
}
187
 
188
static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr,
189
              int len)
190
{
191
  int iobase = instance->io_port;
192
  int iobase2= instance->io_port + 0x100;
193
  unsigned char *start = addr;
194
  int s;
195
printk("reading %p len %d\n",addr, len);
196
  outb(inb(iobase + 128), iobase + 135);
197
  while(len > 0)
198
  {
199
    int status,b,i, timeout;
200
    timeout = 0x07FFFFFF;
201
    while(((status = STAT(iobase)) & 0x100)==0)
202
    {
203
      timeout--;
204
      if(status & 0x200 || !timeout)
205
      {
206
        printk("status = %p\n",status);
207
        outb(0, iobase + 135);
208
        return 1;
209
      }
210
    }
211
    if(len >= 128)
212
    {
213
      for(i=0; i<64; i++)
214
      {
215
        b = inw(iobase + 136);
216
        *addr++ = b;
217
        *addr++ = b>>8;
218
      }
219
      len -= 128;
220
    }
221
    else
222
    {
223
      b = inw(iobase + 136);
224
      *addr ++ = b;
225
      len -= 1;
226
      if(len)
227
        *addr ++ = b>>8;
228
      len -= 1;
229
    }
230
  }
231
  outb(0, iobase + 135);
232
  printk("first bytes = %02X %02X %02X %20X %02X %02X %02X\n",*start, start[1], start[2], start[3], start[4], start[5], start[6]);
233
  return 1;
234
}
235
#endif
236
#undef STAT
237
 
238
#define NCR5380_implementation_fields \
239
    int port, ctrl
240
 
241
#define NCR5380_local_declare() \
242
        struct Scsi_Host *_instance
243
 
244
#define NCR5380_setup(instance) \
245
        _instance = instance
246
 
247
#define NCR5380_read(reg) ecoscsi_read(_instance, reg)
248
#define NCR5380_write(reg, value) ecoscsi_write(_instance, reg, value)
249
 
250
#define do_NCR5380_intr do_ecoscsi_intr
251
#define NCR5380_queue_command ecoscsi_queue_command
252
#define NCR5380_abort ecoscsi_abort
253
#define NCR5380_reset ecoscsi_reset
254
#define NCR5380_proc_info ecoscsi_proc_info
255
 
256
int NCR5380_proc_info(char *buffer, char **start, off_t offset,
257
                      int length, int hostno, int inout);
258
 
259
#define BOARD_NORMAL    0
260
#define BOARD_NCR53C400 1
261
 
262
#include "../../scsi/NCR5380.c"
263
 
264
static Scsi_Host_Template ecoscsi_template =  {
265
        module:         THIS_MODULE,
266
        name:           "Serial Port EcoSCSI NCR5380",
267
        detect:         ecoscsi_detect,
268
        release:        ecoscsi_release,
269
        info:           ecoscsi_info,
270
        queuecommand:   ecoscsi_queue_command,
271
        abort:          ecoscsi_abort,
272
        reset:          ecoscsi_reset,
273
        can_queue:      16,
274
        this_id:        7,
275
        sg_tablesize:   SG_ALL,
276
        cmd_per_lun:    2,
277
        use_clustering: DISABLE_CLUSTERING
278
};
279
 
280
static int __init ecoscsi_init(void)
281
{
282
        scsi_register_module(MODULE_SCSI_HA, &ecoscsi_template);
283
        if (ecoscsi_template.present)
284
                return 0;
285
 
286
        scsi_unregister_module(MODULE_SCSI_HA, &ecoscsi_template);
287
        return -ENODEV;
288
}
289
 
290
static void __exit ecoscsi_exit(void)
291
{
292
        scsi_unregister_module(MODULE_SCSI_HA, &ecoscsi_template);
293
}
294
 
295
module_init(ecoscsi_init);
296
module_exit(ecoscsi_exit);
297
 
298
MODULE_AUTHOR("Russell King");
299
MODULE_DESCRIPTION("Econet-SCSI driver for Acorn machines");
300
MODULE_LICENSE("GPL");
301
EXPORT_NO_SYMBOLS;

powered by: WebSVN 2.1.0

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