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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#define AUTOSENSE
2
/*#define PSEUDO_DMA*/
3
 
4
/*
5
 * Oak 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 "oak.h"
54
#include "NCR5380.h"
55
#include "constants.h"
56
 
57
#undef START_DMA_INITIATOR_RECEIVE_REG
58
#define START_DMA_INITIATOR_RECEIVE_REG (7 + 128)
59
 
60
#include <asm/ecard.h>
61
 
62
static const card_ids oakscsi_cids[] = {
63
        { MANU_OAK, PROD_OAK_SCSI },
64
        { 0xffff, 0xffff }
65
};
66
 
67
static struct proc_dir_entry proc_scsi_oakscsi = {
68
        PROC_SCSI_PAS16, 7, "oakscsi", S_IFDIR | S_IRUGO | S_IXUGO, 2
69
};
70
 
71
#define OAK_ADDRESS(card) (ecard_address((card), ECARD_MEMC, 0))
72
#define OAK_IRQ(card)     (IRQ_NONE)
73
/*
74
 * Function : int oakscsi_detect(Scsi_Host_Template * tpnt)
75
 *
76
 * Purpose : initializes oak NCR5380 driver based on the
77
 *      command line / compile time port and irq definitions.
78
 *
79
 * Inputs : tpnt - template for this SCSI adapter.
80
 *
81
 * Returns : 1 if a host adapter was found, 0 if not.
82
 *
83
 */
84
static struct expansion_card *ecs[4];
85
 
86
int oakscsi_detect(Scsi_Host_Template * tpnt)
87
{
88
    int count = 0;
89
    struct Scsi_Host *instance;
90
 
91
    tpnt->proc_dir = &proc_scsi_oakscsi;
92
 
93
    memset (ecs, 0, sizeof (ecs));
94
 
95
    ecard_startfind ();
96
 
97
    while(1) {
98
        if ((ecs[count] = ecard_find(0, oakscsi_cids)) == NULL)
99
            break;
100
 
101
        instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
102
        instance->io_port = OAK_ADDRESS(ecs[count]);
103
        instance->irq = OAK_IRQ(ecs[count]);
104
 
105
        NCR5380_init(instance, 0);
106
        ecard_claim(ecs[count]);
107
 
108
        instance->n_io_port = 255;
109
        request_region (instance->io_port, instance->n_io_port, "Oak SCSI");
110
 
111
        if (instance->irq != IRQ_NONE)
112
            if (request_irq(instance->irq, oakscsi_intr, SA_INTERRUPT, "Oak SCSI", NULL)) {
113
                printk("scsi%d: IRQ%d not free, interrupts disabled\n",
114
                    instance->host_no, instance->irq);
115
                instance->irq = IRQ_NONE;
116
            }
117
 
118
        if (instance->irq != IRQ_NONE) {
119
            printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no);
120
            printk("scsi%d: that the board had an interrupt!\n", instance->host_no);
121
        }
122
 
123
        printk("scsi%d: at port %X irq", instance->host_no, instance->io_port);
124
        if (instance->irq == IRQ_NONE)
125
            printk ("s disabled");
126
        else
127
            printk (" %d", instance->irq);
128
        printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d",
129
            CAN_QUEUE, CMD_PER_LUN, OAKSCSI_PUBLIC_RELEASE);
130
        printk("\nscsi%d:", instance->host_no);
131
        NCR5380_print_options(instance);
132
        printk("\n");
133
 
134
        ++count;
135
    }
136
#ifdef MODULE
137
    if(count == 0)
138
        printk("No oak scsi devices found\n");
139
#endif
140
    return count;
141
}
142
 
143
int oakscsi_release (struct Scsi_Host *shpnt)
144
{
145
        int i;
146
 
147
        if (shpnt->irq != IRQ_NONE)
148
                free_irq (shpnt->irq, NULL);
149
        if (shpnt->io_port)
150
                release_region (shpnt->io_port, shpnt->n_io_port);
151
 
152
        for (i = 0; i < 4; i++)
153
                if (shpnt->io_port == OAK_ADDRESS(ecs[i]))
154
                        ecard_release (ecs[i]);
155
        return 0;
156
}
157
 
158
const char * oakscsi_info (struct Scsi_Host *spnt) {
159
    return "";
160
}
161
 
162
#define STAT(p)   inw(p + 144)
163
extern void inswb(int from, void *to, int len);
164
 
165
static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr,
166
              int len)
167
{
168
  int iobase = instance->io_port;
169
printk("writing %p len %d\n",addr, len);
170
  if(!len) return -1;
171
 
172
  while(1)
173
  {
174
    int status;
175
    while(((status = STAT(iobase)) & 0x100)==0);
176
  }
177
}
178
 
179
static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr,
180
              int len)
181
{
182
  int iobase = instance->io_port;
183
printk("reading %p len %d\n", addr, len);
184
  while(len > 0)
185
  {
186
    int status, timeout;
187
    unsigned long b;
188
 
189
    timeout = 0x01FFFFFF;
190
 
191
    while(((status = STAT(iobase)) & 0x100)==0)
192
    {
193
      timeout--;
194
      if(status & 0x200 || !timeout)
195
      {
196
        printk("status = %08X\n",status);
197
        return 1;
198
      }
199
    }
200
    if(len >= 128)
201
    {
202
      inswb(iobase + 136, addr, 128);
203
      addr += 128;
204
      len -= 128;
205
    }
206
    else
207
    {
208
      b = (unsigned long) inw(iobase + 136);
209
      *addr ++ = b;
210
      len -= 1;
211
      if(len)
212
        *addr ++ = b>>8;
213
      len -= 1;
214
    }
215
  }
216
  return 0;
217
}
218
 
219
#define oakscsi_read(instance,reg)      (inb((instance)->io_port + (reg)))
220
#define oakscsi_write(instance,reg,val) (outb((val), (instance)->io_port + (reg)))
221
 
222
#undef STAT
223
 
224
#include "NCR5380.c"
225
 
226
#ifdef MODULE
227
 
228
Scsi_Host_Template driver_template = OAK_NCR5380;
229
 
230
#include "scsi_module.c"
231
#endif

powered by: WebSVN 2.1.0

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