@@ -51,10 +51,15 @@ typedef struct {
51
51
} imm_struct ;
52
52
53
53
static void imm_reset_pulse (unsigned int base );
54
- static int device_check (imm_struct * dev );
54
+ static int device_check (imm_struct * dev , bool autodetect );
55
55
56
56
#include "imm.h"
57
57
58
+ static unsigned int mode = IMM_AUTODETECT ;
59
+ module_param (mode , uint , 0644 );
60
+ MODULE_PARM_DESC (mode , "Transfer mode (0 = Autodetect, 1 = SPP 4-bit, "
61
+ "2 = SPP 8-bit, 3 = EPP 8-bit, 4 = EPP 16-bit, 5 = EPP 32-bit" );
62
+
58
63
static inline imm_struct * imm_dev (struct Scsi_Host * host )
59
64
{
60
65
return * (imm_struct * * )& host -> hostdata ;
@@ -366,13 +371,10 @@ static int imm_out(imm_struct *dev, char *buffer, int len)
366
371
case IMM_EPP_8 :
367
372
epp_reset (ppb );
368
373
w_ctr (ppb , 0x4 );
369
- #ifdef CONFIG_SCSI_IZIP_EPP16
370
- if (!(((long ) buffer | len ) & 0x01 ))
371
- outsw (ppb + 4 , buffer , len >> 1 );
372
- #else
373
- if (!(((long ) buffer | len ) & 0x03 ))
374
+ if (dev -> mode == IMM_EPP_32 && !(((long ) buffer | len ) & 0x03 ))
374
375
outsl (ppb + 4 , buffer , len >> 2 );
375
- #endif
376
+ else if (dev -> mode == IMM_EPP_16 && !(((long ) buffer | len ) & 0x01 ))
377
+ outsw (ppb + 4 , buffer , len >> 1 );
376
378
else
377
379
outsb (ppb + 4 , buffer , len );
378
380
w_ctr (ppb , 0xc );
@@ -426,13 +428,10 @@ static int imm_in(imm_struct *dev, char *buffer, int len)
426
428
case IMM_EPP_8 :
427
429
epp_reset (ppb );
428
430
w_ctr (ppb , 0x24 );
429
- #ifdef CONFIG_SCSI_IZIP_EPP16
430
- if (!(((long ) buffer | len ) & 0x01 ))
431
- insw (ppb + 4 , buffer , len >> 1 );
432
- #else
433
- if (!(((long ) buffer | len ) & 0x03 ))
434
- insl (ppb + 4 , buffer , len >> 2 );
435
- #endif
431
+ if (dev -> mode == IMM_EPP_32 && !(((long ) buffer | len ) & 0x03 ))
432
+ insw (ppb + 4 , buffer , len >> 2 );
433
+ else if (dev -> mode == IMM_EPP_16 && !(((long ) buffer | len ) & 0x01 ))
434
+ insl (ppb + 4 , buffer , len >> 1 );
436
435
else
437
436
insb (ppb + 4 , buffer , len );
438
437
w_ctr (ppb , 0x2c );
@@ -589,13 +588,28 @@ static int imm_select(imm_struct *dev, int target)
589
588
590
589
static int imm_init (imm_struct * dev )
591
590
{
591
+ bool autodetect = dev -> mode == IMM_AUTODETECT ;
592
+
593
+ if (autodetect ) {
594
+ int modes = dev -> dev -> port -> modes ;
595
+
596
+ /* Mode detection works up the chain of speed
597
+ * This avoids a nasty if-then-else-if-... tree
598
+ */
599
+ dev -> mode = IMM_NIBBLE ;
600
+
601
+ if (modes & PARPORT_MODE_TRISTATE )
602
+ dev -> mode = IMM_PS2 ;
603
+ }
604
+
592
605
if (imm_connect (dev , 0 ) != 1 )
593
606
return - EIO ;
594
607
imm_reset_pulse (dev -> base );
595
608
mdelay (1 ); /* Delay to allow devices to settle */
596
609
imm_disconnect (dev );
597
610
mdelay (1 ); /* Another delay to allow devices to settle */
598
- return device_check (dev );
611
+
612
+ return device_check (dev , autodetect );
599
613
}
600
614
601
615
static inline int imm_send_command (struct scsi_cmnd * cmd )
@@ -1000,7 +1014,7 @@ static int imm_reset(struct scsi_cmnd *cmd)
1000
1014
return SUCCESS ;
1001
1015
}
1002
1016
1003
- static int device_check (imm_struct * dev )
1017
+ static int device_check (imm_struct * dev , bool autodetect )
1004
1018
{
1005
1019
/* This routine looks for a device and then attempts to use EPP
1006
1020
to send a command. If all goes as planned then EPP is available. */
@@ -1012,8 +1026,8 @@ static int device_check(imm_struct *dev)
1012
1026
old_mode = dev -> mode ;
1013
1027
for (loop = 0 ; loop < 8 ; loop ++ ) {
1014
1028
/* Attempt to use EPP for Test Unit Ready */
1015
- if ((ppb & 0x0007 ) == 0x0000 )
1016
- dev -> mode = IMM_EPP_32 ;
1029
+ if (autodetect && (ppb & 0x0007 ) == 0x0000 )
1030
+ dev -> mode = IMM_EPP_8 ;
1017
1031
1018
1032
second_pass :
1019
1033
imm_connect (dev , CONNECT_EPP_MAYBE );
@@ -1038,7 +1052,7 @@ static int device_check(imm_struct *dev)
1038
1052
udelay (1000 );
1039
1053
imm_disconnect (dev );
1040
1054
udelay (1000 );
1041
- if (dev -> mode == IMM_EPP_32 ) {
1055
+ if (dev -> mode != old_mode ) {
1042
1056
dev -> mode = old_mode ;
1043
1057
goto second_pass ;
1044
1058
}
@@ -1063,7 +1077,7 @@ static int device_check(imm_struct *dev)
1063
1077
udelay (1000 );
1064
1078
imm_disconnect (dev );
1065
1079
udelay (1000 );
1066
- if (dev -> mode == IMM_EPP_32 ) {
1080
+ if (dev -> mode != old_mode ) {
1067
1081
dev -> mode = old_mode ;
1068
1082
goto second_pass ;
1069
1083
}
@@ -1150,7 +1164,6 @@ static int __imm_attach(struct parport *pb)
1150
1164
DECLARE_WAIT_QUEUE_HEAD_ONSTACK (waiting );
1151
1165
DEFINE_WAIT (wait );
1152
1166
int ports ;
1153
- int modes , ppb ;
1154
1167
int err = - ENOMEM ;
1155
1168
struct pardev_cb imm_cb ;
1156
1169
@@ -1162,7 +1175,7 @@ static int __imm_attach(struct parport *pb)
1162
1175
1163
1176
1164
1177
dev -> base = -1 ;
1165
- dev -> mode = IMM_AUTODETECT ;
1178
+ dev -> mode = mode < IMM_UNKNOWN ? mode : IMM_AUTODETECT ;
1166
1179
INIT_LIST_HEAD (& dev -> list );
1167
1180
1168
1181
temp = find_parent ();
@@ -1197,18 +1210,9 @@ static int __imm_attach(struct parport *pb)
1197
1210
}
1198
1211
dev -> waiting = NULL ;
1199
1212
finish_wait (& waiting , & wait );
1200
- ppb = dev -> base = dev -> dev -> port -> base ;
1213
+ dev -> base = dev -> dev -> port -> base ;
1201
1214
dev -> base_hi = dev -> dev -> port -> base_hi ;
1202
- w_ctr (ppb , 0x0c );
1203
- modes = dev -> dev -> port -> modes ;
1204
-
1205
- /* Mode detection works up the chain of speed
1206
- * This avoids a nasty if-then-else-if-... tree
1207
- */
1208
- dev -> mode = IMM_NIBBLE ;
1209
-
1210
- if (modes & PARPORT_MODE_TRISTATE )
1211
- dev -> mode = IMM_PS2 ;
1215
+ w_ctr (dev -> base , 0x0c );
1212
1216
1213
1217
/* Done configuration */
1214
1218
0 commit comments