Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 1 | |
| 2 | #include <linux/kernel.h> |
| 3 | #include <linux/init.h> |
| 4 | #include <linux/module.h> |
| 5 | #include <linux/ide.h> |
| 6 | |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame^] | 7 | #define DRV_NAME "ide-4drives" |
| 8 | |
Paolo Ciarrocchi | f94e008 | 2008-04-26 17:36:40 +0200 | [diff] [blame] | 9 | int probe_4drives; |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 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; |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame^] | 17 | unsigned long base = 0x1f0, ctl = 0x3f6; |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 18 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
Bartlomiej Zolnierkiewicz | dfd8784 | 2008-04-18 00:46:35 +0200 | [diff] [blame] | 19 | hw_regs_t hw; |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 20 | |
| 21 | if (probe_4drives == 0) |
| 22 | return -ENODEV; |
| 23 | |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame^] | 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 | |
Bartlomiej Zolnierkiewicz | dfd8784 | 2008-04-18 00:46:35 +0200 | [diff] [blame] | 37 | memset(&hw, 0, sizeof(hw)); |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 38 | |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame^] | 39 | ide_std_init_ports(&hw, base, ctl); |
Bartlomiej Zolnierkiewicz | dfd8784 | 2008-04-18 00:46:35 +0200 | [diff] [blame] | 40 | hw.irq = 14; |
| 41 | hw.chipset = ide_4drives; |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 42 | |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 43 | hwif = ide_find_port(); |
| 44 | if (hwif) { |
| 45 | ide_init_port_hw(hwif, &hw); |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame^] | 46 | hwif->mmio = 1; |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 47 | idx[0] = hwif->index; |
| 48 | } |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 49 | |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 50 | mate = ide_find_port(); |
| 51 | if (mate) { |
| 52 | ide_init_port_hw(mate, &hw); |
| 53 | mate->drives[0].select.all ^= 0x20; |
| 54 | mate->drives[1].select.all ^= 0x20; |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame^] | 55 | mate->mmio = 1; |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 56 | idx[1] = mate->index; |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 57 | |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 58 | if (hwif) { |
| 59 | hwif->mate = mate; |
| 60 | mate->mate = hwif; |
| 61 | hwif->serialized = mate->serialized = 1; |
| 62 | } |
| 63 | } |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 64 | |
| 65 | ide_device_add(idx, NULL); |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | module_init(ide_4drives_init); |
| 71 | |
| 72 | MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); |
| 73 | MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support"); |
| 74 | MODULE_LICENSE("GPL"); |