blob: 78aca75a2c487ece474e08bcb220c5542caa8b4b [file] [log] [blame]
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +02001
2#include <linux/kernel.h>
3#include <linux/init.h>
4#include <linux/module.h>
5#include <linux/ide.h>
6
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +02007#define DRV_NAME "ide-4drives"
8
Bartlomiej Zolnierkiewiczef87f8d2008-04-27 15:38:24 +02009static int probe_4drives;
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020010
11module_param_named(probe, probe_4drives, bool, 0);
12MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
13
Bartlomiej Zolnierkiewicze6d95bd2008-07-16 20:33:42 +020014static void ide_4drives_init_dev(ide_drive_t *drive)
Bartlomiej Zolnierkiewiczf333f922008-07-16 20:33:40 +020015{
Bartlomiej Zolnierkiewicze6d95bd2008-07-16 20:33:42 +020016 if (drive->hwif->channel)
Bartlomiej Zolnierkiewicz7f612f22008-10-13 21:39:40 +020017 drive->select ^= 0x20;
Bartlomiej Zolnierkiewiczf333f922008-07-16 20:33:40 +020018}
19
20static const struct ide_port_ops ide_4drives_port_ops = {
Bartlomiej Zolnierkiewicze6d95bd2008-07-16 20:33:42 +020021 .init_dev = ide_4drives_init_dev,
Bartlomiej Zolnierkiewiczf333f922008-07-16 20:33:40 +020022};
23
24static const struct ide_port_info ide_4drives_port_info = {
25 .port_ops = &ide_4drives_port_ops,
Bartlomiej Zolnierkiewiczc094ea02009-03-27 12:46:28 +010026 .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA |
27 IDE_HFLAG_4DRIVES,
Bartlomiej Zolnierkiewiczf333f922008-07-16 20:33:40 +020028};
29
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020030static int __init ide_4drives_init(void)
31{
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +020032 unsigned long base = 0x1f0, ctl = 0x3f6;
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020033 hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL };
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020034
35 if (probe_4drives == 0)
36 return -ENODEV;
37
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +020038 if (!request_region(base, 8, DRV_NAME)) {
39 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
40 DRV_NAME, base, base + 7);
41 return -EBUSY;
42 }
43
44 if (!request_region(ctl, 1, DRV_NAME)) {
45 printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
46 DRV_NAME, ctl);
47 release_region(base, 8);
48 return -EBUSY;
49 }
50
Bartlomiej Zolnierkiewiczdfd87842008-04-18 00:46:35 +020051 memset(&hw, 0, sizeof(hw));
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020052
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +020053 ide_std_init_ports(&hw, base, ctl);
Bartlomiej Zolnierkiewiczdfd87842008-04-18 00:46:35 +020054 hw.irq = 14;
55 hw.chipset = ide_4drives;
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020056
Bartlomiej Zolnierkiewicz6f904d02008-07-23 19:55:57 +020057 return ide_host_add(&ide_4drives_port_info, hws, NULL);
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020058}
59
60module_init(ide_4drives_init);
61
62MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
63MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
64MODULE_LICENSE("GPL");