Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Support for IDE interfaces on PowerMacs. |
Bartlomiej Zolnierkiewicz | 58f189f | 2008-02-01 23:09:33 +0100 | [diff] [blame] | 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * These IDE interfaces are memory-mapped and have a DBDMA channel |
| 5 | * for doing DMA. |
| 6 | * |
| 7 | * Copyright (C) 1998-2003 Paul Mackerras & Ben. Herrenschmidt |
Bartlomiej Zolnierkiewicz | c15d5d4 | 2007-10-11 23:54:01 +0200 | [diff] [blame] | 8 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License |
| 12 | * as published by the Free Software Foundation; either version |
| 13 | * 2 of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * Some code taken from drivers/ide/ide-dma.c: |
| 16 | * |
| 17 | * Copyright (c) 1995-1998 Mark Lord |
| 18 | * |
| 19 | * TODO: - Use pre-calculated (kauai) timing tables all the time and |
| 20 | * get rid of the "rounded" tables used previously, so we have the |
| 21 | * same table format for all controllers and can then just have one |
| 22 | * big table |
| 23 | * |
| 24 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/types.h> |
| 26 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/init.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/ide.h> |
| 30 | #include <linux/notifier.h> |
| 31 | #include <linux/reboot.h> |
| 32 | #include <linux/pci.h> |
| 33 | #include <linux/adb.h> |
| 34 | #include <linux/pmu.h> |
| 35 | #include <linux/scatterlist.h> |
| 36 | |
| 37 | #include <asm/prom.h> |
| 38 | #include <asm/io.h> |
| 39 | #include <asm/dbdma.h> |
| 40 | #include <asm/ide.h> |
| 41 | #include <asm/pci-bridge.h> |
| 42 | #include <asm/machdep.h> |
| 43 | #include <asm/pmac_feature.h> |
| 44 | #include <asm/sections.h> |
| 45 | #include <asm/irq.h> |
| 46 | |
| 47 | #ifndef CONFIG_PPC64 |
| 48 | #include <asm/mediabay.h> |
| 49 | #endif |
| 50 | |
Andrew Morton | 9e5755b | 2007-03-03 17:48:54 +0100 | [diff] [blame] | 51 | #include "../ide-timing.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | #undef IDE_PMAC_DEBUG |
| 54 | |
| 55 | #define DMA_WAIT_TIMEOUT 50 |
| 56 | |
| 57 | typedef struct pmac_ide_hwif { |
| 58 | unsigned long regbase; |
| 59 | int irq; |
| 60 | int kind; |
| 61 | int aapl_bus_id; |
| 62 | unsigned cable_80 : 1; |
| 63 | unsigned mediabay : 1; |
| 64 | unsigned broken_dma : 1; |
| 65 | unsigned broken_dma_warn : 1; |
| 66 | struct device_node* node; |
| 67 | struct macio_dev *mdev; |
| 68 | u32 timings[4]; |
| 69 | volatile u32 __iomem * *kauai_fcr; |
| 70 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
| 71 | /* Those fields are duplicating what is in hwif. We currently |
| 72 | * can't use the hwif ones because of some assumptions that are |
| 73 | * beeing done by the generic code about the kind of dma controller |
| 74 | * and format of the dma table. This will have to be fixed though. |
| 75 | */ |
| 76 | volatile struct dbdma_regs __iomem * dma_regs; |
| 77 | struct dbdma_cmd* dma_table_cpu; |
| 78 | #endif |
| 79 | |
| 80 | } pmac_ide_hwif_t; |
| 81 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | enum { |
| 83 | controller_ohare, /* OHare based */ |
| 84 | controller_heathrow, /* Heathrow/Paddington */ |
| 85 | controller_kl_ata3, /* KeyLargo ATA-3 */ |
| 86 | controller_kl_ata4, /* KeyLargo ATA-4 */ |
| 87 | controller_un_ata6, /* UniNorth2 ATA-6 */ |
| 88 | controller_k2_ata6, /* K2 ATA-6 */ |
| 89 | controller_sh_ata6, /* Shasta ATA-6 */ |
| 90 | }; |
| 91 | |
| 92 | static const char* model_name[] = { |
| 93 | "OHare ATA", /* OHare based */ |
| 94 | "Heathrow ATA", /* Heathrow/Paddington */ |
| 95 | "KeyLargo ATA-3", /* KeyLargo ATA-3 (MDMA only) */ |
| 96 | "KeyLargo ATA-4", /* KeyLargo ATA-4 (UDMA/66) */ |
| 97 | "UniNorth ATA-6", /* UniNorth2 ATA-6 (UDMA/100) */ |
| 98 | "K2 ATA-6", /* K2 ATA-6 (UDMA/100) */ |
| 99 | "Shasta ATA-6", /* Shasta ATA-6 (UDMA/133) */ |
| 100 | }; |
| 101 | |
| 102 | /* |
| 103 | * Extra registers, both 32-bit little-endian |
| 104 | */ |
| 105 | #define IDE_TIMING_CONFIG 0x200 |
| 106 | #define IDE_INTERRUPT 0x300 |
| 107 | |
| 108 | /* Kauai (U2) ATA has different register setup */ |
| 109 | #define IDE_KAUAI_PIO_CONFIG 0x200 |
| 110 | #define IDE_KAUAI_ULTRA_CONFIG 0x210 |
| 111 | #define IDE_KAUAI_POLL_CONFIG 0x220 |
| 112 | |
| 113 | /* |
| 114 | * Timing configuration register definitions |
| 115 | */ |
| 116 | |
| 117 | /* Number of IDE_SYSCLK_NS ticks, argument is in nanoseconds */ |
| 118 | #define SYSCLK_TICKS(t) (((t) + IDE_SYSCLK_NS - 1) / IDE_SYSCLK_NS) |
| 119 | #define SYSCLK_TICKS_66(t) (((t) + IDE_SYSCLK_66_NS - 1) / IDE_SYSCLK_66_NS) |
| 120 | #define IDE_SYSCLK_NS 30 /* 33Mhz cell */ |
| 121 | #define IDE_SYSCLK_66_NS 15 /* 66Mhz cell */ |
| 122 | |
| 123 | /* 133Mhz cell, found in shasta. |
| 124 | * See comments about 100 Mhz Uninorth 2... |
| 125 | * Note that PIO_MASK and MDMA_MASK seem to overlap |
| 126 | */ |
| 127 | #define TR_133_PIOREG_PIO_MASK 0xff000fff |
| 128 | #define TR_133_PIOREG_MDMA_MASK 0x00fff800 |
| 129 | #define TR_133_UDMAREG_UDMA_MASK 0x0003ffff |
| 130 | #define TR_133_UDMAREG_UDMA_EN 0x00000001 |
| 131 | |
| 132 | /* 100Mhz cell, found in Uninorth 2. I don't have much infos about |
| 133 | * this one yet, it appears as a pci device (106b/0033) on uninorth |
| 134 | * internal PCI bus and it's clock is controlled like gem or fw. It |
| 135 | * appears to be an evolution of keylargo ATA4 with a timing register |
| 136 | * extended to 2 32bits registers and a similar DBDMA channel. Other |
| 137 | * registers seem to exist but I can't tell much about them. |
| 138 | * |
| 139 | * So far, I'm using pre-calculated tables for this extracted from |
| 140 | * the values used by the MacOS X driver. |
| 141 | * |
| 142 | * The "PIO" register controls PIO and MDMA timings, the "ULTRA" |
| 143 | * register controls the UDMA timings. At least, it seems bit 0 |
| 144 | * of this one enables UDMA vs. MDMA, and bits 4..7 are the |
| 145 | * cycle time in units of 10ns. Bits 8..15 are used by I don't |
| 146 | * know their meaning yet |
| 147 | */ |
| 148 | #define TR_100_PIOREG_PIO_MASK 0xff000fff |
| 149 | #define TR_100_PIOREG_MDMA_MASK 0x00fff000 |
| 150 | #define TR_100_UDMAREG_UDMA_MASK 0x0000ffff |
| 151 | #define TR_100_UDMAREG_UDMA_EN 0x00000001 |
| 152 | |
| 153 | |
| 154 | /* 66Mhz cell, found in KeyLargo. Can do ultra mode 0 to 2 on |
| 155 | * 40 connector cable and to 4 on 80 connector one. |
| 156 | * Clock unit is 15ns (66Mhz) |
| 157 | * |
| 158 | * 3 Values can be programmed: |
| 159 | * - Write data setup, which appears to match the cycle time. They |
| 160 | * also call it DIOW setup. |
| 161 | * - Ready to pause time (from spec) |
| 162 | * - Address setup. That one is weird. I don't see where exactly |
| 163 | * it fits in UDMA cycles, I got it's name from an obscure piece |
| 164 | * of commented out code in Darwin. They leave it to 0, we do as |
| 165 | * well, despite a comment that would lead to think it has a |
| 166 | * min value of 45ns. |
| 167 | * Apple also add 60ns to the write data setup (or cycle time ?) on |
| 168 | * reads. |
| 169 | */ |
| 170 | #define TR_66_UDMA_MASK 0xfff00000 |
| 171 | #define TR_66_UDMA_EN 0x00100000 /* Enable Ultra mode for DMA */ |
| 172 | #define TR_66_UDMA_ADDRSETUP_MASK 0xe0000000 /* Address setup */ |
| 173 | #define TR_66_UDMA_ADDRSETUP_SHIFT 29 |
| 174 | #define TR_66_UDMA_RDY2PAUS_MASK 0x1e000000 /* Ready 2 pause time */ |
| 175 | #define TR_66_UDMA_RDY2PAUS_SHIFT 25 |
| 176 | #define TR_66_UDMA_WRDATASETUP_MASK 0x01e00000 /* Write data setup time */ |
| 177 | #define TR_66_UDMA_WRDATASETUP_SHIFT 21 |
| 178 | #define TR_66_MDMA_MASK 0x000ffc00 |
| 179 | #define TR_66_MDMA_RECOVERY_MASK 0x000f8000 |
| 180 | #define TR_66_MDMA_RECOVERY_SHIFT 15 |
| 181 | #define TR_66_MDMA_ACCESS_MASK 0x00007c00 |
| 182 | #define TR_66_MDMA_ACCESS_SHIFT 10 |
| 183 | #define TR_66_PIO_MASK 0x000003ff |
| 184 | #define TR_66_PIO_RECOVERY_MASK 0x000003e0 |
| 185 | #define TR_66_PIO_RECOVERY_SHIFT 5 |
| 186 | #define TR_66_PIO_ACCESS_MASK 0x0000001f |
| 187 | #define TR_66_PIO_ACCESS_SHIFT 0 |
| 188 | |
| 189 | /* 33Mhz cell, found in OHare, Heathrow (& Paddington) and KeyLargo |
| 190 | * Can do pio & mdma modes, clock unit is 30ns (33Mhz) |
| 191 | * |
| 192 | * The access time and recovery time can be programmed. Some older |
| 193 | * Darwin code base limit OHare to 150ns cycle time. I decided to do |
| 194 | * the same here fore safety against broken old hardware ;) |
| 195 | * The HalfTick bit, when set, adds half a clock (15ns) to the access |
| 196 | * time and removes one from recovery. It's not supported on KeyLargo |
| 197 | * implementation afaik. The E bit appears to be set for PIO mode 0 and |
| 198 | * is used to reach long timings used in this mode. |
| 199 | */ |
| 200 | #define TR_33_MDMA_MASK 0x003ff800 |
| 201 | #define TR_33_MDMA_RECOVERY_MASK 0x001f0000 |
| 202 | #define TR_33_MDMA_RECOVERY_SHIFT 16 |
| 203 | #define TR_33_MDMA_ACCESS_MASK 0x0000f800 |
| 204 | #define TR_33_MDMA_ACCESS_SHIFT 11 |
| 205 | #define TR_33_MDMA_HALFTICK 0x00200000 |
| 206 | #define TR_33_PIO_MASK 0x000007ff |
| 207 | #define TR_33_PIO_E 0x00000400 |
| 208 | #define TR_33_PIO_RECOVERY_MASK 0x000003e0 |
| 209 | #define TR_33_PIO_RECOVERY_SHIFT 5 |
| 210 | #define TR_33_PIO_ACCESS_MASK 0x0000001f |
| 211 | #define TR_33_PIO_ACCESS_SHIFT 0 |
| 212 | |
| 213 | /* |
| 214 | * Interrupt register definitions |
| 215 | */ |
| 216 | #define IDE_INTR_DMA 0x80000000 |
| 217 | #define IDE_INTR_DEVICE 0x40000000 |
| 218 | |
| 219 | /* |
| 220 | * FCR Register on Kauai. Not sure what bit 0x4 is ... |
| 221 | */ |
| 222 | #define KAUAI_FCR_UATA_MAGIC 0x00000004 |
| 223 | #define KAUAI_FCR_UATA_RESET_N 0x00000002 |
| 224 | #define KAUAI_FCR_UATA_ENABLE 0x00000001 |
| 225 | |
| 226 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
| 227 | |
| 228 | /* Rounded Multiword DMA timings |
| 229 | * |
| 230 | * I gave up finding a generic formula for all controller |
| 231 | * types and instead, built tables based on timing values |
| 232 | * used by Apple in Darwin's implementation. |
| 233 | */ |
| 234 | struct mdma_timings_t { |
| 235 | int accessTime; |
| 236 | int recoveryTime; |
| 237 | int cycleTime; |
| 238 | }; |
| 239 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 240 | struct mdma_timings_t mdma_timings_33[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | { |
| 242 | { 240, 240, 480 }, |
| 243 | { 180, 180, 360 }, |
| 244 | { 135, 135, 270 }, |
| 245 | { 120, 120, 240 }, |
| 246 | { 105, 105, 210 }, |
| 247 | { 90, 90, 180 }, |
| 248 | { 75, 75, 150 }, |
| 249 | { 75, 45, 120 }, |
| 250 | { 0, 0, 0 } |
| 251 | }; |
| 252 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 253 | struct mdma_timings_t mdma_timings_33k[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | { |
| 255 | { 240, 240, 480 }, |
| 256 | { 180, 180, 360 }, |
| 257 | { 150, 150, 300 }, |
| 258 | { 120, 120, 240 }, |
| 259 | { 90, 120, 210 }, |
| 260 | { 90, 90, 180 }, |
| 261 | { 90, 60, 150 }, |
| 262 | { 90, 30, 120 }, |
| 263 | { 0, 0, 0 } |
| 264 | }; |
| 265 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 266 | struct mdma_timings_t mdma_timings_66[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | { |
| 268 | { 240, 240, 480 }, |
| 269 | { 180, 180, 360 }, |
| 270 | { 135, 135, 270 }, |
| 271 | { 120, 120, 240 }, |
| 272 | { 105, 105, 210 }, |
| 273 | { 90, 90, 180 }, |
| 274 | { 90, 75, 165 }, |
| 275 | { 75, 45, 120 }, |
| 276 | { 0, 0, 0 } |
| 277 | }; |
| 278 | |
| 279 | /* KeyLargo ATA-4 Ultra DMA timings (rounded) */ |
| 280 | struct { |
| 281 | int addrSetup; /* ??? */ |
| 282 | int rdy2pause; |
| 283 | int wrDataSetup; |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 284 | } kl66_udma_timings[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | { |
| 286 | { 0, 180, 120 }, /* Mode 0 */ |
| 287 | { 0, 150, 90 }, /* 1 */ |
| 288 | { 0, 120, 60 }, /* 2 */ |
| 289 | { 0, 90, 45 }, /* 3 */ |
| 290 | { 0, 90, 30 } /* 4 */ |
| 291 | }; |
| 292 | |
| 293 | /* UniNorth 2 ATA/100 timings */ |
| 294 | struct kauai_timing { |
| 295 | int cycle_time; |
| 296 | u32 timing_reg; |
| 297 | }; |
| 298 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 299 | static struct kauai_timing kauai_pio_timings[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | { |
| 301 | { 930 , 0x08000fff }, |
| 302 | { 600 , 0x08000a92 }, |
| 303 | { 383 , 0x0800060f }, |
| 304 | { 360 , 0x08000492 }, |
| 305 | { 330 , 0x0800048f }, |
| 306 | { 300 , 0x080003cf }, |
| 307 | { 270 , 0x080003cc }, |
| 308 | { 240 , 0x0800038b }, |
| 309 | { 239 , 0x0800030c }, |
| 310 | { 180 , 0x05000249 }, |
Bartlomiej Zolnierkiewicz | c15d5d4 | 2007-10-11 23:54:01 +0200 | [diff] [blame] | 311 | { 120 , 0x04000148 }, |
| 312 | { 0 , 0 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | }; |
| 314 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 315 | static struct kauai_timing kauai_mdma_timings[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | { |
| 317 | { 1260 , 0x00fff000 }, |
| 318 | { 480 , 0x00618000 }, |
| 319 | { 360 , 0x00492000 }, |
| 320 | { 270 , 0x0038e000 }, |
| 321 | { 240 , 0x0030c000 }, |
| 322 | { 210 , 0x002cb000 }, |
| 323 | { 180 , 0x00249000 }, |
| 324 | { 150 , 0x00209000 }, |
| 325 | { 120 , 0x00148000 }, |
| 326 | { 0 , 0 }, |
| 327 | }; |
| 328 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 329 | static struct kauai_timing kauai_udma_timings[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | { |
| 331 | { 120 , 0x000070c0 }, |
| 332 | { 90 , 0x00005d80 }, |
| 333 | { 60 , 0x00004a60 }, |
| 334 | { 45 , 0x00003a50 }, |
| 335 | { 30 , 0x00002a30 }, |
| 336 | { 20 , 0x00002921 }, |
| 337 | { 0 , 0 }, |
| 338 | }; |
| 339 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 340 | static struct kauai_timing shasta_pio_timings[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | { |
| 342 | { 930 , 0x08000fff }, |
| 343 | { 600 , 0x0A000c97 }, |
| 344 | { 383 , 0x07000712 }, |
| 345 | { 360 , 0x040003cd }, |
| 346 | { 330 , 0x040003cd }, |
| 347 | { 300 , 0x040003cd }, |
| 348 | { 270 , 0x040003cd }, |
| 349 | { 240 , 0x040003cd }, |
| 350 | { 239 , 0x040003cd }, |
| 351 | { 180 , 0x0400028b }, |
Bartlomiej Zolnierkiewicz | c15d5d4 | 2007-10-11 23:54:01 +0200 | [diff] [blame] | 352 | { 120 , 0x0400010a }, |
| 353 | { 0 , 0 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | }; |
| 355 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 356 | static struct kauai_timing shasta_mdma_timings[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | { |
| 358 | { 1260 , 0x00fff000 }, |
| 359 | { 480 , 0x00820800 }, |
| 360 | { 360 , 0x00820800 }, |
| 361 | { 270 , 0x00820800 }, |
| 362 | { 240 , 0x00820800 }, |
| 363 | { 210 , 0x00820800 }, |
| 364 | { 180 , 0x00820800 }, |
| 365 | { 150 , 0x0028b000 }, |
| 366 | { 120 , 0x001ca000 }, |
| 367 | { 0 , 0 }, |
| 368 | }; |
| 369 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 370 | static struct kauai_timing shasta_udma133_timings[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | { |
| 372 | { 120 , 0x00035901, }, |
| 373 | { 90 , 0x000348b1, }, |
| 374 | { 60 , 0x00033881, }, |
| 375 | { 45 , 0x00033861, }, |
| 376 | { 30 , 0x00033841, }, |
| 377 | { 20 , 0x00033031, }, |
| 378 | { 15 , 0x00033021, }, |
| 379 | { 0 , 0 }, |
| 380 | }; |
| 381 | |
| 382 | |
| 383 | static inline u32 |
| 384 | kauai_lookup_timing(struct kauai_timing* table, int cycle_time) |
| 385 | { |
| 386 | int i; |
| 387 | |
| 388 | for (i=0; table[i].cycle_time; i++) |
| 389 | if (cycle_time > table[i+1].cycle_time) |
| 390 | return table[i].timing_reg; |
Bartlomiej Zolnierkiewicz | 90a87ea | 2007-10-13 17:47:48 +0200 | [diff] [blame] | 391 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | return 0; |
| 393 | } |
| 394 | |
| 395 | /* allow up to 256 DBDMA commands per xfer */ |
| 396 | #define MAX_DCMDS 256 |
| 397 | |
| 398 | /* |
| 399 | * Wait 1s for disk to answer on IDE bus after a hard reset |
| 400 | * of the device (via GPIO/FCR). |
| 401 | * |
| 402 | * Some devices seem to "pollute" the bus even after dropping |
| 403 | * the BSY bit (typically some combo drives slave on the UDMA |
| 404 | * bus) after a hard reset. Since we hard reset all drives on |
| 405 | * KeyLargo ATA66, we have to keep that delay around. I may end |
| 406 | * up not hard resetting anymore on these and keep the delay only |
| 407 | * for older interfaces instead (we have to reset when coming |
| 408 | * from MacOS...) --BenH. |
| 409 | */ |
| 410 | #define IDE_WAKEUP_DELAY (1*HZ) |
| 411 | |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 412 | static int pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | static void pmac_ide_selectproc(ide_drive_t *drive); |
| 415 | static void pmac_ide_kauai_selectproc(ide_drive_t *drive); |
| 416 | |
| 417 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
| 418 | |
Bartlomiej Zolnierkiewicz | 23579a2 | 2008-04-18 00:46:26 +0200 | [diff] [blame] | 419 | #define PMAC_IDE_REG(x) \ |
| 420 | ((void __iomem *)((drive)->hwif->io_ports[IDE_DATA_OFFSET] + (x))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
| 422 | /* |
| 423 | * Apply the timings of the proper unit (master/slave) to the shared |
| 424 | * timing register when selecting that unit. This version is for |
| 425 | * ASICs with a single timing register |
| 426 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 427 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | pmac_ide_selectproc(ide_drive_t *drive) |
| 429 | { |
| 430 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; |
| 431 | |
| 432 | if (pmif == NULL) |
| 433 | return; |
| 434 | |
| 435 | if (drive->select.b.unit & 0x01) |
| 436 | writel(pmif->timings[1], PMAC_IDE_REG(IDE_TIMING_CONFIG)); |
| 437 | else |
| 438 | writel(pmif->timings[0], PMAC_IDE_REG(IDE_TIMING_CONFIG)); |
| 439 | (void)readl(PMAC_IDE_REG(IDE_TIMING_CONFIG)); |
| 440 | } |
| 441 | |
| 442 | /* |
| 443 | * Apply the timings of the proper unit (master/slave) to the shared |
| 444 | * timing register when selecting that unit. This version is for |
| 445 | * ASICs with a dual timing register (Kauai) |
| 446 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 447 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | pmac_ide_kauai_selectproc(ide_drive_t *drive) |
| 449 | { |
| 450 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; |
| 451 | |
| 452 | if (pmif == NULL) |
| 453 | return; |
| 454 | |
| 455 | if (drive->select.b.unit & 0x01) { |
| 456 | writel(pmif->timings[1], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG)); |
| 457 | writel(pmif->timings[3], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG)); |
| 458 | } else { |
| 459 | writel(pmif->timings[0], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG)); |
| 460 | writel(pmif->timings[2], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG)); |
| 461 | } |
| 462 | (void)readl(PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG)); |
| 463 | } |
| 464 | |
| 465 | /* |
| 466 | * Force an update of controller timing values for a given drive |
| 467 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 468 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | pmac_ide_do_update_timings(ide_drive_t *drive) |
| 470 | { |
| 471 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; |
| 472 | |
| 473 | if (pmif == NULL) |
| 474 | return; |
| 475 | |
| 476 | if (pmif->kind == controller_sh_ata6 || |
| 477 | pmif->kind == controller_un_ata6 || |
| 478 | pmif->kind == controller_k2_ata6) |
| 479 | pmac_ide_kauai_selectproc(drive); |
| 480 | else |
| 481 | pmac_ide_selectproc(drive); |
| 482 | } |
| 483 | |
| 484 | static void |
| 485 | pmac_outbsync(ide_drive_t *drive, u8 value, unsigned long port) |
| 486 | { |
| 487 | u32 tmp; |
| 488 | |
| 489 | writeb(value, (void __iomem *) port); |
| 490 | tmp = readl(PMAC_IDE_REG(IDE_TIMING_CONFIG)); |
| 491 | } |
| 492 | |
| 493 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | * Old tuning functions (called on hdparm -p), sets up drive PIO timings |
| 495 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 496 | static void |
Bartlomiej Zolnierkiewicz | 26bcb87 | 2007-10-11 23:54:00 +0200 | [diff] [blame] | 497 | pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | { |
Benjamin Herrenschmidt | 0b46ff2 | 2007-10-13 17:47:50 +0200 | [diff] [blame] | 499 | u32 *timings, t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | unsigned accessTicks, recTicks; |
| 501 | unsigned accessTime, recTime; |
| 502 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; |
Bartlomiej Zolnierkiewicz | 7dd0008 | 2007-07-20 01:11:56 +0200 | [diff] [blame] | 503 | unsigned int cycle_time; |
| 504 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | if (pmif == NULL) |
| 506 | return; |
| 507 | |
| 508 | /* which drive is it ? */ |
| 509 | timings = &pmif->timings[drive->select.b.unit & 0x01]; |
Benjamin Herrenschmidt | 0b46ff2 | 2007-10-13 17:47:50 +0200 | [diff] [blame] | 510 | t = *timings; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | |
Bartlomiej Zolnierkiewicz | 7dd0008 | 2007-07-20 01:11:56 +0200 | [diff] [blame] | 512 | cycle_time = ide_pio_cycle_time(drive, pio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | |
| 514 | switch (pmif->kind) { |
| 515 | case controller_sh_ata6: { |
| 516 | /* 133Mhz cell */ |
Bartlomiej Zolnierkiewicz | 7dd0008 | 2007-07-20 01:11:56 +0200 | [diff] [blame] | 517 | u32 tr = kauai_lookup_timing(shasta_pio_timings, cycle_time); |
Benjamin Herrenschmidt | 0b46ff2 | 2007-10-13 17:47:50 +0200 | [diff] [blame] | 518 | t = (t & ~TR_133_PIOREG_PIO_MASK) | tr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | break; |
| 520 | } |
| 521 | case controller_un_ata6: |
| 522 | case controller_k2_ata6: { |
| 523 | /* 100Mhz cell */ |
Bartlomiej Zolnierkiewicz | 7dd0008 | 2007-07-20 01:11:56 +0200 | [diff] [blame] | 524 | u32 tr = kauai_lookup_timing(kauai_pio_timings, cycle_time); |
Benjamin Herrenschmidt | 0b46ff2 | 2007-10-13 17:47:50 +0200 | [diff] [blame] | 525 | t = (t & ~TR_100_PIOREG_PIO_MASK) | tr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | break; |
| 527 | } |
| 528 | case controller_kl_ata4: |
| 529 | /* 66Mhz cell */ |
Bartlomiej Zolnierkiewicz | 7dd0008 | 2007-07-20 01:11:56 +0200 | [diff] [blame] | 530 | recTime = cycle_time - ide_pio_timings[pio].active_time |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | - ide_pio_timings[pio].setup_time; |
| 532 | recTime = max(recTime, 150U); |
| 533 | accessTime = ide_pio_timings[pio].active_time; |
| 534 | accessTime = max(accessTime, 150U); |
| 535 | accessTicks = SYSCLK_TICKS_66(accessTime); |
| 536 | accessTicks = min(accessTicks, 0x1fU); |
| 537 | recTicks = SYSCLK_TICKS_66(recTime); |
| 538 | recTicks = min(recTicks, 0x1fU); |
Benjamin Herrenschmidt | 0b46ff2 | 2007-10-13 17:47:50 +0200 | [diff] [blame] | 539 | t = (t & ~TR_66_PIO_MASK) | |
| 540 | (accessTicks << TR_66_PIO_ACCESS_SHIFT) | |
| 541 | (recTicks << TR_66_PIO_RECOVERY_SHIFT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | break; |
| 543 | default: { |
| 544 | /* 33Mhz cell */ |
| 545 | int ebit = 0; |
Bartlomiej Zolnierkiewicz | 7dd0008 | 2007-07-20 01:11:56 +0200 | [diff] [blame] | 546 | recTime = cycle_time - ide_pio_timings[pio].active_time |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | - ide_pio_timings[pio].setup_time; |
| 548 | recTime = max(recTime, 150U); |
| 549 | accessTime = ide_pio_timings[pio].active_time; |
| 550 | accessTime = max(accessTime, 150U); |
| 551 | accessTicks = SYSCLK_TICKS(accessTime); |
| 552 | accessTicks = min(accessTicks, 0x1fU); |
| 553 | accessTicks = max(accessTicks, 4U); |
| 554 | recTicks = SYSCLK_TICKS(recTime); |
| 555 | recTicks = min(recTicks, 0x1fU); |
| 556 | recTicks = max(recTicks, 5U) - 4; |
| 557 | if (recTicks > 9) { |
| 558 | recTicks--; /* guess, but it's only for PIO0, so... */ |
| 559 | ebit = 1; |
| 560 | } |
Benjamin Herrenschmidt | 0b46ff2 | 2007-10-13 17:47:50 +0200 | [diff] [blame] | 561 | t = (t & ~TR_33_PIO_MASK) | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | (accessTicks << TR_33_PIO_ACCESS_SHIFT) | |
| 563 | (recTicks << TR_33_PIO_RECOVERY_SHIFT); |
| 564 | if (ebit) |
Benjamin Herrenschmidt | 0b46ff2 | 2007-10-13 17:47:50 +0200 | [diff] [blame] | 565 | t |= TR_33_PIO_E; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | break; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | #ifdef IDE_PMAC_DEBUG |
| 571 | printk(KERN_ERR "%s: Set PIO timing for mode %d, reg: 0x%08x\n", |
| 572 | drive->name, pio, *timings); |
| 573 | #endif |
| 574 | |
Benjamin Herrenschmidt | 0b46ff2 | 2007-10-13 17:47:50 +0200 | [diff] [blame] | 575 | *timings = t; |
Bartlomiej Zolnierkiewicz | c15d5d4 | 2007-10-11 23:54:01 +0200 | [diff] [blame] | 576 | pmac_ide_do_update_timings(drive); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
| 580 | |
| 581 | /* |
| 582 | * Calculate KeyLargo ATA/66 UDMA timings |
| 583 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 584 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | set_timings_udma_ata4(u32 *timings, u8 speed) |
| 586 | { |
| 587 | unsigned rdyToPauseTicks, wrDataSetupTicks, addrTicks; |
| 588 | |
| 589 | if (speed > XFER_UDMA_4) |
| 590 | return 1; |
| 591 | |
| 592 | rdyToPauseTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].rdy2pause); |
| 593 | wrDataSetupTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].wrDataSetup); |
| 594 | addrTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].addrSetup); |
| 595 | |
| 596 | *timings = ((*timings) & ~(TR_66_UDMA_MASK | TR_66_MDMA_MASK)) | |
| 597 | (wrDataSetupTicks << TR_66_UDMA_WRDATASETUP_SHIFT) | |
| 598 | (rdyToPauseTicks << TR_66_UDMA_RDY2PAUS_SHIFT) | |
| 599 | (addrTicks <<TR_66_UDMA_ADDRSETUP_SHIFT) | |
| 600 | TR_66_UDMA_EN; |
| 601 | #ifdef IDE_PMAC_DEBUG |
| 602 | printk(KERN_ERR "ide_pmac: Set UDMA timing for mode %d, reg: 0x%08x\n", |
| 603 | speed & 0xf, *timings); |
| 604 | #endif |
| 605 | |
| 606 | return 0; |
| 607 | } |
| 608 | |
| 609 | /* |
| 610 | * Calculate Kauai ATA/100 UDMA timings |
| 611 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 612 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | set_timings_udma_ata6(u32 *pio_timings, u32 *ultra_timings, u8 speed) |
| 614 | { |
| 615 | struct ide_timing *t = ide_timing_find_mode(speed); |
| 616 | u32 tr; |
| 617 | |
| 618 | if (speed > XFER_UDMA_5 || t == NULL) |
| 619 | return 1; |
| 620 | tr = kauai_lookup_timing(kauai_udma_timings, (int)t->udma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | *ultra_timings = ((*ultra_timings) & ~TR_100_UDMAREG_UDMA_MASK) | tr; |
| 622 | *ultra_timings = (*ultra_timings) | TR_100_UDMAREG_UDMA_EN; |
| 623 | |
| 624 | return 0; |
| 625 | } |
| 626 | |
| 627 | /* |
| 628 | * Calculate Shasta ATA/133 UDMA timings |
| 629 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 630 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | set_timings_udma_shasta(u32 *pio_timings, u32 *ultra_timings, u8 speed) |
| 632 | { |
| 633 | struct ide_timing *t = ide_timing_find_mode(speed); |
| 634 | u32 tr; |
| 635 | |
| 636 | if (speed > XFER_UDMA_6 || t == NULL) |
| 637 | return 1; |
| 638 | tr = kauai_lookup_timing(shasta_udma133_timings, (int)t->udma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | *ultra_timings = ((*ultra_timings) & ~TR_133_UDMAREG_UDMA_MASK) | tr; |
| 640 | *ultra_timings = (*ultra_timings) | TR_133_UDMAREG_UDMA_EN; |
| 641 | |
| 642 | return 0; |
| 643 | } |
| 644 | |
| 645 | /* |
| 646 | * Calculate MDMA timings for all cells |
| 647 | */ |
Bartlomiej Zolnierkiewicz | 90f72ec | 2007-10-13 17:47:48 +0200 | [diff] [blame] | 648 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2, |
Bartlomiej Zolnierkiewicz | 90f72ec | 2007-10-13 17:47:48 +0200 | [diff] [blame] | 650 | u8 speed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | { |
| 652 | int cycleTime, accessTime = 0, recTime = 0; |
| 653 | unsigned accessTicks, recTicks; |
Bartlomiej Zolnierkiewicz | 90f72ec | 2007-10-13 17:47:48 +0200 | [diff] [blame] | 654 | struct hd_driveid *id = drive->id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | struct mdma_timings_t* tm = NULL; |
| 656 | int i; |
| 657 | |
| 658 | /* Get default cycle time for mode */ |
| 659 | switch(speed & 0xf) { |
| 660 | case 0: cycleTime = 480; break; |
| 661 | case 1: cycleTime = 150; break; |
| 662 | case 2: cycleTime = 120; break; |
| 663 | default: |
Bartlomiej Zolnierkiewicz | 90f72ec | 2007-10-13 17:47:48 +0200 | [diff] [blame] | 664 | BUG(); |
| 665 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | } |
Bartlomiej Zolnierkiewicz | 90f72ec | 2007-10-13 17:47:48 +0200 | [diff] [blame] | 667 | |
| 668 | /* Check if drive provides explicit DMA cycle time */ |
| 669 | if ((id->field_valid & 2) && id->eide_dma_time) |
| 670 | cycleTime = max_t(int, id->eide_dma_time, cycleTime); |
| 671 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | /* OHare limits according to some old Apple sources */ |
| 673 | if ((intf_type == controller_ohare) && (cycleTime < 150)) |
| 674 | cycleTime = 150; |
| 675 | /* Get the proper timing array for this controller */ |
| 676 | switch(intf_type) { |
| 677 | case controller_sh_ata6: |
| 678 | case controller_un_ata6: |
| 679 | case controller_k2_ata6: |
| 680 | break; |
| 681 | case controller_kl_ata4: |
| 682 | tm = mdma_timings_66; |
| 683 | break; |
| 684 | case controller_kl_ata3: |
| 685 | tm = mdma_timings_33k; |
| 686 | break; |
| 687 | default: |
| 688 | tm = mdma_timings_33; |
| 689 | break; |
| 690 | } |
| 691 | if (tm != NULL) { |
| 692 | /* Lookup matching access & recovery times */ |
| 693 | i = -1; |
| 694 | for (;;) { |
| 695 | if (tm[i+1].cycleTime < cycleTime) |
| 696 | break; |
| 697 | i++; |
| 698 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | cycleTime = tm[i].cycleTime; |
| 700 | accessTime = tm[i].accessTime; |
| 701 | recTime = tm[i].recoveryTime; |
| 702 | |
| 703 | #ifdef IDE_PMAC_DEBUG |
| 704 | printk(KERN_ERR "%s: MDMA, cycleTime: %d, accessTime: %d, recTime: %d\n", |
| 705 | drive->name, cycleTime, accessTime, recTime); |
| 706 | #endif |
| 707 | } |
| 708 | switch(intf_type) { |
| 709 | case controller_sh_ata6: { |
| 710 | /* 133Mhz cell */ |
| 711 | u32 tr = kauai_lookup_timing(shasta_mdma_timings, cycleTime); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | *timings = ((*timings) & ~TR_133_PIOREG_MDMA_MASK) | tr; |
| 713 | *timings2 = (*timings2) & ~TR_133_UDMAREG_UDMA_EN; |
| 714 | } |
| 715 | case controller_un_ata6: |
| 716 | case controller_k2_ata6: { |
| 717 | /* 100Mhz cell */ |
| 718 | u32 tr = kauai_lookup_timing(kauai_mdma_timings, cycleTime); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | *timings = ((*timings) & ~TR_100_PIOREG_MDMA_MASK) | tr; |
| 720 | *timings2 = (*timings2) & ~TR_100_UDMAREG_UDMA_EN; |
| 721 | } |
| 722 | break; |
| 723 | case controller_kl_ata4: |
| 724 | /* 66Mhz cell */ |
| 725 | accessTicks = SYSCLK_TICKS_66(accessTime); |
| 726 | accessTicks = min(accessTicks, 0x1fU); |
| 727 | accessTicks = max(accessTicks, 0x1U); |
| 728 | recTicks = SYSCLK_TICKS_66(recTime); |
| 729 | recTicks = min(recTicks, 0x1fU); |
| 730 | recTicks = max(recTicks, 0x3U); |
| 731 | /* Clear out mdma bits and disable udma */ |
| 732 | *timings = ((*timings) & ~(TR_66_MDMA_MASK | TR_66_UDMA_MASK)) | |
| 733 | (accessTicks << TR_66_MDMA_ACCESS_SHIFT) | |
| 734 | (recTicks << TR_66_MDMA_RECOVERY_SHIFT); |
| 735 | break; |
| 736 | case controller_kl_ata3: |
| 737 | /* 33Mhz cell on KeyLargo */ |
| 738 | accessTicks = SYSCLK_TICKS(accessTime); |
| 739 | accessTicks = max(accessTicks, 1U); |
| 740 | accessTicks = min(accessTicks, 0x1fU); |
| 741 | accessTime = accessTicks * IDE_SYSCLK_NS; |
| 742 | recTicks = SYSCLK_TICKS(recTime); |
| 743 | recTicks = max(recTicks, 1U); |
| 744 | recTicks = min(recTicks, 0x1fU); |
| 745 | *timings = ((*timings) & ~TR_33_MDMA_MASK) | |
| 746 | (accessTicks << TR_33_MDMA_ACCESS_SHIFT) | |
| 747 | (recTicks << TR_33_MDMA_RECOVERY_SHIFT); |
| 748 | break; |
| 749 | default: { |
| 750 | /* 33Mhz cell on others */ |
| 751 | int halfTick = 0; |
| 752 | int origAccessTime = accessTime; |
| 753 | int origRecTime = recTime; |
| 754 | |
| 755 | accessTicks = SYSCLK_TICKS(accessTime); |
| 756 | accessTicks = max(accessTicks, 1U); |
| 757 | accessTicks = min(accessTicks, 0x1fU); |
| 758 | accessTime = accessTicks * IDE_SYSCLK_NS; |
| 759 | recTicks = SYSCLK_TICKS(recTime); |
| 760 | recTicks = max(recTicks, 2U) - 1; |
| 761 | recTicks = min(recTicks, 0x1fU); |
| 762 | recTime = (recTicks + 1) * IDE_SYSCLK_NS; |
| 763 | if ((accessTicks > 1) && |
| 764 | ((accessTime - IDE_SYSCLK_NS/2) >= origAccessTime) && |
| 765 | ((recTime - IDE_SYSCLK_NS/2) >= origRecTime)) { |
| 766 | halfTick = 1; |
| 767 | accessTicks--; |
| 768 | } |
| 769 | *timings = ((*timings) & ~TR_33_MDMA_MASK) | |
| 770 | (accessTicks << TR_33_MDMA_ACCESS_SHIFT) | |
| 771 | (recTicks << TR_33_MDMA_RECOVERY_SHIFT); |
| 772 | if (halfTick) |
| 773 | *timings |= TR_33_MDMA_HALFTICK; |
| 774 | } |
| 775 | } |
| 776 | #ifdef IDE_PMAC_DEBUG |
| 777 | printk(KERN_ERR "%s: Set MDMA timing for mode %d, reg: 0x%08x\n", |
| 778 | drive->name, speed & 0xf, *timings); |
| 779 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | } |
| 781 | #endif /* #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC */ |
| 782 | |
Bartlomiej Zolnierkiewicz | 88b2b32 | 2007-10-13 17:47:51 +0200 | [diff] [blame] | 783 | static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | { |
| 785 | int unit = (drive->select.b.unit & 0x01); |
| 786 | int ret = 0; |
| 787 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; |
Bartlomiej Zolnierkiewicz | 085798b | 2007-10-13 17:47:48 +0200 | [diff] [blame] | 788 | u32 *timings, *timings2, tl[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | timings = &pmif->timings[unit]; |
| 791 | timings2 = &pmif->timings[unit+2]; |
Bartlomiej Zolnierkiewicz | 085798b | 2007-10-13 17:47:48 +0200 | [diff] [blame] | 792 | |
| 793 | /* Copy timings to local image */ |
| 794 | tl[0] = *timings; |
| 795 | tl[1] = *timings2; |
| 796 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
Bartlomiej Zolnierkiewicz | 4db90a1 | 2008-01-25 22:17:18 +0100 | [diff] [blame] | 798 | if (speed >= XFER_UDMA_0) { |
| 799 | if (pmif->kind == controller_kl_ata4) |
| 800 | ret = set_timings_udma_ata4(&tl[0], speed); |
| 801 | else if (pmif->kind == controller_un_ata6 |
| 802 | || pmif->kind == controller_k2_ata6) |
| 803 | ret = set_timings_udma_ata6(&tl[0], &tl[1], speed); |
| 804 | else if (pmif->kind == controller_sh_ata6) |
| 805 | ret = set_timings_udma_shasta(&tl[0], &tl[1], speed); |
| 806 | else |
| 807 | ret = -1; |
| 808 | } else |
| 809 | set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | if (ret) |
Bartlomiej Zolnierkiewicz | 88b2b32 | 2007-10-13 17:47:51 +0200 | [diff] [blame] | 812 | return; |
Bartlomiej Zolnierkiewicz | 085798b | 2007-10-13 17:47:48 +0200 | [diff] [blame] | 813 | |
| 814 | /* Apply timings to controller */ |
| 815 | *timings = tl[0]; |
| 816 | *timings2 = tl[1]; |
| 817 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | pmac_ide_do_update_timings(drive); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | /* |
| 822 | * Blast some well known "safe" values to the timing registers at init or |
| 823 | * wakeup from sleep time, before we do real calculation |
| 824 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 825 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | sanitize_timings(pmac_ide_hwif_t *pmif) |
| 827 | { |
| 828 | unsigned int value, value2 = 0; |
| 829 | |
| 830 | switch(pmif->kind) { |
| 831 | case controller_sh_ata6: |
| 832 | value = 0x0a820c97; |
| 833 | value2 = 0x00033031; |
| 834 | break; |
| 835 | case controller_un_ata6: |
| 836 | case controller_k2_ata6: |
| 837 | value = 0x08618a92; |
| 838 | value2 = 0x00002921; |
| 839 | break; |
| 840 | case controller_kl_ata4: |
| 841 | value = 0x0008438c; |
| 842 | break; |
| 843 | case controller_kl_ata3: |
| 844 | value = 0x00084526; |
| 845 | break; |
| 846 | case controller_heathrow: |
| 847 | case controller_ohare: |
| 848 | default: |
| 849 | value = 0x00074526; |
| 850 | break; |
| 851 | } |
| 852 | pmif->timings[0] = pmif->timings[1] = value; |
| 853 | pmif->timings[2] = pmif->timings[3] = value2; |
| 854 | } |
| 855 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | /* Suspend call back, should be called after the child devices |
| 857 | * have actually been suspended |
| 858 | */ |
| 859 | static int |
| 860 | pmac_ide_do_suspend(ide_hwif_t *hwif) |
| 861 | { |
| 862 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; |
| 863 | |
| 864 | /* We clear the timings */ |
| 865 | pmif->timings[0] = 0; |
| 866 | pmif->timings[1] = 0; |
| 867 | |
Benjamin Herrenschmidt | 616299a | 2005-05-01 08:58:41 -0700 | [diff] [blame] | 868 | disable_irq(pmif->irq); |
| 869 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | /* The media bay will handle itself just fine */ |
| 871 | if (pmif->mediabay) |
| 872 | return 0; |
| 873 | |
| 874 | /* Kauai has bus control FCRs directly here */ |
| 875 | if (pmif->kauai_fcr) { |
| 876 | u32 fcr = readl(pmif->kauai_fcr); |
| 877 | fcr &= ~(KAUAI_FCR_UATA_RESET_N | KAUAI_FCR_UATA_ENABLE); |
| 878 | writel(fcr, pmif->kauai_fcr); |
| 879 | } |
| 880 | |
| 881 | /* Disable the bus on older machines and the cell on kauai */ |
| 882 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, |
| 883 | 0); |
| 884 | |
| 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | /* Resume call back, should be called before the child devices |
| 889 | * are resumed |
| 890 | */ |
| 891 | static int |
| 892 | pmac_ide_do_resume(ide_hwif_t *hwif) |
| 893 | { |
| 894 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; |
| 895 | |
| 896 | /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */ |
| 897 | if (!pmif->mediabay) { |
| 898 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1); |
| 899 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1); |
| 900 | msleep(10); |
| 901 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | |
| 903 | /* Kauai has it different */ |
| 904 | if (pmif->kauai_fcr) { |
| 905 | u32 fcr = readl(pmif->kauai_fcr); |
| 906 | fcr |= KAUAI_FCR_UATA_RESET_N | KAUAI_FCR_UATA_ENABLE; |
| 907 | writel(fcr, pmif->kauai_fcr); |
| 908 | } |
Benjamin Herrenschmidt | 616299a | 2005-05-01 08:58:41 -0700 | [diff] [blame] | 909 | |
| 910 | msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | } |
| 912 | |
| 913 | /* Sanitize drive timings */ |
| 914 | sanitize_timings(pmif); |
| 915 | |
Benjamin Herrenschmidt | 616299a | 2005-05-01 08:58:41 -0700 | [diff] [blame] | 916 | enable_irq(pmif->irq); |
| 917 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | return 0; |
| 919 | } |
| 920 | |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame^] | 921 | static const struct ide_port_ops pmac_ide_ata6_port_ops = { |
| 922 | .set_pio_mode = pmac_ide_set_pio_mode, |
| 923 | .set_dma_mode = pmac_ide_set_dma_mode, |
| 924 | .selectproc = pmac_ide_kauai_selectproc, |
| 925 | }; |
| 926 | |
| 927 | static const struct ide_port_ops pmac_ide_port_ops = { |
| 928 | .set_pio_mode = pmac_ide_set_pio_mode, |
| 929 | .set_dma_mode = pmac_ide_set_dma_mode, |
| 930 | .selectproc = pmac_ide_selectproc, |
| 931 | }; |
| 932 | |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 933 | static const struct ide_port_info pmac_port_info = { |
| 934 | .chipset = ide_pmac, |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame^] | 935 | .port_ops = &pmac_ide_port_ops, |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 936 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 937 | IDE_HFLAG_POST_SET_MODE | |
| 938 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ |
| 939 | IDE_HFLAG_UNMASK_IRQS, |
| 940 | .pio_mask = ATA_PIO4, |
| 941 | .mwdma_mask = ATA_MWDMA2, |
| 942 | }; |
| 943 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | /* |
| 945 | * Setup, register & probe an IDE channel driven by this driver, this is |
| 946 | * called by one of the 2 probe functions (macio or PCI). Note that a channel |
| 947 | * that ends up beeing free of any device is not kept around by this driver |
| 948 | * (it is kept in 2.4). This introduce an interface numbering change on some |
| 949 | * rare machines unfortunately, but it's better this way. |
| 950 | */ |
Adrian Bunk | 468e468 | 2008-02-01 23:09:16 +0100 | [diff] [blame] | 951 | static int __devinit |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 952 | pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | { |
| 954 | struct device_node *np = pmif->node; |
Jeremy Kerr | 018a3d1 | 2006-07-12 15:40:29 +1000 | [diff] [blame] | 955 | const int *bidp; |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 956 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 957 | struct ide_port_info d = pmac_port_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | |
| 959 | pmif->cable_80 = 0; |
| 960 | pmif->broken_dma = pmif->broken_dma_warn = 0; |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 961 | if (of_device_is_compatible(np, "shasta-ata")) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | pmif->kind = controller_sh_ata6; |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame^] | 963 | d.port_ops = &pmac_ide_ata6_port_ops; |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 964 | d.udma_mask = ATA_UDMA6; |
| 965 | } else if (of_device_is_compatible(np, "kauai-ata")) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | pmif->kind = controller_un_ata6; |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame^] | 967 | d.port_ops = &pmac_ide_ata6_port_ops; |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 968 | d.udma_mask = ATA_UDMA5; |
| 969 | } else if (of_device_is_compatible(np, "K2-UATA")) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | pmif->kind = controller_k2_ata6; |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame^] | 971 | d.port_ops = &pmac_ide_ata6_port_ops; |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 972 | d.udma_mask = ATA_UDMA5; |
| 973 | } else if (of_device_is_compatible(np, "keylargo-ata")) { |
| 974 | if (strcmp(np->name, "ata-4") == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | pmif->kind = controller_kl_ata4; |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 976 | d.udma_mask = ATA_UDMA4; |
| 977 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | pmif->kind = controller_kl_ata3; |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 979 | } else if (of_device_is_compatible(np, "heathrow-ata")) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | pmif->kind = controller_heathrow; |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 981 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | pmif->kind = controller_ohare; |
| 983 | pmif->broken_dma = 1; |
| 984 | } |
| 985 | |
Stephen Rothwell | 40cd3a4 | 2007-05-01 13:54:02 +1000 | [diff] [blame] | 986 | bidp = of_get_property(np, "AAPL,bus-id", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | pmif->aapl_bus_id = bidp ? *bidp : 0; |
| 988 | |
| 989 | /* Get cable type from device-tree */ |
| 990 | if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6 |
| 991 | || pmif->kind == controller_k2_ata6 |
| 992 | || pmif->kind == controller_sh_ata6) { |
Stephen Rothwell | 40cd3a4 | 2007-05-01 13:54:02 +1000 | [diff] [blame] | 993 | const char* cable = of_get_property(np, "cable-type", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | if (cable && !strncmp(cable, "80-", 3)) |
| 995 | pmif->cable_80 = 1; |
| 996 | } |
| 997 | /* G5's seem to have incorrect cable type in device-tree. Let's assume |
| 998 | * they have a 80 conductor cable, this seem to be always the case unless |
| 999 | * the user mucked around |
| 1000 | */ |
Stephen Rothwell | 55b61fe | 2007-05-03 17:26:52 +1000 | [diff] [blame] | 1001 | if (of_device_is_compatible(np, "K2-UATA") || |
| 1002 | of_device_is_compatible(np, "shasta-ata")) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 | pmif->cable_80 = 1; |
| 1004 | |
| 1005 | /* On Kauai-type controllers, we make sure the FCR is correct */ |
| 1006 | if (pmif->kauai_fcr) |
| 1007 | writel(KAUAI_FCR_UATA_MAGIC | |
| 1008 | KAUAI_FCR_UATA_RESET_N | |
| 1009 | KAUAI_FCR_UATA_ENABLE, pmif->kauai_fcr); |
| 1010 | |
| 1011 | pmif->mediabay = 0; |
| 1012 | |
| 1013 | /* Make sure we have sane timings */ |
| 1014 | sanitize_timings(pmif); |
| 1015 | |
| 1016 | #ifndef CONFIG_PPC64 |
| 1017 | /* XXX FIXME: Media bay stuff need re-organizing */ |
| 1018 | if (np->parent && np->parent->name |
| 1019 | && strcasecmp(np->parent->name, "media-bay") == 0) { |
Benjamin Herrenschmidt | 8c87093 | 2005-06-27 14:36:34 -0700 | [diff] [blame] | 1020 | #ifdef CONFIG_PMAC_MEDIABAY |
Bartlomiej Zolnierkiewicz | 2dde786 | 2008-04-18 00:46:23 +0200 | [diff] [blame] | 1021 | media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq, |
| 1022 | hwif); |
Benjamin Herrenschmidt | 8c87093 | 2005-06-27 14:36:34 -0700 | [diff] [blame] | 1023 | #endif /* CONFIG_PMAC_MEDIABAY */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | pmif->mediabay = 1; |
| 1025 | if (!bidp) |
| 1026 | pmif->aapl_bus_id = 1; |
| 1027 | } else if (pmif->kind == controller_ohare) { |
| 1028 | /* The code below is having trouble on some ohare machines |
| 1029 | * (timing related ?). Until I can put my hand on one of these |
| 1030 | * units, I keep the old way |
| 1031 | */ |
| 1032 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1); |
| 1033 | } else |
| 1034 | #endif |
| 1035 | { |
| 1036 | /* This is necessary to enable IDE when net-booting */ |
| 1037 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1); |
| 1038 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1); |
| 1039 | msleep(10); |
| 1040 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0); |
| 1041 | msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY)); |
| 1042 | } |
| 1043 | |
| 1044 | /* Setup MMIO ops */ |
| 1045 | default_hwif_mmiops(hwif); |
| 1046 | hwif->OUTBSYNC = pmac_outbsync; |
| 1047 | |
| 1048 | /* Tell common code _not_ to mess with resources */ |
Bartlomiej Zolnierkiewicz | 2ad1e55 | 2007-02-17 02:40:25 +0100 | [diff] [blame] | 1049 | hwif->mmio = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | hwif->hwif_data = pmif; |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 1051 | ide_init_port_hw(hwif, hw); |
| 1052 | hwif->noprobe = pmif->mediabay; |
Bartlomiej Zolnierkiewicz | 49521f9 | 2007-07-09 23:17:58 +0200 | [diff] [blame] | 1053 | hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", |
| 1056 | hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, |
| 1057 | pmif->mediabay ? " (mediabay)" : "", hwif->irq); |
| 1058 | |
Benjamin Herrenschmidt | 8c87093 | 2005-06-27 14:36:34 -0700 | [diff] [blame] | 1059 | #ifdef CONFIG_PMAC_MEDIABAY |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | if (pmif->mediabay && check_media_bay_by_base(pmif->regbase, MB_CD) == 0) |
| 1061 | hwif->noprobe = 0; |
Benjamin Herrenschmidt | 8c87093 | 2005-06-27 14:36:34 -0700 | [diff] [blame] | 1062 | #endif /* CONFIG_PMAC_MEDIABAY */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1064 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 1065 | if (pmif->cable_80 == 0) |
| 1066 | d.udma_mask &= ATA_UDMA2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | /* has a DBDMA controller channel */ |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 1068 | if (pmif->dma_regs == 0 || pmac_ide_setup_dma(pmif, hwif) < 0) |
| 1069 | #endif |
| 1070 | d.udma_mask = d.mwdma_mask = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 1072 | idx[0] = hwif->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 1074 | ide_device_add(idx, &d); |
Bartlomiej Zolnierkiewicz | 5cbf79c | 2007-05-10 00:01:11 +0200 | [diff] [blame] | 1075 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | return 0; |
| 1077 | } |
| 1078 | |
Bartlomiej Zolnierkiewicz | 5c58666 | 2008-04-18 00:46:29 +0200 | [diff] [blame] | 1079 | static void __devinit pmac_ide_init_ports(hw_regs_t *hw, unsigned long base) |
| 1080 | { |
| 1081 | int i; |
| 1082 | |
| 1083 | for (i = 0; i < 8; ++i) |
| 1084 | hw->io_ports[i] = base + i * 0x10; |
| 1085 | hw->io_ports[8] = base + 0x160; |
| 1086 | } |
| 1087 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | /* |
| 1089 | * Attach to a macio probed interface |
| 1090 | */ |
| 1091 | static int __devinit |
Jeff Mahoney | 5e65577 | 2005-07-06 15:44:41 -0400 | [diff] [blame] | 1092 | pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | { |
| 1094 | void __iomem *base; |
| 1095 | unsigned long regbase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | ide_hwif_t *hwif; |
| 1097 | pmac_ide_hwif_t *pmif; |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1098 | int irq, rc; |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 1099 | hw_regs_t hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1101 | pmif = kzalloc(sizeof(*pmif), GFP_KERNEL); |
| 1102 | if (pmif == NULL) |
| 1103 | return -ENOMEM; |
| 1104 | |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1105 | hwif = ide_find_port(); |
| 1106 | if (hwif == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n"); |
| 1108 | printk(KERN_ERR " %s\n", mdev->ofdev.node->full_name); |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1109 | rc = -ENODEV; |
| 1110 | goto out_free_pmif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | } |
| 1112 | |
Benjamin Herrenschmidt | cc5d018 | 2005-12-13 18:01:21 +1100 | [diff] [blame] | 1113 | if (macio_resource_count(mdev) == 0) { |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1114 | printk(KERN_WARNING "ide-pmac: no address for %s\n", |
| 1115 | mdev->ofdev.node->full_name); |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1116 | rc = -ENXIO; |
| 1117 | goto out_free_pmif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | } |
| 1119 | |
| 1120 | /* Request memory resource for IO ports */ |
| 1121 | if (macio_request_resource(mdev, 0, "ide-pmac (ports)")) { |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1122 | printk(KERN_ERR "ide-pmac: can't request MMIO resource for " |
| 1123 | "%s!\n", mdev->ofdev.node->full_name); |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1124 | rc = -EBUSY; |
| 1125 | goto out_free_pmif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | } |
| 1127 | |
| 1128 | /* XXX This is bogus. Should be fixed in the registry by checking |
| 1129 | * the kind of host interrupt controller, a bit like gatwick |
| 1130 | * fixes in irq.c. That works well enough for the single case |
| 1131 | * where that happens though... |
| 1132 | */ |
| 1133 | if (macio_irq_count(mdev) == 0) { |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1134 | printk(KERN_WARNING "ide-pmac: no intrs for device %s, using " |
| 1135 | "13\n", mdev->ofdev.node->full_name); |
Benjamin Herrenschmidt | 69917c2 | 2006-09-22 12:56:30 +1000 | [diff] [blame] | 1136 | irq = irq_create_mapping(NULL, 13); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | } else |
| 1138 | irq = macio_irq(mdev, 0); |
| 1139 | |
| 1140 | base = ioremap(macio_resource_start(mdev, 0), 0x400); |
| 1141 | regbase = (unsigned long) base; |
| 1142 | |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 1143 | hwif->dev = &mdev->bus->pdev->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | |
| 1145 | pmif->mdev = mdev; |
| 1146 | pmif->node = mdev->ofdev.node; |
| 1147 | pmif->regbase = regbase; |
| 1148 | pmif->irq = irq; |
| 1149 | pmif->kauai_fcr = NULL; |
| 1150 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
| 1151 | if (macio_resource_count(mdev) >= 2) { |
| 1152 | if (macio_request_resource(mdev, 1, "ide-pmac (dma)")) |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1153 | printk(KERN_WARNING "ide-pmac: can't request DMA " |
| 1154 | "resource for %s!\n", |
| 1155 | mdev->ofdev.node->full_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | else |
| 1157 | pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000); |
| 1158 | } else |
| 1159 | pmif->dma_regs = NULL; |
| 1160 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
| 1161 | dev_set_drvdata(&mdev->ofdev.dev, hwif); |
| 1162 | |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 1163 | memset(&hw, 0, sizeof(hw)); |
Bartlomiej Zolnierkiewicz | 5c58666 | 2008-04-18 00:46:29 +0200 | [diff] [blame] | 1164 | pmac_ide_init_ports(&hw, pmif->regbase); |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 1165 | hw.irq = irq; |
| 1166 | hw.dev = &mdev->ofdev.dev; |
| 1167 | |
| 1168 | rc = pmac_ide_setup_device(pmif, hwif, &hw); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | if (rc != 0) { |
| 1170 | /* The inteface is released to the common IDE layer */ |
| 1171 | dev_set_drvdata(&mdev->ofdev.dev, NULL); |
| 1172 | iounmap(base); |
Bartlomiej Zolnierkiewicz | ed908fa | 2008-02-01 23:09:32 +0100 | [diff] [blame] | 1173 | if (pmif->dma_regs) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | iounmap(pmif->dma_regs); |
Bartlomiej Zolnierkiewicz | ed908fa | 2008-02-01 23:09:32 +0100 | [diff] [blame] | 1175 | macio_release_resource(mdev, 1); |
| 1176 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | macio_release_resource(mdev, 0); |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1178 | kfree(pmif); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | return rc; |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1182 | |
| 1183 | out_free_pmif: |
| 1184 | kfree(pmif); |
| 1185 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | static int |
David Brownell | 8b4b8a2 | 2006-08-14 23:11:03 -0700 | [diff] [blame] | 1189 | pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | { |
| 1191 | ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); |
| 1192 | int rc = 0; |
| 1193 | |
David Brownell | 8b4b8a2 | 2006-08-14 23:11:03 -0700 | [diff] [blame] | 1194 | if (mesg.event != mdev->ofdev.dev.power.power_state.event |
Rafael J. Wysocki | 3a2d5b7 | 2008-02-23 19:13:25 +0100 | [diff] [blame] | 1195 | && (mesg.event & PM_EVENT_SLEEP)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | rc = pmac_ide_do_suspend(hwif); |
| 1197 | if (rc == 0) |
David Brownell | 8b4b8a2 | 2006-08-14 23:11:03 -0700 | [diff] [blame] | 1198 | mdev->ofdev.dev.power.power_state = mesg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | } |
| 1200 | |
| 1201 | return rc; |
| 1202 | } |
| 1203 | |
| 1204 | static int |
| 1205 | pmac_ide_macio_resume(struct macio_dev *mdev) |
| 1206 | { |
| 1207 | ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); |
| 1208 | int rc = 0; |
| 1209 | |
Pavel Machek | ca078ba | 2005-09-03 15:56:57 -0700 | [diff] [blame] | 1210 | if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | rc = pmac_ide_do_resume(hwif); |
| 1212 | if (rc == 0) |
Pavel Machek | 829ca9a | 2005-09-03 15:56:56 -0700 | [diff] [blame] | 1213 | mdev->ofdev.dev.power.power_state = PMSG_ON; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | } |
| 1215 | |
| 1216 | return rc; |
| 1217 | } |
| 1218 | |
| 1219 | /* |
| 1220 | * Attach to a PCI probed interface |
| 1221 | */ |
| 1222 | static int __devinit |
| 1223 | pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) |
| 1224 | { |
| 1225 | ide_hwif_t *hwif; |
| 1226 | struct device_node *np; |
| 1227 | pmac_ide_hwif_t *pmif; |
| 1228 | void __iomem *base; |
| 1229 | unsigned long rbase, rlen; |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1230 | int rc; |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 1231 | hw_regs_t hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | |
| 1233 | np = pci_device_to_OF_node(pdev); |
| 1234 | if (np == NULL) { |
| 1235 | printk(KERN_ERR "ide-pmac: cannot find MacIO node for Kauai ATA interface\n"); |
| 1236 | return -ENODEV; |
| 1237 | } |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1238 | |
| 1239 | pmif = kzalloc(sizeof(*pmif), GFP_KERNEL); |
| 1240 | if (pmif == NULL) |
| 1241 | return -ENOMEM; |
| 1242 | |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1243 | hwif = ide_find_port(); |
| 1244 | if (hwif == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n"); |
| 1246 | printk(KERN_ERR " %s\n", np->full_name); |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1247 | rc = -ENODEV; |
| 1248 | goto out_free_pmif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | } |
| 1250 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | if (pci_enable_device(pdev)) { |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1252 | printk(KERN_WARNING "ide-pmac: Can't enable PCI device for " |
| 1253 | "%s\n", np->full_name); |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1254 | rc = -ENXIO; |
| 1255 | goto out_free_pmif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | } |
| 1257 | pci_set_master(pdev); |
| 1258 | |
| 1259 | if (pci_request_regions(pdev, "Kauai ATA")) { |
Bartlomiej Zolnierkiewicz | 939b0f1 | 2008-04-26 17:36:33 +0200 | [diff] [blame] | 1260 | printk(KERN_ERR "ide-pmac: Cannot obtain PCI resources for " |
| 1261 | "%s\n", np->full_name); |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1262 | rc = -ENXIO; |
| 1263 | goto out_free_pmif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1264 | } |
| 1265 | |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 1266 | hwif->dev = &pdev->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | pmif->mdev = NULL; |
| 1268 | pmif->node = np; |
| 1269 | |
| 1270 | rbase = pci_resource_start(pdev, 0); |
| 1271 | rlen = pci_resource_len(pdev, 0); |
| 1272 | |
| 1273 | base = ioremap(rbase, rlen); |
| 1274 | pmif->regbase = (unsigned long) base + 0x2000; |
| 1275 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
| 1276 | pmif->dma_regs = base + 0x1000; |
| 1277 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
| 1278 | pmif->kauai_fcr = base; |
| 1279 | pmif->irq = pdev->irq; |
| 1280 | |
| 1281 | pci_set_drvdata(pdev, hwif); |
| 1282 | |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 1283 | memset(&hw, 0, sizeof(hw)); |
Bartlomiej Zolnierkiewicz | 5c58666 | 2008-04-18 00:46:29 +0200 | [diff] [blame] | 1284 | pmac_ide_init_ports(&hw, pmif->regbase); |
Bartlomiej Zolnierkiewicz | 57c802e | 2008-01-26 20:13:05 +0100 | [diff] [blame] | 1285 | hw.irq = pdev->irq; |
| 1286 | hw.dev = &pdev->dev; |
| 1287 | |
| 1288 | rc = pmac_ide_setup_device(pmif, hwif, &hw); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | if (rc != 0) { |
| 1290 | /* The inteface is released to the common IDE layer */ |
| 1291 | pci_set_drvdata(pdev, NULL); |
| 1292 | iounmap(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1293 | pci_release_regions(pdev); |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1294 | kfree(pmif); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | return rc; |
Bartlomiej Zolnierkiewicz | 5297a3e | 2008-04-26 17:36:32 +0200 | [diff] [blame] | 1298 | |
| 1299 | out_free_pmif: |
| 1300 | kfree(pmif); |
| 1301 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1302 | } |
| 1303 | |
| 1304 | static int |
David Brownell | 8b4b8a2 | 2006-08-14 23:11:03 -0700 | [diff] [blame] | 1305 | pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | { |
| 1307 | ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev); |
| 1308 | int rc = 0; |
| 1309 | |
David Brownell | 8b4b8a2 | 2006-08-14 23:11:03 -0700 | [diff] [blame] | 1310 | if (mesg.event != pdev->dev.power.power_state.event |
Rafael J. Wysocki | 3a2d5b7 | 2008-02-23 19:13:25 +0100 | [diff] [blame] | 1311 | && (mesg.event & PM_EVENT_SLEEP)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | rc = pmac_ide_do_suspend(hwif); |
| 1313 | if (rc == 0) |
David Brownell | 8b4b8a2 | 2006-08-14 23:11:03 -0700 | [diff] [blame] | 1314 | pdev->dev.power.power_state = mesg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | } |
| 1316 | |
| 1317 | return rc; |
| 1318 | } |
| 1319 | |
| 1320 | static int |
| 1321 | pmac_ide_pci_resume(struct pci_dev *pdev) |
| 1322 | { |
| 1323 | ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev); |
| 1324 | int rc = 0; |
| 1325 | |
Pavel Machek | ca078ba | 2005-09-03 15:56:57 -0700 | [diff] [blame] | 1326 | if (pdev->dev.power.power_state.event != PM_EVENT_ON) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | rc = pmac_ide_do_resume(hwif); |
| 1328 | if (rc == 0) |
Pavel Machek | 829ca9a | 2005-09-03 15:56:56 -0700 | [diff] [blame] | 1329 | pdev->dev.power.power_state = PMSG_ON; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | } |
| 1331 | |
| 1332 | return rc; |
| 1333 | } |
| 1334 | |
Jeff Mahoney | 5e65577 | 2005-07-06 15:44:41 -0400 | [diff] [blame] | 1335 | static struct of_device_id pmac_ide_macio_match[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1336 | { |
| 1337 | { |
| 1338 | .name = "IDE", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | }, |
| 1340 | { |
| 1341 | .name = "ATA", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | }, |
| 1343 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | .type = "ide", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | }, |
| 1346 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | .type = "ata", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | }, |
| 1349 | {}, |
| 1350 | }; |
| 1351 | |
| 1352 | static struct macio_driver pmac_ide_macio_driver = |
| 1353 | { |
| 1354 | .name = "ide-pmac", |
| 1355 | .match_table = pmac_ide_macio_match, |
| 1356 | .probe = pmac_ide_macio_attach, |
| 1357 | .suspend = pmac_ide_macio_suspend, |
| 1358 | .resume = pmac_ide_macio_resume, |
| 1359 | }; |
| 1360 | |
Bartlomiej Zolnierkiewicz | 9cbcc5e | 2007-10-16 22:29:56 +0200 | [diff] [blame] | 1361 | static const struct pci_device_id pmac_ide_pci_match[] = { |
| 1362 | { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA), 0 }, |
| 1363 | { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100), 0 }, |
| 1364 | { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100), 0 }, |
| 1365 | { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_SH_ATA), 0 }, |
| 1366 | { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_IPID2_ATA), 0 }, |
Benjamin Herrenschmidt | 71e4eda | 2007-10-06 18:52:27 +1000 | [diff] [blame] | 1367 | {}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | }; |
| 1369 | |
| 1370 | static struct pci_driver pmac_ide_pci_driver = { |
| 1371 | .name = "ide-pmac", |
| 1372 | .id_table = pmac_ide_pci_match, |
| 1373 | .probe = pmac_ide_pci_attach, |
| 1374 | .suspend = pmac_ide_pci_suspend, |
| 1375 | .resume = pmac_ide_pci_resume, |
| 1376 | }; |
| 1377 | MODULE_DEVICE_TABLE(pci, pmac_ide_pci_match); |
| 1378 | |
Andrew Morton | 9e5755b | 2007-03-03 17:48:54 +0100 | [diff] [blame] | 1379 | int __init pmac_ide_probe(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | { |
Andrew Morton | 9e5755b | 2007-03-03 17:48:54 +0100 | [diff] [blame] | 1381 | int error; |
| 1382 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 1383 | if (!machine_is(powermac)) |
Andrew Morton | 9e5755b | 2007-03-03 17:48:54 +0100 | [diff] [blame] | 1384 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | |
| 1386 | #ifdef CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST |
Andrew Morton | 9e5755b | 2007-03-03 17:48:54 +0100 | [diff] [blame] | 1387 | error = pci_register_driver(&pmac_ide_pci_driver); |
| 1388 | if (error) |
| 1389 | goto out; |
| 1390 | error = macio_register_driver(&pmac_ide_macio_driver); |
| 1391 | if (error) { |
| 1392 | pci_unregister_driver(&pmac_ide_pci_driver); |
| 1393 | goto out; |
| 1394 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | #else |
Andrew Morton | 9e5755b | 2007-03-03 17:48:54 +0100 | [diff] [blame] | 1396 | error = macio_register_driver(&pmac_ide_macio_driver); |
| 1397 | if (error) |
| 1398 | goto out; |
| 1399 | error = pci_register_driver(&pmac_ide_pci_driver); |
| 1400 | if (error) { |
| 1401 | macio_unregister_driver(&pmac_ide_macio_driver); |
| 1402 | goto out; |
| 1403 | } |
Benjamin Herrenschmidt | 1beb6a7 | 2005-12-14 13:10:10 +1100 | [diff] [blame] | 1404 | #endif |
Andrew Morton | 9e5755b | 2007-03-03 17:48:54 +0100 | [diff] [blame] | 1405 | out: |
| 1406 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1407 | } |
| 1408 | |
| 1409 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
| 1410 | |
| 1411 | /* |
| 1412 | * pmac_ide_build_dmatable builds the DBDMA command list |
| 1413 | * for a transfer and sets the DBDMA channel to point to it. |
| 1414 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 1415 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1416 | pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) |
| 1417 | { |
| 1418 | struct dbdma_cmd *table; |
| 1419 | int i, count = 0; |
| 1420 | ide_hwif_t *hwif = HWIF(drive); |
| 1421 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data; |
| 1422 | volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; |
| 1423 | struct scatterlist *sg; |
| 1424 | int wr = (rq_data_dir(rq) == WRITE); |
| 1425 | |
| 1426 | /* DMA table is already aligned */ |
| 1427 | table = (struct dbdma_cmd *) pmif->dma_table_cpu; |
| 1428 | |
| 1429 | /* Make sure DMA controller is stopped (necessary ?) */ |
| 1430 | writel((RUN|PAUSE|FLUSH|WAKE|DEAD) << 16, &dma->control); |
| 1431 | while (readl(&dma->status) & RUN) |
| 1432 | udelay(1); |
| 1433 | |
| 1434 | hwif->sg_nents = i = ide_build_sglist(drive, rq); |
| 1435 | |
| 1436 | if (!i) |
| 1437 | return 0; |
| 1438 | |
| 1439 | /* Build DBDMA commands list */ |
| 1440 | sg = hwif->sg_table; |
| 1441 | while (i && sg_dma_len(sg)) { |
| 1442 | u32 cur_addr; |
| 1443 | u32 cur_len; |
| 1444 | |
| 1445 | cur_addr = sg_dma_address(sg); |
| 1446 | cur_len = sg_dma_len(sg); |
| 1447 | |
| 1448 | if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) { |
| 1449 | if (pmif->broken_dma_warn == 0) { |
Joe Perches | aca38a5 | 2007-11-27 21:35:55 +0100 | [diff] [blame] | 1450 | printk(KERN_WARNING "%s: DMA on non aligned address, " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1451 | "switching to PIO on Ohare chipset\n", drive->name); |
| 1452 | pmif->broken_dma_warn = 1; |
| 1453 | } |
| 1454 | goto use_pio_instead; |
| 1455 | } |
| 1456 | while (cur_len) { |
| 1457 | unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00; |
| 1458 | |
| 1459 | if (count++ >= MAX_DCMDS) { |
| 1460 | printk(KERN_WARNING "%s: DMA table too small\n", |
| 1461 | drive->name); |
| 1462 | goto use_pio_instead; |
| 1463 | } |
| 1464 | st_le16(&table->command, wr? OUTPUT_MORE: INPUT_MORE); |
| 1465 | st_le16(&table->req_count, tc); |
| 1466 | st_le32(&table->phy_addr, cur_addr); |
| 1467 | table->cmd_dep = 0; |
| 1468 | table->xfer_status = 0; |
| 1469 | table->res_count = 0; |
| 1470 | cur_addr += tc; |
| 1471 | cur_len -= tc; |
| 1472 | ++table; |
| 1473 | } |
Jens Axboe | 55c16a7 | 2007-07-25 08:13:56 +0200 | [diff] [blame] | 1474 | sg = sg_next(sg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | i--; |
| 1476 | } |
| 1477 | |
| 1478 | /* convert the last command to an input/output last command */ |
| 1479 | if (count) { |
| 1480 | st_le16(&table[-1].command, wr? OUTPUT_LAST: INPUT_LAST); |
| 1481 | /* add the stop command to the end of the list */ |
| 1482 | memset(table, 0, sizeof(struct dbdma_cmd)); |
| 1483 | st_le16(&table->command, DBDMA_STOP); |
| 1484 | mb(); |
| 1485 | writel(hwif->dmatable_dma, &dma->cmdptr); |
| 1486 | return 1; |
| 1487 | } |
| 1488 | |
| 1489 | printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name); |
Bartlomiej Zolnierkiewicz | f6fb786 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 1490 | |
| 1491 | use_pio_instead: |
| 1492 | ide_destroy_dmatable(drive); |
| 1493 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1494 | return 0; /* revert to PIO for this request */ |
| 1495 | } |
| 1496 | |
| 1497 | /* Teardown mappings after DMA has completed. */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 1498 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | pmac_ide_destroy_dmatable (ide_drive_t *drive) |
| 1500 | { |
| 1501 | ide_hwif_t *hwif = drive->hwif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1502 | |
Bartlomiej Zolnierkiewicz | f6fb786 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 1503 | if (hwif->sg_nents) { |
| 1504 | ide_destroy_dmatable(drive); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | hwif->sg_nents = 0; |
| 1506 | } |
| 1507 | } |
| 1508 | |
| 1509 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | * Prepare a DMA transfer. We build the DMA table, adjust the timings for |
| 1511 | * a read on KeyLargo ATA/66 and mark us as waiting for DMA completion |
| 1512 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 1513 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | pmac_ide_dma_setup(ide_drive_t *drive) |
| 1515 | { |
| 1516 | ide_hwif_t *hwif = HWIF(drive); |
| 1517 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data; |
| 1518 | struct request *rq = HWGROUP(drive)->rq; |
| 1519 | u8 unit = (drive->select.b.unit & 0x01); |
| 1520 | u8 ata4; |
| 1521 | |
| 1522 | if (pmif == NULL) |
| 1523 | return 1; |
| 1524 | ata4 = (pmif->kind == controller_kl_ata4); |
| 1525 | |
| 1526 | if (!pmac_ide_build_dmatable(drive, rq)) { |
| 1527 | ide_map_sg(drive, rq); |
| 1528 | return 1; |
| 1529 | } |
| 1530 | |
| 1531 | /* Apple adds 60ns to wrDataSetup on reads */ |
| 1532 | if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) { |
| 1533 | writel(pmif->timings[unit] + (!rq_data_dir(rq) ? 0x00800000UL : 0), |
| 1534 | PMAC_IDE_REG(IDE_TIMING_CONFIG)); |
| 1535 | (void)readl(PMAC_IDE_REG(IDE_TIMING_CONFIG)); |
| 1536 | } |
| 1537 | |
| 1538 | drive->waiting_for_dma = 1; |
| 1539 | |
| 1540 | return 0; |
| 1541 | } |
| 1542 | |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 1543 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1544 | pmac_ide_dma_exec_cmd(ide_drive_t *drive, u8 command) |
| 1545 | { |
| 1546 | /* issue cmd to drive */ |
| 1547 | ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, NULL); |
| 1548 | } |
| 1549 | |
| 1550 | /* |
| 1551 | * Kick the DMA controller into life after the DMA command has been issued |
| 1552 | * to the drive. |
| 1553 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 1554 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1555 | pmac_ide_dma_start(ide_drive_t *drive) |
| 1556 | { |
| 1557 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; |
| 1558 | volatile struct dbdma_regs __iomem *dma; |
| 1559 | |
| 1560 | dma = pmif->dma_regs; |
| 1561 | |
| 1562 | writel((RUN << 16) | RUN, &dma->control); |
| 1563 | /* Make sure it gets to the controller right now */ |
| 1564 | (void)readl(&dma->control); |
| 1565 | } |
| 1566 | |
| 1567 | /* |
| 1568 | * After a DMA transfer, make sure the controller is stopped |
| 1569 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 1570 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1571 | pmac_ide_dma_end (ide_drive_t *drive) |
| 1572 | { |
| 1573 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; |
| 1574 | volatile struct dbdma_regs __iomem *dma; |
| 1575 | u32 dstat; |
| 1576 | |
| 1577 | if (pmif == NULL) |
| 1578 | return 0; |
| 1579 | dma = pmif->dma_regs; |
| 1580 | |
| 1581 | drive->waiting_for_dma = 0; |
| 1582 | dstat = readl(&dma->status); |
| 1583 | writel(((RUN|WAKE|DEAD) << 16), &dma->control); |
| 1584 | pmac_ide_destroy_dmatable(drive); |
| 1585 | /* verify good dma status. we don't check for ACTIVE beeing 0. We should... |
| 1586 | * in theory, but with ATAPI decices doing buffer underruns, that would |
| 1587 | * cause us to disable DMA, which isn't what we want |
| 1588 | */ |
| 1589 | return (dstat & (RUN|DEAD)) != RUN; |
| 1590 | } |
| 1591 | |
| 1592 | /* |
| 1593 | * Check out that the interrupt we got was for us. We can't always know this |
| 1594 | * for sure with those Apple interfaces (well, we could on the recent ones but |
| 1595 | * that's not implemented yet), on the other hand, we don't have shared interrupts |
| 1596 | * so it's not really a problem |
| 1597 | */ |
Jon Loeliger | aacaf9b | 2005-09-17 10:36:54 -0500 | [diff] [blame] | 1598 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1599 | pmac_ide_dma_test_irq (ide_drive_t *drive) |
| 1600 | { |
| 1601 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; |
| 1602 | volatile struct dbdma_regs __iomem *dma; |
| 1603 | unsigned long status, timeout; |
| 1604 | |
| 1605 | if (pmif == NULL) |
| 1606 | return 0; |
| 1607 | dma = pmif->dma_regs; |
| 1608 | |
| 1609 | /* We have to things to deal with here: |
| 1610 | * |
| 1611 | * - The dbdma won't stop if the command was started |
| 1612 | * but completed with an error without transferring all |
| 1613 | * datas. This happens when bad blocks are met during |
| 1614 | * a multi-block transfer. |
| 1615 | * |
| 1616 | * - The dbdma fifo hasn't yet finished flushing to |
| 1617 | * to system memory when the disk interrupt occurs. |
| 1618 | * |
| 1619 | */ |
| 1620 | |
| 1621 | /* If ACTIVE is cleared, the STOP command have passed and |
| 1622 | * transfer is complete. |
| 1623 | */ |
| 1624 | status = readl(&dma->status); |
| 1625 | if (!(status & ACTIVE)) |
| 1626 | return 1; |
| 1627 | if (!drive->waiting_for_dma) |
| 1628 | printk(KERN_WARNING "ide%d, ide_dma_test_irq \ |
| 1629 | called while not waiting\n", HWIF(drive)->index); |
| 1630 | |
| 1631 | /* If dbdma didn't execute the STOP command yet, the |
| 1632 | * active bit is still set. We consider that we aren't |
| 1633 | * sharing interrupts (which is hopefully the case with |
| 1634 | * those controllers) and so we just try to flush the |
| 1635 | * channel for pending data in the fifo |
| 1636 | */ |
| 1637 | udelay(1); |
| 1638 | writel((FLUSH << 16) | FLUSH, &dma->control); |
| 1639 | timeout = 0; |
| 1640 | for (;;) { |
| 1641 | udelay(1); |
| 1642 | status = readl(&dma->status); |
| 1643 | if ((status & FLUSH) == 0) |
| 1644 | break; |
| 1645 | if (++timeout > 100) { |
| 1646 | printk(KERN_WARNING "ide%d, ide_dma_test_irq \ |
| 1647 | timeout flushing channel\n", HWIF(drive)->index); |
| 1648 | break; |
| 1649 | } |
| 1650 | } |
| 1651 | return 1; |
| 1652 | } |
| 1653 | |
Bartlomiej Zolnierkiewicz | 15ce926 | 2008-01-26 20:13:03 +0100 | [diff] [blame] | 1654 | static void pmac_ide_dma_host_set(ide_drive_t *drive, int on) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1655 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1656 | } |
| 1657 | |
Sergei Shtylyov | 841d2a9 | 2007-07-09 23:17:54 +0200 | [diff] [blame] | 1658 | static void |
| 1659 | pmac_ide_dma_lost_irq (ide_drive_t *drive) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1660 | { |
| 1661 | pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; |
| 1662 | volatile struct dbdma_regs __iomem *dma; |
| 1663 | unsigned long status; |
| 1664 | |
| 1665 | if (pmif == NULL) |
Sergei Shtylyov | 841d2a9 | 2007-07-09 23:17:54 +0200 | [diff] [blame] | 1666 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1667 | dma = pmif->dma_regs; |
| 1668 | |
| 1669 | status = readl(&dma->status); |
| 1670 | printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1671 | } |
| 1672 | |
| 1673 | /* |
| 1674 | * Allocate the data structures needed for using DMA with an interface |
| 1675 | * and fill the proper list of functions pointers |
| 1676 | */ |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 1677 | static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1678 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 1679 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| 1680 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1681 | /* We won't need pci_dev if we switch to generic consistent |
| 1682 | * DMA routines ... |
| 1683 | */ |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 1684 | if (dev == NULL) |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 1685 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1686 | /* |
| 1687 | * Allocate space for the DBDMA commands. |
| 1688 | * The +2 is +1 for the stop command and +1 to allow for |
| 1689 | * aligning the start address to a multiple of 16 bytes. |
| 1690 | */ |
| 1691 | pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent( |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame] | 1692 | dev, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd), |
| 1694 | &hwif->dmatable_dma); |
| 1695 | if (pmif->dma_table_cpu == NULL) { |
| 1696 | printk(KERN_ERR "%s: unable to allocate DMA command list\n", |
| 1697 | hwif->name); |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 1698 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | } |
| 1700 | |
Bartlomiej Zolnierkiewicz | 4f52a32 | 2008-01-26 20:13:08 +0100 | [diff] [blame] | 1701 | hwif->sg_max_nents = MAX_DCMDS; |
| 1702 | |
Bartlomiej Zolnierkiewicz | 15ce926 | 2008-01-26 20:13:03 +0100 | [diff] [blame] | 1703 | hwif->dma_host_set = &pmac_ide_dma_host_set; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | hwif->dma_setup = &pmac_ide_dma_setup; |
| 1705 | hwif->dma_exec_cmd = &pmac_ide_dma_exec_cmd; |
| 1706 | hwif->dma_start = &pmac_ide_dma_start; |
| 1707 | hwif->ide_dma_end = &pmac_ide_dma_end; |
| 1708 | hwif->ide_dma_test_irq = &pmac_ide_dma_test_irq; |
Sergei Shtylyov | c283f5d | 2007-07-09 23:17:54 +0200 | [diff] [blame] | 1709 | hwif->dma_timeout = &ide_dma_timeout; |
Sergei Shtylyov | 841d2a9 | 2007-07-09 23:17:54 +0200 | [diff] [blame] | 1710 | hwif->dma_lost_irq = &pmac_ide_dma_lost_irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 1712 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | } |
| 1714 | |
| 1715 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
Bartlomiej Zolnierkiewicz | ade2daf | 2008-01-26 20:13:07 +0100 | [diff] [blame] | 1716 | |
| 1717 | module_init(pmac_ide_probe); |
Adrian Bunk | de9facb | 2008-04-02 21:22:03 +0200 | [diff] [blame] | 1718 | |
| 1719 | MODULE_LICENSE("GPL"); |