diff options
author | James Bottomley <James.Bottomley@suse.de> | 2010-05-18 10:33:43 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-05-18 10:37:41 -0400 |
commit | 95bb335c0ebe96afe926387a1ef3a096bd884a82 (patch) | |
tree | 56115332b4f2f7ef300c36248a6a7d20db2e639d /drivers/scsi/gvp11.c | |
parent | 1b4d0d8ea7b3cbd107f345ab766416f9b38ce66a (diff) | |
parent | 9cccde93fed1ca988eb2fb17ab9194bf7b5ed1b0 (diff) |
[SCSI] Merge scsi-misc-2.6 into scsi-rc-fixes-2.6
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/gvp11.c')
-rw-r--r-- | drivers/scsi/gvp11.c | 565 |
1 files changed, 283 insertions, 282 deletions
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c index 48f406850c65..18b7102bb80e 100644 --- a/drivers/scsi/gvp11.c +++ b/drivers/scsi/gvp11.c | |||
@@ -19,332 +19,334 @@ | |||
19 | #include "wd33c93.h" | 19 | #include "wd33c93.h" |
20 | #include "gvp11.h" | 20 | #include "gvp11.h" |
21 | 21 | ||
22 | #include<linux/stat.h> | 22 | #include <linux/stat.h> |
23 | 23 | ||
24 | #define DMA(ptr) ((gvp11_scsiregs *)((ptr)->base)) | ||
25 | #define HDATA(ptr) ((struct WD33C93_hostdata *)((ptr)->hostdata)) | ||
26 | 24 | ||
27 | static irqreturn_t gvp11_intr (int irq, void *_instance) | 25 | #define DMA(ptr) ((gvp11_scsiregs *)((ptr)->base)) |
26 | |||
27 | static irqreturn_t gvp11_intr(int irq, void *_instance) | ||
28 | { | 28 | { |
29 | unsigned long flags; | 29 | unsigned long flags; |
30 | unsigned int status; | 30 | unsigned int status; |
31 | struct Scsi_Host *instance = (struct Scsi_Host *)_instance; | 31 | struct Scsi_Host *instance = (struct Scsi_Host *)_instance; |
32 | 32 | ||
33 | status = DMA(instance)->CNTR; | 33 | status = DMA(instance)->CNTR; |
34 | if (!(status & GVP11_DMAC_INT_PENDING)) | 34 | if (!(status & GVP11_DMAC_INT_PENDING)) |
35 | return IRQ_NONE; | 35 | return IRQ_NONE; |
36 | 36 | ||
37 | spin_lock_irqsave(instance->host_lock, flags); | 37 | spin_lock_irqsave(instance->host_lock, flags); |
38 | wd33c93_intr(instance); | 38 | wd33c93_intr(instance); |
39 | spin_unlock_irqrestore(instance->host_lock, flags); | 39 | spin_unlock_irqrestore(instance->host_lock, flags); |
40 | return IRQ_HANDLED; | 40 | return IRQ_HANDLED; |
41 | } | 41 | } |
42 | 42 | ||
43 | static int gvp11_xfer_mask = 0; | 43 | static int gvp11_xfer_mask = 0; |
44 | 44 | ||
45 | void gvp11_setup (char *str, int *ints) | 45 | void gvp11_setup(char *str, int *ints) |
46 | { | 46 | { |
47 | gvp11_xfer_mask = ints[1]; | 47 | gvp11_xfer_mask = ints[1]; |
48 | } | 48 | } |
49 | 49 | ||
50 | static int dma_setup(struct scsi_cmnd *cmd, int dir_in) | 50 | static int dma_setup(struct scsi_cmnd *cmd, int dir_in) |
51 | { | 51 | { |
52 | unsigned short cntr = GVP11_DMAC_INT_ENABLE; | 52 | struct Scsi_Host *instance = cmd->device->host; |
53 | unsigned long addr = virt_to_bus(cmd->SCp.ptr); | 53 | struct WD33C93_hostdata *hdata = shost_priv(instance); |
54 | int bank_mask; | 54 | unsigned short cntr = GVP11_DMAC_INT_ENABLE; |
55 | static int scsi_alloc_out_of_range = 0; | 55 | unsigned long addr = virt_to_bus(cmd->SCp.ptr); |
56 | 56 | int bank_mask; | |
57 | /* use bounce buffer if the physical address is bad */ | 57 | static int scsi_alloc_out_of_range = 0; |
58 | if (addr & HDATA(cmd->device->host)->dma_xfer_mask) | 58 | |
59 | { | 59 | /* use bounce buffer if the physical address is bad */ |
60 | HDATA(cmd->device->host)->dma_bounce_len = (cmd->SCp.this_residual + 511) | 60 | if (addr & hdata->dma_xfer_mask) { |
61 | & ~0x1ff; | 61 | hdata->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; |
62 | 62 | ||
63 | if( !scsi_alloc_out_of_range ) { | 63 | if (!scsi_alloc_out_of_range) { |
64 | HDATA(cmd->device->host)->dma_bounce_buffer = | 64 | hdata->dma_bounce_buffer = |
65 | kmalloc (HDATA(cmd->device->host)->dma_bounce_len, GFP_KERNEL); | 65 | kmalloc(hdata->dma_bounce_len, GFP_KERNEL); |
66 | HDATA(cmd->device->host)->dma_buffer_pool = BUF_SCSI_ALLOCED; | 66 | hdata->dma_buffer_pool = BUF_SCSI_ALLOCED; |
67 | } | 67 | } |
68 | 68 | ||
69 | if (scsi_alloc_out_of_range || | 69 | if (scsi_alloc_out_of_range || |
70 | !HDATA(cmd->device->host)->dma_bounce_buffer) { | 70 | !hdata->dma_bounce_buffer) { |
71 | HDATA(cmd->device->host)->dma_bounce_buffer = | 71 | hdata->dma_bounce_buffer = |
72 | amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len, | 72 | amiga_chip_alloc(hdata->dma_bounce_len, |
73 | "GVP II SCSI Bounce Buffer"); | 73 | "GVP II SCSI Bounce Buffer"); |
74 | 74 | ||
75 | if(!HDATA(cmd->device->host)->dma_bounce_buffer) | 75 | if (!hdata->dma_bounce_buffer) { |
76 | { | 76 | hdata->dma_bounce_len = 0; |
77 | HDATA(cmd->device->host)->dma_bounce_len = 0; | 77 | return 1; |
78 | return 1; | 78 | } |
79 | } | ||
80 | 79 | ||
81 | HDATA(cmd->device->host)->dma_buffer_pool = BUF_CHIP_ALLOCED; | 80 | hdata->dma_buffer_pool = BUF_CHIP_ALLOCED; |
82 | } | 81 | } |
83 | 82 | ||
84 | /* check if the address of the bounce buffer is OK */ | 83 | /* check if the address of the bounce buffer is OK */ |
85 | addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer); | 84 | addr = virt_to_bus(hdata->dma_bounce_buffer); |
86 | 85 | ||
87 | if (addr & HDATA(cmd->device->host)->dma_xfer_mask) { | 86 | if (addr & hdata->dma_xfer_mask) { |
88 | /* fall back to Chip RAM if address out of range */ | 87 | /* fall back to Chip RAM if address out of range */ |
89 | if( HDATA(cmd->device->host)->dma_buffer_pool == BUF_SCSI_ALLOCED) { | 88 | if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED) { |
90 | kfree (HDATA(cmd->device->host)->dma_bounce_buffer); | 89 | kfree(hdata->dma_bounce_buffer); |
91 | scsi_alloc_out_of_range = 1; | 90 | scsi_alloc_out_of_range = 1; |
92 | } else { | 91 | } else { |
93 | amiga_chip_free (HDATA(cmd->device->host)->dma_bounce_buffer); | 92 | amiga_chip_free(hdata->dma_bounce_buffer); |
94 | } | 93 | } |
95 | 94 | ||
96 | HDATA(cmd->device->host)->dma_bounce_buffer = | 95 | hdata->dma_bounce_buffer = |
97 | amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len, | 96 | amiga_chip_alloc(hdata->dma_bounce_len, |
98 | "GVP II SCSI Bounce Buffer"); | 97 | "GVP II SCSI Bounce Buffer"); |
99 | 98 | ||
100 | if(!HDATA(cmd->device->host)->dma_bounce_buffer) | 99 | if (!hdata->dma_bounce_buffer) { |
101 | { | 100 | hdata->dma_bounce_len = 0; |
102 | HDATA(cmd->device->host)->dma_bounce_len = 0; | 101 | return 1; |
103 | return 1; | 102 | } |
104 | } | 103 | |
105 | 104 | addr = virt_to_bus(hdata->dma_bounce_buffer); | |
106 | addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer); | 105 | hdata->dma_buffer_pool = BUF_CHIP_ALLOCED; |
107 | HDATA(cmd->device->host)->dma_buffer_pool = BUF_CHIP_ALLOCED; | 106 | } |
108 | } | 107 | |
109 | 108 | if (!dir_in) { | |
110 | if (!dir_in) { | 109 | /* copy to bounce buffer for a write */ |
111 | /* copy to bounce buffer for a write */ | 110 | memcpy(hdata->dma_bounce_buffer, cmd->SCp.ptr, |
112 | memcpy (HDATA(cmd->device->host)->dma_bounce_buffer, | 111 | cmd->SCp.this_residual); |
113 | cmd->SCp.ptr, cmd->SCp.this_residual); | 112 | } |
114 | } | 113 | } |
115 | } | ||
116 | 114 | ||
117 | /* setup dma direction */ | 115 | /* setup dma direction */ |
118 | if (!dir_in) | 116 | if (!dir_in) |
119 | cntr |= GVP11_DMAC_DIR_WRITE; | 117 | cntr |= GVP11_DMAC_DIR_WRITE; |
120 | 118 | ||
121 | HDATA(cmd->device->host)->dma_dir = dir_in; | 119 | hdata->dma_dir = dir_in; |
122 | DMA(cmd->device->host)->CNTR = cntr; | 120 | DMA(cmd->device->host)->CNTR = cntr; |
123 | 121 | ||
124 | /* setup DMA *physical* address */ | 122 | /* setup DMA *physical* address */ |
125 | DMA(cmd->device->host)->ACR = addr; | 123 | DMA(cmd->device->host)->ACR = addr; |
126 | 124 | ||
127 | if (dir_in) | 125 | if (dir_in) { |
128 | /* invalidate any cache */ | 126 | /* invalidate any cache */ |
129 | cache_clear (addr, cmd->SCp.this_residual); | 127 | cache_clear(addr, cmd->SCp.this_residual); |
130 | else | 128 | } else { |
131 | /* push any dirty cache */ | 129 | /* push any dirty cache */ |
132 | cache_push (addr, cmd->SCp.this_residual); | 130 | cache_push(addr, cmd->SCp.this_residual); |
131 | } | ||
133 | 132 | ||
134 | if ((bank_mask = (~HDATA(cmd->device->host)->dma_xfer_mask >> 18) & 0x01c0)) | 133 | bank_mask = (~hdata->dma_xfer_mask >> 18) & 0x01c0; |
135 | DMA(cmd->device->host)->BANK = bank_mask & (addr >> 18); | 134 | if (bank_mask) |
135 | DMA(cmd->device->host)->BANK = bank_mask & (addr >> 18); | ||
136 | 136 | ||
137 | /* start DMA */ | 137 | /* start DMA */ |
138 | DMA(cmd->device->host)->ST_DMA = 1; | 138 | DMA(cmd->device->host)->ST_DMA = 1; |
139 | 139 | ||
140 | /* return success */ | 140 | /* return success */ |
141 | return 0; | 141 | return 0; |
142 | } | 142 | } |
143 | 143 | ||
144 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | 144 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, |
145 | int status) | 145 | int status) |
146 | { | 146 | { |
147 | /* stop DMA */ | 147 | struct WD33C93_hostdata *hdata = shost_priv(instance); |
148 | DMA(instance)->SP_DMA = 1; | 148 | |
149 | /* remove write bit from CONTROL bits */ | 149 | /* stop DMA */ |
150 | DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE; | 150 | DMA(instance)->SP_DMA = 1; |
151 | 151 | /* remove write bit from CONTROL bits */ | |
152 | /* copy from a bounce buffer, if necessary */ | 152 | DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE; |
153 | if (status && HDATA(instance)->dma_bounce_buffer) { | 153 | |
154 | if (HDATA(instance)->dma_dir && SCpnt) | 154 | /* copy from a bounce buffer, if necessary */ |
155 | memcpy (SCpnt->SCp.ptr, | 155 | if (status && hdata->dma_bounce_buffer) { |
156 | HDATA(instance)->dma_bounce_buffer, | 156 | if (hdata->dma_dir && SCpnt) |
157 | SCpnt->SCp.this_residual); | 157 | memcpy(SCpnt->SCp.ptr, hdata->dma_bounce_buffer, |
158 | 158 | SCpnt->SCp.this_residual); | |
159 | if (HDATA(instance)->dma_buffer_pool == BUF_SCSI_ALLOCED) | 159 | |
160 | kfree (HDATA(instance)->dma_bounce_buffer); | 160 | if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED) |
161 | else | 161 | kfree(hdata->dma_bounce_buffer); |
162 | amiga_chip_free(HDATA(instance)->dma_bounce_buffer); | 162 | else |
163 | 163 | amiga_chip_free(hdata->dma_bounce_buffer); | |
164 | HDATA(instance)->dma_bounce_buffer = NULL; | 164 | |
165 | HDATA(instance)->dma_bounce_len = 0; | 165 | hdata->dma_bounce_buffer = NULL; |
166 | } | 166 | hdata->dma_bounce_len = 0; |
167 | } | ||
167 | } | 168 | } |
168 | 169 | ||
169 | #define CHECK_WD33C93 | 170 | #define CHECK_WD33C93 |
170 | 171 | ||
171 | int __init gvp11_detect(struct scsi_host_template *tpnt) | 172 | int __init gvp11_detect(struct scsi_host_template *tpnt) |
172 | { | 173 | { |
173 | static unsigned char called = 0; | 174 | static unsigned char called = 0; |
174 | struct Scsi_Host *instance; | 175 | struct Scsi_Host *instance; |
175 | unsigned long address; | 176 | unsigned long address; |
176 | unsigned int epc; | 177 | unsigned int epc; |
177 | struct zorro_dev *z = NULL; | 178 | struct zorro_dev *z = NULL; |
178 | unsigned int default_dma_xfer_mask; | 179 | unsigned int default_dma_xfer_mask; |
179 | wd33c93_regs regs; | 180 | struct WD33C93_hostdata *hdata; |
180 | int num_gvp11 = 0; | 181 | wd33c93_regs regs; |
182 | int num_gvp11 = 0; | ||
181 | #ifdef CHECK_WD33C93 | 183 | #ifdef CHECK_WD33C93 |
182 | volatile unsigned char *sasr_3393, *scmd_3393; | 184 | volatile unsigned char *sasr_3393, *scmd_3393; |
183 | unsigned char save_sasr; | 185 | unsigned char save_sasr; |
184 | unsigned char q, qq; | 186 | unsigned char q, qq; |
185 | #endif | 187 | #endif |
186 | 188 | ||
187 | if (!MACH_IS_AMIGA || called) | 189 | if (!MACH_IS_AMIGA || called) |
188 | return 0; | 190 | return 0; |
189 | called = 1; | 191 | called = 1; |
190 | 192 | ||
191 | tpnt->proc_name = "GVP11"; | 193 | tpnt->proc_name = "GVP11"; |
192 | tpnt->proc_info = &wd33c93_proc_info; | 194 | tpnt->proc_info = &wd33c93_proc_info; |
193 | 195 | ||
194 | while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { | 196 | while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { |
195 | /* | 197 | /* |
196 | * This should (hopefully) be the correct way to identify | 198 | * This should (hopefully) be the correct way to identify |
197 | * all the different GVP SCSI controllers (except for the | 199 | * all the different GVP SCSI controllers (except for the |
198 | * SERIES I though). | 200 | * SERIES I though). |
199 | */ | 201 | */ |
200 | 202 | ||
201 | if (z->id == ZORRO_PROD_GVP_COMBO_030_R3_SCSI || | 203 | if (z->id == ZORRO_PROD_GVP_COMBO_030_R3_SCSI || |
202 | z->id == ZORRO_PROD_GVP_SERIES_II) | 204 | z->id == ZORRO_PROD_GVP_SERIES_II) |
203 | default_dma_xfer_mask = ~0x00ffffff; | 205 | default_dma_xfer_mask = ~0x00ffffff; |
204 | else if (z->id == ZORRO_PROD_GVP_GFORCE_030_SCSI || | 206 | else if (z->id == ZORRO_PROD_GVP_GFORCE_030_SCSI || |
205 | z->id == ZORRO_PROD_GVP_A530_SCSI || | 207 | z->id == ZORRO_PROD_GVP_A530_SCSI || |
206 | z->id == ZORRO_PROD_GVP_COMBO_030_R4_SCSI) | 208 | z->id == ZORRO_PROD_GVP_COMBO_030_R4_SCSI) |
207 | default_dma_xfer_mask = ~0x01ffffff; | 209 | default_dma_xfer_mask = ~0x01ffffff; |
208 | else if (z->id == ZORRO_PROD_GVP_A1291 || | 210 | else if (z->id == ZORRO_PROD_GVP_A1291 || |
209 | z->id == ZORRO_PROD_GVP_GFORCE_040_SCSI_1) | 211 | z->id == ZORRO_PROD_GVP_GFORCE_040_SCSI_1) |
210 | default_dma_xfer_mask = ~0x07ffffff; | 212 | default_dma_xfer_mask = ~0x07ffffff; |
211 | else | 213 | else |
212 | continue; | 214 | continue; |
213 | 215 | ||
214 | /* | 216 | /* |
215 | * Rumors state that some GVP ram boards use the same product | 217 | * Rumors state that some GVP ram boards use the same product |
216 | * code as the SCSI controllers. Therefore if the board-size | 218 | * code as the SCSI controllers. Therefore if the board-size |
217 | * is not 64KB we asume it is a ram board and bail out. | 219 | * is not 64KB we asume it is a ram board and bail out. |
218 | */ | 220 | */ |
219 | if (z->resource.end-z->resource.start != 0xffff) | 221 | if (z->resource.end - z->resource.start != 0xffff) |
220 | continue; | 222 | continue; |
221 | 223 | ||
222 | address = z->resource.start; | 224 | address = z->resource.start; |
223 | if (!request_mem_region(address, 256, "wd33c93")) | 225 | if (!request_mem_region(address, 256, "wd33c93")) |
224 | continue; | 226 | continue; |
225 | 227 | ||
226 | #ifdef CHECK_WD33C93 | 228 | #ifdef CHECK_WD33C93 |
227 | 229 | ||
228 | /* | 230 | /* |
229 | * These darn GVP boards are a problem - it can be tough to tell | 231 | * These darn GVP boards are a problem - it can be tough to tell |
230 | * whether or not they include a SCSI controller. This is the | 232 | * whether or not they include a SCSI controller. This is the |
231 | * ultimate Yet-Another-GVP-Detection-Hack in that it actually | 233 | * ultimate Yet-Another-GVP-Detection-Hack in that it actually |
232 | * probes for a WD33c93 chip: If we find one, it's extremely | 234 | * probes for a WD33c93 chip: If we find one, it's extremely |
233 | * likely that this card supports SCSI, regardless of Product_ | 235 | * likely that this card supports SCSI, regardless of Product_ |
234 | * Code, Board_Size, etc. | 236 | * Code, Board_Size, etc. |
235 | */ | 237 | */ |
236 | 238 | ||
237 | /* Get pointers to the presumed register locations and save contents */ | 239 | /* Get pointers to the presumed register locations and save contents */ |
238 | 240 | ||
239 | sasr_3393 = &(((gvp11_scsiregs *)(ZTWO_VADDR(address)))->SASR); | 241 | sasr_3393 = &(((gvp11_scsiregs *)(ZTWO_VADDR(address)))->SASR); |
240 | scmd_3393 = &(((gvp11_scsiregs *)(ZTWO_VADDR(address)))->SCMD); | 242 | scmd_3393 = &(((gvp11_scsiregs *)(ZTWO_VADDR(address)))->SCMD); |
241 | save_sasr = *sasr_3393; | 243 | save_sasr = *sasr_3393; |
242 | 244 | ||
243 | /* First test the AuxStatus Reg */ | 245 | /* First test the AuxStatus Reg */ |
244 | 246 | ||
245 | q = *sasr_3393; /* read it */ | 247 | q = *sasr_3393; /* read it */ |
246 | if (q & 0x08) /* bit 3 should always be clear */ | 248 | if (q & 0x08) /* bit 3 should always be clear */ |
247 | goto release; | 249 | goto release; |
248 | *sasr_3393 = WD_AUXILIARY_STATUS; /* setup indirect address */ | 250 | *sasr_3393 = WD_AUXILIARY_STATUS; /* setup indirect address */ |
249 | if (*sasr_3393 == WD_AUXILIARY_STATUS) { /* shouldn't retain the write */ | 251 | if (*sasr_3393 == WD_AUXILIARY_STATUS) { /* shouldn't retain the write */ |
250 | *sasr_3393 = save_sasr; /* Oops - restore this byte */ | 252 | *sasr_3393 = save_sasr; /* Oops - restore this byte */ |
251 | goto release; | 253 | goto release; |
252 | } | 254 | } |
253 | if (*sasr_3393 != q) { /* should still read the same */ | 255 | if (*sasr_3393 != q) { /* should still read the same */ |
254 | *sasr_3393 = save_sasr; /* Oops - restore this byte */ | 256 | *sasr_3393 = save_sasr; /* Oops - restore this byte */ |
255 | goto release; | 257 | goto release; |
256 | } | 258 | } |
257 | if (*scmd_3393 != q) /* and so should the image at 0x1f */ | 259 | if (*scmd_3393 != q) /* and so should the image at 0x1f */ |
258 | goto release; | 260 | goto release; |
259 | 261 | ||
260 | 262 | /* | |
261 | /* Ok, we probably have a wd33c93, but let's check a few other places | 263 | * Ok, we probably have a wd33c93, but let's check a few other places |
262 | * for good measure. Make sure that this works for both 'A and 'B | 264 | * for good measure. Make sure that this works for both 'A and 'B |
263 | * chip versions. | 265 | * chip versions. |
264 | */ | 266 | */ |
265 | 267 | ||
266 | *sasr_3393 = WD_SCSI_STATUS; | 268 | *sasr_3393 = WD_SCSI_STATUS; |
267 | q = *scmd_3393; | 269 | q = *scmd_3393; |
268 | *sasr_3393 = WD_SCSI_STATUS; | 270 | *sasr_3393 = WD_SCSI_STATUS; |
269 | *scmd_3393 = ~q; | 271 | *scmd_3393 = ~q; |
270 | *sasr_3393 = WD_SCSI_STATUS; | 272 | *sasr_3393 = WD_SCSI_STATUS; |
271 | qq = *scmd_3393; | 273 | qq = *scmd_3393; |
272 | *sasr_3393 = WD_SCSI_STATUS; | 274 | *sasr_3393 = WD_SCSI_STATUS; |
273 | *scmd_3393 = q; | 275 | *scmd_3393 = q; |
274 | if (qq != q) /* should be read only */ | 276 | if (qq != q) /* should be read only */ |
275 | goto release; | 277 | goto release; |
276 | *sasr_3393 = 0x1e; /* this register is unimplemented */ | 278 | *sasr_3393 = 0x1e; /* this register is unimplemented */ |
277 | q = *scmd_3393; | 279 | q = *scmd_3393; |
278 | *sasr_3393 = 0x1e; | 280 | *sasr_3393 = 0x1e; |
279 | *scmd_3393 = ~q; | 281 | *scmd_3393 = ~q; |
280 | *sasr_3393 = 0x1e; | 282 | *sasr_3393 = 0x1e; |
281 | qq = *scmd_3393; | 283 | qq = *scmd_3393; |
282 | *sasr_3393 = 0x1e; | 284 | *sasr_3393 = 0x1e; |
283 | *scmd_3393 = q; | 285 | *scmd_3393 = q; |
284 | if (qq != q || qq != 0xff) /* should be read only, all 1's */ | 286 | if (qq != q || qq != 0xff) /* should be read only, all 1's */ |
285 | goto release; | 287 | goto release; |
286 | *sasr_3393 = WD_TIMEOUT_PERIOD; | 288 | *sasr_3393 = WD_TIMEOUT_PERIOD; |
287 | q = *scmd_3393; | 289 | q = *scmd_3393; |
288 | *sasr_3393 = WD_TIMEOUT_PERIOD; | 290 | *sasr_3393 = WD_TIMEOUT_PERIOD; |
289 | *scmd_3393 = ~q; | 291 | *scmd_3393 = ~q; |
290 | *sasr_3393 = WD_TIMEOUT_PERIOD; | 292 | *sasr_3393 = WD_TIMEOUT_PERIOD; |
291 | qq = *scmd_3393; | 293 | qq = *scmd_3393; |
292 | *sasr_3393 = WD_TIMEOUT_PERIOD; | 294 | *sasr_3393 = WD_TIMEOUT_PERIOD; |
293 | *scmd_3393 = q; | 295 | *scmd_3393 = q; |
294 | if (qq != (~q & 0xff)) /* should be read/write */ | 296 | if (qq != (~q & 0xff)) /* should be read/write */ |
295 | goto release; | 297 | goto release; |
296 | #endif | 298 | #endif |
297 | 299 | ||
298 | instance = scsi_register (tpnt, sizeof (struct WD33C93_hostdata)); | 300 | instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata)); |
299 | if(instance == NULL) | 301 | if (instance == NULL) |
300 | goto release; | 302 | goto release; |
301 | instance->base = ZTWO_VADDR(address); | 303 | instance->base = ZTWO_VADDR(address); |
302 | instance->irq = IRQ_AMIGA_PORTS; | 304 | instance->irq = IRQ_AMIGA_PORTS; |
303 | instance->unique_id = z->slotaddr; | 305 | instance->unique_id = z->slotaddr; |
304 | 306 | ||
305 | if (gvp11_xfer_mask) | 307 | hdata = shost_priv(instance); |
306 | HDATA(instance)->dma_xfer_mask = gvp11_xfer_mask; | 308 | if (gvp11_xfer_mask) |
307 | else | 309 | hdata->dma_xfer_mask = gvp11_xfer_mask; |
308 | HDATA(instance)->dma_xfer_mask = default_dma_xfer_mask; | 310 | else |
309 | 311 | hdata->dma_xfer_mask = default_dma_xfer_mask; | |
310 | 312 | ||
311 | DMA(instance)->secret2 = 1; | 313 | DMA(instance)->secret2 = 1; |
312 | DMA(instance)->secret1 = 0; | 314 | DMA(instance)->secret1 = 0; |
313 | DMA(instance)->secret3 = 15; | 315 | DMA(instance)->secret3 = 15; |
314 | while (DMA(instance)->CNTR & GVP11_DMAC_BUSY) ; | 316 | while (DMA(instance)->CNTR & GVP11_DMAC_BUSY) |
315 | DMA(instance)->CNTR = 0; | 317 | ; |
316 | 318 | DMA(instance)->CNTR = 0; | |
317 | DMA(instance)->BANK = 0; | 319 | |
318 | 320 | DMA(instance)->BANK = 0; | |
319 | epc = *(unsigned short *)(ZTWO_VADDR(address) + 0x8000); | 321 | |
320 | 322 | epc = *(unsigned short *)(ZTWO_VADDR(address) + 0x8000); | |
321 | /* | 323 | |
322 | * Check for 14MHz SCSI clock | 324 | /* |
323 | */ | 325 | * Check for 14MHz SCSI clock |
324 | regs.SASR = &(DMA(instance)->SASR); | 326 | */ |
325 | regs.SCMD = &(DMA(instance)->SCMD); | 327 | regs.SASR = &(DMA(instance)->SASR); |
326 | HDATA(instance)->no_sync = 0xff; | 328 | regs.SCMD = &(DMA(instance)->SCMD); |
327 | HDATA(instance)->fast = 0; | 329 | hdata->no_sync = 0xff; |
328 | HDATA(instance)->dma_mode = CTRL_DMA; | 330 | hdata->fast = 0; |
329 | wd33c93_init(instance, regs, dma_setup, dma_stop, | 331 | hdata->dma_mode = CTRL_DMA; |
330 | (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10 | 332 | wd33c93_init(instance, regs, dma_setup, dma_stop, |
331 | : WD33C93_FS_12_15); | 333 | (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10 |
332 | 334 | : WD33C93_FS_12_15); | |
333 | if (request_irq(IRQ_AMIGA_PORTS, gvp11_intr, IRQF_SHARED, "GVP11 SCSI", | 335 | |
334 | instance)) | 336 | if (request_irq(IRQ_AMIGA_PORTS, gvp11_intr, IRQF_SHARED, |
335 | goto unregister; | 337 | "GVP11 SCSI", instance)) |
336 | DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE; | 338 | goto unregister; |
337 | num_gvp11++; | 339 | DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE; |
338 | continue; | 340 | num_gvp11++; |
341 | continue; | ||
339 | 342 | ||
340 | unregister: | 343 | unregister: |
341 | scsi_unregister(instance); | 344 | scsi_unregister(instance); |
342 | wd33c93_release(); | ||
343 | release: | 345 | release: |
344 | release_mem_region(address, 256); | 346 | release_mem_region(address, 256); |
345 | } | 347 | } |
346 | 348 | ||
347 | return num_gvp11; | 349 | return num_gvp11; |
348 | } | 350 | } |
349 | 351 | ||
350 | static int gvp11_bus_reset(struct scsi_cmnd *cmd) | 352 | static int gvp11_bus_reset(struct scsi_cmnd *cmd) |
@@ -389,12 +391,11 @@ static struct scsi_host_template driver_template = { | |||
389 | int gvp11_release(struct Scsi_Host *instance) | 391 | int gvp11_release(struct Scsi_Host *instance) |
390 | { | 392 | { |
391 | #ifdef MODULE | 393 | #ifdef MODULE |
392 | DMA(instance)->CNTR = 0; | 394 | DMA(instance)->CNTR = 0; |
393 | release_mem_region(ZTWO_PADDR(instance->base), 256); | 395 | release_mem_region(ZTWO_PADDR(instance->base), 256); |
394 | free_irq(IRQ_AMIGA_PORTS, instance); | 396 | free_irq(IRQ_AMIGA_PORTS, instance); |
395 | wd33c93_release(); | ||
396 | #endif | 397 | #endif |
397 | return 1; | 398 | return 1; |
398 | } | 399 | } |
399 | 400 | ||
400 | MODULE_LICENSE("GPL"); | 401 | MODULE_LICENSE("GPL"); |