All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix pata-rb532-cf
@ 2008-10-30 21:47 Phil Sutter
  2008-10-30 22:39 ` Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: Phil Sutter @ 2008-10-30 21:47 UTC (permalink / raw)
  To: linux-ide; +Cc: Florian Fainelli

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

The symbols rb532_gpio_set_ilevel and rb532_gpio_set_istat are not yet
available in a vanilla kernel, an appropriate patch has already been
sent to the linux-mips mailinglist.

Signed-off-by: Phil Sutter <n0-1@freewrt.org>
---
 drivers/ata/pata_rb532_cf.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index f8b3ffc..a8b3c3a 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -39,9 +39,14 @@
 #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_CTRL	0x080E
 #define RB500_CF_REG_DATA	0x0C00
+#define RB500_CF_REG_ERR	0x080D
+
+/* exported in arch/mips/rb532/gpio.c */
+extern void rb532_gpio_set_ilevel(int bit, unsigned gpio);
+extern void rb532_gpio_set_istat(int bit, unsigned gpio);
 
 struct rb532_cf_info {
 	void __iomem	*iobase;
@@ -62,21 +67,23 @@ 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,
 				const struct ata_taskfile *tf)
 {
+
 	writeb(tf->command, ap->ioaddr.command_addr);
 	rb532_pata_finish_io(ap);
 }
 
-static void rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf,
+static unsigned int 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;
+	unsigned int ret = buflen;
 
 	if (write_data) {
 		for (; buflen > 0; buflen--, buf++)
@@ -87,6 +94,8 @@ static void rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf,
 	}
 
 	rb532_pata_finish_io(adev->link->ap);
+
+	return ret;
 }
 
 static void rb532_pata_freeze(struct ata_port *ap)
@@ -109,13 +118,16 @@ 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,12 +158,13 @@ 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.error_addr	= info->iobase + RB500_CF_REG_ERR;
 	ap->ioaddr.data_addr	= info->iobase + RB500_CF_REG_DATA;
 }
 
-- 
1.5.6.4


^ permalink raw reply related	[flat|nested] 39+ messages in thread
* [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; 39+ 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] 39+ messages in thread
* Re: MIPS: RB532: Provide functions for gpio configuration
@ 2008-11-28 19:35 Phil Sutter
  2008-11-28 19:48 ` [PATCH] pata-rb532-cf: read/write data in 4-byte blocks Phil Sutter
  0 siblings, 1 reply; 39+ messages in thread
From: Phil Sutter @ 2008-11-28 19:35 UTC (permalink / raw)
  To: David Brownell
  Cc: Ralf Baechle, linux-mips, linux-ide, Jeff Garzik,
	Bartlomiej Zolnierkiewicz

Hi!

I fullquote here because of the lists and people added to Cc.

