Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
c7a4e6c2
Commit
c7a4e6c2
authored
Oct 27, 2002
by
Alan Cox
Committed by
Linus Torvalds
Oct 27, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] resurrect the NCR53c406a
parent
ec765df5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
777 additions
and
806 deletions
+777
-806
drivers/scsi/NCR53c406a.c
drivers/scsi/NCR53c406a.c
+750
-763
drivers/scsi/NCR53c406a.h
drivers/scsi/NCR53c406a.h
+27
-43
No files found.
drivers/scsi/NCR53c406a.c
View file @
c7a4e6c2
...
@@ -26,9 +26,9 @@
...
@@ -26,9 +26,9 @@
#define USE_PIO 1
#define USE_PIO 1
#define USE_BIOS 0
#define USE_BIOS 0
/* #define BIOS_ADDR 0xD8000 */
/* define this if autoprobe fails */
/* #define BIOS_ADDR 0xD8000 */
/* define this if autoprobe fails */
/* #define PORT_BASE 0x330 */
/* define this if autoprobe fails */
/* #define PORT_BASE 0x330 */
/* define this if autoprobe fails */
/* #define IRQ_LEV 0 */
/* define this if autoprobe fails */
/* #define IRQ_LEV 0 */
/* define this if autoprobe fails */
#define DMA_CHAN 5
/* this is ignored if DMA is disabled */
#define DMA_CHAN 5
/* this is ignored if DMA is disabled */
/* Set this to 0 if you encounter kernel lockups while transferring
/* Set this to 0 if you encounter kernel lockups while transferring
...
@@ -196,7 +196,7 @@ static int port_base;
...
@@ -196,7 +196,7 @@ static int port_base;
#if IRQ_LEV
#if IRQ_LEV
static
int
irq_level
=
IRQ_LEV
;
static
int
irq_level
=
IRQ_LEV
;
#else
#else
static
int
irq_level
=
-
1
;
/* 0 is 'no irq', so use -1 for 'uninitialized'
*/
static
int
irq_level
=
-
1
;
/* 0 is 'no irq', so use -1 for 'uninitialized'
*/
#endif
#endif
#if USE_DMA
#if USE_DMA
...
@@ -217,15 +217,14 @@ static char info_msg[256];
...
@@ -217,15 +217,14 @@ static char info_msg[256];
/* possible BIOS locations */
/* possible BIOS locations */
#if USE_BIOS
#if USE_BIOS
static
void
*
addresses
[]
=
{
static
void
*
addresses
[]
=
{
(
void
*
)
0xd8000
,
(
void
*
)
0xd8000
,
(
void
*
)
0xc8000
(
void
*
)
0xc8000
};
};
#define ADDRESS_COUNT (sizeof( addresses ) / sizeof( unsigned ))
#define ADDRESS_COUNT (sizeof( addresses ) / sizeof( unsigned ))
#endif
/* USE_BIOS */
#endif
/* USE_BIOS */
/* possible i/o port addresses */
/* possible i/o port addresses */
static
unsigned
short
ports
[]
=
static
unsigned
short
ports
[]
=
{
0x230
,
0x330
,
0x280
,
0x290
,
0x330
,
0x340
,
0x300
,
0x310
,
0x348
,
0x350
};
{
0x230
,
0x330
,
0x280
,
0x290
,
0x330
,
0x340
,
0x300
,
0x310
,
0x348
,
0x350
};
#define PORT_COUNT (sizeof( ports ) / sizeof( unsigned short ))
#define PORT_COUNT (sizeof( ports ) / sizeof( unsigned short ))
/* possible interrupt channels */
/* possible interrupt channels */
...
@@ -241,8 +240,9 @@ struct signature {
...
@@ -241,8 +240,9 @@ struct signature {
}
signatures
[]
__initdata
=
{
}
signatures
[]
__initdata
=
{
/* 1 2 3 4 5 6 */
/* 1 2 3 4 5 6 */
/* 123456789012345678901234567890123456789012345678901234567890 */
/* 123456789012345678901234567890123456789012345678901234567890 */
{
"Copyright (C) Acculogic, Inc.
\r\n
2.8M Diskette Extension Bios ver 4.04.03 03/01/1993"
,
61
,
82
},
{
};
"Copyright (C) Acculogic, Inc.
\r\n
2.8M Diskette Extension Bios ver 4.04.03 03/01/1993"
,
61
,
82
},};
#define SIGNATURE_COUNT (sizeof( signatures ) / sizeof( struct signature ))
#define SIGNATURE_COUNT (sizeof( signatures ) / sizeof( struct signature ))
#endif
/* USE_BIOS */
#endif
/* USE_BIOS */
...
@@ -263,57 +263,56 @@ static int FIFO_FLAGS; /* indicates # of bytes in fifo */
...
@@ -263,57 +263,56 @@ static int FIFO_FLAGS; /* indicates # of bytes in fifo */
static
int
SYNCOFF
;
/* synchronous offset register */
static
int
SYNCOFF
;
/* synchronous offset register */
static
int
CONFIG1
;
/* configuration register */
static
int
CONFIG1
;
/* configuration register */
static
int
CLKCONV
;
/* clock conversion reg */
static
int
CLKCONV
;
/* clock conversion reg */
/*static int TESTREG;*/
/* test mode register
*/
/*static int TESTREG;*//* test mode register
*/
static
int
CONFIG2
;
/* Configuration 2 Register */
static
int
CONFIG2
;
/* Configuration 2 Register */
static
int
CONFIG3
;
/* Configuration 3 Register */
static
int
CONFIG3
;
/* Configuration 3 Register */
static
int
CONFIG4
;
/* Configuration 4 Register */
static
int
CONFIG4
;
/* Configuration 4 Register */
static
int
TC_HIGH
;
/* Transfer Counter High */
static
int
TC_HIGH
;
/* Transfer Counter High */
/*static int FIFO_BOTTOM;*/
/* Reserve FIFO byte register */
/*static int FIFO_BOTTOM;*/
/* Reserve FIFO byte register */
/* Control Register Set 1 */
/* Control Register Set 1 */
/*static int JUMPER_SENSE;*/
/* Jumper sense port reg (r/w) */
/*static int JUMPER_SENSE;*/
/* Jumper sense port reg (r/w) */
/*static int SRAM_PTR;*/
/* SRAM address pointer reg (r/w) */
/*static int SRAM_PTR;*/
/* SRAM address pointer reg (r/w) */
/*static int SRAM_DATA;*/
/* SRAM data register (r/w) */
/*static int SRAM_DATA;*/
/* SRAM data register (r/w) */
static
int
PIO_FIFO
;
/* PIO FIFO registers (r/w) */
static
int
PIO_FIFO
;
/* PIO FIFO registers (r/w) */
/*static int PIO_FIFO1;*/
/* */
/*static int PIO_FIFO1;*/
/* */
/*static int PIO_FIFO2;*/
/* */
/*static int PIO_FIFO2;*/
/* */
/*static int PIO_FIFO3;*/
/* */
/*static int PIO_FIFO3;*/
/* */
static
int
PIO_STATUS
;
/* PIO status (r/w) */
static
int
PIO_STATUS
;
/* PIO status (r/w) */
/*static int ATA_CMD;*/
/* ATA command/status reg (r/w) */
/*static int ATA_CMD;*/
/* ATA command/status reg (r/w) */
/*static int ATA_ERR;*/
/* ATA features/error register (r/w)
*/
/*static int ATA_ERR;*//* ATA features/error register (r/w)
*/
static
int
PIO_FLAG
;
/* PIO flag interrupt enable (r/w) */
static
int
PIO_FLAG
;
/* PIO flag interrupt enable (r/w) */
static
int
CONFIG5
;
/* Configuration 5 register (r/w) */
static
int
CONFIG5
;
/* Configuration 5 register (r/w) */
/*static int SIGNATURE;*/
/* Signature Register (r) */
/*static int SIGNATURE;*/
/* Signature Register (r) */
/*static int CONFIG6;*/
/* Configuration 6 register (r) */
/*static int CONFIG6;*/
/* Configuration 6 register (r) */
/* ============================================================== */
/* ============================================================== */
#if USE_DMA
#if USE_DMA
static
__inline__
int
static
__inline__
int
NCR53c406a_dma_setup
(
unsigned
char
*
ptr
,
unsigned
int
count
,
unsigned
char
mode
)
NCR53c406a_dma_setup
(
unsigned
char
*
ptr
,
{
unsigned
int
count
,
unsigned
char
mode
)
{
unsigned
limit
;
unsigned
limit
;
unsigned
long
flags
=
0
;
unsigned
long
flags
=
0
;
VDEB
(
printk
(
"dma: before count=%d "
,
count
));
VDEB
(
printk
(
"dma: before count=%d "
,
count
));
if
(
dma_chan
<=
3
)
{
if
(
dma_chan
<=
3
)
{
if
(
count
>
65536
)
if
(
count
>
65536
)
count
=
65536
;
count
=
65536
;
limit
=
65536
-
(((
unsigned
)
ptr
)
&
0xFFFF
);
limit
=
65536
-
(((
unsigned
)
ptr
)
&
0xFFFF
);
}
else
{
}
else
{
if
(
count
>
(
65536
<<
1
))
if
(
count
>
(
65536
<<
1
))
count
=
(
65536
<<
1
);
count
=
(
65536
<<
1
);
limit
=
(
65536
<<
1
)
-
(((
unsigned
)
ptr
)
&
0x1FFFF
);
limit
=
(
65536
<<
1
)
-
(((
unsigned
)
ptr
)
&
0x1FFFF
);
}
}
if
(
count
>
limit
)
count
=
limit
;
if
(
count
>
limit
)
count
=
limit
;
VDEB
(
printk
(
"after count=%d
\n
"
,
count
));
VDEB
(
printk
(
"after count=%d
\n
"
,
count
));
if
((
count
&
1
)
||
(((
unsigned
)
ptr
)
&
1
))
if
((
count
&
1
)
||
(((
unsigned
)
ptr
)
&
1
))
panic
(
"NCR53c406a: attempted unaligned DMA transfer
\n
"
);
panic
(
"NCR53c406a: attempted unaligned DMA transfer
\n
"
);
flags
=
claim_dma_lock
();
flags
=
claim_dma_lock
();
disable_dma
(
dma_chan
);
disable_dma
(
dma_chan
);
clear_dma_ff
(
dma_chan
);
clear_dma_ff
(
dma_chan
);
set_dma_addr
(
dma_chan
,
(
long
)
ptr
);
set_dma_addr
(
dma_chan
,
(
long
)
ptr
);
...
@@ -325,22 +324,22 @@ NCR53c406a_dma_setup (unsigned char *ptr,
...
@@ -325,22 +324,22 @@ NCR53c406a_dma_setup (unsigned char *ptr,
return
count
;
return
count
;
}
}
static
__inline__
int
static
__inline__
int
NCR53c406a_dma_write
(
unsigned
char
*
src
,
unsigned
int
count
)
NCR53c406a_dma_write
(
unsigned
char
*
src
,
unsigned
int
count
)
{
{
return
NCR53c406a_dma_setup
(
src
,
count
,
DMA_MODE_WRITE
);
return
NCR53c406a_dma_setup
(
src
,
count
,
DMA_MODE_WRITE
);
}
}
static
__inline__
int
static
__inline__
int
NCR53c406a_dma_read
(
unsigned
char
*
src
,
unsigned
int
count
)
NCR53c406a_dma_read
(
unsigned
char
*
src
,
unsigned
int
count
)
{
{
return
NCR53c406a_dma_setup
(
src
,
count
,
DMA_MODE_READ
);
return
NCR53c406a_dma_setup
(
src
,
count
,
DMA_MODE_READ
);
}
}
static
__inline__
int
static
__inline__
int
NCR53c406a_dma_residual
(
void
)
NCR53c406a_dma_residual
(
void
)
{
{
register
int
tmp
;
register
int
tmp
;
unsigned
long
flags
;
unsigned
long
flags
;
flags
=
claim_dma_lock
();
flags
=
claim_dma_lock
();
clear_dma_ff
(
dma_chan
);
clear_dma_ff
(
dma_chan
);
tmp
=
get_dma_residue
(
dma_chan
);
tmp
=
get_dma_residue
(
dma_chan
);
release_dma_lock
(
flags
);
release_dma_lock
(
flags
);
...
@@ -350,12 +349,10 @@ NCR53c406a_dma_residual (void) {
...
@@ -350,12 +349,10 @@ NCR53c406a_dma_residual (void) {
#endif
/* USE_DMA */
#endif
/* USE_DMA */
#if USE_PIO
#if USE_PIO
static
__inline__
int
NCR53c406a_pio_read
(
unsigned
char
*
request
,
static
__inline__
int
NCR53c406a_pio_read
(
unsigned
char
*
request
,
unsigned
int
reqlen
)
unsigned
int
reqlen
)
{
{
int
i
;
int
i
;
int
len
;
/* current scsi fifo size */
int
len
;
/* current scsi fifo size */
unsigned
long
flags
=
0
;
REG1
;
REG1
;
while
(
reqlen
)
{
while
(
reqlen
)
{
...
@@ -364,18 +361,23 @@ static __inline__ int NCR53c406a_pio_read(unsigned char *request,
...
@@ -364,18 +361,23 @@ static __inline__ int NCR53c406a_pio_read(unsigned char *request,
if
(
i
&
0x80
)
if
(
i
&
0x80
)
return
0
;
return
0
;
switch
(
i
&
0x1e
)
{
switch
(
i
&
0x1e
)
{
default:
default:
case
0x10
:
case
0x10
:
len
=
0
;
break
;
len
=
0
;
break
;
case
0x0
:
case
0x0
:
len
=
1
;
break
;
len
=
1
;
break
;
case
0x8
:
case
0x8
:
len
=
42
;
break
;
len
=
42
;
break
;
case
0xc
:
case
0xc
:
len
=
84
;
break
;
len
=
84
;
break
;
case
0xe
:
case
0xe
:
len
=
128
;
break
;
len
=
128
;
break
;
}
}
if
((
i
&
0x40
)
&&
len
==
0
)
{
/* fifo empty and interrupt occurred */
if
((
i
&
0x40
)
&&
len
==
0
)
{
/* fifo empty and interrupt occurred */
...
@@ -383,82 +385,77 @@ static __inline__ int NCR53c406a_pio_read(unsigned char *request,
...
@@ -383,82 +385,77 @@ static __inline__ int NCR53c406a_pio_read(unsigned char *request,
}
}
if
(
len
)
{
if
(
len
)
{
if
(
len
>
reqlen
)
if
(
len
>
reqlen
)
len
=
reqlen
;
len
=
reqlen
;
save_flags
(
flags
);
if
(
fast_pio
&&
len
>
3
)
{
cli
();
insl
(
PIO_FIFO
,
request
,
len
>>
2
);
if
(
fast_pio
&&
len
>
3
)
{
insl
(
PIO_FIFO
,
request
,
len
>>
2
);
request
+=
len
&
0xfc
;
request
+=
len
&
0xfc
;
reqlen
-=
len
&
0xfc
;
reqlen
-=
len
&
0xfc
;
}
}
else
{
else
{
while
(
len
--
)
{
while
(
len
--
)
{
*
request
++
=
inb
(
PIO_FIFO
);
*
request
++
=
inb
(
PIO_FIFO
);
reqlen
--
;
reqlen
--
;
}
}
}
}
restore_flags
(
flags
);
}
}
}
}
return
0
;
return
0
;
}
}
static
__inline__
int
NCR53c406a_pio_write
(
unsigned
char
*
request
,
static
__inline__
int
NCR53c406a_pio_write
(
unsigned
char
*
request
,
unsigned
int
reqlen
)
unsigned
int
reqlen
)
{
{
int
i
=
0
;
int
i
=
0
;
int
len
;
/* current scsi fifo size */
int
len
;
/* current scsi fifo size */
unsigned
long
flags
=
0
;
REG1
;
REG1
;
while
(
reqlen
&&
!
(
i
&
0x40
))
{
while
(
reqlen
&&
!
(
i
&
0x40
))
{
i
=
inb
(
PIO_STATUS
);
i
=
inb
(
PIO_STATUS
);
/* VDEB(printk("pio_status=%x\n", i)); */
/* VDEB(printk("pio_status=%x\n", i)); */
if
(
i
&
0x80
)
/* error */
if
(
i
&
0x80
)
/* error */
return
0
;
return
0
;
switch
(
i
&
0x1e
)
{
switch
(
i
&
0x1e
)
{
case
0x10
:
case
0x10
:
len
=
128
;
break
;
len
=
128
;
break
;
case
0x0
:
case
0x0
:
len
=
84
;
break
;
len
=
84
;
break
;
case
0x8
:
case
0x8
:
len
=
42
;
break
;
len
=
42
;
break
;
case
0xc
:
case
0xc
:
len
=
1
;
break
;
len
=
1
;
break
;
default:
default:
case
0xe
:
case
0xe
:
len
=
0
;
break
;
len
=
0
;
break
;
}
}
if
(
len
)
{
if
(
len
)
{
if
(
len
>
reqlen
)
if
(
len
>
reqlen
)
len
=
reqlen
;
len
=
reqlen
;
save_flags
(
flags
);
if
(
fast_pio
&&
len
>
3
)
{
cli
();
outsl
(
PIO_FIFO
,
request
,
len
>>
2
);
if
(
fast_pio
&&
len
>
3
)
{
outsl
(
PIO_FIFO
,
request
,
len
>>
2
);
request
+=
len
&
0xfc
;
request
+=
len
&
0xfc
;
reqlen
-=
len
&
0xfc
;
reqlen
-=
len
&
0xfc
;
}
}
else
{
else
{
while
(
len
--
)
{
while
(
len
--
)
{
outb
(
*
request
++
,
PIO_FIFO
);
outb
(
*
request
++
,
PIO_FIFO
);
reqlen
--
;
reqlen
--
;
}
}
}
}
restore_flags
(
flags
);
}
}
}
}
return
0
;
return
0
;
}
}
#endif
/* USE_PIO */
#endif
/* USE_PIO */
int
__init
static
int
__init
NCR53c406a_detect
(
Scsi_Host_Template
*
tpnt
)
NCR53c406a_detect
(
Scsi_Host_Template
*
tpnt
)
{
{
struct
Scsi_Host
*
shpnt
=
NULL
;
struct
Scsi_Host
*
shpnt
=
NULL
;
#ifndef PORT_BASE
#ifndef PORT_BASE
int
i
;
int
i
;
...
@@ -468,19 +465,18 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
...
@@ -468,19 +465,18 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
int
ii
,
jj
;
int
ii
,
jj
;
bios_base
=
0
;
bios_base
=
0
;
/* look for a valid signature */
/* look for a valid signature */
for
(
ii
=
0
;
ii
<
ADDRESS_COUNT
&&
!
bios_base
;
ii
++
)
for
(
ii
=
0
;
ii
<
ADDRESS_COUNT
&&
!
bios_base
;
ii
++
)
for
(
jj
=
0
;
(
jj
<
SIGNATURE_COUNT
)
&&
!
bios_base
;
jj
++
)
for
(
jj
=
0
;
(
jj
<
SIGNATURE_COUNT
)
&&
!
bios_base
;
jj
++
)
if
(
!
memcmp
((
void
*
)
addresses
[
ii
]
+
signatures
[
jj
].
sig_offset
,
if
(
!
memcmp
((
void
*
)
addresses
[
ii
]
+
signatures
[
jj
].
sig_offset
,
(
void
*
)
signatures
[
jj
].
signature
,
(
int
)
signatures
[
jj
].
sig_length
))
(
void
*
)
signatures
[
jj
].
signature
,
bios_base
=
addresses
[
ii
];
(
int
)
signatures
[
jj
].
sig_length
))
bios_base
=
addresses
[
ii
];
if
(
!
bios_base
)
{
if
(
!
bios_base
){
printk
(
"NCR53c406a: BIOS signature not found
\n
"
);
printk
(
"NCR53c406a: BIOS signature not found
\n
"
);
return
0
;
return
0
;
}
}
DEB
(
printk
(
"NCR53c406a BIOS found at %X
\n
"
,
(
unsigned
int
)
bios_base
););
DEB
(
printk
(
"NCR53c406a BIOS found at %X
\n
"
,
(
unsigned
int
)
bios_base
);
);
#endif
/* USE_BIOS */
#endif
/* USE_BIOS */
#ifdef PORT_BASE
#ifdef PORT_BASE
...
@@ -491,18 +487,14 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
...
@@ -491,18 +487,14 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
if
(
port_base
)
{
/* LILO override */
if
(
port_base
)
{
/* LILO override */
if
(
!
request_region
(
port_base
,
0x10
,
"NCR53c406a"
))
if
(
!
request_region
(
port_base
,
0x10
,
"NCR53c406a"
))
port_base
=
0
;
port_base
=
0
;
}
}
else
{
else
{
for
(
i
=
0
;
i
<
PORT_COUNT
&&
!
port_base
;
i
++
)
{
for
(
i
=
0
;
i
<
PORT_COUNT
&&
!
port_base
;
i
++
){
if
(
!
request_region
(
ports
[
i
],
0x10
,
"NCR53c406a"
))
{
if
(
!
request_region
(
ports
[
i
],
0x10
,
"NCR53c406a"
)){
DEB
(
printk
(
"NCR53c406a: port %x in use
\n
"
,
ports
[
i
]));
DEB
(
printk
(
"NCR53c406a: port %x in use
\n
"
,
ports
[
i
]));
}
}
else
{
else
{
VDEB
(
printk
(
"NCR53c406a: port %x available
\n
"
,
ports
[
i
]));
VDEB
(
printk
(
"NCR53c406a: port %x available
\n
"
,
ports
[
i
]));
outb
(
C5_IMG
,
ports
[
i
]
+
0x0d
);
/* reg set 1 */
outb
(
C5_IMG
,
ports
[
i
]
+
0x0d
);
/* reg set 1 */
if
(
(
inb
(
ports
[
i
]
+
0x0e
)
^
inb
(
ports
[
i
]
+
0x0e
))
==
7
if
((
inb
(
ports
[
i
]
+
0x0e
)
^
inb
(
ports
[
i
]
+
0x0e
))
==
7
&&
(
inb
(
ports
[
i
]
+
0x0e
)
^
inb
(
ports
[
i
]
+
0x0e
))
==
7
&&
(
inb
(
ports
[
i
]
+
0x0e
)
&
0xf8
)
==
0x58
)
{
&&
(
inb
(
ports
[
i
]
+
0x0e
)
^
inb
(
ports
[
i
]
+
0x0e
))
==
7
&&
(
inb
(
ports
[
i
]
+
0x0e
)
&
0xf8
)
==
0x58
)
{
port_base
=
ports
[
i
];
port_base
=
ports
[
i
];
VDEB
(
printk
(
"NCR53c406a: Sig register valid
\n
"
));
VDEB
(
printk
(
"NCR53c406a: Sig register valid
\n
"
));
VDEB
(
printk
(
"port_base=%x
\n
"
,
port_base
));
VDEB
(
printk
(
"port_base=%x
\n
"
,
port_base
));
...
@@ -514,7 +506,7 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
...
@@ -514,7 +506,7 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
}
}
#endif
/* PORT_BASE */
#endif
/* PORT_BASE */
if
(
!
port_base
){
/* no ports found */
if
(
!
port_base
)
{
/* no ports found */
printk
(
"NCR53c406a: no available ports found
\n
"
);
printk
(
"NCR53c406a: no available ports found
\n
"
);
return
0
;
return
0
;
}
}
...
@@ -525,8 +517,8 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
...
@@ -525,8 +517,8 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
chip_init
();
chip_init
();
#ifndef IRQ_LEV
#ifndef IRQ_LEV
if
(
irq_level
<
0
)
{
/* LILO override if >= 0
*/
if
(
irq_level
<
0
)
{
/* LILO override if >= 0
*/
irq_level
=
irq_probe
();
irq_level
=
irq_probe
();
if
(
irq_level
<
0
)
{
/* Trouble */
if
(
irq_level
<
0
)
{
/* Trouble */
printk
(
"NCR53c406a: IRQ problem, irq_level=%d, giving up
\n
"
,
irq_level
);
printk
(
"NCR53c406a: IRQ problem, irq_level=%d, giving up
\n
"
,
irq_level
);
goto
err_release
;
goto
err_release
;
...
@@ -545,30 +537,28 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
...
@@ -545,30 +537,28 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
goto
err_release
;
goto
err_release
;
}
}
if
(
irq_level
>
0
)
{
if
(
irq_level
>
0
)
{
if
(
request_irq
(
irq_level
,
do_NCR53c406a_intr
,
0
,
"NCR53c406a"
,
shpnt
))
{
if
(
request_irq
(
irq_level
,
do_NCR53c406a_intr
,
0
,
"NCR53c406a"
,
shpnt
))
{
printk
(
"NCR53c406a: unable to allocate IRQ %d
\n
"
,
irq_level
);
printk
(
"NCR53c406a: unable to allocate IRQ %d
\n
"
,
irq_level
);
goto
err_free_scsi
;
goto
err_free_scsi
;
}
}
tpnt
->
can_queue
=
1
;
tpnt
->
can_queue
=
1
;
DEB
(
printk
(
"NCR53c406a: allocated IRQ %d
\n
"
,
irq_level
));
DEB
(
printk
(
"NCR53c406a: allocated IRQ %d
\n
"
,
irq_level
));
}
}
else
if
(
irq_level
==
0
)
{
else
if
(
irq_level
==
0
)
{
tpnt
->
can_queue
=
0
;
tpnt
->
can_queue
=
0
;
DEB
(
printk
(
"NCR53c406a: No interrupts detected
\n
"
));
DEB
(
printk
(
"NCR53c406a: No interrupts detected
\n
"
));
#if USE_DMA
#if USE_DMA
printk
(
"NCR53c406a: No interrupts found and DMA mode defined. Giving up.
\n
"
);
printk
(
"NCR53c406a: No interrupts found and DMA mode defined. Giving up.
\n
"
);
goto
err_free_scsi
;
goto
err_free_scsi
;
#endif
/* USE_DMA */
#endif
/* USE_DMA */
}
}
else
{
else
{
DEB
(
printk
(
"NCR53c406a: Shouldn't get here!
\n
"
));
DEB
(
printk
(
"NCR53c406a: Shouldn't get here!
\n
"
));
goto
err_free_scsi
;
goto
err_free_scsi
;
}
}
#if USE_DMA
#if USE_DMA
dma_chan
=
DMA_CHAN
;
dma_chan
=
DMA_CHAN
;
if
(
request_dma
(
dma_chan
,
"NCR53c406a"
)
!=
0
)
{
if
(
request_dma
(
dma_chan
,
"NCR53c406a"
)
!=
0
)
{
printk
(
"NCR53c406a: unable to allocate DMA channel %d
\n
"
,
dma_chan
);
printk
(
"NCR53c406a: unable to allocate DMA channel %d
\n
"
,
dma_chan
);
goto
err_free_irq
;
goto
err_free_irq
;
}
}
...
@@ -584,18 +574,16 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
...
@@ -584,18 +574,16 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
#endif
#endif
#if USE_DMA
#if USE_DMA
sprintf
(
info_msg
,
"NCR53c406a at 0x%x, IRQ %d, DMA channel %d."
,
sprintf
(
info_msg
,
"NCR53c406a at 0x%x, IRQ %d, DMA channel %d."
,
port_base
,
irq_level
,
dma_chan
);
port_base
,
irq_level
,
dma_chan
);
#else
#else
sprintf
(
info_msg
,
"NCR53c406a at 0x%x, IRQ %d, %s PIO mode."
,
sprintf
(
info_msg
,
"NCR53c406a at 0x%x, IRQ %d, %s PIO mode."
,
port_base
,
irq_level
,
fast_pio
?
"fast"
:
"slow"
);
port_base
,
irq_level
,
fast_pio
?
"fast"
:
"slow"
);
#endif
#endif
return
(
tpnt
->
present
);
return
(
tpnt
->
present
);
#if USE_DMA
#if USE_DMA
err_free_irq:
err_free_irq:
if
(
irq_level
)
if
(
irq_level
)
free_irq
(
irq_level
,
shpnt
);
free_irq
(
irq_level
,
shpnt
);
#endif
#endif
err_free_scsi:
err_free_scsi:
...
@@ -606,12 +594,13 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
...
@@ -606,12 +594,13 @@ NCR53c406a_detect(Scsi_Host_Template * tpnt){
}
}
/* called from init/main.c */
/* called from init/main.c */
void
__init
NCR53c406a_setup
(
char
*
str
,
int
*
ints
)
static
void
__init
NCR53c406a_setup
(
char
*
str
,
int
*
ints
)
{
{
static
size_t
setup_idx
=
0
;
static
size_t
setup_idx
=
0
;
size_t
i
;
size_t
i
;
DEB
(
printk
(
"NCR53c406a: Setup called
\n
"
););
DEB
(
printk
(
"NCR53c406a: Setup called
\n
"
);
);
if
(
setup_idx
>=
PORT_COUNT
-
1
)
{
if
(
setup_idx
>=
PORT_COUNT
-
1
)
{
printk
(
"NCR53c406a: Setup called too many times. Bad LILO params?
\n
"
);
printk
(
"NCR53c406a: Setup called too many times. Bad LILO params?
\n
"
);
...
@@ -625,7 +614,8 @@ void __init NCR53c406a_setup(char *str, int *ints)
...
@@ -625,7 +614,8 @@ void __init NCR53c406a_setup(char *str, int *ints)
for
(
i
=
0
;
i
<
PORT_COUNT
&&
!
port_base
;
i
++
)
for
(
i
=
0
;
i
<
PORT_COUNT
&&
!
port_base
;
i
++
)
if
(
ports
[
i
]
==
ints
[
1
])
{
if
(
ports
[
i
]
==
ints
[
1
])
{
port_base
=
ints
[
1
];
port_base
=
ints
[
1
];
DEB
(
printk
(
"NCR53c406a: Specified port_base 0x%X
\n
"
,
port_base
);)
DEB
(
printk
(
"NCR53c406a: Specified port_base 0x%X
\n
"
,
port_base
);
)
}
}
if
(
!
port_base
)
{
if
(
!
port_base
)
{
printk
(
"NCR53c406a: Invalid PORTBASE 0x%X specified
\n
"
,
ints
[
1
]);
printk
(
"NCR53c406a: Invalid PORTBASE 0x%X specified
\n
"
,
ints
[
1
]);
...
@@ -635,13 +625,14 @@ void __init NCR53c406a_setup(char *str, int *ints)
...
@@ -635,13 +625,14 @@ void __init NCR53c406a_setup(char *str, int *ints)
if
(
ints
[
0
]
>
1
)
{
if
(
ints
[
0
]
>
1
)
{
if
(
ints
[
2
]
==
0
)
{
if
(
ints
[
2
]
==
0
)
{
irq_level
=
0
;
irq_level
=
0
;
DEB
(
printk
(
"NCR53c406a: Specified irq %d
\n
"
,
irq_level
);)
DEB
(
printk
(
"NCR53c406a: Specified irq %d
\n
"
,
irq_level
);
}
)
else
}
else
for
(
i
=
0
;
i
<
INTR_COUNT
&&
irq_level
<
0
;
i
++
)
for
(
i
=
0
;
i
<
INTR_COUNT
&&
irq_level
<
0
;
i
++
)
if
(
intrs
[
i
]
==
ints
[
2
])
{
if
(
intrs
[
i
]
==
ints
[
2
])
{
irq_level
=
ints
[
2
];
irq_level
=
ints
[
2
];
DEB
(
printk
(
"NCR53c406a: Specified irq %d
\n
"
,
port_base
);)
DEB
(
printk
(
"NCR53c406a: Specified irq %d
\n
"
,
port_base
);
)
}
}
if
(
irq_level
<
0
)
if
(
irq_level
<
0
)
printk
(
"NCR53c406a: Invalid IRQ %d specified
\n
"
,
ints
[
2
]);
printk
(
"NCR53c406a: Invalid IRQ %d specified
\n
"
,
ints
[
2
]);
...
@@ -650,29 +641,34 @@ void __init NCR53c406a_setup(char *str, int *ints)
...
@@ -650,29 +641,34 @@ void __init NCR53c406a_setup(char *str, int *ints)
if
(
ints
[
0
]
>
2
)
if
(
ints
[
0
]
>
2
)
fast_pio
=
ints
[
3
];
fast_pio
=
ints
[
3
];
DEB
(
printk
(
"NCR53c406a: port_base=0x%X, irq=%d, fast_pio=%d
\n
"
,
DEB
(
printk
(
"NCR53c406a: port_base=0x%X, irq=%d, fast_pio=%d
\n
"
,
port_base
,
irq_level
,
fast_pio
);)
port_base
,
irq_level
,
fast_pio
);)
}
}
const
char
*
__setup
(
"ncr53c406a="
,
NCR53c406a_setup
);
NCR53c406a_info
(
struct
Scsi_Host
*
SChost
){
static
const
char
*
NCR53c406a_info
(
struct
Scsi_Host
*
SChost
)
{
DEB
(
printk
(
"NCR53c406a_info called
\n
"
));
DEB
(
printk
(
"NCR53c406a_info called
\n
"
));
return
(
info_msg
);
return
(
info_msg
);
}
}
static
void
internal_done
(
Scsi_Cmnd
*
SCpnt
)
{
static
void
internal_done
(
Scsi_Cmnd
*
SCpnt
)
{
internal_done_errcode
=
SCpnt
->
result
;
internal_done_errcode
=
SCpnt
->
result
;
++
internal_done_flag
;
++
internal_done_flag
;
}
}
static
void
wait_intr
(
void
)
{
static
void
wait_intr
(
void
)
{
int
i
=
jiffies
+
WATCHDOG
;
int
i
=
jiffies
+
WATCHDOG
;
while
(
time_after
(
i
,
jiffies
)
&&
!
(
inb
(
STAT_REG
)
&
0xe0
))
/* wait for a pseudo-interrupt */
while
(
time_after
(
i
,
jiffies
)
&&
!
(
inb
(
STAT_REG
)
&
0xe0
))
{
/* wait for a pseudo-interrupt */
cpu_relax
();
barrier
();
barrier
();
}
if
(
time_before_eq
(
i
,
jiffies
))
{
/* Timed out */
if
(
time_before_eq
(
i
,
jiffies
))
{
/* Timed out */
rtrc
(
0
);
rtrc
(
0
);
current_SC
->
result
=
DID_TIME_OUT
<<
16
;
current_SC
->
result
=
DID_TIME_OUT
<<
16
;
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
SCp
.
phase
=
idle
;
...
@@ -683,11 +679,13 @@ static void wait_intr(void) {
...
@@ -683,11 +679,13 @@ static void wait_intr(void) {
NCR53c406a_intr
(
0
,
NULL
,
NULL
);
NCR53c406a_intr
(
0
,
NULL
,
NULL
);
}
}
int
NCR53c406a_command
(
Scsi_Cmnd
*
SCpnt
){
static
int
NCR53c406a_command
(
Scsi_Cmnd
*
SCpnt
)
{
DEB
(
printk
(
"NCR53c406a_command called
\n
"
));
DEB
(
printk
(
"NCR53c406a_command called
\n
"
));
NCR53c406a_queue
(
SCpnt
,
internal_done
);
NCR53c406a_queue
(
SCpnt
,
internal_done
);
if
(
irq_level
)
if
(
irq_level
)
while
(
!
internal_done_flag
);
while
(
!
internal_done_flag
)
cpu_relax
();
else
/* interrupts not supported */
else
/* interrupts not supported */
while
(
!
internal_done_flag
)
while
(
!
internal_done_flag
)
wait_intr
();
wait_intr
();
...
@@ -697,21 +695,15 @@ int NCR53c406a_command(Scsi_Cmnd *SCpnt){
...
@@ -697,21 +695,15 @@ int NCR53c406a_command(Scsi_Cmnd *SCpnt){
}
}
int
static
int
NCR53c406a_queue
(
Scsi_Cmnd
*
SCpnt
,
void
(
*
done
)
(
Scsi_Cmnd
*
))
NCR53c406a_queue
(
Scsi_Cmnd
*
SCpnt
,
void
(
*
done
)(
Scsi_Cmnd
*
))
{
{
int
i
;
int
i
;
unsigned
long
flags
=
0
;
VDEB
(
printk
(
"NCR53c406a_queue called
\n
"
));
VDEB
(
printk
(
"NCR53c406a_queue called
\n
"
));
DEB
(
printk
(
"cmd=%02x, cmd_len=%02x, target=%02x, lun=%02x, bufflen=%d
\n
"
,
DEB
(
printk
(
"cmd=%02x, cmd_len=%02x, target=%02x, lun=%02x, bufflen=%d
\n
"
,
SCpnt
->
cmnd
[
0
],
SCpnt
->
cmd_len
,
SCpnt
->
target
,
SCpnt
->
lun
,
SCpnt
->
request_bufflen
));
SCpnt
->
cmnd
[
0
],
SCpnt
->
cmd_len
,
SCpnt
->
target
,
SCpnt
->
lun
,
SCpnt
->
request_bufflen
));
#if 0
#if 0
VDEB(for(i=0; i<
SCpnt->cmd_len; i++)
VDEB(for (i = 0; i <
SCpnt->cmd_len; i++)
printk("cmd[%d]=%02x ", i, SCpnt->cmnd[i]));
printk("cmd[%d]=%02x ", i, SCpnt->cmnd[i]));
VDEB(printk("\n"));
VDEB(printk("\n"));
#endif
#endif
...
@@ -722,30 +714,28 @@ NCR53c406a_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)){
...
@@ -722,30 +714,28 @@ NCR53c406a_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)){
current_SC
->
SCp
.
Status
=
0
;
current_SC
->
SCp
.
Status
=
0
;
current_SC
->
SCp
.
Message
=
0
;
current_SC
->
SCp
.
Message
=
0
;
save_flags
(
flags
);
/* We are locked here already by the mid layer */
cli
();
REG0
;
REG0
;
outb
(
SCpnt
->
target
,
DEST_ID
);
/* set destination */
outb
(
SCpnt
->
target
,
DEST_ID
);
/* set destination */
outb
(
FLUSH_FIFO
,
CMD_REG
);
/* reset the fifos */
outb
(
FLUSH_FIFO
,
CMD_REG
);
/* reset the fifos */
for
(
i
=
0
;
i
<
SCpnt
->
cmd_len
;
i
++
)
{
for
(
i
=
0
;
i
<
SCpnt
->
cmd_len
;
i
++
)
{
outb
(
SCpnt
->
cmnd
[
i
],
SCSI_FIFO
);
outb
(
SCpnt
->
cmnd
[
i
],
SCSI_FIFO
);
}
}
outb
(
SELECT_NO_ATN
,
CMD_REG
);
outb
(
SELECT_NO_ATN
,
CMD_REG
);
restore_flags
(
flags
);
rtrc
(
1
);
rtrc
(
1
);
return
0
;
return
0
;
}
}
int
static
int
NCR53c406a_abort
(
Scsi_Cmnd
*
SCpnt
)
NCR53c406a_abort
(
Scsi_Cmnd
*
SCpnt
)
{
{
DEB
(
printk
(
"NCR53c406a_abort called
\n
"
));
DEB
(
printk
(
"NCR53c406a_abort called
\n
"
));
return
SCSI_ABORT_SNOOZE
;
/* Don't know how to abort */
return
FAILED
;
/* Don't know how to abort */
}
}
int
static
int
NCR53c406a_host_reset
(
Scsi_Cmnd
*
SCpnt
)
NCR53c406a_reset
(
Scsi_Cmnd
*
SCpnt
,
unsigned
int
ignored
)
{
{
DEB
(
printk
(
"NCR53c406a_reset called
\n
"
));
DEB
(
printk
(
"NCR53c406a_reset called
\n
"
));
outb
(
C4_IMG
,
CONFIG4
);
/* Select reg set 0 */
outb
(
C4_IMG
,
CONFIG4
);
/* Select reg set 0 */
outb
(
CHIP_RESET
,
CMD_REG
);
outb
(
CHIP_RESET
,
CMD_REG
);
...
@@ -754,14 +744,21 @@ NCR53c406a_reset(Scsi_Cmnd *SCpnt, unsigned int ignored){
...
@@ -754,14 +744,21 @@ NCR53c406a_reset(Scsi_Cmnd *SCpnt, unsigned int ignored){
chip_init
();
chip_init
();
rtrc
(
2
);
rtrc
(
2
);
if
(
irq_level
)
return
SUCCESS
;
return
SCSI_RESET_PENDING
;
/* should get an interrupt */
else
return
SCSI_RESET_WAKEUP
;
/* won't get any interrupts */
}
}
int
static
int
NCR53c406a_device_reset
(
Scsi_Cmnd
*
SCpnt
)
NCR53c406a_biosparm
(
Scsi_Disk
*
disk
,
struct
block_device
*
dev
,
int
*
info_array
){
{
return
FAILED
;
}
static
int
NCR53c406a_bus_reset
(
Scsi_Cmnd
*
SCpnt
)
{
return
FAILED
;
}
static
int
NCR53c406a_biosparm
(
Scsi_Disk
*
disk
,
struct
block_device
*
dev
,
int
*
info_array
)
{
int
size
;
int
size
;
DEB
(
printk
(
"NCR53c406a_biosparm called
\n
"
));
DEB
(
printk
(
"NCR53c406a_biosparm called
\n
"
));
...
@@ -769,31 +766,32 @@ NCR53c406a_biosparm(Scsi_Disk *disk, struct block_device *dev, int* info_array){
...
@@ -769,31 +766,32 @@ NCR53c406a_biosparm(Scsi_Disk *disk, struct block_device *dev, int* info_array){
size
=
disk
->
capacity
;
size
=
disk
->
capacity
;
info_array
[
0
]
=
64
;
/* heads */
info_array
[
0
]
=
64
;
/* heads */
info_array
[
1
]
=
32
;
/* sectors */
info_array
[
1
]
=
32
;
/* sectors */
info_array
[
2
]
=
size
>>
11
;
/* cylinders */
info_array
[
2
]
=
size
>>
11
;
/* cylinders */
if
(
info_array
[
2
]
>
1024
)
{
/* big disk */
if
(
info_array
[
2
]
>
1024
)
{
/* big disk */
info_array
[
0
]
=
255
;
info_array
[
0
]
=
255
;
info_array
[
1
]
=
63
;
info_array
[
1
]
=
63
;
info_array
[
2
]
=
size
/
(
255
*
63
);
info_array
[
2
]
=
size
/
(
255
*
63
);
}
}
return
0
;
return
0
;
}
}
static
void
static
void
do_NCR53c406a_intr
(
int
unused
,
void
*
dev_id
,
struct
pt_regs
*
regs
)
do_NCR53c406a_intr
(
int
unused
,
void
*
dev_id
,
struct
pt_regs
*
regs
)
{
{
unsigned
long
flags
;
unsigned
long
flags
;
struct
Scsi_Host
*
dev
=
dev_id
;
struct
Scsi_Host
*
dev
=
dev_id
;
spin_lock_irqsave
(
dev
->
host_lock
,
flags
);
spin_lock_irqsave
(
dev
->
host_lock
,
flags
);
NCR53c406a_intr
(
0
,
dev_id
,
regs
);
NCR53c406a_intr
(
0
,
dev_id
,
regs
);
spin_unlock_irqrestore
(
dev
->
host_lock
,
flags
);
spin_unlock_irqrestore
(
dev
->
host_lock
,
flags
);
}
}
static
void
static
void
NCR53c406a_intr
(
int
unused
,
void
*
dev_id
,
struct
pt_regs
*
regs
)
NCR53c406a_intr
(
int
unused
,
void
*
dev_id
,
struct
pt_regs
*
regs
){
{
DEB
(
unsigned
char
fifo_size
;)
DEB
(
unsigned
char
fifo_size
;
DEB
(
unsigned
char
seq_reg
;)
)
DEB
(
unsigned
char
seq_reg
;
)
unsigned
char
status
,
int_reg
;
unsigned
char
status
,
int_reg
;
unsigned
long
flags
=
0
;
#if USE_PIO
#if USE_PIO
unsigned
char
pio_status
;
unsigned
char
pio_status
;
struct
scatterlist
*
sglist
;
struct
scatterlist
*
sglist
;
...
@@ -802,8 +800,6 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
...
@@ -802,8 +800,6 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
VDEB
(
printk
(
"NCR53c406a_intr called
\n
"
));
VDEB
(
printk
(
"NCR53c406a_intr called
\n
"
));
save_flags
(
flags
);
cli
();
#if USE_PIO
#if USE_PIO
REG1
;
REG1
;
pio_status
=
inb
(
PIO_STATUS
);
pio_status
=
inb
(
PIO_STATUS
);
...
@@ -813,11 +809,9 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
...
@@ -813,11 +809,9 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
DEB
(
seq_reg
=
inb
(
SEQ_REG
));
DEB
(
seq_reg
=
inb
(
SEQ_REG
));
int_reg
=
inb
(
INT_REG
);
int_reg
=
inb
(
INT_REG
);
DEB
(
fifo_size
=
inb
(
FIFO_FLAGS
)
&
0x1f
);
DEB
(
fifo_size
=
inb
(
FIFO_FLAGS
)
&
0x1f
);
restore_flags
(
flags
);
#if NCR53C406A_DEBUG
#if NCR53C406A_DEBUG
printk
(
"status=%02x, seq_reg=%02x, int_reg=%02x, fifo_size=%02x"
,
printk
(
"status=%02x, seq_reg=%02x, int_reg=%02x, fifo_size=%02x"
,
status
,
seq_reg
,
int_reg
,
fifo_size
);
status
,
seq_reg
,
int_reg
,
fifo_size
);
#if (USE_DMA)
#if (USE_DMA)
printk
(
"
\n
"
);
printk
(
"
\n
"
);
#else
#else
...
@@ -825,7 +819,7 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
...
@@ -825,7 +819,7 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
#endif
/* USE_DMA */
#endif
/* USE_DMA */
#endif
/* NCR53C406A_DEBUG */
#endif
/* NCR53C406A_DEBUG */
if
(
int_reg
&
0x80
){
/* SCSI reset intr */
if
(
int_reg
&
0x80
)
{
/* SCSI reset intr */
rtrc
(
3
);
rtrc
(
3
);
DEB
(
printk
(
"NCR53c406a: reset intr received
\n
"
));
DEB
(
printk
(
"NCR53c406a: reset intr received
\n
"
));
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
SCp
.
phase
=
idle
;
...
@@ -833,9 +827,8 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
...
@@ -833,9 +827,8 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
current_SC
->
scsi_done
(
current_SC
);
current_SC
->
scsi_done
(
current_SC
);
return
;
return
;
}
}
#if USE_PIO
#if USE_PIO
if
(
pio_status
&
0x80
)
{
if
(
pio_status
&
0x80
)
{
printk
(
"NCR53C406A: Warning: PIO error!
\n
"
);
printk
(
"NCR53C406A: Warning: PIO error!
\n
"
);
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
result
=
DID_ERROR
<<
16
;
current_SC
->
result
=
DID_ERROR
<<
16
;
...
@@ -844,7 +837,7 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
...
@@ -844,7 +837,7 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
}
}
#endif
/* USE_PIO */
#endif
/* USE_PIO */
if
(
status
&
0x20
)
{
/* Parity error */
if
(
status
&
0x20
)
{
/* Parity error */
printk
(
"NCR53c406a: Warning: parity error!
\n
"
);
printk
(
"NCR53c406a: Warning: parity error!
\n
"
);
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
result
=
DID_PARITY
<<
16
;
current_SC
->
result
=
DID_PARITY
<<
16
;
...
@@ -852,7 +845,7 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
...
@@ -852,7 +845,7 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
return
;
return
;
}
}
if
(
status
&
0x40
)
{
/* Gross error */
if
(
status
&
0x40
)
{
/* Gross error */
printk
(
"NCR53c406a: Warning: gross error!
\n
"
);
printk
(
"NCR53c406a: Warning: gross error!
\n
"
);
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
result
=
DID_ERROR
<<
16
;
current_SC
->
result
=
DID_ERROR
<<
16
;
...
@@ -860,43 +853,40 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
...
@@ -860,43 +853,40 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
return
;
return
;
}
}
if
(
int_reg
&
0x20
){
/* Disconnect */
if
(
int_reg
&
0x20
)
{
/* Disconnect */
DEB
(
printk
(
"NCR53c406a: disconnect intr received
\n
"
));
DEB
(
printk
(
"NCR53c406a: disconnect intr received
\n
"
));
if
(
current_SC
->
SCp
.
phase
!=
message_in
){
/* Unexpected disconnect */
if
(
current_SC
->
SCp
.
phase
!=
message_in
)
{
/* Unexpected disconnect */
current_SC
->
result
=
DID_NO_CONNECT
<<
16
;
current_SC
->
result
=
DID_NO_CONNECT
<<
16
;
}
}
else
{
/* Command complete, return status and message */
else
{
/* Command complete, return status and message */
current_SC
->
result
=
(
current_SC
->
SCp
.
Status
&
0xff
)
current_SC
->
result
=
(
current_SC
->
SCp
.
Status
&
0xff
)
|
((
current_SC
->
SCp
.
Message
&
0xff
)
<<
8
)
|
(
DID_OK
<<
16
);
|
((
current_SC
->
SCp
.
Message
&
0xff
)
<<
8
)
|
(
DID_OK
<<
16
);
}
}
rtrc
(
0
);
rtrc
(
0
);
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
SCp
.
phase
=
idle
;
current_SC
->
scsi_done
(
current_SC
);
current_SC
->
scsi_done
(
current_SC
);
return
;
return
;
}
}
switch
(
status
&
0x07
)
{
/* scsi phase */
switch
(
status
&
0x07
)
{
/* scsi phase */
case
0x00
:
/* DATA-OUT */
case
0x00
:
/* DATA-OUT */
if
(
int_reg
&
0x10
){
/* Target requesting info transfer */
if
(
int_reg
&
0x10
)
{
/* Target requesting info transfer */
rtrc
(
5
);
rtrc
(
5
);
current_SC
->
SCp
.
phase
=
data_out
;
current_SC
->
SCp
.
phase
=
data_out
;
VDEB
(
printk
(
"NCR53c406a: Data-Out phase
\n
"
));
VDEB
(
printk
(
"NCR53c406a: Data-Out phase
\n
"
));
outb
(
FLUSH_FIFO
,
CMD_REG
);
outb
(
FLUSH_FIFO
,
CMD_REG
);
LOAD_DMA_COUNT
(
current_SC
->
request_bufflen
);
/* Max transfer size */
LOAD_DMA_COUNT
(
current_SC
->
request_bufflen
);
/* Max transfer size */
#if USE_DMA
/* No s/g support for DMA */
#if USE_DMA
/* No s/g support for DMA */
NCR53c406a_dma_write
(
current_SC
->
request_buffer
,
NCR53c406a_dma_write
(
current_SC
->
request_buffer
,
current_SC
->
request_bufflen
);
current_SC
->
request_bufflen
);
#endif
/* USE_DMA */
#endif
/* USE_DMA */
outb
(
TRANSFER_INFO
|
DMA_OP
,
CMD_REG
);
outb
(
TRANSFER_INFO
|
DMA_OP
,
CMD_REG
);
#if USE_PIO
#if USE_PIO
if
(
!
current_SC
->
use_sg
)
/* Don't use scatter-gather */
if
(
!
current_SC
->
use_sg
)
/* Don't use scatter-gather */
NCR53c406a_pio_write
(
current_SC
->
request_buffer
,
NCR53c406a_pio_write
(
current_SC
->
request_buffer
,
current_SC
->
request_bufflen
);
current_SC
->
request_bufflen
);
else
{
/* use scatter-gather */
else
{
/* use scatter-gather */
sgcount
=
current_SC
->
use_sg
;
sgcount
=
current_SC
->
use_sg
;
sglist
=
current_SC
->
request_buffer
;
sglist
=
current_SC
->
request_buffer
;
while
(
sgcount
--
)
{
while
(
sgcount
--
)
{
NCR53c406a_pio_write
(
page_address
(
sglist
->
page
)
+
sglist
->
offset
,
sglist
->
length
);
NCR53c406a_pio_write
(
page_address
(
sglist
->
page
)
+
sglist
->
offset
,
sglist
->
length
);
sglist
++
;
sglist
++
;
}
}
...
@@ -907,25 +897,23 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
...
@@ -907,25 +897,23 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
break
;
break
;
case
0x01
:
/* DATA-IN */
case
0x01
:
/* DATA-IN */
if
(
int_reg
&
0x10
){
/* Target requesting info transfer */
if
(
int_reg
&
0x10
)
{
/* Target requesting info transfer */
rtrc
(
6
);
rtrc
(
6
);
current_SC
->
SCp
.
phase
=
data_in
;
current_SC
->
SCp
.
phase
=
data_in
;
VDEB
(
printk
(
"NCR53c406a: Data-In phase
\n
"
));
VDEB
(
printk
(
"NCR53c406a: Data-In phase
\n
"
));
outb
(
FLUSH_FIFO
,
CMD_REG
);
outb
(
FLUSH_FIFO
,
CMD_REG
);
LOAD_DMA_COUNT
(
current_SC
->
request_bufflen
);
/* Max transfer size */
LOAD_DMA_COUNT
(
current_SC
->
request_bufflen
);
/* Max transfer size */
#if USE_DMA
/* No s/g support for DMA */
#if USE_DMA
/* No s/g support for DMA */
NCR53c406a_dma_read
(
current_SC
->
request_buffer
,
NCR53c406a_dma_read
(
current_SC
->
request_buffer
,
current_SC
->
request_bufflen
);
current_SC
->
request_bufflen
);
#endif
/* USE_DMA */
#endif
/* USE_DMA */
outb
(
TRANSFER_INFO
|
DMA_OP
,
CMD_REG
);
outb
(
TRANSFER_INFO
|
DMA_OP
,
CMD_REG
);
#if USE_PIO
#if USE_PIO
if
(
!
current_SC
->
use_sg
)
/* Don't use scatter-gather */
if
(
!
current_SC
->
use_sg
)
/* Don't use scatter-gather */
NCR53c406a_pio_read
(
current_SC
->
request_buffer
,
NCR53c406a_pio_read
(
current_SC
->
request_buffer
,
current_SC
->
request_bufflen
);
current_SC
->
request_bufflen
);
else
{
/* Use scatter-gather */
else
{
/* Use scatter-gather */
sgcount
=
current_SC
->
use_sg
;
sgcount
=
current_SC
->
use_sg
;
sglist
=
current_SC
->
request_buffer
;
sglist
=
current_SC
->
request_buffer
;
while
(
sgcount
--
)
{
while
(
sgcount
--
)
{
NCR53c406a_pio_read
(
page_address
(
sglist
->
page
)
+
sglist
->
offset
,
sglist
->
length
);
NCR53c406a_pio_read
(
page_address
(
sglist
->
page
)
+
sglist
->
offset
,
sglist
->
length
);
sglist
++
;
sglist
++
;
}
}
...
@@ -969,11 +957,9 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
...
@@ -969,11 +957,9 @@ NCR53c406a_intr(int unused, void *dev_id, struct pt_regs *regs){
current_SC
->
SCp
.
Message
=
inb
(
SCSI_FIFO
);
current_SC
->
SCp
.
Message
=
inb
(
SCSI_FIFO
);
VDEB
(
printk
(
"SCSI FIFO size=%d
\n
"
,
inb
(
FIFO_FLAGS
)
&
0x1f
));
VDEB
(
printk
(
"SCSI FIFO size=%d
\n
"
,
inb
(
FIFO_FLAGS
)
&
0x1f
));
DEB
(
printk
(
"Status = %02x Message = %02x
\n
"
,
DEB
(
printk
(
"Status = %02x Message = %02x
\n
"
,
current_SC
->
SCp
.
Status
,
current_SC
->
SCp
.
Message
));
current_SC
->
SCp
.
Status
,
current_SC
->
SCp
.
Message
));
if
(
current_SC
->
SCp
.
Message
==
SAVE_POINTERS
||
if
(
current_SC
->
SCp
.
Message
==
SAVE_POINTERS
||
current_SC
->
SCp
.
Message
==
DISCONNECT
)
{
current_SC
->
SCp
.
Message
==
DISCONNECT
)
{
outb
(
SET_ATN
,
CMD_REG
);
/* Reject message */
outb
(
SET_ATN
,
CMD_REG
);
/* Reject message */
DEB
(
printk
(
"Discarding SAVE_POINTERS message
\n
"
));
DEB
(
printk
(
"Discarding SAVE_POINTERS message
\n
"
));
}
}
...
@@ -997,7 +983,7 @@ static int irq_probe(void)
...
@@ -997,7 +983,7 @@ static int irq_probe(void)
/* Wait for the interrupt to occur */
/* Wait for the interrupt to occur */
i
=
jiffies
+
WATCHDOG
;
i
=
jiffies
+
WATCHDOG
;
while
(
time_after
(
i
,
jiffies
)
&&
!
(
inb
(
STAT_REG
)
&
0x80
))
while
(
time_after
(
i
,
jiffies
)
&&
!
(
inb
(
STAT_REG
)
&
0x80
))
barrier
();
barrier
();
if
(
time_before_eq
(
i
,
jiffies
))
{
/* Timed out, must be hardware trouble */
if
(
time_before_eq
(
i
,
jiffies
))
{
/* Timed out, must be hardware trouble */
probe_irq_off
(
irqs
);
probe_irq_off
(
irqs
);
...
@@ -1036,46 +1022,47 @@ static void chip_init(void)
...
@@ -1036,46 +1022,47 @@ static void chip_init(void)
outb
(
SYNC_MODE
,
SYNCOFF
);
/* synchronous mode */
outb
(
SYNC_MODE
,
SYNCOFF
);
/* synchronous mode */
}
}
void
__init
calc_port_addr
(
void
)
static
void
__init
calc_port_addr
(
void
)
{
{
/* Control Register Set 0 */
/* Control Register Set 0 */
TC_LSB
=
(
port_base
+
0x00
);
TC_LSB
=
(
port_base
+
0x00
);
TC_MSB
=
(
port_base
+
0x01
);
TC_MSB
=
(
port_base
+
0x01
);
SCSI_FIFO
=
(
port_base
+
0x02
);
SCSI_FIFO
=
(
port_base
+
0x02
);
CMD_REG
=
(
port_base
+
0x03
);
CMD_REG
=
(
port_base
+
0x03
);
STAT_REG
=
(
port_base
+
0x04
);
STAT_REG
=
(
port_base
+
0x04
);
DEST_ID
=
(
port_base
+
0x04
);
DEST_ID
=
(
port_base
+
0x04
);
INT_REG
=
(
port_base
+
0x05
);
INT_REG
=
(
port_base
+
0x05
);
SRTIMOUT
=
(
port_base
+
0x05
);
SRTIMOUT
=
(
port_base
+
0x05
);
SEQ_REG
=
(
port_base
+
0x06
);
SEQ_REG
=
(
port_base
+
0x06
);
SYNCPRD
=
(
port_base
+
0x06
);
SYNCPRD
=
(
port_base
+
0x06
);
FIFO_FLAGS
=
(
port_base
+
0x07
);
FIFO_FLAGS
=
(
port_base
+
0x07
);
SYNCOFF
=
(
port_base
+
0x07
);
SYNCOFF
=
(
port_base
+
0x07
);
CONFIG1
=
(
port_base
+
0x08
);
CONFIG1
=
(
port_base
+
0x08
);
CLKCONV
=
(
port_base
+
0x09
);
CLKCONV
=
(
port_base
+
0x09
);
/* TESTREG = (port_base+0x0A); */
/* TESTREG = (port_base+0x0A); */
CONFIG2
=
(
port_base
+
0x0B
);
CONFIG2
=
(
port_base
+
0x0B
);
CONFIG3
=
(
port_base
+
0x0C
);
CONFIG3
=
(
port_base
+
0x0C
);
CONFIG4
=
(
port_base
+
0x0D
);
CONFIG4
=
(
port_base
+
0x0D
);
TC_HIGH
=
(
port_base
+
0x0E
);
TC_HIGH
=
(
port_base
+
0x0E
);
/* FIFO_BOTTOM = (port_base+0x0F); */
/* FIFO_BOTTOM = (port_base+0x0F); */
/* Control Register Set 1 */
/* Control Register Set 1 */
/* JUMPER_SENSE = (port_base+0x00);
*/
/* JUMPER_SENSE = (port_base+0x00);
*/
/* SRAM_PTR = (port_base+0x01);
*/
/* SRAM_PTR = (port_base+0x01);
*/
/* SRAM_DATA = (port_base+0x02);
*/
/* SRAM_DATA = (port_base+0x02);
*/
PIO_FIFO
=
(
port_base
+
0x04
);
PIO_FIFO
=
(
port_base
+
0x04
);
/* PIO_FIFO1 = (port_base+0x05);
*/
/* PIO_FIFO1 = (port_base+0x05);
*/
/* PIO_FIFO2 = (port_base+0x06);
*/
/* PIO_FIFO2 = (port_base+0x06);
*/
/* PIO_FIFO3 = (port_base+0x07);
*/
/* PIO_FIFO3 = (port_base+0x07);
*/
PIO_STATUS
=
(
port_base
+
0x08
);
PIO_STATUS
=
(
port_base
+
0x08
);
/* ATA_CMD = (port_base+0x09);
*/
/* ATA_CMD = (port_base+0x09);
*/
/* ATA_ERR = (port_base+0x0A);
*/
/* ATA_ERR = (port_base+0x0A);
*/
PIO_FLAG
=
(
port_base
+
0x0B
);
PIO_FLAG
=
(
port_base
+
0x0B
);
CONFIG5
=
(
port_base
+
0x0D
);
CONFIG5
=
(
port_base
+
0x0D
);
/* SIGNATURE = (port_base+0x0E);
*/
/* SIGNATURE = (port_base+0x0E);
*/
/* CONFIG6 = (port_base+0x0F);
*/
/* CONFIG6 = (port_base+0x0F);
*/
}
}
MODULE_LICENSE
(
"GPL"
);
MODULE_LICENSE
(
"GPL"
);
/* Eventually this will go into an include file, but this will be later */
/* Eventually this will go into an include file, but this will be later */
...
...
drivers/scsi/NCR53c406a.h
View file @
c7a4e6c2
...
@@ -32,8 +32,10 @@
...
@@ -32,8 +32,10 @@
info: NCR53c406a_info
/* info */
, \
info: NCR53c406a_info
/* info */
, \
command: NCR53c406a_command
/* command */
, \
command: NCR53c406a_command
/* command */
, \
queuecommand: NCR53c406a_queue
/* queuecommand */
, \
queuecommand: NCR53c406a_queue
/* queuecommand */
, \
abort: NCR53c406a_abort
/* abort */
, \
eh_abort_handler: NCR53c406a_abort
/* abort */
, \
reset: NCR53c406a_reset
/* reset */
, \
eh_bus_reset_handler: NCR53c406a_bus_reset
/* reset */
, \
eh_device_reset_handler: NCR53c406a_device_reset
/* reset */
, \
eh_host_reset_handler: NCR53c406a_host_reset
/* reset */
, \
bios_param: NCR53c406a_biosparm
/* biosparm */
, \
bios_param: NCR53c406a_biosparm
/* biosparm */
, \
can_queue: 1
/* can_queue */
, \
can_queue: 1
/* can_queue */
, \
this_id: 7
/* SCSI ID of the chip */
, \
this_id: 7
/* SCSI ID of the chip */
, \
...
@@ -43,33 +45,15 @@
...
@@ -43,33 +45,15 @@
use_clustering: ENABLE_CLUSTERING \
use_clustering: ENABLE_CLUSTERING \
}
}
int
NCR53c406a_detect
(
Scsi_Host_Template
*
);
static
int
NCR53c406a_detect
(
Scsi_Host_Template
*
);
const
char
*
NCR53c406a_info
(
struct
Scsi_Host
*
);
static
const
char
*
NCR53c406a_info
(
struct
Scsi_Host
*
);
int
NCR53c406a_command
(
Scsi_Cmnd
*
);
static
int
NCR53c406a_command
(
Scsi_Cmnd
*
);
int
NCR53c406a_queue
(
Scsi_Cmnd
*
,
void
(
*
done
)(
Scsi_Cmnd
*
));
static
int
NCR53c406a_queue
(
Scsi_Cmnd
*
,
void
(
*
done
)
(
Scsi_Cmnd
*
));
int
NCR53c406a_abort
(
Scsi_Cmnd
*
);
static
int
NCR53c406a_abort
(
Scsi_Cmnd
*
);
int
NCR53c406a_reset
(
Scsi_Cmnd
*
,
unsigned
int
);
static
int
NCR53c406a_bus_reset
(
Scsi_Cmnd
*
);
int
NCR53c406a_biosparm
(
Disk
*
,
struct
block_device
*
,
int
[]);
static
int
NCR53c406a_device_reset
(
Scsi_Cmnd
*
);
static
int
NCR53c406a_host_reset
(
Scsi_Cmnd
*
);
static
int
NCR53c406a_biosparm
(
Disk
*
,
struct
block_device
*
,
int
[]);
#endif
/* _NCR53C406A_H */
#endif
/* _NCR53C406A_H */
/*
* Overrides for Emacs so that we get a uniform tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-indent-level: 4
* c-brace-imaginary-offset: 0
* c-brace-offset: -4
* c-argdecl-indent: 4
* c-label-offset: -4
* c-continued-statement-offset: 4
* c-continued-brace-offset: 0
* indent-tabs-mode: nil
* tab-width: 8
* End:
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment