blob: 06c6215e0cbe333ead72df51330131feb9ad3eeb [file] [log] [blame]
Thomas Gleixner09c434b2019-05-19 13:08:20 +01001// SPDX-License-Identifier: GPL-2.0-only
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +02002
3#include <linux/kernel.h>
4#include <linux/init.h>
5#include <linux/module.h>
6#include <linux/ide.h>
7
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +02008#define DRV_NAME "ide-4drives"
9
Rusty Russell90ab5ee2012-01-13 09:32:20 +103010static bool probe_4drives;
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020011
12module_param_named(probe, probe_4drives, bool, 0);
13MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
14
Bartlomiej Zolnierkiewicze6d95bd2008-07-16 20:33:42 +020015static void ide_4drives_init_dev(ide_drive_t *drive)
Bartlomiej Zolnierkiewiczf333f922008-07-16 20:33:40 +020016{
Bartlomiej Zolnierkiewicze6d95bd2008-07-16 20:33:42 +020017 if (drive->hwif->channel)
Bartlomiej Zolnierkiewicz7f612f22008-10-13 21:39:40 +020018 drive->select ^= 0x20;
Bartlomiej Zolnierkiewiczf333f922008-07-16 20:33:40 +020019}
20
21static const struct ide_port_ops ide_4drives_port_ops = {
Bartlomiej Zolnierkiewicze6d95bd2008-07-16 20:33:42 +020022 .init_dev = ide_4drives_init_dev,
Bartlomiej Zolnierkiewiczf333f922008-07-16 20:33:40 +020023};
24
25static const struct ide_port_info ide_4drives_port_info = {
26 .port_ops = &ide_4drives_port_ops,
Bartlomiej Zolnierkiewiczc094ea02009-03-27 12:46:28 +010027 .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA |
28 IDE_HFLAG_4DRIVES,
Bartlomiej Zolnierkiewicz29e52cf2009-05-17 19:12:22 +020029 .chipset = ide_4drives,
Bartlomiej Zolnierkiewiczf333f922008-07-16 20:33:40 +020030};
31
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020032static int __init ide_4drives_init(void)
33{
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +020034 unsigned long base = 0x1f0, ctl = 0x3f6;
Bartlomiej Zolnierkiewicz9f36d312009-05-17 19:12:25 +020035 struct ide_hw hw, *hws[] = { &hw, &hw };
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020036
37 if (probe_4drives == 0)
38 return -ENODEV;
39
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +020040 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 Zolnierkiewiczdfd87842008-04-18 00:46:35 +020053 memset(&hw, 0, sizeof(hw));
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020054
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +020055 ide_std_init_ports(&hw, base, ctl);
Bartlomiej Zolnierkiewiczdfd87842008-04-18 00:46:35 +020056 hw.irq = 14;
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020057
Bartlomiej Zolnierkiewiczdca39832009-05-17 19:12:24 +020058 return ide_host_add(&ide_4drives_port_info, hws, 2, NULL);
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020059}
60
61module_init(ide_4drives_init);
62
63MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
64MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
65MODULE_LICENSE("GPL");