main.c 16 KB

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