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 | * Copyright (C) 1995-2000 Linus Torvalds & author (see below) |
| 3 | */ |
| 4 | |
| 5 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * HT-6560B EIDE-controller support |
| 7 | * To activate controller support use kernel parameter "ide0=ht6560b". |
| 8 | * Use hdparm utility to enable PIO mode support. |
| 9 | * |
| 10 | * Author: Mikko Ala-Fossi <maf@iki.fi> |
Jan Evert van Grootheest | eb34b2d | 2008-07-24 22:53:35 +0200 | [diff] [blame] | 11 | * Jan Evert van Grootheest <j.e.van.grootheest@caiway.nl> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | */ |
| 14 | |
Bartlomiej Zolnierkiewicz | 2e4ed29 | 2008-04-26 17:36:35 +0200 | [diff] [blame] | 15 | #define DRV_NAME "ht6560b" |
Jan Evert van Grootheest | 0e7d8d48 | 2008-02-19 01:41:26 +0100 | [diff] [blame] | 16 | #define HT6560B_VERSION "v0.08" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/types.h> |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/timer.h> |
| 23 | #include <linux/mm.h> |
| 24 | #include <linux/ioport.h> |
| 25 | #include <linux/blkdev.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/ide.h> |
| 27 | #include <linux/init.h> |
| 28 | |
| 29 | #include <asm/io.h> |
| 30 | |
| 31 | /* #define DEBUG */ /* remove comments for DEBUG messages */ |
| 32 | |
| 33 | /* |
| 34 | * The special i/o-port that HT-6560B uses to configuration: |
| 35 | * bit0 (0x01): "1" selects secondary interface |
| 36 | * bit2 (0x04): "1" enables FIFO function |
| 37 | * bit5 (0x20): "1" enables prefetched data read function (???) |
| 38 | * |
| 39 | * The special i/o-port that HT-6560A uses to configuration: |
| 40 | * bit0 (0x01): "1" selects secondary interface |
| 41 | * bit1 (0x02): "1" enables prefetched data read function |
| 42 | * bit2 (0x04): "0" enables multi-master system (?) |
| 43 | * bit3 (0x08): "1" 3 cycle time, "0" 2 cycle time (?) |
| 44 | */ |
| 45 | #define HT_CONFIG_PORT 0x3e6 |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 46 | |
| 47 | static inline u8 HT_CONFIG(ide_drive_t *drive) |
| 48 | { |
| 49 | return ((unsigned long)ide_get_drivedata(drive) & 0xff00) >> 8; |
| 50 | } |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | /* |
| 53 | * FIFO + PREFETCH (both a/b-model) |
| 54 | */ |
| 55 | #define HT_CONFIG_DEFAULT 0x1c /* no prefetch */ |
| 56 | /* #define HT_CONFIG_DEFAULT 0x3c */ /* with prefetch */ |
| 57 | #define HT_SECONDARY_IF 0x01 |
| 58 | #define HT_PREFETCH_MODE 0x20 |
| 59 | |
| 60 | /* |
| 61 | * ht6560b Timing values: |
| 62 | * |
| 63 | * I reviewed some assembler source listings of htide drivers and found |
| 64 | * out how they setup those cycle time interfacing values, as they at Holtek |
| 65 | * call them. IDESETUP.COM that is supplied with the drivers figures out |
| 66 | * optimal values and fetches those values to drivers. I found out that |
Bartlomiej Zolnierkiewicz | 23579a2 | 2008-04-18 00:46:26 +0200 | [diff] [blame] | 67 | * they use Select register to fetch timings to the ide board right after |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | * interface switching. After that it was quite easy to add code to |
| 69 | * ht6560b.c. |
| 70 | * |
| 71 | * IDESETUP.COM gave me values 0x24, 0x45, 0xaa, 0xff that worked fine |
| 72 | * for hda and hdc. But hdb needed higher values to work, so I guess |
| 73 | * that sometimes it is necessary to give higher value than IDESETUP |
| 74 | * gives. [see cmd640.c for an extreme example of this. -ml] |
| 75 | * |
| 76 | * Perhaps I should explain something about these timing values: |
| 77 | * The higher nibble of value is the Recovery Time (rt) and the lower nibble |
| 78 | * of the value is the Active Time (at). Minimum value 2 is the fastest and |
| 79 | * the maximum value 15 is the slowest. Default values should be 15 for both. |
| 80 | * So 0x24 means 2 for rt and 4 for at. Each of the drives should have |
| 81 | * both values, and IDESETUP gives automatically rt=15 st=15 for CDROMs or |
| 82 | * similar. If value is too small there will be all sorts of failures. |
| 83 | * |
| 84 | * Timing byte consists of |
| 85 | * High nibble: Recovery Cycle Time (rt) |
| 86 | * The valid values range from 2 to 15. The default is 15. |
| 87 | * |
| 88 | * Low nibble: Active Cycle Time (at) |
| 89 | * The valid values range from 2 to 15. The default is 15. |
| 90 | * |
| 91 | * You can obtain optimized timing values by running Holtek IDESETUP.COM |
| 92 | * for DOS. DOS drivers get their timing values from command line, where |
| 93 | * the first value is the Recovery Time and the second value is the |
| 94 | * Active Time for each drive. Smaller value gives higher speed. |
| 95 | * In case of failures you should probably fall back to a higher value. |
| 96 | */ |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 97 | static inline u8 HT_TIMING(ide_drive_t *drive) |
| 98 | { |
| 99 | return (unsigned long)ide_get_drivedata(drive) & 0x00ff; |
| 100 | } |
| 101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | #define HT_TIMING_DEFAULT 0xff |
| 103 | |
| 104 | /* |
| 105 | * This routine handles interface switching for the peculiar hardware design |
| 106 | * on the F.G.I./Holtek HT-6560B VLB IDE interface. |
| 107 | * The HT-6560B can only enable one IDE port at a time, and requires a |
| 108 | * silly sequence (below) whenever we switch between primary and secondary. |
| 109 | */ |
| 110 | |
| 111 | /* |
| 112 | * This routine is invoked from ide.c to prepare for access to a given drive. |
| 113 | */ |
Sergei Shtylyov | abb596b | 2009-03-31 20:15:32 +0200 | [diff] [blame] | 114 | static void ht6560b_dev_select(ide_drive_t *drive) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | { |
Bartlomiej Zolnierkiewicz | 23579a2 | 2008-04-18 00:46:26 +0200 | [diff] [blame] | 116 | ide_hwif_t *hwif = drive->hwif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | unsigned long flags; |
| 118 | static u8 current_select = 0; |
| 119 | static u8 current_timing = 0; |
| 120 | u8 select, timing; |
| 121 | |
| 122 | local_irq_save(flags); |
Jan Evert van Grootheest | 0e7d8d48 | 2008-02-19 01:41:26 +0100 | [diff] [blame] | 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | select = HT_CONFIG(drive); |
| 125 | timing = HT_TIMING(drive); |
Jan Evert van Grootheest | 0e7d8d48 | 2008-02-19 01:41:26 +0100 | [diff] [blame] | 126 | |
| 127 | /* |
| 128 | * Need to enforce prefetch sometimes because otherwise |
| 129 | * it'll hang (hard). |
| 130 | */ |
Bartlomiej Zolnierkiewicz | 97100fc | 2008-10-13 21:39:36 +0200 | [diff] [blame] | 131 | if (drive->media != ide_disk || |
| 132 | (drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
Jan Evert van Grootheest | 0e7d8d48 | 2008-02-19 01:41:26 +0100 | [diff] [blame] | 133 | select |= HT_PREFETCH_MODE; |
| 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | if (select != current_select || timing != current_timing) { |
| 136 | current_select = select; |
| 137 | current_timing = timing; |
Bartlomiej Zolnierkiewicz | 0ecdca2 | 2007-02-17 02:40:25 +0100 | [diff] [blame] | 138 | (void)inb(HT_CONFIG_PORT); |
| 139 | (void)inb(HT_CONFIG_PORT); |
| 140 | (void)inb(HT_CONFIG_PORT); |
| 141 | (void)inb(HT_CONFIG_PORT); |
| 142 | outb(select, HT_CONFIG_PORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | /* |
| 144 | * Set timing for this drive: |
| 145 | */ |
Bartlomiej Zolnierkiewicz | 4c3032d | 2008-04-27 15:38:32 +0200 | [diff] [blame] | 146 | outb(timing, hwif->io_ports.device_addr); |
| 147 | (void)inb(hwif->io_ports.status_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | #ifdef DEBUG |
| 149 | printk("ht6560b: %s: select=%#x timing=%#x\n", |
| 150 | drive->name, select, timing); |
| 151 | #endif |
| 152 | } |
| 153 | local_irq_restore(flags); |
Sergei Shtylyov | abb596b | 2009-03-31 20:15:32 +0200 | [diff] [blame] | 154 | |
| 155 | outb(drive->select | ATA_DEVICE_OBS, hwif->io_ports.device_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /* |
| 159 | * Autodetection and initialization of ht6560b |
| 160 | */ |
| 161 | static int __init try_to_init_ht6560b(void) |
| 162 | { |
| 163 | u8 orig_value; |
| 164 | int i; |
| 165 | |
| 166 | /* Autodetect ht6560b */ |
| 167 | if ((orig_value = inb(HT_CONFIG_PORT)) == 0xff) |
| 168 | return 0; |
| 169 | |
| 170 | for (i=3;i>0;i--) { |
| 171 | outb(0x00, HT_CONFIG_PORT); |
| 172 | if (!( (~inb(HT_CONFIG_PORT)) & 0x3f )) { |
| 173 | outb(orig_value, HT_CONFIG_PORT); |
| 174 | return 0; |
| 175 | } |
| 176 | } |
| 177 | outb(0x00, HT_CONFIG_PORT); |
| 178 | if ((~inb(HT_CONFIG_PORT))& 0x3f) { |
| 179 | outb(orig_value, HT_CONFIG_PORT); |
| 180 | return 0; |
| 181 | } |
| 182 | /* |
| 183 | * Ht6560b autodetected |
| 184 | */ |
| 185 | outb(HT_CONFIG_DEFAULT, HT_CONFIG_PORT); |
Bartlomiej Zolnierkiewicz | 23579a2 | 2008-04-18 00:46:26 +0200 | [diff] [blame] | 186 | outb(HT_TIMING_DEFAULT, 0x1f6); /* Select register */ |
| 187 | (void)inb(0x1f7); /* Status register */ |
| 188 | |
Jan Evert van Grootheest | 0e7d8d48 | 2008-02-19 01:41:26 +0100 | [diff] [blame] | 189 | printk("ht6560b " HT6560B_VERSION |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | ": chipset detected and initialized" |
| 191 | #ifdef DEBUG |
| 192 | " with debug enabled" |
| 193 | #endif |
Jan Evert van Grootheest | 0e7d8d48 | 2008-02-19 01:41:26 +0100 | [diff] [blame] | 194 | "\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | ); |
| 196 | return 1; |
| 197 | } |
| 198 | |
Bartlomiej Zolnierkiewicz | 26bcb87 | 2007-10-11 23:54:00 +0200 | [diff] [blame] | 199 | static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | { |
| 201 | int active_time, recovery_time; |
| 202 | int active_cycles, recovery_cycles; |
Bartlomiej Zolnierkiewicz | 30e5ee4 | 2008-07-15 21:21:46 +0200 | [diff] [blame] | 203 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; |
Bartlomiej Zolnierkiewicz | ebae41a | 2008-04-27 15:38:29 +0200 | [diff] [blame] | 204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | if (pio) { |
Bartlomiej Zolnierkiewicz | 7dd0008 | 2007-07-20 01:11:56 +0200 | [diff] [blame] | 206 | unsigned int cycle_time; |
Bartlomiej Zolnierkiewicz | b32b76f | 2008-07-16 20:33:37 +0200 | [diff] [blame] | 207 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); |
Bartlomiej Zolnierkiewicz | 7dd0008 | 2007-07-20 01:11:56 +0200 | [diff] [blame] | 208 | |
Bartlomiej Zolnierkiewicz | 7dd0008 | 2007-07-20 01:11:56 +0200 | [diff] [blame] | 209 | cycle_time = ide_pio_cycle_time(drive, pio); |
| 210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | /* |
| 212 | * Just like opti621.c we try to calculate the |
| 213 | * actual cycle time for recovery and activity |
| 214 | * according system bus speed. |
| 215 | */ |
Bartlomiej Zolnierkiewicz | b32b76f | 2008-07-16 20:33:37 +0200 | [diff] [blame] | 216 | active_time = t->active; |
| 217 | recovery_time = cycle_time - active_time - t->setup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | /* |
| 219 | * Cycle times should be Vesa bus cycles |
| 220 | */ |
| 221 | active_cycles = (active_time * bus_speed + 999) / 1000; |
| 222 | recovery_cycles = (recovery_time * bus_speed + 999) / 1000; |
| 223 | /* |
| 224 | * Upper and lower limits |
| 225 | */ |
| 226 | if (active_cycles < 2) active_cycles = 2; |
| 227 | if (recovery_cycles < 2) recovery_cycles = 2; |
| 228 | if (active_cycles > 15) active_cycles = 15; |
| 229 | if (recovery_cycles > 15) recovery_cycles = 0; /* 0==16 */ |
| 230 | |
| 231 | #ifdef DEBUG |
| 232 | printk("ht6560b: drive %s setting pio=%d recovery=%d (%dns) active=%d (%dns)\n", drive->name, pio, recovery_cycles, recovery_time, active_cycles, active_time); |
| 233 | #endif |
| 234 | |
| 235 | return (u8)((recovery_cycles << 4) | active_cycles); |
| 236 | } else { |
| 237 | |
| 238 | #ifdef DEBUG |
| 239 | printk("ht6560b: drive %s setting pio=0\n", drive->name); |
| 240 | #endif |
| 241 | |
| 242 | return HT_TIMING_DEFAULT; /* default setting */ |
| 243 | } |
| 244 | } |
| 245 | |
Bartlomiej Zolnierkiewicz | 69e88d2 | 2007-10-20 00:32:35 +0200 | [diff] [blame] | 246 | static DEFINE_SPINLOCK(ht6560b_lock); |
| 247 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | /* |
| 249 | * Enable/Disable so called prefetch mode |
| 250 | */ |
| 251 | static void ht_set_prefetch(ide_drive_t *drive, u8 state) |
| 252 | { |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 253 | unsigned long flags, config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | int t = HT_PREFETCH_MODE << 8; |
Bartlomiej Zolnierkiewicz | 69e88d2 | 2007-10-20 00:32:35 +0200 | [diff] [blame] | 255 | |
| 256 | spin_lock_irqsave(&ht6560b_lock, flags); |
| 257 | |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 258 | config = (unsigned long)ide_get_drivedata(drive); |
| 259 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | /* |
| 261 | * Prefetch mode and unmask irq seems to conflict |
| 262 | */ |
| 263 | if (state) { |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 264 | config |= t; /* enable prefetch mode */ |
Bartlomiej Zolnierkiewicz | 97100fc | 2008-10-13 21:39:36 +0200 | [diff] [blame] | 265 | drive->dev_flags |= IDE_DFLAG_NO_UNMASK; |
| 266 | drive->dev_flags &= ~IDE_DFLAG_UNMASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } else { |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 268 | config &= ~t; /* disable prefetch mode */ |
Bartlomiej Zolnierkiewicz | 97100fc | 2008-10-13 21:39:36 +0200 | [diff] [blame] | 269 | drive->dev_flags &= ~IDE_DFLAG_NO_UNMASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | } |
Bartlomiej Zolnierkiewicz | 69e88d2 | 2007-10-20 00:32:35 +0200 | [diff] [blame] | 271 | |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 272 | ide_set_drivedata(drive, (void *)config); |
| 273 | |
Bartlomiej Zolnierkiewicz | 69e88d2 | 2007-10-20 00:32:35 +0200 | [diff] [blame] | 274 | spin_unlock_irqrestore(&ht6560b_lock, flags); |
| 275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | #ifdef DEBUG |
| 277 | printk("ht6560b: drive %s prefetch mode %sabled\n", drive->name, (state ? "en" : "dis")); |
| 278 | #endif |
| 279 | } |
| 280 | |
Bartlomiej Zolnierkiewicz | e085b3c | 2010-01-19 01:44:41 -0800 | [diff] [blame] | 281 | static void ht6560b_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | { |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 283 | unsigned long flags, config; |
Bartlomiej Zolnierkiewicz | e085b3c | 2010-01-19 01:44:41 -0800 | [diff] [blame] | 284 | const u8 pio = drive->pio_mode - XFER_PIO_0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | u8 timing; |
| 286 | |
| 287 | switch (pio) { |
| 288 | case 8: /* set prefetch off */ |
| 289 | case 9: /* set prefetch on */ |
| 290 | ht_set_prefetch(drive, pio & 1); |
| 291 | return; |
| 292 | } |
Bartlomiej Zolnierkiewicz | 69e88d2 | 2007-10-20 00:32:35 +0200 | [diff] [blame] | 293 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | timing = ht_pio2timings(drive, pio); |
Bartlomiej Zolnierkiewicz | 69e88d2 | 2007-10-20 00:32:35 +0200 | [diff] [blame] | 295 | |
| 296 | spin_lock_irqsave(&ht6560b_lock, flags); |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 297 | config = (unsigned long)ide_get_drivedata(drive); |
| 298 | config &= 0xff00; |
| 299 | config |= timing; |
| 300 | ide_set_drivedata(drive, (void *)config); |
Bartlomiej Zolnierkiewicz | 69e88d2 | 2007-10-20 00:32:35 +0200 | [diff] [blame] | 301 | spin_unlock_irqrestore(&ht6560b_lock, flags); |
| 302 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | #ifdef DEBUG |
| 304 | printk("ht6560b: drive %s tuned to pio mode %#x timing=%#x\n", drive->name, pio, timing); |
| 305 | #endif |
| 306 | } |
| 307 | |
Bartlomiej Zolnierkiewicz | e6d95bd | 2008-07-16 20:33:42 +0200 | [diff] [blame] | 308 | static void __init ht6560b_init_dev(ide_drive_t *drive) |
Bartlomiej Zolnierkiewicz | 1f2cf8b | 2008-02-02 19:56:40 +0100 | [diff] [blame] | 309 | { |
Bartlomiej Zolnierkiewicz | e6d95bd | 2008-07-16 20:33:42 +0200 | [diff] [blame] | 310 | ide_hwif_t *hwif = drive->hwif; |
Bartlomiej Zolnierkiewicz | 1f2cf8b | 2008-02-02 19:56:40 +0100 | [diff] [blame] | 311 | /* Setting default configurations for drives. */ |
| 312 | int t = (HT_CONFIG_DEFAULT << 8) | HT_TIMING_DEFAULT; |
| 313 | |
| 314 | if (hwif->channel) |
| 315 | t |= (HT_SECONDARY_IF << 8); |
| 316 | |
Joao Ramos | 5bfb151f | 2009-06-15 22:13:44 +0200 | [diff] [blame] | 317 | ide_set_drivedata(drive, (void *)t); |
Bartlomiej Zolnierkiewicz | 1f2cf8b | 2008-02-02 19:56:40 +0100 | [diff] [blame] | 318 | } |
| 319 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 320 | static bool probe_ht6560b; |
Bartlomiej Zolnierkiewicz | 8491388 | 2007-03-03 17:48:55 +0100 | [diff] [blame] | 321 | |
| 322 | module_param_named(probe, probe_ht6560b, bool, 0); |
| 323 | MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); |
| 324 | |
Sergei Shtylyov | abb596b | 2009-03-31 20:15:32 +0200 | [diff] [blame] | 325 | static const struct ide_tp_ops ht6560b_tp_ops = { |
| 326 | .exec_command = ide_exec_command, |
| 327 | .read_status = ide_read_status, |
| 328 | .read_altstatus = ide_read_altstatus, |
| 329 | .write_devctl = ide_write_devctl, |
| 330 | |
| 331 | .dev_select = ht6560b_dev_select, |
| 332 | .tf_load = ide_tf_load, |
| 333 | .tf_read = ide_tf_read, |
| 334 | |
| 335 | .input_data = ide_input_data, |
| 336 | .output_data = ide_output_data, |
| 337 | }; |
| 338 | |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 339 | static const struct ide_port_ops ht6560b_port_ops = { |
Bartlomiej Zolnierkiewicz | e6d95bd | 2008-07-16 20:33:42 +0200 | [diff] [blame] | 340 | .init_dev = ht6560b_init_dev, |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 341 | .set_pio_mode = ht6560b_set_pio_mode, |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 342 | }; |
| 343 | |
Andi Kleen | e6b5370 | 2012-10-04 17:11:48 -0700 | [diff] [blame] | 344 | static const struct ide_port_info ht6560b_port_info __initconst = { |
Bartlomiej Zolnierkiewicz | d92f1a2 | 2008-04-26 22:25:18 +0200 | [diff] [blame] | 345 | .name = DRV_NAME, |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 346 | .chipset = ide_ht6560b, |
Sergei Shtylyov | abb596b | 2009-03-31 20:15:32 +0200 | [diff] [blame] | 347 | .tp_ops = &ht6560b_tp_ops, |
Bartlomiej Zolnierkiewicz | ac95bee | 2008-04-26 22:25:14 +0200 | [diff] [blame] | 348 | .port_ops = &ht6560b_port_ops, |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 349 | .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ |
| 350 | IDE_HFLAG_NO_DMA | |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 351 | IDE_HFLAG_ABUSE_PREFETCH, |
Jan Evert van Grootheest | 1a1990f | 2008-02-19 01:41:26 +0100 | [diff] [blame] | 352 | .pio_mask = ATA_PIO4, |
Bartlomiej Zolnierkiewicz | c413b9b | 2008-02-02 19:56:31 +0100 | [diff] [blame] | 353 | }; |
| 354 | |
Bartlomiej Zolnierkiewicz | ade2daf | 2008-01-26 20:13:07 +0100 | [diff] [blame] | 355 | static int __init ht6560b_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | { |
Bartlomiej Zolnierkiewicz | 8491388 | 2007-03-03 17:48:55 +0100 | [diff] [blame] | 357 | if (probe_ht6560b == 0) |
| 358 | return -ENODEV; |
| 359 | |
Bartlomiej Zolnierkiewicz | 2e4ed29 | 2008-04-26 17:36:35 +0200 | [diff] [blame] | 360 | if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", |
Harvey Harrison | eb63963 | 2008-04-26 22:25:20 +0200 | [diff] [blame] | 362 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | return -ENODEV; |
| 364 | } |
| 365 | |
| 366 | if (!try_to_init_ht6560b()) { |
Harvey Harrison | eb63963 | 2008-04-26 22:25:20 +0200 | [diff] [blame] | 367 | printk(KERN_NOTICE "%s: HBA not found\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | goto release_region; |
| 369 | } |
| 370 | |
Bartlomiej Zolnierkiewicz | 0bfeee7 | 2008-04-26 22:25:16 +0200 | [diff] [blame] | 371 | return ide_legacy_device_add(&ht6560b_port_info, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | |
| 373 | release_region: |
| 374 | release_region(HT_CONFIG_PORT, 1); |
| 375 | return -ENODEV; |
| 376 | } |
| 377 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | module_init(ht6560b_init); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
| 380 | MODULE_AUTHOR("See Local File"); |
| 381 | MODULE_DESCRIPTION("HT-6560B EIDE-controller support"); |
| 382 | MODULE_LICENSE("GPL"); |