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.c110
1 files changed, 57 insertions, 53 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 45944219eea0..5425d3038ec2 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -159,17 +159,20 @@ EXPORT_SYMBOL(default_hwif_mmiops);
159void SELECT_DRIVE (ide_drive_t *drive) 159void SELECT_DRIVE (ide_drive_t *drive)
160{ 160{
161 ide_hwif_t *hwif = drive->hwif; 161 ide_hwif_t *hwif = drive->hwif;
162 const struct ide_port_ops *port_ops = hwif->port_ops;
162 163
163 if (hwif->selectproc) 164 if (port_ops && port_ops->selectproc)
164 hwif->selectproc(drive); 165 port_ops->selectproc(drive);
165 166
166 hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]); 167 hwif->OUTB(drive->select.all, hwif->io_ports.device_addr);
167} 168}
168 169
169void SELECT_MASK (ide_drive_t *drive, int mask) 170void SELECT_MASK (ide_drive_t *drive, int mask)
170{ 171{
171 if (HWIF(drive)->maskproc) 172 const struct ide_port_ops *port_ops = drive->hwif->port_ops;
172 HWIF(drive)->maskproc(drive, mask); 173
174 if (port_ops && port_ops->maskproc)
175 port_ops->maskproc(drive, mask);
173} 176}
174 177
175/* 178/*
@@ -191,24 +194,22 @@ static void ata_vlb_sync(ide_drive_t *drive, unsigned long port)
191 */ 194 */
192static 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)
193{ 196{
194 ide_hwif_t *hwif = HWIF(drive); 197 ide_hwif_t *hwif = drive->hwif;
195 u8 io_32bit = drive->io_32bit; 198 struct ide_io_ports *io_ports = &hwif->io_ports;
199 u8 io_32bit = drive->io_32bit;
196 200
197 if (io_32bit) { 201 if (io_32bit) {
198 if (io_32bit & 2) { 202 if (io_32bit & 2) {
199 unsigned long flags; 203 unsigned long flags;
200 204
201 local_irq_save(flags); 205 local_irq_save(flags);
202 ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]); 206 ata_vlb_sync(drive, io_ports->nsect_addr);
203 hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, 207 hwif->INSL(io_ports->data_addr, buffer, wcount);
204 wcount);
205 local_irq_restore(flags); 208 local_irq_restore(flags);
206 } else 209 } else
207 hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, 210 hwif->INSL(io_ports->data_addr, buffer, wcount);
208 wcount);
209 } else 211 } else
210 hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET], buffer, 212 hwif->INSW(io_ports->data_addr, buffer, wcount << 1);
211 wcount << 1);
212} 213}
213 214
214/* 215/*
@@ -216,24 +217,22 @@ static void ata_input_data(ide_drive_t *drive, void *buffer, u32 wcount)
216 */ 217 */
217static 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)
218{ 219{
219 ide_hwif_t *hwif = HWIF(drive); 220 ide_hwif_t *hwif = drive->hwif;
220 u8 io_32bit = drive->io_32bit; 221 struct ide_io_ports *io_ports = &hwif->io_ports;
222 u8 io_32bit = drive->io_32bit;
221 223
222 if (io_32bit) { 224 if (io_32bit) {
223 if (io_32bit & 2) { 225 if (io_32bit & 2) {
224 unsigned long flags; 226 unsigned long flags;
225 227
226 local_irq_save(flags); 228 local_irq_save(flags);
227 ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]); 229 ata_vlb_sync(drive, io_ports->nsect_addr);
228 hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, 230 hwif->OUTSL(io_ports->data_addr, buffer, wcount);
229 wcount);
230 local_irq_restore(flags); 231 local_irq_restore(flags);
231 } else 232 } else
232 hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer, 233 hwif->OUTSL(io_ports->data_addr, buffer, wcount);
233 wcount);
234 } else 234 } else
235 hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET], buffer, 235 hwif->OUTSW(io_ports->data_addr, buffer, wcount << 1);
236 wcount << 1);
237} 236}
238 237
239/* 238/*
@@ -252,14 +251,13 @@ static void atapi_input_bytes(ide_drive_t *drive, void *buffer, u32 bytecount)
252#if defined(CONFIG_ATARI) || defined(CONFIG_Q40) 251#if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
253 if (MACH_IS_ATARI || MACH_IS_Q40) { 252 if (MACH_IS_ATARI || MACH_IS_Q40) {
254 /* Atari has a byte-swapped IDE interface */ 253 /* Atari has a byte-swapped IDE interface */
255 insw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer, 254 insw_swapw(hwif->io_ports.data_addr, buffer, bytecount / 2);
256 bytecount / 2);
257 return; 255 return;
258 } 256 }
259#endif /* CONFIG_ATARI || CONFIG_Q40 */ 257#endif /* CONFIG_ATARI || CONFIG_Q40 */
260 hwif->ata_input_data(drive, buffer, bytecount / 4); 258 hwif->ata_input_data(drive, buffer, bytecount / 4);
261 if ((bytecount & 0x03) >= 2) 259 if ((bytecount & 0x03) >= 2)
262 hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET], 260 hwif->INSW(hwif->io_ports.data_addr,
263 (u8 *)buffer + (bytecount & ~0x03), 1); 261 (u8 *)buffer + (bytecount & ~0x03), 1);
264} 262}
265 263
@@ -271,14 +269,13 @@ static void atapi_output_bytes(ide_drive_t *drive, void *buffer, u32 bytecount)
271#if defined(CONFIG_ATARI) || defined(CONFIG_Q40) 269#if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
272 if (MACH_IS_ATARI || MACH_IS_Q40) { 270 if (MACH_IS_ATARI || MACH_IS_Q40) {
273 /* Atari has a byte-swapped IDE interface */ 271 /* Atari has a byte-swapped IDE interface */
274 outsw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer, 272 outsw_swapw(hwif->io_ports.data_addr, buffer, bytecount / 2);
275 bytecount / 2);
276 return; 273 return;
277 } 274 }
278#endif /* CONFIG_ATARI || CONFIG_Q40 */ 275#endif /* CONFIG_ATARI || CONFIG_Q40 */
279 hwif->ata_output_data(drive, buffer, bytecount / 4); 276 hwif->ata_output_data(drive, buffer, bytecount / 4);
280 if ((bytecount & 0x03) >= 2) 277 if ((bytecount & 0x03) >= 2)
281 hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET], 278 hwif->OUTSW(hwif->io_ports.data_addr,
282 (u8 *)buffer + (bytecount & ~0x03), 1); 279 (u8 *)buffer + (bytecount & ~0x03), 1);
283} 280}
284 281
@@ -429,7 +426,7 @@ int drive_is_ready (ide_drive_t *drive)
429 u8 stat = 0; 426 u8 stat = 0;
430 427
431 if (drive->waiting_for_dma) 428 if (drive->waiting_for_dma)
432 return hwif->ide_dma_test_irq(drive); 429 return hwif->dma_ops->dma_test_irq(drive);
433 430
434#if 0 431#if 0
435 /* need to guarantee 400ns since last command was issued */ 432 /* need to guarantee 400ns since last command was issued */
@@ -442,7 +439,7 @@ int drive_is_ready (ide_drive_t *drive)
442 * an interrupt with another pci card/device. We make no assumptions 439 * an interrupt with another pci card/device. We make no assumptions
443 * about possible isa-pnp and pci-pnp issues yet. 440 * about possible isa-pnp and pci-pnp issues yet.
444 */ 441 */
445 if (hwif->io_ports[IDE_CONTROL_OFFSET]) 442 if (hwif->io_ports.ctl_addr)
446 stat = ide_read_altstatus(drive); 443 stat = ide_read_altstatus(drive);
447 else 444 else
448 /* Note: this may clear a pending IRQ!! */ 445 /* Note: this may clear a pending IRQ!! */
@@ -644,7 +641,7 @@ int ide_driveid_update(ide_drive_t *drive)
644 SELECT_MASK(drive, 1); 641 SELECT_MASK(drive, 1);
645 ide_set_irq(drive, 1); 642 ide_set_irq(drive, 1);
646 msleep(50); 643 msleep(50);
647 hwif->OUTB(WIN_IDENTIFY, hwif->io_ports[IDE_COMMAND_OFFSET]); 644 hwif->OUTB(WIN_IDENTIFY, hwif->io_ports.command_addr);
648 timeout = jiffies + WAIT_WORSTCASE; 645 timeout = jiffies + WAIT_WORSTCASE;
649 do { 646 do {
650 if (time_after(jiffies, timeout)) { 647 if (time_after(jiffies, timeout)) {
@@ -693,6 +690,7 @@ int ide_driveid_update(ide_drive_t *drive)
693int ide_config_drive_speed(ide_drive_t *drive, u8 speed) 690int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
694{ 691{
695 ide_hwif_t *hwif = drive->hwif; 692 ide_hwif_t *hwif = drive->hwif;
693 struct ide_io_ports *io_ports = &hwif->io_ports;
696 int error = 0; 694 int error = 0;
697 u8 stat; 695 u8 stat;
698 696
@@ -700,8 +698,8 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
700// msleep(50); 698// msleep(50);
701 699
702#ifdef CONFIG_BLK_DEV_IDEDMA 700#ifdef CONFIG_BLK_DEV_IDEDMA
703 if (hwif->dma_host_set) /* check if host supports DMA */ 701 if (hwif->dma_ops) /* check if host supports DMA */
704 hwif->dma_host_set(drive, 0); 702 hwif->dma_ops->dma_host_set(drive, 0);
705#endif 703#endif
706 704
707 /* Skip setting PIO flow-control modes on pre-EIDE drives */ 705 /* Skip setting PIO flow-control modes on pre-EIDE drives */
@@ -731,10 +729,9 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
731 SELECT_MASK(drive, 0); 729 SELECT_MASK(drive, 0);
732 udelay(1); 730 udelay(1);
733 ide_set_irq(drive, 0); 731 ide_set_irq(drive, 0);
734 hwif->OUTB(speed, hwif->io_ports[IDE_NSECTOR_OFFSET]); 732 hwif->OUTB(speed, io_ports->nsect_addr);
735 hwif->OUTB(SETFEATURES_XFER, hwif->io_ports[IDE_FEATURE_OFFSET]); 733 hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr);
736 hwif->OUTBSYNC(drive, WIN_SETFEATURES, 734 hwif->OUTBSYNC(drive, WIN_SETFEATURES, io_ports->command_addr);
737 hwif->io_ports[IDE_COMMAND_OFFSET]);
738 if (drive->quirk_list == 2) 735 if (drive->quirk_list == 2)
739 ide_set_irq(drive, 1); 736 ide_set_irq(drive, 1);
740 737
@@ -759,8 +756,8 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
759#ifdef CONFIG_BLK_DEV_IDEDMA 756#ifdef CONFIG_BLK_DEV_IDEDMA
760 if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) && 757 if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) &&
761 drive->using_dma) 758 drive->using_dma)
762 hwif->dma_host_set(drive, 1); 759 hwif->dma_ops->dma_host_set(drive, 1);
763 else if (hwif->dma_host_set) /* check if host supports DMA */ 760 else if (hwif->dma_ops) /* check if host supports DMA */
764 ide_dma_off_quietly(drive); 761 ide_dma_off_quietly(drive);
765#endif 762#endif
766 763
@@ -842,7 +839,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
842 839
843 spin_lock_irqsave(&ide_lock, flags); 840 spin_lock_irqsave(&ide_lock, flags);
844 __ide_set_handler(drive, handler, timeout, expiry); 841 __ide_set_handler(drive, handler, timeout, expiry);
845 hwif->OUTBSYNC(drive, cmd, hwif->io_ports[IDE_COMMAND_OFFSET]); 842 hwif->OUTBSYNC(drive, cmd, hwif->io_ports.command_addr);
846 /* 843 /*
847 * Drive takes 400nS to respond, we must avoid the IRQ being 844 * Drive takes 400nS to respond, we must avoid the IRQ being
848 * serviced before that. 845 * serviced before that.
@@ -905,10 +902,11 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
905{ 902{
906 ide_hwgroup_t *hwgroup = HWGROUP(drive); 903 ide_hwgroup_t *hwgroup = HWGROUP(drive);
907 ide_hwif_t *hwif = HWIF(drive); 904 ide_hwif_t *hwif = HWIF(drive);
905 const struct ide_port_ops *port_ops = hwif->port_ops;
908 u8 tmp; 906 u8 tmp;
909 907
910 if (hwif->reset_poll != NULL) { 908 if (port_ops && port_ops->reset_poll) {
911 if (hwif->reset_poll(drive)) { 909 if (port_ops->reset_poll(drive)) {
912 printk(KERN_ERR "%s: host reset_poll failure for %s.\n", 910 printk(KERN_ERR "%s: host reset_poll failure for %s.\n",
913 hwif->name, drive->name); 911 hwif->name, drive->name);
914 return ide_stopped; 912 return ide_stopped;
@@ -974,6 +972,8 @@ static void ide_disk_pre_reset(ide_drive_t *drive)
974 972
975static void pre_reset(ide_drive_t *drive) 973static void pre_reset(ide_drive_t *drive)
976{ 974{
975 const struct ide_port_ops *port_ops = drive->hwif->port_ops;
976
977 if (drive->media == ide_disk) 977 if (drive->media == ide_disk)
978 ide_disk_pre_reset(drive); 978 ide_disk_pre_reset(drive);
979 else 979 else
@@ -994,8 +994,8 @@ static void pre_reset(ide_drive_t *drive)
994 return; 994 return;
995 } 995 }
996 996
997 if (HWIF(drive)->pre_reset != NULL) 997 if (port_ops && port_ops->pre_reset)
998 HWIF(drive)->pre_reset(drive); 998 port_ops->pre_reset(drive);
999 999
1000 if (drive->current_speed != 0xff) 1000 if (drive->current_speed != 0xff)
1001 drive->desired_speed = drive->current_speed; 1001 drive->desired_speed = drive->current_speed;
@@ -1023,12 +1023,16 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1023 unsigned long flags; 1023 unsigned long flags;
1024 ide_hwif_t *hwif; 1024 ide_hwif_t *hwif;
1025 ide_hwgroup_t *hwgroup; 1025 ide_hwgroup_t *hwgroup;
1026 struct ide_io_ports *io_ports;
1027 const struct ide_port_ops *port_ops;
1026 u8 ctl; 1028 u8 ctl;
1027 1029
1028 spin_lock_irqsave(&ide_lock, flags); 1030 spin_lock_irqsave(&ide_lock, flags);
1029 hwif = HWIF(drive); 1031 hwif = HWIF(drive);
1030 hwgroup = HWGROUP(drive); 1032 hwgroup = HWGROUP(drive);
1031 1033
1034 io_ports = &hwif->io_ports;
1035
1032 /* We must not reset with running handlers */ 1036 /* We must not reset with running handlers */
1033 BUG_ON(hwgroup->handler != NULL); 1037 BUG_ON(hwgroup->handler != NULL);
1034 1038
@@ -1038,8 +1042,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1038 pre_reset(drive); 1042 pre_reset(drive);
1039 SELECT_DRIVE(drive); 1043 SELECT_DRIVE(drive);
1040 udelay (20); 1044 udelay (20);
1041 hwif->OUTBSYNC(drive, WIN_SRST, 1045 hwif->OUTBSYNC(drive, WIN_SRST, io_ports->command_addr);
1042 hwif->io_ports[IDE_COMMAND_OFFSET]);
1043 ndelay(400); 1046 ndelay(400);
1044 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1047 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
1045 hwgroup->polling = 1; 1048 hwgroup->polling = 1;
@@ -1055,7 +1058,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1055 for (unit = 0; unit < MAX_DRIVES; ++unit) 1058 for (unit = 0; unit < MAX_DRIVES; ++unit)
1056 pre_reset(&hwif->drives[unit]); 1059 pre_reset(&hwif->drives[unit]);
1057 1060
1058 if (hwif->io_ports[IDE_CONTROL_OFFSET] == 0) { 1061 if (io_ports->ctl_addr == 0) {
1059 spin_unlock_irqrestore(&ide_lock, flags); 1062 spin_unlock_irqrestore(&ide_lock, flags);
1060 return ide_stopped; 1063 return ide_stopped;
1061 } 1064 }
@@ -1070,14 +1073,14 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1070 * 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.
1071 */ 1074 */
1072 /* set SRST and nIEN */ 1075 /* set SRST and nIEN */
1073 hwif->OUTBSYNC(drive, drive->ctl|6, hwif->io_ports[IDE_CONTROL_OFFSET]); 1076 hwif->OUTBSYNC(drive, drive->ctl|6, io_ports->ctl_addr);
1074 /* more than enough time */ 1077 /* more than enough time */
1075 udelay(10); 1078 udelay(10);
1076 if (drive->quirk_list == 2) 1079 if (drive->quirk_list == 2)
1077 ctl = drive->ctl; /* clear SRST and nIEN */ 1080 ctl = drive->ctl; /* clear SRST and nIEN */
1078 else 1081 else
1079 ctl = drive->ctl | 2; /* clear SRST, leave nIEN */ 1082 ctl = drive->ctl | 2; /* clear SRST, leave nIEN */
1080 hwif->OUTBSYNC(drive, ctl, hwif->io_ports[IDE_CONTROL_OFFSET]); 1083 hwif->OUTBSYNC(drive, ctl, io_ports->ctl_addr);
1081 /* more than enough time */ 1084 /* more than enough time */
1082 udelay(10); 1085 udelay(10);
1083 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1086 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
@@ -1089,8 +1092,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1089 * state when the disks are reset this way. At least, the Winbond 1092 * state when the disks are reset this way. At least, the Winbond
1090 * 553 documentation says that 1093 * 553 documentation says that
1091 */ 1094 */
1092 if (hwif->resetproc) 1095 port_ops = hwif->port_ops;
1093 hwif->resetproc(drive); 1096 if (port_ops && port_ops->resetproc)
1097 port_ops->resetproc(drive);
1094 1098
1095 spin_unlock_irqrestore(&ide_lock, flags); 1099 spin_unlock_irqrestore(&ide_lock, flags);
1096 return ide_started; 1100 return ide_started;
@@ -1121,7 +1125,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
1121 * about locking issues (2.5 work ?). 1125 * about locking issues (2.5 work ?).
1122 */ 1126 */
1123 mdelay(1); 1127 mdelay(1);
1124 stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); 1128 stat = hwif->INB(hwif->io_ports.status_addr);
1125 if ((stat & BUSY_STAT) == 0) 1129 if ((stat & BUSY_STAT) == 0)
1126 return 0; 1130 return 0;
1127 /* 1131 /*