]>
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 | ||
14 | static int __init ide_4drives_init(void) | |
15 | { | |
16 | ide_hwif_t *hwif, *mate; | |
2c4be251 | 17 | unsigned long base = 0x1f0, ctl = 0x3f6; |
e277f91f | 18 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
dfd87842 | 19 | hw_regs_t hw; |
ffd4f6f0 BZ |
20 | |
21 | if (probe_4drives == 0) | |
22 | return -ENODEV; | |
23 | ||
2c4be251 BZ |
24 | if (!request_region(base, 8, DRV_NAME)) { |
25 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | |
26 | DRV_NAME, base, base + 7); | |
27 | return -EBUSY; | |
28 | } | |
29 | ||
30 | if (!request_region(ctl, 1, DRV_NAME)) { | |
31 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | |
32 | DRV_NAME, ctl); | |
33 | release_region(base, 8); | |
34 | return -EBUSY; | |
35 | } | |
36 | ||
dfd87842 | 37 | memset(&hw, 0, sizeof(hw)); |
ffd4f6f0 | 38 | |
2c4be251 | 39 | ide_std_init_ports(&hw, base, ctl); |
dfd87842 BZ |
40 | hw.irq = 14; |
41 | hw.chipset = ide_4drives; | |
ffd4f6f0 | 42 | |
e277f91f BZ |
43 | hwif = ide_find_port(); |
44 | if (hwif) { | |
45 | ide_init_port_hw(hwif, &hw); | |
46 | idx[0] = hwif->index; | |
47 | } | |
48 | ||
49 | mate = ide_find_port(); | |
50 | if (mate) { | |
51 | ide_init_port_hw(mate, &hw); | |
52 | mate->drives[0].select.all ^= 0x20; | |
53 | mate->drives[1].select.all ^= 0x20; | |
54 | idx[1] = mate->index; | |
55 | ||
56 | if (hwif) { | |
57 | hwif->mate = mate; | |
58 | mate->mate = hwif; | |
59 | hwif->serialized = mate->serialized = 1; | |
60 | } | |
61 | } | |
ffd4f6f0 BZ |
62 | |
63 | ide_device_add(idx, NULL); | |
64 | ||
65 | return 0; | |
66 | } | |
67 | ||
68 | module_init(ide_4drives_init); | |
69 | ||
70 | MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); | |
71 | MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support"); | |
72 | MODULE_LICENSE("GPL"); |