aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-legacy.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-12-29 14:27:37 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-12-29 14:27:37 -0500
commit7f92b11c1cc0e865fc64f3148eda87fff74920e1 (patch)
tree6cc52b4abfab5c66efb6fd679a0a915f6dd6108b /drivers/ide/ide-legacy.c
parente2984c628c924442132304ae662da433f41c05c9 (diff)
ide: move legacy ISA/VLB ports handling to ide-legacy.c (v2)
* Move legacy ISA/VLB ports handling from ide-probe.c to ide-legacy.c. * Add CONFIG_IDE_LEGACY config option to be selected by host drivers needing ide-legacy.c. v2: Fix CONFIG_IDE_LEGACY not being defined in Kconfig. (from Takashi Iwai <tiwai@suse.de>) There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-legacy.c')
-rw-r--r--drivers/ide/ide-legacy.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/drivers/ide/ide-legacy.c b/drivers/ide/ide-legacy.c
new file mode 100644
index 000000000000..8c5dcbf22547
--- /dev/null
+++ b/drivers/ide/ide-legacy.c
@@ -0,0 +1,58 @@
1#include <linux/kernel.h>
2#include <linux/ide.h>
3
4static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw,
5 u8 port_no, const struct ide_port_info *d,
6 unsigned long config)
7{
8 unsigned long base, ctl;
9 int irq;
10
11 if (port_no == 0) {
12 base = 0x1f0;
13 ctl = 0x3f6;
14 irq = 14;
15 } else {
16 base = 0x170;
17 ctl = 0x376;
18 irq = 15;
19 }
20
21 if (!request_region(base, 8, d->name)) {
22 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
23 d->name, base, base + 7);
24 return;
25 }
26
27 if (!request_region(ctl, 1, d->name)) {
28 printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
29 d->name, ctl);
30 release_region(base, 8);
31 return;
32 }
33
34 ide_std_init_ports(hw, base, ctl);
35 hw->irq = irq;
36 hw->chipset = d->chipset;
37 hw->config = config;
38
39 hws[port_no] = hw;
40}
41
42int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
43{
44 hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
45
46 memset(&hw, 0, sizeof(hw));
47
48 if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0)
49 ide_legacy_init_one(hws, &hw[0], 0, d, config);
50 ide_legacy_init_one(hws, &hw[1], 1, d, config);
51
52 if (hws[0] == NULL && hws[1] == NULL &&
53 (d->host_flags & IDE_HFLAG_SINGLE))
54 return -ENOENT;
55
56 return ide_host_add(d, hws, NULL);
57}
58EXPORT_SYMBOL_GPL(ide_legacy_device_add);