Skip to contentSkip to conversation

Pata support on Promise controller under Fedora Core 3

PATCH James C. Bevier 2 participants 3 messages Oct 25, 2004 – Oct 26, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Jeff,

I cut out the attached patch from the sata_promise dev patches on kernel.org. I put it in the latest kernel in Fedora Core 3 RC1. It is version 2.6.9-1.640 kernel. It works well enough to be able to see the first PATA drive on the Promise controller. It does not see the second drive. The code only seems to work for one drive. Could you (or Erik) provide the rest of the code that will see the second drive. If you could point me to specs for the controller or give me the register offset for the last drive, I could try to hack at it myself. I really need this to work in Fedora Core 3.

Thanks for your help!

Jim Bevier

BK users:

bk pull bk://gkernel.bkbits.net/libata-dev-2.6

This will update the following files:

 drivers/scsi/sata_promise.c  |   56 ++

/include/linux/libata.h

<erikbenada:yahoo.ca>:
o [libata sata_promise] support PATA ports on SATA controllers

drivers/scsi/sata_promise.c +53 -3
diff -Nru a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
@@ -79,6 +79,8 @@
 static int pdc_port_start(struct ata_port *ap);
 static void pdc_port_stop(struct ata_port *ap);
 static void pdc_phy_reset(struct ata_port *ap);
+static void pdc_pata_phy_reset(struct ata_port *ap);
+static void pdc_pata_cbl_detect(struct ata_port *ap);
 static void pdc_qc_prep(struct ata_queued_cmd *qc);
 static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf);
 static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf);
