1#define AUTOSENSE 2/* #define PSEUDO_DMA */ 3 4/* 5 * EcoSCSI 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#include <linux/module.h> 25#include <linux/signal.h> 26#include <linux/ioport.h> 27#include <linux/delay.h> 28#include <linux/init.h> 29#include <linux/blkdev.h> 30 31#include <asm/io.h> 32#include <asm/system.h> 33 34#include "../scsi.h" 35#include <scsi/scsi_host.h> 36 37#define NCR5380_implementation_fields int port, ctrl 38#define NCR5380_local_declare() struct Scsi_Host *_instance 39#define NCR5380_setup(instance) _instance = instance 40 41#define NCR5380_read(reg) ecoscsi_read(_instance, reg) 42#define NCR5380_write(reg, value) ecoscsi_write(_instance, reg, value) 43 44#define NCR5380_intr ecoscsi_intr 45#define NCR5380_queue_command ecoscsi_queue_command 46#define NCR5380_proc_info ecoscsi_proc_info 47 48#include "../NCR5380.h" 49 50#define ECOSCSI_PUBLIC_RELEASE 1 51 52static 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 59static 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/* 67 * Function : ecoscsi_setup(char *str, int *ints) 68 * 69 * Purpose : LILO command line initialization of the overrides array, 70 * 71 * Inputs : str - unused, ints - array of integer parameters with ints[0] 72 * equal to the number of ints. 73 * 74 */ 75 76void ecoscsi_setup(char *str, int *ints) 77{ 78} 79 80const char * ecoscsi_info (struct Scsi_Host *spnt) 81{ 82 return ""; 83} 84 85#undef STAT 86 87#define BOARD_NORMAL 0 88#define BOARD_NCR53C400 1 89 90#include "../NCR5380.c" 91 92static struct scsi_host_template ecoscsi_template = { 93 .module = THIS_MODULE, 94 .name = "Serial Port EcoSCSI NCR5380", 95 .proc_name = "ecoscsi", 96 .info = ecoscsi_info, 97 .queuecommand = ecoscsi_queue_command, 98 .eh_abort_handler = NCR5380_abort, 99 .eh_bus_reset_handler = NCR5380_bus_reset, 100 .can_queue = 16, 101 .this_id = 7, 102 .sg_tablesize = SG_ALL, 103 .cmd_per_lun = 2, 104 .use_clustering = DISABLE_CLUSTERING 105}; 106 107static struct Scsi_Host *host; 108 109static int __init ecoscsi_init(void) 110{ 111 112 host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata)); 113 if (!host) 114 return 0; 115 116 host->io_port = 0x80ce8000; 117 host->n_io_port = 144; 118 host->irq = IRQ_NONE; 119 120 if (!(request_region(host->io_port, host->n_io_port, "ecoscsi")) ) 121 goto unregister_scsi; 122 123 ecoscsi_write(host, MODE_REG, 0x20); /* Is it really SCSI? */ 124 if (ecoscsi_read(host, MODE_REG) != 0x20) /* Write to a reg. */ 125 goto release_reg; 126 127 ecoscsi_write(host, MODE_REG, 0x00 ); /* it back. */ 128 if (ecoscsi_read(host, MODE_REG) != 0x00) 129 goto release_reg; 130 131 NCR5380_init(host, 0); 132 133 printk("scsi%d: at port 0x%08lx irqs disabled", host->host_no, host->io_port); 134 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", 135 host->can_queue, host->cmd_per_lun, ECOSCSI_PUBLIC_RELEASE); 136 printk("\nscsi%d:", host->host_no); 137 NCR5380_print_options(host); 138 printk("\n"); 139 140 scsi_add_host(host, NULL); 141 scsi_scan_host(host); 142 return 0; 143 144release_reg: 145 release_region(host->io_port, host->n_io_port); 146unregister_scsi: 147 scsi_host_put(host); 148 return -ENODEV; 149} 150 151static void __exit ecoscsi_exit(void) 152{ 153 scsi_remove_host(host); 154 155 if (shpnt->irq != IRQ_NONE) 156 free_irq(shpnt->irq, NULL); 157 NCR5380_exit(host); 158 if (shpnt->io_port) 159 release_region(shpnt->io_port, shpnt->n_io_port); 160 161 scsi_host_put(host); 162 return 0; 163} 164 165module_init(ecoscsi_init); 166module_exit(ecoscsi_exit); 167 168MODULE_AUTHOR("Russell King"); 169MODULE_DESCRIPTION("Econet-SCSI driver for Acorn machines"); 170MODULE_LICENSE("GPL"); 171