blob: 6310dc50e3c509ae6abf5fe3b06495b1e0a7b704 [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)
17 drive->select.all ^= 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,
26 .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA,
27};
28
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020029static int __init ide_4drives_init(void)
30{
31 ide_hwif_t *hwif, *mate;
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +020032 unsigned long base = 0x1f0, ctl = 0x3f6;
Bartlomiej Zolnierkiewiczc97c6ac2008-07-23 19:55:50 +020033 hw_regs_t hw, *hws[] = { NULL, NULL, NULL, NULL };
Bartlomiej Zolnierkiewicze277f912008-04-26 17:36:36 +020034 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020035
36 if (probe_4drives == 0)
37 return -ENODEV;
38
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +020039 if (!request_region(base, 8, DRV_NAME)) {
40 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
41 DRV_NAME, base, base + 7);
42 return -EBUSY;
43 }
44
45 if (!request_region(ctl, 1, DRV_NAME)) {
46 printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
47 DRV_NAME, ctl);
48 release_region(base, 8);
49 return -EBUSY;
50 }
51
Bartlomiej Zolnierkiewiczdfd87842008-04-18 00:46:35 +020052 memset(&hw, 0, sizeof(hw));
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020053
Bartlomiej Zolnierkiewicz2c4be252008-04-26 22:25:18 +020054 ide_std_init_ports(&hw, base, ctl);
Bartlomiej Zolnierkiewiczdfd87842008-04-18 00:46:35 +020055 hw.irq = 14;
56 hw.chipset = ide_4drives;
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020057
Bartlomiej Zolnierkiewicze277f912008-04-26 17:36:36 +020058 hwif = ide_find_port();
59 if (hwif) {
Bartlomiej Zolnierkiewiczc97c6ac2008-07-23 19:55:50 +020060 hwif->chipset = ide_4drives;
61
62 hws[0] = &hw;
Bartlomiej Zolnierkiewicze277f912008-04-26 17:36:36 +020063 idx[0] = hwif->index;
64 }
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020065
Bartlomiej Zolnierkiewicze277f912008-04-26 17:36:36 +020066 mate = ide_find_port();
67 if (mate) {
Bartlomiej Zolnierkiewiczc97c6ac2008-07-23 19:55:50 +020068 hws[1] = &hw;
Bartlomiej Zolnierkiewicze277f912008-04-26 17:36:36 +020069 idx[1] = mate->index;
Bartlomiej Zolnierkiewicze277f912008-04-26 17:36:36 +020070 }
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020071
Bartlomiej Zolnierkiewiczc97c6ac2008-07-23 19:55:50 +020072 ide_device_add(idx, &ide_4drives_port_info, hws);
Bartlomiej Zolnierkiewiczffd4f6f2008-04-18 00:46:34 +020073
74 return 0;
75}
76
77module_init(ide_4drives_init);
78
79MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
80MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
81MODULE_LICENSE("GPL");