[PATCH] pata_ixp4xx_cf: support single chip-select operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>

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@xxxxxxxxxx> <hamish@xxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux