| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame^] | 37 | #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame^] | 39 | #define NCR5380_local_declare() void __iomem *_base |
| 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); }) |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | #define NCR5380_intr ecoscsi_intr |
| 46 | #define NCR5380_queue_command ecoscsi_queue_command |
| 47 | #define NCR5380_proc_info ecoscsi_proc_info |
| 48 | |
| Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame^] | 49 | #define NCR5380_implementation_fields \ |
| 50 | void __iomem *base |
| 51 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #include "../NCR5380.h" |
| 53 | |
| 54 | #define ECOSCSI_PUBLIC_RELEASE 1 |
| 55 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | /* |
| 57 | * Function : ecoscsi_setup(char *str, int *ints) |
| 58 | * |
| 59 | * Purpose : LILO command line initialization of the overrides array, |
| 60 | * |
| 61 | * Inputs : str - unused, ints - array of integer parameters with ints[0] |
| 62 | * equal to the number of ints. |
| 63 | * |
| 64 | */ |
| 65 | |
| 66 | void ecoscsi_setup(char *str, int *ints) |
| 67 | { |
| 68 | } |
| 69 | |
| 70 | const char * ecoscsi_info (struct Scsi_Host *spnt) |
| 71 | { |
| 72 | return ""; |
| 73 | } |
| 74 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #define BOARD_NORMAL 0 |
| 76 | #define BOARD_NCR53C400 1 |
| 77 | |
| 78 | #include "../NCR5380.c" |
| 79 | |
| Christoph Hellwig | d0be4a7d | 2005-10-31 18:31:40 +0100 | [diff] [blame] | 80 | static struct scsi_host_template ecoscsi_template = { |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | .module = THIS_MODULE, |
| 82 | .name = "Serial Port EcoSCSI NCR5380", |
| 83 | .proc_name = "ecoscsi", |
| 84 | .info = ecoscsi_info, |
| 85 | .queuecommand = ecoscsi_queue_command, |
| 86 | .eh_abort_handler = NCR5380_abort, |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | .eh_bus_reset_handler = NCR5380_bus_reset, |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | .can_queue = 16, |
| 89 | .this_id = 7, |
| 90 | .sg_tablesize = SG_ALL, |
| 91 | .cmd_per_lun = 2, |
| 92 | .use_clustering = DISABLE_CLUSTERING |
| 93 | }; |
| 94 | |
| 95 | static struct Scsi_Host *host; |
| 96 | |
| 97 | static int __init ecoscsi_init(void) |
| 98 | { |
| Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame^] | 99 | void __iomem *_base; |
| 100 | int ret; |
| 101 | |
| 102 | if (!request_mem_region(0x33a0000, 4096, "ecoscsi")) { |
| 103 | ret = -EBUSY; |
| 104 | goto out; |
| 105 | } |
| 106 | |
| 107 | _base = ioremap(0x33a0000, 4096); |
| 108 | if (!_base) { |
| 109 | ret = -ENOMEM; |
| 110 | goto out_release; |
| 111 | } |
| 112 | |
| 113 | NCR5380_write(MODE_REG, 0x20); /* Is it really SCSI? */ |
| 114 | if (NCR5380_read(MODE_REG) != 0x20) /* Write to a reg. */ |
| 115 | goto out_unmap; |
| 116 | |
| 117 | NCR5380_write(MODE_REG, 0x00); /* it back. */ |
| 118 | if (NCR5380_read(MODE_REG) != 0x00) |
| 119 | goto out_unmap; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata)); |
| Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame^] | 122 | if (!host) { |
| 123 | ret = -ENOMEM; |
| 124 | goto out_unmap; |
| 125 | } |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
| Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame^] | 127 | priv(host)->base = _base; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | host->irq = IRQ_NONE; |
| 129 | |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | NCR5380_init(host, 0); |
| 131 | |
| 132 | printk("scsi%d: at port 0x%08lx irqs disabled", host->host_no, host->io_port); |
| 133 | printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", |
| 134 | host->can_queue, host->cmd_per_lun, ECOSCSI_PUBLIC_RELEASE); |
| 135 | printk("\nscsi%d:", host->host_no); |
| 136 | NCR5380_print_options(host); |
| 137 | printk("\n"); |
| 138 | |
| 139 | scsi_add_host(host, NULL); /* XXX handle failure */ |
| 140 | scsi_scan_host(host); |
| 141 | return 0; |
| 142 | |
| Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame^] | 143 | out_unmap: |
| 144 | iounmap(_base); |
| 145 | out_release: |
| 146 | release_mem_region(0x33a0000, 4096); |
| 147 | out: |
| 148 | return ret; |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | static void __exit ecoscsi_exit(void) |
| 152 | { |
| 153 | scsi_remove_host(host); |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | NCR5380_exit(host); |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | scsi_host_put(host); |
| Russell King | 8b801ea | 2007-07-20 10:38:54 +0100 | [diff] [blame^] | 156 | release_mem_region(0x33a0000, 4096); |
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | module_init(ecoscsi_init); |
| 161 | module_exit(ecoscsi_exit); |
| 162 | |
| 163 | MODULE_AUTHOR("Russell King"); |
| 164 | MODULE_DESCRIPTION("Econet-SCSI driver for Acorn machines"); |
| 165 | MODULE_LICENSE("GPL"); |
| 166 | |