aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pdc202xx_old.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/ide/pdc202xx_old.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/ide/pdc202xx_old.c')
-rw-r--r--drivers/ide/pdc202xx_old.c46
1 files changed, 15 insertions, 31 deletions
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index cb812f3700e8..c5f3841af360 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> 2 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>
3 * Copyright (C) 2006-2007, 2009 MontaVista Software, Inc. 3 * Copyright (C) 2006-2007, 2009 MontaVista Software, Inc.
4 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 4 * Copyright (C) 2007-2010 Bartlomiej Zolnierkiewicz
5 * 5 *
6 * Portions Copyright (C) 1999 Promise Technology, Inc. 6 * Portions Copyright (C) 1999 Promise Technology, Inc.
7 * Author: Frank Tiernan (frankt@promise.com) 7 * Author: Frank Tiernan (frankt@promise.com)
@@ -21,30 +21,15 @@
21 21
22#define DRV_NAME "pdc202xx_old" 22#define DRV_NAME "pdc202xx_old"
23 23
24#define PDC202XX_DEBUG_DRIVE_INFO 0 24static void pdc202xx_set_mode(ide_hwif_t *hwif, ide_drive_t *drive)
25
26static void pdc_old_disable_66MHz_clock(ide_hwif_t *);
27
28static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed)
29{ 25{
30 ide_hwif_t *hwif = drive->hwif;
31 struct pci_dev *dev = to_pci_dev(hwif->dev); 26 struct pci_dev *dev = to_pci_dev(hwif->dev);
32 u8 drive_pci = 0x60 + (drive->dn << 2); 27 u8 drive_pci = 0x60 + (drive->dn << 2);
28 const u8 speed = drive->dma_mode;
33 29
34 u8 AP = 0, BP = 0, CP = 0; 30 u8 AP = 0, BP = 0, CP = 0;
35 u8 TA = 0, TB = 0, TC = 0; 31 u8 TA = 0, TB = 0, TC = 0;
36 32
37#if PDC202XX_DEBUG_DRIVE_INFO
38 u32 drive_conf = 0;
39 pci_read_config_dword(dev, drive_pci, &drive_conf);
40#endif
41
42 /*
43 * TODO: do this once per channel
44 */
45 if (dev->device != PCI_DEVICE_ID_PROMISE_20246)
46 pdc_old_disable_66MHz_clock(hwif);
47
48 pci_read_config_byte(dev, drive_pci, &AP); 33 pci_read_config_byte(dev, drive_pci, &AP);
49 pci_read_config_byte(dev, drive_pci + 1, &BP); 34 pci_read_config_byte(dev, drive_pci + 1, &BP);
50 pci_read_config_byte(dev, drive_pci + 2, &CP); 35 pci_read_config_byte(dev, drive_pci + 2, &CP);
@@ -89,19 +74,12 @@ static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed)
89 pci_write_config_byte(dev, drive_pci + 1, BP | TB); 74 pci_write_config_byte(dev, drive_pci + 1, BP | TB);
90 pci_write_config_byte(dev, drive_pci + 2, CP | TC); 75 pci_write_config_byte(dev, drive_pci + 2, CP | TC);
91 } 76 }
92
93#if PDC202XX_DEBUG_DRIVE_INFO
94 printk(KERN_DEBUG "%s: %s drive%d 0x%08x ",
95 drive->name, ide_xfer_verbose(speed),
96 drive->dn, drive_conf);
97 pci_read_config_dword(dev, drive_pci, &drive_conf);
98 printk("0x%08x\n", drive_conf);
99#endif
100} 77}
101 78
102static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio) 79static void pdc202xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
103{ 80{
104 pdc202xx_set_mode(drive, XFER_PIO_0 + pio); 81 drive->dma_mode = drive->pio_mode;
82 pdc202xx_set_mode(hwif, drive);
105} 83}
106 84
107static int pdc202xx_test_irq(ide_hwif_t *hwif) 85static int pdc202xx_test_irq(ide_hwif_t *hwif)
@@ -115,13 +93,13 @@ static int pdc202xx_test_irq(ide_hwif_t *hwif)
115 * bit 7: error, bit 6: interrupting, 93 * bit 7: error, bit 6: interrupting,
116 * bit 5: FIFO full, bit 4: FIFO empty 94 * bit 5: FIFO full, bit 4: FIFO empty
117 */ 95 */
118 return ((sc1d & 0x50) == 0x40) ? 1 : 0; 96 return ((sc1d & 0x50) == 0x50) ? 1 : 0;
119 } else { 97 } else {
120 /* 98 /*
121 * bit 3: error, bit 2: interrupting, 99 * bit 3: error, bit 2: interrupting,
122 * bit 1: FIFO full, bit 0: FIFO empty 100 * bit 1: FIFO full, bit 0: FIFO empty
123 */ 101 */
124 return ((sc1d & 0x05) == 0x04) ? 1 : 0; 102 return ((sc1d & 0x05) == 0x05) ? 1 : 0;
125 } 103 }
126} 104}
127 105
@@ -160,6 +138,11 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif)
160 outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); 138 outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg);
161} 139}
162 140
141static void pdc2026x_init_hwif(ide_hwif_t *hwif)
142{
143 pdc_old_disable_66MHz_clock(hwif);
144}
145
163static void pdc202xx_dma_start(ide_drive_t *drive) 146static void pdc202xx_dma_start(ide_drive_t *drive)
164{ 147{
165 if (drive->current_speed > XFER_UDMA_2) 148 if (drive->current_speed > XFER_UDMA_2)
@@ -276,6 +259,7 @@ static const struct ide_dma_ops pdc2026x_dma_ops = {
276 { \ 259 { \
277 .name = DRV_NAME, \ 260 .name = DRV_NAME, \
278 .init_chipset = init_chipset_pdc202xx, \ 261 .init_chipset = init_chipset_pdc202xx, \
262 .init_hwif = pdc2026x_init_hwif, \
279 .port_ops = &pdc2026x_port_ops, \ 263 .port_ops = &pdc2026x_port_ops, \
280 .dma_ops = &pdc2026x_dma_ops, \ 264 .dma_ops = &pdc2026x_dma_ops, \
281 .host_flags = IDE_HFLAGS_PDC202XX, \ 265 .host_flags = IDE_HFLAGS_PDC202XX, \
@@ -371,6 +355,6 @@ static void __exit pdc202xx_ide_exit(void)
371module_init(pdc202xx_ide_init); 355module_init(pdc202xx_ide_init);
372module_exit(pdc202xx_ide_exit); 356module_exit(pdc202xx_ide_exit);
373 357
374MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); 358MODULE_AUTHOR("Andre Hedrick, Frank Tiernan, Bartlomiej Zolnierkiewicz");
375MODULE_DESCRIPTION("PCI driver module for older Promise IDE"); 359MODULE_DESCRIPTION("PCI driver module for older Promise IDE");
376MODULE_LICENSE("GPL"); 360MODULE_LICENSE("GPL");