aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-dma.c2
-rw-r--r--drivers/ide/ide-probe.c26
-rw-r--r--drivers/ide/ide.c6
-rw-r--r--drivers/ide/legacy/ali14xx.c2
-rw-r--r--drivers/ide/legacy/qd65xx.c2
-rw-r--r--drivers/ide/pci/aec62xx.c2
-rw-r--r--drivers/ide/pci/alim15x3.c7
-rw-r--r--drivers/ide/pci/cmd640.c4
-rw-r--r--drivers/ide/pci/cs5535.c2
-rw-r--r--drivers/ide/pci/cy82c693.c7
-rw-r--r--drivers/ide/pci/it821x.c36
-rw-r--r--drivers/ide/pci/ns87415.c4
-rw-r--r--drivers/ide/pci/opti621.c2
-rw-r--r--drivers/ide/pci/sc1200.c3
-rw-r--r--drivers/ide/pci/scc_pata.c2
-rw-r--r--drivers/ide/pci/serverworks.c2
-rw-r--r--drivers/ide/pci/siimage.c9
-rw-r--r--drivers/ide/pci/triflex.c9
-rw-r--r--drivers/ide/ppc/pmac.c11
19 files changed, 66 insertions, 72 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 82fa6107434b..d5934fc8f85f 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -370,7 +370,7 @@ static int dma_timer_expiry (ide_drive_t *drive)
370void ide_dma_host_set(ide_drive_t *drive, int on) 370void ide_dma_host_set(ide_drive_t *drive, int on)
371{ 371{
372 ide_hwif_t *hwif = HWIF(drive); 372 ide_hwif_t *hwif = HWIF(drive);
373 u8 unit = (drive->select.b.unit & 0x01); 373 u8 unit = drive->dn & 1;
374 u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 374 u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
375 375
376 if (on) 376 if (on)
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 57c741876536..58a2caf17903 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -447,7 +447,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
447 msleep(50); 447 msleep(50);
448 448
449 if (ide_read_device(drive) != drive->select.all && present == 0) { 449 if (ide_read_device(drive) != drive->select.all && present == 0) {
450 if (drive->select.b.unit != 0) { 450 if (drive->dn & 1) {
451 /* exit with drive0 selected */ 451 /* exit with drive0 selected */
452 SELECT_DRIVE(&hwif->drives[0]); 452 SELECT_DRIVE(&hwif->drives[0]);
453 /* allow ATA_BUSY to assert & clear */ 453 /* allow ATA_BUSY to assert & clear */
@@ -493,7 +493,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
493 /* not present or maybe ATAPI */ 493 /* not present or maybe ATAPI */
494 rc = 3; 494 rc = 3;
495 } 495 }
496 if (drive->select.b.unit != 0) { 496 if (drive->dn & 1) {
497 /* exit with drive0 selected */ 497 /* exit with drive0 selected */
498 SELECT_DRIVE(&hwif->drives[0]); 498 SELECT_DRIVE(&hwif->drives[0]);
499 msleep(50); 499 msleep(50);
@@ -798,7 +798,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
798 */ 798 */
799 for (unit = 0; unit < MAX_DRIVES; ++unit) { 799 for (unit = 0; unit < MAX_DRIVES; ++unit) {
800 ide_drive_t *drive = &hwif->drives[unit]; 800 ide_drive_t *drive = &hwif->drives[unit];
801 drive->dn = (hwif->channel ? 2 : 0) + unit; 801
802 (void) probe_for_drive(drive); 802 (void) probe_for_drive(drive);
803 if (drive->dev_flags & IDE_DFLAG_PRESENT) 803 if (drive->dev_flags & IDE_DFLAG_PRESENT)
804 rc = 0; 804 rc = 0;
@@ -1357,6 +1357,8 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
1357 for (i = 0; i < MAX_DRIVES; i++) { 1357 for (i = 0; i < MAX_DRIVES; i++) {
1358 ide_drive_t *drive = &hwif->drives[i]; 1358 ide_drive_t *drive = &hwif->drives[i];
1359 1359
1360 drive->dn = i + hwif->channel * 2;
1361
1360 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) 1362 if (hwif->host_flags & IDE_HFLAG_IO_32BIT)
1361 drive->io_32bit = 1; 1363 drive->io_32bit = 1;
1362 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) 1364 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS)
@@ -1627,18 +1629,18 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1627 1629
1628 if (d == NULL) { 1630 if (d == NULL) {
1629 mate = NULL; 1631 mate = NULL;
1630 continue; 1632 } else {
1631 } 1633 if ((i & 1) && mate) {
1634 hwif->mate = mate;
1635 mate->mate = hwif;
1636 }
1632 1637
1633 if ((i & 1) && mate) { 1638 mate = (i & 1) ? NULL : hwif;
1634 hwif->mate = mate;
1635 mate->mate = hwif;
1636 }
1637 1639
1638 mate = (i & 1) ? NULL : hwif; 1640 ide_init_port(hwif, i & 1, d);
1641 ide_port_cable_detect(hwif);
1642 }
1639 1643
1640 ide_init_port(hwif, i & 1, d);
1641 ide_port_cable_detect(hwif);
1642 ide_port_init_devices(hwif); 1644 ide_port_init_devices(hwif);
1643 } 1645 }
1644 1646
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 40b5a4614340..7624b937398a 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -713,9 +713,9 @@ static int ide_set_disk_chs(const char *str, struct kernel_param *kp)
713module_param_call(chs, ide_set_disk_chs, NULL, NULL, 0); 713module_param_call(chs, ide_set_disk_chs, NULL, NULL, 0);
714MODULE_PARM_DESC(chs, "force device as a disk (using CHS)"); 714MODULE_PARM_DESC(chs, "force device as a disk (using CHS)");
715 715
716static void ide_dev_apply_params(ide_drive_t *drive) 716static void ide_dev_apply_params(ide_drive_t *drive, u8 unit)
717{ 717{
718 int i = drive->hwif->index * MAX_DRIVES + drive->select.b.unit; 718 int i = drive->hwif->index * MAX_DRIVES + unit;
719 719
720 if (ide_nodma & (1 << i)) { 720 if (ide_nodma & (1 << i)) {
721 printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name); 721 printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name);
@@ -791,7 +791,7 @@ void ide_port_apply_params(ide_hwif_t *hwif)
791 } 791 }
792 792
793 for (i = 0; i < MAX_DRIVES; i++) 793 for (i = 0; i < MAX_DRIVES; i++)
794 ide_dev_apply_params(&hwif->drives[i]); 794 ide_dev_apply_params(&hwif->drives[i], i);
795} 795}
796 796
797/* 797/*
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
index 7276c96aaa2a..90da1f953ed0 100644
--- a/drivers/ide/legacy/ali14xx.c
+++ b/drivers/ide/legacy/ali14xx.c
@@ -131,7 +131,7 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
131 drive->name, pio, time1, time2, param1, param2, param3, param4); 131 drive->name, pio, time1, time2, param1, param2, param3, param4);
132 132
133 /* stuff timing parameters into controller registers */ 133 /* stuff timing parameters into controller registers */
134 driveNum = (HWIF(drive)->index << 1) + drive->select.b.unit; 134 driveNum = (drive->hwif->index << 1) + (drive->dn & 1);
135 spin_lock_irqsave(&ali14xx_lock, flags); 135 spin_lock_irqsave(&ali14xx_lock, flags);
136 outb_p(regOn, basePort); 136 outb_p(regOn, basePort);
137 outReg(param1, regTab[driveNum].reg1); 137 outReg(param1, regTab[driveNum].reg1);
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
index ec408b3a7100..bc27c7aba936 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -305,7 +305,7 @@ static void __init qd6580_init_dev(ide_drive_t *drive)
305 } else 305 } else
306 t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA; 306 t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA;
307 307
308 drive->drive_data = drive->select.b.unit ? t2 : t1; 308 drive->drive_data = (drive->dn & 1) ? t2 : t1;
309} 309}
310 310
311static const struct ide_port_ops qd6500_port_ops = { 311static const struct ide_port_ops qd6500_port_ops = {
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index e7475ba559c7..c294b19f5552 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -115,7 +115,7 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed)
115 struct pci_dev *dev = to_pci_dev(hwif->dev); 115 struct pci_dev *dev = to_pci_dev(hwif->dev);
116 struct ide_host *host = pci_get_drvdata(dev); 116 struct ide_host *host = pci_get_drvdata(dev);
117 struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; 117 struct chipset_bus_clock_list_entry *bus_clock = host->host_priv;
118 u8 unit = (drive->select.b.unit & 0x01); 118 u8 unit = drive->dn & 1;
119 u8 tmp1 = 0, tmp2 = 0; 119 u8 tmp1 = 0, tmp2 = 0;
120 u8 ultra = 0, drive_conf = 0, ultra_conf = 0; 120 u8 ultra = 0, drive_conf = 0, ultra_conf = 0;
121 unsigned long flags; 121 unsigned long flags;
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 053c75263918..f1c57f72bbdb 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -77,8 +77,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
77 int bus_speed = ide_pci_clk ? ide_pci_clk : 33; 77 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
78 int port = hwif->channel ? 0x5c : 0x58; 78 int port = hwif->channel ? 0x5c : 0x58;
79 int portFIFO = hwif->channel ? 0x55 : 0x54; 79 int portFIFO = hwif->channel ? 0x55 : 0x54;
80 u8 cd_dma_fifo = 0; 80 u8 cd_dma_fifo = 0, unit = drive->dn & 1;
81 int unit = drive->select.b.unit & 1;
82 81
83 if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8) 82 if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8)
84 s_clc = 0; 83 s_clc = 0;
@@ -112,7 +111,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
112 } 111 }
113 112
114 pci_write_config_byte(dev, port, s_clc); 113 pci_write_config_byte(dev, port, s_clc);
115 pci_write_config_byte(dev, port+drive->select.b.unit+2, (a_clc << 4) | r_clc); 114 pci_write_config_byte(dev, port + unit + 2, (a_clc << 4) | r_clc);
116 local_irq_restore(flags); 115 local_irq_restore(flags);
117} 116}
118 117
@@ -154,7 +153,7 @@ static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed)
154 ide_hwif_t *hwif = HWIF(drive); 153 ide_hwif_t *hwif = HWIF(drive);
155 struct pci_dev *dev = to_pci_dev(hwif->dev); 154 struct pci_dev *dev = to_pci_dev(hwif->dev);
156 u8 speed1 = speed; 155 u8 speed1 = speed;
157 u8 unit = (drive->select.b.unit & 0x01); 156 u8 unit = drive->dn & 1;
158 u8 tmpbyte = 0x00; 157 u8 tmpbyte = 0x00;
159 int m5229_udma = (hwif->channel) ? 0x57 : 0x56; 158 int m5229_udma = (hwif->channel) ? 0x57 : 0x56;
160 159
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index d3afdffcb07a..e4306647d00d 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -468,7 +468,7 @@ static void program_drive_counts(ide_drive_t *drive, unsigned int index)
468 */ 468 */
469 if (index > 1) { 469 if (index > 1) {
470 ide_hwif_t *hwif = drive->hwif; 470 ide_hwif_t *hwif = drive->hwif;
471 ide_drive_t *peer = &hwif->drives[!drive->select.b.unit]; 471 ide_drive_t *peer = &hwif->drives[!(drive->dn & 1)];
472 unsigned int mate = index ^ 1; 472 unsigned int mate = index ^ 1;
473 473
474 if (peer->dev_flags & IDE_DFLAG_PRESENT) { 474 if (peer->dev_flags & IDE_DFLAG_PRESENT) {
@@ -607,7 +607,7 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio)
607 607
608static void cmd640_init_dev(ide_drive_t *drive) 608static void cmd640_init_dev(ide_drive_t *drive)
609{ 609{
610 unsigned int i = drive->hwif->channel * 2 + drive->select.b.unit; 610 unsigned int i = drive->hwif->channel * 2 + (drive->dn & 1);
611 611
612#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 612#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
613 /* 613 /*
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c
index 1e5bc59ea2fb..fa6dca9f3287 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/pci/cs5535.c
@@ -76,7 +76,7 @@ static unsigned int cs5535_udma_timings[5] =
76static void cs5535_set_speed(ide_drive_t *drive, const u8 speed) 76static void cs5535_set_speed(ide_drive_t *drive, const u8 speed)
77{ 77{
78 u32 reg = 0, dummy; 78 u32 reg = 0, dummy;
79 int unit = drive->select.b.unit; 79 u8 unit = drive->dn & 1;
80 80
81 /* Set the PIO timings */ 81 /* Set the PIO timings */
82 if (speed < XFER_SW_DMA_0) { 82 if (speed < XFER_SW_DMA_0) {
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index 5241ef74f8d9..e5f8fc0ed318 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -178,8 +178,7 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode)
178 178
179#if CY82C693_DEBUG_INFO 179#if CY82C693_DEBUG_INFO
180 printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n", 180 printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n",
181 drive->name, HWIF(drive)->channel, drive->select.b.unit, 181 drive->name, hwif->channel, drive->dn & 1, mode & 3, single);
182 mode & 3, single);
183#endif /* CY82C693_DEBUG_INFO */ 182#endif /* CY82C693_DEBUG_INFO */
184 183
185 /* 184 /*
@@ -224,7 +223,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
224 compute_clocks(pio, &pclk); 223 compute_clocks(pio, &pclk);
225 224
226 /* now let's write the clocks registers */ 225 /* now let's write the clocks registers */
227 if (drive->select.b.unit == 0) { 226 if ((drive->dn & 1) == 0) {
228 /* 227 /*
229 * set master drive 228 * set master drive
230 * address setup control register 229 * address setup control register
@@ -266,7 +265,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
266#if CY82C693_DEBUG_INFO 265#if CY82C693_DEBUG_INFO
267 printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to " 266 printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to "
268 "(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n", 267 "(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n",
269 drive->name, hwif->channel, drive->select.b.unit, 268 drive->name, hwif->channel, drive->dn & 1,
270 addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8); 269 addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8);
271#endif /* CY82C693_DEBUG_INFO */ 270#endif /* CY82C693_DEBUG_INFO */
272} 271}
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index b761015ee190..1aada445a9c8 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -138,8 +138,7 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing)
138 struct pci_dev *dev = to_pci_dev(hwif->dev); 138 struct pci_dev *dev = to_pci_dev(hwif->dev);
139 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 139 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
140 int channel = hwif->channel; 140 int channel = hwif->channel;
141 int unit = drive->select.b.unit; 141 u8 unit = drive->dn & 1, conf;
142 u8 conf;
143 142
144 /* Program UDMA timing bits */ 143 /* Program UDMA timing bits */
145 if(itdev->clock_mode == ATA_66) 144 if(itdev->clock_mode == ATA_66)
@@ -168,13 +167,11 @@ static void it821x_clock_strategy(ide_drive_t *drive)
168 ide_hwif_t *hwif = drive->hwif; 167 ide_hwif_t *hwif = drive->hwif;
169 struct pci_dev *dev = to_pci_dev(hwif->dev); 168 struct pci_dev *dev = to_pci_dev(hwif->dev);
170 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 169 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
170 ide_drive_t *pair;
171 int clock, altclock, sel = 0;
172 u8 unit = drive->dn & 1, v;
171 173
172 u8 unit = drive->select.b.unit; 174 pair = &hwif->drives[1 - unit];
173 ide_drive_t *pair = &hwif->drives[1-unit];
174
175 int clock, altclock;
176 u8 v;
177 int sel = 0;
178 175
179 if(itdev->want[0][0] > itdev->want[1][0]) { 176 if(itdev->want[0][0] > itdev->want[1][0]) {
180 clock = itdev->want[0][1]; 177 clock = itdev->want[0][1];
@@ -240,16 +237,17 @@ static void it821x_clock_strategy(ide_drive_t *drive)
240 237
241static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) 238static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio)
242{ 239{
243 ide_hwif_t *hwif = drive->hwif; 240 ide_hwif_t *hwif = drive->hwif;
244 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 241 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
245 int unit = drive->select.b.unit; 242 ide_drive_t *pair;
246 ide_drive_t *pair = &hwif->drives[1 - unit]; 243 u8 unit = drive->dn & 1, set_pio = pio;
247 u8 set_pio = pio;
248 244
249 /* Spec says 89 ref driver uses 88 */ 245 /* Spec says 89 ref driver uses 88 */
250 static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; 246 static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 };
251 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; 247 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY };
252 248
249 pair = &hwif->drives[1 - unit];
250
253 /* 251 /*
254 * Compute the best PIO mode we can for a given device. We must 252 * Compute the best PIO mode we can for a given device. We must
255 * pick a speed that does not cause problems with the other device 253 * pick a speed that does not cause problems with the other device
@@ -286,9 +284,7 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted)
286 ide_hwif_t *hwif = drive->hwif; 284 ide_hwif_t *hwif = drive->hwif;
287 struct pci_dev *dev = to_pci_dev(hwif->dev); 285 struct pci_dev *dev = to_pci_dev(hwif->dev);
288 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); 286 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif);
289 int unit = drive->select.b.unit; 287 u8 unit = drive->dn & 1, channel = hwif->channel, conf;
290 int channel = hwif->channel;
291 u8 conf;
292 288
293 static u16 dma[] = { 0x8866, 0x3222, 0x3121 }; 289 static u16 dma[] = { 0x8866, 0x3222, 0x3121 };
294 static u8 mwdma_want[] = { ATA_ANY, ATA_66, ATA_ANY }; 290 static u8 mwdma_want[] = { ATA_ANY, ATA_66, ATA_ANY };
@@ -325,9 +321,7 @@ static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted)
325 ide_hwif_t *hwif = drive->hwif; 321 ide_hwif_t *hwif = drive->hwif;
326 struct pci_dev *dev = to_pci_dev(hwif->dev); 322 struct pci_dev *dev = to_pci_dev(hwif->dev);
327 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 323 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
328 int unit = drive->select.b.unit; 324 u8 unit = drive->dn & 1, channel = hwif->channel, conf;
329 int channel = hwif->channel;
330 u8 conf;
331 325
332 static u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 }; 326 static u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 };
333 static u8 udma_want[] = { ATA_ANY, ATA_50, ATA_ANY, ATA_66, ATA_66, ATA_50, ATA_66 }; 327 static u8 udma_want[] = { ATA_ANY, ATA_50, ATA_ANY, ATA_66, ATA_66, ATA_50, ATA_66 };
@@ -369,7 +363,8 @@ static void it821x_dma_start(ide_drive_t *drive)
369{ 363{
370 ide_hwif_t *hwif = drive->hwif; 364 ide_hwif_t *hwif = drive->hwif;
371 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 365 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
372 int unit = drive->select.b.unit; 366 u8 unit = drive->dn & 1;
367
373 if(itdev->mwdma[unit] != MWDMA_OFF) 368 if(itdev->mwdma[unit] != MWDMA_OFF)
374 it821x_program(drive, itdev->mwdma[unit]); 369 it821x_program(drive, itdev->mwdma[unit]);
375 else if(itdev->udma[unit] != UDMA_OFF && itdev->timing10) 370 else if(itdev->udma[unit] != UDMA_OFF && itdev->timing10)
@@ -389,9 +384,10 @@ static void it821x_dma_start(ide_drive_t *drive)
389static int it821x_dma_end(ide_drive_t *drive) 384static int it821x_dma_end(ide_drive_t *drive)
390{ 385{
391 ide_hwif_t *hwif = drive->hwif; 386 ide_hwif_t *hwif = drive->hwif;
392 int unit = drive->select.b.unit;
393 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 387 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
394 int ret = __ide_dma_end(drive); 388 int ret = __ide_dma_end(drive);
389 u8 unit = drive->dn & 1;
390
395 if(itdev->mwdma[unit] != MWDMA_OFF) 391 if(itdev->mwdma[unit] != MWDMA_OFF)
396 it821x_program(drive, itdev->pio[unit]); 392 it821x_program(drive, itdev->pio[unit]);
397 return ret; 393 return ret;
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index 99e98e5e271c..61a143661ee0 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -160,8 +160,8 @@ static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
160 new |= bit; 160 new |= bit;
161 161
162 /* Select PIO or DMA, DMA may only be selected for one drive/channel. */ 162 /* Select PIO or DMA, DMA may only be selected for one drive/channel. */
163 bit = 1 << (20 + drive->select.b.unit + (hwif->channel << 1)); 163 bit = 1 << (20 + (drive->dn & 1) + (hwif->channel << 1));
164 other = 1 << (20 + (1 - drive->select.b.unit) + (hwif->channel << 1)); 164 other = 1 << (20 + (1 - (drive->dn & 1)) + (hwif->channel << 1));
165 new = use_dma ? ((new & ~other) | bit) : (new & ~bit); 165 new = use_dma ? ((new & ~other) | bit) : (new & ~bit);
166 166
167 if (new != *old) { 167 if (new != *old) {
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
index 3de11ddcf863..f0db38bd70e3 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -179,7 +179,7 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
179 misc = addr_timings[clk][addr_pio]; 179 misc = addr_timings[clk][addr_pio];
180 180
181 /* select Index-0/1 for Register-A/B */ 181 /* select Index-0/1 for Register-A/B */
182 write_reg(drive->select.b.unit, MISC_REG); 182 write_reg(drive->dn & 1, MISC_REG);
183 /* set read cycle timings */ 183 /* set read cycle timings */
184 write_reg(tim, READ_REG); 184 write_reg(tim, READ_REG);
185 /* set write cycle timings */ 185 /* set write cycle timings */
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index 50405ed6f0cb..79eeeadad655 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -126,7 +126,6 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode)
126{ 126{
127 ide_hwif_t *hwif = HWIF(drive); 127 ide_hwif_t *hwif = HWIF(drive);
128 struct pci_dev *dev = to_pci_dev(hwif->dev); 128 struct pci_dev *dev = to_pci_dev(hwif->dev);
129 int unit = drive->select.b.unit;
130 unsigned int reg, timings; 129 unsigned int reg, timings;
131 unsigned short pci_clock; 130 unsigned short pci_clock;
132 unsigned int basereg = hwif->channel ? 0x50 : 0x40; 131 unsigned int basereg = hwif->channel ? 0x50 : 0x40;
@@ -155,7 +154,7 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode)
155 else 154 else
156 timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0]; 155 timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0];
157 156
158 if (unit == 0) { /* are we configuring drive0? */ 157 if ((drive->dn & 1) == 0) {
159 pci_read_config_dword(dev, basereg + 4, &reg); 158 pci_read_config_dword(dev, basereg + 4, &reg);
160 timings |= reg & 0x80000000; /* preserve PIO format bit */ 159 timings |= reg & 0x80000000; /* preserve PIO format bit */
161 pci_write_config_dword(dev, basereg + 4, timings); 160 pci_write_config_dword(dev, basereg + 4, timings);
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 62fa31409a33..0eced0ae2e86 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -291,7 +291,7 @@ static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed)
291static void scc_dma_host_set(ide_drive_t *drive, int on) 291static void scc_dma_host_set(ide_drive_t *drive, int on)
292{ 292{
293 ide_hwif_t *hwif = drive->hwif; 293 ide_hwif_t *hwif = drive->hwif;
294 u8 unit = (drive->select.b.unit & 0x01); 294 u8 unit = drive->dn & 1;
295 u8 dma_stat = scc_ide_inb(hwif->dma_base + 4); 295 u8 dma_stat = scc_ide_inb(hwif->dma_base + 4);
296 296
297 if (on) 297 if (on)
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 3dff2aea317e..7fac80192f3b 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -153,7 +153,7 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed)
153 153
154 ide_hwif_t *hwif = HWIF(drive); 154 ide_hwif_t *hwif = HWIF(drive);
155 struct pci_dev *dev = to_pci_dev(hwif->dev); 155 struct pci_dev *dev = to_pci_dev(hwif->dev);
156 u8 unit = (drive->select.b.unit & 0x01); 156 u8 unit = drive->dn & 1;
157 157
158 u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; 158 u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0;
159 159
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 174a873b4c64..134868c71c34 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -116,13 +116,14 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r)
116{ 116{
117 ide_hwif_t *hwif = HWIF(drive); 117 ide_hwif_t *hwif = HWIF(drive);
118 unsigned long base = (unsigned long)hwif->hwif_data; 118 unsigned long base = (unsigned long)hwif->hwif_data;
119 u8 unit = drive->dn & 1;
119 120
120 base += 0xA0 + r; 121 base += 0xA0 + r;
121 if (hwif->host_flags & IDE_HFLAG_MMIO) 122 if (hwif->host_flags & IDE_HFLAG_MMIO)
122 base += hwif->channel << 6; 123 base += hwif->channel << 6;
123 else 124 else
124 base += hwif->channel << 4; 125 base += hwif->channel << 4;
125 base |= drive->select.b.unit << drive->select.b.unit; 126 base |= unit << unit;
126 return base; 127 return base;
127} 128}
128 129
@@ -255,7 +256,7 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio)
255 u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) 256 u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84)
256 : (mmio ? 0xB4 : 0x80); 257 : (mmio ? 0xB4 : 0x80);
257 u8 mode = 0; 258 u8 mode = 0;
258 u8 unit = drive->select.b.unit; 259 u8 unit = drive->dn & 1;
259 260
260 /* trim *taskfile* PIO to the slowest of the master/slave */ 261 /* trim *taskfile* PIO to the slowest of the master/slave */
261 if (pair) { 262 if (pair) {
@@ -301,9 +302,9 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed)
301 302
302 ide_hwif_t *hwif = HWIF(drive); 303 ide_hwif_t *hwif = HWIF(drive);
303 struct pci_dev *dev = to_pci_dev(hwif->dev); 304 struct pci_dev *dev = to_pci_dev(hwif->dev);
304 u16 ultra = 0, multi = 0;
305 u8 mode = 0, unit = drive->select.b.unit;
306 unsigned long base = (unsigned long)hwif->hwif_data; 305 unsigned long base = (unsigned long)hwif->hwif_data;
306 u16 ultra = 0, multi = 0;
307 u8 mode = 0, unit = drive->dn & 1;
307 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; 308 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
308 u8 scsc = 0, addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) 309 u8 scsc = 0, addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84)
309 : (mmio ? 0xB4 : 0x80); 310 : (mmio ? 0xB4 : 0x80);
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index be8715dcee05..42fb98f268d5 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -38,13 +38,12 @@ static void triflex_set_mode(ide_drive_t *drive, const u8 speed)
38{ 38{
39 ide_hwif_t *hwif = HWIF(drive); 39 ide_hwif_t *hwif = HWIF(drive);
40 struct pci_dev *dev = to_pci_dev(hwif->dev); 40 struct pci_dev *dev = to_pci_dev(hwif->dev);
41 u8 channel_offset = hwif->channel ? 0x74 : 0x70;
42 u16 timing = 0;
43 u32 triflex_timings = 0; 41 u32 triflex_timings = 0;
44 u8 unit = (drive->select.b.unit & 0x01); 42 u16 timing = 0;
45 43 u8 channel_offset = hwif->channel ? 0x74 : 0x70, unit = drive->dn & 1;
44
46 pci_read_config_dword(dev, channel_offset, &triflex_timings); 45 pci_read_config_dword(dev, channel_offset, &triflex_timings);
47 46
48 switch(speed) { 47 switch(speed) {
49 case XFER_MW_DMA_2: 48 case XFER_MW_DMA_2:
50 timing = 0x0103; 49 timing = 0x0103;
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 2de22b6fe3bd..5b083700d882 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -433,7 +433,7 @@ pmac_ide_selectproc(ide_drive_t *drive)
433 if (pmif == NULL) 433 if (pmif == NULL)
434 return; 434 return;
435 435
436 if (drive->select.b.unit & 0x01) 436 if (drive->dn & 1)
437 writel(pmif->timings[1], PMAC_IDE_REG(IDE_TIMING_CONFIG)); 437 writel(pmif->timings[1], PMAC_IDE_REG(IDE_TIMING_CONFIG));
438 else 438 else
439 writel(pmif->timings[0], PMAC_IDE_REG(IDE_TIMING_CONFIG)); 439 writel(pmif->timings[0], PMAC_IDE_REG(IDE_TIMING_CONFIG));
@@ -455,7 +455,7 @@ pmac_ide_kauai_selectproc(ide_drive_t *drive)
455 if (pmif == NULL) 455 if (pmif == NULL)
456 return; 456 return;
457 457
458 if (drive->select.b.unit & 0x01) { 458 if (drive->dn & 1) {
459 writel(pmif->timings[1], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG)); 459 writel(pmif->timings[1], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG));
460 writel(pmif->timings[3], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG)); 460 writel(pmif->timings[3], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG));
461 } else { 461 } else {
@@ -528,7 +528,7 @@ pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
528 return; 528 return;
529 529
530 /* which drive is it ? */ 530 /* which drive is it ? */
531 timings = &pmif->timings[drive->select.b.unit & 0x01]; 531 timings = &pmif->timings[drive->dn & 1];
532 t = *timings; 532 t = *timings;
533 533
534 cycle_time = ide_pio_cycle_time(drive, pio); 534 cycle_time = ide_pio_cycle_time(drive, pio);
@@ -805,9 +805,9 @@ static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed)
805 ide_hwif_t *hwif = drive->hwif; 805 ide_hwif_t *hwif = drive->hwif;
806 pmac_ide_hwif_t *pmif = 806 pmac_ide_hwif_t *pmif =
807 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 807 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
808 int unit = (drive->select.b.unit & 0x01);
809 int ret = 0; 808 int ret = 0;
810 u32 *timings, *timings2, tl[2]; 809 u32 *timings, *timings2, tl[2];
810 u8 unit = drive->dn & 1;
811 811
812 timings = &pmif->timings[unit]; 812 timings = &pmif->timings[unit];
813 timings2 = &pmif->timings[unit+2]; 813 timings2 = &pmif->timings[unit+2];
@@ -1558,8 +1558,7 @@ pmac_ide_dma_setup(ide_drive_t *drive)
1558 pmac_ide_hwif_t *pmif = 1558 pmac_ide_hwif_t *pmif =
1559 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1559 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1560 struct request *rq = HWGROUP(drive)->rq; 1560 struct request *rq = HWGROUP(drive)->rq;
1561 u8 unit = (drive->select.b.unit & 0x01); 1561 u8 unit = drive->dn & 1, ata4;
1562 u8 ata4;
1563 1562
1564 if (pmif == NULL) 1563 if (pmif == NULL)
1565 return 1; 1564 return 1;