aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/it821x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/it821x.c')
-rw-r--r--drivers/ide/pci/it821x.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index e610a5340fdc..938d35f35c81 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -1,7 +1,4 @@
1
2/* 1/*
3 * linux/drivers/ide/pci/it821x.c Version 0.16 Jul 3 2007
4 *
5 * Copyright (C) 2004 Red Hat <alan@redhat.com> 2 * Copyright (C) 2004 Red Hat <alan@redhat.com>
6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 3 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
7 * 4 *
@@ -113,7 +110,8 @@ static int it8212_noraid;
113 110
114static void it821x_program(ide_drive_t *drive, u16 timing) 111static void it821x_program(ide_drive_t *drive, u16 timing)
115{ 112{
116 ide_hwif_t *hwif = drive->hwif; 113 ide_hwif_t *hwif = drive->hwif;
114 struct pci_dev *dev = to_pci_dev(hwif->dev);
117 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 115 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
118 int channel = hwif->channel; 116 int channel = hwif->channel;
119 u8 conf; 117 u8 conf;
@@ -123,7 +121,8 @@ static void it821x_program(ide_drive_t *drive, u16 timing)
123 conf = timing >> 8; 121 conf = timing >> 8;
124 else 122 else
125 conf = timing & 0xFF; 123 conf = timing & 0xFF;
126 pci_write_config_byte(hwif->pci_dev, 0x54 + 4 * channel, conf); 124
125 pci_write_config_byte(dev, 0x54 + 4 * channel, conf);
127} 126}
128 127
129/** 128/**
@@ -137,7 +136,8 @@ static void it821x_program(ide_drive_t *drive, u16 timing)
137 136
138static void it821x_program_udma(ide_drive_t *drive, u16 timing) 137static void it821x_program_udma(ide_drive_t *drive, u16 timing)
139{ 138{
140 ide_hwif_t *hwif = drive->hwif; 139 ide_hwif_t *hwif = drive->hwif;
140 struct pci_dev *dev = to_pci_dev(hwif->dev);
141 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 141 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
142 int channel = hwif->channel; 142 int channel = hwif->channel;
143 int unit = drive->select.b.unit; 143 int unit = drive->select.b.unit;
@@ -148,11 +148,12 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing)
148 conf = timing >> 8; 148 conf = timing >> 8;
149 else 149 else
150 conf = timing & 0xFF; 150 conf = timing & 0xFF;
151 if(itdev->timing10 == 0) 151
152 pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + unit, conf); 152 if (itdev->timing10 == 0)
153 pci_write_config_byte(dev, 0x56 + 4 * channel + unit, conf);
153 else { 154 else {
154 pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel, conf); 155 pci_write_config_byte(dev, 0x56 + 4 * channel, conf);
155 pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + 1, conf); 156 pci_write_config_byte(dev, 0x56 + 4 * channel + 1, conf);
156 } 157 }
157} 158}
158 159
@@ -167,6 +168,7 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing)
167static void it821x_clock_strategy(ide_drive_t *drive) 168static void it821x_clock_strategy(ide_drive_t *drive)
168{ 169{
169 ide_hwif_t *hwif = drive->hwif; 170 ide_hwif_t *hwif = drive->hwif;
171 struct pci_dev *dev = to_pci_dev(hwif->dev);
170 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 172 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
171 173
172 u8 unit = drive->select.b.unit; 174 u8 unit = drive->select.b.unit;
@@ -205,10 +207,11 @@ static void it821x_clock_strategy(ide_drive_t *drive)
205 itdev->clock_mode = ATA_50; 207 itdev->clock_mode = ATA_50;
206 sel = 1; 208 sel = 1;
207 } 209 }
208 pci_read_config_byte(hwif->pci_dev, 0x50, &v); 210
211 pci_read_config_byte(dev, 0x50, &v);
209 v &= ~(1 << (1 + hwif->channel)); 212 v &= ~(1 << (1 + hwif->channel));
210 v |= sel << (1 + hwif->channel); 213 v |= sel << (1 + hwif->channel);
211 pci_write_config_byte(hwif->pci_dev, 0x50, v); 214 pci_write_config_byte(dev, 0x50, v);
212 215
213 /* 216 /*
214 * Reprogram the UDMA/PIO of the pair drive for the switch 217 * Reprogram the UDMA/PIO of the pair drive for the switch
@@ -282,7 +285,8 @@ static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio)
282 285
283static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) 286static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted)
284{ 287{
285 ide_hwif_t *hwif = drive->hwif; 288 ide_hwif_t *hwif = drive->hwif;
289 struct pci_dev *dev = to_pci_dev(hwif->dev);
286 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); 290 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif);
287 int unit = drive->select.b.unit; 291 int unit = drive->select.b.unit;
288 int channel = hwif->channel; 292 int channel = hwif->channel;
@@ -297,12 +301,12 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted)
297 itdev->udma[unit] = UDMA_OFF; 301 itdev->udma[unit] = UDMA_OFF;
298 302
299 /* UDMA bits off - Revision 0x10 do them in pairs */ 303 /* UDMA bits off - Revision 0x10 do them in pairs */
300 pci_read_config_byte(hwif->pci_dev, 0x50, &conf); 304 pci_read_config_byte(dev, 0x50, &conf);
301 if(itdev->timing10) 305 if (itdev->timing10)
302 conf |= channel ? 0x60: 0x18; 306 conf |= channel ? 0x60: 0x18;
303 else 307 else
304 conf |= 1 << (3 + 2 * channel + unit); 308 conf |= 1 << (3 + 2 * channel + unit);
305 pci_write_config_byte(hwif->pci_dev, 0x50, conf); 309 pci_write_config_byte(dev, 0x50, conf);
306 310
307 it821x_clock_strategy(drive); 311 it821x_clock_strategy(drive);
308 /* FIXME: do we need to program this ? */ 312 /* FIXME: do we need to program this ? */
@@ -320,7 +324,8 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted)
320 324
321static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) 325static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted)
322{ 326{
323 ide_hwif_t *hwif = drive->hwif; 327 ide_hwif_t *hwif = drive->hwif;
328 struct pci_dev *dev = to_pci_dev(hwif->dev);
324 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 329 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
325 int unit = drive->select.b.unit; 330 int unit = drive->select.b.unit;
326 int channel = hwif->channel; 331 int channel = hwif->channel;
@@ -337,12 +342,12 @@ static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted)
337 itdev->udma[unit] |= 0x8080; /* UDMA 5/6 select on */ 342 itdev->udma[unit] |= 0x8080; /* UDMA 5/6 select on */
338 343
339 /* UDMA on. Again revision 0x10 must do the pair */ 344 /* UDMA on. Again revision 0x10 must do the pair */
340 pci_read_config_byte(hwif->pci_dev, 0x50, &conf); 345 pci_read_config_byte(dev, 0x50, &conf);
341 if(itdev->timing10) 346 if (itdev->timing10)
342 conf &= channel ? 0x9F: 0xE7; 347 conf &= channel ? 0x9F: 0xE7;
343 else 348 else
344 conf &= ~ (1 << (3 + 2 * channel + unit)); 349 conf &= ~ (1 << (3 + 2 * channel + unit));
345 pci_write_config_byte(hwif->pci_dev, 0x50, conf); 350 pci_write_config_byte(dev, 0x50, conf);
346 351
347 it821x_clock_strategy(drive); 352 it821x_clock_strategy(drive);
348 it821x_program_udma(drive, itdev->udma[unit]); 353 it821x_program_udma(drive, itdev->udma[unit]);
@@ -520,6 +525,7 @@ static void __devinit it821x_quirkproc(ide_drive_t *drive)
520 525
521static void __devinit init_hwif_it821x(ide_hwif_t *hwif) 526static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
522{ 527{
528 struct pci_dev *dev = to_pci_dev(hwif->dev);
523 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); 529 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL);
524 u8 conf; 530 u8 conf;
525 531
@@ -532,7 +538,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
532 538
533 ide_set_hwifdata(hwif, idev); 539 ide_set_hwifdata(hwif, idev);
534 540
535 pci_read_config_byte(hwif->pci_dev, 0x50, &conf); 541 pci_read_config_byte(dev, 0x50, &conf);
536 if (conf & 1) { 542 if (conf & 1) {
537 idev->smart = 1; 543 idev->smart = 1;
538 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 544 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
@@ -555,7 +561,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
555 * this is necessary. 561 * this is necessary.
556 */ 562 */
557 563
558 pci_read_config_byte(hwif->pci_dev, 0x08, &conf); 564 pci_read_config_byte(dev, 0x08, &conf);
559 if (conf == 0x10) { 565 if (conf == 0x10) {
560 idev->timing10 = 1; 566 idev->timing10 = 1;
561 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 567 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;