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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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