Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 1 | |
| 2 | #include <linux/kernel.h> |
| 3 | #include <linux/ide.h> |
| 4 | |
Bartlomiej Zolnierkiewicz | 15a453a | 2009-03-27 12:46:26 +0100 | [diff] [blame] | 5 | #if defined(CONFIG_ARM) || defined(CONFIG_M68K) || defined(CONFIG_MIPS) || \ |
| 6 | defined(CONFIG_PARISC) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) |
| 7 | #include <asm/ide.h> |
| 8 | #else |
| 9 | #include <asm-generic/ide_iops.h> |
| 10 | #endif |
| 11 | |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 12 | /* |
| 13 | * Conventional PIO operations for ATA devices |
| 14 | */ |
| 15 | |
| 16 | static u8 ide_inb(unsigned long port) |
| 17 | { |
| 18 | return (u8) inb(port); |
| 19 | } |
| 20 | |
| 21 | static void ide_outb(u8 val, unsigned long port) |
| 22 | { |
| 23 | outb(val, port); |
| 24 | } |
| 25 | |
| 26 | /* |
| 27 | * MMIO operations, typically used for SATA controllers |
| 28 | */ |
| 29 | |
| 30 | static u8 ide_mm_inb(unsigned long port) |
| 31 | { |
| 32 | return (u8) readb((void __iomem *) port); |
| 33 | } |
| 34 | |
| 35 | static void ide_mm_outb(u8 value, unsigned long port) |
| 36 | { |
| 37 | writeb(value, (void __iomem *) port); |
| 38 | } |
| 39 | |
| 40 | void ide_exec_command(ide_hwif_t *hwif, u8 cmd) |
| 41 | { |
| 42 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
| 43 | writeb(cmd, (void __iomem *)hwif->io_ports.command_addr); |
| 44 | else |
| 45 | outb(cmd, hwif->io_ports.command_addr); |
| 46 | } |
| 47 | EXPORT_SYMBOL_GPL(ide_exec_command); |
| 48 | |
| 49 | u8 ide_read_status(ide_hwif_t *hwif) |
| 50 | { |
| 51 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
| 52 | return readb((void __iomem *)hwif->io_ports.status_addr); |
| 53 | else |
| 54 | return inb(hwif->io_ports.status_addr); |
| 55 | } |
| 56 | EXPORT_SYMBOL_GPL(ide_read_status); |
| 57 | |
| 58 | u8 ide_read_altstatus(ide_hwif_t *hwif) |
| 59 | { |
| 60 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
| 61 | return readb((void __iomem *)hwif->io_ports.ctl_addr); |
| 62 | else |
| 63 | return inb(hwif->io_ports.ctl_addr); |
| 64 | } |
| 65 | EXPORT_SYMBOL_GPL(ide_read_altstatus); |
| 66 | |
Sergei Shtylyov | ecf3a31 | 2009-03-31 20:15:30 +0200 | [diff] [blame] | 67 | void ide_write_devctl(ide_hwif_t *hwif, u8 ctl) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 68 | { |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 69 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
| 70 | writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr); |
| 71 | else |
| 72 | outb(ctl, hwif->io_ports.ctl_addr); |
| 73 | } |
Sergei Shtylyov | ecf3a31 | 2009-03-31 20:15:30 +0200 | [diff] [blame] | 74 | EXPORT_SYMBOL_GPL(ide_write_devctl); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 75 | |
Sergei Shtylyov | abb596b | 2009-03-31 20:15:32 +0200 | [diff] [blame] | 76 | void ide_dev_select(ide_drive_t *drive) |
| 77 | { |
| 78 | ide_hwif_t *hwif = drive->hwif; |
| 79 | u8 select = drive->select | ATA_DEVICE_OBS; |
| 80 | |
| 81 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
| 82 | writeb(select, (void __iomem *)hwif->io_ports.device_addr); |
| 83 | else |
| 84 | outb(select, hwif->io_ports.device_addr); |
| 85 | } |
| 86 | EXPORT_SYMBOL_GPL(ide_dev_select); |
| 87 | |
Bartlomiej Zolnierkiewicz | 22aa4b3 | 2009-03-27 12:46:37 +0100 | [diff] [blame] | 88 | void ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 89 | { |
| 90 | ide_hwif_t *hwif = drive->hwif; |
| 91 | struct ide_io_ports *io_ports = &hwif->io_ports; |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 92 | struct ide_taskfile *tf = &cmd->hob; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 93 | void (*tf_outb)(u8 addr, unsigned long port); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 94 | u8 valid = cmd->valid.out.hob; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 95 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
Bartlomiej Zolnierkiewicz | 22aa4b3 | 2009-03-27 12:46:37 +0100 | [diff] [blame] | 96 | u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 97 | |
| 98 | if (mmio) |
| 99 | tf_outb = ide_mm_outb; |
| 100 | else |
| 101 | tf_outb = ide_outb; |
| 102 | |
Bartlomiej Zolnierkiewicz | 22aa4b3 | 2009-03-27 12:46:37 +0100 | [diff] [blame] | 103 | if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 104 | HIHI = 0xFF; |
| 105 | |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 106 | if (valid & IDE_VALID_FEATURE) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 107 | tf_outb(tf->feature, io_ports->feature_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 108 | if (valid & IDE_VALID_NSECT) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 109 | tf_outb(tf->nsect, io_ports->nsect_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 110 | if (valid & IDE_VALID_LBAL) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 111 | tf_outb(tf->lbal, io_ports->lbal_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 112 | if (valid & IDE_VALID_LBAM) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 113 | tf_outb(tf->lbam, io_ports->lbam_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 114 | if (valid & IDE_VALID_LBAH) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 115 | tf_outb(tf->lbah, io_ports->lbah_addr); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 116 | |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 117 | tf = &cmd->tf; |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 118 | valid = cmd->valid.out.tf; |
| 119 | |
| 120 | if (valid & IDE_VALID_FEATURE) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 121 | tf_outb(tf->feature, io_ports->feature_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 122 | if (valid & IDE_VALID_NSECT) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 123 | tf_outb(tf->nsect, io_ports->nsect_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 124 | if (valid & IDE_VALID_LBAL) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 125 | tf_outb(tf->lbal, io_ports->lbal_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 126 | if (valid & IDE_VALID_LBAM) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 127 | tf_outb(tf->lbam, io_ports->lbam_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 128 | if (valid & IDE_VALID_LBAH) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 129 | tf_outb(tf->lbah, io_ports->lbah_addr); |
| 130 | |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 131 | if (valid & IDE_VALID_DEVICE) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 132 | tf_outb((tf->device & HIHI) | drive->select, |
| 133 | io_ports->device_addr); |
| 134 | } |
| 135 | EXPORT_SYMBOL_GPL(ide_tf_load); |
| 136 | |
Bartlomiej Zolnierkiewicz | 22aa4b3 | 2009-03-27 12:46:37 +0100 | [diff] [blame] | 137 | void ide_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 138 | { |
| 139 | ide_hwif_t *hwif = drive->hwif; |
| 140 | struct ide_io_ports *io_ports = &hwif->io_ports; |
Bartlomiej Zolnierkiewicz | 22aa4b3 | 2009-03-27 12:46:37 +0100 | [diff] [blame] | 141 | struct ide_taskfile *tf = &cmd->tf; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 142 | void (*tf_outb)(u8 addr, unsigned long port); |
| 143 | u8 (*tf_inb)(unsigned long port); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 144 | u8 valid = cmd->valid.in.tf; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 145 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
| 146 | |
| 147 | if (mmio) { |
| 148 | tf_outb = ide_mm_outb; |
| 149 | tf_inb = ide_mm_inb; |
| 150 | } else { |
| 151 | tf_outb = ide_outb; |
| 152 | tf_inb = ide_inb; |
| 153 | } |
| 154 | |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 155 | /* be sure we're looking at the low order bits */ |
Sergei Shtylyov | 4d74c3f | 2009-03-31 20:15:29 +0200 | [diff] [blame] | 156 | tf_outb(ATA_DEVCTL_OBS, io_ports->ctl_addr); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 157 | |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 158 | if (valid & IDE_VALID_ERROR) |
Sergei Shtylyov | 6762511 | 2009-03-31 20:15:30 +0200 | [diff] [blame] | 159 | tf->error = tf_inb(io_ports->feature_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 160 | if (valid & IDE_VALID_NSECT) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 161 | tf->nsect = tf_inb(io_ports->nsect_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 162 | if (valid & IDE_VALID_LBAL) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 163 | tf->lbal = tf_inb(io_ports->lbal_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 164 | if (valid & IDE_VALID_LBAM) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 165 | tf->lbam = tf_inb(io_ports->lbam_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 166 | if (valid & IDE_VALID_LBAH) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 167 | tf->lbah = tf_inb(io_ports->lbah_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 168 | if (valid & IDE_VALID_DEVICE) |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 169 | tf->device = tf_inb(io_ports->device_addr); |
| 170 | |
Bartlomiej Zolnierkiewicz | 22aa4b3 | 2009-03-27 12:46:37 +0100 | [diff] [blame] | 171 | if (cmd->tf_flags & IDE_TFLAG_LBA48) { |
Sergei Shtylyov | 4d74c3f | 2009-03-31 20:15:29 +0200 | [diff] [blame] | 172 | tf_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 173 | |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 174 | tf = &cmd->hob; |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 175 | valid = cmd->valid.in.hob; |
| 176 | |
| 177 | if (valid & IDE_VALID_ERROR) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 178 | tf->error = tf_inb(io_ports->feature_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 179 | if (valid & IDE_VALID_NSECT) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 180 | tf->nsect = tf_inb(io_ports->nsect_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 181 | if (valid & IDE_VALID_LBAL) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 182 | tf->lbal = tf_inb(io_ports->lbal_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 183 | if (valid & IDE_VALID_LBAM) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 184 | tf->lbam = tf_inb(io_ports->lbam_addr); |
Sergei Shtylyov | 60f8501 | 2009-04-08 14:13:01 +0200 | [diff] [blame] | 185 | if (valid & IDE_VALID_LBAH) |
Sergei Shtylyov | 745483f | 2009-04-08 14:13:02 +0200 | [diff] [blame^] | 186 | tf->lbah = tf_inb(io_ports->lbah_addr); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 187 | } |
| 188 | } |
| 189 | EXPORT_SYMBOL_GPL(ide_tf_read); |
| 190 | |
| 191 | /* |
| 192 | * Some localbus EIDE interfaces require a special access sequence |
| 193 | * when using 32-bit I/O instructions to transfer data. We call this |
| 194 | * the "vlb_sync" sequence, which consists of three successive reads |
| 195 | * of the sector count register location, with interrupts disabled |
| 196 | * to ensure that the reads all happen together. |
| 197 | */ |
| 198 | static void ata_vlb_sync(unsigned long port) |
| 199 | { |
| 200 | (void)inb(port); |
| 201 | (void)inb(port); |
| 202 | (void)inb(port); |
| 203 | } |
| 204 | |
| 205 | /* |
| 206 | * This is used for most PIO data transfers *from* the IDE interface |
| 207 | * |
| 208 | * These routines will round up any request for an odd number of bytes, |
| 209 | * so if an odd len is specified, be sure that there's at least one |
| 210 | * extra byte allocated for the buffer. |
| 211 | */ |
Bartlomiej Zolnierkiewicz | adb1af9 | 2009-03-27 12:46:38 +0100 | [diff] [blame] | 212 | void ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf, |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 213 | unsigned int len) |
| 214 | { |
| 215 | ide_hwif_t *hwif = drive->hwif; |
| 216 | struct ide_io_ports *io_ports = &hwif->io_ports; |
| 217 | unsigned long data_addr = io_ports->data_addr; |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 218 | unsigned int words = (len + 1) >> 1; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 219 | u8 io_32bit = drive->io_32bit; |
| 220 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
| 221 | |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 222 | if (io_32bit) { |
| 223 | unsigned long uninitialized_var(flags); |
| 224 | |
| 225 | if ((io_32bit & 2) && !mmio) { |
| 226 | local_irq_save(flags); |
| 227 | ata_vlb_sync(io_ports->nsect_addr); |
| 228 | } |
| 229 | |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 230 | words >>= 1; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 231 | if (mmio) |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 232 | __ide_mm_insl((void __iomem *)data_addr, buf, words); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 233 | else |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 234 | insl(data_addr, buf, words); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 235 | |
| 236 | if ((io_32bit & 2) && !mmio) |
| 237 | local_irq_restore(flags); |
| 238 | |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 239 | if (((len + 1) & 3) < 2) |
| 240 | return; |
| 241 | |
| 242 | buf += len & ~3; |
| 243 | words = 1; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 244 | } |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 245 | |
| 246 | if (mmio) |
| 247 | __ide_mm_insw((void __iomem *)data_addr, buf, words); |
| 248 | else |
| 249 | insw(data_addr, buf, words); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 250 | } |
| 251 | EXPORT_SYMBOL_GPL(ide_input_data); |
| 252 | |
| 253 | /* |
| 254 | * This is used for most PIO data transfers *to* the IDE interface |
| 255 | */ |
Bartlomiej Zolnierkiewicz | adb1af9 | 2009-03-27 12:46:38 +0100 | [diff] [blame] | 256 | void ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf, |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 257 | unsigned int len) |
| 258 | { |
| 259 | ide_hwif_t *hwif = drive->hwif; |
| 260 | struct ide_io_ports *io_ports = &hwif->io_ports; |
| 261 | unsigned long data_addr = io_ports->data_addr; |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 262 | unsigned int words = (len + 1) >> 1; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 263 | u8 io_32bit = drive->io_32bit; |
| 264 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
| 265 | |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 266 | if (io_32bit) { |
| 267 | unsigned long uninitialized_var(flags); |
| 268 | |
| 269 | if ((io_32bit & 2) && !mmio) { |
| 270 | local_irq_save(flags); |
| 271 | ata_vlb_sync(io_ports->nsect_addr); |
| 272 | } |
| 273 | |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 274 | words >>= 1; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 275 | if (mmio) |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 276 | __ide_mm_outsl((void __iomem *)data_addr, buf, words); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 277 | else |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 278 | outsl(data_addr, buf, words); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 279 | |
| 280 | if ((io_32bit & 2) && !mmio) |
| 281 | local_irq_restore(flags); |
| 282 | |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 283 | if (((len + 1) & 3) < 2) |
| 284 | return; |
| 285 | |
| 286 | buf += len & ~3; |
| 287 | words = 1; |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 288 | } |
Sergei Shtylyov | deae17f | 2009-03-31 20:15:31 +0200 | [diff] [blame] | 289 | |
| 290 | if (mmio) |
| 291 | __ide_mm_outsw((void __iomem *)data_addr, buf, words); |
| 292 | else |
| 293 | outsw(data_addr, buf, words); |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 294 | } |
| 295 | EXPORT_SYMBOL_GPL(ide_output_data); |
| 296 | |
| 297 | const struct ide_tp_ops default_tp_ops = { |
| 298 | .exec_command = ide_exec_command, |
| 299 | .read_status = ide_read_status, |
| 300 | .read_altstatus = ide_read_altstatus, |
Sergei Shtylyov | ecf3a31 | 2009-03-31 20:15:30 +0200 | [diff] [blame] | 301 | .write_devctl = ide_write_devctl, |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 302 | |
Sergei Shtylyov | abb596b | 2009-03-31 20:15:32 +0200 | [diff] [blame] | 303 | .dev_select = ide_dev_select, |
Bartlomiej Zolnierkiewicz | 1574cf6 | 2009-03-24 23:22:46 +0100 | [diff] [blame] | 304 | .tf_load = ide_tf_load, |
| 305 | .tf_read = ide_tf_read, |
| 306 | |
| 307 | .input_data = ide_input_data, |
| 308 | .output_data = ide_output_data, |
| 309 | }; |