[PATCH 2.6.20-rc4 1/2] sata_promise: TX2plus PATA support

STALE7149d

3 messages, 2 authors, 2007-01-09 · open the first message on its own page

[PATCH 2.6.20-rc4 1/2] sata_promise: TX2plus PATA support

From: Mikael Pettersson <hidden>
Date: 2007-01-09 09:50:53

This patch implements a simple way of setting up per-port
flags on the SATA+PATA Promise TX2plus chips, which is a
prerequisite for supporting the PATA port on those chips.

It is based on the observation that ap->flags isn't really
used until after ->port_start() has been invoked. So it
places the "exceptional" per-port flags array in the driver's
private host structure, and uses it in ->port_start() to
finalise the port's flags.

This patch obsoletes the #promise-sata-pata branch included
in the #all branch.

Signed-off-by: Mikael Pettersson <redacted>

---

Changes since the RFC version:
- check cable type not ATA_FLAG_SLAVE_POSS in ->scr_read and ->scr_write

diff -rupN linux-2.6.20-rc4/drivers/ata/sata_promise.c linux-2.6.20-rc4.sata_promise-pata-20x7x-v3/drivers/ata/sata_promise.c
--- linux-2.6.20-rc4/drivers/ata/sata_promise.c	2007-01-08 20:42:55.000000000 +0100
+++ linux-2.6.20-rc4.sata_promise-pata-20x7x-v3/drivers/ata/sata_promise.c	2007-01-09 09:35:25.000000000 +0100
@@ -92,6 +92,7 @@ struct pdc_port_priv {
 
 struct pdc_host_priv {
 	unsigned long		flags;
+	unsigned long		port_flags[ATA_MAX_PORTS];
 };
 
 static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg);
@@ -183,7 +184,7 @@ static const struct ata_port_info pdc_po
 	/* board_2037x */
 	{
 		.sht		= &pdc_ata_sht,
-		.flags		= PDC_COMMON_FLAGS | ATA_FLAG_SATA,
+		.flags		= PDC_COMMON_FLAGS,
 		.pio_mask	= 0x1f, /* pio0-4 */
 		.mwdma_mask	= 0x07, /* mwdma0-2 */
 		.udma_mask	= 0x7f, /* udma0-6 ; FIXME */
@@ -213,7 +214,7 @@ static const struct ata_port_info pdc_po
 	/* board_2057x */
 	{
 		.sht		= &pdc_ata_sht,
-		.flags		= PDC_COMMON_FLAGS | ATA_FLAG_SATA,
+		.flags		= PDC_COMMON_FLAGS,
 		.pio_mask	= 0x1f, /* pio0-4 */
 		.mwdma_mask	= 0x07, /* mwdma0-2 */
 		.udma_mask	= 0x7f, /* udma0-6 ; FIXME */
@@ -271,6 +272,11 @@ static int pdc_port_start(struct ata_por
 	struct pdc_port_priv *pp;
 	int rc;
 
+	/* fix up port flags and cable type for SATA+PATA chips */
+	ap->flags |= hp->port_flags[ap->port_no];
+	if (ap->flags & ATA_FLAG_SATA)
+		ap->cbl = ATA_CBL_SATA;
+
 	rc = ata_port_start(ap);
 	if (rc)
 		return rc;
@@ -377,7 +383,7 @@ static void pdc_pata_phy_reset(struct at
 
 static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
-	if (sc_reg > SCR_CONTROL)
+	if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA)
 		return 0xffffffffU;
 	return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
 }
@@ -386,7 +392,7 @@ static u32 pdc_sata_scr_read (struct ata
 static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
 			       u32 val)
 {
-	if (sc_reg > SCR_CONTROL)
+	if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA)
 		return;
 	writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
 }
@@ -740,6 +746,7 @@ static int pdc_ata_init_one (struct pci_
 	unsigned int board_idx = (unsigned int) ent->driver_data;
 	int pci_dev_busy = 0;
 	int rc;
+	u8 tmp;
 
 	if (!printed_version++)
 		dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
@@ -820,7 +827,17 @@ static int pdc_ata_init_one (struct pci_
 		hp->flags |= PDC_FLAG_GEN_II;
 		/* Fall through */
 	case board_2037x:
-		probe_ent->n_ports = 2;
+		/* TX2plus boards also have a PATA port */
+		tmp = readb(mmio_base + PDC_FLASH_CTL+1);
+		if (!(tmp & 0x80)) {
+			probe_ent->n_ports = 3;
+			pdc_ata_setup_port(&probe_ent->port[2], base + 0x300);
+			hp->port_flags[2] = ATA_FLAG_SLAVE_POSS;
+			printk(KERN_INFO DRV_NAME " PATA port found\n");
+		} else
+			probe_ent->n_ports = 2;
+		hp->port_flags[0] = ATA_FLAG_SATA;
+		hp->port_flags[1] = ATA_FLAG_SATA;
 		break;
 	case board_20619:
 		probe_ent->n_ports = 4;

Re: [PATCH 2.6.20-rc4 1/2] sata_promise: TX2plus PATA support

From: Jeff Garzik <hidden>
Date: 2007-01-09 10:12:50

Mikael Pettersson wrote:
This patch implements a simple way of setting up per-port
flags on the SATA+PATA Promise TX2plus chips, which is a
prerequisite for supporting the PATA port on those chips.

It is based on the observation that ap->flags isn't really
used until after ->port_start() has been invoked. So it
places the "exceptional" per-port flags array in the driver's
private host structure, and uses it in ->port_start() to
finalise the port's flags.

This patch obsoletes the #promise-sata-pata branch included
in the #all branch.

Signed-off-by: Mikael Pettersson <redacted>
applied patches 1-2 to #upstream.  minor follow-up comments follow in 
separate emails.

Thanks a bunch for working on this, sata_promise has needed some "love" 
for quite a while.

Any chance you could be talked to becoming "official" sata_promise 
maintainer, by sending in a patch to MAINTAINERS?

One open issue that remains is port enumeration order.  Bug reports 
consistently indicate that the ports are numbered on the board (visible 
to the naked eye) in a different manner than how the chip enumerates 
each port.  According to the bug reports, Promise's driver enumerates 
the ports in the correct order.

	Jeff


Re: [PATCH 2.6.20-rc4 1/2] sata_promise: TX2plus PATA support

From: Jeff Garzik <hidden>
Date: 2007-01-09 10:16:12

Mikael Pettersson wrote:
quoted hunk
@@ -271,6 +272,11 @@ static int pdc_port_start(struct ata_por
 	struct pdc_port_priv *pp;
 	int rc;
 
+	/* fix up port flags and cable type for SATA+PATA chips */
+	ap->flags |= hp->port_flags[ap->port_no];
+	if (ap->flags & ATA_FLAG_SATA)
+		ap->cbl = ATA_CBL_SATA;
+
 	rc = ata_port_start(ap);
 	if (rc)
 		return rc;
@@ -377,7 +383,7 @@ static void pdc_pata_phy_reset(struct at
 
 static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
-	if (sc_reg > SCR_CONTROL)
+	if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA)
 		return 0xffffffffU;
 	return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
 }
@@ -386,7 +392,7 @@ static u32 pdc_sata_scr_read (struct ata
 static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
 			       u32 val)
 {
-	if (sc_reg > SCR_CONTROL)
+	if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA)
 		return;
 	writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
 }

It would be nice to see a [tested] follow-up patch that separates SATA 
and PATA into two separate sets of ata_port_operations hooks.  That 
should eliminate these 'ap->cbl' tests, and some other tests.

You should be able to set ap->ops in the same manner as you are setting 
the flags now.

	Jeff

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help