lkml.org 
[lkml]   [2002]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] 2.5.24: generic ATA PCI auto-dma tuning (5/5)

- split config_chipset_for_dma() in pdc202xx.c to
pdc202xx_udma_setup() and pdc202xx_tx_udma_setup()

- convert it8172.c and pdc202xx.c to new scheme

--
Bartlomiej Zolnierkiewicz
diff -ur linux-ata-hosts-10/drivers/ide/it8172.c linux/drivers/ide/it8172.c
--- linux-ata-hosts-10/drivers/ide/it8172.c Mon Jun 24 22:15:18 2002
+++ linux/drivers/ide/it8172.c Mon Jun 24 22:45:20 2002
@@ -179,14 +179,6 @@

return ide_config_drive_speed(drive, speed);
}
-
-static int it8172_udma_setup(struct ata_device *drive)
-{
- u8 speed = ata_timing_mode(drive, XFER_PIO | XFER_EPIO |
- XFER_SWDMA | XFER_MWDMA | XFER_UDMA);
-
- return !it8172_tune_chipset(drive, speed);
-}
#endif /* defined(CONFIG_BLK_DEV_IDEDMA) && (CONFIG_IT8172_TUNING) */


@@ -221,6 +213,8 @@
#else /* CONFIG_BLK_DEV_IDEDMA */
# ifdef CONFIG_IT8172_TUNING
hwif->autodma = 1;
+ hwif->modes_map = XFER_EPIO | XFER_SWDMA | XFER_MWDMA | XFER_UDMA;
+ hwif->udma_setup = udma_generic_setup;
hwif->dmaproc = &it8172_dmaproc;
hwif->speedproc = &it8172_tune_chipset;
# endif
diff -ur linux-ata-hosts-10/drivers/ide/pdc202xx.c linux/drivers/ide/pdc202xx.c
--- linux-ata-hosts-10/drivers/ide/pdc202xx.c Mon Jun 24 22:40:40 2002
+++ linux/drivers/ide/pdc202xx.c Mon Jun 24 22:44:38 2002
@@ -131,7 +131,7 @@

static int __init pdc202xx_modes_map(struct ata_channel *ch)
{
- int map = XFER_EPIO | XFER_SWDMA | XFER_MWDMA;
+ int map = XFER_EPIO | XFER_SWDMA | XFER_MWDMA | XFER_UDMA;

switch(ch->pci_dev->device) {
case PCI_DEVICE_ID_PROMISE_20276:
@@ -146,8 +146,11 @@
map |= XFER_UDMA_100;
case PCI_DEVICE_ID_PROMISE_20262:
map |= XFER_UDMA_66;
- case PCI_DEVICE_ID_PROMISE_20246:
- map |= XFER_UDMA;
+
+ if (!ch->udma_four) {
+ printk(KERN_WARNING "%s: 40-pin cable, speed reduced to UDMA(33) mode.\n", ch->name);
+ map &= ~XFER_UDMA_80W;
+ }
}

return map;
@@ -370,48 +373,34 @@
}