@@ -127,7 +129,7 @@
 	/* board_2037x */
 	{
 		.sht		= &pdc_sata_sht,
-		.host_flags	= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+		.host_flags	= /* ATA_FLAG_SATA | */ ATA_FLAG_NO_LEGACY |
 				  ATA_FLAG_SRST | ATA_FLAG_MMIO,
 		.pio_mask	= 0x1f, /* pio0-4 */
 		.mwdma_mask	= 0x07, /* mwdma0-2 */
@@ -244,7 +246,35 @@
 static void pdc_phy_reset(struct ata_port *ap)
 {
 	pdc_reset_port(ap);
-	sata_phy_reset(ap);
+	if (ap->flags & ATA_FLAG_SATA)
+		sata_phy_reset(ap);
+	else
+		pdc_pata_phy_reset(ap);
+}
+
+static void pdc_pata_cbl_detect(struct ata_port *ap)
+{
+	u8 tmp;
+	void *mmio = (void *) ap->ioaddr.cmd_addr + PDC_CTLSTAT + 0x03;
+
+	tmp = readb(mmio);
+	
+	if (tmp & 0x01)
+	{
+		ap->cbl = ATA_CBL_PATA40;
+		ap->udma_mask &= ATA_UDMA_MASK_40C;
+	}
+	else
+		ap->cbl = ATA_CBL_PATA80;
+}
+		
+static void pdc_pata_phy_reset(struct ata_port *ap)
+{
+	pdc_pata_cbl_detect(ap);
+
+	ata_port_probe(ap);
+	
+	ata_bus_reset(ap);
 }
 
 static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
@@ -547,6 +577,7 @@
 	void *mmio_base;
 	unsigned int board_idx = (unsigned int) ent->driver_data;
 	int rc;
+	u8 tmp;
 
 	if (!printed_version++)
 		printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
@@ -605,6 +636,9 @@
 	probe_ent->port[0].scr_addr = base + 0x400;
 	probe_ent->port[1].scr_addr = base + 0x500;
 
+	probe_ent->port_flags[0] = ATA_FLAG_SATA;
+	probe_ent->port_flags[1] = ATA_FLAG_SATA;
+	
 	/* notice 4-port boards */
 	switch (board_idx) {
 	case board_20319:
@@ -615,9 +649,25 @@
 
 		probe_ent->port[2].scr_addr = base + 0x600;
 		probe_ent->port[3].scr_addr = base + 0x700;
+	
+		probe_ent->port_flags[2] = ATA_FLAG_SATA;
+		probe_ent->port_flags[3] = ATA_FLAG_SATA;
 		break;
 	case board_2037x:
-       		probe_ent->n_ports = 2;
+		/* Some boards have also PATA port */
+		tmp = readb(base + PDC_FLASH_CTL+1);
+		if (!(tmp & 0x80))
+		{
+			probe_ent->n_ports = 3;
+			
+			pdc_sata_setup_port(&probe_ent->port[2], base + 0x300);
+			
+			probe_ent->port_flags[2] = ATA_FLAG_SLAVE_POSS;
+			
+			printk(KERN_INFO DRV_NAME " PATA port found\n");
+		}
+		else
+       			probe_ent->n_ports = 2;
 		break;
 	default:
 		BUG();
include/linux/libata.h +1 -0
diff -Nru a/include/linux/libata.h b/include/linux/libata.h
@@ -197,6 +197,7 @@
 	unsigned long		irq;
 	unsigned int		irq_flags;
 	unsigned long		host_flags;
+	unsigned long		port_flags[ATA_MAX_PORTS];
 	void __iomem		*mmio_base;
 	void			*private_data;
 };
#1 lore raw

James,

I don't have any additional code. I quickly tested it on my system (PDC20378) and both drives were recognized.
However, I've got hard lockup after about 1 min. It is with vanilla 2.6.9-rc3, smp, preempt enabled. Didn't have time to investigate further.
Are your drives recognized by BIOS? Also, AFAIK PATA port on 378 supports only ATA (disk) drives, not ATAPI drives (CD/DVD). Is your second drive disk or CD/DVD?

Erik

Quoted 18 lines · --- "James C. Bevier

Jeff,

I cut out the attached patch from the sata_promise dev patches on kernel.org. I
put it in the latest kernel in Fedora Core 3 RC1. It is version 2.6.9-1.640
kernel. It works well enough to be able to see the first PATA drive on the
Promise controller. It does not see the second drive. The code only seems to
work for one drive. Could you (or Erik) provide the rest of the code that will
see the second drive. If you could point me to specs for the controller or give
me the register offset for the last drive, I could try to hack at it myself. I
really need this to work in Fedora Core 3.

Quoted 6 lines

Thanks for your help!

Jim Bevier

ATTACHMENT part 2 application/octet-stream

name=linux-2.6.9-sata_promise.patch

#2 lore raw

Ericisko,

The disks are two identical Western Digital 160 GB drives. They are seen by Windows XP and were seen by the Promise driver under Linux 2.4. I have the BIOS set on the K8V SE Deluxe motherboard to be non-raid disks on the Promise controller. The first drive has two NTFS partitions and the second has three Linux partitions. Hda & hdb are 80 GB drives and hdc & hdd are DVDROM & DVD Writer. I was able to read the NTFS files and did not experience any lock-ups. I have an Athlon64 3200+ and am only running the 64 bit version of Fedora Core 3 RC1.

I will do some more testing to see if I can see the second drive. Thanks for the information.

Jim

----- Original Message ----- From: "Ericisko" <[email protected]>
To: "James C. Bevier" <[email protected]>; "Jeff Garzik" <[email protected]>
Cc: <[email protected]>
Sent: Tuesday, October 26, 2004 4:17 AM
Subject: Re: Pata support on Promise controller under Fedora Core 3

Quoted 34 lines

James,

I don't have any additional code. I quickly tested it on my system (PDC20378) and both drives were recognized.
However, I've got hard lockup after about 1 min. It is with vanilla 2.6.9-rc3, smp, preempt enabled. Didn't have time to investigate further.
Are your drives recognized by BIOS? Also, AFAIK PATA port on 378 supports only ATA (disk) drives, not ATAPI drives (CD/DVD). Is your second drive disk or CD/DVD?

Erik

Quoted 10 lines · --- "James C. Bevier

Jeff,

I cut out the attached patch from the sata_promise
dev patches on kernel.org. I put it in the latest kernel in Fedora Core 3 RC1. It is version 2.6.9-1.640 kernel. It works well enough to be able to see the first PATA drive on the Promise controller. It does not see the second
drive. The code only seems to work for one drive. Could you (or Erik) provide the
rest of the code that will see the second drive. If you could point me to
specs for the controller or give me the register offset for the last drive, I could
try to hack at it myself. I really need this to work in Fedora Core 3.

Quoted 6 lines

Thanks for your help!

Jim Bevier

ATTACHMENT part 2 application/octet-stream

name=linux-2.6.9-sata_promise.patch
)