Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | Low Level Linux Driver for the IBM Microchannel SCSI Subsystem for |
| 3 | Linux Kernel >= 2.4.0. |
| 4 | Copyright (c) 1995 Strom Systems, Inc. under the terms of the GNU |
| 5 | General Public License. Written by Martin Kolinek, December 1995. |
| 6 | Further development by: Chris Beauregard, Klaus Kudielka, Michael Lang |
| 7 | See the file Documentation/scsi/ibmmca.txt for a detailed description |
| 8 | of this driver, the commandline arguments and the history of its |
| 9 | development. |
| 10 | See the WWW-page: http://www.uni-mainz.de/~langm000/linux.html for latest |
| 11 | updates, info and ADF-files for adapters supported by this driver. |
| 12 | |
| 13 | Alan Cox <alan@redhat.com> |
| 14 | Updated for Linux 2.5.45 to use the new error handler, cleaned up the |
| 15 | lock macros and did a few unavoidable locking tweaks, plus one locking |
| 16 | fix in the irq and completion path. |
| 17 | |
| 18 | */ |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/module.h> |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/types.h> |
| 23 | #include <linux/ctype.h> |
| 24 | #include <linux/string.h> |
| 25 | #include <linux/interrupt.h> |
| 26 | #include <linux/ioport.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/blkdev.h> |
| 29 | #include <linux/proc_fs.h> |
| 30 | #include <linux/stat.h> |
| 31 | #include <linux/mca.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/spinlock.h> |
| 33 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | #include <asm/system.h> |
| 36 | #include <asm/io.h> |
| 37 | |
| 38 | #include "scsi.h" |
| 39 | #include <scsi/scsi_host.h> |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 40 | |
| 41 | /* Common forward declarations for all Linux-versions: */ |
| 42 | static int ibmmca_queuecommand (Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); |
| 43 | static int ibmmca_abort (Scsi_Cmnd *); |
| 44 | static int ibmmca_host_reset (Scsi_Cmnd *); |
| 45 | static int ibmmca_biosparam (struct scsi_device *, struct block_device *, sector_t, int *); |
| 46 | static int ibmmca_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start, off_t offset, int length, int inout); |
| 47 | |
| 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | /* current version of this driver-source: */ |
| 51 | #define IBMMCA_SCSI_DRIVER_VERSION "4.0b-ac" |
| 52 | |
| 53 | /* driver configuration */ |
| 54 | #define IM_MAX_HOSTS 8 /* maximum number of host adapters */ |
| 55 | #define IM_RESET_DELAY 60 /* seconds allowed for a reset */ |
| 56 | |
| 57 | /* driver debugging - #undef all for normal operation */ |
| 58 | /* if defined: count interrupts and ignore this special one: */ |
| 59 | #undef IM_DEBUG_TIMEOUT //50 |
| 60 | #define TIMEOUT_PUN 0 |
| 61 | #define TIMEOUT_LUN 0 |
| 62 | /* verbose interrupt: */ |
| 63 | #undef IM_DEBUG_INT |
| 64 | /* verbose queuecommand: */ |
| 65 | #undef IM_DEBUG_CMD |
| 66 | /* verbose queucommand for specific SCSI-device type: */ |
| 67 | #undef IM_DEBUG_CMD_SPEC_DEV |
| 68 | /* verbose device probing */ |
| 69 | #undef IM_DEBUG_PROBE |
| 70 | |
| 71 | /* device type that shall be displayed on syslog (only during debugging): */ |
| 72 | #define IM_DEBUG_CMD_DEVICE TYPE_TAPE |
| 73 | |
| 74 | /* relative addresses of hardware registers on a subsystem */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 75 | #define IM_CMD_REG(h) ((h)->io_port) /*Command Interface, (4 bytes long) */ |
| 76 | #define IM_ATTN_REG(h) ((h)->io_port+4) /*Attention (1 byte) */ |
| 77 | #define IM_CTR_REG(h) ((h)->io_port+5) /*Basic Control (1 byte) */ |
| 78 | #define IM_INTR_REG(h) ((h)->io_port+6) /*Interrupt Status (1 byte, r/o) */ |
| 79 | #define IM_STAT_REG(h) ((h)->io_port+7) /*Basic Status (1 byte, read only) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
| 81 | /* basic I/O-port of first adapter */ |
| 82 | #define IM_IO_PORT 0x3540 |
| 83 | /* maximum number of hosts that can be found */ |
| 84 | #define IM_N_IO_PORT 8 |
| 85 | |
| 86 | /*requests going into the upper nibble of the Attention register */ |
| 87 | /*note: the lower nibble specifies the device(0-14), or subsystem(15) */ |
| 88 | #define IM_IMM_CMD 0x10 /*immediate command */ |
| 89 | #define IM_SCB 0x30 /*Subsystem Control Block command */ |
| 90 | #define IM_LONG_SCB 0x40 /*long Subsystem Control Block command */ |
| 91 | #define IM_EOI 0xe0 /*end-of-interrupt request */ |
| 92 | |
| 93 | /*values for bits 7,1,0 of Basic Control reg. (bits 6-2 reserved) */ |
| 94 | #define IM_HW_RESET 0x80 /*hardware reset */ |
| 95 | #define IM_ENABLE_DMA 0x02 /*enable subsystem's busmaster DMA */ |
| 96 | #define IM_ENABLE_INTR 0x01 /*enable interrupts to the system */ |
| 97 | |
| 98 | /*to interpret the upper nibble of Interrupt Status register */ |
| 99 | /*note: the lower nibble specifies the device(0-14), or subsystem(15) */ |
| 100 | #define IM_SCB_CMD_COMPLETED 0x10 |
| 101 | #define IM_SCB_CMD_COMPLETED_WITH_RETRIES 0x50 |
| 102 | #define IM_LOOP_SCATTER_BUFFER_FULL 0x60 |
| 103 | #define IM_ADAPTER_HW_FAILURE 0x70 |
| 104 | #define IM_IMMEDIATE_CMD_COMPLETED 0xa0 |
| 105 | #define IM_CMD_COMPLETED_WITH_FAILURE 0xc0 |
| 106 | #define IM_CMD_ERROR 0xe0 |
| 107 | #define IM_SOFTWARE_SEQUENCING_ERROR 0xf0 |
| 108 | |
| 109 | /*to interpret bits 3-0 of Basic Status register (bits 7-4 reserved) */ |
| 110 | #define IM_CMD_REG_FULL 0x08 |
| 111 | #define IM_CMD_REG_EMPTY 0x04 |
| 112 | #define IM_INTR_REQUEST 0x02 |
| 113 | #define IM_BUSY 0x01 |
| 114 | |
| 115 | /*immediate commands (word written into low 2 bytes of command reg) */ |
| 116 | #define IM_RESET_IMM_CMD 0x0400 |
| 117 | #define IM_FEATURE_CTR_IMM_CMD 0x040c |
| 118 | #define IM_DMA_PACING_IMM_CMD 0x040d |
| 119 | #define IM_ASSIGN_IMM_CMD 0x040e |
| 120 | #define IM_ABORT_IMM_CMD 0x040f |
| 121 | #define IM_FORMAT_PREP_IMM_CMD 0x0417 |
| 122 | |
| 123 | /*SCB (Subsystem Control Block) structure */ |
| 124 | struct im_scb { |
| 125 | unsigned short command; /*command word (read, etc.) */ |
| 126 | unsigned short enable; /*enable word, modifies cmd */ |
| 127 | union { |
| 128 | unsigned long log_blk_adr; /*block address on SCSI device */ |
| 129 | unsigned char scsi_cmd_length; /*6,10,12, for other scsi cmd */ |
| 130 | } u1; |
| 131 | unsigned long sys_buf_adr; /*physical system memory adr */ |
| 132 | unsigned long sys_buf_length; /*size of sys mem buffer */ |
| 133 | unsigned long tsb_adr; /*Termination Status Block adr */ |
| 134 | unsigned long scb_chain_adr; /*optional SCB chain address */ |
| 135 | union { |
| 136 | struct { |
| 137 | unsigned short count; /*block count, on SCSI device */ |
| 138 | unsigned short length; /*block length, on SCSI device */ |
| 139 | } blk; |
| 140 | unsigned char scsi_command[12]; /*other scsi command */ |
| 141 | } u2; |
| 142 | }; |
| 143 | |
| 144 | /*structure scatter-gather element (for list of system memory areas) */ |
| 145 | struct im_sge { |
| 146 | void *address; |
| 147 | unsigned long byte_length; |
| 148 | }; |
| 149 | |
| 150 | /*structure returned by a get_pos_info command: */ |
| 151 | struct im_pos_info { |
| 152 | unsigned short pos_id; /* adapter id */ |
| 153 | unsigned char pos_3a; /* pos 3 (if pos 6 = 0) */ |
| 154 | unsigned char pos_2; /* pos 2 */ |
| 155 | unsigned char int_level; /* interrupt level IRQ 11 or 14 */ |
| 156 | unsigned char pos_4a; /* pos 4 (if pos 6 = 0) */ |
| 157 | unsigned short connector_size; /* MCA connector size: 16 or 32 Bit */ |
| 158 | unsigned char num_luns; /* number of supported luns per device */ |
| 159 | unsigned char num_puns; /* number of supported puns */ |
| 160 | unsigned char pacing_factor; /* pacing factor */ |
| 161 | unsigned char num_ldns; /* number of ldns available */ |
| 162 | unsigned char eoi_off; /* time EOI and interrupt inactive */ |
| 163 | unsigned char max_busy; /* time between reset and busy on */ |
| 164 | unsigned short cache_stat; /* ldn cachestat. Bit=1 = not cached */ |
| 165 | unsigned short retry_stat; /* retry status of ldns. Bit=1=disabled */ |
| 166 | unsigned char pos_4b; /* pos 4 (if pos 6 = 1) */ |
| 167 | unsigned char pos_3b; /* pos 3 (if pos 6 = 1) */ |
| 168 | unsigned char pos_6; /* pos 6 */ |
| 169 | unsigned char pos_5; /* pos 5 */ |
| 170 | unsigned short max_overlap; /* maximum overlapping requests */ |
| 171 | unsigned short num_bus; /* number of SCSI-busses */ |
| 172 | }; |
| 173 | |
| 174 | /*values for SCB command word */ |
| 175 | #define IM_NO_SYNCHRONOUS 0x0040 /*flag for any command */ |
| 176 | #define IM_NO_DISCONNECT 0x0080 /*flag for any command */ |
| 177 | #define IM_READ_DATA_CMD 0x1c01 |
| 178 | #define IM_WRITE_DATA_CMD 0x1c02 |
| 179 | #define IM_READ_VERIFY_CMD 0x1c03 |
| 180 | #define IM_WRITE_VERIFY_CMD 0x1c04 |
| 181 | #define IM_REQUEST_SENSE_CMD 0x1c08 |
| 182 | #define IM_READ_CAPACITY_CMD 0x1c09 |
| 183 | #define IM_DEVICE_INQUIRY_CMD 0x1c0b |
| 184 | #define IM_READ_LOGICAL_CMD 0x1c2a |
| 185 | #define IM_OTHER_SCSI_CMD_CMD 0x241f |
| 186 | |
| 187 | /* unused, but supported, SCB commands */ |
| 188 | #define IM_GET_COMMAND_COMPLETE_STATUS_CMD 0x1c07 /* command status */ |
| 189 | #define IM_GET_POS_INFO_CMD 0x1c0a /* returns neat stuff */ |
| 190 | #define IM_READ_PREFETCH_CMD 0x1c31 /* caching controller only */ |
| 191 | #define IM_FOMAT_UNIT_CMD 0x1c16 /* format unit */ |
| 192 | #define IM_REASSIGN_BLOCK_CMD 0x1c18 /* in case of error */ |
| 193 | |
| 194 | /*values to set bits in the enable word of SCB */ |
| 195 | #define IM_READ_CONTROL 0x8000 |
| 196 | #define IM_REPORT_TSB_ONLY_ON_ERROR 0x4000 |
| 197 | #define IM_RETRY_ENABLE 0x2000 |
| 198 | #define IM_POINTER_TO_LIST 0x1000 |
| 199 | #define IM_SUPRESS_EXCEPTION_SHORT 0x0400 |
| 200 | #define IM_BYPASS_BUFFER 0x0200 |
| 201 | #define IM_CHAIN_ON_NO_ERROR 0x0001 |
| 202 | |
| 203 | /*TSB (Termination Status Block) structure */ |
| 204 | struct im_tsb { |
| 205 | unsigned short end_status; |
| 206 | unsigned short reserved1; |
| 207 | unsigned long residual_byte_count; |
| 208 | unsigned long sg_list_element_adr; |
| 209 | unsigned short status_length; |
| 210 | unsigned char dev_status; |
| 211 | unsigned char cmd_status; |
| 212 | unsigned char dev_error; |
| 213 | unsigned char cmd_error; |
| 214 | unsigned short reserved2; |
| 215 | unsigned short reserved3; |
| 216 | unsigned short low_of_last_scb_adr; |
| 217 | unsigned short high_of_last_scb_adr; |
| 218 | }; |
| 219 | |
| 220 | /*subsystem uses interrupt request level 14 */ |
| 221 | #define IM_IRQ 14 |
| 222 | /*SCSI-2 F/W may evade to interrupt 11 */ |
| 223 | #define IM_IRQ_FW 11 |
| 224 | |
| 225 | /* Model 95 has an additional alphanumeric display, which can be used |
| 226 | to display SCSI-activities. 8595 models do not have any disk led, which |
| 227 | makes this feature quite useful. |
| 228 | The regular PS/2 disk led is turned on/off by bits 6,7 of system |
| 229 | control port. */ |
| 230 | |
| 231 | /* LED display-port (actually, last LED on display) */ |
| 232 | #define MOD95_LED_PORT 0x108 |
| 233 | /* system-control-register of PS/2s with diskindicator */ |
| 234 | #define PS2_SYS_CTR 0x92 |
| 235 | /* activity displaying methods */ |
| 236 | #define LED_DISP 1 |
| 237 | #define LED_ADISP 2 |
| 238 | #define LED_ACTIVITY 4 |
| 239 | /* failed intr */ |
| 240 | #define CMD_FAIL 255 |
| 241 | |
| 242 | /* The SCSI-ID(!) of the accessed SCSI-device is shown on PS/2-95 machines' LED |
| 243 | displays. ldn is no longer displayed here, because the ldn mapping is now |
| 244 | done dynamically and the ldn <-> pun,lun maps can be looked-up at boottime |
| 245 | or during uptime in /proc/scsi/ibmmca/<host_no> in case of trouble, |
| 246 | interest, debugging or just for having fun. The left number gives the |
| 247 | host-adapter number and the right shows the accessed SCSI-ID. */ |
| 248 | |
| 249 | /* display_mode is set by the ibmmcascsi= command line arg */ |
| 250 | static int display_mode = 0; |
| 251 | /* set default adapter timeout */ |
| 252 | static unsigned int adapter_timeout = 45; |
| 253 | /* for probing on feature-command: */ |
| 254 | static unsigned int global_command_error_excuse = 0; |
| 255 | /* global setting by command line for adapter_speed */ |
| 256 | static int global_adapter_speed = 0; /* full speed by default */ |
| 257 | |
| 258 | /* Panel / LED on, do it right for F/W addressin, too. adisplay will |
| 259 | * just ignore ids>7, as the panel has only 7 digits available */ |
| 260 | #define PS2_DISK_LED_ON(ad,id) { if (display_mode & LED_DISP) { if (id>9) \ |
| 261 | outw((ad+48)|((id+55)<<8), MOD95_LED_PORT ); else \ |
| 262 | outw((ad+48)|((id+48)<<8), MOD95_LED_PORT ); } else \ |
| 263 | if (display_mode & LED_ADISP) { if (id<7) outb((char)(id+48),MOD95_LED_PORT+1+id); \ |
| 264 | outb((char)(ad+48), MOD95_LED_PORT); } \ |
| 265 | if ((display_mode & LED_ACTIVITY)||(!display_mode)) \ |
| 266 | outb(inb(PS2_SYS_CTR) | 0xc0, PS2_SYS_CTR); } |
| 267 | |
| 268 | /* Panel / LED off */ |
| 269 | /* bug fixed, Dec 15, 1997, where | was replaced by & here */ |
| 270 | #define PS2_DISK_LED_OFF() { if (display_mode & LED_DISP) \ |
| 271 | outw(0x2020, MOD95_LED_PORT ); else if (display_mode & LED_ADISP) { \ |
| 272 | outl(0x20202020,MOD95_LED_PORT); outl(0x20202020,MOD95_LED_PORT+4); } \ |
| 273 | if ((display_mode & LED_ACTIVITY)||(!display_mode)) \ |
| 274 | outb(inb(PS2_SYS_CTR) & 0x3f, PS2_SYS_CTR); } |
| 275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | /* types of different supported hardware that goes to hostdata special */ |
| 277 | #define IBM_SCSI2_FW 0 |
| 278 | #define IBM_7568_WCACHE 1 |
| 279 | #define IBM_EXP_UNIT 2 |
| 280 | #define IBM_SCSI_WCACHE 3 |
| 281 | #define IBM_SCSI 4 |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 282 | #define IBM_INTEGSCSI 5 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
| 284 | /* other special flags for hostdata structure */ |
| 285 | #define FORCED_DETECTION 100 |
| 286 | #define INTEGRATED_SCSI 101 |
| 287 | |
| 288 | /* List of possible IBM-SCSI-adapters */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 289 | static short ibmmca_id_table[] = { |
| 290 | 0x8efc, |
| 291 | 0x8efd, |
| 292 | 0x8ef8, |
| 293 | 0x8eff, |
| 294 | 0x8efe, |
| 295 | /* No entry for integrated SCSI, that's part of the register */ |
| 296 | 0 |
| 297 | }; |
| 298 | |
| 299 | static const char *ibmmca_description[] = { |
| 300 | "IBM SCSI-2 F/W Adapter", /* special = 0 */ |
| 301 | "IBM 7568 Industrial Computer SCSI Adapter w/Cache", /* special = 1 */ |
| 302 | "IBM Expansion Unit SCSI Controller", /* special = 2 */ |
| 303 | "IBM SCSI Adapter w/Cache", /* special = 3 */ |
| 304 | "IBM SCSI Adapter", /* special = 4 */ |
| 305 | "IBM Integrated SCSI Controller", /* special = 5 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | }; |
| 307 | |
| 308 | /* Max number of logical devices (can be up from 0 to 14). 15 is the address |
| 309 | of the adapter itself. */ |
| 310 | #define MAX_LOG_DEV 15 |
| 311 | |
| 312 | /*local data for a logical device */ |
| 313 | struct logical_device { |
| 314 | struct im_scb scb; /* SCSI-subsystem-control-block structure */ |
| 315 | struct im_tsb tsb; /* SCSI command complete status block structure */ |
| 316 | struct im_sge sge[16]; /* scatter gather list structure */ |
| 317 | unsigned char buf[256]; /* SCSI command return data buffer */ |
| 318 | Scsi_Cmnd *cmd; /* SCSI-command that is currently in progress */ |
| 319 | int device_type; /* type of the SCSI-device. See include/scsi/scsi.h |
| 320 | for interpretation of the possible values */ |
| 321 | int block_length; /* blocksize of a particular logical SCSI-device */ |
| 322 | int cache_flag; /* 1 if this is uncached, 0 if cache is present for ldn */ |
| 323 | int retry_flag; /* 1 if adapter retry is disabled, 0 if enabled */ |
| 324 | }; |
| 325 | |
| 326 | /* statistics of the driver during operations (for proc_info) */ |
| 327 | struct Driver_Statistics { |
| 328 | /* SCSI statistics on the adapter */ |
| 329 | int ldn_access[MAX_LOG_DEV + 1]; /* total accesses on a ldn */ |
| 330 | int ldn_read_access[MAX_LOG_DEV + 1]; /* total read-access on a ldn */ |
| 331 | int ldn_write_access[MAX_LOG_DEV + 1]; /* total write-access on a ldn */ |
| 332 | int ldn_inquiry_access[MAX_LOG_DEV + 1]; /* total inquiries on a ldn */ |
| 333 | int ldn_modeselect_access[MAX_LOG_DEV + 1]; /* total mode selects on ldn */ |
| 334 | int scbs; /* short SCBs queued */ |
| 335 | int long_scbs; /* long SCBs queued */ |
| 336 | int total_accesses; /* total accesses on all ldns */ |
| 337 | int total_interrupts; /* total interrupts (should be |
| 338 | same as total_accesses) */ |
| 339 | int total_errors; /* command completed with error */ |
| 340 | /* dynamical assignment statistics */ |
| 341 | int total_scsi_devices; /* number of physical pun,lun */ |
| 342 | int dyn_flag; /* flag showing dynamical mode */ |
| 343 | int dynamical_assignments; /* number of remappings of ldns */ |
| 344 | int ldn_assignments[MAX_LOG_DEV + 1]; /* number of remappings of each |
| 345 | ldn */ |
| 346 | }; |
| 347 | |
| 348 | /* data structure for each host adapter */ |
| 349 | struct ibmmca_hostdata { |
| 350 | /* array of logical devices: */ |
| 351 | struct logical_device _ld[MAX_LOG_DEV + 1]; |
| 352 | /* array to convert (pun, lun) into logical device number: */ |
| 353 | unsigned char _get_ldn[16][8]; |
| 354 | /*array that contains the information about the physical SCSI-devices |
| 355 | attached to this host adapter: */ |
| 356 | unsigned char _get_scsi[16][8]; |
| 357 | /* used only when checking logical devices: */ |
| 358 | int _local_checking_phase_flag; |
| 359 | /* report received interrupt: */ |
| 360 | int _got_interrupt; |
| 361 | /* report termination-status of SCSI-command: */ |
| 362 | int _stat_result; |
| 363 | /* reset status (used only when doing reset): */ |
| 364 | int _reset_status; |
| 365 | /* code of the last SCSI command (needed for panic info): */ |
| 366 | int _last_scsi_command[MAX_LOG_DEV + 1]; |
| 367 | /* identifier of the last SCSI-command type */ |
| 368 | int _last_scsi_type[MAX_LOG_DEV + 1]; |
| 369 | /* last blockcount */ |
| 370 | int _last_scsi_blockcount[MAX_LOG_DEV + 1]; |
| 371 | /* last locgical block address */ |
| 372 | unsigned long _last_scsi_logical_block[MAX_LOG_DEV + 1]; |
| 373 | /* Counter that points on the next reassignable ldn for dynamical |
| 374 | remapping. The default value is 7, that is the first reassignable |
| 375 | number in the list at boottime: */ |
| 376 | int _next_ldn; |
| 377 | /* Statistics-structure for this IBM-SCSI-host: */ |
| 378 | struct Driver_Statistics _IBM_DS; |
| 379 | /* This hostadapters pos-registers pos2 until pos6 */ |
| 380 | unsigned int _pos[8]; |
| 381 | /* assign a special variable, that contains dedicated info about the |
| 382 | adaptertype */ |
| 383 | int _special; |
| 384 | /* connector size on the MCA bus */ |
| 385 | int _connector_size; |
| 386 | /* synchronous SCSI transfer rate bitpattern */ |
| 387 | int _adapter_speed; |
| 388 | }; |
| 389 | |
| 390 | /* macros to access host data structure */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 391 | #define subsystem_pun(h) ((h)->this_id) |
| 392 | #define subsystem_maxid(h) ((h)->max_id) |
| 393 | #define ld(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_ld) |
| 394 | #define get_ldn(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_get_ldn) |
| 395 | #define get_scsi(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_get_scsi) |
| 396 | #define local_checking_phase_flag(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_local_checking_phase_flag) |
| 397 | #define got_interrupt(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_got_interrupt) |
| 398 | #define stat_result(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_stat_result) |
| 399 | #define reset_status(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_reset_status) |
| 400 | #define last_scsi_command(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_last_scsi_command) |
| 401 | #define last_scsi_type(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_last_scsi_type) |
| 402 | #define last_scsi_blockcount(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_last_scsi_blockcount) |
| 403 | #define last_scsi_logical_block(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_last_scsi_logical_block) |
| 404 | #define last_scsi_type(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_last_scsi_type) |
| 405 | #define next_ldn(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_next_ldn) |
| 406 | #define IBM_DS(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_IBM_DS) |
| 407 | #define special(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_special) |
| 408 | #define subsystem_connector_size(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_connector_size) |
| 409 | #define adapter_speed(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_adapter_speed) |
| 410 | #define pos2(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_pos[2]) |
| 411 | #define pos3(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_pos[3]) |
| 412 | #define pos4(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_pos[4]) |
| 413 | #define pos5(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_pos[5]) |
| 414 | #define pos6(h) (((struct ibmmca_hostdata *) (h)->hostdata)->_pos[6]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | |
| 416 | /* Define a arbitrary number as subsystem-marker-type. This number is, as |
| 417 | described in the ANSI-SCSI-standard, not occupied by other device-types. */ |
| 418 | #define TYPE_IBM_SCSI_ADAPTER 0x2F |
| 419 | |
| 420 | /* Define 0xFF for no device type, because this type is not defined within |
| 421 | the ANSI-SCSI-standard, therefore, it can be used and should not cause any |
| 422 | harm. */ |
| 423 | #define TYPE_NO_DEVICE 0xFF |
| 424 | |
| 425 | /* define medium-changer. If this is not defined previously, e.g. Linux |
| 426 | 2.0.x, define this type here. */ |
| 427 | #ifndef TYPE_MEDIUM_CHANGER |
| 428 | #define TYPE_MEDIUM_CHANGER 0x08 |
| 429 | #endif |
| 430 | |
| 431 | /* define possible operations for the immediate_assign command */ |
| 432 | #define SET_LDN 0 |
| 433 | #define REMOVE_LDN 1 |
| 434 | |
| 435 | /* ldn which is used to probe the SCSI devices */ |
| 436 | #define PROBE_LDN 0 |
| 437 | |
| 438 | /* reset status flag contents */ |
| 439 | #define IM_RESET_NOT_IN_PROGRESS 0 |
| 440 | #define IM_RESET_IN_PROGRESS 1 |
| 441 | #define IM_RESET_FINISHED_OK 2 |
| 442 | #define IM_RESET_FINISHED_FAIL 3 |
| 443 | #define IM_RESET_NOT_IN_PROGRESS_NO_INT 4 |
| 444 | #define IM_RESET_FINISHED_OK_NO_INT 5 |
| 445 | |
| 446 | /* define undefined SCSI-command */ |
| 447 | #define NO_SCSI 0xffff |
| 448 | |
| 449 | /*-----------------------------------------------------------------------*/ |
| 450 | |
| 451 | /* if this is nonzero, ibmmcascsi option has been passed to the kernel */ |
| 452 | static int io_port[IM_MAX_HOSTS] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 453 | static int scsi_id[IM_MAX_HOSTS] = { 7, 7, 7, 7, 7, 7, 7, 7 }; |
| 454 | |
| 455 | /* fill module-parameters only, when this define is present. |
| 456 | (that is kernel version 2.1.x) */ |
| 457 | #if defined(MODULE) |
| 458 | static char *boot_options = NULL; |
| 459 | module_param(boot_options, charp, 0); |
| 460 | module_param_array(io_port, int, NULL, 0); |
| 461 | module_param_array(scsi_id, int, NULL, 0); |
| 462 | |
| 463 | #if 0 /* FIXME: No longer exist? --RR */ |
| 464 | MODULE_PARM(display, "1i"); |
| 465 | MODULE_PARM(adisplay, "1i"); |
| 466 | MODULE_PARM(normal, "1i"); |
| 467 | MODULE_PARM(ansi, "1i"); |
| 468 | #endif |
Randy.Dunlap | d39a942 | 2005-09-13 21:43:56 -0700 | [diff] [blame] | 469 | |
| 470 | MODULE_LICENSE("GPL"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | #endif |
| 472 | /*counter of concurrent disk read/writes, to turn on/off disk led */ |
| 473 | static int disk_rw_in_progress = 0; |
| 474 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | static unsigned int pos[8]; /* whole pos register-line for diagnosis */ |
| 476 | /* Taking into account the additions, made by ZP Gu. |
| 477 | * This selects now the preset value from the configfile and |
| 478 | * offers the 'normal' commandline option to be accepted */ |
| 479 | #ifdef CONFIG_IBMMCA_SCSI_ORDER_STANDARD |
| 480 | static char ibm_ansi_order = 1; |
| 481 | #else |
| 482 | static char ibm_ansi_order = 0; |
| 483 | #endif |
| 484 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 485 | static void issue_cmd(struct Scsi_Host *, unsigned long, unsigned char); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | static void internal_done(Scsi_Cmnd * cmd); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 487 | static void check_devices(struct Scsi_Host *, int); |
| 488 | static int immediate_assign(struct Scsi_Host *, unsigned int, unsigned int, unsigned int, unsigned int); |
| 489 | static int immediate_feature(struct Scsi_Host *, unsigned int, unsigned int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | #ifdef CONFIG_IBMMCA_SCSI_DEV_RESET |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 491 | static int immediate_reset(struct Scsi_Host *, unsigned int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | #endif |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 493 | static int device_inquiry(struct Scsi_Host *, int); |
| 494 | static int read_capacity(struct Scsi_Host *, int); |
| 495 | static int get_pos_info(struct Scsi_Host *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | static char *ti_p(int); |
| 497 | static char *ti_l(int); |
| 498 | static char *ibmrate(unsigned int, int); |
| 499 | static int probe_display(int); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 500 | static int probe_bus_mode(struct Scsi_Host *); |
| 501 | static int device_exists(struct Scsi_Host *, int, int *, int *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | static int option_setup(char *); |
| 503 | /* local functions needed for proc_info */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 504 | static int ldn_access_load(struct Scsi_Host *, int); |
| 505 | static int ldn_access_total_read_write(struct Scsi_Host *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 507 | static irqreturn_t interrupt_handler(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | unsigned int intr_reg; |
| 510 | unsigned int cmd_result; |
| 511 | unsigned int ldn; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 512 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | Scsi_Cmnd *cmd; |
| 514 | int lastSCSI; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 515 | struct device *dev = dev_id; |
| 516 | struct Scsi_Host *shpnt = dev_get_drvdata(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 518 | spin_lock_irqsave(shpnt->host_lock, flags); |
| 519 | |
| 520 | if(!(inb(IM_STAT_REG(shpnt)) & IM_INTR_REQUEST)) { |
| 521 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | return IRQ_NONE; |
| 523 | } |
| 524 | |
| 525 | /* the reset-function already did all the job, even ints got |
| 526 | renabled on the subsystem, so just return */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 527 | if ((reset_status(shpnt) == IM_RESET_NOT_IN_PROGRESS_NO_INT) || (reset_status(shpnt) == IM_RESET_FINISHED_OK_NO_INT)) { |
| 528 | reset_status(shpnt) = IM_RESET_NOT_IN_PROGRESS; |
| 529 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | return IRQ_HANDLED; |
| 531 | } |
| 532 | |
| 533 | /*must wait for attention reg not busy, then send EOI to subsystem */ |
| 534 | while (1) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 535 | if (!(inb(IM_STAT_REG(shpnt)) & IM_BUSY)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | break; |
| 537 | cpu_relax(); |
| 538 | } |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 539 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | /*get command result and logical device */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 541 | intr_reg = (unsigned char) (inb(IM_INTR_REG(shpnt))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | cmd_result = intr_reg & 0xf0; |
| 543 | ldn = intr_reg & 0x0f; |
| 544 | /* get the last_scsi_command here */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 545 | lastSCSI = last_scsi_command(shpnt)[ldn]; |
| 546 | outb(IM_EOI | ldn, IM_ATTN_REG(shpnt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | |
| 548 | /*these should never happen (hw fails, or a local programming bug) */ |
| 549 | if (!global_command_error_excuse) { |
| 550 | switch (cmd_result) { |
| 551 | /* Prevent from Ooopsing on error to show the real reason */ |
| 552 | case IM_ADAPTER_HW_FAILURE: |
| 553 | case IM_SOFTWARE_SEQUENCING_ERROR: |
| 554 | case IM_CMD_ERROR: |
| 555 | printk(KERN_ERR "IBM MCA SCSI: Fatal Subsystem ERROR!\n"); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 556 | printk(KERN_ERR " Last cmd=0x%x, ena=%x, len=", lastSCSI, ld(shpnt)[ldn].scb.enable); |
| 557 | if (ld(shpnt)[ldn].cmd) |
| 558 | printk("%ld/%ld,", (long) (ld(shpnt)[ldn].cmd->request_bufflen), (long) (ld(shpnt)[ldn].scb.sys_buf_length)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | else |
| 560 | printk("none,"); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 561 | if (ld(shpnt)[ldn].cmd) |
| 562 | printk("Blocksize=%d", ld(shpnt)[ldn].scb.u2.blk.length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | else |
| 564 | printk("Blocksize=none"); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 565 | printk(", host=%p, ldn=0x%x\n", shpnt, ldn); |
| 566 | if (ld(shpnt)[ldn].cmd) { |
| 567 | printk(KERN_ERR "Blockcount=%d/%d\n", last_scsi_blockcount(shpnt)[ldn], ld(shpnt)[ldn].scb.u2.blk.count); |
| 568 | printk(KERN_ERR "Logical block=%lx/%lx\n", last_scsi_logical_block(shpnt)[ldn], ld(shpnt)[ldn].scb.u1.log_blk_adr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | } |
| 570 | printk(KERN_ERR "Reason given: %s\n", (cmd_result == IM_ADAPTER_HW_FAILURE) ? "HARDWARE FAILURE" : (cmd_result == IM_SOFTWARE_SEQUENCING_ERROR) ? "SOFTWARE SEQUENCING ERROR" : (cmd_result == IM_CMD_ERROR) ? "COMMAND ERROR" : "UNKNOWN"); |
| 571 | /* if errors appear, enter this section to give detailed info */ |
| 572 | printk(KERN_ERR "IBM MCA SCSI: Subsystem Error-Status follows:\n"); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 573 | printk(KERN_ERR " Command Type................: %x\n", last_scsi_type(shpnt)[ldn]); |
| 574 | printk(KERN_ERR " Attention Register..........: %x\n", inb(IM_ATTN_REG(shpnt))); |
| 575 | printk(KERN_ERR " Basic Control Register......: %x\n", inb(IM_CTR_REG(shpnt))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | printk(KERN_ERR " Interrupt Status Register...: %x\n", intr_reg); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 577 | printk(KERN_ERR " Basic Status Register.......: %x\n", inb(IM_STAT_REG(shpnt))); |
| 578 | if ((last_scsi_type(shpnt)[ldn] == IM_SCB) || (last_scsi_type(shpnt)[ldn] == IM_LONG_SCB)) { |
| 579 | printk(KERN_ERR " SCB-Command.................: %x\n", ld(shpnt)[ldn].scb.command); |
| 580 | printk(KERN_ERR " SCB-Enable..................: %x\n", ld(shpnt)[ldn].scb.enable); |
| 581 | printk(KERN_ERR " SCB-logical block address...: %lx\n", ld(shpnt)[ldn].scb.u1.log_blk_adr); |
| 582 | printk(KERN_ERR " SCB-system buffer address...: %lx\n", ld(shpnt)[ldn].scb.sys_buf_adr); |
| 583 | printk(KERN_ERR " SCB-system buffer length....: %lx\n", ld(shpnt)[ldn].scb.sys_buf_length); |
| 584 | printk(KERN_ERR " SCB-tsb address.............: %lx\n", ld(shpnt)[ldn].scb.tsb_adr); |
| 585 | printk(KERN_ERR " SCB-Chain address...........: %lx\n", ld(shpnt)[ldn].scb.scb_chain_adr); |
| 586 | printk(KERN_ERR " SCB-block count.............: %x\n", ld(shpnt)[ldn].scb.u2.blk.count); |
| 587 | printk(KERN_ERR " SCB-block length............: %x\n", ld(shpnt)[ldn].scb.u2.blk.length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | } |
| 589 | printk(KERN_ERR " Send this report to the maintainer.\n"); |
| 590 | panic("IBM MCA SCSI: Fatal error message from the subsystem (0x%X,0x%X)!\n", lastSCSI, cmd_result); |
| 591 | break; |
| 592 | } |
| 593 | } else { |
| 594 | /* The command error handling is made silent, but we tell the |
| 595 | * calling function, that there is a reported error from the |
| 596 | * adapter. */ |
| 597 | switch (cmd_result) { |
| 598 | case IM_ADAPTER_HW_FAILURE: |
| 599 | case IM_SOFTWARE_SEQUENCING_ERROR: |
| 600 | case IM_CMD_ERROR: |
| 601 | global_command_error_excuse = CMD_FAIL; |
| 602 | break; |
| 603 | default: |
| 604 | global_command_error_excuse = 0; |
| 605 | break; |
| 606 | } |
| 607 | } |
| 608 | /* if no panic appeared, increase the interrupt-counter */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 609 | IBM_DS(shpnt).total_interrupts++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | /*only for local checking phase */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 611 | if (local_checking_phase_flag(shpnt)) { |
| 612 | stat_result(shpnt) = cmd_result; |
| 613 | got_interrupt(shpnt) = 1; |
| 614 | reset_status(shpnt) = IM_RESET_FINISHED_OK; |
| 615 | last_scsi_command(shpnt)[ldn] = NO_SCSI; |
| 616 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | return IRQ_HANDLED; |
| 618 | } |
| 619 | /* handling of commands coming from upper level of scsi driver */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 620 | if (last_scsi_type(shpnt)[ldn] == IM_IMM_CMD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | /* verify ldn, and may handle rare reset immediate command */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 622 | if ((reset_status(shpnt) == IM_RESET_IN_PROGRESS) && (last_scsi_command(shpnt)[ldn] == IM_RESET_IMM_CMD)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | if (cmd_result == IM_CMD_COMPLETED_WITH_FAILURE) { |
| 624 | disk_rw_in_progress = 0; |
| 625 | PS2_DISK_LED_OFF(); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 626 | reset_status(shpnt) = IM_RESET_FINISHED_FAIL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | } else { |
| 628 | /*reset disk led counter, turn off disk led */ |
| 629 | disk_rw_in_progress = 0; |
| 630 | PS2_DISK_LED_OFF(); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 631 | reset_status(shpnt) = IM_RESET_FINISHED_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | } |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 633 | stat_result(shpnt) = cmd_result; |
| 634 | last_scsi_command(shpnt)[ldn] = NO_SCSI; |
| 635 | last_scsi_type(shpnt)[ldn] = 0; |
| 636 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | return IRQ_HANDLED; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 638 | } else if (last_scsi_command(shpnt)[ldn] == IM_ABORT_IMM_CMD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | /* react on SCSI abort command */ |
| 640 | #ifdef IM_DEBUG_PROBE |
| 641 | printk("IBM MCA SCSI: Interrupt from SCSI-abort.\n"); |
| 642 | #endif |
| 643 | disk_rw_in_progress = 0; |
| 644 | PS2_DISK_LED_OFF(); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 645 | cmd = ld(shpnt)[ldn].cmd; |
| 646 | ld(shpnt)[ldn].cmd = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | if (cmd_result == IM_CMD_COMPLETED_WITH_FAILURE) |
| 648 | cmd->result = DID_NO_CONNECT << 16; |
| 649 | else |
| 650 | cmd->result = DID_ABORT << 16; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 651 | stat_result(shpnt) = cmd_result; |
| 652 | last_scsi_command(shpnt)[ldn] = NO_SCSI; |
| 653 | last_scsi_type(shpnt)[ldn] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | if (cmd->scsi_done) |
| 655 | (cmd->scsi_done) (cmd); /* should be the internal_done */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 656 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | return IRQ_HANDLED; |
| 658 | } else { |
| 659 | disk_rw_in_progress = 0; |
| 660 | PS2_DISK_LED_OFF(); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 661 | reset_status(shpnt) = IM_RESET_FINISHED_OK; |
| 662 | stat_result(shpnt) = cmd_result; |
| 663 | last_scsi_command(shpnt)[ldn] = NO_SCSI; |
| 664 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | return IRQ_HANDLED; |
| 666 | } |
| 667 | } |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 668 | last_scsi_command(shpnt)[ldn] = NO_SCSI; |
| 669 | last_scsi_type(shpnt)[ldn] = 0; |
| 670 | cmd = ld(shpnt)[ldn].cmd; |
| 671 | ld(shpnt)[ldn].cmd = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | #ifdef IM_DEBUG_TIMEOUT |
| 673 | if (cmd) { |
| 674 | if ((cmd->target == TIMEOUT_PUN) && (cmd->device->lun == TIMEOUT_LUN)) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 675 | spin_unlock_irqsave(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | printk("IBM MCA SCSI: Ignoring interrupt from pun=%x, lun=%x.\n", cmd->target, cmd->device->lun); |
| 677 | return IRQ_HANDLED; |
| 678 | } |
| 679 | } |
| 680 | #endif |
| 681 | /*if no command structure, just return, else clear cmd */ |
| 682 | if (!cmd) |
| 683 | { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 684 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | return IRQ_HANDLED; |
| 686 | } |
| 687 | |
| 688 | #ifdef IM_DEBUG_INT |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 689 | printk("cmd=%02x ireg=%02x ds=%02x cs=%02x de=%02x ce=%02x\n", cmd->cmnd[0], intr_reg, ld(shpnt)[ldn].tsb.dev_status, ld(shpnt)[ldn].tsb.cmd_status, ld(shpnt)[ldn].tsb.dev_error, ld(shpnt)[ldn].tsb.cmd_error); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | #endif |
| 691 | /*if this is end of media read/write, may turn off PS/2 disk led */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 692 | if ((ld(shpnt)[ldn].device_type != TYPE_NO_LUN) && (ld(shpnt)[ldn].device_type != TYPE_NO_DEVICE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | /* only access this, if there was a valid device addressed */ |
| 694 | if (--disk_rw_in_progress == 0) |
| 695 | PS2_DISK_LED_OFF(); |
| 696 | } |
| 697 | |
| 698 | /* IBM describes the status-mask to be 0x1e, but this is not conform |
| 699 | * with SCSI-definition, I suppose, the reason for it is that IBM |
| 700 | * adapters do not support CMD_TERMINATED, TASK_SET_FULL and |
| 701 | * ACA_ACTIVE as returning statusbyte information. (ML) */ |
| 702 | if (cmd_result == IM_CMD_COMPLETED_WITH_FAILURE) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 703 | cmd->result = (unsigned char) (ld(shpnt)[ldn].tsb.dev_status & 0x1e); |
| 704 | IBM_DS(shpnt).total_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | } else |
| 706 | cmd->result = 0; |
| 707 | /* write device status into cmd->result, and call done function */ |
| 708 | if (lastSCSI == NO_SCSI) { /* unexpected interrupt :-( */ |
| 709 | cmd->result |= DID_BAD_INTR << 16; |
| 710 | printk("IBM MCA SCSI: WARNING - Interrupt from non-pending SCSI-command!\n"); |
| 711 | } else /* things went right :-) */ |
| 712 | cmd->result |= DID_OK << 16; |
| 713 | if (cmd->scsi_done) |
| 714 | (cmd->scsi_done) (cmd); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 715 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | return IRQ_HANDLED; |
| 717 | } |
| 718 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 719 | static void issue_cmd(struct Scsi_Host *shpnt, unsigned long cmd_reg, |
| 720 | unsigned char attn_reg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | { |
| 722 | unsigned long flags; |
| 723 | /* must wait for attention reg not busy */ |
| 724 | while (1) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 725 | spin_lock_irqsave(shpnt->host_lock, flags); |
| 726 | if (!(inb(IM_STAT_REG(shpnt)) & IM_BUSY)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | break; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 728 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | } |
| 730 | /* write registers and enable system interrupts */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 731 | outl(cmd_reg, IM_CMD_REG(shpnt)); |
| 732 | outb(attn_reg, IM_ATTN_REG(shpnt)); |
| 733 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | static void internal_done(Scsi_Cmnd * cmd) |
| 737 | { |
| 738 | cmd->SCp.Status++; |
| 739 | return; |
| 740 | } |
| 741 | |
| 742 | /* SCSI-SCB-command for device_inquiry */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 743 | static int device_inquiry(struct Scsi_Host *shpnt, int ldn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | { |
| 745 | int retr; |
| 746 | struct im_scb *scb; |
| 747 | struct im_tsb *tsb; |
| 748 | unsigned char *buf; |
| 749 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 750 | scb = &(ld(shpnt)[ldn].scb); |
| 751 | tsb = &(ld(shpnt)[ldn].tsb); |
| 752 | buf = (unsigned char *) (&(ld(shpnt)[ldn].buf)); |
| 753 | ld(shpnt)[ldn].tsb.dev_status = 0; /* prepare statusblock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | for (retr = 0; retr < 3; retr++) { |
| 755 | /* fill scb with inquiry command */ |
| 756 | scb->command = IM_DEVICE_INQUIRY_CMD | IM_NO_DISCONNECT; |
| 757 | scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_RETRY_ENABLE | IM_BYPASS_BUFFER; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 758 | last_scsi_command(shpnt)[ldn] = IM_DEVICE_INQUIRY_CMD; |
| 759 | last_scsi_type(shpnt)[ldn] = IM_SCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | scb->sys_buf_adr = isa_virt_to_bus(buf); |
| 761 | scb->sys_buf_length = 255; /* maximum bufferlength gives max info */ |
| 762 | scb->tsb_adr = isa_virt_to_bus(tsb); |
| 763 | /* issue scb to passed ldn, and busy wait for interrupt */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 764 | got_interrupt(shpnt) = 0; |
| 765 | issue_cmd(shpnt, isa_virt_to_bus(scb), IM_SCB | ldn); |
| 766 | while (!got_interrupt(shpnt)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | barrier(); |
| 768 | |
Andreas Mohr | d6e05ed | 2006-06-26 18:35:02 +0200 | [diff] [blame] | 769 | /*if command successful, break */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 770 | if ((stat_result(shpnt) == IM_SCB_CMD_COMPLETED) || (stat_result(shpnt) == IM_SCB_CMD_COMPLETED_WITH_RETRIES)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | return 1; |
| 772 | } |
| 773 | /*if all three retries failed, return "no device at this ldn" */ |
| 774 | if (retr >= 3) |
| 775 | return 0; |
| 776 | else |
| 777 | return 1; |
| 778 | } |
| 779 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 780 | static int read_capacity(struct Scsi_Host *shpnt, int ldn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | { |
| 782 | int retr; |
| 783 | struct im_scb *scb; |
| 784 | struct im_tsb *tsb; |
| 785 | unsigned char *buf; |
| 786 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 787 | scb = &(ld(shpnt)[ldn].scb); |
| 788 | tsb = &(ld(shpnt)[ldn].tsb); |
| 789 | buf = (unsigned char *) (&(ld(shpnt)[ldn].buf)); |
| 790 | ld(shpnt)[ldn].tsb.dev_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | for (retr = 0; retr < 3; retr++) { |
| 792 | /*fill scb with read capacity command */ |
| 793 | scb->command = IM_READ_CAPACITY_CMD; |
| 794 | scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_READ_CONTROL | IM_RETRY_ENABLE | IM_BYPASS_BUFFER; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 795 | last_scsi_command(shpnt)[ldn] = IM_READ_CAPACITY_CMD; |
| 796 | last_scsi_type(shpnt)[ldn] = IM_SCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | scb->sys_buf_adr = isa_virt_to_bus(buf); |
| 798 | scb->sys_buf_length = 8; |
| 799 | scb->tsb_adr = isa_virt_to_bus(tsb); |
| 800 | /*issue scb to passed ldn, and busy wait for interrupt */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 801 | got_interrupt(shpnt) = 0; |
| 802 | issue_cmd(shpnt, isa_virt_to_bus(scb), IM_SCB | ldn); |
| 803 | while (!got_interrupt(shpnt)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | barrier(); |
| 805 | |
| 806 | /*if got capacity, get block length and return one device found */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 807 | if ((stat_result(shpnt) == IM_SCB_CMD_COMPLETED) || (stat_result(shpnt) == IM_SCB_CMD_COMPLETED_WITH_RETRIES)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | return 1; |
| 809 | } |
| 810 | /*if all three retries failed, return "no device at this ldn" */ |
| 811 | if (retr >= 3) |
| 812 | return 0; |
| 813 | else |
| 814 | return 1; |
| 815 | } |
| 816 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 817 | static int get_pos_info(struct Scsi_Host *shpnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | { |
| 819 | int retr; |
| 820 | struct im_scb *scb; |
| 821 | struct im_tsb *tsb; |
| 822 | unsigned char *buf; |
| 823 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 824 | scb = &(ld(shpnt)[MAX_LOG_DEV].scb); |
| 825 | tsb = &(ld(shpnt)[MAX_LOG_DEV].tsb); |
| 826 | buf = (unsigned char *) (&(ld(shpnt)[MAX_LOG_DEV].buf)); |
| 827 | ld(shpnt)[MAX_LOG_DEV].tsb.dev_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | for (retr = 0; retr < 3; retr++) { |
| 829 | /*fill scb with get_pos_info command */ |
| 830 | scb->command = IM_GET_POS_INFO_CMD; |
| 831 | scb->enable = IM_READ_CONTROL | IM_REPORT_TSB_ONLY_ON_ERROR | IM_RETRY_ENABLE | IM_BYPASS_BUFFER; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 832 | last_scsi_command(shpnt)[MAX_LOG_DEV] = IM_GET_POS_INFO_CMD; |
| 833 | last_scsi_type(shpnt)[MAX_LOG_DEV] = IM_SCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | scb->sys_buf_adr = isa_virt_to_bus(buf); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 835 | if (special(shpnt) == IBM_SCSI2_FW) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | scb->sys_buf_length = 256; /* get all info from F/W adapter */ |
| 837 | else |
| 838 | scb->sys_buf_length = 18; /* get exactly 18 bytes for other SCSI */ |
| 839 | scb->tsb_adr = isa_virt_to_bus(tsb); |
| 840 | /*issue scb to ldn=15, and busy wait for interrupt */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 841 | got_interrupt(shpnt) = 0; |
| 842 | issue_cmd(shpnt, isa_virt_to_bus(scb), IM_SCB | MAX_LOG_DEV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | |
| 844 | /* FIXME: timeout */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 845 | while (!got_interrupt(shpnt)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | barrier(); |
| 847 | |
| 848 | /*if got POS-stuff, get block length and return one device found */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 849 | if ((stat_result(shpnt) == IM_SCB_CMD_COMPLETED) || (stat_result(shpnt) == IM_SCB_CMD_COMPLETED_WITH_RETRIES)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | return 1; |
| 851 | } |
| 852 | /* if all three retries failed, return "no device at this ldn" */ |
| 853 | if (retr >= 3) |
| 854 | return 0; |
| 855 | else |
| 856 | return 1; |
| 857 | } |
| 858 | |
| 859 | /* SCSI-immediate-command for assign. This functions maps/unmaps specific |
| 860 | ldn-numbers on SCSI (PUN,LUN). It is needed for presetting of the |
| 861 | subsystem and for dynamical remapping od ldns. */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 862 | static int immediate_assign(struct Scsi_Host *shpnt, unsigned int pun, |
| 863 | unsigned int lun, unsigned int ldn, |
| 864 | unsigned int operation) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | { |
| 866 | int retr; |
| 867 | unsigned long imm_cmd; |
| 868 | |
| 869 | for (retr = 0; retr < 3; retr++) { |
| 870 | /* select mutation level of the SCSI-adapter */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 871 | switch (special(shpnt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | case IBM_SCSI2_FW: |
| 873 | imm_cmd = (unsigned long) (IM_ASSIGN_IMM_CMD); |
| 874 | imm_cmd |= (unsigned long) ((lun & 7) << 24); |
| 875 | imm_cmd |= (unsigned long) ((operation & 1) << 23); |
| 876 | imm_cmd |= (unsigned long) ((pun & 7) << 20) | ((pun & 8) << 24); |
| 877 | imm_cmd |= (unsigned long) ((ldn & 15) << 16); |
| 878 | break; |
| 879 | default: |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 880 | imm_cmd = inl(IM_CMD_REG(shpnt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | imm_cmd &= (unsigned long) (0xF8000000); /* keep reserved bits */ |
| 882 | imm_cmd |= (unsigned long) (IM_ASSIGN_IMM_CMD); |
| 883 | imm_cmd |= (unsigned long) ((lun & 7) << 24); |
| 884 | imm_cmd |= (unsigned long) ((operation & 1) << 23); |
| 885 | imm_cmd |= (unsigned long) ((pun & 7) << 20); |
| 886 | imm_cmd |= (unsigned long) ((ldn & 15) << 16); |
| 887 | break; |
| 888 | } |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 889 | last_scsi_command(shpnt)[MAX_LOG_DEV] = IM_ASSIGN_IMM_CMD; |
| 890 | last_scsi_type(shpnt)[MAX_LOG_DEV] = IM_IMM_CMD; |
| 891 | got_interrupt(shpnt) = 0; |
| 892 | issue_cmd(shpnt, (unsigned long) (imm_cmd), IM_IMM_CMD | MAX_LOG_DEV); |
| 893 | while (!got_interrupt(shpnt)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | barrier(); |
| 895 | |
Andreas Mohr | d6e05ed | 2006-06-26 18:35:02 +0200 | [diff] [blame] | 896 | /*if command successful, break */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 897 | if (stat_result(shpnt) == IM_IMMEDIATE_CMD_COMPLETED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | return 1; |
| 899 | } |
| 900 | if (retr >= 3) |
| 901 | return 0; |
| 902 | else |
| 903 | return 1; |
| 904 | } |
| 905 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 906 | static int immediate_feature(struct Scsi_Host *shpnt, unsigned int speed, unsigned int timeout) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | { |
| 908 | int retr; |
| 909 | unsigned long imm_cmd; |
| 910 | |
| 911 | for (retr = 0; retr < 3; retr++) { |
| 912 | /* select mutation level of the SCSI-adapter */ |
| 913 | imm_cmd = IM_FEATURE_CTR_IMM_CMD; |
| 914 | imm_cmd |= (unsigned long) ((speed & 0x7) << 29); |
| 915 | imm_cmd |= (unsigned long) ((timeout & 0x1fff) << 16); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 916 | last_scsi_command(shpnt)[MAX_LOG_DEV] = IM_FEATURE_CTR_IMM_CMD; |
| 917 | last_scsi_type(shpnt)[MAX_LOG_DEV] = IM_IMM_CMD; |
| 918 | got_interrupt(shpnt) = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | /* we need to run into command errors in order to probe for the |
| 920 | * right speed! */ |
| 921 | global_command_error_excuse = 1; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 922 | issue_cmd(shpnt, (unsigned long) (imm_cmd), IM_IMM_CMD | MAX_LOG_DEV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | |
| 924 | /* FIXME: timeout */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 925 | while (!got_interrupt(shpnt)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | barrier(); |
| 927 | if (global_command_error_excuse == CMD_FAIL) { |
| 928 | global_command_error_excuse = 0; |
| 929 | return 2; |
| 930 | } else |
| 931 | global_command_error_excuse = 0; |
Andreas Mohr | d6e05ed | 2006-06-26 18:35:02 +0200 | [diff] [blame] | 932 | /*if command successful, break */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 933 | if (stat_result(shpnt) == IM_IMMEDIATE_CMD_COMPLETED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | return 1; |
| 935 | } |
| 936 | if (retr >= 3) |
| 937 | return 0; |
| 938 | else |
| 939 | return 1; |
| 940 | } |
| 941 | |
| 942 | #ifdef CONFIG_IBMMCA_SCSI_DEV_RESET |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 943 | static int immediate_reset(struct Scsi_Host *shpnt, unsigned int ldn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | { |
| 945 | int retries; |
| 946 | int ticks; |
| 947 | unsigned long imm_command; |
| 948 | |
| 949 | for (retries = 0; retries < 3; retries++) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 950 | imm_command = inl(IM_CMD_REG(shpnt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | imm_command &= (unsigned long) (0xFFFF0000); /* keep reserved bits */ |
| 952 | imm_command |= (unsigned long) (IM_RESET_IMM_CMD); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 953 | last_scsi_command(shpnt)[ldn] = IM_RESET_IMM_CMD; |
| 954 | last_scsi_type(shpnt)[ldn] = IM_IMM_CMD; |
| 955 | got_interrupt(shpnt) = 0; |
| 956 | reset_status(shpnt) = IM_RESET_IN_PROGRESS; |
| 957 | issue_cmd(shpnt, (unsigned long) (imm_command), IM_IMM_CMD | ldn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | ticks = IM_RESET_DELAY * HZ; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 959 | while (reset_status(shpnt) == IM_RESET_IN_PROGRESS && --ticks) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | udelay((1 + 999 / HZ) * 1000); |
| 961 | barrier(); |
| 962 | } |
| 963 | /* if reset did not complete, just complain */ |
| 964 | if (!ticks) { |
| 965 | printk(KERN_ERR "IBM MCA SCSI: reset did not complete within %d seconds.\n", IM_RESET_DELAY); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 966 | reset_status(shpnt) = IM_RESET_FINISHED_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | /* did not work, finish */ |
| 968 | return 1; |
| 969 | } |
Andreas Mohr | d6e05ed | 2006-06-26 18:35:02 +0200 | [diff] [blame] | 970 | /*if command successful, break */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 971 | if (stat_result(shpnt) == IM_IMMEDIATE_CMD_COMPLETED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | return 1; |
| 973 | } |
| 974 | if (retries >= 3) |
| 975 | return 0; |
| 976 | else |
| 977 | return 1; |
| 978 | } |
| 979 | #endif |
| 980 | |
| 981 | /* type-interpreter for physical device numbers */ |
| 982 | static char *ti_p(int dev) |
| 983 | { |
| 984 | switch (dev) { |
| 985 | case TYPE_IBM_SCSI_ADAPTER: |
| 986 | return ("A"); |
| 987 | case TYPE_DISK: |
| 988 | return ("D"); |
| 989 | case TYPE_TAPE: |
| 990 | return ("T"); |
| 991 | case TYPE_PROCESSOR: |
| 992 | return ("P"); |
| 993 | case TYPE_WORM: |
| 994 | return ("W"); |
| 995 | case TYPE_ROM: |
| 996 | return ("R"); |
| 997 | case TYPE_SCANNER: |
| 998 | return ("S"); |
| 999 | case TYPE_MOD: |
| 1000 | return ("M"); |
| 1001 | case TYPE_MEDIUM_CHANGER: |
| 1002 | return ("C"); |
| 1003 | case TYPE_NO_LUN: |
| 1004 | return ("+"); /* show NO_LUN */ |
| 1005 | } |
| 1006 | return ("-"); /* TYPE_NO_DEVICE and others */ |
| 1007 | } |
| 1008 | |
| 1009 | /* interpreter for logical device numbers (ldn) */ |
| 1010 | static char *ti_l(int val) |
| 1011 | { |
| 1012 | const char hex[16] = "0123456789abcdef"; |
| 1013 | static char answer[2]; |
| 1014 | |
| 1015 | answer[1] = (char) (0x0); |
| 1016 | if (val <= MAX_LOG_DEV) |
| 1017 | answer[0] = hex[val]; |
| 1018 | else |
| 1019 | answer[0] = '-'; |
| 1020 | return (char *) &answer; |
| 1021 | } |
| 1022 | |
| 1023 | /* transfers bitpattern of the feature command to values in MHz */ |
| 1024 | static char *ibmrate(unsigned int speed, int i) |
| 1025 | { |
| 1026 | switch (speed) { |
| 1027 | case 0: |
| 1028 | return i ? "5.00" : "10.00"; |
| 1029 | case 1: |
| 1030 | return i ? "4.00" : "8.00"; |
| 1031 | case 2: |
| 1032 | return i ? "3.33" : "6.66"; |
| 1033 | case 3: |
| 1034 | return i ? "2.86" : "5.00"; |
| 1035 | case 4: |
| 1036 | return i ? "2.50" : "4.00"; |
| 1037 | case 5: |
| 1038 | return i ? "2.22" : "3.10"; |
| 1039 | case 6: |
| 1040 | return i ? "2.00" : "2.50"; |
| 1041 | case 7: |
| 1042 | return i ? "1.82" : "2.00"; |
| 1043 | } |
| 1044 | return "---"; |
| 1045 | } |
| 1046 | |
| 1047 | static int probe_display(int what) |
| 1048 | { |
| 1049 | static int rotator = 0; |
| 1050 | const char rotor[] = "|/-\\"; |
| 1051 | |
| 1052 | if (!(display_mode & LED_DISP)) |
| 1053 | return 0; |
| 1054 | if (!what) { |
| 1055 | outl(0x20202020, MOD95_LED_PORT); |
| 1056 | outl(0x20202020, MOD95_LED_PORT + 4); |
| 1057 | } else { |
| 1058 | outb('S', MOD95_LED_PORT + 7); |
| 1059 | outb('C', MOD95_LED_PORT + 6); |
| 1060 | outb('S', MOD95_LED_PORT + 5); |
| 1061 | outb('I', MOD95_LED_PORT + 4); |
| 1062 | outb('i', MOD95_LED_PORT + 3); |
| 1063 | outb('n', MOD95_LED_PORT + 2); |
| 1064 | outb('i', MOD95_LED_PORT + 1); |
| 1065 | outb((char) (rotor[rotator]), MOD95_LED_PORT); |
| 1066 | rotator++; |
| 1067 | if (rotator > 3) |
| 1068 | rotator = 0; |
| 1069 | } |
| 1070 | return 0; |
| 1071 | } |
| 1072 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1073 | static int probe_bus_mode(struct Scsi_Host *shpnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | { |
| 1075 | struct im_pos_info *info; |
| 1076 | int num_bus = 0; |
| 1077 | int ldn; |
| 1078 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1079 | info = (struct im_pos_info *) (&(ld(shpnt)[MAX_LOG_DEV].buf)); |
| 1080 | if (get_pos_info(shpnt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | if (info->connector_size & 0xf000) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1082 | subsystem_connector_size(shpnt) = 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | else |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1084 | subsystem_connector_size(shpnt) = 32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | num_bus |= (info->pos_4b & 8) >> 3; |
| 1086 | for (ldn = 0; ldn <= MAX_LOG_DEV; ldn++) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1087 | if ((special(shpnt) == IBM_SCSI_WCACHE) || (special(shpnt) == IBM_7568_WCACHE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | if (!((info->cache_stat >> ldn) & 1)) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1089 | ld(shpnt)[ldn].cache_flag = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1090 | } |
| 1091 | if (!((info->retry_stat >> ldn) & 1)) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1092 | ld(shpnt)[ldn].retry_flag = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | } |
| 1094 | #ifdef IM_DEBUG_PROBE |
| 1095 | printk("IBM MCA SCSI: SCSI-Cache bits: "); |
| 1096 | for (ldn = 0; ldn <= MAX_LOG_DEV; ldn++) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1097 | printk("%d", ld(shpnt)[ldn].cache_flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1098 | } |
| 1099 | printk("\nIBM MCA SCSI: SCSI-Retry bits: "); |
| 1100 | for (ldn = 0; ldn <= MAX_LOG_DEV; ldn++) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1101 | printk("%d", ld(shpnt)[ldn].retry_flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | } |
| 1103 | printk("\n"); |
| 1104 | #endif |
| 1105 | } |
| 1106 | return num_bus; |
| 1107 | } |
| 1108 | |
| 1109 | /* probing scsi devices */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1110 | static void check_devices(struct Scsi_Host *shpnt, int adaptertype) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | { |
| 1112 | int id, lun, ldn, ticks; |
| 1113 | int count_devices; /* local counter for connected device */ |
| 1114 | int max_pun; |
| 1115 | int num_bus; |
| 1116 | int speedrun; /* local adapter_speed check variable */ |
| 1117 | |
| 1118 | /* assign default values to certain variables */ |
| 1119 | ticks = 0; |
| 1120 | count_devices = 0; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1121 | IBM_DS(shpnt).dyn_flag = 0; /* normally no need for dynamical ldn management */ |
| 1122 | IBM_DS(shpnt).total_errors = 0; /* set errorcounter to 0 */ |
| 1123 | next_ldn(shpnt) = 7; /* next ldn to be assigned is 7, because 0-6 is 'hardwired' */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | |
| 1125 | /* initialize the very important driver-informational arrays/structs */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1126 | memset(ld(shpnt), 0, sizeof(ld(shpnt))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | for (ldn = 0; ldn <= MAX_LOG_DEV; ldn++) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1128 | last_scsi_command(shpnt)[ldn] = NO_SCSI; /* emptify last SCSI-command storage */ |
| 1129 | last_scsi_type(shpnt)[ldn] = 0; |
| 1130 | ld(shpnt)[ldn].cache_flag = 1; |
| 1131 | ld(shpnt)[ldn].retry_flag = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | } |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1133 | memset(get_ldn(shpnt), TYPE_NO_DEVICE, sizeof(get_ldn(shpnt))); /* this is essential ! */ |
| 1134 | memset(get_scsi(shpnt), TYPE_NO_DEVICE, sizeof(get_scsi(shpnt))); /* this is essential ! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | for (lun = 0; lun < 8; lun++) { |
| 1136 | /* mark the adapter at its pun on all luns */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1137 | get_scsi(shpnt)[subsystem_pun(shpnt)][lun] = TYPE_IBM_SCSI_ADAPTER; |
| 1138 | get_ldn(shpnt)[subsystem_pun(shpnt)][lun] = MAX_LOG_DEV; /* make sure, the subsystem |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1139 | ldn is active for all |
| 1140 | luns. */ |
| 1141 | } |
| 1142 | probe_display(0); /* Supercool display usage during SCSI-probing. */ |
| 1143 | /* This makes sense, when booting without any */ |
| 1144 | /* monitor connected on model XX95. */ |
| 1145 | |
| 1146 | /* STEP 1: */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1147 | adapter_speed(shpnt) = global_adapter_speed; |
| 1148 | speedrun = adapter_speed(shpnt); |
| 1149 | while (immediate_feature(shpnt, speedrun, adapter_timeout) == 2) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | probe_display(1); |
| 1151 | if (speedrun == 7) |
| 1152 | panic("IBM MCA SCSI: Cannot set Synchronous-Transfer-Rate!\n"); |
| 1153 | speedrun++; |
| 1154 | if (speedrun > 7) |
| 1155 | speedrun = 7; |
| 1156 | } |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1157 | adapter_speed(shpnt) = speedrun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | /* Get detailed information about the current adapter, necessary for |
| 1159 | * device operations: */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1160 | num_bus = probe_bus_mode(shpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | |
| 1162 | /* num_bus contains only valid data for the F/W adapter! */ |
| 1163 | if (adaptertype == IBM_SCSI2_FW) { /* F/W SCSI adapter: */ |
| 1164 | /* F/W adapter PUN-space extension evaluation: */ |
| 1165 | if (num_bus) { |
| 1166 | printk(KERN_INFO "IBM MCA SCSI: Separate bus mode (wide-addressing enabled)\n"); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1167 | subsystem_maxid(shpnt) = 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | } else { |
| 1169 | printk(KERN_INFO "IBM MCA SCSI: Combined bus mode (wide-addressing disabled)\n"); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1170 | subsystem_maxid(shpnt) = 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | } |
| 1172 | printk(KERN_INFO "IBM MCA SCSI: Sync.-Rate (F/W: 20, Int.: 10, Ext.: %s) MBytes/s\n", ibmrate(speedrun, adaptertype)); |
| 1173 | } else /* all other IBM SCSI adapters: */ |
| 1174 | printk(KERN_INFO "IBM MCA SCSI: Synchronous-SCSI-Transfer-Rate: %s MBytes/s\n", ibmrate(speedrun, adaptertype)); |
| 1175 | |
| 1176 | /* assign correct PUN device space */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1177 | max_pun = subsystem_maxid(shpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | |
| 1179 | #ifdef IM_DEBUG_PROBE |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1180 | printk("IBM MCA SCSI: Current SCSI-host index: %d\n", shpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | printk("IBM MCA SCSI: Removing default logical SCSI-device mapping."); |
| 1182 | #else |
| 1183 | printk(KERN_INFO "IBM MCA SCSI: Dev. Order: %s, Mapping (takes <2min): ", (ibm_ansi_order) ? "ANSI" : "New"); |
| 1184 | #endif |
| 1185 | for (ldn = 0; ldn < MAX_LOG_DEV; ldn++) { |
| 1186 | probe_display(1); |
| 1187 | #ifdef IM_DEBUG_PROBE |
| 1188 | printk("."); |
| 1189 | #endif |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1190 | immediate_assign(shpnt, 0, 0, ldn, REMOVE_LDN); /* remove ldn (wherever) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | } |
| 1192 | lun = 0; /* default lun is 0 */ |
| 1193 | #ifndef IM_DEBUG_PROBE |
| 1194 | printk("cleared,"); |
| 1195 | #endif |
| 1196 | /* STEP 2: */ |
| 1197 | #ifdef IM_DEBUG_PROBE |
| 1198 | printk("\nIBM MCA SCSI: Scanning SCSI-devices."); |
| 1199 | #endif |
| 1200 | for (id = 0; id < max_pun; id++) |
| 1201 | #ifdef CONFIG_SCSI_MULTI_LUN |
| 1202 | for (lun = 0; lun < 8; lun++) |
| 1203 | #endif |
| 1204 | { |
| 1205 | probe_display(1); |
| 1206 | #ifdef IM_DEBUG_PROBE |
| 1207 | printk("."); |
| 1208 | #endif |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1209 | if (id != subsystem_pun(shpnt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | /* if pun is not the adapter: */ |
| 1211 | /* set ldn=0 to pun,lun */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1212 | immediate_assign(shpnt, id, lun, PROBE_LDN, SET_LDN); |
| 1213 | if (device_inquiry(shpnt, PROBE_LDN)) { /* probe device */ |
| 1214 | get_scsi(shpnt)[id][lun] = (unsigned char) (ld(shpnt)[PROBE_LDN].buf[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | /* entry, even for NO_LUN */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1216 | if (ld(shpnt)[PROBE_LDN].buf[0] != TYPE_NO_LUN) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | count_devices++; /* a existing device is found */ |
| 1218 | } |
| 1219 | /* remove ldn */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1220 | immediate_assign(shpnt, id, lun, PROBE_LDN, REMOVE_LDN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | } |
| 1222 | } |
| 1223 | #ifndef IM_DEBUG_PROBE |
| 1224 | printk("scanned,"); |
| 1225 | #endif |
| 1226 | /* STEP 3: */ |
| 1227 | #ifdef IM_DEBUG_PROBE |
| 1228 | printk("\nIBM MCA SCSI: Mapping SCSI-devices."); |
| 1229 | #endif |
| 1230 | ldn = 0; |
| 1231 | lun = 0; |
| 1232 | #ifdef CONFIG_SCSI_MULTI_LUN |
| 1233 | for (lun = 0; lun < 8 && ldn < MAX_LOG_DEV; lun++) |
| 1234 | #endif |
| 1235 | for (id = 0; id < max_pun && ldn < MAX_LOG_DEV; id++) { |
| 1236 | probe_display(1); |
| 1237 | #ifdef IM_DEBUG_PROBE |
| 1238 | printk("."); |
| 1239 | #endif |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1240 | if (id != subsystem_pun(shpnt)) { |
| 1241 | if (get_scsi(shpnt)[id][lun] != TYPE_NO_LUN && get_scsi(shpnt)[id][lun] != TYPE_NO_DEVICE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | /* Only map if accepted type. Always enter for |
| 1243 | lun == 0 to get no gaps into ldn-mapping for ldn<7. */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1244 | immediate_assign(shpnt, id, lun, ldn, SET_LDN); |
| 1245 | get_ldn(shpnt)[id][lun] = ldn; /* map ldn */ |
| 1246 | if (device_exists(shpnt, ldn, &ld(shpnt)[ldn].block_length, &ld(shpnt)[ldn].device_type)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | #ifdef CONFIG_IBMMCA_SCSI_DEV_RESET |
| 1248 | printk("resetting device at ldn=%x ... ", ldn); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1249 | immediate_reset(shpnt, ldn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1250 | #endif |
| 1251 | ldn++; |
| 1252 | } else { |
| 1253 | /* device vanished, probably because we don't know how to |
| 1254 | * handle it or because it has problems */ |
| 1255 | if (lun > 0) { |
| 1256 | /* remove mapping */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1257 | get_ldn(shpnt)[id][lun] = TYPE_NO_DEVICE; |
| 1258 | immediate_assign(shpnt, 0, 0, ldn, REMOVE_LDN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | } else |
| 1260 | ldn++; |
| 1261 | } |
| 1262 | } else if (lun == 0) { |
| 1263 | /* map lun == 0, even if no device exists */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1264 | immediate_assign(shpnt, id, lun, ldn, SET_LDN); |
| 1265 | get_ldn(shpnt)[id][lun] = ldn; /* map ldn */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | ldn++; |
| 1267 | } |
| 1268 | } |
| 1269 | } |
| 1270 | /* STEP 4: */ |
| 1271 | |
| 1272 | /* map remaining ldns to non-existing devices */ |
| 1273 | for (lun = 1; lun < 8 && ldn < MAX_LOG_DEV; lun++) |
| 1274 | for (id = 0; id < max_pun && ldn < MAX_LOG_DEV; id++) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1275 | if (get_scsi(shpnt)[id][lun] == TYPE_NO_LUN || get_scsi(shpnt)[id][lun] == TYPE_NO_DEVICE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | probe_display(1); |
| 1277 | /* Map remaining ldns only to NON-existing pun,lun |
| 1278 | combinations to make sure an inquiry will fail. |
| 1279 | For MULTI_LUN, it is needed to avoid adapter autonome |
| 1280 | SCSI-remapping. */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1281 | immediate_assign(shpnt, id, lun, ldn, SET_LDN); |
| 1282 | get_ldn(shpnt)[id][lun] = ldn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1283 | ldn++; |
| 1284 | } |
| 1285 | } |
| 1286 | #ifndef IM_DEBUG_PROBE |
| 1287 | printk("mapped."); |
| 1288 | #endif |
| 1289 | printk("\n"); |
| 1290 | #ifdef IM_DEBUG_PROBE |
| 1291 | if (ibm_ansi_order) |
| 1292 | printk("IBM MCA SCSI: Device order: IBM/ANSI (pun=7 is first).\n"); |
| 1293 | else |
| 1294 | printk("IBM MCA SCSI: Device order: New Industry Standard (pun=0 is first).\n"); |
| 1295 | #endif |
| 1296 | |
| 1297 | #ifdef IM_DEBUG_PROBE |
| 1298 | /* Show the physical and logical mapping during boot. */ |
| 1299 | printk("IBM MCA SCSI: Determined SCSI-device-mapping:\n"); |
| 1300 | printk(" Physical SCSI-Device Map Logical SCSI-Device Map\n"); |
| 1301 | printk("ID\\LUN 0 1 2 3 4 5 6 7 ID\\LUN 0 1 2 3 4 5 6 7\n"); |
| 1302 | for (id = 0; id < max_pun; id++) { |
| 1303 | printk("%2d ", id); |
| 1304 | for (lun = 0; lun < 8; lun++) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1305 | printk("%2s ", ti_p(get_scsi(shpnt)[id][lun])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | printk(" %2d ", id); |
| 1307 | for (lun = 0; lun < 8; lun++) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1308 | printk("%2s ", ti_l(get_ldn(shpnt)[id][lun])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | printk("\n"); |
| 1310 | } |
| 1311 | #endif |
| 1312 | |
| 1313 | /* assign total number of found SCSI-devices to the statistics struct */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1314 | IBM_DS(shpnt).total_scsi_devices = count_devices; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | |
| 1316 | /* decide for output in /proc-filesystem, if the configuration of |
| 1317 | SCSI-devices makes dynamical reassignment of devices necessary */ |
| 1318 | if (count_devices >= MAX_LOG_DEV) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1319 | IBM_DS(shpnt).dyn_flag = 1; /* dynamical assignment is necessary */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | else |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1321 | IBM_DS(shpnt).dyn_flag = 0; /* dynamical assignment is not necessary */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | |
| 1323 | /* If no SCSI-devices are assigned, return 1 in order to cause message. */ |
| 1324 | if (ldn == 0) |
| 1325 | printk("IBM MCA SCSI: Warning: No SCSI-devices found/assigned!\n"); |
| 1326 | |
| 1327 | /* reset the counters for statistics on the current adapter */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1328 | IBM_DS(shpnt).scbs = 0; |
| 1329 | IBM_DS(shpnt).long_scbs = 0; |
| 1330 | IBM_DS(shpnt).total_accesses = 0; |
| 1331 | IBM_DS(shpnt).total_interrupts = 0; |
| 1332 | IBM_DS(shpnt).dynamical_assignments = 0; |
| 1333 | memset(IBM_DS(shpnt).ldn_access, 0x0, sizeof(IBM_DS(shpnt).ldn_access)); |
| 1334 | memset(IBM_DS(shpnt).ldn_read_access, 0x0, sizeof(IBM_DS(shpnt).ldn_read_access)); |
| 1335 | memset(IBM_DS(shpnt).ldn_write_access, 0x0, sizeof(IBM_DS(shpnt).ldn_write_access)); |
| 1336 | memset(IBM_DS(shpnt).ldn_inquiry_access, 0x0, sizeof(IBM_DS(shpnt).ldn_inquiry_access)); |
| 1337 | memset(IBM_DS(shpnt).ldn_modeselect_access, 0x0, sizeof(IBM_DS(shpnt).ldn_modeselect_access)); |
| 1338 | memset(IBM_DS(shpnt).ldn_assignments, 0x0, sizeof(IBM_DS(shpnt).ldn_assignments)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | probe_display(0); |
| 1340 | return; |
| 1341 | } |
| 1342 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1343 | static int device_exists(struct Scsi_Host *shpnt, int ldn, int *block_length, int *device_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | { |
| 1345 | unsigned char *buf; |
| 1346 | /* if no valid device found, return immediately with 0 */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1347 | if (!(device_inquiry(shpnt, ldn))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | return 0; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1349 | buf = (unsigned char *) (&(ld(shpnt)[ldn].buf)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | if (*buf == TYPE_ROM) { |
| 1351 | *device_type = TYPE_ROM; |
| 1352 | *block_length = 2048; /* (standard blocksize for yellow-/red-book) */ |
| 1353 | return 1; |
| 1354 | } |
| 1355 | if (*buf == TYPE_WORM) { |
| 1356 | *device_type = TYPE_WORM; |
| 1357 | *block_length = 2048; |
| 1358 | return 1; |
| 1359 | } |
| 1360 | if (*buf == TYPE_DISK) { |
| 1361 | *device_type = TYPE_DISK; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1362 | if (read_capacity(shpnt, ldn)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1363 | *block_length = *(buf + 7) + (*(buf + 6) << 8) + (*(buf + 5) << 16) + (*(buf + 4) << 24); |
| 1364 | return 1; |
| 1365 | } else |
| 1366 | return 0; |
| 1367 | } |
| 1368 | if (*buf == TYPE_MOD) { |
| 1369 | *device_type = TYPE_MOD; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1370 | if (read_capacity(shpnt, ldn)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1371 | *block_length = *(buf + 7) + (*(buf + 6) << 8) + (*(buf + 5) << 16) + (*(buf + 4) << 24); |
| 1372 | return 1; |
| 1373 | } else |
| 1374 | return 0; |
| 1375 | } |
| 1376 | if (*buf == TYPE_TAPE) { |
| 1377 | *device_type = TYPE_TAPE; |
| 1378 | *block_length = 0; /* not in use (setting by mt and mtst in op.) */ |
| 1379 | return 1; |
| 1380 | } |
| 1381 | if (*buf == TYPE_PROCESSOR) { |
| 1382 | *device_type = TYPE_PROCESSOR; |
| 1383 | *block_length = 0; /* they set their stuff on drivers */ |
| 1384 | return 1; |
| 1385 | } |
| 1386 | if (*buf == TYPE_SCANNER) { |
| 1387 | *device_type = TYPE_SCANNER; |
| 1388 | *block_length = 0; /* they set their stuff on drivers */ |
| 1389 | return 1; |
| 1390 | } |
| 1391 | if (*buf == TYPE_MEDIUM_CHANGER) { |
| 1392 | *device_type = TYPE_MEDIUM_CHANGER; |
| 1393 | *block_length = 0; /* One never knows, what to expect on a medium |
| 1394 | changer device. */ |
| 1395 | return 1; |
| 1396 | } |
| 1397 | return 0; |
| 1398 | } |
| 1399 | |
| 1400 | static void internal_ibmmca_scsi_setup(char *str, int *ints) |
| 1401 | { |
| 1402 | int i, j, io_base, id_base; |
| 1403 | char *token; |
| 1404 | |
| 1405 | io_base = 0; |
| 1406 | id_base = 0; |
| 1407 | if (str) { |
| 1408 | j = 0; |
| 1409 | while ((token = strsep(&str, ",")) != NULL) { |
| 1410 | if (!strcmp(token, "activity")) |
| 1411 | display_mode |= LED_ACTIVITY; |
| 1412 | if (!strcmp(token, "display")) |
| 1413 | display_mode |= LED_DISP; |
| 1414 | if (!strcmp(token, "adisplay")) |
| 1415 | display_mode |= LED_ADISP; |
| 1416 | if (!strcmp(token, "normal")) |
| 1417 | ibm_ansi_order = 0; |
| 1418 | if (!strcmp(token, "ansi")) |
| 1419 | ibm_ansi_order = 1; |
| 1420 | if (!strcmp(token, "fast")) |
| 1421 | global_adapter_speed = 0; |
| 1422 | if (!strcmp(token, "medium")) |
| 1423 | global_adapter_speed = 4; |
| 1424 | if (!strcmp(token, "slow")) |
| 1425 | global_adapter_speed = 7; |
| 1426 | if ((*token == '-') || (isdigit(*token))) { |
| 1427 | if (!(j % 2) && (io_base < IM_MAX_HOSTS)) |
| 1428 | io_port[io_base++] = simple_strtoul(token, NULL, 0); |
| 1429 | if ((j % 2) && (id_base < IM_MAX_HOSTS)) |
| 1430 | scsi_id[id_base++] = simple_strtoul(token, NULL, 0); |
| 1431 | j++; |
| 1432 | } |
| 1433 | } |
| 1434 | } else if (ints) { |
| 1435 | for (i = 0; i < IM_MAX_HOSTS && 2 * i + 2 < ints[0]; i++) { |
| 1436 | io_port[i] = ints[2 * i + 2]; |
| 1437 | scsi_id[i] = ints[2 * i + 2]; |
| 1438 | } |
| 1439 | } |
| 1440 | return; |
| 1441 | } |
| 1442 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1443 | #if 0 |
| 1444 | FIXME NEED TO MOVE TO SYSFS |
| 1445 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1446 | static int ibmmca_getinfo(char *buf, int slot, void *dev_id) |
| 1447 | { |
| 1448 | struct Scsi_Host *shpnt; |
| 1449 | int len, speciale, connectore, k; |
| 1450 | unsigned int pos[8]; |
| 1451 | unsigned long flags; |
| 1452 | struct Scsi_Host *dev = dev_id; |
| 1453 | |
| 1454 | spin_lock_irqsave(dev->host_lock, flags); |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 1455 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | shpnt = dev; /* assign host-structure to local pointer */ |
| 1457 | len = 0; /* set filled text-buffer index to 0 */ |
| 1458 | /* get the _special contents of the hostdata structure */ |
| 1459 | speciale = ((struct ibmmca_hostdata *) shpnt->hostdata)->_special; |
| 1460 | connectore = ((struct ibmmca_hostdata *) shpnt->hostdata)->_connector_size; |
| 1461 | for (k = 2; k < 4; k++) |
| 1462 | pos[k] = ((struct ibmmca_hostdata *) shpnt->hostdata)->_pos[k]; |
| 1463 | if (speciale == FORCED_DETECTION) { /* forced detection */ |
| 1464 | len += sprintf(buf + len, |
| 1465 | "Adapter category: forced detected\n" "***************************************\n" "*** Forced detected SCSI Adapter ***\n" "*** No chip-information available ***\n" "***************************************\n"); |
| 1466 | } else if (speciale == INTEGRATED_SCSI) { |
| 1467 | /* if the integrated subsystem has been found automatically: */ |
| 1468 | len += sprintf(buf + len, |
| 1469 | "Adapter category: integrated\n" "Chip revision level: %d\n" "Chip status: %s\n" "8 kByte NVRAM status: %s\n", ((pos[2] & 0xf0) >> 4), (pos[2] & 1) ? "enabled" : "disabled", (pos[2] & 2) ? "locked" : "accessible"); |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 1470 | } else if ((speciale >= 0) && (speciale < ARRAY_SIZE(subsys_list))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | /* if the subsystem is a slot adapter */ |
| 1472 | len += sprintf(buf + len, "Adapter category: slot-card\n" "ROM Segment Address: "); |
| 1473 | if ((pos[2] & 0xf0) == 0xf0) |
| 1474 | len += sprintf(buf + len, "off\n"); |
| 1475 | else |
| 1476 | len += sprintf(buf + len, "0x%x\n", ((pos[2] & 0xf0) << 13) + 0xc0000); |
| 1477 | len += sprintf(buf + len, "Chip status: %s\n", (pos[2] & 1) ? "enabled" : "disabled"); |
| 1478 | len += sprintf(buf + len, "Adapter I/O Offset: 0x%x\n", ((pos[2] & 0x0e) << 2)); |
| 1479 | } else { |
| 1480 | len += sprintf(buf + len, "Adapter category: unknown\n"); |
| 1481 | } |
| 1482 | /* common subsystem information to write to the slotn file */ |
| 1483 | len += sprintf(buf + len, "Subsystem PUN: %d\n", shpnt->this_id); |
| 1484 | len += sprintf(buf + len, "I/O base address range: 0x%x-0x%x\n", (unsigned int) (shpnt->io_port), (unsigned int) (shpnt->io_port + 7)); |
| 1485 | len += sprintf(buf + len, "MCA-slot size: %d bits", connectore); |
| 1486 | /* Now make sure, the bufferlength is devidable by 4 to avoid |
| 1487 | * paging problems of the buffer. */ |
| 1488 | while (len % sizeof(int) != (sizeof(int) - 1)) |
| 1489 | len += sprintf(buf + len, " "); |
| 1490 | len += sprintf(buf + len, "\n"); |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 1491 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 1493 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1494 | return len; |
| 1495 | } |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1496 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1497 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1498 | static struct scsi_host_template ibmmca_driver_template = { |
| 1499 | .proc_name = "ibmmca", |
| 1500 | .proc_info = ibmmca_proc_info, |
| 1501 | .name = "IBM SCSI-Subsystem", |
| 1502 | .queuecommand = ibmmca_queuecommand, |
| 1503 | .eh_abort_handler = ibmmca_abort, |
| 1504 | .eh_host_reset_handler = ibmmca_host_reset, |
| 1505 | .bios_param = ibmmca_biosparam, |
| 1506 | .can_queue = 16, |
| 1507 | .this_id = 7, |
| 1508 | .sg_tablesize = 16, |
| 1509 | .cmd_per_lun = 1, |
| 1510 | .use_clustering = ENABLE_CLUSTERING, |
| 1511 | }; |
| 1512 | |
| 1513 | static int ibmmca_probe(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | { |
| 1515 | struct Scsi_Host *shpnt; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1516 | int port, id, i, j, k, irq, enabled, ret = -EINVAL; |
| 1517 | struct mca_device *mca_dev = to_mca_device(dev); |
| 1518 | const char *description = ibmmca_description[mca_dev->index]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1519 | |
| 1520 | /* First of all, print the version number of the driver. This is |
| 1521 | * important to allow better user bugreports in case of already |
| 1522 | * having problems with the MCA_bus probing. */ |
| 1523 | printk(KERN_INFO "IBM MCA SCSI: Version %s\n", IBMMCA_SCSI_DRIVER_VERSION); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1524 | /* The POS2-register of all PS/2 model SCSI-subsystems has the following |
| 1525 | * interpretation of bits: |
| 1526 | * Bit 7 - 4 : Chip Revision ID (Release) |
| 1527 | * Bit 3 - 2 : Reserved |
| 1528 | * Bit 1 : 8k NVRAM Disabled |
| 1529 | * Bit 0 : Chip Enable (EN-Signal) |
| 1530 | * The POS3-register is interpreted as follows: |
| 1531 | * Bit 7 - 5 : SCSI ID |
| 1532 | * Bit 4 : Reserved = 0 |
| 1533 | * Bit 3 - 0 : Reserved = 0 |
| 1534 | * (taken from "IBM, PS/2 Hardware Interface Technical Reference, Common |
| 1535 | * Interfaces (1991)"). |
| 1536 | * In short words, this means, that IBM PS/2 machines only support |
| 1537 | * 1 single subsystem by default. The slot-adapters must have another |
| 1538 | * configuration on pos2. Here, one has to assume the following |
| 1539 | * things for POS2-register: |
| 1540 | * Bit 7 - 4 : Chip Revision ID (Release) |
| 1541 | * Bit 3 - 1 : port offset factor |
| 1542 | * Bit 0 : Chip Enable (EN-Signal) |
| 1543 | * As I found a patch here, setting the IO-registers to 0x3540 forced, |
| 1544 | * as there was a 0x05 in POS2 on a model 56, I assume, that the |
| 1545 | * port 0x3540 must be fix for integrated SCSI-controllers. |
| 1546 | * Ok, this discovery leads to the following implementation: (M.Lang) */ |
| 1547 | |
| 1548 | /* first look for the IBM SCSI integrated subsystem on the motherboard */ |
| 1549 | for (j = 0; j < 8; j++) /* read the pos-information */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1550 | pos[j] = mca_device_read_pos(mca_dev, j); |
| 1551 | id = (pos[3] & 0xe0) >> 5; /* this is correct and represents the PUN */ |
| 1552 | enabled = (pos[2] &0x01); |
| 1553 | if (!enabled) { |
| 1554 | printk(KERN_WARNING "IBM MCA SCSI: WARNING - Your SCSI-subsystem is disabled!\n"); |
| 1555 | printk(KERN_WARNING " SCSI-operations may not work.\n"); |
| 1556 | } |
| 1557 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1558 | /* pos2 = pos3 = 0xff if there is no integrated SCSI-subsystem present, but |
| 1559 | * if we ignore the settings of all surrounding pos registers, it is not |
| 1560 | * completely sufficient to only check pos2 and pos3. */ |
| 1561 | /* Therefore, now the following if statement is used to |
| 1562 | * make sure, we see a real integrated onboard SCSI-interface and no |
| 1563 | * internal system information, which gets mapped to some pos registers |
| 1564 | * on models 95xx. */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1565 | if (mca_dev->slot == MCA_INTEGSCSI && |
| 1566 | ((!pos[0] && !pos[1] && pos[2] > 0 && |
| 1567 | pos[3] > 0 && !pos[4] && !pos[5] && |
| 1568 | !pos[6] && !pos[7]) || |
| 1569 | (pos[0] == 0xff && pos[1] == 0xff && |
| 1570 | pos[2] < 0xff && pos[3] < 0xff && |
| 1571 | pos[4] == 0xff && pos[5] == 0xff && |
| 1572 | pos[6] == 0xff && pos[7] == 0xff))) { |
| 1573 | irq = IM_IRQ; |
| 1574 | port = IM_IO_PORT; |
| 1575 | } else { |
| 1576 | irq = IM_IRQ; |
| 1577 | port = IM_IO_PORT + ((pos[2] &0x0e) << 2); |
| 1578 | if ((mca_dev->index == IBM_SCSI2_FW) && (pos[6] != 0)) { |
| 1579 | printk(KERN_ERR "IBM MCA SCSI: ERROR - Wrong POS(6)-register setting!\n"); |
| 1580 | printk(KERN_ERR " Impossible to determine adapter PUN!\n"); |
| 1581 | printk(KERN_ERR " Guessing adapter PUN = 7.\n"); |
| 1582 | id = 7; |
| 1583 | } else { |
| 1584 | id = (pos[3] & 0xe0) >> 5; /* get subsystem PUN */ |
| 1585 | if (mca_dev->index == IBM_SCSI2_FW) { |
| 1586 | id |= (pos[3] & 0x10) >> 1; /* get subsystem PUN high-bit |
| 1587 | * for F/W adapters */ |
| 1588 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1589 | } |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1590 | if ((mca_dev->index == IBM_SCSI2_FW) && |
| 1591 | (pos[4] & 0x01) && (pos[6] == 0)) { |
| 1592 | /* IRQ11 is used by SCSI-2 F/W Adapter/A */ |
| 1593 | printk(KERN_DEBUG "IBM MCA SCSI: SCSI-2 F/W adapter needs IRQ 11.\n"); |
| 1594 | irq = IM_IRQ_FW; |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | |
| 1599 | |
| 1600 | /* give detailed information on the subsystem. This helps me |
| 1601 | * additionally during debugging and analyzing bug-reports. */ |
| 1602 | printk(KERN_INFO "IBM MCA SCSI: %s found, io=0x%x, scsi id=%d,\n", |
| 1603 | description, port, id); |
| 1604 | if (mca_dev->slot == MCA_INTEGSCSI) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1605 | printk(KERN_INFO " chip rev.=%d, 8K NVRAM=%s, subsystem=%s\n", ((pos[2] & 0xf0) >> 4), (pos[2] & 2) ? "locked" : "accessible", (pos[2] & 1) ? "enabled." : "disabled."); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1606 | else { |
| 1607 | if ((pos[2] & 0xf0) == 0xf0) |
| 1608 | printk(KERN_DEBUG " ROM Addr.=off,"); |
| 1609 | else |
| 1610 | printk(KERN_DEBUG " ROM Addr.=0x%x,", ((pos[2] & 0xf0) << 13) + 0xc0000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1611 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1612 | printk(KERN_DEBUG " port-offset=0x%x, subsystem=%s\n", ((pos[2] & 0x0e) << 2), (pos[2] & 1) ? "enabled." : "disabled."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | } |
| 1614 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1615 | /* check I/O region */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1616 | if (!request_region(port, IM_N_IO_PORT, description)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | printk(KERN_ERR "IBM MCA SCSI: Unable to get I/O region 0x%x-0x%x (%d ports).\n", port, port + IM_N_IO_PORT - 1, IM_N_IO_PORT); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1618 | goto out_fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1619 | } |
| 1620 | |
| 1621 | /* register host */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1622 | shpnt = scsi_host_alloc(&ibmmca_driver_template, |
| 1623 | sizeof(struct ibmmca_hostdata)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1624 | if (!shpnt) { |
| 1625 | printk(KERN_ERR "IBM MCA SCSI: Unable to register host.\n"); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1626 | goto out_release; |
| 1627 | } |
| 1628 | |
| 1629 | dev_set_drvdata(dev, shpnt); |
| 1630 | if(request_irq(irq, interrupt_handler, IRQF_SHARED, description, dev)) { |
| 1631 | printk(KERN_ERR "IBM MCA SCSI: failed to request interrupt %d\n", irq); |
| 1632 | goto out_free_host; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | } |
| 1634 | |
| 1635 | /* request I/O region */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1636 | special(shpnt) = mca_dev->index; /* important assignment or else crash! */ |
| 1637 | subsystem_connector_size(shpnt) = 0; /* preset slot-size */ |
| 1638 | shpnt->irq = irq; /* assign necessary stuff for the adapter */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | shpnt->io_port = port; |
| 1640 | shpnt->n_io_port = IM_N_IO_PORT; |
| 1641 | shpnt->this_id = id; |
| 1642 | shpnt->max_id = 8; /* 8 PUNs are default */ |
| 1643 | /* now, the SCSI-subsystem is connected to Linux */ |
| 1644 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1645 | #ifdef IM_DEBUG_PROBE |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1646 | ctrl = (unsigned int) (inb(IM_CTR_REG(found))); /* get control-register status */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1647 | printk("IBM MCA SCSI: Control Register contents: %x, status: %x\n", ctrl, inb(IM_STAT_REG(found))); |
| 1648 | printk("IBM MCA SCSI: This adapters' POS-registers: "); |
| 1649 | for (i = 0; i < 8; i++) |
| 1650 | printk("%x ", pos[i]); |
| 1651 | printk("\n"); |
| 1652 | #endif |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1653 | reset_status(shpnt) = IM_RESET_NOT_IN_PROGRESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1654 | |
| 1655 | for (i = 0; i < 16; i++) /* reset the tables */ |
| 1656 | for (j = 0; j < 8; j++) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1657 | get_ldn(shpnt)[i][j] = MAX_LOG_DEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1658 | |
| 1659 | /* check which logical devices exist */ |
| 1660 | /* after this line, local interrupting is possible: */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1661 | local_checking_phase_flag(shpnt) = 1; |
| 1662 | check_devices(shpnt, mca_dev->index); /* call by value, using the global variable hosts */ |
| 1663 | local_checking_phase_flag(shpnt) = 0; |
| 1664 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | /* an ibm mca subsystem has been detected */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1666 | |
| 1667 | for (k = 2; k < 7; k++) |
| 1668 | ((struct ibmmca_hostdata *) shpnt->hostdata)->_pos[k] = pos[k]; |
| 1669 | ((struct ibmmca_hostdata *) shpnt->hostdata)->_special = INTEGRATED_SCSI; |
| 1670 | mca_device_set_name(mca_dev, description); |
| 1671 | /* FIXME: NEED TO REPLUMB TO SYSFS |
| 1672 | mca_set_adapter_procfn(MCA_INTEGSCSI, (MCA_ProcFn) ibmmca_getinfo, shpnt); |
| 1673 | */ |
| 1674 | mca_device_set_claim(mca_dev, 1); |
| 1675 | if (scsi_add_host(shpnt, dev)) { |
| 1676 | dev_printk(KERN_ERR, dev, "IBM MCA SCSI: scsi_add_host failed\n"); |
| 1677 | goto out_free_host; |
| 1678 | } |
| 1679 | scsi_scan_host(shpnt); |
| 1680 | |
| 1681 | return 0; |
| 1682 | out_free_host: |
| 1683 | scsi_host_put(shpnt); |
| 1684 | out_release: |
| 1685 | release_region(port, IM_N_IO_PORT); |
| 1686 | out_fail: |
| 1687 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1688 | } |
| 1689 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1690 | static int __devexit ibmmca_remove(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1691 | { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1692 | struct Scsi_Host *shpnt = dev_get_drvdata(dev); |
| 1693 | scsi_remove_host(shpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | release_region(shpnt->io_port, shpnt->n_io_port); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1695 | free_irq(shpnt->irq, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1696 | return 0; |
| 1697 | } |
| 1698 | |
| 1699 | /* The following routine is the SCSI command queue for the midlevel driver */ |
| 1700 | static int ibmmca_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) |
| 1701 | { |
| 1702 | unsigned int ldn; |
| 1703 | unsigned int scsi_cmd; |
| 1704 | struct im_scb *scb; |
| 1705 | struct Scsi_Host *shpnt; |
| 1706 | int current_ldn; |
| 1707 | int id, lun; |
| 1708 | int target; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1709 | int max_pun; |
| 1710 | int i; |
| 1711 | struct scatterlist *sl; |
| 1712 | |
| 1713 | shpnt = cmd->device->host; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1714 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1715 | max_pun = subsystem_maxid(shpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1716 | if (ibm_ansi_order) { |
| 1717 | target = max_pun - 1 - cmd->device->id; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1718 | if ((target <= subsystem_pun(shpnt)) && (cmd->device->id <= subsystem_pun(shpnt))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1719 | target--; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1720 | else if ((target >= subsystem_pun(shpnt)) && (cmd->device->id >= subsystem_pun(shpnt))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | target++; |
| 1722 | } else |
| 1723 | target = cmd->device->id; |
| 1724 | |
| 1725 | /* if (target,lun) is NO LUN or not existing at all, return error */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1726 | if ((get_scsi(shpnt)[target][cmd->device->lun] == TYPE_NO_LUN) || (get_scsi(shpnt)[target][cmd->device->lun] == TYPE_NO_DEVICE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1727 | cmd->result = DID_NO_CONNECT << 16; |
| 1728 | if (done) |
| 1729 | done(cmd); |
| 1730 | return 0; |
| 1731 | } |
| 1732 | |
| 1733 | /*if (target,lun) unassigned, do further checks... */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1734 | ldn = get_ldn(shpnt)[target][cmd->device->lun]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1735 | if (ldn >= MAX_LOG_DEV) { /* on invalid ldn do special stuff */ |
| 1736 | if (ldn > MAX_LOG_DEV) { /* dynamical remapping if ldn unassigned */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1737 | current_ldn = next_ldn(shpnt); /* stop-value for one circle */ |
| 1738 | while (ld(shpnt)[next_ldn(shpnt)].cmd) { /* search for a occupied, but not in */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | /* command-processing ldn. */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1740 | next_ldn(shpnt)++; |
| 1741 | if (next_ldn(shpnt) >= MAX_LOG_DEV) |
| 1742 | next_ldn(shpnt) = 7; |
| 1743 | if (current_ldn == next_ldn(shpnt)) { /* One circle done ? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | /* no non-processing ldn found */ |
Jeff Garzik | 017560f | 2005-10-24 18:04:36 -0400 | [diff] [blame] | 1745 | scmd_printk(KERN_WARNING, cmd, |
| 1746 | "IBM MCA SCSI: Cannot assign SCSI-device dynamically!\n" |
| 1747 | " On ldn 7-14 SCSI-commands everywhere in progress.\n" |
| 1748 | " Reporting DID_NO_CONNECT for device.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1749 | cmd->result = DID_NO_CONNECT << 16; /* return no connect */ |
| 1750 | if (done) |
| 1751 | done(cmd); |
| 1752 | return 0; |
| 1753 | } |
| 1754 | } |
| 1755 | |
| 1756 | /* unmap non-processing ldn */ |
| 1757 | for (id = 0; id < max_pun; id++) |
| 1758 | for (lun = 0; lun < 8; lun++) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1759 | if (get_ldn(shpnt)[id][lun] == next_ldn(shpnt)) { |
| 1760 | get_ldn(shpnt)[id][lun] = TYPE_NO_DEVICE; |
| 1761 | get_scsi(shpnt)[id][lun] = TYPE_NO_DEVICE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1762 | /* unmap entry */ |
| 1763 | } |
| 1764 | } |
| 1765 | /* set reduced interrupt_handler-mode for checking */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1766 | local_checking_phase_flag(shpnt) = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1767 | /* map found ldn to pun,lun */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1768 | get_ldn(shpnt)[target][cmd->device->lun] = next_ldn(shpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | /* change ldn to the right value, that is now next_ldn */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1770 | ldn = next_ldn(shpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1771 | /* unassign all ldns (pun,lun,ldn does not matter for remove) */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1772 | immediate_assign(shpnt, 0, 0, 0, REMOVE_LDN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | /* set only LDN for remapped device */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1774 | immediate_assign(shpnt, target, cmd->device->lun, ldn, SET_LDN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1775 | /* get device information for ld[ldn] */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1776 | if (device_exists(shpnt, ldn, &ld(shpnt)[ldn].block_length, &ld(shpnt)[ldn].device_type)) { |
| 1777 | ld(shpnt)[ldn].cmd = NULL; /* To prevent panic set 0, because |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1778 | devices that were not assigned, |
| 1779 | should have nothing in progress. */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1780 | get_scsi(shpnt)[target][cmd->device->lun] = ld(shpnt)[ldn].device_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1781 | /* increase assignment counters for statistics in /proc */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1782 | IBM_DS(shpnt).dynamical_assignments++; |
| 1783 | IBM_DS(shpnt).ldn_assignments[ldn]++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | } else |
| 1785 | /* panic here, because a device, found at boottime has |
| 1786 | vanished */ |
| 1787 | panic("IBM MCA SCSI: ldn=0x%x, SCSI-device on (%d,%d) vanished!\n", ldn, target, cmd->device->lun); |
| 1788 | /* unassign again all ldns (pun,lun,ldn does not matter for remove) */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1789 | immediate_assign(shpnt, 0, 0, 0, REMOVE_LDN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1790 | /* remap all ldns, as written in the pun/lun table */ |
| 1791 | lun = 0; |
| 1792 | #ifdef CONFIG_SCSI_MULTI_LUN |
| 1793 | for (lun = 0; lun < 8; lun++) |
| 1794 | #endif |
| 1795 | for (id = 0; id < max_pun; id++) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1796 | if (get_ldn(shpnt)[id][lun] <= MAX_LOG_DEV) |
| 1797 | immediate_assign(shpnt, id, lun, get_ldn(shpnt)[id][lun], SET_LDN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1798 | } |
| 1799 | /* set back to normal interrupt_handling */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1800 | local_checking_phase_flag(shpnt) = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1801 | #ifdef IM_DEBUG_PROBE |
| 1802 | /* Information on syslog terminal */ |
| 1803 | printk("IBM MCA SCSI: ldn=0x%x dynamically reassigned to (%d,%d).\n", ldn, target, cmd->device->lun); |
| 1804 | #endif |
| 1805 | /* increase next_ldn for next dynamical assignment */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1806 | next_ldn(shpnt)++; |
| 1807 | if (next_ldn(shpnt) >= MAX_LOG_DEV) |
| 1808 | next_ldn(shpnt) = 7; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1809 | } else { /* wall against Linux accesses to the subsystem adapter */ |
| 1810 | cmd->result = DID_BAD_TARGET << 16; |
| 1811 | if (done) |
| 1812 | done(cmd); |
| 1813 | return 0; |
| 1814 | } |
| 1815 | } |
| 1816 | |
| 1817 | /*verify there is no command already in progress for this log dev */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1818 | if (ld(shpnt)[ldn].cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1819 | panic("IBM MCA SCSI: cmd already in progress for this ldn.\n"); |
| 1820 | |
| 1821 | /*save done in cmd, and save cmd for the interrupt handler */ |
| 1822 | cmd->scsi_done = done; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1823 | ld(shpnt)[ldn].cmd = cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1824 | |
| 1825 | /*fill scb information independent of the scsi command */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1826 | scb = &(ld(shpnt)[ldn].scb); |
| 1827 | ld(shpnt)[ldn].tsb.dev_status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1828 | scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_RETRY_ENABLE; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1829 | scb->tsb_adr = isa_virt_to_bus(&(ld(shpnt)[ldn].tsb)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1830 | scsi_cmd = cmd->cmnd[0]; |
| 1831 | |
| 1832 | if (cmd->use_sg) { |
| 1833 | i = cmd->use_sg; |
| 1834 | sl = (struct scatterlist *) (cmd->request_buffer); |
| 1835 | if (i > 16) |
| 1836 | panic("IBM MCA SCSI: scatter-gather list too long.\n"); |
| 1837 | while (--i >= 0) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1838 | ld(shpnt)[ldn].sge[i].address = (void *) (isa_page_to_bus(sl[i].page) + sl[i].offset); |
| 1839 | ld(shpnt)[ldn].sge[i].byte_length = sl[i].length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | } |
| 1841 | scb->enable |= IM_POINTER_TO_LIST; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1842 | scb->sys_buf_adr = isa_virt_to_bus(&(ld(shpnt)[ldn].sge[0])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1843 | scb->sys_buf_length = cmd->use_sg * sizeof(struct im_sge); |
| 1844 | } else { |
| 1845 | scb->sys_buf_adr = isa_virt_to_bus(cmd->request_buffer); |
| 1846 | /* recent Linux midlevel SCSI places 1024 byte for inquiry |
| 1847 | * command. Far too much for old PS/2 hardware. */ |
| 1848 | switch (scsi_cmd) { |
| 1849 | /* avoid command errors by setting bufferlengths to |
| 1850 | * ANSI-standard. Beware of forcing it to 255, |
| 1851 | * this could SEGV the kernel!!! */ |
| 1852 | case INQUIRY: |
| 1853 | case REQUEST_SENSE: |
| 1854 | case MODE_SENSE: |
| 1855 | case MODE_SELECT: |
| 1856 | if (cmd->request_bufflen > 255) |
| 1857 | scb->sys_buf_length = 255; |
| 1858 | else |
| 1859 | scb->sys_buf_length = cmd->request_bufflen; |
| 1860 | break; |
| 1861 | case TEST_UNIT_READY: |
| 1862 | scb->sys_buf_length = 0; |
| 1863 | break; |
| 1864 | default: |
| 1865 | scb->sys_buf_length = cmd->request_bufflen; |
| 1866 | break; |
| 1867 | } |
| 1868 | } |
| 1869 | /*fill scb information dependent on scsi command */ |
| 1870 | |
| 1871 | #ifdef IM_DEBUG_CMD |
| 1872 | printk("issue scsi cmd=%02x to ldn=%d\n", scsi_cmd, ldn); |
| 1873 | #endif |
| 1874 | |
| 1875 | /* for specific device-type debugging: */ |
| 1876 | #ifdef IM_DEBUG_CMD_SPEC_DEV |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1877 | if (ld(shpnt)[ldn].device_type == IM_DEBUG_CMD_DEVICE) |
| 1878 | printk("(SCSI-device-type=0x%x) issue scsi cmd=%02x to ldn=%d\n", ld(shpnt)[ldn].device_type, scsi_cmd, ldn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1879 | #endif |
| 1880 | |
| 1881 | /* for possible panics store current command */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1882 | last_scsi_command(shpnt)[ldn] = scsi_cmd; |
| 1883 | last_scsi_type(shpnt)[ldn] = IM_SCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1884 | /* update statistical info */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1885 | IBM_DS(shpnt).total_accesses++; |
| 1886 | IBM_DS(shpnt).ldn_access[ldn]++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1887 | |
| 1888 | switch (scsi_cmd) { |
| 1889 | case READ_6: |
| 1890 | case WRITE_6: |
| 1891 | case READ_10: |
| 1892 | case WRITE_10: |
| 1893 | case READ_12: |
| 1894 | case WRITE_12: |
| 1895 | /* Distinguish between disk and other devices. Only disks (that are the |
| 1896 | most frequently accessed devices) should be supported by the |
| 1897 | IBM-SCSI-Subsystem commands. */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1898 | switch (ld(shpnt)[ldn].device_type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1899 | case TYPE_DISK: /* for harddisks enter here ... */ |
| 1900 | case TYPE_MOD: /* ... try it also for MO-drives (send flames as */ |
| 1901 | /* you like, if this won't work.) */ |
| 1902 | if (scsi_cmd == READ_6 || scsi_cmd == READ_10 || scsi_cmd == READ_12) { |
| 1903 | /* read command preparations */ |
| 1904 | scb->enable |= IM_READ_CONTROL; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1905 | IBM_DS(shpnt).ldn_read_access[ldn]++; /* increase READ-access on ldn stat. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1906 | scb->command = IM_READ_DATA_CMD | IM_NO_DISCONNECT; |
| 1907 | } else { /* write command preparations */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1908 | IBM_DS(shpnt).ldn_write_access[ldn]++; /* increase write-count on ldn stat. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1909 | scb->command = IM_WRITE_DATA_CMD | IM_NO_DISCONNECT; |
| 1910 | } |
| 1911 | if (scsi_cmd == READ_6 || scsi_cmd == WRITE_6) { |
| 1912 | scb->u1.log_blk_adr = (((unsigned) cmd->cmnd[3]) << 0) | (((unsigned) cmd->cmnd[2]) << 8) | ((((unsigned) cmd->cmnd[1]) & 0x1f) << 16); |
| 1913 | scb->u2.blk.count = (unsigned) cmd->cmnd[4]; |
| 1914 | } else { |
| 1915 | scb->u1.log_blk_adr = (((unsigned) cmd->cmnd[5]) << 0) | (((unsigned) cmd->cmnd[4]) << 8) | (((unsigned) cmd->cmnd[3]) << 16) | (((unsigned) cmd->cmnd[2]) << 24); |
| 1916 | scb->u2.blk.count = (((unsigned) cmd->cmnd[8]) << 0) | (((unsigned) cmd->cmnd[7]) << 8); |
| 1917 | } |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1918 | last_scsi_logical_block(shpnt)[ldn] = scb->u1.log_blk_adr; |
| 1919 | last_scsi_blockcount(shpnt)[ldn] = scb->u2.blk.count; |
| 1920 | scb->u2.blk.length = ld(shpnt)[ldn].block_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1921 | break; |
| 1922 | /* for other devices, enter here. Other types are not known by |
| 1923 | Linux! TYPE_NO_LUN is forbidden as valid device. */ |
| 1924 | case TYPE_ROM: |
| 1925 | case TYPE_TAPE: |
| 1926 | case TYPE_PROCESSOR: |
| 1927 | case TYPE_WORM: |
| 1928 | case TYPE_SCANNER: |
| 1929 | case TYPE_MEDIUM_CHANGER: |
| 1930 | /* If there is a sequential-device, IBM recommends to use |
| 1931 | IM_OTHER_SCSI_CMD_CMD instead of subsystem READ/WRITE. |
| 1932 | This includes CD-ROM devices, too, due to the partial sequential |
| 1933 | read capabilities. */ |
| 1934 | scb->command = IM_OTHER_SCSI_CMD_CMD; |
| 1935 | if (scsi_cmd == READ_6 || scsi_cmd == READ_10 || scsi_cmd == READ_12) |
| 1936 | /* enable READ */ |
| 1937 | scb->enable |= IM_READ_CONTROL; |
| 1938 | scb->enable |= IM_BYPASS_BUFFER; |
| 1939 | scb->u1.scsi_cmd_length = cmd->cmd_len; |
| 1940 | memcpy(scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1941 | last_scsi_type(shpnt)[ldn] = IM_LONG_SCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1942 | /* Read/write on this non-disk devices is also displayworthy, |
| 1943 | so flash-up the LED/display. */ |
| 1944 | break; |
| 1945 | } |
| 1946 | break; |
| 1947 | case INQUIRY: |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1948 | IBM_DS(shpnt).ldn_inquiry_access[ldn]++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1949 | scb->command = IM_DEVICE_INQUIRY_CMD; |
| 1950 | scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER; |
| 1951 | scb->u1.log_blk_adr = 0; |
| 1952 | break; |
| 1953 | case TEST_UNIT_READY: |
| 1954 | scb->command = IM_OTHER_SCSI_CMD_CMD; |
| 1955 | scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER; |
| 1956 | scb->u1.log_blk_adr = 0; |
| 1957 | scb->u1.scsi_cmd_length = 6; |
| 1958 | memcpy(scb->u2.scsi_command, cmd->cmnd, 6); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1959 | last_scsi_type(shpnt)[ldn] = IM_LONG_SCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1960 | break; |
| 1961 | case READ_CAPACITY: |
| 1962 | /* the length of system memory buffer must be exactly 8 bytes */ |
| 1963 | scb->command = IM_READ_CAPACITY_CMD; |
| 1964 | scb->enable |= IM_READ_CONTROL | IM_BYPASS_BUFFER; |
| 1965 | if (scb->sys_buf_length > 8) |
| 1966 | scb->sys_buf_length = 8; |
| 1967 | break; |
| 1968 | /* Commands that need read-only-mode (system <- device): */ |
| 1969 | case REQUEST_SENSE: |
| 1970 | scb->command = IM_REQUEST_SENSE_CMD; |
| 1971 | scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER; |
| 1972 | break; |
| 1973 | /* Commands that need write-only-mode (system -> device): */ |
| 1974 | case MODE_SELECT: |
| 1975 | case MODE_SELECT_10: |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1976 | IBM_DS(shpnt).ldn_modeselect_access[ldn]++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1977 | scb->command = IM_OTHER_SCSI_CMD_CMD; |
| 1978 | scb->enable |= IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER; /*Select needs WRITE-enabled */ |
| 1979 | scb->u1.scsi_cmd_length = cmd->cmd_len; |
| 1980 | memcpy(scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1981 | last_scsi_type(shpnt)[ldn] = IM_LONG_SCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1982 | break; |
| 1983 | /* For other commands, read-only is useful. Most other commands are |
| 1984 | running without an input-data-block. */ |
| 1985 | default: |
| 1986 | scb->command = IM_OTHER_SCSI_CMD_CMD; |
| 1987 | scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER; |
| 1988 | scb->u1.scsi_cmd_length = cmd->cmd_len; |
| 1989 | memcpy(scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1990 | last_scsi_type(shpnt)[ldn] = IM_LONG_SCB; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1991 | break; |
| 1992 | } |
| 1993 | /*issue scb command, and return */ |
| 1994 | if (++disk_rw_in_progress == 1) |
| 1995 | PS2_DISK_LED_ON(shpnt->host_no, target); |
| 1996 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 1997 | if (last_scsi_type(shpnt)[ldn] == IM_LONG_SCB) { |
| 1998 | issue_cmd(shpnt, isa_virt_to_bus(scb), IM_LONG_SCB | ldn); |
| 1999 | IBM_DS(shpnt).long_scbs++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | } else { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2001 | issue_cmd(shpnt, isa_virt_to_bus(scb), IM_SCB | ldn); |
| 2002 | IBM_DS(shpnt).scbs++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2003 | } |
| 2004 | return 0; |
| 2005 | } |
| 2006 | |
Jeff Garzik | 8fa728a | 2005-05-28 07:54:40 -0400 | [diff] [blame] | 2007 | static int __ibmmca_abort(Scsi_Cmnd * cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2008 | { |
| 2009 | /* Abort does not work, as the adapter never generates an interrupt on |
| 2010 | * whatever situation is simulated, even when really pending commands |
| 2011 | * are running on the adapters' hardware ! */ |
| 2012 | |
| 2013 | struct Scsi_Host *shpnt; |
| 2014 | unsigned int ldn; |
| 2015 | void (*saved_done) (Scsi_Cmnd *); |
| 2016 | int target; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2017 | int max_pun; |
| 2018 | unsigned long imm_command; |
| 2019 | |
| 2020 | #ifdef IM_DEBUG_PROBE |
| 2021 | printk("IBM MCA SCSI: Abort subroutine called...\n"); |
| 2022 | #endif |
| 2023 | |
| 2024 | shpnt = cmd->device->host; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2025 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2026 | max_pun = subsystem_maxid(shpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2027 | if (ibm_ansi_order) { |
| 2028 | target = max_pun - 1 - cmd->device->id; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2029 | if ((target <= subsystem_pun(shpnt)) && (cmd->device->id <= subsystem_pun(shpnt))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | target--; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2031 | else if ((target >= subsystem_pun(shpnt)) && (cmd->device->id >= subsystem_pun(shpnt))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2032 | target++; |
| 2033 | } else |
| 2034 | target = cmd->device->id; |
| 2035 | |
| 2036 | /* get logical device number, and disable system interrupts */ |
| 2037 | printk(KERN_WARNING "IBM MCA SCSI: Sending abort to device pun=%d, lun=%d.\n", target, cmd->device->lun); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2038 | ldn = get_ldn(shpnt)[target][cmd->device->lun]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2039 | |
| 2040 | /*if cmd for this ldn has already finished, no need to abort */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2041 | if (!ld(shpnt)[ldn].cmd) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | return SUCCESS; |
| 2043 | } |
| 2044 | |
| 2045 | /* Clear ld.cmd, save done function, install internal done, |
| 2046 | * send abort immediate command (this enables sys. interrupts), |
| 2047 | * and wait until the interrupt arrives. |
| 2048 | */ |
| 2049 | saved_done = cmd->scsi_done; |
| 2050 | cmd->scsi_done = internal_done; |
| 2051 | cmd->SCp.Status = 0; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2052 | last_scsi_command(shpnt)[ldn] = IM_ABORT_IMM_CMD; |
| 2053 | last_scsi_type(shpnt)[ldn] = IM_IMM_CMD; |
| 2054 | imm_command = inl(IM_CMD_REG(shpnt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | imm_command &= (unsigned long) (0xffff0000); /* mask reserved stuff */ |
| 2056 | imm_command |= (unsigned long) (IM_ABORT_IMM_CMD); |
| 2057 | /* must wait for attention reg not busy */ |
| 2058 | /* FIXME - timeout, politeness */ |
| 2059 | while (1) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2060 | if (!(inb(IM_STAT_REG(shpnt)) & IM_BUSY)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | break; |
| 2062 | } |
| 2063 | /* write registers and enable system interrupts */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2064 | outl(imm_command, IM_CMD_REG(shpnt)); |
| 2065 | outb(IM_IMM_CMD | ldn, IM_ATTN_REG(shpnt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2066 | #ifdef IM_DEBUG_PROBE |
| 2067 | printk("IBM MCA SCSI: Abort queued to adapter...\n"); |
| 2068 | #endif |
| 2069 | spin_unlock_irq(shpnt->host_lock); |
| 2070 | while (!cmd->SCp.Status) |
| 2071 | yield(); |
| 2072 | spin_lock_irq(shpnt->host_lock); |
| 2073 | cmd->scsi_done = saved_done; |
| 2074 | #ifdef IM_DEBUG_PROBE |
| 2075 | printk("IBM MCA SCSI: Abort returned with adapter response...\n"); |
| 2076 | #endif |
| 2077 | |
| 2078 | /*if abort went well, call saved done, then return success or error */ |
| 2079 | if (cmd->result == (DID_ABORT << 16)) |
| 2080 | { |
| 2081 | cmd->result |= DID_ABORT << 16; |
| 2082 | if (cmd->scsi_done) |
| 2083 | (cmd->scsi_done) (cmd); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2084 | ld(shpnt)[ldn].cmd = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2085 | #ifdef IM_DEBUG_PROBE |
| 2086 | printk("IBM MCA SCSI: Abort finished with success.\n"); |
| 2087 | #endif |
| 2088 | return SUCCESS; |
| 2089 | } else { |
| 2090 | cmd->result |= DID_NO_CONNECT << 16; |
| 2091 | if (cmd->scsi_done) |
| 2092 | (cmd->scsi_done) (cmd); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2093 | ld(shpnt)[ldn].cmd = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | #ifdef IM_DEBUG_PROBE |
| 2095 | printk("IBM MCA SCSI: Abort failed.\n"); |
| 2096 | #endif |
| 2097 | return FAILED; |
| 2098 | } |
| 2099 | } |
| 2100 | |
Jeff Garzik | 8fa728a | 2005-05-28 07:54:40 -0400 | [diff] [blame] | 2101 | static int ibmmca_abort(Scsi_Cmnd * cmd) |
| 2102 | { |
| 2103 | struct Scsi_Host *shpnt = cmd->device->host; |
| 2104 | int rc; |
| 2105 | |
| 2106 | spin_lock_irq(shpnt->host_lock); |
| 2107 | rc = __ibmmca_abort(cmd); |
| 2108 | spin_unlock_irq(shpnt->host_lock); |
| 2109 | |
| 2110 | return rc; |
| 2111 | } |
| 2112 | |
Jeff Garzik | df0ae24 | 2005-05-28 07:57:14 -0400 | [diff] [blame] | 2113 | static int __ibmmca_host_reset(Scsi_Cmnd * cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | { |
| 2115 | struct Scsi_Host *shpnt; |
| 2116 | Scsi_Cmnd *cmd_aid; |
| 2117 | int ticks, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2118 | unsigned long imm_command; |
| 2119 | |
Eric Sesterhenn | 125e187 | 2006-06-23 02:06:06 -0700 | [diff] [blame] | 2120 | BUG_ON(cmd == NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2121 | |
| 2122 | ticks = IM_RESET_DELAY * HZ; |
| 2123 | shpnt = cmd->device->host; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2125 | if (local_checking_phase_flag(shpnt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2126 | printk(KERN_WARNING "IBM MCA SCSI: unable to reset while checking devices.\n"); |
| 2127 | return FAILED; |
| 2128 | } |
| 2129 | |
| 2130 | /* issue reset immediate command to subsystem, and wait for interrupt */ |
| 2131 | printk("IBM MCA SCSI: resetting all devices.\n"); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2132 | reset_status(shpnt) = IM_RESET_IN_PROGRESS; |
| 2133 | last_scsi_command(shpnt)[0xf] = IM_RESET_IMM_CMD; |
| 2134 | last_scsi_type(shpnt)[0xf] = IM_IMM_CMD; |
| 2135 | imm_command = inl(IM_CMD_REG(shpnt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2136 | imm_command &= (unsigned long) (0xffff0000); /* mask reserved stuff */ |
| 2137 | imm_command |= (unsigned long) (IM_RESET_IMM_CMD); |
| 2138 | /* must wait for attention reg not busy */ |
| 2139 | while (1) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2140 | if (!(inb(IM_STAT_REG(shpnt)) & IM_BUSY)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | break; |
| 2142 | spin_unlock_irq(shpnt->host_lock); |
| 2143 | yield(); |
| 2144 | spin_lock_irq(shpnt->host_lock); |
| 2145 | } |
| 2146 | /*write registers and enable system interrupts */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2147 | outl(imm_command, IM_CMD_REG(shpnt)); |
| 2148 | outb(IM_IMM_CMD | 0xf, IM_ATTN_REG(shpnt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2149 | /* wait for interrupt finished or intr_stat register to be set, as the |
| 2150 | * interrupt will not be executed, while we are in here! */ |
| 2151 | |
| 2152 | /* FIXME: This is really really icky we so want a sleeping version of this ! */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2153 | while (reset_status(shpnt) == IM_RESET_IN_PROGRESS && --ticks && ((inb(IM_INTR_REG(shpnt)) & 0x8f) != 0x8f)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | udelay((1 + 999 / HZ) * 1000); |
| 2155 | barrier(); |
| 2156 | } |
| 2157 | /* if reset did not complete, just return an error */ |
| 2158 | if (!ticks) { |
| 2159 | printk(KERN_ERR "IBM MCA SCSI: reset did not complete within %d seconds.\n", IM_RESET_DELAY); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2160 | reset_status(shpnt) = IM_RESET_FINISHED_FAIL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 | return FAILED; |
| 2162 | } |
| 2163 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2164 | if ((inb(IM_INTR_REG(shpnt)) & 0x8f) == 0x8f) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2165 | /* analysis done by this routine and not by the intr-routine */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2166 | if (inb(IM_INTR_REG(shpnt)) == 0xaf) |
| 2167 | reset_status(shpnt) = IM_RESET_FINISHED_OK_NO_INT; |
| 2168 | else if (inb(IM_INTR_REG(shpnt)) == 0xcf) |
| 2169 | reset_status(shpnt) = IM_RESET_FINISHED_FAIL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | else /* failed, 4get it */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2171 | reset_status(shpnt) = IM_RESET_NOT_IN_PROGRESS_NO_INT; |
| 2172 | outb(IM_EOI | 0xf, IM_ATTN_REG(shpnt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2173 | } |
| 2174 | |
| 2175 | /* if reset failed, just return an error */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2176 | if (reset_status(shpnt) == IM_RESET_FINISHED_FAIL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | printk(KERN_ERR "IBM MCA SCSI: reset failed.\n"); |
| 2178 | return FAILED; |
| 2179 | } |
| 2180 | |
| 2181 | /* so reset finished ok - call outstanding done's, and return success */ |
| 2182 | printk(KERN_INFO "IBM MCA SCSI: Reset successfully completed.\n"); |
| 2183 | for (i = 0; i < MAX_LOG_DEV; i++) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2184 | cmd_aid = ld(shpnt)[i].cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2185 | if (cmd_aid && cmd_aid->scsi_done) { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2186 | ld(shpnt)[i].cmd = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2187 | cmd_aid->result = DID_RESET << 16; |
| 2188 | } |
| 2189 | } |
| 2190 | return SUCCESS; |
| 2191 | } |
| 2192 | |
Jeff Garzik | df0ae24 | 2005-05-28 07:57:14 -0400 | [diff] [blame] | 2193 | static int ibmmca_host_reset(Scsi_Cmnd * cmd) |
| 2194 | { |
| 2195 | struct Scsi_Host *shpnt = cmd->device->host; |
| 2196 | int rc; |
| 2197 | |
| 2198 | spin_lock_irq(shpnt->host_lock); |
| 2199 | rc = __ibmmca_host_reset(cmd); |
| 2200 | spin_unlock_irq(shpnt->host_lock); |
| 2201 | |
| 2202 | return rc; |
| 2203 | } |
| 2204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2205 | static int ibmmca_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int *info) |
| 2206 | { |
| 2207 | int size = capacity; |
| 2208 | info[0] = 64; |
| 2209 | info[1] = 32; |
| 2210 | info[2] = size / (info[0] * info[1]); |
| 2211 | if (info[2] >= 1024) { |
| 2212 | info[0] = 128; |
| 2213 | info[1] = 63; |
| 2214 | info[2] = size / (info[0] * info[1]); |
| 2215 | if (info[2] >= 1024) { |
| 2216 | info[0] = 255; |
| 2217 | info[1] = 63; |
| 2218 | info[2] = size / (info[0] * info[1]); |
| 2219 | if (info[2] >= 1024) |
| 2220 | info[2] = 1023; |
| 2221 | } |
| 2222 | } |
| 2223 | return 0; |
| 2224 | } |
| 2225 | |
| 2226 | /* calculate percentage of total accesses on a ldn */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2227 | static int ldn_access_load(struct Scsi_Host *shpnt, int ldn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2228 | { |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2229 | if (IBM_DS(shpnt).total_accesses == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2230 | return (0); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2231 | if (IBM_DS(shpnt).ldn_access[ldn] == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | return (0); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2233 | return (IBM_DS(shpnt).ldn_access[ldn] * 100) / IBM_DS(shpnt).total_accesses; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | } |
| 2235 | |
| 2236 | /* calculate total amount of r/w-accesses */ |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2237 | static int ldn_access_total_read_write(struct Scsi_Host *shpnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2238 | { |
| 2239 | int a; |
| 2240 | int i; |
| 2241 | |
| 2242 | a = 0; |
| 2243 | for (i = 0; i <= MAX_LOG_DEV; i++) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2244 | a += IBM_DS(shpnt).ldn_read_access[i] + IBM_DS(shpnt).ldn_write_access[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2245 | return (a); |
| 2246 | } |
| 2247 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2248 | static int ldn_access_total_inquiry(struct Scsi_Host *shpnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | { |
| 2250 | int a; |
| 2251 | int i; |
| 2252 | |
| 2253 | a = 0; |
| 2254 | for (i = 0; i <= MAX_LOG_DEV; i++) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2255 | a += IBM_DS(shpnt).ldn_inquiry_access[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2256 | return (a); |
| 2257 | } |
| 2258 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2259 | static int ldn_access_total_modeselect(struct Scsi_Host *shpnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2260 | { |
| 2261 | int a; |
| 2262 | int i; |
| 2263 | |
| 2264 | a = 0; |
| 2265 | for (i = 0; i <= MAX_LOG_DEV; i++) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2266 | a += IBM_DS(shpnt).ldn_modeselect_access[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2267 | return (a); |
| 2268 | } |
| 2269 | |
| 2270 | /* routine to display info in the proc-fs-structure (a deluxe feature) */ |
| 2271 | static int ibmmca_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start, off_t offset, int length, int inout) |
| 2272 | { |
| 2273 | int len = 0; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2274 | int i, id, lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | unsigned long flags; |
| 2276 | int max_pun; |
| 2277 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2278 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2279 | spin_lock_irqsave(shpnt->host_lock, flags); /* Check it */ |
| 2280 | |
| 2281 | max_pun = subsystem_maxid(shpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2282 | |
| 2283 | len += sprintf(buffer + len, "\n IBM-SCSI-Subsystem-Linux-Driver, Version %s\n\n\n", IBMMCA_SCSI_DRIVER_VERSION); |
| 2284 | len += sprintf(buffer + len, " SCSI Access-Statistics:\n"); |
| 2285 | len += sprintf(buffer + len, " Device Scanning Order....: %s\n", (ibm_ansi_order) ? "IBM/ANSI" : "New Industry Standard"); |
| 2286 | #ifdef CONFIG_SCSI_MULTI_LUN |
| 2287 | len += sprintf(buffer + len, " Multiple LUN probing.....: Yes\n"); |
| 2288 | #else |
| 2289 | len += sprintf(buffer + len, " Multiple LUN probing.....: No\n"); |
| 2290 | #endif |
| 2291 | len += sprintf(buffer + len, " This Hostnumber..........: %d\n", shpnt->host_no); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2292 | len += sprintf(buffer + len, " Base I/O-Port............: 0x%x\n", (unsigned int) (IM_CMD_REG(shpnt))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | len += sprintf(buffer + len, " (Shared) IRQ.............: %d\n", IM_IRQ); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2294 | len += sprintf(buffer + len, " Total Interrupts.........: %d\n", IBM_DS(shpnt).total_interrupts); |
| 2295 | len += sprintf(buffer + len, " Total SCSI Accesses......: %d\n", IBM_DS(shpnt).total_accesses); |
| 2296 | len += sprintf(buffer + len, " Total short SCBs.........: %d\n", IBM_DS(shpnt).scbs); |
| 2297 | len += sprintf(buffer + len, " Total long SCBs..........: %d\n", IBM_DS(shpnt).long_scbs); |
| 2298 | len += sprintf(buffer + len, " Total SCSI READ/WRITE..: %d\n", ldn_access_total_read_write(shpnt)); |
| 2299 | len += sprintf(buffer + len, " Total SCSI Inquiries...: %d\n", ldn_access_total_inquiry(shpnt)); |
| 2300 | len += sprintf(buffer + len, " Total SCSI Modeselects.: %d\n", ldn_access_total_modeselect(shpnt)); |
| 2301 | len += sprintf(buffer + len, " Total SCSI other cmds..: %d\n", IBM_DS(shpnt).total_accesses - ldn_access_total_read_write(shpnt) |
| 2302 | - ldn_access_total_modeselect(shpnt) |
| 2303 | - ldn_access_total_inquiry(shpnt)); |
| 2304 | len += sprintf(buffer + len, " Total SCSI command fails.: %d\n\n", IBM_DS(shpnt).total_errors); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2305 | len += sprintf(buffer + len, " Logical-Device-Number (LDN) Access-Statistics:\n"); |
| 2306 | len += sprintf(buffer + len, " LDN | Accesses [%%] | READ | WRITE | ASSIGNMENTS\n"); |
| 2307 | len += sprintf(buffer + len, " -----|--------------|-----------|-----------|--------------\n"); |
| 2308 | for (i = 0; i <= MAX_LOG_DEV; i++) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2309 | len += sprintf(buffer + len, " %2X | %3d | %8d | %8d | %8d\n", i, ldn_access_load(shpnt, i), IBM_DS(shpnt).ldn_read_access[i], IBM_DS(shpnt).ldn_write_access[i], IBM_DS(shpnt).ldn_assignments[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2310 | len += sprintf(buffer + len, " -----------------------------------------------------------\n\n"); |
| 2311 | len += sprintf(buffer + len, " Dynamical-LDN-Assignment-Statistics:\n"); |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2312 | len += sprintf(buffer + len, " Number of physical SCSI-devices..: %d (+ Adapter)\n", IBM_DS(shpnt).total_scsi_devices); |
| 2313 | len += sprintf(buffer + len, " Dynamical Assignment necessary...: %s\n", IBM_DS(shpnt).dyn_flag ? "Yes" : "No "); |
| 2314 | len += sprintf(buffer + len, " Next LDN to be assigned..........: 0x%x\n", next_ldn(shpnt)); |
| 2315 | len += sprintf(buffer + len, " Dynamical assignments done yet...: %d\n", IBM_DS(shpnt).dynamical_assignments); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2316 | len += sprintf(buffer + len, "\n Current SCSI-Device-Mapping:\n"); |
| 2317 | len += sprintf(buffer + len, " Physical SCSI-Device Map Logical SCSI-Device Map\n"); |
| 2318 | len += sprintf(buffer + len, " ID\\LUN 0 1 2 3 4 5 6 7 ID\\LUN 0 1 2 3 4 5 6 7\n"); |
| 2319 | for (id = 0; id < max_pun; id++) { |
| 2320 | len += sprintf(buffer + len, " %2d ", id); |
| 2321 | for (lun = 0; lun < 8; lun++) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2322 | len += sprintf(buffer + len, "%2s ", ti_p(get_scsi(shpnt)[id][lun])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2323 | len += sprintf(buffer + len, " %2d ", id); |
| 2324 | for (lun = 0; lun < 8; lun++) |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2325 | len += sprintf(buffer + len, "%2s ", ti_l(get_ldn(shpnt)[id][lun])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2326 | len += sprintf(buffer + len, "\n"); |
| 2327 | } |
| 2328 | |
| 2329 | len += sprintf(buffer + len, "(A = IBM-Subsystem, D = Harddisk, T = Tapedrive, P = Processor, W = WORM,\n"); |
| 2330 | len += sprintf(buffer + len, " R = CD-ROM, S = Scanner, M = MO-Drive, C = Medium-Changer, + = unprovided LUN,\n"); |
| 2331 | len += sprintf(buffer + len, " - = nothing found, nothing assigned or unprobed LUN)\n\n"); |
| 2332 | |
| 2333 | *start = buffer + offset; |
| 2334 | len -= offset; |
| 2335 | if (len > length) |
| 2336 | len = length; |
| 2337 | spin_unlock_irqrestore(shpnt->host_lock, flags); |
| 2338 | return len; |
| 2339 | } |
| 2340 | |
| 2341 | static int option_setup(char *str) |
| 2342 | { |
| 2343 | int ints[IM_MAX_HOSTS]; |
| 2344 | char *cur = str; |
| 2345 | int i = 1; |
| 2346 | |
| 2347 | while (cur && isdigit(*cur) && i <= IM_MAX_HOSTS) { |
| 2348 | ints[i++] = simple_strtoul(cur, NULL, 0); |
| 2349 | if ((cur = strchr(cur, ',')) != NULL) |
| 2350 | cur++; |
| 2351 | } |
| 2352 | ints[0] = i - 1; |
| 2353 | internal_ibmmca_scsi_setup(cur, ints); |
OGAWA Hirofumi | 9b41046 | 2006-03-31 02:30:33 -0800 | [diff] [blame] | 2354 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | } |
| 2356 | |
| 2357 | __setup("ibmmcascsi=", option_setup); |
| 2358 | |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2359 | static struct mca_driver ibmmca_driver = { |
| 2360 | .id_table = ibmmca_id_table, |
| 2361 | .driver = { |
| 2362 | .name = "ibmmca", |
| 2363 | .bus = &mca_bus_type, |
| 2364 | .probe = ibmmca_probe, |
| 2365 | .remove = __devexit_p(ibmmca_remove), |
| 2366 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2367 | }; |
James Bottomley | 67b2009 | 2007-05-03 11:13:08 -0500 | [diff] [blame^] | 2368 | |
| 2369 | static int __init ibmmca_init(void) |
| 2370 | { |
| 2371 | #ifdef MODULE |
| 2372 | /* If the driver is run as module, read from conf.modules or cmd-line */ |
| 2373 | if (boot_options) |
| 2374 | option_setup(boot_options); |
| 2375 | #endif |
| 2376 | |
| 2377 | return mca_register_driver_integrated(&ibmmca_driver, MCA_INTEGSCSI); |
| 2378 | } |
| 2379 | |
| 2380 | static void __exit ibmmca_exit(void) |
| 2381 | { |
| 2382 | mca_unregister_driver(&ibmmca_driver); |
| 2383 | } |
| 2384 | |
| 2385 | module_init(ibmmca_init); |
| 2386 | module_exit(ibmmca_exit); |