aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/alim15x3.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2010-01-18 02:21:26 -0500
committerDavid S. Miller <davem@davemloft.net>2010-01-19 04:52:31 -0500
commite4c7112b5686c70ba7be86dbc83c989c75aca802 (patch)
tree3c3e11ddee39d18eea78ee1d61307da9ff38aaf8 /drivers/ide/alim15x3.c
parenta345c7856e52bf8b21a5ae6a24fb824bfedefbe9 (diff)
alim15x3: fix handling of UDMA enable bit
Clear UDMA enable bit also for PIO modes. Based on libata pata_ali host driver. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/ide/alim15x3.c')
-rw-r--r--drivers/ide/alim15x3.c43
1 files changed, 18 insertions, 25 deletions
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c
index 3ba7d0bdd25d..2c8016ad0e26 100644
--- a/drivers/ide/alim15x3.c
+++ b/drivers/ide/alim15x3.c
@@ -62,11 +62,22 @@ static void ali_fifo_control(ide_hwif_t *hwif, ide_drive_t *drive, int on)
62} 62}
63 63
64static void ali_program_timings(ide_hwif_t *hwif, ide_drive_t *drive, 64static void ali_program_timings(ide_hwif_t *hwif, ide_drive_t *drive,
65 struct ide_timing *t) 65 struct ide_timing *t, u8 ultra)
66{ 66{
67 struct pci_dev *dev = to_pci_dev(hwif->dev); 67 struct pci_dev *dev = to_pci_dev(hwif->dev);
68 int port = hwif->channel ? 0x5c : 0x58; 68 int port = hwif->channel ? 0x5c : 0x58;
69 u8 unit = drive->dn & 1; 69 int udmat = 0x56 + hwif->channel;
70 u8 unit = drive->dn & 1, udma;
71 int shift = 4 * unit;
72
73 /* Set up the UDMA */
74 pci_read_config_byte(dev, udmat, &udma);
75 udma &= ~(0x0F << shift);
76 udma |= ultra << shift;
77 pci_write_config_byte(dev, udmat, udma);
78
79 if (t == NULL)
80 return;
70 81
71 t->setup = clamp_val(t->setup, 1, 8) & 7; 82 t->setup = clamp_val(t->setup, 1, 8) & 7;
72 t->act8b = clamp_val(t->act8b, 1, 8) & 7; 83 t->act8b = clamp_val(t->act8b, 1, 8) & 7;
@@ -114,7 +125,7 @@ static void ali_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
114 */ 125 */
115 ali_fifo_control(hwif, drive, (drive->media == ide_disk) ? 0x05 : 0x00); 126 ali_fifo_control(hwif, drive, (drive->media == ide_disk) ? 0x05 : 0x00);
116 127
117 ali_program_timings(hwif, drive, &t); 128 ali_program_timings(hwif, drive, &t, 0);
118} 129}
119 130
120/** 131/**
@@ -152,29 +163,16 @@ static u8 ali_udma_filter(ide_drive_t *drive)
152 163
153static void ali_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) 164static void ali_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
154{ 165{
166 static u8 udma_timing[7] = { 0xC, 0xB, 0xA, 0x9, 0x8, 0xF, 0xD };
155 struct pci_dev *dev = to_pci_dev(hwif->dev); 167 struct pci_dev *dev = to_pci_dev(hwif->dev);
156 ide_drive_t *pair = ide_get_pair_dev(drive); 168 ide_drive_t *pair = ide_get_pair_dev(drive);
157 int bus_speed = ide_pci_clk ? ide_pci_clk : 33; 169 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
158 unsigned long T = 1000000 / bus_speed; /* PCI clock based */ 170 unsigned long T = 1000000 / bus_speed; /* PCI clock based */
159 const u8 speed = drive->dma_mode; 171 const u8 speed = drive->dma_mode;
160 u8 speed1 = speed;
161 u8 unit = drive->dn & 1;
162 u8 tmpbyte = 0x00; 172 u8 tmpbyte = 0x00;
163 int m5229_udma = (hwif->channel) ? 0x57 : 0x56;
164 struct ide_timing t; 173 struct ide_timing t;
165 174
166 if (speed == XFER_UDMA_6)
167 speed1 = 0x47;
168
169 if (speed < XFER_UDMA_0) { 175 if (speed < XFER_UDMA_0) {
170 u8 ultra_enable = (unit) ? 0x7f : 0xf7;
171 /*
172 * clear "ultra enable" bit
173 */
174 pci_read_config_byte(dev, m5229_udma, &tmpbyte);
175 tmpbyte &= ultra_enable;
176 pci_write_config_byte(dev, m5229_udma, tmpbyte);
177
178 ide_timing_compute(drive, drive->dma_mode, &t, T, 1); 176 ide_timing_compute(drive, drive->dma_mode, &t, T, 1);
179 if (pair) { 177 if (pair) {
180 struct ide_timing p; 178 struct ide_timing p;
@@ -189,15 +187,10 @@ static void ali_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
189 IDE_TIMING_SETUP | IDE_TIMING_8BIT); 187 IDE_TIMING_SETUP | IDE_TIMING_8BIT);
190 } 188 }
191 } 189 }
192 ali_program_timings(hwif, drive, &t); 190 ali_program_timings(hwif, drive, &t, 0);
193 } else { 191 } else {
194 pci_read_config_byte(dev, m5229_udma, &tmpbyte); 192 ali_program_timings(hwif, drive, NULL,
195 tmpbyte &= (0x0f << ((1-unit) << 2)); 193 udma_timing[speed - XFER_UDMA_0]);
196 /*
197 * enable ultra dma and set timing
198 */
199 tmpbyte |= ((0x08 | ((4-speed1)&0x07)) << (unit << 2));
200 pci_write_config_byte(dev, m5229_udma, tmpbyte);
201 if (speed >= XFER_UDMA_3) { 194 if (speed >= XFER_UDMA_3) {
202 pci_read_config_byte(dev, 0x4b, &tmpbyte); 195 pci_read_config_byte(dev, 0x4b, &tmpbyte);
203 tmpbyte |= 1; 196 tmpbyte |= 1;