aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-iops.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-iops.c')
-rw-r--r--drivers/ide/ide-iops.c72
1 files changed, 34 insertions, 38 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 9c646bd63549..5425d3038ec2 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -164,7 +164,7 @@ void SELECT_DRIVE (ide_drive_t *drive)
164 if (port_ops && port_ops->selectproc) 164 if (port_ops && port_ops->selectproc)
165 port_ops->selectproc(drive); 165 port_ops->selectproc(drive);
166 166
167 hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]); 167 hwif->OUTB(drive->select.all, hwif->io_ports.device_addr);
168} 168}
169 169
170void SELECT_MASK (ide_drive_t *drive, int mask) 170void SELECT_MASK (ide_drive_t *drive, int mask)
@@ -194,24 +194,22 @@ static void ata_vlb_sync(ide_drive_t *drive, unsigned long port)
194 */ 194 */
195static void ata_input_data(ide_drive_t *drive, void *buffer, u32 wcount) 195static void ata_input_data(ide_drive_t *drive, void *buffer, u32 wcount)
196{ 196{
197 ide_hwif_t *hwif = HWIF(drive); 197 ide_hwif_t *hwif = drive->hwif;
198 u8 io_32bit = drive->io_32bit; 198 struct ide_io_ports *io_ports = &hwif->io_ports;
199 u8 io_32bit = drive->io_32bit;
199 200
200 if (io_32bit) { 201 if (io_32bit) {
201 if (io_32bit & 2) { 202 if (io_32bit & 2) {
202 unsigned long flags; 203 unsigned long flags;
203 204
204 local_irq_save(flags); 205 local_irq_save(flags);
205 ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]); 206 ata_vlb_sync(drive, io_ports->nsect_addr);
206 hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, 207 hwif->INSL(io_ports->data_addr, buffer, wcount);
207 wcount);
208 local_irq_restore(flags); 208 local_irq_restore(flags);
209 } else 209 } else
210 hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, 210 hwif->INSL(io_ports->data_addr, buffer, wcount);
211 wcount);
212 } else 211 } else
213 hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET], buffer, 212 hwif->INSW(io_ports->data_addr, buffer, wcount << 1);
214 wcount << 1);
215} 213}
216 214
217/* 215/*
@@ -219,24 +217,22 @@ static void ata_input_data(ide_drive_t *drive, void *buffer, u32 wcount)
219 */ 217 */
220static void ata_output_data(ide_drive_t *drive, void *buffer, u32 wcount) 218static void ata_output_data(ide_drive_t *drive, void *buffer, u32 wcount)
221{ 219{
222 ide_hwif_t *hwif = HWIF(drive); 220 ide_hwif_t *hwif = drive->hwif;
223 u8 io_32bit = drive->io_32bit; 221 struct ide_io_ports *io_ports = &hwif->io_ports;
222 u8 io_32bit = drive->io_32bit;
224 223
225 if (io_32bit) { 224 if (io_32bit) {
226 if (io_32bit & 2) { 225 if (io_32bit & 2) {
227 unsigned long flags; 226 unsigned long flags;
228 227
229 local_irq_save(flags); 228 local_irq_save(flags);
230 ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]); 229 ata_vlb_sync(drive, io_ports->nsect_addr);
231 hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, 230 hwif->OUTSL(io_ports->data_addr, buffer, wcount);
232 wcount);
233 local_irq_restore(flags); 231 local_irq_restore(flags);
234 } else 232 } else
235 hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, 233 hwif->OUTSL(io_ports->data_addr, buffer, wcount);
236 wcount);
237 } else 234 } else
238 hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET], buffer, 235 hwif->OUTSW(io_ports->data_addr, buffer, wcount << 1);
239 wcount << 1);
240} 236}
241 237
242/* 238/*
@@ -255,14 +251,13 @@ static void atapi_input_bytes(ide_drive_t *drive, void *buffer, u32 bytecount)
255#if defined(CONFIG_ATARI) || defined(CONFIG_Q40) 251#if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
256 if (MACH_IS_ATARI || MACH_IS_Q40) { 252 if (MACH_IS_ATARI || MACH_IS_Q40) {
257 /* Atari has a byte-swapped IDE interface */ 253 /* Atari has a byte-swapped IDE interface */
258 insw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer, 254 insw_swapw(hwif->io_ports.data_addr, buffer, bytecount / 2);
259 bytecount / 2);
260 return; 255 return;
261 } 256 }
262#endif /* CONFIG_ATARI || CONFIG_Q40 */ 257#endif /* CONFIG_ATARI || CONFIG_Q40 */
263 hwif->ata_input_data(drive, buffer, bytecount / 4); 258 hwif->ata_input_data(drive, buffer, bytecount / 4);
264 if ((bytecount & 0x03) >= 2) 259 if ((bytecount & 0x03) >= 2)
265 hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET], 260 hwif->INSW(hwif->io_ports.data_addr,
266 (u8 *)buffer + (bytecount & ~0x03), 1); 261 (u8 *)buffer + (bytecount & ~0x03), 1);
267} 262}
268 263
@@ -274,14 +269,13 @@ static void atapi_output_bytes(ide_drive_t *drive, void *buffer, u32 bytecount)
274#if defined(CONFIG_ATARI) || defined(CONFIG_Q40) 269#if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
275 if (MACH_IS_ATARI || MACH_IS_Q40) { 270 if (MACH_IS_ATARI || MACH_IS_Q40) {
276 /* Atari has a byte-swapped IDE interface */ 271 /* Atari has a byte-swapped IDE interface */
277 outsw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer, 272 outsw_swapw(hwif->io_ports.data_addr, buffer, bytecount / 2);
278 bytecount / 2);
279 return; 273 return;
280 } 274 }
281#endif /* CONFIG_ATARI || CONFIG_Q40 */ 275#endif /* CONFIG_ATARI || CONFIG_Q40 */
282 hwif->ata_output_data(drive, buffer, bytecount / 4); 276 hwif->ata_output_data(drive, buffer, bytecount / 4);
283 if ((bytecount & 0x03) >= 2) 277 if ((bytecount & 0x03) >= 2)
284 hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET], 278 hwif->OUTSW(hwif->io_ports.data_addr,
285 (u8 *)buffer + (bytecount & ~0x03), 1); 279 (u8 *)buffer + (bytecount & ~0x03), 1);
286} 280}
287 281
@@ -445,7 +439,7 @@ int drive_is_ready (ide_drive_t *drive)
445 * an interrupt with another pci card/device. We make no assumptions 439 * an interrupt with another pci card/device. We make no assumptions
446 * about possible isa-pnp and pci-pnp issues yet. 440 * about possible isa-pnp and pci-pnp issues yet.
447 */ 441 */
448 if (hwif->io_ports[IDE_CONTROL_OFFSET]) 442 if (hwif->io_ports.ctl_addr)
449 stat = ide_read_altstatus(drive); 443 stat = ide_read_altstatus(drive);
450 else 444 else
451 /* Note: this may clear a pending IRQ!! */ 445 /* Note: this may clear a pending IRQ!! */
@@ -647,7 +641,7 @@ int ide_driveid_update(ide_drive_t *drive)
647 SELECT_MASK(drive, 1); 641 SELECT_MASK(drive, 1);
648 ide_set_irq(drive, 1); 642 ide_set_irq(drive, 1);
649 msleep(50); 643 msleep(50);
650 hwif->OUTB(WIN_IDENTIFY, hwif->io_ports[IDE_COMMAND_OFFSET]); 644 hwif->OUTB(WIN_IDENTIFY, hwif->io_ports.command_addr);
651 timeout = jiffies + WAIT_WORSTCASE; 645 timeout = jiffies + WAIT_WORSTCASE;
652 do { 646 do {
653 if (time_after(jiffies, timeout)) { 647 if (time_after(jiffies, timeout)) {
@@ -696,6 +690,7 @@ int ide_driveid_update(ide_drive_t *drive)
696int ide_config_drive_speed(ide_drive_t *drive, u8 speed) 690int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
697{ 691{
698 ide_hwif_t *hwif = drive->hwif; 692 ide_hwif_t *hwif = drive->hwif;
693 struct ide_io_ports *io_ports = &hwif->io_ports;
699 int error = 0; 694 int error = 0;
700 u8 stat; 695 u8 stat;
701 696
@@ -734,10 +729,9 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
734 SELECT_MASK(drive, 0); 729 SELECT_MASK(drive, 0);
735 udelay(1); 730 udelay(1);
736 ide_set_irq(drive, 0); 731 ide_set_irq(drive, 0);
737 hwif->OUTB(speed, hwif->io_ports[IDE_NSECTOR_OFFSET]); 732 hwif->OUTB(speed, io_ports->nsect_addr);
738 hwif->OUTB(SETFEATURES_XFER, hwif->io_ports[IDE_FEATURE_OFFSET]); 733 hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr);
739 hwif->OUTBSYNC(drive, WIN_SETFEATURES, 734 hwif->OUTBSYNC(drive, WIN_SETFEATURES, io_ports->command_addr);
740 hwif->io_ports[IDE_COMMAND_OFFSET]);
741 if (drive->quirk_list == 2) 735 if (drive->quirk_list == 2)
742 ide_set_irq(drive, 1); 736 ide_set_irq(drive, 1);
743 737
@@ -845,7 +839,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
845 839
846 spin_lock_irqsave(&ide_lock, flags); 840 spin_lock_irqsave(&ide_lock, flags);
847 __ide_set_handler(drive, handler, timeout, expiry); 841 __ide_set_handler(drive, handler, timeout, expiry);
848 hwif->OUTBSYNC(drive, cmd, hwif->io_ports[IDE_COMMAND_OFFSET]); 842 hwif->OUTBSYNC(drive, cmd, hwif->io_ports.command_addr);
849 /* 843 /*
850 * Drive takes 400nS to respond, we must avoid the IRQ being 844 * Drive takes 400nS to respond, we must avoid the IRQ being
851 * serviced before that. 845 * serviced before that.
@@ -1029,6 +1023,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1029 unsigned long flags; 1023 unsigned long flags;
1030 ide_hwif_t *hwif; 1024 ide_hwif_t *hwif;
1031 ide_hwgroup_t *hwgroup; 1025 ide_hwgroup_t *hwgroup;
1026 struct ide_io_ports *io_ports;
1032 const struct ide_port_ops *port_ops; 1027 const struct ide_port_ops *port_ops;
1033 u8 ctl; 1028 u8 ctl;
1034 1029
@@ -1036,6 +1031,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1036 hwif = HWIF(drive); 1031 hwif = HWIF(drive);
1037 hwgroup = HWGROUP(drive); 1032 hwgroup = HWGROUP(drive);
1038 1033
1034 io_ports = &hwif->io_ports;
1035
1039 /* We must not reset with running handlers */ 1036 /* We must not reset with running handlers */
1040 BUG_ON(hwgroup->handler != NULL); 1037 BUG_ON(hwgroup->handler != NULL);
1041 1038
@@ -1045,8 +1042,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1045 pre_reset(drive); 1042 pre_reset(drive);
1046 SELECT_DRIVE(drive); 1043 SELECT_DRIVE(drive);
1047 udelay (20); 1044 udelay (20);
1048 hwif->OUTBSYNC(drive, WIN_SRST, 1045 hwif->OUTBSYNC(drive, WIN_SRST, io_ports->command_addr);
1049 hwif->io_ports[IDE_COMMAND_OFFSET]);
1050 ndelay(400); 1046 ndelay(400);
1051 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1047 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
1052 hwgroup->polling = 1; 1048 hwgroup->polling = 1;
@@ -1062,7 +1058,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1062 for (unit = 0; unit < MAX_DRIVES; ++unit) 1058 for (unit = 0; unit < MAX_DRIVES; ++unit)
1063 pre_reset(&hwif->drives[unit]); 1059 pre_reset(&hwif->drives[unit]);
1064 1060
1065 if (hwif->io_ports[IDE_CONTROL_OFFSET] == 0) { 1061 if (io_ports->ctl_addr == 0) {
1066 spin_unlock_irqrestore(&ide_lock, flags); 1062 spin_unlock_irqrestore(&ide_lock, flags);
1067 return ide_stopped; 1063 return ide_stopped;
1068 } 1064 }
@@ -1077,14 +1073,14 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1077 * recover from reset very quickly, saving us the first 50ms wait time. 1073 * recover from reset very quickly, saving us the first 50ms wait time.
1078 */ 1074 */
1079 /* set SRST and nIEN */ 1075 /* set SRST and nIEN */
1080 hwif->OUTBSYNC(drive, drive->ctl|6, hwif->io_ports[IDE_CONTROL_OFFSET]); 1076 hwif->OUTBSYNC(drive, drive->ctl|6, io_ports->ctl_addr);
1081 /* more than enough time */ 1077 /* more than enough time */
1082 udelay(10); 1078 udelay(10);
1083 if (drive->quirk_list == 2) 1079 if (drive->quirk_list == 2)
1084 ctl = drive->ctl; /* clear SRST and nIEN */ 1080 ctl = drive->ctl; /* clear SRST and nIEN */
1085 else 1081 else
1086 ctl = drive->ctl | 2; /* clear SRST, leave nIEN */ 1082 ctl = drive->ctl | 2; /* clear SRST, leave nIEN */
1087 hwif->OUTBSYNC(drive, ctl, hwif->io_ports[IDE_CONTROL_OFFSET]); 1083 hwif->OUTBSYNC(drive, ctl, io_ports->ctl_addr);
1088 /* more than enough time */ 1084 /* more than enough time */
1089 udelay(10); 1085 udelay(10);
1090 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1086 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
@@ -1129,7 +1125,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
1129 * about locking issues (2.5 work ?). 1125 * about locking issues (2.5 work ?).
1130 */ 1126 */
1131 mdelay(1); 1127 mdelay(1);
1132 stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); 1128 stat = hwif->INB(hwif->io_ports.status_addr);
1133 if ((stat & BUSY_STAT) == 0) 1129 if ((stat & BUSY_STAT) == 0)
1134 return 0; 1130 return 0;
1135 /* 1131 /*