5935153ef2adf8e6dedd3c66c402e4f4d2b253ce
[sfrench/cifs-2.6.git] / drivers / ide / legacy / ide-4drives.c
1
2 #include <linux/kernel.h>
3 #include <linux/init.h>
4 #include <linux/module.h>
5 #include <linux/ide.h>
6
7 #define DRV_NAME "ide-4drives"
8
9 static int probe_4drives;
10
11 module_param_named(probe, probe_4drives, bool, 0);
12 MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
13
14 static void ide_4drives_init_dev(ide_drive_t *drive)
15 {
16         if (drive->hwif->channel)
17                 drive->select.all ^= 0x20;
18 }
19
20 static const struct ide_port_ops ide_4drives_port_ops = {
21         .init_dev               = ide_4drives_init_dev,
22 };
23
24 static const struct ide_port_info ide_4drives_port_info = {
25         .port_ops               = &ide_4drives_port_ops,
26         .host_flags             = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA,
27 };
28
29 static int __init ide_4drives_init(void)
30 {
31         struct ide_host *host;
32         unsigned long base = 0x1f0, ctl = 0x3f6;
33         hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL };
34
35         if (probe_4drives == 0)
36                 return -ENODEV;
37
38         if (!request_region(base, 8, DRV_NAME)) {
39                 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
40                                 DRV_NAME, base, base + 7);
41                 return -EBUSY;
42         }
43
44         if (!request_region(ctl, 1, DRV_NAME)) {
45                 printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
46                                 DRV_NAME, ctl);
47                 release_region(base, 8);
48                 return -EBUSY;
49         }
50
51         memset(&hw, 0, sizeof(hw));
52
53         ide_std_init_ports(&hw, base, ctl);
54         hw.irq = 14;
55         hw.chipset = ide_4drives;
56
57         host = ide_host_alloc(&ide_4drives_port_info, hws);
58         if (host)
59                 ide_host_register(host, &ide_4drives_port_info, hws);
60
61         return 0;
62 }
63
64 module_init(ide_4drives_init);
65
66 MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
67 MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
68 MODULE_LICENSE("GPL");