mt7601u: lock out rx path and tx status reporting
[linux-2.6-block.git] / drivers / bcma / main.c
CommitLineData
8369ae33
RM
1/*
2 * Broadcom specific AMBA
3 * Bus subsystem
4 *
5 * Licensed under the GNU/GPL. See COPYING for details.
6 */
7
8#include "bcma_private.h"
200351c7 9#include <linux/module.h>
d57ef3a6 10#include <linux/platform_device.h>
8369ae33 11#include <linux/bcma/bcma.h>
eef72699 12#include <linux/slab.h>
2101e533 13#include <linux/of_address.h>
71783576 14#include <linux/of_irq.h>
cae761b5 15#include <linux/of_platform.h>
8369ae33
RM
16
17MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
18MODULE_LICENSE("GPL");
19
8f9ada4f
HM
20/* contains the number the next bus should get. */
21static unsigned int bcma_bus_next_num = 0;
22
23/* bcma_buses_mutex locks the bcma_bus_next_num */
24static DEFINE_MUTEX(bcma_buses_mutex);
25
8369ae33
RM
26static int bcma_bus_match(struct device *dev, struct device_driver *drv);
27static int bcma_device_probe(struct device *dev);
28static int bcma_device_remove(struct device *dev);
886b66ef 29static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env);
8369ae33
RM
30
31static ssize_t manuf_show(struct device *dev, struct device_attribute *attr, char *buf)
32{
33 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
34 return sprintf(buf, "0x%03X\n", core->id.manuf);
35}
fdcf4f81
GKH
36static DEVICE_ATTR_RO(manuf);
37
8369ae33
RM
38static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf)
39{
40 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
41 return sprintf(buf, "0x%03X\n", core->id.id);
42}
fdcf4f81
GKH
43static DEVICE_ATTR_RO(id);
44
8369ae33
RM
45static ssize_t rev_show(struct device *dev, struct device_attribute *attr, char *buf)
46{
47 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
48 return sprintf(buf, "0x%02X\n", core->id.rev);
49}
fdcf4f81
GKH
50static DEVICE_ATTR_RO(rev);
51
8369ae33
RM
52static ssize_t class_show(struct device *dev, struct device_attribute *attr, char *buf)
53{
54 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
55 return sprintf(buf, "0x%X\n", core->id.class);
56}
fdcf4f81
GKH
57static DEVICE_ATTR_RO(class);
58
59static struct attribute *bcma_device_attrs[] = {
60 &dev_attr_manuf.attr,
61 &dev_attr_id.attr,
62 &dev_attr_rev.attr,
63 &dev_attr_class.attr,
64 NULL,
8369ae33 65};
fdcf4f81 66ATTRIBUTE_GROUPS(bcma_device);
8369ae33
RM
67
68static struct bus_type bcma_bus_type = {
69 .name = "bcma",
70 .match = bcma_bus_match,
71 .probe = bcma_device_probe,
72 .remove = bcma_device_remove,
886b66ef 73 .uevent = bcma_device_uevent,
fdcf4f81 74 .dev_groups = bcma_device_groups,
8369ae33
RM
75};
76
6d5cfc9f
RM
77static u16 bcma_cc_core_id(struct bcma_bus *bus)
78{
79 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
80 return BCMA_CORE_4706_CHIPCOMMON;
81 return BCMA_CORE_CHIPCOMMON;
82}
83
929a03ae
HM
84struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
85 u8 unit)
dfae7143
HM
86{
87 struct bcma_device *core;
88
89 list_for_each_entry(core, &bus->cores, list) {
90 if (core->id.id == coreid && core->core_unit == unit)
91 return core;
92 }
93 return NULL;
94}
b2395b8a 95EXPORT_SYMBOL_GPL(bcma_find_core_unit);
dfae7143 96
88f9b65d
RM
97bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
98 int timeout)
99{
100 unsigned long deadline = jiffies + timeout;
101 u32 val;
102
103 do {
104 val = bcma_read32(core, reg);
105 if ((val & mask) == value)
106 return true;
107 cpu_relax();
108 udelay(10);
109 } while (!time_after_eq(jiffies, deadline));
110
111 bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
112
113 return false;
114}
115
8369ae33
RM
116static void bcma_release_core_dev(struct device *dev)
117{
118 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
ecd177c2
HM
119 if (core->io_addr)
120 iounmap(core->io_addr);
121 if (core->io_wrap)
122 iounmap(core->io_wrap);
8369ae33
RM
123 kfree(core);
124}
125
37a7f876
RM
126static bool bcma_is_core_needed_early(u16 core_id)
127{
128 switch (core_id) {
129 case BCMA_CORE_NS_NAND:
130 case BCMA_CORE_NS_QSPI:
131 return true;
132 }
133
134 return false;
135}
136
78afe83c 137#if defined(CONFIG_OF) && defined(CONFIG_OF_ADDRESS)
2101e533
HM
138static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
139 struct bcma_device *core)
140{
141 struct device_node *node;
142 u64 size;
143 const __be32 *reg;
144
145 if (!parent || !parent->dev.of_node)
146 return NULL;
147
148 for_each_child_of_node(parent->dev.of_node, node) {
149 reg = of_get_address(node, 0, &size, NULL);
150 if (!reg)
151 continue;
152 if (of_translate_address(node, reg) == core->addr)
153 return node;
154 }
155 return NULL;
156}
157
71783576
HM
158static int bcma_of_irq_parse(struct platform_device *parent,
159 struct bcma_device *core,
160 struct of_phandle_args *out_irq, int num)
161{
162 __be32 laddr[1];
163 int rc;
164
165 if (core->dev.of_node) {
166 rc = of_irq_parse_one(core->dev.of_node, num, out_irq);
167 if (!rc)
168 return rc;
169 }
170
171 out_irq->np = parent->dev.of_node;
172 out_irq->args_count = 1;
173 out_irq->args[0] = num;
174
175 laddr[0] = cpu_to_be32(core->addr);
176 return of_irq_parse_raw(laddr, out_irq);
177}
178
179static unsigned int bcma_of_get_irq(struct platform_device *parent,
180 struct bcma_device *core, int num)
181{
182 struct of_phandle_args out_irq;
183 int ret;
184
185 if (!parent || !parent->dev.of_node)
186 return 0;
187
188 ret = bcma_of_irq_parse(parent, core, &out_irq, num);
189 if (ret) {
190 bcma_debug(core->bus, "bcma_of_get_irq() failed with rc=%d\n",
191 ret);
192 return 0;
193 }
194
195 return irq_create_of_mapping(&out_irq);
196}
197
2101e533
HM
198static void bcma_of_fill_device(struct platform_device *parent,
199 struct bcma_device *core)
200{
201 struct device_node *node;
202
203 node = bcma_of_find_child_device(parent, core);
204 if (node)
205 core->dev.of_node = node;
71783576
HM
206
207 core->irq = bcma_of_get_irq(parent, core, 0);
2101e533
HM
208}
209#else
210static void bcma_of_fill_device(struct platform_device *parent,
211 struct bcma_device *core)
212{
213}
71783576
HM
214static inline unsigned int bcma_of_get_irq(struct platform_device *parent,
215 struct bcma_device *core, int num)
216{
217 return 0;
218}
2101e533
HM
219#endif /* CONFIG_OF */
220
85eb92e8
HM
221unsigned int bcma_core_irq(struct bcma_device *core, int num)
222{
223 struct bcma_bus *bus = core->bus;
224 unsigned int mips_irq;
225
226 switch (bus->hosttype) {
227 case BCMA_HOSTTYPE_PCI:
228 return bus->host_pci->irq;
229 case BCMA_HOSTTYPE_SOC:
230 if (bus->drv_mips.core && num == 0) {
231 mips_irq = bcma_core_mips_irq(core);
232 return mips_irq <= 4 ? mips_irq + 2 : 0;
233 }
71783576
HM
234 if (bus->host_pdev)
235 return bcma_of_get_irq(bus->host_pdev, core, num);
236 return 0;
85eb92e8
HM
237 case BCMA_HOSTTYPE_SDIO:
238 return 0;
239 }
240
241 return 0;
242}
243EXPORT_SYMBOL(bcma_core_irq);
244
ab54bc84 245void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
6e094bd8 246{
6e094bd8
RM
247 core->dev.release = bcma_release_core_dev;
248 core->dev.bus = &bcma_bus_type;
249 dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
250
251 switch (bus->hosttype) {
252 case BCMA_HOSTTYPE_PCI:
253 core->dev.parent = &bus->host_pci->dev;
254 core->dma_dev = &bus->host_pci->dev;
255 core->irq = bus->host_pci->irq;
256 break;
257 case BCMA_HOSTTYPE_SOC:
258 core->dev.dma_mask = &core->dev.coherent_dma_mask;
2101e533
HM
259 if (bus->host_pdev) {
260 core->dma_dev = &bus->host_pdev->dev;
261 core->dev.parent = &bus->host_pdev->dev;
262 bcma_of_fill_device(bus->host_pdev, core);
263 } else {
264 core->dma_dev = &core->dev;
265 }
6e094bd8
RM
266 break;
267 case BCMA_HOSTTYPE_SDIO:
268 break;
269 }
ab54bc84
RM
270}
271
799038ea
RM
272void bcma_init_bus(struct bcma_bus *bus)
273{
274 mutex_lock(&bcma_buses_mutex);
275 bus->num = bcma_bus_next_num++;
276 mutex_unlock(&bcma_buses_mutex);
277
278 INIT_LIST_HEAD(&bus->cores);
279 bus->nr_cores = 0;
280
281 bcma_detect_chip(bus);
282}
283
ab54bc84
RM
284static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
285{
286 int err;
6e094bd8
RM
287
288 err = device_register(&core->dev);
289 if (err) {
290 bcma_err(bus, "Could not register dev for core 0x%03X\n",
291 core->id.id);
292 put_device(&core->dev);
293 return;
294 }
295 core->dev_registered = true;
296}
297
298static int bcma_register_devices(struct bcma_bus *bus)
8369ae33
RM
299{
300 struct bcma_device *core;
6e094bd8 301 int err;
8369ae33
RM
302
303 list_for_each_entry(core, &bus->cores, list) {
304 /* We support that cores ourself */
305 switch (core->id.id) {
6d5cfc9f 306 case BCMA_CORE_4706_CHIPCOMMON:
8369ae33 307 case BCMA_CORE_CHIPCOMMON:
1716bcf3 308 case BCMA_CORE_NS_CHIPCOMMON_B:
8369ae33
RM
309 case BCMA_CORE_PCI:
310 case BCMA_CORE_PCIE:
f473832f 311 case BCMA_CORE_PCIE2:
21e0534a 312 case BCMA_CORE_MIPS_74K:
e1ac4b40 313 case BCMA_CORE_4706_MAC_GBIT_COMMON:
8369ae33
RM
314 continue;
315 }
316
37a7f876
RM
317 /* Early cores were already registered */
318 if (bcma_is_core_needed_early(core->id.id))
319 continue;
320
10419d08
RM
321 /* Only first GMAC core on BCM4706 is connected and working */
322 if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
323 core->core_unit > 0)
324 continue;
325
6e094bd8 326 bcma_register_core(bus, core);
8369ae33
RM
327 }
328
73e4dbe4
RM
329#ifdef CONFIG_BCMA_DRIVER_MIPS
330 if (bus->drv_cc.pflash.present) {
331 err = platform_device_register(&bcma_pflash_dev);
332 if (err)
333 bcma_err(bus, "Error registering parallel flash\n");
334 }
335#endif
336
d57ef3a6
RM
337#ifdef CONFIG_BCMA_SFLASH
338 if (bus->drv_cc.sflash.present) {
339 err = platform_device_register(&bcma_sflash_dev);
340 if (err)
341 bcma_err(bus, "Error registering serial flash\n");
342 }
343#endif
344
371a0044
RM
345#ifdef CONFIG_BCMA_NFLASH
346 if (bus->drv_cc.nflash.present) {
347 err = platform_device_register(&bcma_nflash_dev);
348 if (err)
349 bcma_err(bus, "Error registering NAND flash\n");
350 }
351#endif
cf0936b0
HM
352 err = bcma_gpio_init(&bus->drv_cc);
353 if (err == -ENOTSUPP)
354 bcma_debug(bus, "GPIO driver not activated\n");
355 else if (err)
356 bcma_err(bus, "Error registering GPIO driver: %i\n", err);
371a0044 357
a4855f39
HM
358 if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
359 err = bcma_chipco_watchdog_register(&bus->drv_cc);
360 if (err)
361 bcma_err(bus, "Error registering watchdog driver\n");
362 }
363
8369ae33
RM
364 return 0;
365}
366
9b6cc9a8 367void bcma_unregister_cores(struct bcma_bus *bus)
8369ae33 368{
1fffa905 369 struct bcma_device *core, *tmp;
8369ae33 370
1fffa905 371 list_for_each_entry_safe(core, tmp, &bus->cores, list) {
17fbaa6e
RM
372 if (!core->dev_registered)
373 continue;
1fffa905 374 list_del(&core->list);
17fbaa6e 375 device_unregister(&core->dev);
8369ae33 376 }
a4855f39
HM
377 if (bus->hosttype == BCMA_HOSTTYPE_SOC)
378 platform_device_unregister(bus->drv_cc.watchdog);
17fbaa6e
RM
379
380 /* Now noone uses internally-handled cores, we can free them */
381 list_for_each_entry_safe(core, tmp, &bus->cores, list) {
382 list_del(&core->list);
383 kfree(core);
384 }
8369ae33
RM
385}
386
0f58a01d 387int bcma_bus_register(struct bcma_bus *bus)
8369ae33
RM
388{
389 int err;
390 struct bcma_device *core;
391
392 /* Scan for devices (cores) */
393 err = bcma_bus_scan(bus);
394 if (err) {
3d9d8af3 395 bcma_err(bus, "Failed to scan: %d\n", err);
1cabf7db 396 return err;
8369ae33
RM
397 }
398
30cfb023
HM
399 /* Early init CC core */
400 core = bcma_find_core(bus, bcma_cc_core_id(bus));
401 if (core) {
402 bus->drv_cc.core = core;
403 bcma_core_chipcommon_early_init(&bus->drv_cc);
404 }
b504075f
RM
405
406 /* Early init PCIE core */
407 core = bcma_find_core(bus, BCMA_CORE_PCIE);
408 if (core) {
409 bus->drv_pci[0].core = core;
410 bcma_core_pci_early_init(&bus->drv_pci[0]);
411 }
cae761b5 412
92ff7a69
HM
413 /* TODO: remove check for IS_BUILTIN(CONFIG_BCMA) check when
414 * of_default_bus_match_table is exported or in some other way
415 * accessible. This is just a temporary workaround.
416 */
417 if (IS_BUILTIN(CONFIG_BCMA) && bus->host_pdev) {
cae761b5
RM
418 struct device *dev = &bus->host_pdev->dev;
419
420 of_platform_populate(dev->of_node, of_default_bus_match_table,
421 NULL, dev);
422 }
30cfb023 423
37a7f876
RM
424 /* Cores providing flash access go before SPROM init */
425 list_for_each_entry(core, &bus->cores, list) {
426 if (bcma_is_core_needed_early(core->id.id))
427 bcma_register_core(bus, core);
428 }
429
30cfb023
HM
430 /* Try to get SPROM */
431 err = bcma_sprom_get(bus);
432 if (err == -ENOENT) {
433 bcma_err(bus, "No SPROM available\n");
434 } else if (err)
435 bcma_err(bus, "Failed to get SPROM: %d\n", err);
436
8369ae33 437 /* Init CC core */
6d5cfc9f 438 core = bcma_find_core(bus, bcma_cc_core_id(bus));
8369ae33
RM
439 if (core) {
440 bus->drv_cc.core = core;
441 bcma_core_chipcommon_init(&bus->drv_cc);
442 }
443
1716bcf3
HM
444 /* Init CC core */
445 core = bcma_find_core(bus, BCMA_CORE_NS_CHIPCOMMON_B);
446 if (core) {
447 bus->drv_cc_b.core = core;
448 bcma_core_chipcommon_b_init(&bus->drv_cc_b);
449 }
450
21e0534a
HM
451 /* Init MIPS core */
452 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
453 if (core) {
454 bus->drv_mips.core = core;
455 bcma_core_mips_init(&bus->drv_mips);
456 }
457
8369ae33 458 /* Init PCIE core */
dfae7143
HM
459 core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
460 if (core) {
461 bus->drv_pci[0].core = core;
462 bcma_core_pci_init(&bus->drv_pci[0]);
463 }
464
465 /* Init PCIE core */
466 core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
8369ae33 467 if (core) {
dfae7143
HM
468 bus->drv_pci[1].core = core;
469 bcma_core_pci_init(&bus->drv_pci[1]);
8369ae33
RM
470 }
471
f473832f
RM
472 /* Init PCIe Gen 2 core */
473 core = bcma_find_core_unit(bus, BCMA_CORE_PCIE2, 0);
474 if (core) {
475 bus->drv_pcie2.core = core;
476 bcma_core_pcie2_init(&bus->drv_pcie2);
477 }
478
e1ac4b40
RM
479 /* Init GBIT MAC COMMON core */
480 core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
481 if (core) {
482 bus->drv_gmac_cmn.core = core;
483 bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
484 }
485
8369ae33 486 /* Register found cores */
6e094bd8 487 bcma_register_devices(bus);
8369ae33 488
3d9d8af3 489 bcma_info(bus, "Bus registered\n");
8369ae33
RM
490
491 return 0;
492}
8369ae33
RM
493
494void bcma_bus_unregister(struct bcma_bus *bus)
495{
c50ae947
HM
496 int err;
497
498 err = bcma_gpio_unregister(&bus->drv_cc);
499 if (err == -EBUSY)
500 bcma_err(bus, "Some GPIOs are still in use.\n");
501 else if (err)
502 bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
ee915927 503
1716bcf3
HM
504 bcma_core_chipcommon_b_free(&bus->drv_cc_b);
505
8369ae33
RM
506 bcma_unregister_cores(bus);
507}
8369ae33 508
c5ed1df7
RM
509/*
510 * This is a special version of bus registration function designed for SoCs.
511 * It scans bus and performs basic initialization of main cores only.
512 * Please note it requires memory allocation, however it won't try to sleep.
513 */
514int __init bcma_bus_early_register(struct bcma_bus *bus)
517f43e5
HM
515{
516 int err;
517 struct bcma_device *core;
517f43e5 518
c5ed1df7
RM
519 /* Scan for devices (cores) */
520 err = bcma_bus_scan(bus);
517f43e5 521 if (err) {
c5ed1df7 522 bcma_err(bus, "Failed to scan bus: %d\n", err);
517f43e5
HM
523 return -1;
524 }
525
49655bb8 526 /* Early init CC core */
6d5cfc9f 527 core = bcma_find_core(bus, bcma_cc_core_id(bus));
517f43e5
HM
528 if (core) {
529 bus->drv_cc.core = core;
49655bb8 530 bcma_core_chipcommon_early_init(&bus->drv_cc);
517f43e5
HM
531 }
532
49655bb8 533 /* Early init MIPS core */
21e0534a
HM
534 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
535 if (core) {
536 bus->drv_mips.core = core;
49655bb8 537 bcma_core_mips_early_init(&bus->drv_mips);
21e0534a
HM
538 }
539
3d9d8af3 540 bcma_info(bus, "Early bus registered\n");
517f43e5
HM
541
542 return 0;
543}
544
775ab521 545#ifdef CONFIG_PM
685a4ef0
LT
546int bcma_bus_suspend(struct bcma_bus *bus)
547{
7d5869e7
LT
548 struct bcma_device *core;
549
550 list_for_each_entry(core, &bus->cores, list) {
551 struct device_driver *drv = core->dev.driver;
552 if (drv) {
553 struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
554 if (adrv->suspend)
555 adrv->suspend(core);
556 }
557 }
685a4ef0
LT
558 return 0;
559}
560
775ab521
RM
561int bcma_bus_resume(struct bcma_bus *bus)
562{
563 struct bcma_device *core;
564
565 /* Init CC core */
6d5cfc9f 566 if (bus->drv_cc.core) {
775ab521
RM
567 bus->drv_cc.setup_done = false;
568 bcma_core_chipcommon_init(&bus->drv_cc);
569 }
570
7d5869e7
LT
571 list_for_each_entry(core, &bus->cores, list) {
572 struct device_driver *drv = core->dev.driver;
573 if (drv) {
574 struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
575 if (adrv->resume)
576 adrv->resume(core);
577 }
578 }
579
775ab521
RM
580 return 0;
581}
582#endif
583
8369ae33
RM
584int __bcma_driver_register(struct bcma_driver *drv, struct module *owner)
585{
586 drv->drv.name = drv->name;
587 drv->drv.bus = &bcma_bus_type;
588 drv->drv.owner = owner;
589
590 return driver_register(&drv->drv);
591}
592EXPORT_SYMBOL_GPL(__bcma_driver_register);
593
594void bcma_driver_unregister(struct bcma_driver *drv)
595{
596 driver_unregister(&drv->drv);
597}
598EXPORT_SYMBOL_GPL(bcma_driver_unregister);
599
600static int bcma_bus_match(struct device *dev, struct device_driver *drv)
601{
602 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
603 struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
604 const struct bcma_device_id *cid = &core->id;
605 const struct bcma_device_id *did;
606
607 for (did = adrv->id_table; did->manuf || did->id || did->rev; did++) {
608 if ((did->manuf == cid->manuf || did->manuf == BCMA_ANY_MANUF) &&
609 (did->id == cid->id || did->id == BCMA_ANY_ID) &&
610 (did->rev == cid->rev || did->rev == BCMA_ANY_REV) &&
611 (did->class == cid->class || did->class == BCMA_ANY_CLASS))
612 return 1;
613 }
614 return 0;
615}
616
617static int bcma_device_probe(struct device *dev)
618{
619 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
620 struct bcma_driver *adrv = container_of(dev->driver, struct bcma_driver,
621 drv);
622 int err = 0;
623
624 if (adrv->probe)
625 err = adrv->probe(core);
626
627 return err;
628}
629
630static int bcma_device_remove(struct device *dev)
631{
632 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
633 struct bcma_driver *adrv = container_of(dev->driver, struct bcma_driver,
634 drv);
635
636 if (adrv->remove)
637 adrv->remove(core);
638
639 return 0;
640}
641
886b66ef
DW
642static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env)
643{
644 struct bcma_device *core = container_of(dev, struct bcma_device, dev);
645
646 return add_uevent_var(env,
647 "MODALIAS=bcma:m%04Xid%04Xrev%02Xcl%02X",
648 core->id.manuf, core->id.id,
649 core->id.rev, core->id.class);
650}
651
8369ae33
RM
652static int __init bcma_modinit(void)
653{
654 int err;
655
656 err = bus_register(&bcma_bus_type);
657 if (err)
658 return err;
659
2101e533
HM
660 err = bcma_host_soc_register_driver();
661 if (err) {
662 pr_err("SoC host initialization failed\n");
663 err = 0;
664 }
8369ae33
RM
665#ifdef CONFIG_BCMA_HOST_PCI
666 err = bcma_host_pci_init();
667 if (err) {
668 pr_err("PCI host initialization failed\n");
669 err = 0;
670 }
671#endif
672
673 return err;
674}
675fs_initcall(bcma_modinit);
676
677static void __exit bcma_modexit(void)
678{
679#ifdef CONFIG_BCMA_HOST_PCI
680 bcma_host_pci_exit();
681#endif
2101e533 682 bcma_host_soc_unregister_driver();
8369ae33
RM
683 bus_unregister(&bcma_bus_type);
684}
685module_exit(bcma_modexit)