55 #include <linux/kernel.h>
56 #include <linux/module.h>
57 #include <linux/pci.h>
66 #define DRV_NAME "pata_via"
67 #define DRV_VERSION "0.3.4"
88 static const struct via_isa_bridge {
95 } via_isa_bridges[] = {
127 static const struct dmi_system_id no_atapi_dma_dmi_table[] = {
129 .ident =
"AVERATEC 3200",
148 .ident =
"Acer Ferrari 3400",
157 static int via_cable_override(
struct pci_dev *pdev)
181 static int via_cable_detect(
struct ata_port *ap) {
182 const struct via_isa_bridge *
config = ap->
host->private_data;
186 if (via_cable_override(pdev))
199 pci_read_config_dword(pdev, 0x50, &ata66);
202 if (ata66 & (0x10100000 >> (16 * ap->
port_no)))
205 if (ata_acpi_init_gtm(ap) &&
211 static int via_pre_reset(
struct ata_link *
link,
unsigned long deadline)
214 const struct via_isa_bridge *config = ap->
host->private_data;
217 static const struct pci_bits via_enable_bits[] = {
218 { 0x40, 1, 0x02, 0x02 },
219 { 0x40, 1, 0x01, 0x01 }
222 if (!pci_test_config_bits(pdev, &via_enable_bits[ap->
port_no]))
246 int mode,
int set_ast,
int udma_type)
252 unsigned long T = 1000000000 / via_clock;
253 unsigned long UT =
T;
282 pci_read_config_byte(pdev, 0x4C, &setup);
283 setup &= ~(3 << shift);
284 setup |= (
clamp_val(
t.setup, 1, 4) - 1) << shift;
285 pci_write_config_byte(pdev, 0x4C, setup);
289 pci_write_config_byte(pdev, 0x4F - ap->
port_no,
291 pci_write_config_byte(pdev, 0x48 + offset,
298 ut =
t.udma ? (0xe0 | (
clamp_val(
t.udma, 2, 5) - 2)) : 0x03;
301 ut =
t.udma ? (0xe8 | (
clamp_val(
t.udma, 2, 9) - 2)) : 0x0f;
304 ut =
t.udma ? (0xe0 | (
clamp_val(
t.udma, 2, 9) - 2)) : 0x07;
307 ut =
t.udma ? (0xe0 | (
clamp_val(
t.udma, 2, 9) - 2)) : 0x07;
315 pci_read_config_byte(pdev, 0x50 + offset, &udma_etc);
326 pci_write_config_byte(pdev, 0x50 + offset, udma_etc);
332 const struct via_isa_bridge *config = ap->
host->private_data;
333 int set_ast = (config->flags &
VIA_BAD_AST) ? 0 : 1;
335 via_do_set_mode(ap, adev, adev->
pio_mode, set_ast, config->udma_mask);
340 const struct via_isa_bridge *config = ap->
host->private_data;
341 int set_ast = (config->flags &
VIA_BAD_AST) ? 0 : 1;
343 via_do_set_mode(ap, adev, adev->
dma_mode, set_ast, config->udma_mask);
358 const struct via_isa_bridge *config = host->
private_data;
363 if (
strcmp(model_num,
"TS64GSSD25-M") == 0) {
365 "disabling UDMA mode due to reported lockups with this device\n");
372 ata_dev_warn(dev,
"controller locks up on ATAPI DMA, forcing PIO\n");
392 struct ata_ioports *ioaddr = &ap->ioaddr;
397 if (tf->
ctl != ap->last_ctl) {
399 ap->last_ctl = tf->
ctl;
417 VPRINTK(
"hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
431 VPRINTK(
"feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n",
442 static int via_port_start(
struct ata_port *ap)
447 int ret = ata_bmdma_port_start(ap);
463 .inherits = &ata_bmdma_port_ops,
464 .cable_detect = via_cable_detect,
465 .set_piomode = via_set_piomode,
466 .set_dmamode = via_set_dmamode,
467 .prereset = via_pre_reset,
468 .sff_tf_load = via_tf_load,
469 .port_start = via_port_start,
470 .mode_filter = via_mode_filter,
474 .inherits = &via_port_ops,
487 static void via_config_fifo(
struct pci_dev *pdev,
unsigned int flags)
492 pci_read_config_byte(pdev, 0x40 , &enable);
496 static const u8 fifo_setting[4] = {0x00, 0x60, 0x00, 0x20};
499 pci_read_config_byte(pdev, 0x43, &fifo);
507 fifo |= fifo_setting[
enable];
508 pci_write_config_byte(pdev, 0x43, fifo);
512 static void via_fixup(
struct pci_dev *pdev,
const struct via_isa_bridge *config)
517 via_config_fifo(pdev, config->flags);
521 pci_read_config_dword(pdev, 0x50, &timing);
523 pci_write_config_dword(pdev, 0x50, timing);
527 pci_read_config_dword(pdev, 0x50, &timing);
529 pci_write_config_dword(pdev, 0x50, timing);
549 .port_ops = &via_port_ops
556 .port_ops = &via_port_ops_noirq,
564 .port_ops = &via_port_ops
572 .port_ops = &via_port_ops
580 .port_ops = &via_port_ops
588 .port_ops = &via_port_ops
592 const struct via_isa_bridge *
config;
594 unsigned long flags =
id->driver_data;
612 config->id,
NULL))) {
617 (config->id != id->
device))
620 if (rev >= config->rev_min && rev <= config->rev_max)
626 pci_read_config_byte(pdev, 0x40 , &enable);
633 switch (config->udma_mask) {
636 ppi[0] = &via_mwdma_info_borked;
638 ppi[0] = &via_mwdma_info;
641 ppi[0] = &via_udma33_info;
644 ppi[0] = &via_udma66_info;
647 ppi[0] = &via_udma100_info;
650 ppi[0] = &via_udma133_info;
657 via_fixup(pdev, config);
660 return ata_pci_bmdma_init_one(pdev, ppi, &via_sht, (
void *)config, 0);
674 static int via_reinit_one(
struct pci_dev *pdev)
679 rc = ata_pci_device_do_resume(pdev);
685 ata_host_resume(host);
706 .probe = via_init_one,
707 .remove = ata_pci_remove_one,
709 .suspend = ata_pci_device_suspend,
710 .resume = via_reinit_one,