linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix pata-rb532-cf
@ 2008-11-17 20:04 Phil Sutter
  2008-11-17 20:04 ` [PATCH] pata-rb532-cf: fix signature of the xfer function Phil Sutter
  0 siblings, 1 reply; 25+ messages in thread
From: Phil Sutter @ 2008-11-17 20:04 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-ide

Hi,

I applied the latest comments to my set of changes for pata-rb532-cf, i.e.:
* add missing Acket-by statements
* switch order of the last two patches
* have some cosmetics for the 4-byte-blocks patch

The rb532_gpio_set_i{level,stat} symbols aren't upstream yet, though
Ralf Baechle has the according patch in his linux-mips tree (branch
master), so they should be available soon.

Greetings, Phil

---
After applying the following changes I could verify functionality by
mounting a filesystem on the cfdisk and reading/writing files in it.

The set_irq_type() function must be wrong, as there is no set_type()
function defined for the rb532 IRQ chip. But as the used IRQ actually is
being triggered by a GPIO, setting it's interrupt level should be the
right alternative. Also to clear a GPIO triggered IRQ, the source has to
be cleared. This is being done at the end of rb532_pata_irq_handler.

Signed-off-by: Phil Sutter <n0-1@freewrt.org>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Florian Fainelli <florian@openwrt.org>
---
 drivers/ata/pata_rb532_cf.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index f8b3ffc..7b11f40 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -31,6 +31,7 @@
 #include <scsi/scsi_host.h>
 
 #include <asm/gpio.h>
+#include <asm/mach-rc32434/gpio.h>
 
 #define DRV_NAME	"pata-rb532-cf"
 #define DRV_VERSION	"0.1.0"
@@ -39,7 +40,8 @@
 #define RB500_CF_MAXPORTS	1
 #define RB500_CF_IO_DELAY	400
 
-#define RB500_CF_REG_CMD	0x0800
+#define RB500_CF_REG_BASE	0x0800
+#define RB500_CF_REG_ERR	0x080D
 #define RB500_CF_REG_CTRL	0x080E
 #define RB500_CF_REG_DATA	0x0C00
 
@@ -62,7 +64,7 @@ static inline void rb532_pata_finish_io(struct ata_port *ap)
 	ata_sff_dma_pause(ap);
 	ndelay(RB500_CF_IO_DELAY);
 
-	set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH);
+	rb532_gpio_set_ilevel(1, info->gpio_line);
 }
 
 static void rb532_pata_exec_command(struct ata_port *ap,
@@ -109,13 +111,15 @@ static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance)
 	struct rb532_cf_info *info = ah->private_data;
 
 	if (gpio_get_value(info->gpio_line)) {
-		set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW);
+		rb532_gpio_set_ilevel(0, info->gpio_line);
 		if (!info->frozen)
 			ata_sff_interrupt(info->irq, dev_instance);
 	} else {
-		set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH);
+		rb532_gpio_set_ilevel(1, info->gpio_line);
 	}
 
+	rb532_gpio_set_istat(0, info->gpio_line);
+
 	return IRQ_HANDLED;
 }
 
@@ -146,13 +150,14 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
 	ap->pio_mask	= 0x1f; /* PIO4 */
 	ap->flags	= ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO;
 
-	ap->ioaddr.cmd_addr	= info->iobase + RB500_CF_REG_CMD;
+	ap->ioaddr.cmd_addr	= info->iobase + RB500_CF_REG_BASE;
 	ap->ioaddr.ctl_addr	= info->iobase + RB500_CF_REG_CTRL;
 	ap->ioaddr.altstatus_addr = info->iobase + RB500_CF_REG_CTRL;
 
 	ata_sff_std_ports(&ap->ioaddr);
 
 	ap->ioaddr.data_addr	= info->iobase + RB500_CF_REG_DATA;
+	ap->ioaddr.error_addr	= info->iobase + RB500_CF_REG_ERR;
 }
 
 static __devinit int rb532_pata_driver_probe(struct platform_device *pdev)
-- 
1.5.6.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread
* [PATCH] pata-rb532-cf: read/write data in 4-byte blocks
@ 2008-11-12  0:13 Phil Sutter
  2008-11-12  0:14 ` [PATCH] pata-rb532-cf: fix signature of the xfer function Phil Sutter
  0 siblings, 1 reply; 25+ messages in thread
From: Phil Sutter @ 2008-11-12  0:13 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, Florian Fainelli

* rename the offset definition to avoid abiguity with the standard ATA
  IO address
* read and write four bytes at once like the original driver does
* use writesl() and readsl() which implicitly iterate over the data

This patch assumes buflen to be a multiple of four, which is true for
ATA devices. ATAPI support is not known, though unlikely, as the
original driver always transfers 512 Bytes at once.

Signed-off-by: Phil Sutter <n0-1@freewrt.org>
Acked-by: Sergei Shtyltov <sshtylyov@ru.mvista.com>
---
 drivers/ata/pata_rb532_cf.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index 7b11f40..b919012 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -43,7 +43,8 @@
 #define RB500_CF_REG_BASE	0x0800
 #define RB500_CF_REG_ERR	0x080D
 #define RB500_CF_REG_CTRL	0x080E
