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 | |
Bartlomiej Zolnierkiewicz | ef87f8d | 2008-04-27 15:38:24 +0200 | [diff] [blame] | 9 | static 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 | |
Bartlomiej Zolnierkiewicz | f333f92 | 2008-07-16 20:33:40 +0200 | [diff] [blame^] | 14 | static void ide_4drives_port_init_devs(ide_hwif_t *hwif) |
| 15 | { |
| 16 | if (hwif->channel) { |
| 17 | hwif->drives[0].select.all ^= 0x20; |
| 18 | hwif->drives[1].select.all ^= 0x20; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | static const struct ide_port_ops ide_4drives_port_ops = { |
| 23 | .port_init_devs = ide_4drives_port_init_devs, |
| 24 | }; |
| 25 | |
| 26 | static const struct ide_port_info ide_4drives_port_info = { |
| 27 | .port_ops = &ide_4drives_port_ops, |
| 28 | .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA, |
| 29 | }; |
| 30 | |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 31 | static int __init ide_4drives_init(void) |
| 32 | { |
| 33 | ide_hwif_t *hwif, *mate; |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame] | 34 | unsigned long base = 0x1f0, ctl = 0x3f6; |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 35 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
Bartlomiej Zolnierkiewicz | dfd8784 | 2008-04-18 00:46:35 +0200 | [diff] [blame] | 36 | hw_regs_t hw; |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 37 | |
| 38 | if (probe_4drives == 0) |
| 39 | return -ENODEV; |
| 40 | |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame] | 41 | if (!request_region(base, 8, DRV_NAME)) { |
| 42 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", |
| 43 | DRV_NAME, base, base + 7); |
| 44 | return -EBUSY; |
| 45 | } |
| 46 | |
| 47 | if (!request_region(ctl, 1, DRV_NAME)) { |
| 48 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", |
| 49 | DRV_NAME, ctl); |
| 50 | release_region(base, 8); |
| 51 | return -EBUSY; |
| 52 | } |
| 53 | |
Bartlomiej Zolnierkiewicz | dfd8784 | 2008-04-18 00:46:35 +0200 | [diff] [blame] | 54 | memset(&hw, 0, sizeof(hw)); |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 55 | |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame] | 56 | ide_std_init_ports(&hw, base, ctl); |
Bartlomiej Zolnierkiewicz | dfd8784 | 2008-04-18 00:46:35 +0200 | [diff] [blame] | 57 | hw.irq = 14; |
| 58 | hw.chipset = ide_4drives; |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 59 | |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 60 | hwif = ide_find_port(); |
| 61 | if (hwif) { |
| 62 | ide_init_port_hw(hwif, &hw); |
| 63 | idx[0] = hwif->index; |
| 64 | } |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 65 | |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 66 | mate = ide_find_port(); |
| 67 | if (mate) { |
| 68 | ide_init_port_hw(mate, &hw); |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 69 | idx[1] = mate->index; |
Bartlomiej Zolnierkiewicz | e277f91 | 2008-04-26 17:36:36 +0200 | [diff] [blame] | 70 | } |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 71 | |
Bartlomiej Zolnierkiewicz | f333f92 | 2008-07-16 20:33:40 +0200 | [diff] [blame^] | 72 | ide_device_add(idx, &ide_4drives_port_info); |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 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"); |