diff options
Diffstat (limited to 'drivers/ide/ide-generic.c')
-rw-r--r-- | drivers/ide/ide-generic.c | 86 |
1 files changed, 14 insertions, 72 deletions
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 9d03e8211536..7812ca0be13b 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
@@ -1,27 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * generic/default IDE host driver | 2 | * generic/default IDE host driver |
3 | * | 3 | * |
4 | * Copyright (C) 2004, 2008 Bartlomiej Zolnierkiewicz | 4 | * Copyright (C) 2004, 2008-2009 Bartlomiej Zolnierkiewicz |
5 | * This code was split off from ide.c. See it for original copyrights. | 5 | * This code was split off from ide.c. See it for original copyrights. |
6 | * | 6 | * |
7 | * May be copied or modified under the terms of the GNU General Public License. | 7 | * May be copied or modified under the terms of the GNU General Public License. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* | ||
11 | * For special cases new interfaces may be added using sysfs, i.e. | ||
12 | * | ||
13 | * echo -n "0x168:0x36e:10" > /sys/class/ide_generic/add | ||
14 | * | ||
15 | * will add an interface using I/O ports 0x168-0x16f/0x36e and IRQ 10. | ||
16 | */ | ||
17 | |||
18 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
19 | #include <linux/init.h> | 11 | #include <linux/init.h> |
20 | #include <linux/module.h> | 12 | #include <linux/module.h> |
21 | #include <linux/ide.h> | 13 | #include <linux/ide.h> |
22 | #include <linux/pci_ids.h> | 14 | #include <linux/pci_ids.h> |
23 | 15 | ||
24 | /* FIXME: convert m32r to use ide_platform host driver */ | 16 | /* FIXME: convert arm and m32r to use ide_platform host driver */ |
17 | #ifdef CONFIG_ARM | ||
18 | #include <asm/irq.h> | ||
19 | #endif | ||
25 | #ifdef CONFIG_M32R | 20 | #ifdef CONFIG_M32R |
26 | #include <asm/m32r.h> | 21 | #include <asm/m32r.h> |
27 | #endif | 22 | #endif |
@@ -36,62 +31,11 @@ static const struct ide_port_info ide_generic_port_info = { | |||
36 | .host_flags = IDE_HFLAG_NO_DMA, | 31 | .host_flags = IDE_HFLAG_NO_DMA, |
37 | }; | 32 | }; |
38 | 33 | ||
39 | static ssize_t store_add(struct class *cls, const char *buf, size_t n) | 34 | #ifdef CONFIG_ARM |
40 | { | 35 | static const u16 legacy_bases[] = { 0x1f0 }; |
41 | unsigned int base, ctl; | 36 | static const int legacy_irqs[] = { IRQ_HARDDISK }; |
42 | int irq, rc; | 37 | #elif defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) || \ |
43 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 38 | defined(CONFIG_PLAT_OPSPUT) |
44 | |||
45 | if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3) | ||
46 | return -EINVAL; | ||
47 | |||
48 | memset(&hw, 0, sizeof(hw)); | ||
49 | ide_std_init_ports(&hw, base, ctl); | ||
50 | hw.irq = irq; | ||
51 | hw.chipset = ide_generic; | ||
52 | |||
53 | rc = ide_host_add(&ide_generic_port_info, hws, NULL); | ||
54 | if (rc) | ||
55 | return rc; | ||
56 | |||
57 | return n; | ||
58 | }; | ||
59 | |||
60 | static struct class_attribute ide_generic_class_attrs[] = { | ||
61 | __ATTR(add, S_IWUSR, NULL, store_add), | ||
62 | __ATTR_NULL | ||
63 | }; | ||
64 | |||
65 | static void ide_generic_class_release(struct class *cls) | ||
66 | { | ||
67 | kfree(cls); | ||
68 | } | ||
69 | |||
70 | static int __init ide_generic_sysfs_init(void) | ||
71 | { | ||
72 | struct class *cls; | ||
73 | int rc; | ||
74 | |||
75 | cls = kzalloc(sizeof(*cls), GFP_KERNEL); | ||
76 | if (!cls) | ||
77 | return -ENOMEM; | ||
78 | |||
79 | cls->name = DRV_NAME; | ||
80 | cls->owner = THIS_MODULE; | ||
81 | cls->class_release = ide_generic_class_release; | ||
82 | cls->class_attrs = ide_generic_class_attrs; | ||
83 | |||
84 | rc = class_register(cls); | ||
85 | if (rc) { | ||
86 | kfree(cls); | ||
87 | return rc; | ||
88 | } | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | #if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) \ | ||
94 | || defined(CONFIG_PLAT_OPSPUT) | ||
95 | static const u16 legacy_bases[] = { 0x1f0 }; | 39 | static const u16 legacy_bases[] = { 0x1f0 }; |
96 | static const int legacy_irqs[] = { PLD_IRQ_CFIREQ }; | 40 | static const int legacy_irqs[] = { PLD_IRQ_CFIREQ }; |
97 | #elif defined(CONFIG_PLAT_MAPPI3) | 41 | #elif defined(CONFIG_PLAT_MAPPI3) |
@@ -107,11 +51,11 @@ static const int legacy_irqs[] = { 14, 15, 11, 10, 8, 12 }; | |||
107 | 51 | ||
108 | static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary) | 52 | static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary) |
109 | { | 53 | { |
54 | #ifdef CONFIG_PCI | ||
110 | struct pci_dev *p = NULL; | 55 | struct pci_dev *p = NULL; |
111 | u16 val; | 56 | u16 val; |
112 | 57 | ||
113 | for_each_pci_dev(p) { | 58 | for_each_pci_dev(p) { |
114 | |||
115 | if (pci_resource_start(p, 0) == 0x1f0) | 59 | if (pci_resource_start(p, 0) == 0x1f0) |
116 | *primary = 1; | 60 | *primary = 1; |
117 | if (pci_resource_start(p, 2) == 0x170) | 61 | if (pci_resource_start(p, 2) == 0x170) |
@@ -126,7 +70,6 @@ static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary) | |||
126 | /* Intel MPIIX - PIO ATA on non PCI side of bridge */ | 70 | /* Intel MPIIX - PIO ATA on non PCI side of bridge */ |
127 | if (p->vendor == PCI_VENDOR_ID_INTEL && | 71 | if (p->vendor == PCI_VENDOR_ID_INTEL && |
128 | p->device == PCI_DEVICE_ID_INTEL_82371MX) { | 72 | p->device == PCI_DEVICE_ID_INTEL_82371MX) { |
129 | |||
130 | pci_read_config_word(p, 0x6C, &val); | 73 | pci_read_config_word(p, 0x6C, &val); |
131 | if (val & 0x8000) { | 74 | if (val & 0x8000) { |
132 | /* ATA port enabled */ | 75 | /* ATA port enabled */ |
@@ -137,6 +80,7 @@ static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary) | |||
137 | } | 80 | } |
138 | } | 81 | } |
139 | } | 82 | } |
83 | #endif | ||
140 | } | 84 | } |
141 | 85 | ||
142 | static int __init ide_generic_init(void) | 86 | static int __init ide_generic_init(void) |
@@ -168,6 +112,7 @@ static int __init ide_generic_init(void) | |||
168 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " | 112 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " |
169 | "not free.\n", | 113 | "not free.\n", |
170 | DRV_NAME, io_addr, io_addr + 7); | 114 | DRV_NAME, io_addr, io_addr + 7); |
115 | rc = -EBUSY; | ||
171 | continue; | 116 | continue; |
172 | } | 117 | } |
173 | 118 | ||
@@ -176,6 +121,7 @@ static int __init ide_generic_init(void) | |||
176 | "not free.\n", | 121 | "not free.\n", |
177 | DRV_NAME, io_addr + 0x206); | 122 | DRV_NAME, io_addr + 0x206); |
178 | release_region(io_addr, 8); | 123 | release_region(io_addr, 8); |
124 | rc = -EBUSY; | ||
179 | continue; | 125 | continue; |
180 | } | 126 | } |
181 | 127 | ||
@@ -196,10 +142,6 @@ static int __init ide_generic_init(void) | |||
196 | } | 142 | } |
197 | } | 143 | } |
198 | 144 | ||
199 | if (ide_generic_sysfs_init()) | ||
200 | printk(KERN_ERR DRV_NAME ": failed to create ide_generic " | ||
201 | "class\n"); | ||
202 | |||
203 | return rc; | 145 | return rc; |
204 | } | 146 | } |
205 | 147 | ||