aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-08-07 04:55:03 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-08-07 04:55:03 -0400
commit4fb8af10d0fd09372d52966b76922b9e82bbc950 (patch)
treed240e4d40357583e3f3eb228dccf20122a5b31ed /drivers/ata
parentf44f82e8a20b98558486eb14497b2f71c78fa325 (diff)
parent64a99d2a8c3ed5c4e39f3ae1cc682aa8fd3977fc (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fixes
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/ata_piix.c1
-rw-r--r--drivers/ata/libata-core.c57
-rw-r--r--drivers/ata/libata-scsi.c34
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/pata_ali.c3
-rw-r--r--drivers/ata/pata_it821x.c270
-rw-r--r--drivers/ata/pata_via.c64
7 files changed, 350 insertions, 80 deletions
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index a90ae03f56b2..c294121fd69e 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -250,6 +250,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
250 /* Mobile SATA Controller IDE (ICH8M), Apple */ 250 /* Mobile SATA Controller IDE (ICH8M), Apple */
251 { 0x8086, 0x2828, 0x106b, 0x00a0, 0, 0, ich8m_apple_sata }, 251 { 0x8086, 0x2828, 0x106b, 0x00a0, 0, 0, ich8m_apple_sata },
252 { 0x8086, 0x2828, 0x106b, 0x00a1, 0, 0, ich8m_apple_sata }, 252 { 0x8086, 0x2828, 0x106b, 0x00a1, 0, 0, ich8m_apple_sata },
253 { 0x8086, 0x2828, 0x106b, 0x00a3, 0, 0, ich8m_apple_sata },
253 /* Mobile SATA Controller IDE (ICH8M) */ 254 /* Mobile SATA Controller IDE (ICH8M) */
254 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 255 { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
255 /* SATA Controller IDE (ICH9) */ 256 /* SATA Controller IDE (ICH9) */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 9bef1a84fe3f..5ba96c5052c8 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -120,7 +120,7 @@ static char ata_force_param_buf[PAGE_SIZE] __initdata;
120module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0); 120module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0);
121MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)"); 121MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)");
122 122
123int atapi_enabled = 1; 123static int atapi_enabled = 1;
124module_param(atapi_enabled, int, 0444); 124module_param(atapi_enabled, int, 0444);
125MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); 125MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)");
126 126
@@ -1132,6 +1132,8 @@ void ata_id_string(const u16 *id, unsigned char *s,
1132{ 1132{
1133 unsigned int c; 1133 unsigned int c;
1134 1134
1135 BUG_ON(len & 1);
1136
1135 while (len > 0) { 1137 while (len > 0) {
1136 c = id[ofs] >> 8; 1138 c = id[ofs] >> 8;
1137 *s = c; 1139 *s = c;
@@ -1165,8 +1167,6 @@ void ata_id_c_string(const u16 *id, unsigned char *s,
1165{ 1167{
1166 unsigned char *p; 1168 unsigned char *p;
1167 1169
1168 WARN_ON(!(len & 1));
1169
1170 ata_id_string(id, s, ofs, len - 1); 1170 ata_id_string(id, s, ofs, len - 1);
1171 1171
1172 p = s + strnlen(s, len - 1); 1172 p = s + strnlen(s, len - 1);
@@ -1886,6 +1886,23 @@ static u32 ata_pio_mask_no_iordy(const struct ata_device *adev)
1886} 1886}
1887 1887
1888/** 1888/**
1889 * ata_do_dev_read_id - default ID read method
1890 * @dev: device
1891 * @tf: proposed taskfile
1892 * @id: data buffer
1893 *
1894 * Issue the identify taskfile and hand back the buffer containing
1895 * identify data. For some RAID controllers and for pre ATA devices
1896 * this function is wrapped or replaced by the driver
1897 */
1898unsigned int ata_do_dev_read_id(struct ata_device *dev,
1899 struct ata_taskfile *tf, u16 *id)
1900{
1901 return ata_exec_internal(dev, tf, NULL, DMA_FROM_DEVICE,
1902 id, sizeof(id[0]) * ATA_ID_WORDS, 0);
1903}
1904
1905/**
1889 * ata_dev_read_id - Read ID data from the specified device 1906 * ata_dev_read_id - Read ID data from the specified device
1890 * @dev: target device 1907 * @dev: target device
1891 * @p_class: pointer to class of the target device (may be changed) 1908 * @p_class: pointer to class of the target device (may be changed)
@@ -1920,7 +1937,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1920 if (ata_msg_ctl(ap)) 1937 if (ata_msg_ctl(ap))
1921 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__); 1938 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__);
1922 1939
1923 retry: 1940retry:
1924 ata_tf_init(dev, &tf); 1941 ata_tf_init(dev, &tf);
1925 1942
1926 switch (class) { 1943 switch (class) {
@@ -1948,8 +1965,11 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1948 */ 1965 */
1949 tf.flags |= ATA_TFLAG_POLLING; 1966 tf.flags |= ATA_TFLAG_POLLING;
1950 1967
1951 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, 1968 if (ap->ops->read_id)
1952 id, sizeof(id[0]) * ATA_ID_WORDS, 0); 1969 err_mask = ap->ops->read_id(dev, &tf, id);
1970 else
1971 err_mask = ata_do_dev_read_id(dev, &tf, id);
1972
1953 if (err_mask) { 1973 if (err_mask) {
1954 if (err_mask & AC_ERR_NODEV_HINT) { 1974 if (err_mask & AC_ERR_NODEV_HINT) {
1955 ata_dev_printk(dev, KERN_DEBUG, 1975 ata_dev_printk(dev, KERN_DEBUG,
@@ -2142,6 +2162,16 @@ int ata_dev_configure(struct ata_device *dev)
2142 return 0; 2162 return 0;
2143 } 2163 }
2144 2164
2165 if ((!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) &&
2166 dev->class == ATA_DEV_ATAPI) {
2167 ata_dev_printk(dev, KERN_WARNING,
2168 "WARNING: ATAPI is %s, device ignored.\n",
2169 atapi_enabled ? "not supported with this driver"
2170 : "disabled");
2171 ata_dev_disable(dev);
2172 return 0;
2173 }
2174
2145 /* let ACPI work its magic */ 2175 /* let ACPI work its magic */
2146 rc = ata_acpi_on_devcfg(dev); 2176 rc = ata_acpi_on_devcfg(dev);
2147 if (rc) 2177 if (rc)
@@ -6088,16 +6118,20 @@ static int __init ata_init(void)
6088 6118
6089 ata_wq = create_workqueue("ata"); 6119 ata_wq = create_workqueue("ata");
6090 if (!ata_wq) 6120 if (!ata_wq)
6091 return -ENOMEM; 6121 goto free_force_tbl;
6092 6122
6093 ata_aux_wq = create_singlethread_workqueue("ata_aux"); 6123 ata_aux_wq = create_singlethread_workqueue("ata_aux");
6094 if (!ata_aux_wq) { 6124 if (!ata_aux_wq)
6095 destroy_workqueue(ata_wq); 6125 goto free_wq;
6096 return -ENOMEM;
6097 }
6098 6126
6099 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n"); 6127 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
6100 return 0; 6128 return 0;
6129
6130free_wq:
6131 destroy_workqueue(ata_wq);
6132free_force_tbl:
6133 kfree(ata_force_tbl);
6134 return -ENOMEM;
6101} 6135}
6102 6136
6103static void __exit ata_exit(void) 6137static void __exit ata_exit(void)
@@ -6269,6 +6303,7 @@ EXPORT_SYMBOL_GPL(ata_host_resume);
6269#endif /* CONFIG_PM */ 6303#endif /* CONFIG_PM */
6270EXPORT_SYMBOL_GPL(ata_id_string); 6304EXPORT_SYMBOL_GPL(ata_id_string);
6271EXPORT_SYMBOL_GPL(ata_id_c_string); 6305EXPORT_SYMBOL_GPL(ata_id_c_string);
6306EXPORT_SYMBOL_GPL(ata_do_dev_read_id);
6272EXPORT_SYMBOL_GPL(ata_scsi_simulate); 6307EXPORT_SYMBOL_GPL(ata_scsi_simulate);
6273 6308
6274EXPORT_SYMBOL_GPL(ata_pio_need_iordy); 6309EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index f3b4b15a8dc4..b9d3ba423cb2 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2551,36 +2551,6 @@ static struct ata_device *__ata_scsi_find_dev(struct ata_port *ap,
2551} 2551}
2552 2552
2553/** 2553/**
2554 * ata_scsi_dev_enabled - determine if device is enabled
2555 * @dev: ATA device
2556 *
2557 * Determine if commands should be sent to the specified device.
2558 *
2559 * LOCKING:
2560 * spin_lock_irqsave(host lock)
2561 *
2562 * RETURNS:
2563 * 0 if commands are not allowed / 1 if commands are allowed
2564 */
2565
2566static int ata_scsi_dev_enabled(struct ata_device *dev)
2567{
2568 if (unlikely(!ata_dev_enabled(dev)))
2569 return 0;
2570
2571 if (!atapi_enabled || (dev->link->ap->flags & ATA_FLAG_NO_ATAPI)) {
2572 if (unlikely(dev->class == ATA_DEV_ATAPI)) {
2573 ata_dev_printk(dev, KERN_WARNING,
2574 "WARNING: ATAPI is %s, device ignored.\n",
2575 atapi_enabled ? "not supported with this driver" : "disabled");
2576 return 0;
2577 }
2578 }
2579
2580 return 1;
2581}
2582
2583/**
2584 * ata_scsi_find_dev - lookup ata_device from scsi_cmnd 2554 * ata_scsi_find_dev - lookup ata_device from scsi_cmnd
2585 * @ap: ATA port to which the device is attached 2555 * @ap: ATA port to which the device is attached
2586 * @scsidev: SCSI device from which we derive the ATA device 2556 * @scsidev: SCSI device from which we derive the ATA device
@@ -2601,7 +2571,7 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev)
2601{ 2571{
2602 struct ata_device *dev = __ata_scsi_find_dev(ap, scsidev); 2572 struct ata_device *dev = __ata_scsi_find_dev(ap, scsidev);
2603 2573
2604 if (unlikely(!dev || !ata_scsi_dev_enabled(dev))) 2574 if (unlikely(!dev || !ata_dev_enabled(dev)))
2605 return NULL; 2575 return NULL;
2606 2576
2607 return dev; 2577 return dev;
@@ -3622,7 +3592,7 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
3622 3592
3623 ata_scsi_dump_cdb(ap, cmd); 3593 ata_scsi_dump_cdb(ap, cmd);
3624 3594
3625 if (likely(ata_scsi_dev_enabled(ap->link.device))) 3595 if (likely(ata_dev_enabled(ap->link.device)))
3626 rc = __ata_scsi_queuecmd(cmd, done, ap->link.device); 3596 rc = __ata_scsi_queuecmd(cmd, done, ap->link.device);
3627 else { 3597 else {
3628 cmd->result = (DID_BAD_TARGET << 16); 3598 cmd->result = (DID_BAD_TARGET << 16);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index f6f9c28ec7f8..ade5c75b6144 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -66,7 +66,6 @@ enum {
66 66
67extern unsigned int ata_print_id; 67extern unsigned int ata_print_id;
68extern struct workqueue_struct *ata_aux_wq; 68extern struct workqueue_struct *ata_aux_wq;
69extern int atapi_enabled;
70extern int atapi_passthru16; 69extern int atapi_passthru16;
71extern int libata_fua; 70extern int libata_fua;
72extern int libata_noacpi; 71extern int libata_noacpi;
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 0f3e659db99a..5ca70fa1f587 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -550,8 +550,9 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
550 pci_read_config_byte(isa_bridge, 0x5E, &tmp); 550 pci_read_config_byte(isa_bridge, 0x5E, &tmp);
551 if ((tmp & 0x1E) == 0x12) 551 if ((tmp & 0x1E) == 0x12)
552 ppi[0] = &info_20_udma; 552 ppi[0] = &info_20_udma;
553 pci_dev_put(isa_bridge);
554 } 553 }
554 pci_dev_put(isa_bridge);
555
555 return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL); 556 return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL);
556} 557}
557 558
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index e10816931b2f..27843c70eb9d 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -80,7 +80,7 @@
80 80
81 81
82#define DRV_NAME "pata_it821x" 82#define DRV_NAME "pata_it821x"
83#define DRV_VERSION "0.3.8" 83#define DRV_VERSION "0.4.0"
84 84
85struct it821x_dev 85struct it821x_dev
86{ 86{
@@ -425,6 +425,8 @@ static unsigned int it821x_smart_qc_issue(struct ata_queued_cmd *qc)
425 case ATA_CMD_WRITE_MULTI: 425 case ATA_CMD_WRITE_MULTI:
426 case ATA_CMD_WRITE_MULTI_EXT: 426 case ATA_CMD_WRITE_MULTI_EXT:
427 case ATA_CMD_ID_ATA: 427 case ATA_CMD_ID_ATA:
428 case ATA_CMD_INIT_DEV_PARAMS:
429 case 0xFC: /* Internal 'report rebuild state' */
428 /* Arguably should just no-op this one */ 430 /* Arguably should just no-op this one */
429 case ATA_CMD_SET_FEATURES: 431 case ATA_CMD_SET_FEATURES:
430 return ata_sff_qc_issue(qc); 432 return ata_sff_qc_issue(qc);
@@ -509,7 +511,7 @@ static void it821x_dev_config(struct ata_device *adev)
509 511
510 if (strstr(model_num, "Integrated Technology Express")) { 512 if (strstr(model_num, "Integrated Technology Express")) {
511 /* RAID mode */ 513 /* RAID mode */
512 printk(KERN_INFO "IT821x %sRAID%d volume", 514 ata_dev_printk(adev, KERN_INFO, "%sRAID%d volume",
513 adev->id[147]?"Bootable ":"", 515 adev->id[147]?"Bootable ":"",
514 adev->id[129]); 516 adev->id[129]);
515 if (adev->id[129] != 1) 517 if (adev->id[129] != 1)
@@ -519,37 +521,51 @@ static void it821x_dev_config(struct ata_device *adev)
519 /* This is a controller firmware triggered funny, don't 521 /* This is a controller firmware triggered funny, don't
520 report the drive faulty! */ 522 report the drive faulty! */
521 adev->horkage &= ~ATA_HORKAGE_DIAGNOSTIC; 523 adev->horkage &= ~ATA_HORKAGE_DIAGNOSTIC;
524 /* No HPA in 'smart' mode */
525 adev->horkage |= ATA_HORKAGE_BROKEN_HPA;
522} 526}
523 527
524/** 528/**
525 * it821x_ident_hack - Hack identify data up 529 * it821x_read_id - Hack identify data up
526 * @ap: Port 530 * @adev: device to read
531 * @tf: proposed taskfile
532 * @id: buffer for returned ident data
527 * 533 *
528 * Walk the devices on this firmware driven port and slightly 534 * Query the devices on this firmware driven port and slightly
529 * mash the identify data to stop us and common tools trying to 535 * mash the identify data to stop us and common tools trying to
530 * use features not firmware supported. The firmware itself does 536 * use features not firmware supported. The firmware itself does
531 * some masking (eg SMART) but not enough. 537 * some masking (eg SMART) but not enough.
532 *
533 * This is a bit of an abuse of the cable method, but it is the
534 * only method called at the right time. We could modify the libata
535 * core specifically for ident hacking but while we have one offender
536 * it seems better to keep the fallout localised.
537 */ 538 */
538 539
539static int it821x_ident_hack(struct ata_port *ap) 540static unsigned int it821x_read_id(struct ata_device *adev,
541 struct ata_taskfile *tf, u16 *id)
540{ 542{
541 struct ata_device *adev; 543 unsigned int err_mask;
542 ata_link_for_each_dev(adev, &ap->link) { 544 unsigned char model_num[ATA_ID_PROD_LEN + 1];
543 if (ata_dev_enabled(adev)) { 545
544 adev->id[84] &= ~(1 << 6); /* No FUA */ 546 err_mask = ata_do_dev_read_id(adev, tf, id);
545 adev->id[85] &= ~(1 << 10); /* No HPA */ 547 if (err_mask)
546 adev->id[76] = 0; /* No NCQ/AN etc */ 548 return err_mask;
547 } 549 ata_id_c_string(id, model_num, ATA_ID_PROD, sizeof(model_num));
550
551 id[83] &= ~(1 << 12); /* Cache flush is firmware handled */
552 id[83] &= ~(1 << 13); /* Ditto for LBA48 flushes */
553 id[84] &= ~(1 << 6); /* No FUA */
554 id[85] &= ~(1 << 10); /* No HPA */
555 id[76] = 0; /* No NCQ/AN etc */
556
557 if (strstr(model_num, "Integrated Technology Express")) {
558 /* Set feature bits the firmware neglects */
559 id[49] |= 0x0300; /* LBA, DMA */
560 id[82] |= 0x0400; /* LBA48 */
561 id[83] &= 0x7FFF;
562 id[83] |= 0x4000; /* Word 83 is valid */
563 id[86] |= 0x0400; /* LBA48 on */
564 id[ATA_ID_MAJOR_VER] |= 0x1F;
548 } 565 }
549 return ata_cable_unknown(ap); 566 return err_mask;
550} 567}
551 568
552
553/** 569/**
554 * it821x_check_atapi_dma - ATAPI DMA handler 570 * it821x_check_atapi_dma - ATAPI DMA handler
555 * @qc: Command we are about to issue 571 * @qc: Command we are about to issue
@@ -577,6 +593,136 @@ static int it821x_check_atapi_dma(struct ata_queued_cmd *qc)
577 return 0; 593 return 0;
578} 594}
579 595
596/**
597 * it821x_display_disk - display disk setup
598 * @n: Device number
599 * @buf: Buffer block from firmware
600 *
601 * Produce a nice informative display of the device setup as provided
602 * by the firmware.
603 */
604
605static void it821x_display_disk(int n, u8 *buf)
606{
607 unsigned char id[41];
608 int mode = 0;
609 char *mtype;
610 char mbuf[8];
611 char *cbl = "(40 wire cable)";
612
613 static const char *types[5] = {
614 "RAID0", "RAID1" "RAID 0+1", "JBOD", "DISK"
615 };
616
617 if (buf[52] > 4) /* No Disk */
618 return;
619
620 ata_id_c_string((u16 *)buf, id, 0, 41);
621
622 if (buf[51]) {
623 mode = ffs(buf[51]);
624 mtype = "UDMA";
625 } else if (buf[49]) {
626 mode = ffs(buf[49]);
627 mtype = "MWDMA";
628 }
629
630 if (buf[76])
631 cbl = "";
632
633 if (mode)
634 snprintf(mbuf, 8, "%5s%d", mtype, mode - 1);
635 else
636 strcpy(mbuf, "PIO");
637 if (buf[52] == 4)
638 printk(KERN_INFO "%d: %-6s %-8s %s %s\n",
639 n, mbuf, types[buf[52]], id, cbl);
640 else
641 printk(KERN_INFO "%d: %-6s %-8s Volume: %1d %s %s\n",
642 n, mbuf, types[buf[52]], buf[53], id, cbl);
643 if (buf[125] < 100)
644 printk(KERN_INFO "%d: Rebuilding: %d%%\n", n, buf[125]);
645}
646
647/**
648 * it821x_firmware_command - issue firmware command
649 * @ap: IT821x port to interrogate
650 * @cmd: command
651 * @len: length
652 *
653 * Issue firmware commands expecting data back from the controller. We
654 * use this to issue commands that do not go via the normal paths. Other
655 * commands such as 0xFC can be issued normally.
656 */
657
658static u8 *it821x_firmware_command(struct ata_port *ap, u8 cmd, int len)
659{
660 u8 status;
661 int n = 0;
662 u16 *buf = kmalloc(len, GFP_KERNEL);
663 if (buf == NULL) {
664 printk(KERN_ERR "it821x_firmware_command: Out of memory\n");
665 return NULL;
666 }
667 /* This isn't quite a normal ATA command as we are talking to the
668 firmware not the drives */
669 ap->ctl |= ATA_NIEN;
670 iowrite8(ap->ctl, ap->ioaddr.ctl_addr);
671 ata_wait_idle(ap);
672 iowrite8(ATA_DEVICE_OBS, ap->ioaddr.device_addr);
673 iowrite8(cmd, ap->ioaddr.command_addr);
674 udelay(1);
675 /* This should be almost immediate but a little paranoia goes a long
676 way. */
677 while(n++ < 10) {
678 status = ioread8(ap->ioaddr.status_addr);
679 if (status & ATA_ERR) {
680 kfree(buf);
681 printk(KERN_ERR "it821x_firmware_command: rejected\n");
682 return NULL;
683 }
684 if (status & ATA_DRQ) {
685 ioread16_rep(ap->ioaddr.data_addr, buf, len/2);
686 return (u8 *)buf;
687 }
688 mdelay(1);
689 }
690 kfree(buf);
691 printk(KERN_ERR "it821x_firmware_command: timeout\n");
692 return NULL;
693}
694
695/**
696 * it821x_probe_firmware - firmware reporting/setup
697 * @ap: IT821x port being probed
698 *
699 * Probe the firmware of the controller by issuing firmware command
700 * 0xFA and analysing the returned data.
701 */
702
703static void it821x_probe_firmware(struct ata_port *ap)
704{
705 u8 *buf;
706 int i;
707
708 /* This is a bit ugly as we can't just issue a task file to a device
709 as this is controller magic */
710
711 buf = it821x_firmware_command(ap, 0xFA, 512);
712
713 if (buf != NULL) {
714 printk(KERN_INFO "pata_it821x: Firmware %02X/%02X/%02X%02X\n",
715 buf[505],
716 buf[506],
717 buf[507],
718 buf[508]);
719 for (i = 0; i < 4; i++)
720 it821x_display_disk(i, buf + 128 * i);
721 kfree(buf);
722 }
723}
724
725
580 726
581/** 727/**
582 * it821x_port_start - port setup 728 * it821x_port_start - port setup
@@ -610,6 +756,8 @@ static int it821x_port_start(struct ata_port *ap)
610 /* Long I/O's although allowed in LBA48 space cause the 756 /* Long I/O's although allowed in LBA48 space cause the
611 onboard firmware to enter the twighlight zone */ 757 onboard firmware to enter the twighlight zone */
612 /* No ATAPI DMA in this mode either */ 758 /* No ATAPI DMA in this mode either */
759 if (ap->port_no == 0)
760 it821x_probe_firmware(ap);
613 } 761 }
614 /* Pull the current clocks from 0x50 */ 762 /* Pull the current clocks from 0x50 */
615 if (conf & (1 << (1 + ap->port_no))) 763 if (conf & (1 << (1 + ap->port_no)))
@@ -631,6 +779,25 @@ static int it821x_port_start(struct ata_port *ap)
631 return 0; 779 return 0;
632} 780}
633 781
782/**
783 * it821x_rdc_cable - Cable detect for RDC1010
784 * @ap: port we are checking
785 *
786 * Return the RDC1010 cable type. Unlike the IT821x we know how to do
787 * this and can do host side cable detect
788 */
789
790static int it821x_rdc_cable(struct ata_port *ap)
791{
792 u16 r40;
793 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
794
795 pci_read_config_word(pdev, 0x40, &r40);
796 if (r40 & (1 << (2 + ap->port_no)))
797 return ATA_CBL_PATA40;
798 return ATA_CBL_PATA80;
799}
800
634static struct scsi_host_template it821x_sht = { 801static struct scsi_host_template it821x_sht = {
635 ATA_BMDMA_SHT(DRV_NAME), 802 ATA_BMDMA_SHT(DRV_NAME),
636}; 803};
@@ -641,9 +808,10 @@ static struct ata_port_operations it821x_smart_port_ops = {
641 .check_atapi_dma= it821x_check_atapi_dma, 808 .check_atapi_dma= it821x_check_atapi_dma,
642 .qc_issue = it821x_smart_qc_issue, 809 .qc_issue = it821x_smart_qc_issue,
643 810
644 .cable_detect = it821x_ident_hack, 811 .cable_detect = ata_cable_80wire,
645 .set_mode = it821x_smart_set_mode, 812 .set_mode = it821x_smart_set_mode,
646 .dev_config = it821x_dev_config, 813 .dev_config = it821x_dev_config,
814 .read_id = it821x_read_id,
647 815
648 .port_start = it821x_port_start, 816 .port_start = it821x_port_start,
649}; 817};
@@ -664,8 +832,29 @@ static struct ata_port_operations it821x_passthru_port_ops = {
664 .port_start = it821x_port_start, 832 .port_start = it821x_port_start,
665}; 833};
666 834
835static struct ata_port_operations it821x_rdc_port_ops = {
836 .inherits = &ata_bmdma_port_ops,
837
838 .check_atapi_dma= it821x_check_atapi_dma,
839 .sff_dev_select = it821x_passthru_dev_select,
840 .bmdma_start = it821x_passthru_bmdma_start,
841 .bmdma_stop = it821x_passthru_bmdma_stop,
842 .qc_issue = it821x_passthru_qc_issue,
843
844 .cable_detect = it821x_rdc_cable,
845 .set_piomode = it821x_passthru_set_piomode,
846 .set_dmamode = it821x_passthru_set_dmamode,
847
848 .port_start = it821x_port_start,
849};
850
667static void it821x_disable_raid(struct pci_dev *pdev) 851static void it821x_disable_raid(struct pci_dev *pdev)
668{ 852{
853 /* Neither the RDC nor the IT8211 */
854 if (pdev->vendor != PCI_VENDOR_ID_ITE ||
855 pdev->device != PCI_DEVICE_ID_ITE_8212)
856 return;
857
669 /* Reset local CPU, and set BIOS not ready */ 858 /* Reset local CPU, and set BIOS not ready */
670 pci_write_config_byte(pdev, 0x5E, 0x01); 859 pci_write_config_byte(pdev, 0x5E, 0x01);
671 860
@@ -690,6 +879,7 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
690 .flags = ATA_FLAG_SLAVE_POSS, 879 .flags = ATA_FLAG_SLAVE_POSS,
691 .pio_mask = 0x1f, 880 .pio_mask = 0x1f,
692 .mwdma_mask = 0x07, 881 .mwdma_mask = 0x07,
882 .udma_mask = ATA_UDMA6,
693 .port_ops = &it821x_smart_port_ops 883 .port_ops = &it821x_smart_port_ops
694 }; 884 };
695 static const struct ata_port_info info_passthru = { 885 static const struct ata_port_info info_passthru = {
@@ -699,6 +889,13 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
699 .udma_mask = ATA_UDMA6, 889 .udma_mask = ATA_UDMA6,
700 .port_ops = &it821x_passthru_port_ops 890 .port_ops = &it821x_passthru_port_ops
701 }; 891 };
892 static const struct ata_port_info info_rdc = {
893 .flags = ATA_FLAG_SLAVE_POSS,
894 .pio_mask = 0x1f,
895 .mwdma_mask = 0x07,
896 /* No UDMA */
897 .port_ops = &it821x_rdc_port_ops
898 };
702 899
703 const struct ata_port_info *ppi[] = { NULL, NULL }; 900 const struct ata_port_info *ppi[] = { NULL, NULL };
704 static char *mode[2] = { "pass through", "smart" }; 901 static char *mode[2] = { "pass through", "smart" };
@@ -707,21 +904,25 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
707 rc = pcim_enable_device(pdev); 904 rc = pcim_enable_device(pdev);
708 if (rc) 905 if (rc)
709 return rc; 906 return rc;
907
908 if (pdev->vendor == PCI_VENDOR_ID_RDC) {
909 ppi[0] = &info_rdc;
910 } else {
911 /* Force the card into bypass mode if so requested */
912 if (it8212_noraid) {
913 printk(KERN_INFO DRV_NAME ": forcing bypass mode.\n");
914 it821x_disable_raid(pdev);
915 }
916 pci_read_config_byte(pdev, 0x50, &conf);
917 conf &= 1;
710 918
711 /* Force the card into bypass mode if so requested */ 919 printk(KERN_INFO DRV_NAME": controller in %s mode.\n",
712 if (it8212_noraid) { 920 mode[conf]);
713 printk(KERN_INFO DRV_NAME ": forcing bypass mode.\n"); 921 if (conf == 0)
714 it821x_disable_raid(pdev); 922 ppi[0] = &info_passthru;
923 else
924 ppi[0] = &info_smart;
715 } 925 }
716 pci_read_config_byte(pdev, 0x50, &conf);
717 conf &= 1;
718
719 printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]);
720 if (conf == 0)
721 ppi[0] = &info_passthru;
722 else
723 ppi[0] = &info_smart;
724
725 return ata_pci_sff_init_one(pdev, ppi, &it821x_sht, NULL); 926 return ata_pci_sff_init_one(pdev, ppi, &it821x_sht, NULL);
726} 927}
727 928
@@ -745,6 +946,7 @@ static int it821x_reinit_one(struct pci_dev *pdev)
745static const struct pci_device_id it821x[] = { 946static const struct pci_device_id it821x[] = {
746 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), }, 947 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), },
747 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), }, 948 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), },
949 { PCI_VDEVICE(RDC, 0x1010), },
748 950
749 { }, 951 { },
750}; 952};
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 708ed144ede9..57d951b11f2d 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -98,7 +98,8 @@ static const struct via_isa_bridge {
98 u8 rev_max; 98 u8 rev_max;
99 u16 flags; 99 u16 flags;
100} via_isa_bridges[] = { 100} via_isa_bridges[] = {
101 { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 101 { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, VIA_UDMA_133 |
102 VIA_BAD_AST | VIA_SATA_PATA },
102 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 103 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
103 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 104 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
104 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA }, 105 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA },
@@ -322,6 +323,65 @@ static void via_set_dmamode(struct ata_port *ap, struct ata_device *adev)
322 via_do_set_mode(ap, adev, adev->dma_mode, tclock[mode], set_ast, udma[mode]); 323 via_do_set_mode(ap, adev, adev->dma_mode, tclock[mode], set_ast, udma[mode]);
323} 324}
324 325
326/**
327 * via_ata_sff_tf_load - send taskfile registers to host controller
328 * @ap: Port to which output is sent
329 * @tf: ATA taskfile register set
330 *
331 * Outputs ATA taskfile to standard ATA host controller.
332 *
333 * Note: This is to fix the internal bug of via chipsets, which
334 * will reset the device register after changing the IEN bit on
335 * ctl register
336 */
337static void via_ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
338{
339 struct ata_ioports *ioaddr = &ap->ioaddr;
340 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
341
342 if (tf->ctl != ap->last_ctl) {
343 iowrite8(tf->ctl, ioaddr->ctl_addr);
344 iowrite8(tf->device, ioaddr->device_addr);
345 ap->last_ctl = tf->ctl;
346 ata_wait_idle(ap);
347 }
348
349 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
350 iowrite8(tf->hob_feature, ioaddr->feature_addr);
351 iowrite8(tf->hob_nsect, ioaddr->nsect_addr);
352 iowrite8(tf->hob_lbal, ioaddr->lbal_addr);
353 iowrite8(tf->hob_lbam, ioaddr->lbam_addr);
354 iowrite8(tf->hob_lbah, ioaddr->lbah_addr);
355 VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
356 tf->hob_feature,
357 tf->hob_nsect,
358 tf->hob_lbal,
359 tf->hob_lbam,
360 tf->hob_lbah);
361 }
362
363 if (is_addr) {
364 iowrite8(tf->feature, ioaddr->feature_addr);
365 iowrite8(tf->nsect, ioaddr->nsect_addr);
366 iowrite8(tf->lbal, ioaddr->lbal_addr);
367 iowrite8(tf->lbam, ioaddr->lbam_addr);
368 iowrite8(tf->lbah, ioaddr->lbah_addr);
369 VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n",
370 tf->feature,
371 tf->nsect,
372 tf->lbal,
373 tf->lbam,
374 tf->lbah);
375 }
376
377 if (tf->flags & ATA_TFLAG_DEVICE) {
378 iowrite8(tf->device, ioaddr->device_addr);
379 VPRINTK("device 0x%X\n", tf->device);
380 }
381
382 ata_wait_idle(ap);
383}
384
325static struct scsi_host_template via_sht = { 385static struct scsi_host_template via_sht = {
326 ATA_BMDMA_SHT(DRV_NAME), 386 ATA_BMDMA_SHT(DRV_NAME),
327}; 387};
@@ -332,11 +392,13 @@ static struct ata_port_operations via_port_ops = {
332 .set_piomode = via_set_piomode, 392 .set_piomode = via_set_piomode,
333 .set_dmamode = via_set_dmamode, 393 .set_dmamode = via_set_dmamode,
334 .prereset = via_pre_reset, 394 .prereset = via_pre_reset,
395 .sff_tf_load = via_ata_tf_load,
335}; 396};
336 397
337static struct ata_port_operations via_port_ops_noirq = { 398static struct ata_port_operations via_port_ops_noirq = {
338 .inherits = &via_port_ops, 399 .inherits = &via_port_ops,
339 .sff_data_xfer = ata_sff_data_xfer_noirq, 400 .sff_data_xfer = ata_sff_data_xfer_noirq,
401 .sff_tf_load = via_ata_tf_load,
340}; 402};
341 403
342/** 404/**