linux-ide.vger.kernel.org archive mirror
 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 49/68] cy82c693: convert to ide2libata
Date: Fri, 29 Jan 2010 17:08:23 +0100	[thread overview]
Message-ID: <20100129160823.21495.16081.sendpatchset@localhost> (raw)
In-Reply-To: <20100129160308.21495.14120.sendpatchset@localhost>

From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] cy82c693: convert to ide2libata

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ata/pata_cypress.h |   30 ++++++++--
 drivers/ide/cy82c693.c     |  130 +--------------------------------------------
 2 files changed, 29 insertions(+), 131 deletions(-)

Index: b/drivers/ata/pata_cypress.h
===================================================================
--- a/drivers/ata/pata_cypress.h
+++ b/drivers/ata/pata_cypress.h
@@ -30,12 +30,31 @@ enum {
 
 static void cy82c693_set_piomode(struct ata_port *ap, struct ata_device *adev)
 {
+#ifndef __IDE2LIBATA
 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+	int bus_speed = 33;
+#else
+	struct pci_dev *pdev = ap->port_no ? to_pci_dev(ap->host->dev2)
+					   : to_pci_dev(ap->host->dev);
+	int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
+#endif
+	const unsigned long T = 1000000 / bus_speed;
 	struct ata_timing t;
-	const unsigned long T = 1000000 / 33;
 	short time_16, time_8;
 	u32 addr;
 
+#ifdef __IDE2LIBATA
+	/* select primary or secondary channel */
+	if (ap->port_no > 0) {  /* drive is on the secondary channel */
+		pdev = pci_get_slot(pdev->bus, pdev->devfn + 1);
+		if (!pdev) {
+			printk(KERN_ERR "%s: tune_drive: "
+				"Cannot find secondary interface!\n",
+				adev->name);
+			return;
+		}
+	}
+#endif
 	ata_timing_compute(adev->id, adev->pio_mode, adev->pio_mode, &t, T, 1);
 
 	time_16 = clamp_val(t.recover - 1, 0, 15) |
@@ -79,10 +98,11 @@ static void cy82c693_set_dmamode(struct
 	int reg = CY82_INDEX_CHANNEL0 + ap->port_no;
 
 	/* Be afraid, be very afraid. Magic registers  in low I/O space */
-	outb(reg, 0x22);
-	outb(adev->dma_mode - XFER_MW_DMA_0, 0x23);
+	outb(reg, CY82_INDEX_PORT);
+	outb((adev->dma_mode - XFER_MW_DMA_0) |
+	     ((adev->dma_mode & 0x10) >> 2), CY82_DATA_PORT);
 
 	/* 0x50 gives the best behaviour on the Alpha's using this chip */
-	outb(CY82_INDEX_TIMEOUT, 0x22);
-	outb(0x50, 0x23);
+	outb(CY82_INDEX_TIMEOUT, CY82_INDEX_PORT);
+	outb(0x50, CY82_DATA_PORT);
 }
Index: b/drivers/ide/cy82c693.c
===================================================================
--- a/drivers/ide/cy82c693.c
+++ b/drivers/ide/cy82c693.c
@@ -18,130 +18,8 @@
 
 #define DRV_NAME "cy82c693"
 
-/*
- *	NOTE: the value for busmaster timeout is tricky and I got it by
- *	trial and error!  By using a to low value will cause DMA timeouts
- *	and drop IDE performance, and by using a to high value will cause
- *	audio playback to scatter.
- *	If you know a better value or how to calc it, please let me know.
- */
-
-/* twice the value written in cy82c693ub datasheet */
-#define BUSMASTER_TIMEOUT	0x50
-/*
- * the value above was tested on my machine and it seems to work okay
- */
-
-/* here are the offset definitions for the registers */
-#define CY82_IDE_CMDREG		0x04
-#define CY82_IDE_ADDRSETUP	0x48
-#define CY82_IDE_MASTER_IOR	0x4C
-#define CY82_IDE_MASTER_IOW	0x4D
-#define CY82_IDE_SLAVE_IOR	0x4E
-#define CY82_IDE_SLAVE_IOW	0x4F
-#define CY82_IDE_MASTER_8BIT	0x50
-#define CY82_IDE_SLAVE_8BIT	0x51
-
-#define CY82_INDEX_PORT		0x22
-#define CY82_DATA_PORT		0x23
-
-#define CY82_INDEX_CHANNEL0	0x30
-#define CY82_INDEX_CHANNEL1	0x31
-#define CY82_INDEX_TIMEOUT	0x32
-
-/*
- * set DMA mode a specific channel for CY82C693
- */
-
-static void cy82c693_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
-{
-	const u8 mode = drive->dma_mode;
-	u8 single = (mode & 0x10) >> 4, index = 0, data = 0;
-
-	index = hwif->channel ? CY82_INDEX_CHANNEL1 : CY82_INDEX_CHANNEL0;
-
-	data = (mode & 3) | (single << 2);
-
-	outb(index, CY82_INDEX_PORT);
-	outb(data, CY82_DATA_PORT);
-
-	/*
-	 * note: below we set the value for Bus Master IDE TimeOut Register
-	 * I'm not absolutly sure what this does, but it solved my problem
-	 * with IDE DMA and sound, so I now can play sound and work with
-	 * my IDE driver at the same time :-)
-	 *
-	 * If you know the correct (best) value for this register please
-	 * let me know - ASK
-	 */
-
-	data = BUSMASTER_TIMEOUT;
-	outb(CY82_INDEX_TIMEOUT, CY82_INDEX_PORT);
-	outb(data, CY82_DATA_PORT);
-}
-
-static void cy82c693_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
-{
-	struct pci_dev *dev = to_pci_dev(hwif->dev);
-	int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
-	const unsigned long T = 1000000 / bus_speed;
-	unsigned int addrCtrl;
-	struct ata_timing t;
-	u8 mode = drive->pio_mode, time_16, time_8;
-
-	/* select primary or secondary channel */
-	if (hwif->index > 0) {  /* drive is on the secondary channel */
-		dev = pci_get_slot(dev->bus, dev->devfn+1);
-		if (!dev) {
-			printk(KERN_ERR "%s: tune_drive: "
-				"Cannot find secondary interface!\n",
-				drive->name);
-			return;
-		}
-	}
-
-	ata_timing_compute(drive->id, mode, mode, &t, T, 1);
-
-	time_16 = clamp_val(t.recover - 1, 0, 15) |
-		  (clamp_val(t.active - 1, 0, 15) << 4);
-	time_8 = clamp_val(t.act8b - 1, 0, 15) |
-		 (clamp_val(t.rec8b - 1, 0, 15) << 4);
-
-	/* now let's write  the clocks registers */
-	if ((drive->dn & 1) == 0) {
-		/*
-		 * set master drive
-		 * address setup control register
-		 * is 32 bit !!!
-		 */
-		pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl);
-
-		addrCtrl &= (~0xF);
-		addrCtrl |= clamp_val(t.setup - 1, 0, 15);
-		pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl);
-
-		/* now let's set the remaining registers */
-		pci_write_config_byte(dev, CY82_IDE_MASTER_IOR, time_16);
-		pci_write_config_byte(dev, CY82_IDE_MASTER_IOW, time_16);
-		pci_write_config_byte(dev, CY82_IDE_MASTER_8BIT, time_8);
-	} else {
-		/*
-		 * set slave drive
-		 * address setup control register
-		 * is 32 bit !!!
-		 */
-		pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl);
-
-		addrCtrl &= (~0xF0);
-		addrCtrl |= (clamp_val(t.setup - 1, 0, 15) << 4);
-		pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl);
-
-		/* now let's set the remaining registers */
-		pci_write_config_byte(dev, CY82_IDE_SLAVE_IOR, time_16);
-		pci_write_config_byte(dev, CY82_IDE_SLAVE_IOW, time_16);
-		pci_write_config_byte(dev, CY82_IDE_SLAVE_8BIT, time_8);
-	}
-}
+#include <linux/ide2libata.h>
+#include "../ata/pata_cypress.h"
 
 static void __devinit init_iops_cy82c693(ide_hwif_t *hwif)
 {
@@ -157,8 +35,8 @@ static void __devinit init_iops_cy82c693
 }
 
 static const struct ide_port_ops cy82c693_port_ops = {
-	.set_pio_mode		= cy82c693_set_pio_mode,
-	.set_dma_mode		= cy82c693_set_dma_mode,
+	.set_pio_mode		= cy82c693_set_piomode,
+	.set_dma_mode		= cy82c693_set_dmamode,
 };
 
 static const struct ide_port_info cy82c693_chipset __devinitdata = {

  parent reply	other threads:[~2010-01-29 16:08 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 16:03 [PATCH 00/68] ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:03 ` [PATCH 01/68] piix: add new short cable IDs Bartlomiej Zolnierkiewicz
2010-01-29 16:03 ` [PATCH 02/68] libata: CodingStyle fixes for ATA timings code Bartlomiej Zolnierkiewicz
2010-01-29 16:03 ` [PATCH 03/68] libata: move ATA timings code to ata-timings.c Bartlomiej Zolnierkiewicz
2010-01-29 16:03 ` [PATCH 04/68] ata: make ATA timings code independent of libata Bartlomiej Zolnierkiewicz
2010-01-29 16:03 ` [PATCH 05/68] ata: enable XFER_PIO_SLOW mode in ata_timing table Bartlomiej Zolnierkiewicz
2010-01-29 16:03 ` [PATCH 06/68] ide: switch to generic ATA timings code Bartlomiej Zolnierkiewicz
2010-01-29 16:03 ` [PATCH 07/68] pata_pcmcia: move IDs table to pata_pcmcia.h Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 08/68] ide-cs: use pata_pcmcia.h Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 09/68] ata_piix: factor out short cable detection code to ich_short_ata40() Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 10/68] ata_piix: move short cable handling to ata_piix.h Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 11/68] piix: use ata_piix.h Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 12/68] pata_ali: move short cable handling to pata_ali.h Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 13/68] alim15x3: use pata_ali.h Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 14/68] pata_sis: move short cable handling to pata_sis.h Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 15/68] sis5513: use pata_sis.h Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 16/68] pata_via: move short cable handling to pata_via.h Bartlomiej Zolnierkiewicz
2010-01-29 16:04 ` [PATCH 17/68] via82cxxx: use pata_via.h Bartlomiej Zolnierkiewicz
2010-01-29 16:05 ` [PATCH 18/68] ide: split host->dev table Bartlomiej Zolnierkiewicz
2010-01-29 16:05 ` [PATCH 19/68] ide: add hwif->port_no field Bartlomiej Zolnierkiewicz
2010-01-29 16:05 ` [PATCH 20/68] ide: add hwif->udma_mask field Bartlomiej Zolnierkiewicz
2010-01-29 16:05 ` [PATCH 21/68] ide: add hwif->private_data field Bartlomiej Zolnierkiewicz
2010-01-29 16:05 ` [PATCH 22/68] ide: add drive->devno field Bartlomiej Zolnierkiewicz
2010-01-29 16:05 ` [PATCH 23/68] ide: add drive->class field Bartlomiej Zolnierkiewicz
2010-01-29 16:05 ` [PATCH 24/68] ide: change ->cable_detect method return type to 'int' Bartlomiej Zolnierkiewicz
2010-01-29 16:05 ` [PATCH 25/68] it8213: always program control bits Bartlomiej Zolnierkiewicz
2010-01-29 17:36   ` Sergei Shtylyov
2010-01-29 16:05 ` [PATCH 26/68] piix: " Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 27/68] slc90e66: " Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 28/68] add ide2libata header file Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 29/68] ata_piix: move code to be re-used by ide2libata to ata_piix.h Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 30/68] piix: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 31/68] pata_ali: move code to be re-used by ide2libata to pata_ali.h Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 32/68] alim15x3: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 33/68] pata_amd: move code to be re-used by ide2libata to pata_amd.h Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 34/68] amd74xx: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 35/68] pata_artop: move code to be re-used by ide2libata to pata_artop.h Bartlomiej Zolnierkiewicz
2010-01-29 16:06 ` [PATCH 36/68] aec62xx: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:07 ` [PATCH 37/68] pata_atiixp: move code to be re-used by ide2libata to pata_atiixp.h Bartlomiej Zolnierkiewicz
2010-01-29 16:07 ` [PATCH 38/68] atiixp: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:07 ` [PATCH 39/68] pata_cmd64x: documentation fix Bartlomiej Zolnierkiewicz
2010-01-29 16:07 ` [PATCH 40/68] pata_cmd64x: move code to be re-used by ide2libata to pata_cmd64x.h Bartlomiej Zolnierkiewicz
2010-01-29 16:07 ` [PATCH 41/68] pata_cmd64x: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:07 ` [PATCH 42/68] pata_cs5520: move code to be re-used by ide2libata to pata_cs5520.h Bartlomiej Zolnierkiewicz
2010-01-29 16:07 ` [PATCH 43/68] cs5520: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:07 ` [PATCH 44/68] pata_cs5530: move code to be re-used by ide2libata to pata_cs5530.h Bartlomiej Zolnierkiewicz
2010-01-29 16:07 ` [PATCH 45/68] cs5530: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:08 ` [PATCH 46/68] pata_cs5535: move code to be re-used by ide2libata to pata_cs5535.h Bartlomiej Zolnierkiewicz
2010-01-29 16:08 ` [PATCH 47/68] cs5535: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:08 ` [PATCH 48/68] pata_cypress: move code to be re-used by ide2libata to pata_cypress.h Bartlomiej Zolnierkiewicz
2010-01-29 16:08 ` Bartlomiej Zolnierkiewicz [this message]
2010-01-29 16:08 ` [PATCH 50/68] pata_efar: move code to be re-used by ide2libata to pata_efar.h Bartlomiej Zolnierkiewicz
2010-01-29 16:08 ` [PATCH 51/68] slc90e66: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:08 ` [PATCH 52/68] pata_it8213: move code to be re-used by ide2libata to pata_it8213.h Bartlomiej Zolnierkiewicz
2010-01-29 16:08 ` [PATCH 53/68] it8213: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:08 ` [PATCH 54/68] pata_it821x: move code to be re-used by ide2libata to pata_it821x.h Bartlomiej Zolnierkiewicz
2010-01-29 16:09 ` [PATCH 55/68] it821x: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:09 ` [PATCH 56/68] pata_pdc202xx_old: move code to be re-used by ide2libata to pata_pdc202xx_old.h Bartlomiej Zolnierkiewicz
2010-01-29 16:09 ` [PATCH 57/68] pdc202xx_old: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:09 ` [PATCH 58/68] pata_sc1200: move code to be re-used by ide2libata to pata_sc1200.h Bartlomiej Zolnierkiewicz
2010-01-29 16:09 ` [PATCH 59/68] sc1200: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:09 ` [PATCH 60/68] pata_serverworks: move cable handling to pata_serverworks.h Bartlomiej Zolnierkiewicz
2010-01-29 16:09 ` [PATCH 61/68] serverworks: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:09 ` [PATCH 62/68] pata_sl82c105: move code to be re-used by ide2libata to pata_sl82c105.h Bartlomiej Zolnierkiewicz
2010-01-29 16:09 ` [PATCH 63/68] sl82c105: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:10 ` [PATCH 64/68] pata_triflex: move code to be re-used by ide2libata to pata_triflex.h Bartlomiej Zolnierkiewicz
2010-01-29 16:10 ` [PATCH 65/68] triflex: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 16:10 ` [PATCH 66/68] pata_via: factor out code for finding ISA bridge Bartlomiej Zolnierkiewicz
2010-01-29 16:10 ` [PATCH 67/68] pata_via: move code to be re-used by ide2libata to pata_via.h Bartlomiej Zolnierkiewicz
2010-01-29 16:10 ` [PATCH 68/68] via82cxxx: convert to ide2libata Bartlomiej Zolnierkiewicz
2010-01-29 21:40 ` [PATCH 00/68] ide2libata Jeff Garzik
2010-01-29 22:24   ` Bartlomiej Zolnierkiewicz
2010-01-29 23:25   ` Alan Cox
2010-01-30 15:24     ` Bartlomiej Zolnierkiewicz
2010-02-01  7:47     ` David Miller
2010-02-01  9:31       ` Bartlomiej Zolnierkiewicz
2010-02-01 11:07       ` Alan Cox
2010-02-01 11:17         ` David Miller
2010-02-01 11:48           ` Alan Cox
2010-02-01 12:48             ` David Miller
2010-02-01 12:58               ` Alan Cox
2010-02-01 13:14                 ` David Miller
2010-02-02 23:10                   ` Jeff Garzik
2010-02-02 23:19                     ` David Miller
2010-02-02 23:27                       ` Alan Cox
2010-02-02 23:29                         ` David Miller

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=20100129160823.21495.16081.sendpatchset@localhost \
    --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 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).