Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

m68k: amiga - GVP Series II SCSI zorro_driver conversion

Acked-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

+159 -152
+159 -145
drivers/scsi/gvp11.c
··· 1 1 #include <linux/types.h> 2 - #include <linux/mm.h> 3 - #include <linux/slab.h> 4 - #include <linux/blkdev.h> 5 2 #include <linux/init.h> 6 3 #include <linux/interrupt.h> 4 + #include <linux/mm.h> 5 + #include <linux/slab.h> 6 + #include <linux/spinlock.h> 7 + #include <linux/zorro.h> 7 8 8 - #include <asm/setup.h> 9 9 #include <asm/page.h> 10 10 #include <asm/pgtable.h> 11 11 #include <asm/amigaints.h> 12 12 #include <asm/amigahw.h> 13 - #include <linux/zorro.h> 14 - #include <asm/irq.h> 15 - #include <linux/spinlock.h> 16 13 17 14 #include "scsi.h" 18 - #include <scsi/scsi_host.h> 19 15 #include "wd33c93.h" 20 16 #include "gvp11.h" 21 - 22 - #include <linux/stat.h> 23 17 24 18 25 19 #define CHECK_WD33C93 ··· 163 169 } 164 170 } 165 171 166 - static int __init check_wd33c93(struct gvp11_scsiregs *regs) 172 + static int gvp11_bus_reset(struct scsi_cmnd *cmd) 173 + { 174 + struct Scsi_Host *instance = cmd->device->host; 175 + 176 + /* FIXME perform bus-specific reset */ 177 + 178 + /* FIXME 2: shouldn't we no-op this function (return 179 + FAILED), and fall back to host reset function, 180 + wd33c93_host_reset ? */ 181 + 182 + spin_lock_irq(instance->host_lock); 183 + wd33c93_host_reset(cmd); 184 + spin_unlock_irq(instance->host_lock); 185 + 186 + return SUCCESS; 187 + } 188 + 189 + static struct scsi_host_template gvp11_scsi_template = { 190 + .module = THIS_MODULE, 191 + .name = "GVP Series II SCSI", 192 + .proc_info = wd33c93_proc_info, 193 + .proc_name = "GVP11", 194 + .queuecommand = wd33c93_queuecommand, 195 + .eh_abort_handler = wd33c93_abort, 196 + .eh_bus_reset_handler = gvp11_bus_reset, 197 + .eh_host_reset_handler = wd33c93_host_reset, 198 + .can_queue = CAN_QUEUE, 199 + .this_id = 7, 200 + .sg_tablesize = SG_ALL, 201 + .cmd_per_lun = CMD_PER_LUN, 202 + .use_clustering = DISABLE_CLUSTERING 203 + }; 204 + 205 + static int __devinit check_wd33c93(struct gvp11_scsiregs *regs) 167 206 { 168 207 #ifdef CHECK_WD33C93 169 208 volatile unsigned char *sasr_3393, *scmd_3393; ··· 276 249 return 0; 277 250 } 278 251 279 - int __init gvp11_detect(struct scsi_host_template *tpnt) 252 + static int __devinit gvp11_probe(struct zorro_dev *z, 253 + const struct zorro_device_id *ent) 280 254 { 281 - static unsigned char called = 0; 282 255 struct Scsi_Host *instance; 283 256 unsigned long address; 257 + int error; 284 258 unsigned int epc; 285 - struct zorro_dev *z = NULL; 286 259 unsigned int default_dma_xfer_mask; 287 260 struct WD33C93_hostdata *hdata; 288 261 struct gvp11_scsiregs *regs; 289 262 wd33c93_regs wdregs; 290 - int num_gvp11 = 0; 291 263 292 - if (!MACH_IS_AMIGA || called) 293 - return 0; 294 - called = 1; 264 + default_dma_xfer_mask = ent->driver_data; 295 265 296 - tpnt->proc_name = "GVP11"; 297 - tpnt->proc_info = &wd33c93_proc_info; 266 + /* 267 + * Rumors state that some GVP ram boards use the same product 268 + * code as the SCSI controllers. Therefore if the board-size 269 + * is not 64KB we asume it is a ram board and bail out. 270 + */ 271 + if (zorro_resource_len(z) != 0x10000) 272 + return -ENODEV; 298 273 299 - while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { 300 - /* 301 - * This should (hopefully) be the correct way to identify 302 - * all the different GVP SCSI controllers (except for the 303 - * SERIES I though). 304 - */ 274 + address = z->resource.start; 275 + if (!request_mem_region(address, 256, "wd33c93")) 276 + return -EBUSY; 305 277 306 - if (z->id == ZORRO_PROD_GVP_COMBO_030_R3_SCSI || 307 - z->id == ZORRO_PROD_GVP_SERIES_II) 308 - default_dma_xfer_mask = ~0x00ffffff; 309 - else if (z->id == ZORRO_PROD_GVP_GFORCE_030_SCSI || 310 - z->id == ZORRO_PROD_GVP_A530_SCSI || 311 - z->id == ZORRO_PROD_GVP_COMBO_030_R4_SCSI) 312 - default_dma_xfer_mask = ~0x01ffffff; 313 - else if (z->id == ZORRO_PROD_GVP_A1291 || 314 - z->id == ZORRO_PROD_GVP_GFORCE_040_SCSI_1) 315 - default_dma_xfer_mask = ~0x07ffffff; 316 - else 317 - continue; 278 + regs = (struct gvp11_scsiregs *)(ZTWO_VADDR(address)); 318 279 319 - /* 320 - * Rumors state that some GVP ram boards use the same product 321 - * code as the SCSI controllers. Therefore if the board-size 322 - * is not 64KB we asume it is a ram board and bail out. 323 - */ 324 - if (z->resource.end - z->resource.start != 0xffff) 325 - continue; 280 + error = check_wd33c93(regs); 281 + if (error) 282 + goto fail_check_or_alloc; 326 283 327 - address = z->resource.start; 328 - if (!request_mem_region(address, 256, "wd33c93")) 329 - continue; 330 - 331 - regs = (struct gvp11_scsiregs *)(ZTWO_VADDR(address)); 332 - if (check_wd33c93(regs)) 333 - goto release; 334 - 335 - instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata)); 336 - if (instance == NULL) 337 - goto release; 338 - instance->base = ZTWO_VADDR(address); 339 - instance->irq = IRQ_AMIGA_PORTS; 340 - instance->unique_id = z->slotaddr; 341 - 342 - hdata = shost_priv(instance); 343 - if (gvp11_xfer_mask) 344 - hdata->dma_xfer_mask = gvp11_xfer_mask; 345 - else 346 - hdata->dma_xfer_mask = default_dma_xfer_mask; 347 - 348 - regs->secret2 = 1; 349 - regs->secret1 = 0; 350 - regs->secret3 = 15; 351 - while (regs->CNTR & GVP11_DMAC_BUSY) 352 - ; 353 - regs->CNTR = 0; 354 - 355 - regs->BANK = 0; 356 - 357 - epc = *(unsigned short *)(ZTWO_VADDR(address) + 0x8000); 358 - 359 - /* 360 - * Check for 14MHz SCSI clock 361 - */ 362 - wdregs.SASR = &regs->SASR; 363 - wdregs.SCMD = &regs->SCMD; 364 - hdata->no_sync = 0xff; 365 - hdata->fast = 0; 366 - hdata->dma_mode = CTRL_DMA; 367 - wd33c93_init(instance, wdregs, dma_setup, dma_stop, 368 - (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10 369 - : WD33C93_FS_12_15); 370 - 371 - if (request_irq(IRQ_AMIGA_PORTS, gvp11_intr, IRQF_SHARED, 372 - "GVP11 SCSI", instance)) 373 - goto unregister; 374 - regs->CNTR = GVP11_DMAC_INT_ENABLE; 375 - num_gvp11++; 376 - continue; 377 - 378 - unregister: 379 - scsi_unregister(instance); 380 - release: 381 - release_mem_region(address, 256); 284 + instance = scsi_host_alloc(&gvp11_scsi_template, 285 + sizeof(struct WD33C93_hostdata)); 286 + if (!instance) { 287 + error = -ENOMEM; 288 + goto fail_check_or_alloc; 382 289 } 383 290 384 - return num_gvp11; 291 + instance->base = (unsigned long)regs; 292 + instance->irq = IRQ_AMIGA_PORTS; 293 + instance->unique_id = z->slotaddr; 294 + 295 + regs->secret2 = 1; 296 + regs->secret1 = 0; 297 + regs->secret3 = 15; 298 + while (regs->CNTR & GVP11_DMAC_BUSY) 299 + ; 300 + regs->CNTR = 0; 301 + regs->BANK = 0; 302 + 303 + wdregs.SASR = &regs->SASR; 304 + wdregs.SCMD = &regs->SCMD; 305 + 306 + hdata = shost_priv(instance); 307 + if (gvp11_xfer_mask) 308 + hdata->dma_xfer_mask = gvp11_xfer_mask; 309 + else 310 + hdata->dma_xfer_mask = default_dma_xfer_mask; 311 + 312 + hdata->no_sync = 0xff; 313 + hdata->fast = 0; 314 + hdata->dma_mode = CTRL_DMA; 315 + 316 + /* 317 + * Check for 14MHz SCSI clock 318 + */ 319 + epc = *(unsigned short *)(ZTWO_VADDR(address) + 0x8000); 320 + wd33c93_init(instance, wdregs, dma_setup, dma_stop, 321 + (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10 322 + : WD33C93_FS_12_15); 323 + 324 + error = request_irq(IRQ_AMIGA_PORTS, gvp11_intr, IRQF_SHARED, 325 + "GVP11 SCSI", instance); 326 + if (error) 327 + goto fail_irq; 328 + 329 + regs->CNTR = GVP11_DMAC_INT_ENABLE; 330 + 331 + error = scsi_add_host(instance, NULL); 332 + if (error) 333 + goto fail_host; 334 + 335 + zorro_set_drvdata(z, instance); 336 + scsi_scan_host(instance); 337 + return 0; 338 + 339 + fail_host: 340 + free_irq(IRQ_AMIGA_PORTS, instance); 341 + fail_irq: 342 + scsi_host_put(instance); 343 + fail_check_or_alloc: 344 + release_mem_region(address, 256); 345 + return error; 385 346 } 386 347 387 - static int gvp11_bus_reset(struct scsi_cmnd *cmd) 348 + static void __devexit gvp11_remove(struct zorro_dev *z) 388 349 { 389 - /* FIXME perform bus-specific reset */ 390 - 391 - /* FIXME 2: shouldn't we no-op this function (return 392 - FAILED), and fall back to host reset function, 393 - wd33c93_host_reset ? */ 394 - 395 - spin_lock_irq(cmd->device->host->host_lock); 396 - wd33c93_host_reset(cmd); 397 - spin_unlock_irq(cmd->device->host->host_lock); 398 - 399 - return SUCCESS; 400 - } 401 - 402 - 403 - #define HOSTS_C 404 - 405 - #include "gvp11.h" 406 - 407 - static struct scsi_host_template driver_template = { 408 - .proc_name = "GVP11", 409 - .name = "GVP Series II SCSI", 410 - .detect = gvp11_detect, 411 - .release = gvp11_release, 412 - .queuecommand = wd33c93_queuecommand, 413 - .eh_abort_handler = wd33c93_abort, 414 - .eh_bus_reset_handler = gvp11_bus_reset, 415 - .eh_host_reset_handler = wd33c93_host_reset, 416 - .can_queue = CAN_QUEUE, 417 - .this_id = 7, 418 - .sg_tablesize = SG_ALL, 419 - .cmd_per_lun = CMD_PER_LUN, 420 - .use_clustering = DISABLE_CLUSTERING 421 - }; 422 - 423 - 424 - #include "scsi_module.c" 425 - 426 - int gvp11_release(struct Scsi_Host *instance) 427 - { 428 - #ifdef MODULE 350 + struct Scsi_Host *instance = zorro_get_drvdata(z); 429 351 struct gvp11_scsiregs *regs = (struct gvp11_scsiregs *)(instance->base); 430 352 431 353 regs->CNTR = 0; 432 - release_mem_region(ZTWO_PADDR(instance->base), 256); 354 + scsi_remove_host(instance); 433 355 free_irq(IRQ_AMIGA_PORTS, instance); 434 - #endif 435 - return 1; 356 + scsi_host_put(instance); 357 + release_mem_region(z->resource.start, 256); 436 358 } 437 359 360 + /* 361 + * This should (hopefully) be the correct way to identify 362 + * all the different GVP SCSI controllers (except for the 363 + * SERIES I though). 364 + */ 365 + 366 + static struct zorro_device_id gvp11_zorro_tbl[] __devinitdata = { 367 + { ZORRO_PROD_GVP_COMBO_030_R3_SCSI, ~0x00ffffff }, 368 + { ZORRO_PROD_GVP_SERIES_II, ~0x00ffffff }, 369 + { ZORRO_PROD_GVP_GFORCE_030_SCSI, ~0x01ffffff }, 370 + { ZORRO_PROD_GVP_A530_SCSI, ~0x01ffffff }, 371 + { ZORRO_PROD_GVP_COMBO_030_R4_SCSI, ~0x01ffffff }, 372 + { ZORRO_PROD_GVP_A1291, ~0x07ffffff }, 373 + { ZORRO_PROD_GVP_GFORCE_040_SCSI_1, ~0x07ffffff }, 374 + { 0 } 375 + }; 376 + MODULE_DEVICE_TABLE(zorro, gvp11_zorro_tbl); 377 + 378 + static struct zorro_driver gvp11_driver = { 379 + .name = "gvp11", 380 + .id_table = gvp11_zorro_tbl, 381 + .probe = gvp11_probe, 382 + .remove = __devexit_p(gvp11_remove), 383 + }; 384 + 385 + static int __init gvp11_init(void) 386 + { 387 + return zorro_register_driver(&gvp11_driver); 388 + } 389 + module_init(gvp11_init); 390 + 391 + static void __exit gvp11_exit(void) 392 + { 393 + zorro_unregister_driver(&gvp11_driver); 394 + } 395 + module_exit(gvp11_exit); 396 + 397 + MODULE_DESCRIPTION("GVP Series II SCSI"); 438 398 MODULE_LICENSE("GPL");
-7
drivers/scsi/gvp11.h
··· 11 11 12 12 #include <linux/types.h> 13 13 14 - int gvp11_detect(struct scsi_host_template *); 15 - int gvp11_release(struct Scsi_Host *); 16 - 17 14 #ifndef CMD_PER_LUN 18 15 #define CMD_PER_LUN 2 19 16 #endif ··· 18 21 #ifndef CAN_QUEUE 19 22 #define CAN_QUEUE 16 20 23 #endif 21 - 22 - #ifndef HOSTS_C 23 24 24 25 /* 25 26 * if the transfer address ANDed with this results in a non-zero ··· 48 53 #define GVP11_DMAC_INT_PENDING (1<<1) 49 54 #define GVP11_DMAC_INT_ENABLE (1<<3) 50 55 #define GVP11_DMAC_DIR_WRITE (1<<4) 51 - 52 - #endif /* else def HOSTS_C */ 53 56 54 57 #endif /* GVP11_H */