blob: 1e8062f6dbfcaf23d484ab1880e222d2e99f7194 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * EISA bus support functions for sysfs.
3 *
4 * (C) 2002, 2003 Marc Zyngier <maz@wild-wind.fr.eu.org>
5 *
6 * This code is released under the GPL version 2.
7 */
8
9#include <linux/kernel.h>
10#include <linux/device.h>
11#include <linux/eisa.h>
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/init.h>
15#include <linux/slab.h>
16#include <linux/ioport.h>
17#include <asm/io.h>
18
19#define SLOT_ADDRESS(r,n) (r->bus_base_addr + (0x1000 * n))
20
21#define EISA_DEVINFO(i,s) { .id = { .sig = i }, .name = s }
22
23struct eisa_device_info {
24 struct eisa_device_id id;
Kay Sieversca52a492008-05-02 06:02:41 +020025 char name[50];
Linus Torvalds1da177e2005-04-16 15:20:36 -070026};
27
28#ifdef CONFIG_EISA_NAMES
29static struct eisa_device_info __initdata eisa_table[] = {
30#include "devlist.h"
31};
32#define EISA_INFOS (sizeof (eisa_table) / (sizeof (struct eisa_device_info)))
33#endif
34
35#define EISA_MAX_FORCED_DEV 16
36
37static int enable_dev[EISA_MAX_FORCED_DEV];
Al Viro64a6f952007-10-14 19:35:30 +010038static unsigned int enable_dev_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039static int disable_dev[EISA_MAX_FORCED_DEV];
Al Viro64a6f952007-10-14 19:35:30 +010040static unsigned int disable_dev_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -080042static int is_forced_dev(int *forced_tab,
43 int forced_count,
44 struct eisa_root_device *root,
45 struct eisa_device *edev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070046{
47 int i, x;
48
49 for (i = 0; i < forced_count; i++) {
50 x = (root->bus_nr << 8) | edev->slot;
51 if (forced_tab[i] == x)
52 return 1;
53 }
54
55 return 0;
56}
57
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -080058static void __init eisa_name_device(struct eisa_device *edev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059{
60#ifdef CONFIG_EISA_NAMES
61 int i;
62 for (i = 0; i < EISA_INFOS; i++) {
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -080063 if (!strcmp(edev->id.sig, eisa_table[i].id.sig)) {
64 strlcpy(edev->pretty_name,
65 eisa_table[i].name,
66 sizeof(edev->pretty_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 return;
68 }
69 }
70
71 /* No name was found */
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -080072 sprintf(edev->pretty_name, "EISA device %.7s", edev->id.sig);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#endif
74}
75
76static char __init *decode_eisa_sig(unsigned long addr)
77{
Ladislav Michl91809d22018-01-17 10:44:06 +010078 static char sig_str[EISA_SIG_LEN];
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 u8 sig[4];
Ladislav Michl91809d22018-01-17 10:44:06 +010080 u16 rev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 int i;
82
83 for (i = 0; i < 4; i++) {
84#ifdef CONFIG_EISA_VLB_PRIMING
85 /*
86 * This ugly stuff is used to wake up VL-bus cards
87 * (AHA-284x is the only known example), so we can
88 * read the EISA id.
89 *
90 * Thankfully, this only exists on x86...
91 */
92 outb(0x80 + i, addr);
93#endif
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -080094 sig[i] = inb(addr + i);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96 if (!i && (sig[0] & 0x80))
97 return NULL;
98 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Ladislav Michl91809d22018-01-17 10:44:06 +0100100 sig_str[0] = ((sig[0] >> 2) & 0x1f) + ('A' - 1);
101 sig_str[1] = (((sig[0] & 3) << 3) | (sig[1] >> 5)) + ('A' - 1);
102 sig_str[2] = (sig[1] & 0x1f) + ('A' - 1);
103 rev = (sig[2] << 8) | sig[3];
104 sprintf(sig_str + 3, "%04X", rev);
105
106 return sig_str;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107}
108
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800109static int eisa_bus_match(struct device *dev, struct device_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800111 struct eisa_device *edev = to_eisa_device(dev);
112 struct eisa_driver *edrv = to_eisa_driver(drv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 const struct eisa_device_id *eids = edrv->id_table;
114
115 if (!eids)
116 return 0;
117
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800118 while (strlen(eids->sig)) {
119 if (!strcmp(eids->sig, edev->id.sig) &&
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 edev->state & EISA_CONFIG_ENABLED) {
121 edev->id.driver_data = eids->driver_data;
122 return 1;
123 }
124
125 eids++;
126 }
127
128 return 0;
129}
130
Kay Sievers7eff2e72007-08-14 15:15:12 +0200131static int eisa_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
Michael Tokarev07563c72006-09-27 01:50:56 -0700132{
133 struct eisa_device *edev = to_eisa_device(dev);
Michael Tokarev07563c72006-09-27 01:50:56 -0700134
Kay Sievers7eff2e72007-08-14 15:15:12 +0200135 add_uevent_var(env, "MODALIAS=" EISA_DEVICE_MODALIAS_FMT, edev->id.sig);
Michael Tokarev07563c72006-09-27 01:50:56 -0700136 return 0;
137}
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139struct bus_type eisa_bus_type = {
140 .name = "eisa",
141 .match = eisa_bus_match,
Michael Tokarev07563c72006-09-27 01:50:56 -0700142 .uevent = eisa_bus_uevent,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143};
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800144EXPORT_SYMBOL(eisa_bus_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800146int eisa_driver_register(struct eisa_driver *edrv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 edrv->driver.bus = &eisa_bus_type;
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800149 return driver_register(&edrv->driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150}
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800151EXPORT_SYMBOL(eisa_driver_register);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800153void eisa_driver_unregister(struct eisa_driver *edrv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154{
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800155 driver_unregister(&edrv->driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156}
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800157EXPORT_SYMBOL(eisa_driver_unregister);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800159static ssize_t eisa_show_sig(struct device *dev, struct device_attribute *attr,
160 char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161{
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800162 struct eisa_device *edev = to_eisa_device(dev);
163 return sprintf(buf, "%s\n", edev->id.sig);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164}
165
166static DEVICE_ATTR(signature, S_IRUGO, eisa_show_sig, NULL);
167
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800168static ssize_t eisa_show_state(struct device *dev,
169 struct device_attribute *attr,
170 char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171{
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800172 struct eisa_device *edev = to_eisa_device(dev);
173 return sprintf(buf, "%d\n", edev->state & EISA_CONFIG_ENABLED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174}
175
176static DEVICE_ATTR(enabled, S_IRUGO, eisa_show_state, NULL);
177
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800178static ssize_t eisa_show_modalias(struct device *dev,
179 struct device_attribute *attr,
180 char *buf)
Michael Tokarev07563c72006-09-27 01:50:56 -0700181{
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800182 struct eisa_device *edev = to_eisa_device(dev);
183 return sprintf(buf, EISA_DEVICE_MODALIAS_FMT "\n", edev->id.sig);
Michael Tokarev07563c72006-09-27 01:50:56 -0700184}
185
186static DEVICE_ATTR(modalias, S_IRUGO, eisa_show_modalias, NULL);
187
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800188static int __init eisa_init_device(struct eisa_root_device *root,
189 struct eisa_device *edev,
190 int slot)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191{
192 char *sig;
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800193 unsigned long sig_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 int i;
195
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800196 sig_addr = SLOT_ADDRESS(root, slot) + EISA_VENDOR_ID_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800198 sig = decode_eisa_sig(sig_addr);
199 if (!sig)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 return -1; /* No EISA device here */
Ladislav Michl91809d22018-01-17 10:44:06 +0100201
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800202 memcpy(edev->id.sig, sig, EISA_SIG_LEN);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 edev->slot = slot;
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800204 edev->state = inb(SLOT_ADDRESS(root, slot) + EISA_CONFIG_OFFSET)
205 & EISA_CONFIG_ENABLED;
206 edev->base_addr = SLOT_ADDRESS(root, slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 edev->dma_mask = root->dma_mask; /* Default DMA mask */
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800208 eisa_name_device(edev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 edev->dev.parent = root->dev;
210 edev->dev.bus = &eisa_bus_type;
211 edev->dev.dma_mask = &edev->dma_mask;
212 edev->dev.coherent_dma_mask = edev->dma_mask;
Kay Sieverse537b242009-03-24 16:38:22 -0700213 dev_set_name(&edev->dev, "%02X:%02X", root->bus_nr, slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 for (i = 0; i < EISA_MAX_RESOURCES; i++) {
216#ifdef CONFIG_EISA_NAMES
217 edev->res[i].name = edev->pretty_name;
218#else
219 edev->res[i].name = edev->id.sig;
220#endif
221 }
222
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800223 if (is_forced_dev(enable_dev, enable_dev_count, root, edev))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 edev->state = EISA_CONFIG_ENABLED | EISA_CONFIG_FORCED;
Ladislav Michl91809d22018-01-17 10:44:06 +0100225
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800226 if (is_forced_dev(disable_dev, disable_dev_count, root, edev))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 edev->state = EISA_CONFIG_FORCED;
228
229 return 0;
230}
231
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800232static int __init eisa_register_device(struct eisa_device *edev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233{
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800234 int rc = device_register(&edev->dev);
Levente Kurusa04df0082013-12-13 19:39:54 +0100235 if (rc) {
236 put_device(&edev->dev);
Jeff Garzik42ddfd62006-10-11 01:22:22 -0700237 return rc;
Levente Kurusa04df0082013-12-13 19:39:54 +0100238 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800240 rc = device_create_file(&edev->dev, &dev_attr_signature);
241 if (rc)
242 goto err_devreg;
243 rc = device_create_file(&edev->dev, &dev_attr_enabled);
244 if (rc)
245 goto err_sig;
246 rc = device_create_file(&edev->dev, &dev_attr_modalias);
247 if (rc)
248 goto err_enab;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
250 return 0;
Jeff Garzik42ddfd62006-10-11 01:22:22 -0700251
252err_enab:
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800253 device_remove_file(&edev->dev, &dev_attr_enabled);
Jeff Garzik42ddfd62006-10-11 01:22:22 -0700254err_sig:
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800255 device_remove_file(&edev->dev, &dev_attr_signature);
Jeff Garzik42ddfd62006-10-11 01:22:22 -0700256err_devreg:
257 device_unregister(&edev->dev);
258 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259}
260
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800261static int __init eisa_request_resources(struct eisa_root_device *root,
262 struct eisa_device *edev,
263 int slot)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264{
265 int i;
266
267 for (i = 0; i < EISA_MAX_RESOURCES; i++) {
268 /* Don't register resource for slot 0, since this is
269 * very likely to fail... :-( Instead, grab the EISA
270 * id, now we can display something in /proc/ioports.
271 */
272
273 /* Only one region for mainboard */
274 if (!slot && i > 0) {
275 edev->res[i].start = edev->res[i].end = 0;
276 continue;
277 }
Ladislav Michl91809d22018-01-17 10:44:06 +0100278
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 if (slot) {
Bjorn Helgaas765ee512014-01-17 14:57:29 -0700280 edev->res[i].name = NULL;
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800281 edev->res[i].start = SLOT_ADDRESS(root, slot)
282 + (i * 0x400);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 edev->res[i].end = edev->res[i].start + 0xff;
284 edev->res[i].flags = IORESOURCE_IO;
285 } else {
Bjorn Helgaas765ee512014-01-17 14:57:29 -0700286 edev->res[i].name = NULL;
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800287 edev->res[i].start = SLOT_ADDRESS(root, slot)
288 + EISA_VENDOR_ID_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 edev->res[i].end = edev->res[i].start + 3;
Bjorn Helgaas76668252013-04-15 14:33:56 -0600290 edev->res[i].flags = IORESOURCE_IO | IORESOURCE_BUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 }
292
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800293 if (request_resource(root->res, &edev->res[i]))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 goto failed;
295 }
296
297 return 0;
Ladislav Michl91809d22018-01-17 10:44:06 +0100298
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 failed:
300 while (--i >= 0)
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800301 release_resource(&edev->res[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 return -1;
304}
305
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800306static void __init eisa_release_resources(struct eisa_device *edev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307{
308 int i;
309
310 for (i = 0; i < EISA_MAX_RESOURCES; i++)
311 if (edev->res[i].start || edev->res[i].end)
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800312 release_resource(&edev->res[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313}
314
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800315static int __init eisa_probe(struct eisa_root_device *root)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316{
Ladislav Michl91809d22018-01-17 10:44:06 +0100317 int i, c;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 struct eisa_device *edev;
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600319 char *enabled_str;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600321 dev_info(root->dev, "Probing EISA bus %d\n", root->bus_nr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 /* First try to get hold of slot 0. If there is no device
324 * here, simply fail, unless root->force_probe is set. */
Ladislav Michl91809d22018-01-17 10:44:06 +0100325
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800326 edev = kzalloc(sizeof(*edev), GFP_KERNEL);
Ladislav Michl3ea98d42018-01-17 10:45:01 +0100327 if (!edev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 return -ENOMEM;
Ladislav Michl91809d22018-01-17 10:44:06 +0100329
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800330 if (eisa_request_resources(root, edev, 0)) {
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600331 dev_warn(root->dev,
Ladislav Michl91809d22018-01-17 10:44:06 +0100332 "EISA: Cannot allocate resource for mainboard\n");
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800333 kfree(edev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 if (!root->force_probe)
335 return -EBUSY;
336 goto force_probe;
337 }
338
Bjorn Helgaas765ee512014-01-17 14:57:29 -0700339 if (eisa_init_device(root, edev, 0)) {
340 eisa_release_resources(edev);
341 kfree(edev);
342 if (!root->force_probe)
343 return -ENODEV;
344 goto force_probe;
345 }
346
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600347 dev_info(&edev->dev, "EISA: Mainboard %s detected\n", edev->id.sig);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800349 if (eisa_register_device(edev)) {
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600350 dev_err(&edev->dev, "EISA: Failed to register %s\n",
Ladislav Michl91809d22018-01-17 10:44:06 +0100351 edev->id.sig);
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800352 eisa_release_resources(edev);
353 kfree(edev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 }
Ladislav Michl91809d22018-01-17 10:44:06 +0100355
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 force_probe:
Ladislav Michl91809d22018-01-17 10:44:06 +0100357
358 for (c = 0, i = 1; i <= root->slots; i++) {
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800359 edev = kzalloc(sizeof(*edev), GFP_KERNEL);
360 if (!edev) {
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600361 dev_err(root->dev, "EISA: Out of memory for slot %d\n",
362 i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 continue;
364 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
Bjorn Helgaas26abfee2013-04-15 14:34:02 -0600366 if (eisa_request_resources(root, edev, i)) {
367 dev_warn(root->dev,
Ladislav Michl91809d22018-01-17 10:44:06 +0100368 "Cannot allocate resource for EISA slot %d\n",
369 i);
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800370 kfree(edev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 continue;
372 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
Bjorn Helgaas765ee512014-01-17 14:57:29 -0700374 if (eisa_init_device(root, edev, i)) {
375 eisa_release_resources(edev);
376 kfree(edev);
377 continue;
378 }
379
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600380 if (edev->state == (EISA_CONFIG_ENABLED | EISA_CONFIG_FORCED))
381 enabled_str = " (forced enabled)";
382 else if (edev->state == EISA_CONFIG_FORCED)
383 enabled_str = " (forced disabled)";
384 else if (edev->state == 0)
385 enabled_str = " (disabled)";
386 else
387 enabled_str = "";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600389 dev_info(&edev->dev, "EISA: slot %d: %s detected%s\n", i,
390 edev->id.sig, enabled_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
392 c++;
393
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800394 if (eisa_register_device(edev)) {
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600395 dev_err(&edev->dev, "EISA: Failed to register %s\n",
Ladislav Michl91809d22018-01-17 10:44:06 +0100396 edev->id.sig);
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800397 eisa_release_resources(edev);
398 kfree(edev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 }
Ladislav Michl91809d22018-01-17 10:44:06 +0100400 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
Bjorn Helgaas4cf9f242013-04-15 14:33:42 -0600402 dev_info(root->dev, "EISA: Detected %d card%s\n", c, c == 1 ? "" : "s");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 return 0;
404}
405
406static struct resource eisa_root_res = {
407 .name = "EISA root resource",
408 .start = 0,
409 .end = 0xffffffff,
410 .flags = IORESOURCE_IO,
411};
412
413static int eisa_bus_count;
414
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800415int __init eisa_root_register(struct eisa_root_device *root)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416{
417 int err;
418
419 /* Use our own resources to check if this bus base address has
420 * been already registered. This prevents the virtual root
421 * device from registering after the real one has, for
422 * example... */
Ladislav Michl91809d22018-01-17 10:44:06 +0100423
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 root->eisa_root_res.name = eisa_root_res.name;
425 root->eisa_root_res.start = root->res->start;
426 root->eisa_root_res.end = root->res->end;
427 root->eisa_root_res.flags = IORESOURCE_BUSY;
428
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800429 err = request_resource(&eisa_root_res, &root->eisa_root_res);
430 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 return err;
Ladislav Michl91809d22018-01-17 10:44:06 +0100432
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 root->bus_nr = eisa_bus_count++;
434
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800435 err = eisa_probe(root);
436 if (err)
437 release_resource(&root->eisa_root_res);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
439 return err;
440}
441
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800442static int __init eisa_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443{
444 int r;
Ladislav Michl91809d22018-01-17 10:44:06 +0100445
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800446 r = bus_register(&eisa_bus_type);
447 if (r)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 return r;
449
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800450 printk(KERN_INFO "EISA bus registered\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 return 0;
452}
453
454module_param_array(enable_dev, int, &enable_dev_count, 0444);
455module_param_array(disable_dev, int, &disable_dev_count, 0444);
456
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800457postcore_initcall(eisa_init);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458
459int EISA_bus; /* for legacy drivers */
Thadeu Lima de Souza Cascardo33fd7972010-03-05 13:42:48 -0800460EXPORT_SYMBOL(EISA_bus);