All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 09/18] ide: add ->set_irq method
Date: Fri, 20 Jun 2008 23:34:24 +0200	[thread overview]
Message-ID: <20080620213424.13202.16889.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080620213323.13202.71450.sendpatchset@localhost.localdomain>

Add ->set_irq method for setting nIEN bit of ATA Device Control
register and use it instead of ide_set_irq().

While at it:

* Use ->set_irq in init_irq() and do_reset1().

* Don't use HWIF() macro in ide_check_pm_state().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-io.c       |   14 ++++++++------
 drivers/ide/ide-iops.c     |   37 +++++++++++++++++++++++++++----------
 drivers/ide/ide-probe.c    |    9 ++++-----
 drivers/ide/ide-taskfile.c |    2 +-
 drivers/ide/pci/scc_pata.c |   19 +++++++++++++++++++
 drivers/ide/ppc/pmac.c     |   17 +++++++++++++++++
 include/linux/ide.h        |   10 ++--------
 7 files changed, 78 insertions(+), 30 deletions(-)

Index: b/drivers/ide/ide-io.c
===================================================================
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -783,16 +783,17 @@ static void ide_check_pm_state(ide_drive
 		 * the bus may be broken enough to walk on our toes at this
 		 * point.
 		 */
+		ide_hwif_t *hwif = drive->hwif;
 		int rc;
 #ifdef DEBUG_PM
 		printk("%s: Wakeup request inited, waiting for !BSY...\n", drive->name);
 #endif
-		rc = ide_wait_not_busy(HWIF(drive), 35000);
+		rc = ide_wait_not_busy(hwif, 35000);
 		if (rc)
 			printk(KERN_WARNING "%s: bus not ready on wakeup\n", drive->name);
 		SELECT_DRIVE(drive);
-		ide_set_irq(drive, 1);
-		rc = ide_wait_not_busy(HWIF(drive), 100000);
+		hwif->set_irq(hwif, 1);
+		rc = ide_wait_not_busy(hwif, 100000);
 		if (rc)
 			printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name);
 	}
@@ -1069,7 +1070,7 @@ static void ide_do_request (ide_hwgroup_
 			 * quirk_list may not like intr setups/cleanups
 			 */
 			if (drive->quirk_list != 1)
-				ide_set_irq(drive, 0);
+				hwif->set_irq(hwif, 0);
 		}
 		hwgroup->hwif = hwif;
 		hwgroup->drive = drive;
