linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 #upstream-fixes] sata_via: load DEVICE register when CTL changes
@ 2008-10-21 15:45 Tejun Heo
  2008-10-21 15:46 ` [PATCH 1/2 #upstream-fixes] sata_via: fix support for 5287 Tejun Heo
  2008-10-23  0:43 ` [PATCH 1/2 #upstream-fixes] sata_via: load DEVICE register when CTL changes Jeff Garzik
  0 siblings, 2 replies; 5+ messages in thread
From: Tejun Heo @ 2008-10-21 15:45 UTC (permalink / raw)
  To: Jeff Garzik, IDE/ATA development list, Joseph Chan

VIA controllers clear DEVICE register when IEN changes.  Make sure
DEVICE is updated along with CTL.

This change is separated from Joseph Chan's larger patch.

  http://thread.gmane.org/gmane.linux.kernel.commits.mm/40640

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Joseph Chan <JosephChan@via.com.tw>
---
These two patches are on top of

linus#master
+ [1] libata-eh-fix-slave-link-EH-action-mask-handling
+ [2] libata-transfer-EHI-control-flags-to-slave-ehc_i
+ [3] libata-set-device-class-to-NONE-if-phys_offline

[1] http://article.gmane.org/gmane.linux.ide/35390
[2] http://article.gmane.org/gmane.linux.ide/35393
[3] http://article.gmane.org/gmane.linux.ide/35436

and finally gets vt8251 working.  I'll integrate this into the
separate-sff-bmdma git tree.  :-)

 drivers/ata/sata_via.c |   35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

Index: work/drivers/ata/sata_via.c
===================================================================
--- work.orig/drivers/ata/sata_via.c
+++ work/drivers/ata/sata_via.c
@@ -70,6 +70,7 @@ enum {
 static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
 static int svia_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
 static int svia_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
+static void svia_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
 static void svia_noop_freeze(struct ata_port *ap);
 static int vt6420_prereset(struct ata_link *link, unsigned long deadline);
 static int vt6421_pata_cable_detect(struct ata_port *ap);
@@ -103,21 +104,26 @@ static struct scsi_host_template svia_sh
 	ATA_BMDMA_SHT(DRV_NAME),
 };
 
-static struct ata_port_operations vt6420_sata_ops = {
+static struct ata_port_operations svia_base_ops = {
 	.inherits		= &ata_bmdma_port_ops,
+	.sff_tf_load		= svia_tf_load,
+};
+
+static struct ata_port_operations vt6420_sata_ops = {
+	.inherits		= &svia_base_ops,
 	.freeze			= svia_noop_freeze,
 	.prereset		= vt6420_prereset,
 };
 
 static struct ata_port_operations vt6421_pata_ops = {
-	.inherits		= &ata_bmdma_port_ops,
+	.inherits		= &svia_base_ops,
 	.cable_detect		= vt6421_pata_cable_detect,
 	.set_piomode		= vt6421_set_pio_mode,
 	.set_dmamode		= vt6421_set_dma_mode,
 };
 
 static struct ata_port_operations vt6421_sata_ops = {
-	.inherits		= &ata_bmdma_port_ops,
+	.inherits		= &svia_base_ops,
 	.scr_read		= svia_scr_read,
 	.scr_write		= svia_scr_write,
 };
@@ -168,6 +174,29 @@ static int svia_scr_write(struct ata_lin
 	return 0;
 }
 
+/**
+ *	svia_tf_load - send taskfile registers to host controller
+ *	@ap: Port to which output is sent
+ *	@tf: ATA taskfile register set
+ *
+ *	Outputs ATA taskfile to standard ATA host controller.
+ *
+ *	This is to fix the internal bug of via chipsets, which will
+ *	reset the device register after changing the IEN bit on ctl
+ *	register.
+ */
+static void svia_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
+{
+	struct ata_taskfile ttf;
+
+	if (tf->ctl != ap->last_ctl)  {
+		ttf = *tf;
+		ttf.flags |= ATA_TFLAG_DEVICE;
+		tf = &ttf;
+	}
+	ata_sff_tf_load(ap, tf);
+}
+
 static void svia_noop_freeze(struct ata_port *ap)
 {
 	/* Some VIA controllers choke if ATA_NIEN is manipulated in

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-10-31  5:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-21 15:45 [PATCH 1/2 #upstream-fixes] sata_via: load DEVICE register when CTL changes Tejun Heo
2008-10-21 15:46 ` [PATCH 1/2 #upstream-fixes] sata_via: fix support for 5287 Tejun Heo
2008-10-26  6:46   ` Tejun Heo
2008-10-31  5:45   ` Jeff Garzik
2008-10-23  0:43 ` [PATCH 1/2 #upstream-fixes] sata_via: load DEVICE register when CTL changes Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).