aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/cs5520.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/cs5520.c')
-rw-r--r--drivers/ide/pci/cs5520.c57
1 files changed, 21 insertions, 36 deletions
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index b89e81656875..1217d2a747fb 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -66,32 +66,13 @@ static struct pio_clocks cs5520_pio_clocks[]={
66 {1, 2, 1} 66 {1, 2, 1}
67}; 67};
68 68
69static int cs5520_tune_chipset(ide_drive_t *drive, u8 xferspeed) 69static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio)
70{ 70{
71 ide_hwif_t *hwif = HWIF(drive); 71 ide_hwif_t *hwif = HWIF(drive);
72 struct pci_dev *pdev = hwif->pci_dev; 72 struct pci_dev *pdev = hwif->pci_dev;
73 u8 speed = min((u8)XFER_PIO_4, xferspeed);
74 int pio = speed;
75 u8 reg;
76 int controller = drive->dn > 1 ? 1 : 0; 73 int controller = drive->dn > 1 ? 1 : 0;
77 int error; 74 u8 reg;
78 75
79 switch(speed)
80 {
81 case XFER_PIO_4:
82 case XFER_PIO_3:
83 case XFER_PIO_2:
84 case XFER_PIO_1:
85 case XFER_PIO_0:
86 pio -= XFER_PIO_0;
87 break;
88 default:
89 pio = 0;
90 printk(KERN_ERR "cs55x0: bad ide timing.\n");
91 }
92
93 printk("PIO clocking = %d\n", pio);
94
95 /* FIXME: if DMA = 1 do we need to set the DMA bit here ? */ 76 /* FIXME: if DMA = 1 do we need to set the DMA bit here ? */
96 77
97 /* 8bit CAT/CRT - 8bit command timing for channel */ 78 /* 8bit CAT/CRT - 8bit command timing for channel */
@@ -115,25 +96,28 @@ static int cs5520_tune_chipset(ide_drive_t *drive, u8 xferspeed)
115 reg = inb(hwif->dma_base + 0x02 + 8*controller); 96 reg = inb(hwif->dma_base + 0x02 + 8*controller);
116 reg |= 1<<((drive->dn&1)+5); 97 reg |= 1<<((drive->dn&1)+5);
117 outb(reg, hwif->dma_base + 0x02 + 8*controller); 98 outb(reg, hwif->dma_base + 0x02 + 8*controller);
118
119 error = ide_config_drive_speed(drive, speed);
120 /* ATAPI is harder so leave it for now */
121 if(!error && drive->media == ide_disk)
122 error = hwif->ide_dma_on(drive);
123 99
124 return error; 100 (void)ide_config_drive_speed(drive, XFER_PIO_0 + pio);
125} 101}
126 102
127static void cs5520_tune_drive(ide_drive_t *drive, u8 pio) 103static int cs5520_tune_chipset(ide_drive_t *drive, const u8 speed)
128{ 104{
129 pio = ide_get_best_pio_mode(drive, pio, 4); 105 printk(KERN_ERR "cs55x0: bad ide timing.\n");
130 cs5520_tune_chipset(drive, (XFER_PIO_0 + pio)); 106
107 cs5520_set_pio_mode(drive, 0);
108
109 /*
110 * FIXME: this is incorrect to return zero here but
111 * since all users of ide_set_xfer_rate() ignore
112 * the return value it is not a problem currently
113 */
114 return 0;
131} 115}
132 116
133static int cs5520_config_drive_xfer_rate(ide_drive_t *drive) 117static int cs5520_config_drive_xfer_rate(ide_drive_t *drive)
134{ 118{
135 /* Tune the drive for PIO modes up to PIO 4 */ 119 /* Tune the drive for PIO modes up to PIO 4 */
136 cs5520_tune_drive(drive, 255); 120 ide_set_max_pio(drive);
137 121
138 /* Then tell the core to use DMA operations */ 122 /* Then tell the core to use DMA operations */
139 return 0; 123 return 0;
@@ -165,7 +149,7 @@ static int cs5520_dma_on(ide_drive_t *drive)
165 149
166static void __devinit init_hwif_cs5520(ide_hwif_t *hwif) 150static void __devinit init_hwif_cs5520(ide_hwif_t *hwif)
167{ 151{
168 hwif->tuneproc = &cs5520_tune_drive; 152 hwif->set_pio_mode = &cs5520_set_pio_mode;
169 hwif->speedproc = &cs5520_tune_chipset; 153 hwif->speedproc = &cs5520_tune_chipset;
170 hwif->ide_dma_check = &cs5520_config_drive_xfer_rate; 154 hwif->ide_dma_check = &cs5520_config_drive_xfer_rate;
171 hwif->ide_dma_on = &cs5520_dma_on; 155 hwif->ide_dma_on = &cs5520_dma_on;
@@ -179,7 +163,8 @@ static void __devinit init_hwif_cs5520(ide_hwif_t *hwif)
179 hwif->drives[1].autotune = 1; 163 hwif->drives[1].autotune = 1;
180 return; 164 return;
181 } 165 }
182 166
167 /* ATAPI is harder so leave it for now */
183 hwif->atapi_dma = 0; 168 hwif->atapi_dma = 0;
184 hwif->ultra_mask = 0; 169 hwif->ultra_mask = 0;
185 hwif->swdma_mask = 0; 170 hwif->swdma_mask = 0;