-#define RB500_CF_REG_DATA	0x0C00
+/* 32bit buffered data register offset */
+#define RB500_CF_REG_DBUF32	0x0C00
 
 struct rb532_cf_info {
 	void __iomem	*iobase;
@@ -74,19 +75,16 @@ static void rb532_pata_exec_command(struct ata_port *ap,
 	rb532_pata_finish_io(ap);
 }
 
-static void rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf,
-				unsigned int buflen, int write_data)
+static void rb532_pata_data_xfer(struct ata_device *adev,
+		unsigned char *buf, unsigned int buflen, int write_data)
 {
 	struct ata_port *ap = adev->link->ap;
 	void __iomem *ioaddr = ap->ioaddr.data_addr;
 
-	if (write_data) {
-		for (; buflen > 0; buflen--, buf++)
-			writeb(*buf, ioaddr);
-	} else {
-		for (; buflen > 0; buflen--, buf++)
-			*buf = readb(ioaddr);
-	}
+	if (write_data)
+		writesl(ioaddr, buf, buflen / sizeof(u32));
+	else
+		readsl(ioaddr, buf, buflen / sizeof(u32));
 
 	rb532_pata_finish_io(adev->link->ap);
 }
@@ -156,7 +154,7 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
 
 	ata_sff_std_ports(&ap->ioaddr);
 
-	ap->ioaddr.data_addr	= info->iobase + RB500_CF_REG_DATA;
+	ap->ioaddr.data_addr	= info->iobase + RB500_CF_REG_DBUF32;
 	ap->ioaddr.error_addr	= info->iobase + RB500_CF_REG_ERR;
 }
 
-- 
1.5.6.4


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

end of thread, other threads:[~2009-02-03  4:19 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200811202002.16178.david-b@pacbell.net>
2008-11-28 19:35 ` MIPS: RB532: Provide functions for gpio configuration Phil Sutter
2008-11-28 19:48   ` [PATCH] pata-rb532-cf: fix and rename register definitions Phil Sutter
2008-12-01 19:24     ` Jeff Garzik
2008-11-28 19:48   ` [PATCH] pata-rb532-cf: fix signature of the xfer function Phil Sutter
2008-12-01 19:24     ` Jeff Garzik
2008-11-28 19:48   ` [PATCH] pata-rb532-cf: read/write data in 4-byte blocks Phil Sutter
2009-01-20 16:40     ` review of pata-rb532-cf Phil Sutter
2009-01-24 14:12       ` Bartlomiej Zolnierkiewicz
     [not found]     ` <1232469660-22335-1-git-send-email-n0-1@freewrt.org>
2009-01-20 16:40       ` [PATCH 1/5] pata-rb532-cf: remove set_irq_type from finish_io Phil Sutter
2009-01-27  7:13         ` Jeff Garzik
     [not found]       ` <1232469660-22335-2-git-send-email-n0-1@freewrt.org>
2009-01-20 16:40         ` [PATCH 2/5] pata-rb532-cf: replace rb532_pata_finish_io() Phil Sutter
2009-01-27  7:14           ` Jeff Garzik
2009-01-27 13:36             ` Phil Sutter
2009-01-27 13:35               ` Phil Sutter
2009-02-03  4:19                 ` Jeff Garzik
     [not found]               ` <1233063353-12770-1-git-send-email-n0-1@freewrt.org>
2009-01-27 13:35                 ` [PATCH 3/5] pata-rb532-cf: use ata_sff_exec_command() Phil Sutter
     [not found]                 ` <1233063353-12770-2-git-send-email-n0-1@freewrt.org>
2009-01-27 13:35                   ` [PATCH 4/5] pata-rb532-cf: use ata_sff_data_xfer32() Phil Sutter
     [not found]                   ` <1233063353-12770-3-git-send-email-n0-1@freewrt.org>
2009-01-27 13:35                     ` [PATCH 5/5] pata-rb532-cf: drop custom freeze and thaw Phil Sutter
     [not found]         ` <1232469660-22335-3-git-send-email-n0-1@freewrt.org>
2009-01-20 16:40           ` [PATCH 3/5] pata-rb532-cf: use ata_sff_exec_command() Phil Sutter
     [not found]           ` <1232469660-22335-4-git-send-email-n0-1@freewrt.org>
2009-01-20 16:40             ` [PATCH 4/5] pata-rb532-cf: use ata_sff_data_xfer32() Phil Sutter
     [not found]             ` <1232469660-22335-5-git-send-email-n0-1@freewrt.org>
2009-01-20 16:41               ` [PATCH 5/5] pata-rb532-cf: drop custom freeze and thaw Phil Sutter
2008-11-17 20:04 [PATCH] fix pata-rb532-cf Phil Sutter
2008-11-17 20:04 ` [PATCH] pata-rb532-cf: fix signature of the xfer function Phil Sutter
  -- strict thread matches above, loose matches on Subject: below --
2008-11-12  0:13 [PATCH] pata-rb532-cf: read/write data in 4-byte blocks Phil Sutter
2008-11-12  0:14 ` [PATCH] pata-rb532-cf: fix signature of the xfer function Phil Sutter
2008-11-12  2:26   ` Florian Fainelli
2008-11-12 10:54   ` Sergei Shtylyov

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).