linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pata_ixp4xx_cf: support single chip-select operation
@ 2008-03-06  5:19 Hamish Moffatt
  2008-03-11  0:51 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Hamish Moffatt @ 2008-03-06  5:19 UTC (permalink / raw)
  To: linux-ide

Compact flash cards require two chip selects, and pata_ixp4xx_cf
currently maps these to two IXP4XX chip selects. On our board we use a
single IXP4XX CS line and decode an address line to split it into two.

This patch allows this by allowing you to specify the second CS region
as an offset from the first.

Signed-off-by: Hamish Moffatt <hamish@cloud.net.au>

Index: 2.6.24/drivers/ata/pata_ixp4xx_cf.c
===================================================================
--- 2.6.24/drivers/ata/pata_ixp4xx_cf.c	(revision 3791)
+++ 2.6.24/drivers/ata/pata_ixp4xx_cf.c	(working copy)
@@ -178,11 +178,13 @@ static __devinit int ixp4xx_pata_probe(s
 	struct ata_host *host;
 	struct ata_port *ap;
 	struct ixp4xx_pata_data *data = pdev->dev.platform_data;
+	unsigned long raw_cs1, cs1_offset;
 
 	cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	cs1_offset = data->cs1_offset;
 
-	if (!cs0 || !cs1)
+	if (!cs0 || (!cs1 && !cs1_offset))
 		return -EINVAL;
 
 	/* allocate host */
@@ -193,19 +195,28 @@ static __devinit int ixp4xx_pata_probe(s
 	/* acquire resources and fill host */
 	pdev->dev.coherent_dma_mask = DMA_32BIT_MASK;
 
-	data->cs0 = devm_ioremap(&pdev->dev, cs0->start, 0x1000);
-	data->cs1 = devm_ioremap(&pdev->dev, cs1->start, 0x1000);
-
-	if (!data->cs0 || !data->cs1)
+	data->cs0 = devm_ioremap(&pdev->dev, cs0->start, (cs1_offset + 0x8 + PAGE_SIZE - 1) & PAGE_MASK);
+	if (!data->cs0)
 		return -ENOMEM;
 
+	if (cs1) {
+		data->cs1 = devm_ioremap(&pdev->dev, cs1->start, PAGE_SIZE);
+		if (!data->cs1)
+			return -ENOMEM;
+		raw_cs1 = cs1->start;
+	} else {
+		data->cs1 = data->cs0 + cs1_offset;
+		raw_cs1 = cs0->start + cs1_offset;
+	}
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq)
 		set_irq_type(irq, IRQT_RISING);
 
 	/* Setup expansion bus chip selects */
 	*data->cs0_cfg = data->cs0_bits;
-	*data->cs1_cfg = data->cs1_bits;
+	if (data->cs1_bits & IXP4XX_EXP_BUS_CS_EN)
+		*data->cs1_cfg = data->cs1_bits;
 
 	ap = host->ports[0];
 
@@ -213,7 +224,7 @@ static __devinit int ixp4xx_pata_probe(s
 	ap->pio_mask = 0x1f; /* PIO4 */
 	ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY | ATA_FLAG_NO_ATAPI;
 
-	ixp4xx_setup_port(ap, data, cs0->start, cs1->start);
+	ixp4xx_setup_port(ap, data, cs0->start, raw_cs1);
 
 	dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
 
Index: 2.6.24/include/asm-arm/arch-ixp4xx/platform.h
===================================================================
--- 2.6.24/include/asm-arm/arch-ixp4xx/platform.h	(revision 3791)
+++ 2.6.24/include/asm-arm/arch-ixp4xx/platform.h	(working copy)
@@ -98,6 +98,7 @@ struct ixp4xx_pata_data {
 	unsigned long	cs1_bits;
 	void __iomem	*cs0;
 	void __iomem	*cs1;
+	unsigned long	cs1_offset;
 };
 
 struct ixp4xx_ide_port {
-- 
Hamish Moffatt VK3SB <hamish@debian.org> <hamish@cloud.net.au>

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

end of thread, other threads:[~2008-03-11  0:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-06  5:19 [PATCH] pata_ixp4xx_cf: support single chip-select operation Hamish Moffatt
2008-03-11  0:51 ` 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).