1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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>
32#include <linux/spinlock.h>
33#include <linux/init.h>
34
35#include <asm/system.h>
36#include <asm/io.h>
37
38#include "scsi.h"
39#include <scsi/scsi_host.h>
40
41
42static int ibmmca_queuecommand (struct Scsi_Host *, struct scsi_cmnd *);
43static int ibmmca_abort (Scsi_Cmnd *);
44static int ibmmca_host_reset (Scsi_Cmnd *);
45static int ibmmca_biosparam (struct scsi_device *, struct block_device *, sector_t, int *);
46static int ibmmca_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start, off_t offset, int length, int inout);
47
48
49
50
51#define IBMMCA_SCSI_DRIVER_VERSION "4.0b-ac"
52
53
54#define IM_MAX_HOSTS 8
55#define IM_RESET_DELAY 60
56
57
58
59#undef IM_DEBUG_TIMEOUT
60#define TIMEOUT_PUN 0
61#define TIMEOUT_LUN 0
62
63#undef IM_DEBUG_INT
64
65#undef IM_DEBUG_CMD
66
67#undef IM_DEBUG_CMD_SPEC_DEV
68
69#undef IM_DEBUG_PROBE
70
71
72#define IM_DEBUG_CMD_DEVICE TYPE_TAPE
73
74
75#define IM_CMD_REG(h) ((h)->io_port)
76#define IM_ATTN_REG(h) ((h)->io_port+4)
77#define IM_CTR_REG(h) ((h)->io_port+5)
78#define IM_INTR_REG(h) ((h)->io_port+6)
79#define IM_STAT_REG(h) ((h)->io_port+7)
80
81
82#define IM_IO_PORT 0x3540
83
84#define IM_N_IO_PORT 8
85
86
87
88#define IM_IMM_CMD 0x10
89#define IM_SCB 0x30
90#define IM_LONG_SCB 0x40
91#define IM_EOI 0xe0
92
93
94#define IM_HW_RESET 0x80
95#define IM_ENABLE_DMA 0x02
96#define IM_ENABLE_INTR 0x01
97
98
99
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
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
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
124struct im_scb {
125 unsigned short command;
126 unsigned short enable;
127 union {
128 unsigned long log_blk_adr;
129 unsigned char scsi_cmd_length;
130 } u1;
131 unsigned long sys_buf_adr;
132 unsigned long sys_buf_length;
133 unsigned long tsb_adr;
134 unsigned long scb_chain_adr;
135 union {
136 struct {
137 unsigned short count;
138 unsigned short length;
139 } blk;
140 unsigned char scsi_command[12];
141 } u2;
142};
143
144
145struct im_sge {
146 void *address;
147 unsigned long byte_length;
148};
149
150
151struct im_pos_info {
152 unsigned short pos_id;
153 unsigned char pos_3a;
154 unsigned char pos_2;
155 unsigned char int_level;
156 unsigned char pos_4a;
157 unsigned short connector_size;
158 unsigned char num_luns;
159 unsigned char num_puns;
160 unsigned char pacing_factor;
161 unsigned char num_ldns;
162 unsigned char eoi_off;
163 unsigned char max_busy;
164 unsigned short cache_stat;
165 unsigned short retry_stat;
166 unsigned char pos_4b;
167 unsigned char pos_3b;
168 unsigned char pos_6;
169 unsigned char pos_5;
170 unsigned short max_overlap;
171 unsigned short num_bus;
172};
173
174
175#define IM_NO_SYNCHRONOUS 0x0040
176#define IM_NO_DISCONNECT 0x0080
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
188#define IM_GET_COMMAND_COMPLETE_STATUS_CMD 0x1c07
189#define IM_GET_POS_INFO_CMD 0x1c0a
190#define IM_READ_PREFETCH_CMD 0x1c31
191#define IM_FOMAT_UNIT_CMD 0x1c16
192#define IM_REASSIGN_BLOCK_CMD 0x1c18
193
194
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
204struct 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
221#define IM_IRQ 14
222
223#define IM_IRQ_FW 11
224
225
226
227
228
229
230
231
232#define MOD95_LED_PORT 0x108
233
234#define PS2_SYS_CTR 0x92
235
236#define LED_DISP 1
237#define LED_ADISP 2
238#define LED_ACTIVITY 4
239
240#define CMD_FAIL 255
241
242
243
244
245
246
247
248
249
250static int display_mode = 0;
251
252static unsigned int adapter_timeout = 45;
253
254static unsigned int global_command_error_excuse = 0;
255
256static int global_adapter_speed = 0;
257
258
259
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
269
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
276
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
282#define IBM_INTEGSCSI 5
283
284
285#define FORCED_DETECTION 100
286#define INTEGRATED_SCSI 101
287
288
289static short ibmmca_id_table[] = {
290 0x8efc,
291 0x8efd,
292 0x8ef8,
293 0x8eff,
294 0x8efe,
295
296 0
297};
298
299static const char *ibmmca_description[] = {
300 "IBM SCSI-2 F/W Adapter",
301 "IBM 7568 Industrial Computer SCSI Adapter w/Cache",
302 "IBM Expansion Unit SCSI Controller",
303 "IBM SCSI Adapter w/Cache",
304 "IBM SCSI Adapter",
305 "IBM Integrated SCSI Controller",
306};
307
308
309
310#define MAX_LOG_DEV 15
311
312
313struct logical_device {
314 struct im_scb scb;
315 struct im_tsb tsb;
316 struct im_sge sge[16];
317 unsigned char buf[256];
318 Scsi_Cmnd *cmd;
319 int device_type;
320
321 int block_length;
322 int cache_flag;
323 int retry_flag;
324};
325
326
327struct Driver_Statistics {
328
329 int ldn_access[MAX_LOG_DEV + 1];
330 int ldn_read_access[MAX_LOG_DEV + 1];
331 int ldn_write_access[MAX_LOG_DEV + 1];
332 int ldn_inquiry_access[MAX_LOG_DEV + 1];
333 int ldn_modeselect_access[MAX_LOG_DEV + 1];
334 int scbs;
335 int long_scbs;
336 int total_accesses;
337 int total_interrupts;
338
339 int total_errors;
340
341 int total_scsi_devices;
342 int dyn_flag;
343 int dynamical_assignments;
344 int ldn_assignments[MAX_LOG_DEV + 1];
345
346};
347
348
349struct ibmmca_hostdata {
350
351 struct logical_device _ld[MAX_LOG_DEV + 1];
352
353 unsigned char _get_ldn[16][8];
354
355
356 unsigned char _get_scsi[16][8];
357
358 int _local_checking_phase_flag;
359
360 int _got_interrupt;
361
362 int _stat_result;
363
364 int _reset_status;
365
366 int _last_scsi_command[MAX_LOG_DEV + 1];
367
368 int _last_scsi_type[MAX_LOG_DEV + 1];
369
370 int _last_scsi_blockcount[MAX_LOG_DEV + 1];
371
372 unsigned long _last_scsi_logical_block[MAX_LOG_DEV + 1];
373
374
375
376 int _next_ldn;
377
378 struct Driver_Statistics _IBM_DS;
379
380 unsigned int _pos[8];
381
382
383 int _special;
384
385 int _connector_size;
386
387 int _adapter_speed;
388};
389
390
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])
415
416
417
418#define TYPE_IBM_SCSI_ADAPTER 0x2F
419
420
421
422
423#define TYPE_NO_DEVICE 0xFF
424
425
426
427#ifndef TYPE_MEDIUM_CHANGER
428#define TYPE_MEDIUM_CHANGER 0x08
429#endif
430
431
432#define SET_LDN 0
433#define REMOVE_LDN 1
434
435
436#define PROBE_LDN 0
437
438
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
447#define NO_SCSI 0xffff
448
449
450
451
452static int io_port[IM_MAX_HOSTS] = { 0, 0, 0, 0, 0, 0, 0, 0 };
453static int scsi_id[IM_MAX_HOSTS] = { 7, 7, 7, 7, 7, 7, 7, 7 };
454
455
456
457#if defined(MODULE)
458static char *boot_options = NULL;
459module_param(boot_options, charp, 0);
460module_param_array(io_port, int, NULL, 0);
461module_param_array(scsi_id, int, NULL, 0);
462
463MODULE_LICENSE("GPL");
464#endif
465
466static int disk_rw_in_progress = 0;
467
468static unsigned int pos[8];
469
470
471
472#ifdef CONFIG_IBMMCA_SCSI_ORDER_STANDARD
473static char ibm_ansi_order = 1;
474#else
475static char ibm_ansi_order = 0;
476#endif
477
478static void issue_cmd(struct Scsi_Host *, unsigned long, unsigned char);
479static void internal_done(Scsi_Cmnd * cmd);
480static void check_devices(struct Scsi_Host *, int);
481static int immediate_assign(struct Scsi_Host *, unsigned int, unsigned int, unsigned int, unsigned int);
482static int immediate_feature(struct Scsi_Host *, unsigned int, unsigned int);
483#ifdef CONFIG_IBMMCA_SCSI_DEV_RESET
484static int immediate_reset(struct Scsi_Host *, unsigned int);
485#endif
486static int device_inquiry(struct Scsi_Host *, int);
487static int read_capacity(struct Scsi_Host *, int);
488static int get_pos_info(struct Scsi_Host *);
489static char *ti_p(int);
490static char *ti_l(int);
491static char *ibmrate(unsigned int, int);
492static int probe_display(int);
493static int probe_bus_mode(struct Scsi_Host *);
494static int device_exists(struct Scsi_Host *, int, int *, int *);
495static int option_setup(char *);
496
497static int ldn_access_load(struct Scsi_Host *, int);
498static int ldn_access_total_read_write(struct Scsi_Host *);
499
500static irqreturn_t interrupt_handler(int irq, void *dev_id)
501{
502 unsigned int intr_reg;
503 unsigned int cmd_result;
504 unsigned int ldn;
505 unsigned long flags;
506 Scsi_Cmnd *cmd;
507 int lastSCSI;
508 struct device *dev = dev_id;
509 struct Scsi_Host *shpnt = dev_get_drvdata(dev);
510
511 spin_lock_irqsave(shpnt->host_lock, flags);
512
513 if(!(inb(IM_STAT_REG(shpnt)) & IM_INTR_REQUEST)) {
514 spin_unlock_irqrestore(shpnt->host_lock, flags);
515 return IRQ_NONE;
516 }
517
518
519
520 if ((reset_status(shpnt) == IM_RESET_NOT_IN_PROGRESS_NO_INT) || (reset_status(shpnt) == IM_RESET_FINISHED_OK_NO_INT)) {
521 reset_status(shpnt) = IM_RESET_NOT_IN_PROGRESS;
522 spin_unlock_irqrestore(shpnt->host_lock, flags);
523 return IRQ_HANDLED;
524 }
525
526
527 while (1) {
528 if (!(inb(IM_STAT_REG(shpnt)) & IM_BUSY))
529 break;
530 cpu_relax();
531 }
532
533
534 intr_reg = (unsigned char) (inb(IM_INTR_REG(shpnt)));
535 cmd_result = intr_reg & 0xf0;
536 ldn = intr_reg & 0x0f;
537
538 lastSCSI = last_scsi_command(shpnt)[ldn];
539 outb(IM_EOI | ldn, IM_ATTN_REG(shpnt));
540
541
542 if (!global_command_error_excuse) {
543 switch (cmd_result) {
544
545 case IM_ADAPTER_HW_FAILURE:
546 case IM_SOFTWARE_SEQUENCING_ERROR:
547 case IM_CMD_ERROR:
548 printk(KERN_ERR "IBM MCA SCSI: Fatal Subsystem ERROR!\n");
549 printk(KERN_ERR " Last cmd=0x%x, ena=%x, len=", lastSCSI, ld(shpnt)[ldn].scb.enable);
550 if (ld(shpnt)[ldn].cmd)
551 printk("%ld/%ld,", (long) (scsi_bufflen(ld(shpnt)[ldn].cmd)), (long) (ld(shpnt)[ldn].scb.sys_buf_length));
552 else
553 printk("none,");
554 if (ld(shpnt)[ldn].cmd)
555 printk("Blocksize=%d", ld(shpnt)[ldn].scb.u2.blk.length);
556 else
557 printk("Blocksize=none");
558 printk(", host=%p, ldn=0x%x\n", shpnt, ldn);
559 if (ld(shpnt)[ldn].cmd) {
560 printk(KERN_ERR "Blockcount=%d/%d\n", last_scsi_blockcount(shpnt)[ldn], ld(shpnt)[ldn].scb.u2.blk.count);
561 printk(KERN_ERR "Logical block=%lx/%lx\n", last_scsi_logical_block(shpnt)[ldn], ld(shpnt)[ldn].scb.u1.log_blk_adr);
562 }
563 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");
564
565 printk(KERN_ERR "IBM MCA SCSI: Subsystem Error-Status follows:\n");
566 printk(KERN_ERR " Command Type................: %x\n", last_scsi_type(shpnt)[ldn]);
567 printk(KERN_ERR " Attention Register..........: %x\n", inb(IM_ATTN_REG(shpnt)));
568 printk(KERN_ERR " Basic Control Register......: %x\n", inb(IM_CTR_REG(shpnt)));
569 printk(KERN_ERR " Interrupt Status Register...: %x\n", intr_reg);
570 printk(KERN_ERR " Basic Status Register.......: %x\n", inb(IM_STAT_REG(shpnt)));
571 if ((last_scsi_type(shpnt)[ldn] == IM_SCB) || (last_scsi_type(shpnt)[ldn] == IM_LONG_SCB)) {
572 printk(KERN_ERR " SCB-Command.................: %x\n", ld(shpnt)[ldn].scb.command);
573 printk(KERN_ERR " SCB-Enable..................: %x\n", ld(shpnt)[ldn].scb.enable);
574 printk(KERN_ERR " SCB-logical block address...: %lx\n", ld(shpnt)[ldn].scb.u1.log_blk_adr);
575 printk(KERN_ERR " SCB-system buffer address...: %lx\n", ld(shpnt)[ldn].scb.sys_buf_adr);
576 printk(KERN_ERR " SCB-system buffer length....: %lx\n", ld(shpnt)[ldn].scb.sys_buf_length);
577 printk(KERN_ERR " SCB-tsb address.............: %lx\n", ld(shpnt)[ldn].scb.tsb_adr);
578 printk(KERN_ERR " SCB-Chain address...........: %lx\n", ld(shpnt)[ldn].scb.scb_chain_adr);
579 printk(KERN_ERR " SCB-block count.............: %x\n", ld(shpnt)[ldn].scb.u2.blk.count);
580 printk(KERN_ERR " SCB-block length............: %x\n", ld(shpnt)[ldn].scb.u2.blk.length);
581 }
582 printk(KERN_ERR " Send this report to the maintainer.\n");
583 panic("IBM MCA SCSI: Fatal error message from the subsystem (0x%X,0x%X)!\n", lastSCSI, cmd_result);
584 break;
585 }
586 } else {
587
588
589
590 switch (cmd_result) {
591 case IM_ADAPTER_HW_FAILURE:
592 case IM_SOFTWARE_SEQUENCING_ERROR:
593 case IM_CMD_ERROR:
594 global_command_error_excuse = CMD_FAIL;
595 break;
596 default:
597 global_command_error_excuse = 0;
598 break;
599 }
600 }
601
602 IBM_DS(shpnt).total_interrupts++;
603
604 if (local_checking_phase_flag(shpnt)) {
605 stat_result(shpnt) = cmd_result;
606 got_interrupt(shpnt) = 1;
607 reset_status(shpnt) = IM_RESET_FINISHED_OK;
608 last_scsi_command(shpnt)[ldn] = NO_SCSI;
609 spin_unlock_irqrestore(shpnt->host_lock, flags);
610 return IRQ_HANDLED;
611 }
612
613 if (last_scsi_type(shpnt)[ldn] == IM_IMM_CMD) {
614
615 if ((reset_status(shpnt) == IM_RESET_IN_PROGRESS) && (last_scsi_command(shpnt)[ldn] == IM_RESET_IMM_CMD)) {
616 if (cmd_result == IM_CMD_COMPLETED_WITH_FAILURE) {
617 disk_rw_in_progress = 0;
618 PS2_DISK_LED_OFF();
619 reset_status(shpnt) = IM_RESET_FINISHED_FAIL;
620 } else {
621
622 disk_rw_in_progress = 0;
623 PS2_DISK_LED_OFF();
624 reset_status(shpnt) = IM_RESET_FINISHED_OK;
625 }
626 stat_result(shpnt) = cmd_result;
627 last_scsi_command(shpnt)[ldn] = NO_SCSI;
628 last_scsi_type(shpnt)[ldn] = 0;
629 spin_unlock_irqrestore(shpnt->host_lock, flags);
630 return IRQ_HANDLED;
631 } else if (last_scsi_command(shpnt)[ldn] == IM_ABORT_IMM_CMD) {
632
633#ifdef IM_DEBUG_PROBE
634 printk("IBM MCA SCSI: Interrupt from SCSI-abort.\n");
635#endif
636 disk_rw_in_progress = 0;
637 PS2_DISK_LED_OFF();
638 cmd = ld(shpnt)[ldn].cmd;
639 ld(shpnt)[ldn].cmd = NULL;
640 if (cmd_result == IM_CMD_COMPLETED_WITH_FAILURE)
641 cmd->result = DID_NO_CONNECT << 16;
642 else
643 cmd->result = DID_ABORT << 16;
644 stat_result(shpnt) = cmd_result;
645 last_scsi_command(shpnt)[ldn] = NO_SCSI;
646 last_scsi_type(shpnt)[ldn] = 0;
647 if (cmd->scsi_done)
648 (cmd->scsi_done) (cmd);
649 spin_unlock_irqrestore(shpnt->host_lock, flags);
650 return IRQ_HANDLED;
651 } else {
652 disk_rw_in_progress = 0;
653 PS2_DISK_LED_OFF();
654 reset_status(shpnt) = IM_RESET_FINISHED_OK;
655 stat_result(shpnt) = cmd_result;
656 last_scsi_command(shpnt)[ldn] = NO_SCSI;
657 spin_unlock_irqrestore(shpnt->host_lock, flags);
658 return IRQ_HANDLED;
659 }
660 }
661 last_scsi_command(shpnt)[ldn] = NO_SCSI;
662 last_scsi_type(shpnt)[ldn] = 0;
663 cmd = ld(shpnt)[ldn].cmd;
664 ld(shpnt)[ldn].cmd = NULL;
665#ifdef IM_DEBUG_TIMEOUT
666 if (cmd) {
667 if ((cmd->target == TIMEOUT_PUN) && (cmd->device->lun == TIMEOUT_LUN)) {
668 spin_unlock_irqsave(shpnt->host_lock, flags);
669 printk("IBM MCA SCSI: Ignoring interrupt from pun=%x, lun=%x.\n", cmd->target, cmd->device->lun);
670 return IRQ_HANDLED;
671 }
672 }
673#endif
674
675 if (!cmd)
676 {
677 spin_unlock_irqrestore(shpnt->host_lock, flags);
678 return IRQ_HANDLED;
679 }
680
681#ifdef IM_DEBUG_INT
682 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);
683#endif
684
685 if ((ld(shpnt)[ldn].device_type != TYPE_NO_LUN) && (ld(shpnt)[ldn].device_type != TYPE_NO_DEVICE)) {
686
687 if (--disk_rw_in_progress == 0)
688 PS2_DISK_LED_OFF();
689 }
690
691
692
693
694
695 if (cmd_result == IM_CMD_COMPLETED_WITH_FAILURE) {
696 cmd->result = (unsigned char) (ld(shpnt)[ldn].tsb.dev_status & 0x1e);
697 IBM_DS(shpnt).total_errors++;
698 } else
699 cmd->result = 0;
700
701 if (lastSCSI == NO_SCSI) {
702 cmd->result |= DID_BAD_INTR << 16;
703 printk("IBM MCA SCSI: WARNING - Interrupt from non-pending SCSI-command!\n");
704 } else
705 cmd->result |= DID_OK << 16;
706 if (cmd->scsi_done)
707 (cmd->scsi_done) (cmd);
708 spin_unlock_irqrestore(shpnt->host_lock, flags);
709 return IRQ_HANDLED;
710}
711
712static void issue_cmd(struct Scsi_Host *shpnt, unsigned long cmd_reg,
713 unsigned char attn_reg)
714{
715 unsigned long flags;
716
717 while (1) {
718 spin_lock_irqsave(shpnt->host_lock, flags);
719 if (!(inb(IM_STAT_REG(shpnt)) & IM_BUSY))
720 break;
721 spin_unlock_irqrestore(shpnt->host_lock, flags);
722 }
723
724 outl(cmd_reg, IM_CMD_REG(shpnt));
725 outb(attn_reg, IM_ATTN_REG(shpnt));
726 spin_unlock_irqrestore(shpnt->host_lock, flags);
727}
728
729static void internal_done(Scsi_Cmnd * cmd)
730{
731 cmd->SCp.Status++;
732 return;
733}
734
735
736static int device_inquiry(struct Scsi_Host *shpnt, int ldn)
737{
738 int retr;
739 struct im_scb *scb;
740 struct im_tsb *tsb;
741 unsigned char *buf;
742
743 scb = &(ld(shpnt)[ldn].scb);
744 tsb = &(ld(shpnt)[ldn].tsb);
745 buf = (unsigned char *) (&(ld(shpnt)[ldn].buf));
746 ld(shpnt)[ldn].tsb.dev_status = 0;
747 for (retr = 0; retr < 3; retr++) {
748
749 scb->command = IM_DEVICE_INQUIRY_CMD | IM_NO_DISCONNECT;
750 scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_RETRY_ENABLE | IM_BYPASS_BUFFER;
751 last_scsi_command(shpnt)[ldn] = IM_DEVICE_INQUIRY_CMD;
752 last_scsi_type(shpnt)[ldn] = IM_SCB;
753 scb->sys_buf_adr = isa_virt_to_bus(buf);
754 scb->sys_buf_length = 255;
755 scb->tsb_adr = isa_virt_to_bus(tsb);
756
757 got_interrupt(shpnt) = 0;
758 issue_cmd(shpnt, isa_virt_to_bus(scb), IM_SCB | ldn);
759 while (!got_interrupt(shpnt))
760 barrier();
761
762
763 if ((stat_result(shpnt) == IM_SCB_CMD_COMPLETED) || (stat_result(shpnt) == IM_SCB_CMD_COMPLETED_WITH_RETRIES))
764 return 1;
765 }
766
767 if (retr >= 3)
768 return 0;
769 else
770 return 1;
771}
772
773static int read_capacity(struct Scsi_Host *shpnt, int ldn)
774{
775 int retr;
776 struct im_scb *scb;
777 struct im_tsb *tsb;
778 unsigned char *buf;
779
780 scb = &(ld(shpnt)[ldn].scb);
781 tsb = &(ld(shpnt)[ldn].tsb);
782 buf = (unsigned char *) (&(ld(shpnt)[ldn].buf));
783 ld(shpnt)[ldn].tsb.dev_status = 0;
784 for (retr = 0; retr < 3; retr++) {
785
786 scb->command = IM_READ_CAPACITY_CMD;
787 scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_READ_CONTROL | IM_RETRY_ENABLE | IM_BYPASS_BUFFER;
788 last_scsi_command(shpnt)[ldn] = IM_READ_CAPACITY_CMD;
789 last_scsi_type(shpnt)[ldn] = IM_SCB;
790 scb->sys_buf_adr = isa_virt_to_bus(buf);
791 scb->sys_buf_length = 8;
792 scb->tsb_adr = isa_virt_to_bus(tsb);
793
794 got_interrupt(shpnt) = 0;
795 issue_cmd(shpnt, isa_virt_to_bus(scb), IM_SCB | ldn);
796 while (!got_interrupt(shpnt))
797 barrier();
798
799
800 if ((stat_result(shpnt) == IM_SCB_CMD_COMPLETED) || (stat_result(shpnt) == IM_SCB_CMD_COMPLETED_WITH_RETRIES))
801 return 1;
802 }
803
804 if (retr >= 3)
805 return 0;
806 else
807 return 1;
808}
809
810static int get_pos_info(struct Scsi_Host *shpnt)
811{
812 int retr;
813 struct im_scb *scb;
814 struct im_tsb *tsb;
815 unsigned char *buf;
816
817 scb = &(ld(shpnt)[MAX_LOG_DEV].scb);
818 tsb = &(ld(shpnt)[MAX_LOG_DEV].tsb);
819 buf = (unsigned char *) (&(ld(shpnt)[MAX_LOG_DEV].buf));
820 ld(shpnt)[MAX_LOG_DEV].tsb.dev_status = 0;
821 for (retr = 0; retr < 3; retr++) {
822
823 scb->command = IM_GET_POS_INFO_CMD;
824 scb->enable = IM_READ_CONTROL | IM_REPORT_TSB_ONLY_ON_ERROR | IM_RETRY_ENABLE | IM_BYPASS_BUFFER;
825 last_scsi_command(shpnt)[MAX_LOG_DEV] = IM_GET_POS_INFO_CMD;
826 last_scsi_type(shpnt)[MAX_LOG_DEV] = IM_SCB;
827 scb->sys_buf_adr = isa_virt_to_bus(buf);
828 if (special(shpnt) == IBM_SCSI2_FW)
829 scb->sys_buf_length = 256;
830 else
831 scb->sys_buf_length = 18;
832 scb->tsb_adr = isa_virt_to_bus(tsb);
833
834 got_interrupt(shpnt) = 0;
835 issue_cmd(shpnt, isa_virt_to_bus(scb), IM_SCB | MAX_LOG_DEV);
836
837
838 while (!got_interrupt(shpnt))
839 barrier();
840
841
842 if ((stat_result(shpnt) == IM_SCB_CMD_COMPLETED) || (stat_result(shpnt) == IM_SCB_CMD_COMPLETED_WITH_RETRIES))
843 return 1;
844 }
845
846 if (retr >= 3)
847 return 0;
848 else
849 return 1;
850}
851
852
853
854
855static int immediate_assign(struct Scsi_Host *shpnt, unsigned int pun,
856 unsigned int lun, unsigned int ldn,
857 unsigned int operation)
858{
859 int retr;
860 unsigned long imm_cmd;
861
862 for (retr = 0; retr < 3; retr++) {
863
864 switch (special(shpnt)) {
865 case IBM_SCSI2_FW:
866 imm_cmd = (unsigned long) (IM_ASSIGN_IMM_CMD);
867 imm_cmd |= (unsigned long) ((lun & 7) << 24);
868 imm_cmd |= (unsigned long) ((operation & 1) << 23);
869 imm_cmd |= (unsigned long) ((pun & 7) << 20) | ((pun & 8) << 24);
870 imm_cmd |= (unsigned long) ((ldn & 15) << 16);
871 break;
872 default:
873 imm_cmd = inl(IM_CMD_REG(shpnt));
874 imm_cmd &= (unsigned long) (0xF8000000);
875 imm_cmd |= (unsigned long) (IM_ASSIGN_IMM_CMD);
876 imm_cmd |= (unsigned long) ((lun & 7) << 24);
877 imm_cmd |= (unsigned long) ((operation & 1) << 23);
878 imm_cmd |= (unsigned long) ((pun & 7) << 20);
879 imm_cmd |= (unsigned long) ((ldn & 15) << 16);
880 break;
881 }
882 last_scsi_command(shpnt)[MAX_LOG_DEV] = IM_ASSIGN_IMM_CMD;
883 last_scsi_type(shpnt)[MAX_LOG_DEV] = IM_IMM_CMD;
884 got_interrupt(shpnt) = 0;
885 issue_cmd(shpnt, (unsigned long) (imm_cmd), IM_IMM_CMD | MAX_LOG_DEV);
886 while (!got_interrupt(shpnt))
887 barrier();
888
889
890 if (stat_result(shpnt) == IM_IMMEDIATE_CMD_COMPLETED)
891 return 1;
892 }
893 if (retr >= 3)
894 return 0;
895 else
896 return 1;
897}
898
899static int immediate_feature(struct Scsi_Host *shpnt, unsigned int speed, unsigned int timeout)
900{
901 int retr;
902 unsigned long imm_cmd;
903
904 for (retr = 0; retr < 3; retr++) {
905
906 imm_cmd = IM_FEATURE_CTR_IMM_CMD;
907 imm_cmd |= (unsigned long) ((speed & 0x7) << 29);
908 imm_cmd |= (unsigned long) ((timeout & 0x1fff) << 16);
909 last_scsi_command(shpnt)[MAX_LOG_DEV] = IM_FEATURE_CTR_IMM_CMD;
910 last_scsi_type(shpnt)[MAX_LOG_DEV] = IM_IMM_CMD;
911 got_interrupt(shpnt) = 0;
912
913
914 global_command_error_excuse = 1;
915 issue_cmd(shpnt, (unsigned long) (imm_cmd), IM_IMM_CMD | MAX_LOG_DEV);
916
917
918 while (!got_interrupt(shpnt))
919 barrier();
920 if (global_command_error_excuse == CMD_FAIL) {
921 global_command_error_excuse = 0;
922 return 2;
923 } else
924 global_command_error_excuse = 0;
925
926 if (stat_result(shpnt) == IM_IMMEDIATE_CMD_COMPLETED)
927 return 1;
928 }
929 if (retr >= 3)
930 return 0;
931 else
932 return 1;
933}
934
935#ifdef CONFIG_IBMMCA_SCSI_DEV_RESET
936static int immediate_reset(struct Scsi_Host *shpnt, unsigned int ldn)
937{
938 int retries;
939 int ticks;
940 unsigned long imm_command;
941
942 for (retries = 0; retries < 3; retries++) {
943 imm_command = inl(IM_CMD_REG(shpnt));
944 imm_command &= (unsigned long) (0xFFFF0000);
945 imm_command |= (unsigned long) (IM_RESET_IMM_CMD);
946 last_scsi_command(shpnt)[ldn] = IM_RESET_IMM_CMD;
947 last_scsi_type(shpnt)[ldn] = IM_IMM_CMD;
948 got_interrupt(shpnt) = 0;
949 reset_status(shpnt) = IM_RESET_IN_PROGRESS;
950 issue_cmd(shpnt, (unsigned long) (imm_command), IM_IMM_CMD | ldn);
951 ticks = IM_RESET_DELAY * HZ;
952 while (reset_status(shpnt) == IM_RESET_IN_PROGRESS && --ticks) {
953 udelay((1 + 999 / HZ) * 1000);
954 barrier();
955 }
956
957 if (!ticks) {
958 printk(KERN_ERR "IBM MCA SCSI: reset did not complete within %d seconds.\n", IM_RESET_DELAY);
959 reset_status(shpnt) = IM_RESET_FINISHED_OK;
960
961 return 1;
962 }
963
964 if (stat_result(shpnt) == IM_IMMEDIATE_CMD_COMPLETED)
965 return 1;
966 }
967 if (retries >= 3)
968 return 0;
969 else
970 return 1;
971}
972#endif
973
974
975static char *ti_p(int dev)
976{
977 switch (dev) {
978 case TYPE_IBM_SCSI_ADAPTER:
979 return ("A");
980 case TYPE_DISK:
981 return ("D");
982 case TYPE_TAPE:
983 return ("T");
984 case TYPE_PROCESSOR:
985 return ("P");
986 case TYPE_WORM:
987 return ("W");
988 case TYPE_ROM:
989 return ("R");
990 case TYPE_SCANNER:
991 return ("S");
992 case TYPE_MOD:
993 return ("M");
994 case TYPE_MEDIUM_CHANGER:
995 return ("C");
996 case TYPE_NO_LUN:
997 return ("+");
998 }
999 return ("-");
1000}
1001
1002
1003static char *ti_l(int val)
1004{
1005 const char hex[16] = "0123456789abcdef";
1006 static char answer[2];
1007
1008 answer[1] = (char) (0x0);
1009 if (val <= MAX_LOG_DEV)
1010 answer[0] = hex[val];
1011 else
1012 answer[0] = '-';
1013 return (char *) &answer;
1014}
1015
1016
1017static char *ibmrate(unsigned int speed, int i)
1018{
1019 switch (speed) {
1020 case 0:
1021 return i ? "5.00" : "10.00";
1022 case 1:
1023 return i ? "4.00" : "8.00";
1024 case 2:
1025 return i ? "3.33" : "6.66";
1026 case 3:
1027 return i ? "2.86" : "5.00";
1028 case 4:
1029 return i ? "2.50" : "4.00";
1030 case 5:
1031 return i ? "2.22" : "3.10";
1032 case 6:
1033 return i ? "2.00" : "2.50";
1034 case 7:
1035 return i ? "1.82" : "2.00";
1036 }
1037 return "---";
1038}
1039
1040static int probe_display(int what)
1041{
1042 static int rotator = 0;
1043 const char rotor[] = "|/-\\";
1044
1045 if (!(display_mode & LED_DISP))
1046 return 0;
1047 if (!what) {
1048 outl(0x20202020, MOD95_LED_PORT);
1049 outl(0x20202020, MOD95_LED_PORT + 4);
1050 } else {
1051 outb('S', MOD95_LED_PORT + 7);
1052 outb('C', MOD95_LED_PORT + 6);
1053 outb('S', MOD95_LED_PORT + 5);
1054 outb('I', MOD95_LED_PORT + 4);
1055 outb('i', MOD95_LED_PORT + 3);
1056 outb('n', MOD95_LED_PORT + 2);
1057 outb('i', MOD95_LED_PORT + 1);
1058 outb((char) (rotor[rotator]), MOD95_LED_PORT);
1059 rotator++;
1060 if (rotator > 3)
1061 rotator = 0;
1062 }
1063 return 0;
1064}
1065
1066static int probe_bus_mode(struct Scsi_Host *shpnt)
1067{
1068 struct im_pos_info *info;
1069 int num_bus = 0;
1070 int ldn;
1071
1072 info = (struct im_pos_info *) (&(ld(shpnt)[MAX_LOG_DEV].buf));
1073 if (get_pos_info(shpnt)) {
1074 if (info->connector_size & 0xf000)
1075 subsystem_connector_size(shpnt) = 16;
1076 else
1077 subsystem_connector_size(shpnt) = 32;
1078 num_bus |= (info->pos_4b & 8) >> 3;
1079 for (ldn = 0; ldn <= MAX_LOG_DEV; ldn++) {
1080 if ((special(shpnt) == IBM_SCSI_WCACHE) || (special(shpnt) == IBM_7568_WCACHE)) {
1081 if (!((info->cache_stat >> ldn) & 1))
1082 ld(shpnt)[ldn].cache_flag = 0;
1083 }
1084 if (!((info->retry_stat >> ldn) & 1))
1085 ld(shpnt)[ldn].retry_flag = 0;
1086 }
1087#ifdef IM_DEBUG_PROBE
1088 printk("IBM MCA SCSI: SCSI-Cache bits: ");
1089 for (ldn = 0; ldn <= MAX_LOG_DEV; ldn++) {
1090 printk("%d", ld(shpnt)[ldn].cache_flag);
1091 }
1092 printk("\nIBM MCA SCSI: SCSI-Retry bits: ");
1093 for (ldn = 0; ldn <= MAX_LOG_DEV; ldn++) {
1094 printk("%d", ld(shpnt)[ldn].retry_flag);
1095 }
1096 printk("\n");
1097#endif
1098 }
1099 return num_bus;
1100}
1101
1102
1103static void check_devices(struct Scsi_Host *shpnt, int adaptertype)
1104{
1105 int id, lun, ldn, ticks;
1106 int count_devices;
1107 int max_pun;
1108 int num_bus;
1109 int speedrun;
1110
1111
1112 ticks = 0;
1113 count_devices = 0;
1114 IBM_DS(shpnt).dyn_flag = 0;
1115 IBM_DS(shpnt).total_errors = 0;
1116 next_ldn(shpnt) = 7;
1117
1118
1119 memset(ld(shpnt), 0, sizeof(ld(shpnt)));
1120 for (ldn = 0; ldn <= MAX_LOG_DEV; ldn++) {
1121 last_scsi_command(shpnt)[ldn] = NO_SCSI;
1122 last_scsi_type(shpnt)[ldn] = 0;
1123 ld(shpnt)[ldn].cache_flag = 1;
1124 ld(shpnt)[ldn].retry_flag = 1;
1125 }
1126 memset(get_ldn(shpnt), TYPE_NO_DEVICE, sizeof(get_ldn(shpnt)));
1127 memset(get_scsi(shpnt), TYPE_NO_DEVICE, sizeof(get_scsi(shpnt)));
1128 for (lun = 0; lun < 8; lun++) {
1129
1130 get_scsi(shpnt)[subsystem_pun(shpnt)][lun] = TYPE_IBM_SCSI_ADAPTER;
1131 get_ldn(shpnt)[subsystem_pun(shpnt)][lun] = MAX_LOG_DEV;
1132
1133
1134 }
1135 probe_display(0);
1136
1137
1138
1139
1140 adapter_speed(shpnt) = global_adapter_speed;
1141 speedrun = adapter_speed(shpnt);
1142 while (immediate_feature(shpnt, speedrun, adapter_timeout) == 2) {
1143 probe_display(1);
1144 if (speedrun == 7)
1145 panic("IBM MCA SCSI: Cannot set Synchronous-Transfer-Rate!\n");
1146 speedrun++;
1147 if (speedrun > 7)
1148 speedrun = 7;
1149 }
1150 adapter_speed(shpnt) = speedrun;
1151
1152
1153 num_bus = probe_bus_mode(shpnt);
1154
1155
1156 if (adaptertype == IBM_SCSI2_FW) {
1157
1158 if (num_bus) {
1159 printk(KERN_INFO "IBM MCA SCSI: Separate bus mode (wide-addressing enabled)\n");
1160 subsystem_maxid(shpnt) = 16;
1161 } else {
1162 printk(KERN_INFO "IBM MCA SCSI: Combined bus mode (wide-addressing disabled)\n");
1163 subsystem_maxid(shpnt) = 8;
1164 }
1165 printk(KERN_INFO "IBM MCA SCSI: Sync.-Rate (F/W: 20, Int.: 10, Ext.: %s) MBytes/s\n", ibmrate(speedrun, adaptertype));
1166 } else
1167 printk(KERN_INFO "IBM MCA SCSI: Synchronous-SCSI-Transfer-Rate: %s MBytes/s\n", ibmrate(speedrun, adaptertype));
1168
1169
1170 max_pun = subsystem_maxid(shpnt);
1171
1172#ifdef IM_DEBUG_PROBE
1173 printk("IBM MCA SCSI: Current SCSI-host index: %d\n", shpnt);
1174 printk("IBM MCA SCSI: Removing default logical SCSI-device mapping.");
1175#else
1176 printk(KERN_INFO "IBM MCA SCSI: Dev. Order: %s, Mapping (takes <2min): ", (ibm_ansi_order) ? "ANSI" : "New");
1177#endif
1178 for (ldn = 0; ldn < MAX_LOG_DEV; ldn++) {
1179 probe_display(1);
1180#ifdef IM_DEBUG_PROBE
1181 printk(".");
1182#endif
1183 immediate_assign(shpnt, 0, 0, ldn, REMOVE_LDN);
1184 }
1185 lun = 0;
1186#ifndef IM_DEBUG_PROBE
1187 printk("cleared,");
1188#endif
1189
1190#ifdef IM_DEBUG_PROBE
1191 printk("\nIBM MCA SCSI: Scanning SCSI-devices.");
1192#endif
1193 for (id = 0; id < max_pun; id++)
1194#ifdef CONFIG_SCSI_MULTI_LUN
1195 for (lun = 0; lun < 8; lun++)
1196#endif
1197 {
1198 probe_display(1);
1199#ifdef IM_DEBUG_PROBE
1200 printk(".");
1201#endif
1202 if (id != subsystem_pun(shpnt)) {
1203
1204
1205 immediate_assign(shpnt, id, lun, PROBE_LDN, SET_LDN);
1206 if (device_inquiry(shpnt, PROBE_LDN)) {
1207 get_scsi(shpnt)[id][lun] = (unsigned char) (ld(shpnt)[PROBE_LDN].buf[0]);
1208
1209 if (ld(shpnt)[PROBE_LDN].buf[0] != TYPE_NO_LUN)
1210 count_devices++;
1211 }
1212
1213 immediate_assign(shpnt, id, lun, PROBE_LDN, REMOVE_LDN);
1214 }
1215 }
1216#ifndef IM_DEBUG_PROBE
1217 printk("scanned,");
1218#endif
1219
1220#ifdef IM_DEBUG_PROBE
1221 printk("\nIBM MCA SCSI: Mapping SCSI-devices.");
1222#endif
1223 ldn = 0;
1224 lun = 0;
1225#ifdef CONFIG_SCSI_MULTI_LUN
1226 for (lun = 0; lun < 8 && ldn < MAX_LOG_DEV; lun++)
1227#endif
1228 for (id = 0; id < max_pun && ldn < MAX_LOG_DEV; id++) {
1229 probe_display(1);
1230#ifdef IM_DEBUG_PROBE
1231 printk(".");
1232#endif
1233 if (id != subsystem_pun(shpnt)) {
1234 if (get_scsi(shpnt)[id][lun] != TYPE_NO_LUN && get_scsi(shpnt)[id][lun] != TYPE_NO_DEVICE) {
1235
1236
1237 immediate_assign(shpnt, id, lun, ldn, SET_LDN);
1238 get_ldn(shpnt)[id][lun] = ldn;
1239 if (device_exists(shpnt, ldn, &ld(shpnt)[ldn].block_length, &ld(shpnt)[ldn].device_type)) {
1240#ifdef CONFIG_IBMMCA_SCSI_DEV_RESET
1241 printk("resetting device at ldn=%x ... ", ldn);
1242 immediate_reset(shpnt, ldn);
1243#endif
1244 ldn++;
1245 } else {
1246
1247
1248 if (lun > 0) {
1249
1250 get_ldn(shpnt)[id][lun] = TYPE_NO_DEVICE;
1251 immediate_assign(shpnt, 0, 0, ldn, REMOVE_LDN);
1252 } else
1253 ldn++;
1254 }
1255 } else if (lun == 0) {
1256
1257 immediate_assign(shpnt, id, lun, ldn, SET_LDN);
1258 get_ldn(shpnt)[id][lun] = ldn;
1259 ldn++;
1260 }
1261 }
1262 }
1263
1264
1265
1266 for (lun = 1; lun < 8 && ldn < MAX_LOG_DEV; lun++)
1267 for (id = 0; id < max_pun && ldn < MAX_LOG_DEV; id++) {
1268 if (get_scsi(shpnt)[id][lun] == TYPE_NO_LUN || get_scsi(shpnt)[id][lun] == TYPE_NO_DEVICE) {
1269 probe_display(1);
1270
1271
1272
1273
1274 immediate_assign(shpnt, id, lun, ldn, SET_LDN);
1275 get_ldn(shpnt)[id][lun] = ldn;
1276 ldn++;
1277 }
1278 }
1279#ifndef IM_DEBUG_PROBE
1280 printk("mapped.");
1281#endif
1282 printk("\n");
1283#ifdef IM_DEBUG_PROBE
1284 if (ibm_ansi_order)
1285 printk("IBM MCA SCSI: Device order: IBM/ANSI (pun=7 is first).\n");
1286 else
1287 printk("IBM MCA SCSI: Device order: New Industry Standard (pun=0 is first).\n");
1288#endif
1289
1290#ifdef IM_DEBUG_PROBE
1291
1292 printk("IBM MCA SCSI: Determined SCSI-device-mapping:\n");
1293 printk(" Physical SCSI-Device Map Logical SCSI-Device Map\n");
1294 printk("ID\\LUN 0 1 2 3 4 5 6 7 ID\\LUN 0 1 2 3 4 5 6 7\n");
1295 for (id = 0; id < max_pun; id++) {
1296 printk("%2d ", id);
1297 for (lun = 0; lun < 8; lun++)
1298 printk("%2s ", ti_p(get_scsi(shpnt)[id][lun]));
1299 printk(" %2d ", id);
1300 for (lun = 0; lun < 8; lun++)
1301 printk("%2s ", ti_l(get_ldn(shpnt)[id][lun]));
1302 printk("\n");
1303 }
1304#endif
1305
1306
1307 IBM_DS(shpnt).total_scsi_devices = count_devices;
1308
1309
1310
1311 if (count_devices >= MAX_LOG_DEV)
1312 IBM_DS(shpnt).dyn_flag = 1;
1313 else
1314 IBM_DS(shpnt).dyn_flag = 0;
1315
1316
1317 if (ldn == 0)
1318 printk("IBM MCA SCSI: Warning: No SCSI-devices found/assigned!\n");
1319
1320
1321 IBM_DS(shpnt).scbs = 0;
1322 IBM_DS(shpnt).long_scbs = 0;
1323 IBM_DS(shpnt).total_accesses = 0;
1324 IBM_DS(shpnt).total_interrupts = 0;
1325 IBM_DS(shpnt).dynamical_assignments = 0;
1326 memset(IBM_DS(shpnt).ldn_access, 0x0, sizeof(IBM_DS(shpnt).ldn_access));
1327 memset(IBM_DS(shpnt).ldn_read_access, 0x0, sizeof(IBM_DS(shpnt).ldn_read_access));
1328 memset(IBM_DS(shpnt).ldn_write_access, 0x0, sizeof(IBM_DS(shpnt).ldn_write_access));
1329 memset(IBM_DS(shpnt).ldn_inquiry_access, 0x0, sizeof(IBM_DS(shpnt).ldn_inquiry_access));
1330 memset(IBM_DS(shpnt).ldn_modeselect_access, 0x0, sizeof(IBM_DS(shpnt).ldn_modeselect_access));
1331 memset(IBM_DS(shpnt).ldn_assignments, 0x0, sizeof(IBM_DS(shpnt).ldn_assignments));
1332 probe_display(0);
1333 return;
1334}
1335
1336static int device_exists(struct Scsi_Host *shpnt, int ldn, int *block_length, int *device_type)
1337{
1338 unsigned char *buf;
1339
1340 if (!(device_inquiry(shpnt, ldn)))
1341 return 0;
1342 buf = (unsigned char *) (&(ld(shpnt)[ldn].buf));
1343 if (*buf == TYPE_ROM) {
1344 *device_type = TYPE_ROM;
1345 *block_length = 2048;
1346 return 1;
1347 }
1348 if (*buf == TYPE_WORM) {
1349 *device_type = TYPE_WORM;
1350 *block_length = 2048;
1351 return 1;
1352 }
1353 if (*buf == TYPE_DISK) {
1354 *device_type = TYPE_DISK;
1355 if (read_capacity(shpnt, ldn)) {
1356 *block_length = *(buf + 7) + (*(buf + 6) << 8) + (*(buf + 5) << 16) + (*(buf + 4) << 24);
1357 return 1;
1358 } else
1359 return 0;
1360 }
1361 if (*buf == TYPE_MOD) {
1362 *device_type = TYPE_MOD;
1363 if (read_capacity(shpnt, ldn)) {
1364 *block_length = *(buf + 7) + (*(buf + 6) << 8) + (*(buf + 5) << 16) + (*(buf + 4) << 24);
1365 return 1;
1366 } else
1367 return 0;
1368 }
1369 if (*buf == TYPE_TAPE) {
1370 *device_type = TYPE_TAPE;
1371 *block_length = 0;
1372 return 1;
1373 }
1374 if (*buf == TYPE_PROCESSOR) {
1375 *device_type = TYPE_PROCESSOR;
1376 *block_length = 0;
1377 return 1;
1378 }
1379 if (*buf == TYPE_SCANNER) {
1380 *device_type = TYPE_SCANNER;
1381 *block_length = 0;
1382 return 1;
1383 }
1384 if (*buf == TYPE_MEDIUM_CHANGER) {
1385 *device_type = TYPE_MEDIUM_CHANGER;
1386 *block_length = 0;
1387
1388 return 1;
1389 }
1390 return 0;
1391}
1392
1393static void internal_ibmmca_scsi_setup(char *str, int *ints)
1394{
1395 int i, j, io_base, id_base;
1396 char *token;
1397
1398 io_base = 0;
1399 id_base = 0;
1400 if (str) {
1401 j = 0;
1402 while ((token = strsep(&str, ",")) != NULL) {
1403 if (!strcmp(token, "activity"))
1404 display_mode |= LED_ACTIVITY;
1405 if (!strcmp(token, "display"))
1406 display_mode |= LED_DISP;
1407 if (!strcmp(token, "adisplay"))
1408 display_mode |= LED_ADISP;
1409 if (!strcmp(token, "normal"))
1410 ibm_ansi_order = 0;
1411 if (!strcmp(token, "ansi"))
1412 ibm_ansi_order = 1;
1413 if (!strcmp(token, "fast"))
1414 global_adapter_speed = 0;
1415 if (!strcmp(token, "medium"))
1416 global_adapter_speed = 4;
1417 if (!strcmp(token, "slow"))
1418 global_adapter_speed = 7;
1419 if ((*token == '-') || (isdigit(*token))) {
1420 if (!(j % 2) && (io_base < IM_MAX_HOSTS))
1421 io_port[io_base++] = simple_strtoul(token, NULL, 0);
1422 if ((j % 2) && (id_base < IM_MAX_HOSTS))
1423 scsi_id[id_base++] = simple_strtoul(token, NULL, 0);
1424 j++;
1425 }
1426 }
1427 } else if (ints) {
1428 for (i = 0; i < IM_MAX_HOSTS && 2 * i + 2 < ints[0]; i++) {
1429 io_port[i] = ints[2 * i + 2];
1430 scsi_id[i] = ints[2 * i + 2];
1431 }
1432 }
1433 return;
1434}
1435
1436#if 0
1437 FIXME NEED TO MOVE TO SYSFS
1438
1439static int ibmmca_getinfo(char *buf, int slot, void *dev_id)
1440{
1441 struct Scsi_Host *shpnt;
1442 int len, speciale, connectore, k;
1443 unsigned int pos[8];
1444 unsigned long flags;
1445 struct Scsi_Host *dev = dev_id;
1446
1447 spin_lock_irqsave(dev->host_lock, flags);
1448
1449 shpnt = dev;
1450 len = 0;
1451
1452 speciale = ((struct ibmmca_hostdata *) shpnt->hostdata)->_special;
1453 connectore = ((struct ibmmca_hostdata *) shpnt->hostdata)->_connector_size;
1454 for (k = 2; k < 4; k++)
1455 pos[k] = ((struct ibmmca_hostdata *) shpnt->hostdata)->_pos[k];
1456 if (speciale == FORCED_DETECTION) {
1457 len += sprintf(buf + len,
1458 "Adapter category: forced detected\n" "***************************************\n" "*** Forced detected SCSI Adapter ***\n" "*** No chip-information available ***\n" "***************************************\n");
1459 } else if (speciale == INTEGRATED_SCSI) {
1460
1461 len += sprintf(buf + len,
1462 "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");
1463 } else if ((speciale >= 0) && (speciale < ARRAY_SIZE(subsys_list))) {
1464
1465 len += sprintf(buf + len, "Adapter category: slot-card\n" "ROM Segment Address: ");
1466 if ((pos[2] & 0xf0) == 0xf0)
1467 len += sprintf(buf + len, "off\n");
1468 else
1469 len += sprintf(buf + len, "0x%x\n", ((pos[2] & 0xf0) << 13) + 0xc0000);
1470 len += sprintf(buf + len, "Chip status: %s\n", (pos[2] & 1) ? "enabled" : "disabled");
1471 len += sprintf(buf + len, "Adapter I/O Offset: 0x%x\n", ((pos[2] & 0x0e) << 2));
1472 } else {
1473 len += sprintf(buf + len, "Adapter category: unknown\n");
1474 }
1475
1476 len += sprintf(buf + len, "Subsystem PUN: %d\n", shpnt->this_id);
1477 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));
1478 len += sprintf(buf + len, "MCA-slot size: %d bits", connectore);
1479
1480
1481 while (len % sizeof(int) != (sizeof(int) - 1))
1482 len += sprintf(buf + len, " ");
1483 len += sprintf(buf + len, "\n");
1484
1485 spin_unlock_irqrestore(shpnt->host_lock, flags);
1486
1487 return len;
1488}
1489#endif
1490
1491static struct scsi_host_template ibmmca_driver_template = {
1492 .proc_name = "ibmmca",
1493 .proc_info = ibmmca_proc_info,
1494 .name = "IBM SCSI-Subsystem",
1495 .queuecommand = ibmmca_queuecommand,
1496 .eh_abort_handler = ibmmca_abort,
1497 .eh_host_reset_handler = ibmmca_host_reset,
1498 .bios_param = ibmmca_biosparam,
1499 .can_queue = 16,
1500 .this_id = 7,
1501 .sg_tablesize = 16,
1502 .cmd_per_lun = 1,
1503 .use_clustering = ENABLE_CLUSTERING,
1504};
1505
1506static int ibmmca_probe(struct device *dev)
1507{
1508 struct Scsi_Host *shpnt;
1509 int port, id, i, j, k, irq, enabled, ret = -EINVAL;
1510 struct mca_device *mca_dev = to_mca_device(dev);
1511 const char *description = ibmmca_description[mca_dev->index];
1512
1513
1514
1515
1516 printk(KERN_INFO "IBM MCA SCSI: Version %s\n", IBMMCA_SCSI_DRIVER_VERSION);
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542 for (j = 0; j < 8; j++)
1543 pos[j] = mca_device_read_pos(mca_dev, j);
1544 id = (pos[3] & 0xe0) >> 5;
1545 enabled = (pos[2] &0x01);
1546 if (!enabled) {
1547 printk(KERN_WARNING "IBM MCA SCSI: WARNING - Your SCSI-subsystem is disabled!\n");
1548 printk(KERN_WARNING " SCSI-operations may not work.\n");
1549 }
1550
1551
1552
1553
1554
1555
1556
1557
1558 if (mca_dev->slot == MCA_INTEGSCSI &&
1559 ((!pos[0] && !pos[1] && pos[2] > 0 &&
1560 pos[3] > 0 && !pos[4] && !pos[5] &&
1561 !pos[6] && !pos[7]) ||
1562 (pos[0] == 0xff && pos[1] == 0xff &&
1563 pos[2] < 0xff && pos[3] < 0xff &&
1564 pos[4] == 0xff && pos[5] == 0xff &&
1565 pos[6] == 0xff && pos[7] == 0xff))) {
1566 irq = IM_IRQ;
1567 port = IM_IO_PORT;
1568 } else {
1569 irq = IM_IRQ;
1570 port = IM_IO_PORT + ((pos[2] &0x0e) << 2);
1571 if ((mca_dev->index == IBM_SCSI2_FW) && (pos[6] != 0)) {
1572 printk(KERN_ERR "IBM MCA SCSI: ERROR - Wrong POS(6)-register setting!\n");
1573 printk(KERN_ERR " Impossible to determine adapter PUN!\n");
1574 printk(KERN_ERR " Guessing adapter PUN = 7.\n");
1575 id = 7;
1576 } else {
1577 id = (pos[3] & 0xe0) >> 5;
1578 if (mca_dev->index == IBM_SCSI2_FW) {
1579 id |= (pos[3] & 0x10) >> 1;
1580
1581 }
1582 }
1583 if ((mca_dev->index == IBM_SCSI2_FW) &&
1584 (pos[4] & 0x01) && (pos[6] == 0)) {
1585
1586 printk(KERN_DEBUG "IBM MCA SCSI: SCSI-2 F/W adapter needs IRQ 11.\n");
1587 irq = IM_IRQ_FW;
1588 }
1589 }
1590
1591
1592
1593
1594
1595 printk(KERN_INFO "IBM MCA SCSI: %s found, io=0x%x, scsi id=%d,\n",
1596 description, port, id);
1597 if (mca_dev->slot == MCA_INTEGSCSI)
1598 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.");
1599 else {
1600 if ((pos[2] & 0xf0) == 0xf0)
1601 printk(KERN_DEBUG " ROM Addr.=off,");
1602 else
1603 printk(KERN_DEBUG " ROM Addr.=0x%x,", ((pos[2] & 0xf0) << 13) + 0xc0000);
1604
1605 printk(KERN_DEBUG " port-offset=0x%x, subsystem=%s\n", ((pos[2] & 0x0e) << 2), (pos[2] & 1) ? "enabled." : "disabled.");
1606 }
1607
1608
1609 if (!request_region(port, IM_N_IO_PORT, description)) {
1610 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);
1611 goto out_fail;
1612 }
1613
1614
1615 shpnt = scsi_host_alloc(&ibmmca_driver_template,
1616 sizeof(struct ibmmca_hostdata));
1617 if (!shpnt) {
1618 printk(KERN_ERR "IBM MCA SCSI: Unable to register host.\n");
1619 goto out_release;
1620 }
1621
1622 dev_set_drvdata(dev, shpnt);
1623 if(request_irq(irq, interrupt_handler, IRQF_SHARED, description, dev)) {
1624 printk(KERN_ERR "IBM MCA SCSI: failed to request interrupt %d\n", irq);
1625 goto out_free_host;
1626 }
1627
1628
1629 special(shpnt) = mca_dev->index;
1630 subsystem_connector_size(shpnt) = 0;
1631 shpnt->irq = irq;
1632 shpnt->io_port = port;
1633 shpnt->n_io_port = IM_N_IO_PORT;
1634 shpnt->this_id = id;
1635 shpnt->max_id = 8;
1636
1637
1638#ifdef IM_DEBUG_PROBE
1639 ctrl = (unsigned int) (inb(IM_CTR_REG(found)));
1640 printk("IBM MCA SCSI: Control Register contents: %x, status: %x\n", ctrl, inb(IM_STAT_REG(found)));
1641 printk("IBM MCA SCSI: This adapters' POS-registers: ");
1642 for (i = 0; i < 8; i++)
1643 printk("%x ", pos[i]);
1644 printk("\n");
1645#endif
1646 reset_status(shpnt) = IM_RESET_NOT_IN_PROGRESS;
1647
1648 for (i = 0; i < 16; i++)
1649 for (j = 0; j < 8; j++)
1650 get_ldn(shpnt)[i][j] = MAX_LOG_DEV;
1651
1652
1653
1654 local_checking_phase_flag(shpnt) = 1;
1655 check_devices(shpnt, mca_dev->index);
1656 local_checking_phase_flag(shpnt) = 0;
1657
1658
1659
1660 for (k = 2; k < 7; k++)
1661 ((struct ibmmca_hostdata *) shpnt->hostdata)->_pos[k] = pos[k];
1662 ((struct ibmmca_hostdata *) shpnt->hostdata)->_special = INTEGRATED_SCSI;
1663 mca_device_set_name(mca_dev, description);
1664
1665
1666
1667 mca_device_set_claim(mca_dev, 1);
1668 if (scsi_add_host(shpnt, dev)) {
1669 dev_printk(KERN_ERR, dev, "IBM MCA SCSI: scsi_add_host failed\n");
1670 goto out_free_host;
1671 }
1672 scsi_scan_host(shpnt);
1673
1674 return 0;
1675 out_free_host:
1676 scsi_host_put(shpnt);
1677 out_release:
1678 release_region(port, IM_N_IO_PORT);
1679 out_fail:
1680 return ret;
1681}
1682
1683static int __devexit ibmmca_remove(struct device *dev)
1684{
1685 struct Scsi_Host *shpnt = dev_get_drvdata(dev);
1686 scsi_remove_host(shpnt);
1687 release_region(shpnt->io_port, shpnt->n_io_port);
1688 free_irq(shpnt->irq, dev);
1689 scsi_host_put(shpnt);
1690 return 0;
1691}
1692
1693
1694static int ibmmca_queuecommand_lck(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1695{
1696 unsigned int ldn;
1697 unsigned int scsi_cmd;
1698 struct im_scb *scb;
1699 struct Scsi_Host *shpnt;
1700 int current_ldn;
1701 int id, lun;
1702 int target;
1703 int max_pun;
1704 int i;
1705 struct scatterlist *sg;
1706
1707 shpnt = cmd->device->host;
1708
1709 max_pun = subsystem_maxid(shpnt);
1710 if (ibm_ansi_order) {
1711 target = max_pun - 1 - cmd->device->id;
1712 if ((target <= subsystem_pun(shpnt)) && (cmd->device->id <= subsystem_pun(shpnt)))
1713 target--;
1714 else if ((target >= subsystem_pun(shpnt)) && (cmd->device->id >= subsystem_pun(shpnt)))
1715 target++;
1716 } else
1717 target = cmd->device->id;
1718
1719
1720 if ((get_scsi(shpnt)[target][cmd->device->lun] == TYPE_NO_LUN) || (get_scsi(shpnt)[target][cmd->device->lun] == TYPE_NO_DEVICE)) {
1721 cmd->result = DID_NO_CONNECT << 16;
1722 if (done)
1723 done(cmd);
1724 return 0;
1725 }
1726
1727
1728 ldn = get_ldn(shpnt)[target][cmd->device->lun];
1729 if (ldn >= MAX_LOG_DEV) {
1730 if (ldn > MAX_LOG_DEV) {
1731 current_ldn = next_ldn(shpnt);
1732 while (ld(shpnt)[next_ldn(shpnt)].cmd) {
1733
1734 next_ldn(shpnt)++;
1735 if (next_ldn(shpnt) >= MAX_LOG_DEV)
1736 next_ldn(shpnt) = 7;
1737 if (current_ldn == next_ldn(shpnt)) {
1738
1739 scmd_printk(KERN_WARNING, cmd,
1740 "IBM MCA SCSI: Cannot assign SCSI-device dynamically!\n"
1741 " On ldn 7-14 SCSI-commands everywhere in progress.\n"
1742 " Reporting DID_NO_CONNECT for device.\n");
1743 cmd->result = DID_NO_CONNECT << 16;
1744 if (done)
1745 done(cmd);
1746 return 0;
1747 }
1748 }
1749
1750
1751 for (id = 0; id < max_pun; id++)
1752 for (lun = 0; lun < 8; lun++) {
1753 if (get_ldn(shpnt)[id][lun] == next_ldn(shpnt)) {
1754 get_ldn(shpnt)[id][lun] = TYPE_NO_DEVICE;
1755 get_scsi(shpnt)[id][lun] = TYPE_NO_DEVICE;
1756
1757 }
1758 }
1759
1760 local_checking_phase_flag(shpnt) = 1;
1761
1762 get_ldn(shpnt)[target][cmd->device->lun] = next_ldn(shpnt);
1763
1764 ldn = next_ldn(shpnt);
1765
1766 immediate_assign(shpnt, 0, 0, 0, REMOVE_LDN);
1767
1768 immediate_assign(shpnt, target, cmd->device->lun, ldn, SET_LDN);
1769
1770 if (device_exists(shpnt, ldn, &ld(shpnt)[ldn].block_length, &ld(shpnt)[ldn].device_type)) {
1771 ld(shpnt)[ldn].cmd = NULL;
1772
1773
1774 get_scsi(shpnt)[target][cmd->device->lun] = ld(shpnt)[ldn].device_type;
1775
1776 IBM_DS(shpnt).dynamical_assignments++;
1777 IBM_DS(shpnt).ldn_assignments[ldn]++;
1778 } else
1779
1780
1781 panic("IBM MCA SCSI: ldn=0x%x, SCSI-device on (%d,%d) vanished!\n", ldn, target, cmd->device->lun);
1782
1783 immediate_assign(shpnt, 0, 0, 0, REMOVE_LDN);
1784
1785 lun = 0;
1786#ifdef CONFIG_SCSI_MULTI_LUN
1787 for (lun = 0; lun < 8; lun++)
1788#endif
1789 for (id = 0; id < max_pun; id++) {
1790 if (get_ldn(shpnt)[id][lun] <= MAX_LOG_DEV)
1791 immediate_assign(shpnt, id, lun, get_ldn(shpnt)[id][lun], SET_LDN);
1792 }
1793
1794 local_checking_phase_flag(shpnt) = 0;
1795#ifdef IM_DEBUG_PROBE
1796
1797 printk("IBM MCA SCSI: ldn=0x%x dynamically reassigned to (%d,%d).\n", ldn, target, cmd->device->lun);
1798#endif
1799
1800 next_ldn(shpnt)++;
1801 if (next_ldn(shpnt) >= MAX_LOG_DEV)
1802 next_ldn(shpnt) = 7;
1803 } else {
1804 cmd->result = DID_BAD_TARGET << 16;
1805 if (done)
1806 done(cmd);
1807 return 0;
1808 }
1809 }
1810
1811
1812 if (ld(shpnt)[ldn].cmd)
1813 panic("IBM MCA SCSI: cmd already in progress for this ldn.\n");
1814
1815
1816 cmd->scsi_done = done;
1817 ld(shpnt)[ldn].cmd = cmd;
1818
1819
1820 scb = &(ld(shpnt)[ldn].scb);
1821 ld(shpnt)[ldn].tsb.dev_status = 0;
1822 scb->enable = IM_REPORT_TSB_ONLY_ON_ERROR | IM_RETRY_ENABLE;
1823 scb->tsb_adr = isa_virt_to_bus(&(ld(shpnt)[ldn].tsb));
1824 scsi_cmd = cmd->cmnd[0];
1825
1826 if (scsi_sg_count(cmd)) {
1827 BUG_ON(scsi_sg_count(cmd) > 16);
1828
1829 scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) {
1830 ld(shpnt)[ldn].sge[i].address = (void *) (isa_page_to_bus(sg_page(sg)) + sg->offset);
1831 ld(shpnt)[ldn].sge[i].byte_length = sg->length;
1832 }
1833 scb->enable |= IM_POINTER_TO_LIST;
1834 scb->sys_buf_adr = isa_virt_to_bus(&(ld(shpnt)[ldn].sge[0]));
1835 scb->sys_buf_length = scsi_sg_count(cmd) * sizeof(struct im_sge);
1836 } else {
1837 scb->sys_buf_adr = isa_virt_to_bus(scsi_sglist(cmd));
1838
1839
1840 switch (scsi_cmd) {
1841
1842
1843
1844 case INQUIRY:
1845 case REQUEST_SENSE:
1846 case MODE_SENSE:
1847 case MODE_SELECT:
1848 if (scsi_bufflen(cmd) > 255)
1849 scb->sys_buf_length = 255;
1850 else
1851 scb->sys_buf_length = scsi_bufflen(cmd);
1852 break;
1853 case TEST_UNIT_READY:
1854 scb->sys_buf_length = 0;
1855 break;
1856 default:
1857 scb->sys_buf_length = scsi_bufflen(cmd);
1858 break;
1859 }
1860 }
1861
1862
1863#ifdef IM_DEBUG_CMD
1864 printk("issue scsi cmd=%02x to ldn=%d\n", scsi_cmd, ldn);
1865#endif
1866
1867
1868#ifdef IM_DEBUG_CMD_SPEC_DEV
1869 if (ld(shpnt)[ldn].device_type == IM_DEBUG_CMD_DEVICE)
1870 printk("(SCSI-device-type=0x%x) issue scsi cmd=%02x to ldn=%d\n", ld(shpnt)[ldn].device_type, scsi_cmd, ldn);
1871#endif
1872
1873
1874 last_scsi_command(shpnt)[ldn] = scsi_cmd;
1875 last_scsi_type(shpnt)[ldn] = IM_SCB;
1876
1877 IBM_DS(shpnt).total_accesses++;
1878 IBM_DS(shpnt).ldn_access[ldn]++;
1879
1880 switch (scsi_cmd) {
1881 case READ_6:
1882 case WRITE_6:
1883 case READ_10:
1884 case WRITE_10:
1885 case READ_12:
1886 case WRITE_12:
1887
1888
1889
1890 switch (ld(shpnt)[ldn].device_type) {
1891 case TYPE_DISK:
1892 case TYPE_MOD:
1893
1894 if (scsi_cmd == READ_6 || scsi_cmd == READ_10 || scsi_cmd == READ_12) {
1895
1896 scb->enable |= IM_READ_CONTROL;
1897 IBM_DS(shpnt).ldn_read_access[ldn]++;
1898 scb->command = IM_READ_DATA_CMD | IM_NO_DISCONNECT;
1899 } else {
1900 IBM_DS(shpnt).ldn_write_access[ldn]++;
1901 scb->command = IM_WRITE_DATA_CMD | IM_NO_DISCONNECT;
1902 }
1903 if (scsi_cmd == READ_6 || scsi_cmd == WRITE_6) {
1904 scb->u1.log_blk_adr = (((unsigned) cmd->cmnd[3]) << 0) | (((unsigned) cmd->cmnd[2]) << 8) | ((((unsigned) cmd->cmnd[1]) & 0x1f) << 16);
1905 scb->u2.blk.count = (unsigned) cmd->cmnd[4];
1906 } else {
1907 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);
1908 scb->u2.blk.count = (((unsigned) cmd->cmnd[8]) << 0) | (((unsigned) cmd->cmnd[7]) << 8);
1909 }
1910 last_scsi_logical_block(shpnt)[ldn] = scb->u1.log_blk_adr;
1911 last_scsi_blockcount(shpnt)[ldn] = scb->u2.blk.count;
1912 scb->u2.blk.length = ld(shpnt)[ldn].block_length;
1913 break;
1914
1915
1916 case TYPE_ROM:
1917 case TYPE_TAPE:
1918 case TYPE_PROCESSOR:
1919 case TYPE_WORM:
1920 case TYPE_SCANNER:
1921 case TYPE_MEDIUM_CHANGER:
1922
1923
1924
1925
1926 scb->command = IM_OTHER_SCSI_CMD_CMD;
1927 if (scsi_cmd == READ_6 || scsi_cmd == READ_10 || scsi_cmd == READ_12)
1928
1929 scb->enable |= IM_READ_CONTROL;
1930 scb->enable |= IM_BYPASS_BUFFER;
1931 scb->u1.scsi_cmd_length = cmd->cmd_len;
1932 memcpy(scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
1933 last_scsi_type(shpnt)[ldn] = IM_LONG_SCB;
1934
1935
1936 break;
1937 }
1938 break;
1939 case INQUIRY:
1940 IBM_DS(shpnt).ldn_inquiry_access[ldn]++;
1941 scb->command = IM_DEVICE_INQUIRY_CMD;
1942 scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
1943 scb->u1.log_blk_adr = 0;
1944 break;
1945 case TEST_UNIT_READY:
1946 scb->command = IM_OTHER_SCSI_CMD_CMD;
1947 scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
1948 scb->u1.log_blk_adr = 0;
1949 scb->u1.scsi_cmd_length = 6;
1950 memcpy(scb->u2.scsi_command, cmd->cmnd, 6);
1951 last_scsi_type(shpnt)[ldn] = IM_LONG_SCB;
1952 break;
1953 case READ_CAPACITY:
1954
1955 scb->command = IM_READ_CAPACITY_CMD;
1956 scb->enable |= IM_READ_CONTROL | IM_BYPASS_BUFFER;
1957 if (scb->sys_buf_length > 8)
1958 scb->sys_buf_length = 8;
1959 break;
1960
1961 case REQUEST_SENSE:
1962 scb->command = IM_REQUEST_SENSE_CMD;
1963 scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
1964 break;
1965
1966 case MODE_SELECT:
1967 case MODE_SELECT_10:
1968 IBM_DS(shpnt).ldn_modeselect_access[ldn]++;
1969 scb->command = IM_OTHER_SCSI_CMD_CMD;
1970 scb->enable |= IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
1971 scb->u1.scsi_cmd_length = cmd->cmd_len;
1972 memcpy(scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
1973 last_scsi_type(shpnt)[ldn] = IM_LONG_SCB;
1974 break;
1975
1976
1977 default:
1978 scb->command = IM_OTHER_SCSI_CMD_CMD;
1979 scb->enable |= IM_READ_CONTROL | IM_SUPRESS_EXCEPTION_SHORT | IM_BYPASS_BUFFER;
1980 scb->u1.scsi_cmd_length = cmd->cmd_len;
1981 memcpy(scb->u2.scsi_command, cmd->cmnd, cmd->cmd_len);
1982 last_scsi_type(shpnt)[ldn] = IM_LONG_SCB;
1983 break;
1984 }
1985
1986 if (++disk_rw_in_progress == 1)
1987 PS2_DISK_LED_ON(shpnt->host_no, target);
1988
1989 if (last_scsi_type(shpnt)[ldn] == IM_LONG_SCB) {
1990 issue_cmd(shpnt, isa_virt_to_bus(scb), IM_LONG_SCB | ldn);
1991 IBM_DS(shpnt).long_scbs++;
1992 } else {
1993 issue_cmd(shpnt, isa_virt_to_bus(scb), IM_SCB | ldn);
1994 IBM_DS(shpnt).scbs++;
1995 }
1996 return 0;
1997}
1998
1999static DEF_SCSI_QCMD(ibmmca_queuecommand)
2000
2001static int __ibmmca_abort(Scsi_Cmnd * cmd)
2002{
2003
2004
2005
2006
2007 struct Scsi_Host *shpnt;
2008 unsigned int ldn;
2009 void (*saved_done) (Scsi_Cmnd *);
2010 int target;
2011 int max_pun;
2012 unsigned long imm_command;
2013
2014#ifdef IM_DEBUG_PROBE
2015 printk("IBM MCA SCSI: Abort subroutine called...\n");
2016#endif
2017
2018 shpnt = cmd->device->host;
2019
2020 max_pun = subsystem_maxid(shpnt);
2021 if (ibm_ansi_order) {
2022 target = max_pun - 1 - cmd->device->id;
2023 if ((target <= subsystem_pun(shpnt)) && (cmd->device->id <= subsystem_pun(shpnt)))
2024 target--;
2025 else if ((target >= subsystem_pun(shpnt)) && (cmd->device->id >= subsystem_pun(shpnt)))
2026 target++;
2027 } else
2028 target = cmd->device->id;
2029
2030
2031 printk(KERN_WARNING "IBM MCA SCSI: Sending abort to device pun=%d, lun=%d.\n", target, cmd->device->lun);
2032 ldn = get_ldn(shpnt)[target][cmd->device->lun];
2033
2034
2035 if (!ld(shpnt)[ldn].cmd) {
2036 return SUCCESS;
2037 }
2038
2039
2040
2041
2042
2043 saved_done = cmd->scsi_done;
2044 cmd->scsi_done = internal_done;
2045 cmd->SCp.Status = 0;
2046 last_scsi_command(shpnt)[ldn] = IM_ABORT_IMM_CMD;
2047 last_scsi_type(shpnt)[ldn] = IM_IMM_CMD;
2048 imm_command = inl(IM_CMD_REG(shpnt));
2049 imm_command &= (unsigned long) (0xffff0000);
2050 imm_command |= (unsigned long) (IM_ABORT_IMM_CMD);
2051
2052
2053 while (1) {
2054 if (!(inb(IM_STAT_REG(shpnt)) & IM_BUSY))
2055 break;
2056 }
2057
2058 outl(imm_command, IM_CMD_REG(shpnt));
2059 outb(IM_IMM_CMD | ldn, IM_ATTN_REG(shpnt));
2060#ifdef IM_DEBUG_PROBE
2061 printk("IBM MCA SCSI: Abort queued to adapter...\n");
2062#endif
2063 spin_unlock_irq(shpnt->host_lock);
2064 while (!cmd->SCp.Status)
2065 yield();
2066 spin_lock_irq(shpnt->host_lock);
2067 cmd->scsi_done = saved_done;
2068#ifdef IM_DEBUG_PROBE
2069 printk("IBM MCA SCSI: Abort returned with adapter response...\n");
2070#endif
2071
2072
2073 if (cmd->result == (DID_ABORT << 16))
2074 {
2075 cmd->result |= DID_ABORT << 16;
2076 if (cmd->scsi_done)
2077 (cmd->scsi_done) (cmd);
2078 ld(shpnt)[ldn].cmd = NULL;
2079#ifdef IM_DEBUG_PROBE
2080 printk("IBM MCA SCSI: Abort finished with success.\n");
2081#endif
2082 return SUCCESS;
2083 } else {
2084 cmd->result |= DID_NO_CONNECT << 16;
2085 if (cmd->scsi_done)
2086 (cmd->scsi_done) (cmd);
2087 ld(shpnt)[ldn].cmd = NULL;
2088#ifdef IM_DEBUG_PROBE
2089 printk("IBM MCA SCSI: Abort failed.\n");
2090#endif
2091 return FAILED;
2092 }
2093}
2094
2095static int ibmmca_abort(Scsi_Cmnd * cmd)
2096{
2097 struct Scsi_Host *shpnt = cmd->device->host;
2098 int rc;
2099
2100 spin_lock_irq(shpnt->host_lock);
2101 rc = __ibmmca_abort(cmd);
2102 spin_unlock_irq(shpnt->host_lock);
2103
2104 return rc;
2105}
2106
2107static int __ibmmca_host_reset(Scsi_Cmnd * cmd)
2108{
2109 struct Scsi_Host *shpnt;
2110 Scsi_Cmnd *cmd_aid;
2111 int ticks, i;
2112 unsigned long imm_command;
2113
2114 BUG_ON(cmd == NULL);
2115
2116 ticks = IM_RESET_DELAY * HZ;
2117 shpnt = cmd->device->host;
2118
2119 if (local_checking_phase_flag(shpnt)) {
2120 printk(KERN_WARNING "IBM MCA SCSI: unable to reset while checking devices.\n");
2121 return FAILED;
2122 }
2123
2124
2125 printk("IBM MCA SCSI: resetting all devices.\n");
2126 reset_status(shpnt) = IM_RESET_IN_PROGRESS;
2127 last_scsi_command(shpnt)[0xf] = IM_RESET_IMM_CMD;
2128 last_scsi_type(shpnt)[0xf] = IM_IMM_CMD;
2129 imm_command = inl(IM_CMD_REG(shpnt));
2130 imm_command &= (unsigned long) (0xffff0000);
2131 imm_command |= (unsigned long) (IM_RESET_IMM_CMD);
2132
2133 while (1) {
2134 if (!(inb(IM_STAT_REG(shpnt)) & IM_BUSY))
2135 break;
2136 spin_unlock_irq(shpnt->host_lock);
2137 yield();
2138 spin_lock_irq(shpnt->host_lock);
2139 }
2140
2141 outl(imm_command, IM_CMD_REG(shpnt));
2142 outb(IM_IMM_CMD | 0xf, IM_ATTN_REG(shpnt));
2143
2144
2145
2146
2147 while (reset_status(shpnt) == IM_RESET_IN_PROGRESS && --ticks && ((inb(IM_INTR_REG(shpnt)) & 0x8f) != 0x8f)) {
2148 udelay((1 + 999 / HZ) * 1000);
2149 barrier();
2150 }
2151
2152 if (!ticks) {
2153 printk(KERN_ERR "IBM MCA SCSI: reset did not complete within %d seconds.\n", IM_RESET_DELAY);
2154 reset_status(shpnt) = IM_RESET_FINISHED_FAIL;
2155 return FAILED;
2156 }
2157
2158 if ((inb(IM_INTR_REG(shpnt)) & 0x8f) == 0x8f) {
2159
2160 if (inb(IM_INTR_REG(shpnt)) == 0xaf)
2161 reset_status(shpnt) = IM_RESET_FINISHED_OK_NO_INT;
2162 else if (inb(IM_INTR_REG(shpnt)) == 0xcf)
2163 reset_status(shpnt) = IM_RESET_FINISHED_FAIL;
2164 else
2165 reset_status(shpnt) = IM_RESET_NOT_IN_PROGRESS_NO_INT;
2166 outb(IM_EOI | 0xf, IM_ATTN_REG(shpnt));
2167 }
2168
2169
2170 if (reset_status(shpnt) == IM_RESET_FINISHED_FAIL) {
2171 printk(KERN_ERR "IBM MCA SCSI: reset failed.\n");
2172 return FAILED;
2173 }
2174
2175
2176 printk(KERN_INFO "IBM MCA SCSI: Reset successfully completed.\n");
2177 for (i = 0; i < MAX_LOG_DEV; i++) {
2178 cmd_aid = ld(shpnt)[i].cmd;
2179 if (cmd_aid && cmd_aid->scsi_done) {
2180 ld(shpnt)[i].cmd = NULL;
2181 cmd_aid->result = DID_RESET << 16;
2182 }
2183 }
2184 return SUCCESS;
2185}
2186
2187static int ibmmca_host_reset(Scsi_Cmnd * cmd)
2188{
2189 struct Scsi_Host *shpnt = cmd->device->host;
2190 int rc;
2191
2192 spin_lock_irq(shpnt->host_lock);
2193 rc = __ibmmca_host_reset(cmd);
2194 spin_unlock_irq(shpnt->host_lock);
2195
2196 return rc;
2197}
2198
2199static int ibmmca_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int *info)
2200{
2201 int size = capacity;
2202 info[0] = 64;
2203 info[1] = 32;
2204 info[2] = size / (info[0] * info[1]);
2205 if (info[2] >= 1024) {
2206 info[0] = 128;
2207 info[1] = 63;
2208 info[2] = size / (info[0] * info[1]);
2209 if (info[2] >= 1024) {
2210 info[0] = 255;
2211 info[1] = 63;
2212 info[2] = size / (info[0] * info[1]);
2213 if (info[2] >= 1024)
2214 info[2] = 1023;
2215 }
2216 }
2217 return 0;
2218}
2219
2220
2221static int ldn_access_load(struct Scsi_Host *shpnt, int ldn)
2222{
2223 if (IBM_DS(shpnt).total_accesses == 0)
2224 return (0);
2225 if (IBM_DS(shpnt).ldn_access[ldn] == 0)
2226 return (0);
2227 return (IBM_DS(shpnt).ldn_access[ldn] * 100) / IBM_DS(shpnt).total_accesses;
2228}
2229
2230
2231static int ldn_access_total_read_write(struct Scsi_Host *shpnt)
2232{
2233 int a;
2234 int i;
2235
2236 a = 0;
2237 for (i = 0; i <= MAX_LOG_DEV; i++)
2238 a += IBM_DS(shpnt).ldn_read_access[i] + IBM_DS(shpnt).ldn_write_access[i];
2239 return (a);
2240}
2241
2242static int ldn_access_total_inquiry(struct Scsi_Host *shpnt)
2243{
2244 int a;
2245 int i;
2246
2247 a = 0;
2248 for (i = 0; i <= MAX_LOG_DEV; i++)
2249 a += IBM_DS(shpnt).ldn_inquiry_access[i];
2250 return (a);
2251}
2252
2253static int ldn_access_total_modeselect(struct Scsi_Host *shpnt)
2254{
2255 int a;
2256 int i;
2257
2258 a = 0;
2259 for (i = 0; i <= MAX_LOG_DEV; i++)
2260 a += IBM_DS(shpnt).ldn_modeselect_access[i];
2261 return (a);
2262}
2263
2264
2265static int ibmmca_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start, off_t offset, int length, int inout)
2266{
2267 int len = 0;
2268 int i, id, lun;
2269 unsigned long flags;
2270 int max_pun;
2271
2272
2273 spin_lock_irqsave(shpnt->host_lock, flags);
2274
2275 max_pun = subsystem_maxid(shpnt);
2276
2277 len += sprintf(buffer + len, "\n IBM-SCSI-Subsystem-Linux-Driver, Version %s\n\n\n", IBMMCA_SCSI_DRIVER_VERSION);
2278 len += sprintf(buffer + len, " SCSI Access-Statistics:\n");
2279 len += sprintf(buffer + len, " Device Scanning Order....: %s\n", (ibm_ansi_order) ? "IBM/ANSI" : "New Industry Standard");
2280#ifdef CONFIG_SCSI_MULTI_LUN
2281 len += sprintf(buffer + len, " Multiple LUN probing.....: Yes\n");
2282#else
2283 len += sprintf(buffer + len, " Multiple LUN probing.....: No\n");
2284#endif
2285 len += sprintf(buffer + len, " This Hostnumber..........: %d\n", shpnt->host_no);
2286 len += sprintf(buffer + len, " Base I/O-Port............: 0x%x\n", (unsigned int) (IM_CMD_REG(shpnt)));
2287 len += sprintf(buffer + len, " (Shared) IRQ.............: %d\n", IM_IRQ);
2288 len += sprintf(buffer + len, " Total Interrupts.........: %d\n", IBM_DS(shpnt).total_interrupts);
2289 len += sprintf(buffer + len, " Total SCSI Accesses......: %d\n", IBM_DS(shpnt).total_accesses);
2290 len += sprintf(buffer + len, " Total short SCBs.........: %d\n", IBM_DS(shpnt).scbs);
2291 len += sprintf(buffer + len, " Total long SCBs..........: %d\n", IBM_DS(shpnt).long_scbs);
2292 len += sprintf(buffer + len, " Total SCSI READ/WRITE..: %d\n", ldn_access_total_read_write(shpnt));
2293 len += sprintf(buffer + len, " Total SCSI Inquiries...: %d\n", ldn_access_total_inquiry(shpnt));
2294 len += sprintf(buffer + len, " Total SCSI Modeselects.: %d\n", ldn_access_total_modeselect(shpnt));
2295 len += sprintf(buffer + len, " Total SCSI other cmds..: %d\n", IBM_DS(shpnt).total_accesses - ldn_access_total_read_write(shpnt)
2296 - ldn_access_total_modeselect(shpnt)
2297 - ldn_access_total_inquiry(shpnt));
2298 len += sprintf(buffer + len, " Total SCSI command fails.: %d\n\n", IBM_DS(shpnt).total_errors);
2299 len += sprintf(buffer + len, " Logical-Device-Number (LDN) Access-Statistics:\n");
2300 len += sprintf(buffer + len, " LDN | Accesses [%%] | READ | WRITE | ASSIGNMENTS\n");
2301 len += sprintf(buffer + len, " -----|--------------|-----------|-----------|--------------\n");
2302 for (i = 0; i <= MAX_LOG_DEV; i++)
2303 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]);
2304 len += sprintf(buffer + len, " -----------------------------------------------------------\n\n");
2305 len += sprintf(buffer + len, " Dynamical-LDN-Assignment-Statistics:\n");
2306 len += sprintf(buffer + len, " Number of physical SCSI-devices..: %d (+ Adapter)\n", IBM_DS(shpnt).total_scsi_devices);
2307 len += sprintf(buffer + len, " Dynamical Assignment necessary...: %s\n", IBM_DS(shpnt).dyn_flag ? "Yes" : "No ");
2308 len += sprintf(buffer + len, " Next LDN to be assigned..........: 0x%x\n", next_ldn(shpnt));
2309 len += sprintf(buffer + len, " Dynamical assignments done yet...: %d\n", IBM_DS(shpnt).dynamical_assignments);
2310 len += sprintf(buffer + len, "\n Current SCSI-Device-Mapping:\n");
2311 len += sprintf(buffer + len, " Physical SCSI-Device Map Logical SCSI-Device Map\n");
2312 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");
2313 for (id = 0; id < max_pun; id++) {
2314 len += sprintf(buffer + len, " %2d ", id);
2315 for (lun = 0; lun < 8; lun++)
2316 len += sprintf(buffer + len, "%2s ", ti_p(get_scsi(shpnt)[id][lun]));
2317 len += sprintf(buffer + len, " %2d ", id);
2318 for (lun = 0; lun < 8; lun++)
2319 len += sprintf(buffer + len, "%2s ", ti_l(get_ldn(shpnt)[id][lun]));
2320 len += sprintf(buffer + len, "\n");
2321 }
2322
2323 len += sprintf(buffer + len, "(A = IBM-Subsystem, D = Harddisk, T = Tapedrive, P = Processor, W = WORM,\n");
2324 len += sprintf(buffer + len, " R = CD-ROM, S = Scanner, M = MO-Drive, C = Medium-Changer, + = unprovided LUN,\n");
2325 len += sprintf(buffer + len, " - = nothing found, nothing assigned or unprobed LUN)\n\n");
2326
2327 *start = buffer + offset;
2328 len -= offset;
2329 if (len > length)
2330 len = length;
2331 spin_unlock_irqrestore(shpnt->host_lock, flags);
2332 return len;
2333}
2334
2335static int option_setup(char *str)
2336{
2337 int ints[IM_MAX_HOSTS];
2338 char *cur = str;
2339 int i = 1;
2340
2341 while (cur && isdigit(*cur) && i < IM_MAX_HOSTS) {
2342 ints[i++] = simple_strtoul(cur, NULL, 0);
2343 if ((cur = strchr(cur, ',')) != NULL)
2344 cur++;
2345 }
2346 ints[0] = i - 1;
2347 internal_ibmmca_scsi_setup(cur, ints);
2348 return 1;
2349}
2350
2351__setup("ibmmcascsi=", option_setup);
2352
2353static struct mca_driver ibmmca_driver = {
2354 .id_table = ibmmca_id_table,
2355 .driver = {
2356 .name = "ibmmca",
2357 .bus = &mca_bus_type,
2358 .probe = ibmmca_probe,
2359 .remove = __devexit_p(ibmmca_remove),
2360 },
2361};
2362
2363static int __init ibmmca_init(void)
2364{
2365#ifdef MODULE
2366
2367 if (boot_options)
2368 option_setup(boot_options);
2369#endif
2370
2371 return mca_register_driver_integrated(&ibmmca_driver, MCA_INTEGSCSI);
2372}
2373
2374static void __exit ibmmca_exit(void)
2375{
2376 mca_unregister_driver(&ibmmca_driver);
2377}
2378
2379module_init(ibmmca_init);
2380module_exit(ibmmca_exit);
2381