aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-generic.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-04-05 02:14:15 -0400
committerLen Brown <len.brown@intel.com>2009-04-05 02:14:15 -0400
commit478c6a43fcbc6c11609f8cee7c7b57223907754f (patch)
treea7f7952099da60d33032aed6de9c0c56c9f8779e /drivers/ide/ide-generic.c
parent8a3f257c704e02aee9869decd069a806b45be3f1 (diff)
parent6bb597507f9839b13498781e481f5458aea33620 (diff)
Merge branch 'linus' into release
Conflicts: arch/x86/kernel/cpu/cpufreq/longhaul.c Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/ide/ide-generic.c')
-rw-r--r--drivers/ide/ide-generic.c88
1 files changed, 17 insertions, 71 deletions
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c
index 81a5282ce1eb..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
@@ -32,62 +27,15 @@ static int probe_mask;
32module_param(probe_mask, int, 0); 27module_param(probe_mask, int, 0);
33MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports"); 28MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports");
34 29
35static ssize_t store_add(struct class *cls, const char *buf, size_t n) 30static const struct ide_port_info ide_generic_port_info = {
36{ 31 .host_flags = IDE_HFLAG_NO_DMA,
37 unsigned int base, ctl;
38 int irq, rc;
39 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
40
41 if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3)
42 return -EINVAL;
43
44 memset(&hw, 0, sizeof(hw));
45 ide_std_init_ports(&hw, base, ctl);
46 hw.irq = irq;
47 hw.chipset = ide_generic;
48
49 rc = ide_host_add(NULL, hws, NULL);
50 if (rc)
51 return rc;
52
53 return n;
54};
55
56static struct class_attribute ide_generic_class_attrs[] = {
57 __ATTR(add, S_IWUSR, NULL, store_add),
58 __ATTR_NULL
59}; 32};
60 33
61static void ide_generic_class_release(struct class *cls) 34#ifdef CONFIG_ARM
62{ 35static const u16 legacy_bases[] = { 0x1f0 };
63 kfree(cls); 36static const int legacy_irqs[] = { IRQ_HARDDISK };
64} 37#elif defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) || \
65 38 defined(CONFIG_PLAT_OPSPUT)
66static int __init ide_generic_sysfs_init(void)
67{
68 struct class *cls;
69 int rc;
70
71 cls = kzalloc(sizeof(*cls), GFP_KERNEL);
72 if (!cls)
73 return -ENOMEM;
74
75 cls->name = DRV_NAME;
76 cls->owner = THIS_MODULE;
77 cls->class_release = ide_generic_class_release;
78 cls->class_attrs = ide_generic_class_attrs;
79
80 rc = class_register(cls);
81 if (rc) {
82 kfree(cls);
83 return rc;
84 }
85
86 return 0;
87}
88
89#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) \
90 || defined(CONFIG_PLAT_OPSPUT)
91static const u16 legacy_bases[] = { 0x1f0 }; 39static const u16 legacy_bases[] = { 0x1f0 };
92static const int legacy_irqs[] = { PLD_IRQ_CFIREQ }; 40static const int legacy_irqs[] = { PLD_IRQ_CFIREQ };
93#elif defined(CONFIG_PLAT_MAPPI3) 41#elif defined(CONFIG_PLAT_MAPPI3)
@@ -103,11 +51,11 @@ static const int legacy_irqs[] = { 14, 15, 11, 10, 8, 12 };
103 51
104static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary) 52static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary)
105{ 53{
54#ifdef CONFIG_PCI
106 struct pci_dev *p = NULL; 55 struct pci_dev *p = NULL;
107 u16 val; 56 u16 val;
108 57
109 for_each_pci_dev(p) { 58 for_each_pci_dev(p) {
110
111 if (pci_resource_start(p, 0) == 0x1f0) 59 if (pci_resource_start(p, 0) == 0x1f0)
112 *primary = 1; 60 *primary = 1;
113 if (pci_resource_start(p, 2) == 0x170) 61 if (pci_resource_start(p, 2) == 0x170)
@@ -122,7 +70,6 @@ static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary)
122 /* Intel MPIIX - PIO ATA on non PCI side of bridge */ 70 /* Intel MPIIX - PIO ATA on non PCI side of bridge */
123 if (p->vendor == PCI_VENDOR_ID_INTEL && 71 if (p->vendor == PCI_VENDOR_ID_INTEL &&
124 p->device == PCI_DEVICE_ID_INTEL_82371MX) { 72 p->device == PCI_DEVICE_ID_INTEL_82371MX) {
125
126 pci_read_config_word(p, 0x6C, &val); 73 pci_read_config_word(p, 0x6C, &val);
127 if (val & 0x8000) { 74 if (val & 0x8000) {
128 /* ATA port enabled */ 75 /* ATA port enabled */
@@ -133,6 +80,7 @@ static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary)
133 } 80 }
134 } 81 }
135 } 82 }
83#endif
136} 84}
137 85
138static int __init ide_generic_init(void) 86static int __init ide_generic_init(void)
@@ -164,6 +112,7 @@ static int __init ide_generic_init(void)
164 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " 112 printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX "
165 "not free.\n", 113 "not free.\n",
166 DRV_NAME, io_addr, io_addr + 7); 114 DRV_NAME, io_addr, io_addr + 7);
115 rc = -EBUSY;
167 continue; 116 continue;
168 } 117 }
169 118
@@ -172,6 +121,7 @@ static int __init ide_generic_init(void)
172 "not free.\n", 121 "not free.\n",
173 DRV_NAME, io_addr + 0x206); 122 DRV_NAME, io_addr + 0x206);
174 release_region(io_addr, 8); 123 release_region(io_addr, 8);
124 rc = -EBUSY;
175 continue; 125 continue;
176 } 126 }
177 127
@@ -184,7 +134,7 @@ static int __init ide_generic_init(void)
184#endif 134#endif
185 hw.chipset = ide_generic; 135 hw.chipset = ide_generic;
186 136
187 rc = ide_host_add(NULL, hws, NULL); 137 rc = ide_host_add(&ide_generic_port_info, hws, NULL);
188 if (rc) { 138 if (rc) {
189 release_region(io_addr + 0x206, 1); 139 release_region(io_addr + 0x206, 1);
190 release_region(io_addr, 8); 140 release_region(io_addr, 8);
@@ -192,10 +142,6 @@ static int __init ide_generic_init(void)
192 } 142 }
193 } 143 }
194 144
195 if (ide_generic_sysfs_init())
196 printk(KERN_ERR DRV_NAME ": failed to create ide_generic "
197 "class\n");
198
199 return rc; 145 return rc;
200} 146}
201 147