#ifdef CONFIG_BLK_DEV_IDEDMA
-/* FIXME: split this for old & new chipsets (jumpbit) --bkz */
-static int config_chipset_for_dma(struct ata_device *drive, byte udma)
+static int pdc202xx_tx_udma_setup(struct ata_device *drive, int map)
+{
+ struct hd_driveid *id = drive->id;
+ struct ata_channel *ch = drive->channel;
+ u32 indexreg = ch->dma_base + 1;
+ u32 datareg = indexreg + 2;
+ u8 adj = (drive->dn % 2) ? 0x08 : 0x00;
+
+ if (drive->type != ATA_DISK)
+ return 0;
+
+ /* IORDY_EN & PREFETCH_EN */
+ if (id->capability & 4)
+ set_2regs(0x13, (IN_BYTE(datareg)|0x03));
+
+ return udma_generic_setup(drive, map);
+}
+
+static int pdc202xx_udma_setup(struct ata_device *drive, int map)
{
- struct hd_driveid *id = drive->id;
+ struct hd_driveid *id = drive->id;
struct ata_channel *hwif = drive->channel;
struct hd_driveid *mate_id = hwif->drives[!(drive->dn%2)].id;
- struct pci_dev *dev = hwif->pci_dev;
+ struct pci_dev *dev = hwif->pci_dev;
u32 high_16 = pci_resource_start(dev, 4);
- u32 dma_base = hwif->dma_base;
- u32 indexreg = dma_base + 1;
- u32 datareg = dma_base + 3;
- byte adj = (drive->dn%2) ? 0x08 : 0x00;
- u8 jumpbit;
u32 drive_conf;
u8 drive_pci = 0, AP, tmp, mode = -1;
u8 CLKSPD, mask = hwif->unit ? 0x08 : 0x02;
- int map;
-
- /* UDMA 3, 4, 5 and 6 */
- u8 needs_80w = (id->dma_ultra & 0x0078);
-
- switch(dev->device) {
- case PCI_DEVICE_ID_PROMISE_20267:
- case PCI_DEVICE_ID_PROMISE_20265:
- case PCI_DEVICE_ID_PROMISE_20262:
- case PCI_DEVICE_ID_PROMISE_20246:
- jumpbit = 0;
- break;
- default: /* chipsets newer then 20267 */
- jumpbit = 1;
- break;
- }
-
- /* FIXME: this check is wrong for 20246 --bkz */
- /* */
- if (needs_80w && !hwif->udma_four) {
- printk(KERN_WARNING "%s: channel requires an 80-pin cable.\n", hwif->name);
- printk(KERN_INFO "%s: reduced to UDMA(33) mode.\n", drive->name);
- }
-
- if (jumpbit)
- goto chipset_is_set;

/*
* Set the control register to use the 66Mhz system
@@ -425,7 +414,7 @@
* FIXME: move this to pdc202xx_tuneproc()
* right now you can't downgrade from U66 to U33 --bkz
*/
- if (needs_80w) {
+ if (id->dma_ultra & 0x0078) { /* UDMA 3, 4, 5 and 6 */
CLKSPD = IN_BYTE(high_16 + PDC_CLK);
/* check cable and mate (must be at least udma3 capable) */
if (!hwif->udma_four ||
@@ -447,12 +436,11 @@
/* FIXME: what if SYNC_ERRDY is enabled for slave
and disabled for master? --bkz */
pci_read_config_byte(dev, drive_pci, &AP);
+ /* enable SYNC_ERRDY for master and slave (if enabled for master) */
if (!(AP & SYNC_ERRDY_EN)) {
- if (drive->dn == 0 || drive->dn == 2) {
- /* enable SYNC_ERRDY for master */
+ if (!(drive->dn % 2)) {
pci_write_config_byte(dev, drive_pci, AP|SYNC_ERRDY_EN);
} else {
- /* enable SYNC_ERRDY for slave if enabled for master */
pci_read_config_byte(dev, drive_pci - 4, &tmp);
if (tmp & SYNC_ERRDY_EN)
pci_write_config_byte(dev, drive_pci, AP|SYNC_ERRDY_EN);
@@ -464,84 +452,26 @@
if (drive->type != ATA_DISK)
return 0;

- if (jumpbit) {
- if (id->capability & 4) { /* IORDY_EN & PREFETCH_EN */
- set_2regs(0x13, (IN_BYTE(datareg)|0x03));
- }
- } else {
- pci_read_config_byte(dev, drive_pci, &AP);
- if (id->capability & 4) /* IORDY_EN */
- pci_write_config_byte(dev, drive_pci, AP|IORDY_EN);
- pci_read_config_byte(dev, drive_pci, &AP);
- if (drive->type == ATA_DISK) /* PREFETCH_EN */
- pci_write_config_byte(dev, drive_pci, AP|PREFETCH_EN);
- }
+ pci_read_config_byte(dev, drive_pci, &AP);
+ if (id->capability & 4) /* IORDY_EN */
+ pci_write_config_byte(dev, drive_pci, AP|IORDY_EN);
+ pci_read_config_byte(dev, drive_pci, &AP);
+ if (drive->type == ATA_DISK) /* PREFETCH_EN */
+ pci_write_config_byte(dev, drive_pci, AP|PREFETCH_EN);

map = hwif->modes_map;

if (!eighty_ninty_three(drive))
map &= ~XFER_UDMA_80W;

- if (!udma)
- map &= ~XFER_UDMA_ALL;
-
mode = ata_timing_mode(drive, map);
if (mode < XFER_SW_DMA_0) {
/* restore original pci-config space */
- if (!jumpbit)
- pci_write_config_dword(dev, drive_pci, drive_conf);
+ pci_write_config_dword(dev, drive_pci, drive_conf);
return 0;
}

- return !hwif->speedproc(drive, mode);
-}
-
-static int pdc202xx_udma_setup(struct ata_device *drive, int map)
-{
- struct hd_driveid *id = drive->id;
- struct ata_channel *hwif = drive->channel;
- int on = 0;
- int verbose = 1;
-
- if (id && (id->capability & 1) && hwif->autodma) {
- /* Consult the list of known "bad" drives */
- verbose = 0;
- if (udma_black_list(drive))
- goto no_dma_set;
- if (id->field_valid & 4) {
- if (id->dma_ultra & 0x007F) {
- /* Force if Capable UltraDMA */
- on = config_chipset_for_dma(drive, 1);
- if ((id->field_valid & 2) &&
- (!on))
- goto try_dma_modes;
- }
- } else if (id->field_valid & 2) {
-try_dma_modes:
- if ((id->dma_mword & 0x0007) ||
- (id->dma_1word & 0x0007)) {
- /* Force if Capable regular DMA modes */
- on = config_chipset_for_dma(drive, 0);
- if (!on)
- goto no_dma_set;
- }
- } else if (udma_white_list(drive)) {
- if (id->eide_dma_time > 150) {
- goto no_dma_set;
- }
- /* Consult the list of known "good" drives */
- on = config_chipset_for_dma(drive, 0);
- if (!on)
- goto no_dma_set;
- } else goto no_dma_set;
- } else if ((id->capability & 8) || (id->field_valid & 2)) {
-no_dma_set:
- pdc202xx_tune_drive(drive, 255);
- }
-
- udma_enable(drive, on, verbose);
-
- return 0;
+ return udma_generic_setup(drive, map);
}

static void pdc202xx_udma_start(struct ata_device *drive, struct request *rq)
@@ -724,6 +654,10 @@
case PCI_DEVICE_ID_PROMISE_20268R:
hwif->speedproc = &pdc202xx_new_tune_chipset;
hwif->resetproc = &pdc202xx_new_reset;
+#ifdef CONFIG_BLK_DEV_IDEDMA
+ if (hwif->dma_base)
+ hwif->udma_setup = pdc202xx_tx_udma_setup;
+#endif
break;
case PCI_DEVICE_ID_PROMISE_20267:
case PCI_DEVICE_ID_PROMISE_20265:
@@ -738,6 +672,10 @@
#endif
/* FIXME: check whether 20246 works with lba48 --bkz */
case PCI_DEVICE_ID_PROMISE_20246:
+#ifdef CONFIG_BLK_DEV_IDEDMA
+ if (hwif->dma_base)
+ hwif->udma_setup = pdc202xx_udma_setup;
+#endif
hwif->speedproc = &pdc202xx_tune_chipset;
default:
break;
@@ -748,7 +686,6 @@
hwif->modes_map = pdc202xx_modes_map(hwif);
hwif->udma_irq_lost = pdc202xx_bug;
hwif->udma_timeout = pdc202xx_bug;
- hwif->udma_setup = pdc202xx_udma_setup;
hwif->highmem = 1;
if (!noautodma)
hwif->autodma = 1;
\
 
 \ /
  Last update: 2005-03-22 13:27    [W:0.035 / U:0.460 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site