diff options
Diffstat (limited to 'drivers/scsi/arm/ecoscsi.c')
-rw-r--r-- | drivers/scsi/arm/ecoscsi.c | 152 |
1 files changed, 41 insertions, 111 deletions
diff --git a/drivers/scsi/arm/ecoscsi.c b/drivers/scsi/arm/ecoscsi.c index 378e7af0c5d6..5265a9884338 100644 --- a/drivers/scsi/arm/ecoscsi.c +++ b/drivers/scsi/arm/ecoscsi.c | |||
@@ -34,35 +34,25 @@ | |||
34 | #include "../scsi.h" | 34 | #include "../scsi.h" |
35 | #include <scsi/scsi_host.h> | 35 | #include <scsi/scsi_host.h> |
36 | 36 | ||
37 | #define NCR5380_implementation_fields int port, ctrl | 37 | #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) |
38 | #define NCR5380_local_declare() struct Scsi_Host *_instance | ||
39 | #define NCR5380_setup(instance) _instance = instance | ||
40 | 38 | ||
41 | #define NCR5380_read(reg) ecoscsi_read(_instance, reg) | 39 | #define NCR5380_local_declare() void __iomem *_base |
42 | #define NCR5380_write(reg, value) ecoscsi_write(_instance, reg, value) | 40 | #define NCR5380_setup(host) _base = priv(host)->base |
41 | |||
42 | #define NCR5380_read(reg) ({ writeb(reg | 8, _base); readb(_base + 4); }) | ||
43 | #define NCR5380_write(reg, value) ({ writeb(reg | 8, _base); writeb(value, _base + 4); }) | ||
43 | 44 | ||
44 | #define NCR5380_intr ecoscsi_intr | 45 | #define NCR5380_intr ecoscsi_intr |
45 | #define NCR5380_queue_command ecoscsi_queue_command | 46 | #define NCR5380_queue_command ecoscsi_queue_command |
46 | #define NCR5380_proc_info ecoscsi_proc_info | 47 | #define NCR5380_proc_info ecoscsi_proc_info |
47 | 48 | ||
49 | #define NCR5380_implementation_fields \ | ||
50 | void __iomem *base | ||
51 | |||
48 | #include "../NCR5380.h" | 52 | #include "../NCR5380.h" |
49 | 53 | ||
50 | #define ECOSCSI_PUBLIC_RELEASE 1 | 54 | #define ECOSCSI_PUBLIC_RELEASE 1 |
51 | 55 | ||
52 | static char ecoscsi_read(struct Scsi_Host *instance, int reg) | ||
53 | { | ||
54 | int iobase = instance->io_port; | ||
55 | outb(reg | 8, iobase); | ||
56 | return inb(iobase + 1); | ||
57 | } | ||
58 | |||
59 | static void ecoscsi_write(struct Scsi_Host *instance, int reg, int value) | ||
60 | { | ||
61 | int iobase = instance->io_port; | ||
62 | outb(reg | 8, iobase); | ||
63 | outb(value, iobase + 1); | ||
64 | } | ||
65 | |||
66 | /* | 56 | /* |
67 | * Function : ecoscsi_setup(char *str, int *ints) | 57 | * Function : ecoscsi_setup(char *str, int *ints) |
68 | * | 58 | * |
@@ -82,73 +72,6 @@ const char * ecoscsi_info (struct Scsi_Host *spnt) | |||
82 | return ""; | 72 | return ""; |
83 | } | 73 | } |
84 | 74 | ||
85 | #if 0 | ||
86 | #define STAT(p) inw(p + 144) | ||
87 | |||
88 | static inline int NCR5380_pwrite(struct Scsi_Host *host, unsigned char *addr, | ||
89 | int len) | ||
90 | { | ||
91 | int iobase = host->io_port; | ||
92 | printk("writing %p len %d\n",addr, len); | ||
93 | if(!len) return -1; | ||
94 | |||
95 | while(1) | ||
96 | { | ||
97 | int status; | ||
98 | while(((status = STAT(iobase)) & 0x100)==0); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | static inline int NCR5380_pread(struct Scsi_Host *host, unsigned char *addr, | ||
103 | int len) | ||
104 | { | ||
105 | int iobase = host->io_port; | ||
106 | int iobase2= host->io_port + 0x100; | ||
107 | unsigned char *start = addr; | ||
108 | int s; | ||
109 | printk("reading %p len %d\n",addr, len); | ||
110 | outb(inb(iobase + 128), iobase + 135); | ||
111 | while(len > 0) | ||
112 | { | ||
113 | int status,b,i, timeout; | ||
114 | timeout = 0x07FFFFFF; | ||
115 | while(((status = STAT(iobase)) & 0x100)==0) | ||
116 | { | ||
117 | timeout--; | ||
118 | if(status & 0x200 || !timeout) | ||
119 | { | ||
120 | printk("status = %p\n",status); | ||
121 | outb(0, iobase + 135); | ||
122 | return 1; | ||
123 | } | ||
124 | } | ||
125 | if(len >= 128) | ||
126 | { | ||
127 | for(i=0; i<64; i++) | ||
128 | { | ||
129 | b = inw(iobase + 136); | ||
130 | *addr++ = b; | ||
131 | *addr++ = b>>8; | ||
132 | } | ||
133 | len -= 128; | ||
134 | } | ||
135 | else | ||
136 | { | ||
137 | b = inw(iobase + 136); | ||
138 | *addr ++ = b; | ||
139 | len -= 1; | ||
140 | if(len) | ||
141 | *addr ++ = b>>8; | ||
142 | len -= 1; | ||
143 | } | ||
144 | } | ||
145 | outb(0, iobase + 135); | ||
146 | printk("first bytes = %02X %02X %02X %20X %02X %02X %02X\n",*start, start[1], start[2], start[3], start[4], start[5], start[6]); | ||
147 | return 1; | ||
148 | } | ||
149 | #endif | ||
150 | #undef STAT | ||
151 | |||
152 | #define BOARD_NORMAL 0 | 75 | #define BOARD_NORMAL 0 |
153 | #define BOARD_NCR53C400 1 | 76 | #define BOARD_NCR53C400 1 |
154 | 77 | ||
@@ -173,25 +96,36 @@ static struct Scsi_Host *host; | |||
173 | 96 | ||
174 | static int __init ecoscsi_init(void) | 97 | static int __init ecoscsi_init(void) |
175 | { | 98 | { |
99 | void __iomem *_base; | ||
100 | int ret; | ||
176 | 101 | ||
177 | host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata)); | 102 | if (!request_mem_region(0x33a0000, 4096, "ecoscsi")) { |
178 | if (!host) | 103 | ret = -EBUSY; |
179 | return 0; | 104 | goto out; |
105 | } | ||
180 | 106 | ||
181 | host->io_port = 0x80ce8000; | 107 | _base = ioremap(0x33a0000, 4096); |
182 | host->n_io_port = 144; | 108 | if (!_base) { |
183 | host->irq = IRQ_NONE; | 109 | ret = -ENOMEM; |
110 | goto out_release; | ||
111 | } | ||
184 | 112 | ||
185 | if (!(request_region(host->io_port, host->n_io_port, "ecoscsi")) ) | 113 | NCR5380_write(MODE_REG, 0x20); /* Is it really SCSI? */ |
186 | goto unregister_scsi; | 114 | if (NCR5380_read(MODE_REG) != 0x20) /* Write to a reg. */ |
115 | goto out_unmap; | ||
187 | 116 | ||
188 | ecoscsi_write(host, MODE_REG, 0x20); /* Is it really SCSI? */ | 117 | NCR5380_write(MODE_REG, 0x00); /* it back. */ |
189 | if (ecoscsi_read(host, MODE_REG) != 0x20) /* Write to a reg. */ | 118 | if (NCR5380_read(MODE_REG) != 0x00) |
190 | goto release_reg; | 119 | goto out_unmap; |
191 | 120 | ||
192 | ecoscsi_write(host, MODE_REG, 0x00 ); /* it back. */ | 121 | host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata)); |
193 | if (ecoscsi_read(host, MODE_REG) != 0x00) | 122 | if (!host) { |
194 | goto release_reg; | 123 | ret = -ENOMEM; |
124 | goto out_unmap; | ||
125 | } | ||
126 | |||
127 | priv(host)->base = _base; | ||
128 | host->irq = IRQ_NONE; | ||
195 | 129 | ||
196 | NCR5380_init(host, 0); | 130 | NCR5380_init(host, 0); |
197 | 131 | ||
@@ -206,24 +140,20 @@ static int __init ecoscsi_init(void) | |||
206 | scsi_scan_host(host); | 140 | scsi_scan_host(host); |
207 | return 0; | 141 | return 0; |
208 | 142 | ||
209 | release_reg: | 143 | out_unmap: |
210 | release_region(host->io_port, host->n_io_port); | 144 | iounmap(_base); |
211 | unregister_scsi: | 145 | out_release: |
212 | scsi_host_put(host); | 146 | release_mem_region(0x33a0000, 4096); |
213 | return -ENODEV; | 147 | out: |
148 | return ret; | ||
214 | } | 149 | } |
215 | 150 | ||
216 | static void __exit ecoscsi_exit(void) | 151 | static void __exit ecoscsi_exit(void) |
217 | { | 152 | { |
218 | scsi_remove_host(host); | 153 | scsi_remove_host(host); |
219 | |||
220 | if (shpnt->irq != IRQ_NONE) | ||
221 | free_irq(shpnt->irq, NULL); | ||
222 | NCR5380_exit(host); | 154 | NCR5380_exit(host); |
223 | if (shpnt->io_port) | ||
224 | release_region(shpnt->io_port, shpnt->n_io_port); | ||
225 | |||
226 | scsi_host_put(host); | 155 | scsi_host_put(host); |
156 | release_mem_region(0x33a0000, 4096); | ||
227 | return 0; | 157 | return 0; |
228 | } | 158 | } |
229 | 159 | ||