Thomas Gleixner | 09c434b | 2019-05-19 13:08:20 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 2 | |
| 3 | #include <linux/kernel.h> |
| 4 | #include <linux/init.h> |
| 5 | #include <linux/module.h> |
| 6 | #include <linux/ide.h> |
| 7 | |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame] | 8 | #define DRV_NAME "ide-4drives" |
| 9 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 10 | static bool probe_4drives; |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 11 | |
| 12 | module_param_named(probe, probe_4drives, bool, 0); |
| 13 | MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); |
| 14 | |
Bartlomiej Zolnierkiewicz | e6d95bd | 2008-07-16 20:33:42 +0200 | [diff] [blame] | 15 | static void ide_4drives_init_dev(ide_drive_t *drive) |
Bartlomiej Zolnierkiewicz | f333f92 | 2008-07-16 20:33:40 +0200 | [diff] [blame] | 16 | { |
Bartlomiej Zolnierkiewicz | e6d95bd | 2008-07-16 20:33:42 +0200 | [diff] [blame] | 17 | if (drive->hwif->channel) |
Bartlomiej Zolnierkiewicz | 7f612f2 | 2008-10-13 21:39:40 +0200 | [diff] [blame] | 18 | drive->select ^= 0x20; |
Bartlomiej Zolnierkiewicz | f333f92 | 2008-07-16 20:33:40 +0200 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | static const struct ide_port_ops ide_4drives_port_ops = { |
Bartlomiej Zolnierkiewicz | e6d95bd | 2008-07-16 20:33:42 +0200 | [diff] [blame] | 22 | .init_dev = ide_4drives_init_dev, |
Bartlomiej Zolnierkiewicz | f333f92 | 2008-07-16 20:33:40 +0200 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | static const struct ide_port_info ide_4drives_port_info = { |
| 26 | .port_ops = &ide_4drives_port_ops, |
Bartlomiej Zolnierkiewicz | c094ea0 | 2009-03-27 12:46:28 +0100 | [diff] [blame] | 27 | .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA | |
| 28 | IDE_HFLAG_4DRIVES, |
Bartlomiej Zolnierkiewicz | 29e52cf | 2009-05-17 19:12:22 +0200 | [diff] [blame] | 29 | .chipset = ide_4drives, |
Bartlomiej Zolnierkiewicz | f333f92 | 2008-07-16 20:33:40 +0200 | [diff] [blame] | 30 | }; |
| 31 | |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 32 | static int __init ide_4drives_init(void) |
| 33 | { |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame] | 34 | unsigned long base = 0x1f0, ctl = 0x3f6; |
Bartlomiej Zolnierkiewicz | 9f36d31 | 2009-05-17 19:12:25 +0200 | [diff] [blame] | 35 | struct ide_hw hw, *hws[] = { &hw, &hw }; |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 36 | |
| 37 | if (probe_4drives == 0) |
| 38 | return -ENODEV; |
| 39 | |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame] | 40 | if (!request_region(base, 8, DRV_NAME)) { |
| 41 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", |
| 42 | DRV_NAME, base, base + 7); |
| 43 | return -EBUSY; |
| 44 | } |
| 45 | |
| 46 | if (!request_region(ctl, 1, DRV_NAME)) { |
| 47 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", |
| 48 | DRV_NAME, ctl); |
| 49 | release_region(base, 8); |
| 50 | return -EBUSY; |
| 51 | } |
| 52 | |
Bartlomiej Zolnierkiewicz | dfd8784 | 2008-04-18 00:46:35 +0200 | [diff] [blame] | 53 | memset(&hw, 0, sizeof(hw)); |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 54 | |
Bartlomiej Zolnierkiewicz | 2c4be25 | 2008-04-26 22:25:18 +0200 | [diff] [blame] | 55 | ide_std_init_ports(&hw, base, ctl); |
Bartlomiej Zolnierkiewicz | dfd8784 | 2008-04-18 00:46:35 +0200 | [diff] [blame] | 56 | hw.irq = 14; |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 57 | |
Bartlomiej Zolnierkiewicz | dca3983 | 2009-05-17 19:12:24 +0200 | [diff] [blame] | 58 | return ide_host_add(&ide_4drives_port_info, hws, 2, NULL); |
Bartlomiej Zolnierkiewicz | ffd4f6f | 2008-04-18 00:46:34 +0200 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | module_init(ide_4drives_init); |
| 62 | |
| 63 | MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); |
| 64 | MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support"); |
| 65 | MODULE_LICENSE("GPL"); |