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
327f7fd0
Commit
327f7fd0
authored
Feb 13, 2005
by
Jeff Garzik
Browse files
Options
Browse Files
Download
Plain Diff
Merge pobox.com:/garz/repo/libata-dev/via-6421
into pobox.com:/garz/repo/libata-2.6
parents
735a58f4
c5a0b8f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
148 additions
and
54 deletions
+148
-54
drivers/scsi/sata_via.c
drivers/scsi/sata_via.c
+148
-54
No files found.
drivers/scsi/sata_via.c
View file @
327f7fd0
...
...
@@ -24,6 +24,11 @@
If you do not delete the provisions above, a recipient may use your
version of this file under either the OSL or the GPL.
----------------------------------------------------------------------
To-do list:
* VT6421 PATA support
*/
#include <linux/kernel.h>
...
...
@@ -38,11 +43,14 @@
#include <asm/io.h>
#define DRV_NAME "sata_via"
#define DRV_VERSION "1.
0
"
#define DRV_VERSION "1.
1
"
enum
{
via_sata
=
0
,
enum
board_ids_enum
{
vt6420
,
vt6421
,
};
enum
{
SATA_CHAN_ENAB
=
0x40
,
/* SATA channel enable */
SATA_INT_GATE
=
0x41
,
/* SATA interrupt gating */
SATA_NATIVE_MODE
=
0x42
,
/* Native mode enable */
...
...
@@ -50,10 +58,8 @@ enum {
PORT0
=
(
1
<<
1
),
PORT1
=
(
1
<<
0
),
ENAB_ALL
=
PORT0
|
PORT1
,
INT_GATE_ALL
=
PORT0
|
PORT1
,
ALL_PORTS
=
PORT0
|
PORT1
,
N_PORTS
=
2
,
NATIVE_MODE_ALL
=
(
1
<<
7
)
|
(
1
<<
6
)
|
(
1
<<
5
)
|
(
1
<<
4
),
...
...
@@ -66,7 +72,8 @@ static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg);
static
void
svia_scr_write
(
struct
ata_port
*
ap
,
unsigned
int
sc_reg
,
u32
val
);
static
struct
pci_device_id
svia_pci_tbl
[]
=
{
{
0x1106
,
0x3149
,
PCI_ANY_ID
,
PCI_ANY_ID
,
0
,
0
,
via_sata
},
{
0x1106
,
0x3149
,
PCI_ANY_ID
,
PCI_ANY_ID
,
0
,
0
,
vt6420
},
{
0x1106
,
0x3249
,
PCI_ANY_ID
,
PCI_ANY_ID
,
0
,
0
,
vt6421
},
{
}
/* terminate list */
};
...
...
@@ -158,18 +165,131 @@ static const unsigned int svia_bar_sizes[] = {
8
,
4
,
8
,
4
,
16
,
256
};
static
const
unsigned
int
vt6421_bar_sizes
[]
=
{
16
,
16
,
16
,
16
,
32
,
128
};
static
unsigned
long
svia_scr_addr
(
unsigned
long
addr
,
unsigned
int
port
)
{
return
addr
+
(
port
*
128
);
}
static
unsigned
long
vt6421_scr_addr
(
unsigned
long
addr
,
unsigned
int
port
)
{
return
addr
+
(
port
*
64
);
}
static
void
vt6421_init_addrs
(
struct
ata_probe_ent
*
probe_ent
,
struct
pci_dev
*
pdev
,
unsigned
int
port
)
{
unsigned
long
reg_addr
=
pci_resource_start
(
pdev
,
port
);
unsigned
long
bmdma_addr
=
pci_resource_start
(
pdev
,
4
)
+
(
port
*
8
);
unsigned
long
scr_addr
;
probe_ent
->
port
[
port
].
cmd_addr
=
reg_addr
;
probe_ent
->
port
[
port
].
altstatus_addr
=
probe_ent
->
port
[
port
].
ctl_addr
=
(
reg_addr
+
8
)
|
ATA_PCI_CTL_OFS
;
probe_ent
->
port
[
port
].
bmdma_addr
=
bmdma_addr
;
scr_addr
=
vt6421_scr_addr
(
pci_resource_start
(
pdev
,
5
),
port
);
probe_ent
->
port
[
port
].
scr_addr
=
scr_addr
;
ata_std_ports
(
&
probe_ent
->
port
[
port
]);
}
static
struct
ata_probe_ent
*
vt6420_init_probe_ent
(
struct
pci_dev
*
pdev
)
{
struct
ata_probe_ent
*
probe_ent
;
struct
ata_port_info
*
ppi
=
&
svia_port_info
;
probe_ent
=
ata_pci_init_native_mode
(
pdev
,
&
ppi
);
if
(
!
probe_ent
)
return
NULL
;
probe_ent
->
port
[
0
].
scr_addr
=
svia_scr_addr
(
pci_resource_start
(
pdev
,
5
),
0
);
probe_ent
->
port
[
1
].
scr_addr
=
svia_scr_addr
(
pci_resource_start
(
pdev
,
5
),
1
);
return
probe_ent
;
}
static
struct
ata_probe_ent
*
vt6421_init_probe_ent
(
struct
pci_dev
*
pdev
)
{
struct
ata_probe_ent
*
probe_ent
;
unsigned
int
i
;
probe_ent
=
kmalloc
(
sizeof
(
*
probe_ent
),
GFP_KERNEL
);
if
(
!
probe_ent
)
return
NULL
;
memset
(
probe_ent
,
0
,
sizeof
(
*
probe_ent
));
probe_ent
->
dev
=
pci_dev_to_dev
(
pdev
);
INIT_LIST_HEAD
(
&
probe_ent
->
node
);
probe_ent
->
sht
=
&
svia_sht
;
probe_ent
->
host_flags
=
ATA_FLAG_SATA
|
ATA_FLAG_SATA_RESET
|
ATA_FLAG_NO_LEGACY
;
probe_ent
->
port_ops
=
&
svia_sata_ops
;
probe_ent
->
n_ports
=
N_PORTS
;
probe_ent
->
irq
=
pdev
->
irq
;
probe_ent
->
irq_flags
=
SA_SHIRQ
;
probe_ent
->
pio_mask
=
0x1f
;
probe_ent
->
mwdma_mask
=
0x07
;
probe_ent
->
udma_mask
=
0x7f
;
for
(
i
=
0
;
i
<
N_PORTS
;
i
++
)
vt6421_init_addrs
(
probe_ent
,
pdev
,
i
);
return
probe_ent
;
}
static
void
svia_configure
(
struct
pci_dev
*
pdev
)
{
u8
tmp8
;
pci_read_config_byte
(
pdev
,
PCI_INTERRUPT_LINE
,
&
tmp8
);
printk
(
KERN_INFO
DRV_NAME
"(%s): routed to hard irq line %d
\n
"
,
pci_name
(
pdev
),
(
int
)
(
tmp8
&
0xf0
)
==
0xf0
?
0
:
tmp8
&
0x0f
);
/* make sure SATA channels are enabled */
pci_read_config_byte
(
pdev
,
SATA_CHAN_ENAB
,
&
tmp8
);
if
((
tmp8
&
ALL_PORTS
)
!=
ALL_PORTS
)
{
printk
(
KERN_DEBUG
DRV_NAME
"(%s): enabling SATA channels (0x%x)
\n
"
,
pci_name
(
pdev
),
(
int
)
tmp8
);
tmp8
|=
ALL_PORTS
;
pci_write_config_byte
(
pdev
,
SATA_CHAN_ENAB
,
tmp8
);
}
/* make sure interrupts for each channel sent to us */
pci_read_config_byte
(
pdev
,
SATA_INT_GATE
,
&
tmp8
);
if
((
tmp8
&
ALL_PORTS
)
!=
ALL_PORTS
)
{
printk
(
KERN_DEBUG
DRV_NAME
"(%s): enabling SATA channel interrupts (0x%x)
\n
"
,
pci_name
(
pdev
),
(
int
)
tmp8
);
tmp8
|=
ALL_PORTS
;
pci_write_config_byte
(
pdev
,
SATA_INT_GATE
,
tmp8
);
}
/* make sure native mode is enabled */
pci_read_config_byte
(
pdev
,
SATA_NATIVE_MODE
,
&
tmp8
);
if
((
tmp8
&
NATIVE_MODE_ALL
)
!=
NATIVE_MODE_ALL
)
{
printk
(
KERN_DEBUG
DRV_NAME
"(%s): enabling SATA channel native mode (0x%x)
\n
"
,
pci_name
(
pdev
),
(
int
)
tmp8
);
tmp8
|=
NATIVE_MODE_ALL
;
pci_write_config_byte
(
pdev
,
SATA_NATIVE_MODE
,
tmp8
);
}
}
static
int
svia_init_one
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
)
{
static
int
printed_version
;
unsigned
int
i
;
int
rc
;
struct
ata_port_info
*
ppi
;
struct
ata_probe_ent
*
probe_ent
;
int
board_id
=
(
int
)
ent
->
driver_data
;
const
int
*
bar_sizes
;
u8
tmp8
;
if
(
!
printed_version
++
)
...
...
@@ -183,17 +303,23 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
if
(
rc
)
goto
err_out
;
pci_read_config_byte
(
pdev
,
SATA_PATA_SHARING
,
&
tmp8
);
if
(
tmp8
&
SATA_2DEV
)
{
printk
(
KERN_ERR
DRV_NAME
"(%s): SATA master/slave not supported (0x%x)
\n
"
,
pci_name
(
pdev
),
(
int
)
tmp8
);
rc
=
-
EIO
;
goto
err_out_regions
;
if
(
board_id
==
vt6420
)
{
pci_read_config_byte
(
pdev
,
SATA_PATA_SHARING
,
&
tmp8
);
if
(
tmp8
&
SATA_2DEV
)
{
printk
(
KERN_ERR
DRV_NAME
"(%s): SATA master/slave not supported (0x%x)
\n
"
,
pci_name
(
pdev
),
(
int
)
tmp8
);
rc
=
-
EIO
;
goto
err_out_regions
;
}
bar_sizes
=
&
svia_bar_sizes
[
0
];
}
else
{
bar_sizes
=
&
vt6421_bar_sizes
[
0
];
}
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
svia_bar_sizes
);
i
++
)
if
((
pci_resource_start
(
pdev
,
i
)
==
0
)
||
(
pci_resource_len
(
pdev
,
i
)
<
svia_
bar_sizes
[
i
]))
{
(
pci_resource_len
(
pdev
,
i
)
<
bar_sizes
[
i
]))
{
printk
(
KERN_ERR
DRV_NAME
"(%s): invalid PCI BAR %u (sz 0x%lx, val 0x%lx)
\n
"
,
pci_name
(
pdev
),
i
,
pci_resource_start
(
pdev
,
i
),
...
...
@@ -209,8 +335,11 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
if
(
rc
)
goto
err_out_regions
;
ppi
=
&
svia_port_info
;
probe_ent
=
ata_pci_init_native_mode
(
pdev
,
&
ppi
);
if
(
board_id
==
vt6420
)
probe_ent
=
vt6420_init_probe_ent
(
pdev
);
else
probe_ent
=
vt6421_init_probe_ent
(
pdev
);
if
(
!
probe_ent
)
{
printk
(
KERN_ERR
DRV_NAME
"(%s): out of memory
\n
"
,
pci_name
(
pdev
));
...
...
@@ -218,42 +347,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
goto
err_out_regions
;
}
probe_ent
->
port
[
0
].
scr_addr
=
svia_scr_addr
(
pci_resource_start
(
pdev
,
5
),
0
);
probe_ent
->
port
[
1
].
scr_addr
=
svia_scr_addr
(
pci_resource_start
(
pdev
,
5
),
1
);
pci_read_config_byte
(
pdev
,
PCI_INTERRUPT_LINE
,
&
tmp8
);
printk
(
KERN_INFO
DRV_NAME
"(%s): routed to hard irq line %d
\n
"
,
pci_name
(
pdev
),
(
int
)
(
tmp8
&
0xf0
)
==
0xf0
?
0
:
tmp8
&
0x0f
);
/* make sure SATA channels are enabled */
pci_read_config_byte
(
pdev
,
SATA_CHAN_ENAB
,
&
tmp8
);
if
((
tmp8
&
ENAB_ALL
)
!=
ENAB_ALL
)
{
printk
(
KERN_DEBUG
DRV_NAME
"(%s): enabling SATA channels (0x%x)
\n
"
,
pci_name
(
pdev
),
(
int
)
tmp8
);
tmp8
|=
ENAB_ALL
;
pci_write_config_byte
(
pdev
,
SATA_CHAN_ENAB
,
tmp8
);
}
/* make sure interrupts for each channel sent to us */
pci_read_config_byte
(
pdev
,
SATA_INT_GATE
,
&
tmp8
);
if
((
tmp8
&
INT_GATE_ALL
)
!=
INT_GATE_ALL
)
{
printk
(
KERN_DEBUG
DRV_NAME
"(%s): enabling SATA channel interrupts (0x%x)
\n
"
,
pci_name
(
pdev
),
(
int
)
tmp8
);
tmp8
|=
INT_GATE_ALL
;
pci_write_config_byte
(
pdev
,
SATA_INT_GATE
,
tmp8
);
}
/* make sure native mode is enabled */
pci_read_config_byte
(
pdev
,
SATA_NATIVE_MODE
,
&
tmp8
);
if
((
tmp8
&
NATIVE_MODE_ALL
)
!=
NATIVE_MODE_ALL
)
{
printk
(
KERN_DEBUG
DRV_NAME
"(%s): enabling SATA channel native mode (0x%x)
\n
"
,
pci_name
(
pdev
),
(
int
)
tmp8
);
tmp8
|=
NATIVE_MODE_ALL
;
pci_write_config_byte
(
pdev
,
SATA_NATIVE_MODE
,
tmp8
);
}
svia_configure
(
pdev
);
pci_set_master
(
pdev
);
...
...
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