Commit | Line | Data |
---|---|---|
ffd4f6f0 BZ |
1 | |
2 | #include <linux/kernel.h> | |
3 | #include <linux/init.h> | |
4 | #include <linux/module.h> | |
5 | #include <linux/ide.h> | |
6 | ||
2c4be251 BZ |
7 | #define DRV_NAME "ide-4drives" |
8 | ||
ef87f8d0 | 9 | static int probe_4drives; |
ffd4f6f0 BZ |
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 | ||
e6d95bd1 | 14 | static void ide_4drives_init_dev(ide_drive_t *drive) |
f333f92b | 15 | { |
e6d95bd1 BZ |
16 | if (drive->hwif->channel) |
17 | drive->select.all ^= 0x20; | |
f333f92b BZ |
18 | } |
19 | ||
20 | static const struct ide_port_ops ide_4drives_port_ops = { | |
e6d95bd1 | 21 | .init_dev = ide_4drives_init_dev, |
f333f92b BZ |
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 | ||
ffd4f6f0 BZ |
29 | static int __init ide_4drives_init(void) |
30 | { | |
31 | ide_hwif_t *hwif, *mate; | |
2c4be251 | 32 | unsigned long base = 0x1f0, ctl = 0x3f6; |
c97c6aca | 33 | hw_regs_t hw, *hws[] = { NULL, NULL, NULL, NULL }; |
e277f91f | 34 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
ffd4f6f0 BZ |
35 | |
36 | if (probe_4drives == 0) | |
37 | return -ENODEV; | |
38 | ||
2c4be251 BZ |
39 | if (!request_region(base, 8, DRV_NAME)) { |
40 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | |
41 | DRV_NAME, base, base + 7); | |
42 | return -EBUSY; | |
43 | } | |
44 | ||
45 | if (!request_region(ctl, 1, DRV_NAME)) { | |
46 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | |
47 | DRV_NAME, ctl); | |
48 | release_region(base, 8); | |
49 | return -EBUSY; | |
50 | } | |
51 | ||
dfd87842 | 52 | memset(&hw, 0, sizeof(hw)); |
ffd4f6f0 | 53 | |
2c4be251 | 54 | ide_std_init_ports(&hw, base, ctl); |
dfd87842 BZ |
55 | hw.irq = 14; |
56 | hw.chipset = ide_4drives; | |
ffd4f6f0 | 57 | |
e277f91f BZ |
58 | hwif = ide_find_port(); |
59 | if (hwif) { | |
c97c6aca BZ |
60 | hwif->chipset = ide_4drives; |
61 | ||
62 | hws[0] = &hw; | |
e277f91f BZ |
63 | idx[0] = hwif->index; |
64 | } | |
65 | ||
66 | mate = ide_find_port(); | |
67 | if (mate) { | |
c97c6aca | 68 | hws[1] = &hw; |
e277f91f | 69 | idx[1] = mate->index; |
e277f91f | 70 | } |
ffd4f6f0 | 71 | |
c97c6aca | 72 | ide_device_add(idx, &ide_4drives_port_info, hws); |
ffd4f6f0 BZ |
73 | |
74 | return 0; | |
75 | } | |
76 | ||
77 | module_init(ide_4drives_init); | |
78 | ||
79 | MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); | |
80 | MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support"); | |
81 | MODULE_LICENSE("GPL"); |