@@ -1547,6 +1548,7 @@ EXPORT_SYMBOL(ide_do_drive_cmd);
 
 void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma)
 {
+	ide_hwif_t *hwif = drive->hwif;
 	ide_task_t task;
 
 	memset(&task, 0, sizeof(task));
@@ -1557,9 +1559,9 @@ void ide_pktcmd_tf_load(ide_drive_t *dri
 	task.tf.lbah    = (bcount >> 8) & 0xff;
 
 	ide_tf_dump(drive->name, &task.tf);
-	ide_set_irq(drive, 1);
+	hwif->set_irq(hwif, 1);
 	SELECT_MASK(drive, 0);
-	drive->hwif->tf_load(drive, &task);
+	hwif->tf_load(drive, &task);
 }
 
 EXPORT_SYMBOL_GPL(ide_pktcmd_tf_load);
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -135,6 +135,23 @@ static u8 ide_read_sff_dma_status(ide_hw
 		return inb(hwif->dma_base + ATA_DMA_STATUS);
 }
 
+static void ide_set_irq(ide_hwif_t *hwif, int on)
+{
+	u8 ctl = ATA_DEVCTL_OBS;
+
+	if (on == 4) { /* hack for SRST */
+		ctl |= 4;
+		on &= ~4;
+	}
+
+	ctl |= on ? 0 : 2;
+
+	if (hwif->host_flags & IDE_HFLAG_MMIO)
+		writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr);
+	else
+		outb(ctl, hwif->io_ports.ctl_addr);
+}
+
 static void ide_tf_load(ide_drive_t *drive, ide_task_t *task)
 {
 	ide_hwif_t *hwif = drive->hwif;
@@ -360,6 +377,8 @@ void default_hwif_transport(ide_hwif_t *
 	hwif->read_altstatus	  = ide_read_altstatus;
 	hwif->read_sff_dma_status = ide_read_sff_dma_status;
 
+	hwif->set_irq	  = ide_set_irq;
+
 	hwif->tf_load	  = ide_tf_load;
 	hwif->tf_read	  = ide_tf_read;
 
@@ -722,7 +741,7 @@ int ide_driveid_update(ide_drive_t *driv
 	 */
 
 	SELECT_MASK(drive, 1);
-	ide_set_irq(drive, 1);
+	hwif->set_irq(hwif, 1);
 	msleep(50);
 	hwif->exec_command(hwif, WIN_IDENTIFY);
 	timeout = jiffies + WAIT_WORSTCASE;
@@ -808,12 +827,12 @@ int ide_config_drive_speed(ide_drive_t *
 	SELECT_DRIVE(drive);
 	SELECT_MASK(drive, 0);
 	udelay(1);
-	ide_set_irq(drive, 0);
+	hwif->set_irq(hwif, 0);
 	hwif->OUTB(speed, io_ports->nsect_addr);
 	hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr);
 	hwif->exec_command(hwif, WIN_SETFEATURES);
 	if (drive->quirk_list == 2)
-		ide_set_irq(drive, 1);
+		hwif->set_irq(hwif, 1);
 
 	error = __ide_wait_stat(drive, drive->ready_stat,
 				BUSY_STAT|DRQ_STAT|ERR_STAT,
@@ -1116,7 +1135,6 @@ static ide_startstop_t do_reset1 (ide_dr
 	ide_hwgroup_t *hwgroup;
 	struct ide_io_ports *io_ports;
 	const struct ide_port_ops *port_ops;
-	u8 ctl;
 
 	spin_lock_irqsave(&ide_lock, flags);
 	hwif = HWIF(drive);
@@ -1162,16 +1180,15 @@ static ide_startstop_t do_reset1 (ide_dr
 	 * immediate interrupt due to the edge transition it produces.
 	 * This single interrupt gives us a "fast poll" for drives that
 	 * recover from reset very quickly, saving us the first 50ms wait time.
+	 *
+	 * TODO: add ->softreset method and stop abusing ->set_irq
 	 */
 	/* set SRST and nIEN */
-	hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | 6, io_ports->ctl_addr);
+	hwif->set_irq(hwif, 4);
 	/* more than enough time */
 	udelay(10);
-	if (drive->quirk_list == 2)
-		ctl = ATA_DEVCTL_OBS;		/* clear SRST and nIEN */
-	else
-		ctl = ATA_DEVCTL_OBS | 2;	/* clear SRST, leave nIEN */
-	hwif->OUTBSYNC(hwif, ctl, io_ports->ctl_addr);
+	/* clear SRST, leave nIEN (unless device is on the quirk list) */
+	hwif->set_irq(hwif, drive->quirk_list == 2);
 	/* more than enough time */
 	udelay(10);
 	hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -361,7 +361,7 @@ static int try_to_identify (ide_drive_t 
 			autoprobe = 1;
 			cookie = probe_irq_on();
 		}
-		ide_set_irq(drive, autoprobe);
+		hwif->set_irq(hwif, autoprobe);
 	}
 
 	retval = actual_try_to_identify(drive, cmd);
@@ -369,7 +369,7 @@ static int try_to_identify (ide_drive_t 
 	if (autoprobe) {
 		int irq;
 
-		ide_set_irq(drive, 0);
+		hwif->set_irq(hwif, 0);
 		/* clear drive IRQ */
 		(void)hwif->read_status(hwif);
 		udelay(5);
@@ -711,7 +711,7 @@ static int ide_port_wait_ready(ide_hwif_
 		/* Ignore disks that we will not probe for later. */
 		if (!drive->noprobe || drive->present) {
 			SELECT_DRIVE(drive);
-			ide_set_irq(drive, 1);
+			hwif->set_irq(hwif, 1);
 			mdelay(2);
 			rc = ide_wait_not_busy(hwif, 35000);
 			if (rc)
@@ -1068,8 +1068,7 @@ static int init_irq (ide_hwif_t *hwif)
 			sa = IRQF_SHARED;
 
 		if (io_ports->ctl_addr)
-			/* clear nIEN */
-			hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS, io_ports->ctl_addr);
+			hwif->set_irq(hwif, 1);
 
 		if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup))
 	       		goto out_unlink;
Index: b/drivers/ide/ide-taskfile.c
===================================================================
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -79,7 +79,7 @@ ide_startstop_t do_rw_taskfile (ide_driv
 
 	if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) {
 		ide_tf_dump(drive->name, tf);
-		ide_set_irq(drive, 1);
+		hwif->set_irq(hwif, 1);
 		SELECT_MASK(drive, 0);
 		hwif->tf_load(drive, task);
 	}
Index: b/drivers/ide/pci/scc_pata.c
===================================================================
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -149,6 +149,23 @@ static u8 scc_read_sff_dma_status(ide_hw
 	return (u8)in_be32((void *)(hwif->dma_base + 4));
 }
 
+static void scc_set_irq(ide_hwif_t *hwif, int on)
+{
+	u8 ctl = ATA_DEVCTL_OBS;
+
+	if (on == 4) { /* hack for SRST */
+		ctl |= 4;
+		on &= ~4;
+	}
+
+	ctl |= on ? 0 : 2;
+
+	out_be32((void *)hwif->io_ports.ctl_addr, ctl);
+	eieio();
+	in_be32((void *)(hwif->dma_base + 0x01c));
+	eieio();
+}
+
 static void scc_ide_insw(unsigned long port, void *addr, u32 count)
 {
 	u16 *ptr = (u16 *)addr;
@@ -803,6 +820,8 @@ static void __devinit init_mmio_iops_scc
 	hwif->read_altstatus	  = scc_read_altstatus;
 	hwif->read_sff_dma_status = scc_read_sff_dma_status;
 
+	hwif->set_irq = scc_set_irq;
+
 	hwif->tf_load = scc_tf_load;
 	hwif->tf_read = scc_tf_read;
 
Index: b/drivers/ide/ppc/pmac.c
===================================================================
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -502,6 +502,22 @@ static void pmac_exec_command(ide_hwif_t
 				     + IDE_TIMING_CONFIG));
 }
 
+static void pmac_set_irq(ide_hwif_t *hwif, int on)
+{
+	u8 ctl = ATA_DEVCTL_OBS;
+
+	if (on == 4) { /* hack for SRST */
+		ctl |= 4;
+		on &= ~4;
+	}
+
+	ctl |= on ? 0 : 2;
+
+	writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr);
+	(void)readl((void __iomem *)(hwif->io_ports.data_addr
+				     + IDE_TIMING_CONFIG));
+}
+
 /*
  * Old tuning functions (called on hdparm -p), sets up drive PIO timings
  */
@@ -1094,6 +1110,7 @@ static int __devinit pmac_ide_setup_devi
 		return -ENOENT;
 
 	hwif->exec_command = pmac_exec_command;
+	hwif->set_irq	   = pmac_set_irq;
 
 	/* Setup MMIO ops */
 	default_hwif_mmiops(hwif);
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -473,6 +473,8 @@ typedef struct hwif_s {
 	u8	(*read_altstatus)(struct hwif_s *);
 	u8	(*read_sff_dma_status)(struct hwif_s *);
 
+	void	(*set_irq)(struct hwif_s *, int);
+
 	void (*tf_load)(ide_drive_t *, struct ide_task_s *);
 	void (*tf_read)(ide_drive_t *, struct ide_task_s *);
 
@@ -1342,14 +1344,6 @@ static inline ide_drive_t *ide_get_paire
 	return &hwif->drives[(drive->dn ^ 1) & 1];
 }
 
-static inline void ide_set_irq(ide_drive_t *drive, int on)
-{
-	ide_hwif_t *hwif = drive->hwif;
-
-	hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | (on ? 0 : 2),
-		       hwif->io_ports.ctl_addr);
-}
-
 static inline u8 ide_read_error(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = drive->hwif;

  parent reply	other threads:[~2008-06-20 21:32 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-20 21:33 [PATCH 01/18] ide: add ->read_sff_dma_status method Bartlomiej Zolnierkiewicz
2008-06-20 21:33 ` [PATCH 02/18] ide: use I/O ops directly in ide-dma.c Bartlomiej Zolnierkiewicz
2008-09-08 15:49   ` Sergei Shtylyov
2008-06-20 21:33 ` [PATCH 03/18] ide: remove ->dma_{status,command} fields from ide_hwif_t Bartlomiej Zolnierkiewicz
2008-06-20 21:33 ` [PATCH 04/18] ide: remove ide_setup_dma() Bartlomiej Zolnierkiewicz
2008-06-20 22:03   ` Sergei Shtylyov
2008-06-21 19:06     ` Bartlomiej Zolnierkiewicz
2008-06-21 19:29       ` Sergei Shtylyov
2008-08-21 17:16   ` Sergei Shtylyov
2008-08-21 17:56     ` Sergei Shtylyov
2008-06-20 21:33 ` [PATCH 05/18] ide: factor out simplex handling from ide_pci_dma_base() Bartlomiej Zolnierkiewicz
2008-06-20 21:34 ` [PATCH 06/18] ide: add ->exec_command method Bartlomiej Zolnierkiewicz
2008-06-20 21:34 ` [PATCH 07/18] ide: add ->read_status method Bartlomiej Zolnierkiewicz
2008-06-20 21:34 ` [PATCH 08/18] ide: add ->read_altstatus method Bartlomiej Zolnierkiewicz
2008-06-20 21:34 ` Bartlomiej Zolnierkiewicz [this message]
2008-10-15 12:20   ` [PATCH 09/18] ide: add ->set_irq method Sergei Shtylyov
2008-10-15 18:22     ` Bartlomiej Zolnierkiewicz
2008-10-15 21:22       ` Sergei Shtylyov
2008-06-20 21:34 ` [PATCH 10/18] ide: change order of register access in ide_config_drive_speed() Bartlomiej Zolnierkiewicz
2008-06-20 21:34 ` [PATCH 11/18] ide: use ->tf_load " Bartlomiej Zolnierkiewicz
2008-06-20 21:34 ` [PATCH 12/18] ide: use ->tf_load in actual_try_to_identify() Bartlomiej Zolnierkiewicz
2008-06-20 23:14   ` Sergei Shtylyov
2008-06-21 19:10     ` Bartlomiej Zolnierkiewicz
2008-06-20 21:34 ` [PATCH 13/18] ide: use ->tf_load in SELECT_DRIVE() Bartlomiej Zolnierkiewicz
2009-02-15 20:25   ` Sergei Shtylyov
2009-02-16  0:08     ` Sergei Shtylyov
2009-02-16 11:50       ` Sergei Shtylyov
2009-02-16 21:51         ` Bartlomiej Zolnierkiewicz
2009-02-17  1:04           ` Sergei Shtylyov
2009-02-17 14:43             ` Bartlomiej Zolnierkiewicz
2009-02-17 15:32               ` Sergei Shtylyov
2009-03-04 15:43                 ` Sergei Shtylyov
2009-02-17 12:23       ` Sergei Shtylyov
2009-02-17 15:13         ` Sergei Shtylyov
2008-06-20 21:34 ` [PATCH 14/18] ide: use ->tf_read in ide_read_error() Bartlomiej Zolnierkiewicz
2009-02-15 23:21   ` Sergei Shtylyov
2009-02-16 12:13     ` Sergei Shtylyov
2009-02-16 12:25       ` Sergei Shtylyov
2009-02-16 21:17         ` Bartlomiej Zolnierkiewicz
2009-02-17  0:14           ` Sergei Shtylyov
2009-02-17  0:50             ` Sergei Shtylyov
2008-06-20 21:35 ` [PATCH 15/18] ide: add ide_read_device() helper Bartlomiej Zolnierkiewicz
2008-06-20 21:35 ` [PATCH 16/18] ide: add ide_read_ireason() helper Bartlomiej Zolnierkiewicz
2008-06-20 21:35 ` [PATCH 17/18] ide: add ide_read_bcount_and_ireason() helper Bartlomiej Zolnierkiewicz
2008-06-20 21:35 ` [PATCH 18/18] ide: remove ->INB, ->OUTB and ->OUTBSYNC methods Bartlomiej Zolnierkiewicz
2008-09-03 13:19 ` [PATCH 01/18] ide: add ->read_sff_dma_status method Sergei Shtylyov
2008-09-03 18:13   ` Bartlomiej Zolnierkiewicz
2008-09-07 18:15     ` Sergei Shtylyov
2008-09-07 18:49       ` Sergei Shtylyov
2008-09-07 19:23       ` Bartlomiej Zolnierkiewicz
2008-09-07 22:26         ` Sergei Shtylyov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080620213424.13202.16889.sendpatchset@localhost.localdomain \
    --to=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.