On Thu, Nov 20, 2008 at 08:02:15PM -0800, David Brownell wrote:
> I just noticed:
> 
> > commit 2e373952cc893207a8b47a5e68c2f5155f912449
> > Author: Phil Sutter <n0-1@freewrt.org>
> > Date:   Sat Nov 1 15:13:21 2008 +0100
> >
> >     MIPS: RB532: Provide functions for gpio configuration
> >
> >     As gpiolib doesn't support pin multiplexing, it provides no way to
> >     access the GPIOFUNC register. Also there is no support for setting
> >     interrupt status and level. These functions provide access to them and
> >     are needed by the CompactFlash driver.
> >
> >     Signed-off-by: Phil Sutter <n0-1@freewrt.org>
> >     Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
> 
> The conventional way to do most of that is through the irq_chip
> associated with that block of IRQ-capable GPIOs.
> 
> 
> So ...
> 
> > -       /* Set the interrupt status and level for the CF pin */
> > -       rb532_gpio_set_int_level(&rb532_gpio_chip->chip, CF_GPIO_NUM, 1);
> > -       rb532_gpio_set_int_status(&rb532_gpio_chip->chip, CF_GPIO_NUM, 0);
> > +       /* configure CF_GPIO_NUM as CFRDY IRQ source */
> > +       rb532_gpio_set_func(0, CF_GPIO_NUM);
> 
> ... the pinmux would indeed be a SOC-specific mechanism, kicked in
> only for boards that use that GPIO in that way, but ...
> 
> 
> > +       rb532_gpio_direction_input(&rb532_gpio_chip->chip, CF_GPIO_NUM);
> 
> ... normal gpio_request() + gpio_direction_input() would set the pin up, and ...
> 
> 
> > +       rb532_gpio_set_ilevel(1, CF_GPIO_NUM);
> > +       rb532_gpio_set_istat(0, CF_GPIO_NUM);
> 
> 	status = request_irq(gpio_to_irq(CF_GPIO_NUM), ... )
> 
> with appropriate IRQF_TRIGGER_* flags should solve that problem.
> Or even just set_irq_type().  (At least for one of the two
> registers updated there ... I can't guess what "istat" would be.)
> 
> Just FYI at this point.  Maybe you have a reason not to fit into
> the genirq framework.
> 
> - Dave

Thanks for your hints, Dave. I already had a patch flying around adding
a set_type() function to the irq_chip (merely a dummy to shut up
warnings in the boot log). After extending it to cover the needs of the
mapped GPIO pins and some other work, I could drop that CompactFlash
initialisation code in gpio.c completely.

As a side effect, many of my changes to pata-rb532-cf got unnecessary
which I consider a very good sign.

I'll reply to this mail with the relevant patches for each list and
maintainer. 

Greetings, Phil

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

end of thread, other threads:[~2009-01-12 17:45 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-30 21:47 [PATCH] fix pata-rb532-cf Phil Sutter
2008-10-30 22:39 ` Florian Fainelli
2008-10-30 23:20 ` Sergei Shtylyov
2008-10-31  0:09   ` Phil Sutter
2008-10-31 10:38     ` Sergei Shtylyov
2008-10-31 11:08       ` Sergei Shtylyov
2008-11-01 16:09       ` Phil Sutter
2008-11-01 16:12         ` Phil Sutter
2008-11-01 16:26           ` Sergei Shtylyov
2008-11-01 16:45             ` Sergei Shtylyov
2008-11-01 16:45             ` Phil Sutter
2008-11-01 18:09               ` Phil Sutter
2008-11-01 18:11                 ` [PATCH] read and write data in 4-byte blocks Phil Sutter
2008-11-01 18:21                   ` Phil Sutter
2008-11-02 21:23                     ` Sergei Shtylyov
2008-11-03 13:29                       ` [PATCH] pata-rb532-cf: " Phil Sutter
2008-11-03 13:45                         ` Bartlomiej Zolnierkiewicz
2008-11-04  6:01                         ` Jeff Garzik
2008-11-04 12:35                           ` Phil Sutter
2008-11-05 11:54                             ` Sergei Shtylyov
2008-11-05 12:52                               ` Phil Sutter
2008-11-02 22:04                 ` [PATCH] fix pata-rb532-cf Sergei Shtylyov
2008-11-02 22:45                   ` Phil Sutter
2008-11-01 16:16         ` Sergei Shtylyov
2008-11-12  0:13 ` Phil Sutter
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
2008-11-12  2:25     ` [PATCH] pata-rb532-cf: read/write data in 4-byte blocks Florian Fainelli
2008-11-12 10:50     ` Sergei Shtylyov
2008-11-12 20:57   ` [PATCH] fix pata-rb532-cf Bartlomiej Zolnierkiewicz
2008-11-14 23:53   ` Jeff Garzik
2009-01-11 16:13     ` Florian Fainelli
2009-01-11 20:47       ` Phil Sutter
2009-01-12 14:32         ` Florian Fainelli
2009-01-12 17:48           ` Phil Sutter
  -- strict thread matches above, loose matches on Subject: below --
2008-11-17 20:04 Phil Sutter
2008-11-17 20:04 ` [PATCH] pata-rb532-cf: fix signature of the xfer function Phil Sutter
2008-11-17 20:04   ` [PATCH] pata-rb532-cf: read/write data in 4-byte blocks Phil Sutter
2008-11-28 19:35 MIPS: RB532: Provide functions for gpio configuration Phil Sutter
2008-11-28 19:48 ` [PATCH] pata-rb532-cf: read/write data in 4-byte blocks Phil Sutter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.