Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Bartlomiej Zolnierkiewicz | 59bca8c | 2008-02-01 23:09:33 +0100 | [diff] [blame] | 2 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) |
Pavel Machek | fc41069 | 2008-07-23 19:56:02 +0200 | [diff] [blame] | 3 | * Copyright (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Mostly written by Mark Lord <mlord@pobox.com> |
| 8 | * and Gadi Oxman <gadio@netvision.net.il> |
| 9 | * and Andre Hedrick <andre@linux-ide.org> |
| 10 | * |
| 11 | * See linux/MAINTAINERS for address of current maintainer. |
| 12 | * |
| 13 | * This is the multiple IDE interface driver, as evolved from hd.c. |
| 14 | * It supports up to MAX_HWIFS IDE interfaces, on one or more IRQs |
| 15 | * (usually 14 & 15). |
| 16 | * There can be up to two drives per interface, as per the ATA-2 spec. |
| 17 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | * ... |
| 19 | * |
| 20 | * From hd.c: |
| 21 | * | |
| 22 | * | It traverses the request-list, using interrupts to jump between functions. |
| 23 | * | As nearly all functions can be called within interrupts, we may not sleep. |
| 24 | * | Special care is recommended. Have Fun! |
| 25 | * | |
| 26 | * | modified by Drew Eckhardt to check nr of hd's from the CMOS. |
| 27 | * | |
| 28 | * | Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug |
| 29 | * | in the early extended-partition checks and added DM partitions. |
| 30 | * | |
| 31 | * | Early work on error handling by Mika Liljeberg (liljeber@cs.Helsinki.FI). |
| 32 | * | |
| 33 | * | IRQ-unmask, drive-id, multiple-mode, support for ">16 heads", |
| 34 | * | and general streamlining by Mark Lord (mlord@pobox.com). |
| 35 | * |
| 36 | * October, 1994 -- Complete line-by-line overhaul for linux 1.1.x, by: |
| 37 | * |
| 38 | * Mark Lord (mlord@pobox.com) (IDE Perf.Pkg) |
| 39 | * Delman Lee (delman@ieee.org) ("Mr. atdisk2") |
| 40 | * Scott Snyder (snyder@fnald0.fnal.gov) (ATAPI IDE cd-rom) |
| 41 | * |
| 42 | * This was a rewrite of just about everything from hd.c, though some original |
| 43 | * code is still sprinkled about. Think of it as a major evolution, with |
| 44 | * inspiration from lots of linux users, esp. hamish@zot.apana.org.au |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | */ |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include <linux/module.h> |
| 48 | #include <linux/types.h> |
| 49 | #include <linux/string.h> |
| 50 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include <linux/interrupt.h> |
| 52 | #include <linux/major.h> |
| 53 | #include <linux/errno.h> |
| 54 | #include <linux/genhd.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | #include <linux/slab.h> |
| 56 | #include <linux/init.h> |
| 57 | #include <linux/pci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #include <linux/ide.h> |
Bartlomiej Zolnierkiewicz | 3ceca72 | 2008-10-10 22:39:27 +0200 | [diff] [blame] | 59 | #include <linux/hdreg.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | #include <linux/completion.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #include <linux/device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Bartlomiej Zolnierkiewicz | f74c914 | 2008-04-18 00:46:23 +0200 | [diff] [blame] | 63 | struct class *ide_port_class; |
| 64 | |
Bartlomiej Zolnierkiewicz | 08da591 | 2008-07-24 22:53:15 +0200 | [diff] [blame] | 65 | /** |
| 66 | * ide_device_get - get an additional reference to a ide_drive_t |
| 67 | * @drive: device to get a reference to |
| 68 | * |
| 69 | * Gets a reference to the ide_drive_t and increments the use count of the |
| 70 | * underlying LLDD module. |
| 71 | */ |
| 72 | int ide_device_get(ide_drive_t *drive) |
| 73 | { |
| 74 | struct device *host_dev; |
| 75 | struct module *module; |
| 76 | |
| 77 | if (!get_device(&drive->gendev)) |
| 78 | return -ENXIO; |
| 79 | |
| 80 | host_dev = drive->hwif->host->dev[0]; |
| 81 | module = host_dev ? host_dev->driver->owner : NULL; |
| 82 | |
| 83 | if (module && !try_module_get(module)) { |
| 84 | put_device(&drive->gendev); |
| 85 | return -ENXIO; |
| 86 | } |
| 87 | |
| 88 | return 0; |
| 89 | } |
| 90 | EXPORT_SYMBOL_GPL(ide_device_get); |
| 91 | |
| 92 | /** |
| 93 | * ide_device_put - release a reference to a ide_drive_t |
| 94 | * @drive: device to release a reference on |
| 95 | * |
| 96 | * Release a reference to the ide_drive_t and decrements the use count of |
| 97 | * the underlying LLDD module. |
| 98 | */ |
| 99 | void ide_device_put(ide_drive_t *drive) |
| 100 | { |
| 101 | #ifdef CONFIG_MODULE_UNLOAD |
| 102 | struct device *host_dev = drive->hwif->host->dev[0]; |
| 103 | struct module *module = host_dev ? host_dev->driver->owner : NULL; |
| 104 | |
| 105 | if (module) |
| 106 | module_put(module); |
| 107 | #endif |
| 108 | put_device(&drive->gendev); |
| 109 | } |
| 110 | EXPORT_SYMBOL_GPL(ide_device_put); |
| 111 | |
Bartlomiej Zolnierkiewicz | 8604aff | 2005-05-26 14:55:34 +0200 | [diff] [blame] | 112 | static int ide_bus_match(struct device *dev, struct device_driver *drv) |
| 113 | { |
| 114 | return 1; |
| 115 | } |
| 116 | |
Kay Sievers | 7eff2e7 | 2007-08-14 15:15:12 +0200 | [diff] [blame] | 117 | static int ide_uevent(struct device *dev, struct kobj_uevent_env *env) |
Kay Sievers | 263756e | 2005-12-12 18:03:44 +0100 | [diff] [blame] | 118 | { |
| 119 | ide_drive_t *drive = to_ide_device(dev); |
Kay Sievers | 263756e | 2005-12-12 18:03:44 +0100 | [diff] [blame] | 120 | |
Bartlomiej Zolnierkiewicz | ebdab07 | 2009-01-02 16:12:48 +0100 | [diff] [blame] | 121 | add_uevent_var(env, "MEDIA=%s", ide_media_string(drive)); |
Kay Sievers | 7eff2e7 | 2007-08-14 15:15:12 +0200 | [diff] [blame] | 122 | add_uevent_var(env, "DRIVENAME=%s", drive->name); |
Bartlomiej Zolnierkiewicz | ebdab07 | 2009-01-02 16:12:48 +0100 | [diff] [blame] | 123 | add_uevent_var(env, "MODALIAS=ide:m-%s", ide_media_string(drive)); |
Kay Sievers | 263756e | 2005-12-12 18:03:44 +0100 | [diff] [blame] | 124 | return 0; |
| 125 | } |
| 126 | |
Russell King | 4031bbe | 2006-01-06 11:41:00 +0000 | [diff] [blame] | 127 | static int generic_ide_probe(struct device *dev) |
| 128 | { |
| 129 | ide_drive_t *drive = to_ide_device(dev); |
Bartlomiej Zolnierkiewicz | 7f3c868 | 2009-01-06 17:20:53 +0100 | [diff] [blame] | 130 | struct ide_driver *drv = to_ide_driver(dev->driver); |
Russell King | 4031bbe | 2006-01-06 11:41:00 +0000 | [diff] [blame] | 131 | |
| 132 | return drv->probe ? drv->probe(drive) : -ENODEV; |
| 133 | } |
| 134 | |
| 135 | static int generic_ide_remove(struct device *dev) |
| 136 | { |
| 137 | ide_drive_t *drive = to_ide_device(dev); |
Bartlomiej Zolnierkiewicz | 7f3c868 | 2009-01-06 17:20:53 +0100 | [diff] [blame] | 138 | struct ide_driver *drv = to_ide_driver(dev->driver); |
Russell King | 4031bbe | 2006-01-06 11:41:00 +0000 | [diff] [blame] | 139 | |
| 140 | if (drv->remove) |
| 141 | drv->remove(drive); |
| 142 | |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | static void generic_ide_shutdown(struct device *dev) |
| 147 | { |
| 148 | ide_drive_t *drive = to_ide_device(dev); |
Bartlomiej Zolnierkiewicz | 7f3c868 | 2009-01-06 17:20:53 +0100 | [diff] [blame] | 149 | struct ide_driver *drv = to_ide_driver(dev->driver); |
Russell King | 4031bbe | 2006-01-06 11:41:00 +0000 | [diff] [blame] | 150 | |
| 151 | if (dev->driver && drv->shutdown) |
| 152 | drv->shutdown(drive); |
| 153 | } |
| 154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | struct bus_type ide_bus_type = { |
| 156 | .name = "ide", |
Bartlomiej Zolnierkiewicz | 8604aff | 2005-05-26 14:55:34 +0200 | [diff] [blame] | 157 | .match = ide_bus_match, |
Kay Sievers | 263756e | 2005-12-12 18:03:44 +0100 | [diff] [blame] | 158 | .uevent = ide_uevent, |
Russell King | 4031bbe | 2006-01-06 11:41:00 +0000 | [diff] [blame] | 159 | .probe = generic_ide_probe, |
| 160 | .remove = generic_ide_remove, |
| 161 | .shutdown = generic_ide_shutdown, |
Kay Sievers | 263756e | 2005-12-12 18:03:44 +0100 | [diff] [blame] | 162 | .dev_attrs = ide_dev_attrs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | .suspend = generic_ide_suspend, |
| 164 | .resume = generic_ide_resume, |
| 165 | }; |
| 166 | |
Bartlomiej Zolnierkiewicz | 8604aff | 2005-05-26 14:55:34 +0200 | [diff] [blame] | 167 | EXPORT_SYMBOL_GPL(ide_bus_type); |
| 168 | |
Bartlomiej Zolnierkiewicz | ebae41a | 2008-04-27 15:38:29 +0200 | [diff] [blame] | 169 | int ide_vlb_clk; |
| 170 | EXPORT_SYMBOL_GPL(ide_vlb_clk); |
| 171 | |
| 172 | module_param_named(vlb_clock, ide_vlb_clk, int, 0); |
| 173 | MODULE_PARM_DESC(vlb_clock, "VLB clock frequency (in MHz)"); |
| 174 | |
| 175 | int ide_pci_clk; |
| 176 | EXPORT_SYMBOL_GPL(ide_pci_clk); |
| 177 | |
| 178 | module_param_named(pci_clock, ide_pci_clk, int, 0); |
| 179 | MODULE_PARM_DESC(pci_clock, "PCI bus clock frequency (in MHz)"); |
| 180 | |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 181 | static int ide_set_dev_param_mask(const char *s, struct kernel_param *kp) |
| 182 | { |
| 183 | int a, b, i, j = 1; |
| 184 | unsigned int *dev_param_mask = (unsigned int *)kp->arg; |
| 185 | |
David Fries | 0af80c0 | 2009-02-25 20:28:21 +0100 | [diff] [blame] | 186 | /* controller . device (0 or 1) [ : 1 (set) | 0 (clear) ] */ |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 187 | if (sscanf(s, "%d.%d:%d", &a, &b, &j) != 3 && |
| 188 | sscanf(s, "%d.%d", &a, &b) != 2) |
| 189 | return -EINVAL; |
| 190 | |
| 191 | i = a * MAX_DRIVES + b; |
| 192 | |
| 193 | if (i >= MAX_HWIFS * MAX_DRIVES || j < 0 || j > 1) |
| 194 | return -EINVAL; |
| 195 | |
| 196 | if (j) |
| 197 | *dev_param_mask |= (1 << i); |
| 198 | else |
David Fries | 0af80c0 | 2009-02-25 20:28:21 +0100 | [diff] [blame] | 199 | *dev_param_mask &= ~(1 << i); |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 200 | |
| 201 | return 0; |
| 202 | } |
| 203 | |
| 204 | static unsigned int ide_nodma; |
| 205 | |
| 206 | module_param_call(nodma, ide_set_dev_param_mask, NULL, &ide_nodma, 0); |
| 207 | MODULE_PARM_DESC(nodma, "disallow DMA for a device"); |
| 208 | |
| 209 | static unsigned int ide_noflush; |
| 210 | |
| 211 | module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0); |
| 212 | MODULE_PARM_DESC(noflush, "disable flush requests for a device"); |
| 213 | |
Bartlomiej Zolnierkiewicz | 075affc | 2009-06-07 13:52:52 +0200 | [diff] [blame] | 214 | static unsigned int ide_nohpa; |
| 215 | |
| 216 | module_param_call(nohpa, ide_set_dev_param_mask, NULL, &ide_nohpa, 0); |
| 217 | MODULE_PARM_DESC(nohpa, "disable Host Protected Area for a device"); |
| 218 | |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 219 | static unsigned int ide_noprobe; |
| 220 | |
| 221 | module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0); |
| 222 | MODULE_PARM_DESC(noprobe, "skip probing for a device"); |
| 223 | |
| 224 | static unsigned int ide_nowerr; |
| 225 | |
| 226 | module_param_call(nowerr, ide_set_dev_param_mask, NULL, &ide_nowerr, 0); |
Bartlomiej Zolnierkiewicz | 3a7d248 | 2008-10-10 22:39:21 +0200 | [diff] [blame] | 227 | MODULE_PARM_DESC(nowerr, "ignore the ATA_DF bit for a device"); |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 228 | |
Bartlomiej Zolnierkiewicz | 4706a7e | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 229 | static unsigned int ide_cdroms; |
| 230 | |
| 231 | module_param_call(cdrom, ide_set_dev_param_mask, NULL, &ide_cdroms, 0); |
| 232 | MODULE_PARM_DESC(cdrom, "force device as a CD-ROM"); |
| 233 | |
| 234 | struct chs_geom { |
| 235 | unsigned int cyl; |
| 236 | u8 head; |
| 237 | u8 sect; |
| 238 | }; |
| 239 | |
| 240 | static unsigned int ide_disks; |
| 241 | static struct chs_geom ide_disks_chs[MAX_HWIFS * MAX_DRIVES]; |
| 242 | |
| 243 | static int ide_set_disk_chs(const char *str, struct kernel_param *kp) |
| 244 | { |
| 245 | int a, b, c = 0, h = 0, s = 0, i, j = 1; |
| 246 | |
David Fries | 0af80c0 | 2009-02-25 20:28:21 +0100 | [diff] [blame] | 247 | /* controller . device (0 or 1) : Cylinders , Heads , Sectors */ |
| 248 | /* controller . device (0 or 1) : 1 (use CHS) | 0 (ignore CHS) */ |
Bartlomiej Zolnierkiewicz | 4706a7e | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 249 | if (sscanf(str, "%d.%d:%d,%d,%d", &a, &b, &c, &h, &s) != 5 && |
| 250 | sscanf(str, "%d.%d:%d", &a, &b, &j) != 3) |
| 251 | return -EINVAL; |
| 252 | |
| 253 | i = a * MAX_DRIVES + b; |
| 254 | |
| 255 | if (i >= MAX_HWIFS * MAX_DRIVES || j < 0 || j > 1) |
| 256 | return -EINVAL; |
| 257 | |
| 258 | if (c > INT_MAX || h > 255 || s > 255) |
| 259 | return -EINVAL; |
| 260 | |
| 261 | if (j) |
| 262 | ide_disks |= (1 << i); |
| 263 | else |
David Fries | 0af80c0 | 2009-02-25 20:28:21 +0100 | [diff] [blame] | 264 | ide_disks &= ~(1 << i); |
Bartlomiej Zolnierkiewicz | 4706a7e | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 265 | |
| 266 | ide_disks_chs[i].cyl = c; |
| 267 | ide_disks_chs[i].head = h; |
| 268 | ide_disks_chs[i].sect = s; |
| 269 | |
| 270 | return 0; |
| 271 | } |
| 272 | |
| 273 | module_param_call(chs, ide_set_disk_chs, NULL, NULL, 0); |
| 274 | MODULE_PARM_DESC(chs, "force device as a disk (using CHS)"); |
| 275 | |
Bartlomiej Zolnierkiewicz | 123995b | 2008-10-13 21:39:40 +0200 | [diff] [blame] | 276 | static void ide_dev_apply_params(ide_drive_t *drive, u8 unit) |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 277 | { |
Bartlomiej Zolnierkiewicz | 123995b | 2008-10-13 21:39:40 +0200 | [diff] [blame] | 278 | int i = drive->hwif->index * MAX_DRIVES + unit; |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 279 | |
| 280 | if (ide_nodma & (1 << i)) { |
| 281 | printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name); |
Bartlomiej Zolnierkiewicz | 97100fc | 2008-10-13 21:39:36 +0200 | [diff] [blame] | 282 | drive->dev_flags |= IDE_DFLAG_NODMA; |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 283 | } |
| 284 | if (ide_noflush & (1 << i)) { |
| 285 | printk(KERN_INFO "ide: disabling flush requests for %s\n", |
| 286 | drive->name); |
Bartlomiej Zolnierkiewicz | 97100fc | 2008-10-13 21:39:36 +0200 | [diff] [blame] | 287 | drive->dev_flags |= IDE_DFLAG_NOFLUSH; |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 288 | } |
Bartlomiej Zolnierkiewicz | 075affc | 2009-06-07 13:52:52 +0200 | [diff] [blame] | 289 | if (ide_nohpa & (1 << i)) { |
| 290 | printk(KERN_INFO "ide: disabling Host Protected Area for %s\n", |
| 291 | drive->name); |
| 292 | drive->dev_flags |= IDE_DFLAG_NOHPA; |
| 293 | } |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 294 | if (ide_noprobe & (1 << i)) { |
| 295 | printk(KERN_INFO "ide: skipping probe for %s\n", drive->name); |
Bartlomiej Zolnierkiewicz | 97100fc | 2008-10-13 21:39:36 +0200 | [diff] [blame] | 296 | drive->dev_flags |= IDE_DFLAG_NOPROBE; |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 297 | } |
| 298 | if (ide_nowerr & (1 << i)) { |
Bartlomiej Zolnierkiewicz | 3a7d248 | 2008-10-10 22:39:21 +0200 | [diff] [blame] | 299 | printk(KERN_INFO "ide: ignoring the ATA_DF bit for %s\n", |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 300 | drive->name); |
| 301 | drive->bad_wstat = BAD_R_STAT; |
| 302 | } |
Bartlomiej Zolnierkiewicz | 4706a7e | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 303 | if (ide_cdroms & (1 << i)) { |
| 304 | printk(KERN_INFO "ide: forcing %s as a CD-ROM\n", drive->name); |
Bartlomiej Zolnierkiewicz | 97100fc | 2008-10-13 21:39:36 +0200 | [diff] [blame] | 305 | drive->dev_flags |= IDE_DFLAG_PRESENT; |
Bartlomiej Zolnierkiewicz | 4706a7e | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 306 | drive->media = ide_cdrom; |
| 307 | /* an ATAPI device ignores DRDY */ |
| 308 | drive->ready_stat = 0; |
| 309 | } |
| 310 | if (ide_disks & (1 << i)) { |
| 311 | drive->cyl = drive->bios_cyl = ide_disks_chs[i].cyl; |
| 312 | drive->head = drive->bios_head = ide_disks_chs[i].head; |
| 313 | drive->sect = drive->bios_sect = ide_disks_chs[i].sect; |
Bartlomiej Zolnierkiewicz | 97100fc | 2008-10-13 21:39:36 +0200 | [diff] [blame] | 314 | |
Bartlomiej Zolnierkiewicz | 4706a7e | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 315 | printk(KERN_INFO "ide: forcing %s as a disk (%d/%d/%d)\n", |
| 316 | drive->name, |
| 317 | drive->cyl, drive->head, drive->sect); |
Bartlomiej Zolnierkiewicz | 97100fc | 2008-10-13 21:39:36 +0200 | [diff] [blame] | 318 | |
| 319 | drive->dev_flags |= IDE_DFLAG_FORCED_GEOM | IDE_DFLAG_PRESENT; |
Bartlomiej Zolnierkiewicz | 4706a7e | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 320 | drive->media = ide_disk; |
Bartlomiej Zolnierkiewicz | 3a7d248 | 2008-10-10 22:39:21 +0200 | [diff] [blame] | 321 | drive->ready_stat = ATA_DRDY; |
Bartlomiej Zolnierkiewicz | 4706a7e | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 322 | } |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 323 | } |
| 324 | |
Bartlomiej Zolnierkiewicz | 9fd91d9 | 2008-04-27 15:38:23 +0200 | [diff] [blame] | 325 | static unsigned int ide_ignore_cable; |
| 326 | |
| 327 | static int ide_set_ignore_cable(const char *s, struct kernel_param *kp) |
| 328 | { |
| 329 | int i, j = 1; |
| 330 | |
David Fries | 0af80c0 | 2009-02-25 20:28:21 +0100 | [diff] [blame] | 331 | /* controller (ignore) */ |
| 332 | /* controller : 1 (ignore) | 0 (use) */ |
Bartlomiej Zolnierkiewicz | 9fd91d9 | 2008-04-27 15:38:23 +0200 | [diff] [blame] | 333 | if (sscanf(s, "%d:%d", &i, &j) != 2 && sscanf(s, "%d", &i) != 1) |
| 334 | return -EINVAL; |
| 335 | |
| 336 | if (i >= MAX_HWIFS || j < 0 || j > 1) |
| 337 | return -EINVAL; |
| 338 | |
| 339 | if (j) |
| 340 | ide_ignore_cable |= (1 << i); |
| 341 | else |
David Fries | 0af80c0 | 2009-02-25 20:28:21 +0100 | [diff] [blame] | 342 | ide_ignore_cable &= ~(1 << i); |
Bartlomiej Zolnierkiewicz | 9fd91d9 | 2008-04-27 15:38:23 +0200 | [diff] [blame] | 343 | |
| 344 | return 0; |
| 345 | } |
| 346 | |
| 347 | module_param_call(ignore_cable, ide_set_ignore_cable, NULL, NULL, 0); |
| 348 | MODULE_PARM_DESC(ignore_cable, "ignore cable detection"); |
| 349 | |
| 350 | void ide_port_apply_params(ide_hwif_t *hwif) |
| 351 | { |
Bartlomiej Zolnierkiewicz | 2bd24a1 | 2009-01-06 17:20:56 +0100 | [diff] [blame] | 352 | ide_drive_t *drive; |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 353 | int i; |
| 354 | |
Bartlomiej Zolnierkiewicz | 9fd91d9 | 2008-04-27 15:38:23 +0200 | [diff] [blame] | 355 | if (ide_ignore_cable & (1 << hwif->index)) { |
| 356 | printk(KERN_INFO "ide: ignoring cable detection for %s\n", |
| 357 | hwif->name); |
| 358 | hwif->cbl = ATA_CBL_PATA40_SHORT; |
| 359 | } |
Bartlomiej Zolnierkiewicz | 6e87543 | 2008-04-27 15:38:30 +0200 | [diff] [blame] | 360 | |
Bartlomiej Zolnierkiewicz | 2bd24a1 | 2009-01-06 17:20:56 +0100 | [diff] [blame] | 361 | ide_port_for_each_dev(i, drive, hwif) |
| 362 | ide_dev_apply_params(drive, i); |
Bartlomiej Zolnierkiewicz | 9fd91d9 | 2008-04-27 15:38:23 +0200 | [diff] [blame] | 363 | } |
| 364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | /* |
| 366 | * This is gets invoked once during initialization, to set *everything* up |
| 367 | */ |
| 368 | static int __init ide_init(void) |
| 369 | { |
Randy Dunlap | 349ae23 | 2006-10-03 01:14:23 -0700 | [diff] [blame] | 370 | int ret; |
| 371 | |
Bartlomiej Zolnierkiewicz | eba8ff9 | 2008-02-11 00:32:13 +0100 | [diff] [blame] | 372 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n"); |
Bartlomiej Zolnierkiewicz | 537f06c | 2008-02-01 23:09:35 +0100 | [diff] [blame] | 373 | |
Randy Dunlap | 349ae23 | 2006-10-03 01:14:23 -0700 | [diff] [blame] | 374 | ret = bus_register(&ide_bus_type); |
| 375 | if (ret < 0) { |
| 376 | printk(KERN_WARNING "IDE: bus_register error: %d\n", ret); |
| 377 | return ret; |
| 378 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
Bartlomiej Zolnierkiewicz | f74c914 | 2008-04-18 00:46:23 +0200 | [diff] [blame] | 380 | ide_port_class = class_create(THIS_MODULE, "ide_port"); |
| 381 | if (IS_ERR(ide_port_class)) { |
| 382 | ret = PTR_ERR(ide_port_class); |
| 383 | goto out_port_class; |
| 384 | } |
Bartlomiej Zolnierkiewicz | f74c914 | 2008-04-18 00:46:23 +0200 | [diff] [blame] | 385 | |
Bartlomiej Zolnierkiewicz | 8b803bd | 2009-03-24 23:22:41 +0100 | [diff] [blame] | 386 | ide_acpi_init(); |
| 387 | |
Bartlomiej Zolnierkiewicz | 5cbf79c | 2007-05-10 00:01:11 +0200 | [diff] [blame] | 388 | proc_ide_create(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | return 0; |
Bartlomiej Zolnierkiewicz | f74c914 | 2008-04-18 00:46:23 +0200 | [diff] [blame] | 391 | |
| 392 | out_port_class: |
| 393 | bus_unregister(&ide_bus_type); |
| 394 | |
| 395 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | } |
| 397 | |
Bartlomiej Zolnierkiewicz | 931ee0d | 2008-07-15 21:21:47 +0200 | [diff] [blame] | 398 | static void __exit ide_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | proc_ide_destroy(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | |
Bartlomiej Zolnierkiewicz | f74c914 | 2008-04-18 00:46:23 +0200 | [diff] [blame] | 402 | class_destroy(ide_port_class); |
| 403 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | bus_unregister(&ide_bus_type); |
| 405 | } |
| 406 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | module_init(ide_init); |
Bartlomiej Zolnierkiewicz | 931ee0d | 2008-07-15 21:21:47 +0200 | [diff] [blame] | 408 | module_exit(ide_exit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | |
Bartlomiej Zolnierkiewicz | 931ee0d | 2008-07-15 21:21:47 +0200 | [diff] [blame] | 410 | MODULE_LICENSE("GPL"); |