ibmebus.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. /*
  2. * IBM PowerPC IBM eBus Infrastructure Support.
  3. *
  4. * Copyright (c) 2005 IBM Corporation
  5. * Joachim Fenkes <fenkes@de.ibm.com>
  6. * Heiko J Schick <schickhj@de.ibm.com>
  7. *
  8. * All rights reserved.
  9. *
  10. * This source code is distributed under a dual license of GPL v2.0 and OpenIB
  11. * BSD.
  12. *
  13. * OpenIB BSD License
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are met:
  17. *
  18. * Redistributions of source code must retain the above copyright notice, this
  19. * list of conditions and the following disclaimer.
  20. *
  21. * Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials
  24. * provided with the distribution.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  33. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  34. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. */
  38. #include <linux/init.h>
  39. #include <linux/export.h>
  40. #include <linux/console.h>
  41. #include <linux/kobject.h>
  42. #include <linux/dma-mapping.h>
  43. #include <linux/interrupt.h>
  44. #include <linux/of.h>
  45. #include <linux/slab.h>
  46. #include <linux/of_platform.h>
  47. #include <asm/ibmebus.h>
  48. #include <asm/abs_addr.h>
  49. static struct device ibmebus_bus_device = { /* fake "parent" device */
  50. .init_name = "ibmebus",
  51. };
  52. struct bus_type ibmebus_bus_type;
  53. /* These devices will automatically be added to the bus during init */
  54. static struct of_device_id __initdata ibmebus_matches[] = {
  55. { .compatible = "IBM,lhca" },
  56. { .compatible = "IBM,lhea" },
  57. {},
  58. };
  59. static void *ibmebus_alloc_coherent(struct device *dev,
  60. size_t size,
  61. dma_addr_t *dma_handle,
  62. gfp_t flag)
  63. {
  64. void *mem;
  65. mem = kmalloc(size, flag);
  66. *dma_handle = (dma_addr_t)mem;
  67. return mem;
  68. }
  69. static void ibmebus_free_coherent(struct device *dev,
  70. size_t size, void *vaddr,
  71. dma_addr_t dma_handle)
  72. {
  73. kfree(vaddr);
  74. }
  75. static dma_addr_t ibmebus_map_page(struct device *dev,
  76. struct page *page,
  77. unsigned long offset,
  78. size_t size,
  79. enum dma_data_direction direction,
  80. struct dma_attrs *attrs)
  81. {
  82. return (dma_addr_t)(page_address(page) + offset);
  83. }
  84. static void ibmebus_unmap_page(struct device *dev,
  85. dma_addr_t dma_addr,
  86. size_t size,
  87. enum dma_data_direction direction,
  88. struct dma_attrs *attrs)
  89. {
  90. return;
  91. }
  92. static int ibmebus_map_sg(struct device *dev,
  93. struct scatterlist *sgl,
  94. int nents, enum dma_data_direction direction,
  95. struct dma_attrs *attrs)
  96. {
  97. struct scatterlist *sg;
  98. int i;
  99. for_each_sg(sgl, sg, nents, i) {
  100. sg->dma_address = (dma_addr_t) sg_virt(sg);
  101. sg->dma_length = sg->length;
  102. }
  103. return nents;
  104. }
  105. static void ibmebus_unmap_sg(struct device *dev,
  106. struct scatterlist *sg,
  107. int nents, enum dma_data_direction direction,
  108. struct dma_attrs *attrs)
  109. {
  110. return;
  111. }
  112. static int ibmebus_dma_supported(struct device *dev, u64 mask)
  113. {
  114. return 1;
  115. }
  116. static struct dma_map_ops ibmebus_dma_ops = {
  117. .alloc_coherent = ibmebus_alloc_coherent,
  118. .free_coherent = ibmebus_free_coherent,
  119. .map_sg = ibmebus_map_sg,
  120. .unmap_sg = ibmebus_unmap_sg,
  121. .dma_supported = ibmebus_dma_supported,
  122. .map_page = ibmebus_map_page,
  123. .unmap_page = ibmebus_unmap_page,
  124. };
  125. static int ibmebus_match_path(struct device *dev, void *data)
  126. {
  127. struct device_node *dn = to_platform_device(dev)->dev.of_node;
  128. return (dn->full_name &&
  129. (strcasecmp((char *)data, dn->full_name) == 0));
  130. }
  131. static int ibmebus_match_node(struct device *dev, void *data)
  132. {
  133. return to_platform_device(dev)->dev.of_node == data;
  134. }
  135. static int ibmebus_create_device(struct device_node *dn)
  136. {
  137. struct platform_device *dev;
  138. int ret;
  139. dev = of_device_alloc(dn, NULL, &ibmebus_bus_device);
  140. if (!dev)
  141. return -ENOMEM;
  142. dev->dev.bus = &ibmebus_bus_type;
  143. dev->dev.archdata.dma_ops = &ibmebus_dma_ops;
  144. ret = of_device_add(dev);
  145. if (ret)
  146. platform_device_put(dev);
  147. return ret;
  148. }
  149. static int ibmebus_create_devices(const struct of_device_id *matches)
  150. {
  151. struct device_node *root, *child;
  152. int ret = 0;
  153. root = of_find_node_by_path("/");
  154. for_each_child_of_node(root, child) {
  155. if (!of_match_node(matches, child))
  156. continue;
  157. if (bus_find_device(&ibmebus_bus_type, NULL, child,
  158. ibmebus_match_node))
  159. continue;
  160. ret = ibmebus_create_device(child);
  161. if (ret) {
  162. printk(KERN_ERR "%s: failed to create device (%i)",
  163. __func__, ret);
  164. of_node_put(child);
  165. break;
  166. }
  167. }
  168. of_node_put(root);
  169. return ret;
  170. }
  171. int ibmebus_register_driver(struct of_platform_driver *drv)
  172. {
  173. /* If the driver uses devices that ibmebus doesn't know, add them */
  174. ibmebus_create_devices(drv->driver.of_match_table);
  175. drv->driver.bus = &ibmebus_bus_type;
  176. return driver_register(&drv->driver);
  177. }
  178. EXPORT_SYMBOL(ibmebus_register_driver);
  179. void ibmebus_unregister_driver(struct of_platform_driver *drv)
  180. {
  181. driver_unregister(&drv->driver);
  182. }
  183. EXPORT_SYMBOL(ibmebus_unregister_driver);
  184. int ibmebus_request_irq(u32 ist, irq_handler_t handler,
  185. unsigned long irq_flags, const char *devname,
  186. void *dev_id)
  187. {
  188. unsigned int irq = irq_create_mapping(NULL, ist);
  189. if (irq == NO_IRQ)
  190. return -EINVAL;
  191. return request_irq(irq, handler, irq_flags, devname, dev_id);
  192. }
  193. EXPORT_SYMBOL(ibmebus_request_irq);
  194. void ibmebus_free_irq(u32 ist, void *dev_id)
  195. {
  196. unsigned int irq = irq_find_mapping(NULL, ist);
  197. free_irq(irq, dev_id);
  198. irq_dispose_mapping(irq);
  199. }
  200. EXPORT_SYMBOL(ibmebus_free_irq);
  201. static char *ibmebus_chomp(const char *in, size_t count)
  202. {
  203. char *out = kmalloc(count + 1, GFP_KERNEL);
  204. if (!out)
  205. return NULL;
  206. memcpy(out, in, count);
  207. out[count] = '\0';
  208. if (out[count - 1] == '\n')
  209. out[count - 1] = '\0';
  210. return out;
  211. }
  212. static ssize_t ibmebus_store_probe(struct bus_type *bus,
  213. const char *buf, size_t count)
  214. {
  215. struct device_node *dn = NULL;
  216. char *path;
  217. ssize_t rc = 0;
  218. path = ibmebus_chomp(buf, count);
  219. if (!path)
  220. return -ENOMEM;
  221. if (bus_find_device(&ibmebus_bus_type, NULL, path,
  222. ibmebus_match_path)) {
  223. printk(KERN_WARNING "%s: %s has already been probed\n",
  224. __func__, path);
  225. rc = -EEXIST;
  226. goto out;
  227. }
  228. if ((dn = of_find_node_by_path(path))) {
  229. rc = ibmebus_create_device(dn);
  230. of_node_put(dn);
  231. } else {
  232. printk(KERN_WARNING "%s: no such device node: %s\n",
  233. __func__, path);
  234. rc = -ENODEV;
  235. }
  236. out:
  237. kfree(path);
  238. if (rc)
  239. return rc;
  240. return count;
  241. }
  242. static ssize_t ibmebus_store_remove(struct bus_type *bus,
  243. const char *buf, size_t count)
  244. {
  245. struct device *dev;
  246. char *path;
  247. path = ibmebus_chomp(buf, count);
  248. if (!path)
  249. return -ENOMEM;
  250. if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path,
  251. ibmebus_match_path))) {
  252. of_device_unregister(to_platform_device(dev));
  253. kfree(path);
  254. return count;
  255. } else {
  256. printk(KERN_WARNING "%s: %s not on the bus\n",
  257. __func__, path);
  258. kfree(path);
  259. return -ENODEV;
  260. }
  261. }
  262. static struct bus_attribute ibmebus_bus_attrs[] = {
  263. __ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe),
  264. __ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove),
  265. __ATTR_NULL
  266. };
  267. static int ibmebus_bus_bus_match(struct device *dev, struct device_driver *drv)
  268. {
  269. const struct of_device_id *matches = drv->of_match_table;
  270. if (!matches)
  271. return 0;
  272. return of_match_device(matches, dev) != NULL;
  273. }
  274. static int ibmebus_bus_device_probe(struct device *dev)
  275. {
  276. int error = -ENODEV;
  277. struct of_platform_driver *drv;
  278. struct platform_device *of_dev;
  279. const struct of_device_id *match;
  280. drv = to_of_platform_driver(dev->driver);
  281. of_dev = to_platform_device(dev);
  282. if (!drv->probe)
  283. return error;
  284. of_dev_get(of_dev);
  285. match = of_match_device(drv->driver.of_match_table, dev);
  286. if (match)
  287. error = drv->probe(of_dev, match);
  288. if (error)
  289. of_dev_put(of_dev);
  290. return error;
  291. }
  292. static int ibmebus_bus_device_remove(struct device *dev)
  293. {
  294. struct platform_device *of_dev = to_platform_device(dev);
  295. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  296. if (dev->driver && drv->remove)
  297. drv->remove(of_dev);
  298. return 0;
  299. }
  300. static void ibmebus_bus_device_shutdown(struct device *dev)
  301. {
  302. struct platform_device *of_dev = to_platform_device(dev);
  303. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  304. if (dev->driver && drv->shutdown)
  305. drv->shutdown(of_dev);
  306. }
  307. /*
  308. * ibmebus_bus_device_attrs
  309. */
  310. static ssize_t devspec_show(struct device *dev,
  311. struct device_attribute *attr, char *buf)
  312. {
  313. struct platform_device *ofdev;
  314. ofdev = to_platform_device(dev);
  315. return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name);
  316. }
  317. static ssize_t name_show(struct device *dev,
  318. struct device_attribute *attr, char *buf)
  319. {
  320. struct platform_device *ofdev;
  321. ofdev = to_platform_device(dev);
  322. return sprintf(buf, "%s\n", ofdev->dev.of_node->name);
  323. }
  324. static ssize_t modalias_show(struct device *dev,
  325. struct device_attribute *attr, char *buf)
  326. {
  327. ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2);
  328. buf[len] = '\n';
  329. buf[len+1] = 0;
  330. return len+1;
  331. }
  332. struct device_attribute ibmebus_bus_device_attrs[] = {
  333. __ATTR_RO(devspec),
  334. __ATTR_RO(name),
  335. __ATTR_RO(modalias),
  336. __ATTR_NULL
  337. };
  338. #ifdef CONFIG_PM_SLEEP
  339. static int ibmebus_bus_legacy_suspend(struct device *dev, pm_message_t mesg)
  340. {
  341. struct platform_device *of_dev = to_platform_device(dev);
  342. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  343. int ret = 0;
  344. if (dev->driver && drv->suspend)
  345. ret = drv->suspend(of_dev, mesg);
  346. return ret;
  347. }
  348. static int ibmebus_bus_legacy_resume(struct device *dev)
  349. {
  350. struct platform_device *of_dev = to_platform_device(dev);
  351. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  352. int ret = 0;
  353. if (dev->driver && drv->resume)
  354. ret = drv->resume(of_dev);
  355. return ret;
  356. }
  357. static int ibmebus_bus_pm_prepare(struct device *dev)
  358. {
  359. struct device_driver *drv = dev->driver;
  360. int ret = 0;
  361. if (drv && drv->pm && drv->pm->prepare)
  362. ret = drv->pm->prepare(dev);
  363. return ret;
  364. }
  365. static void ibmebus_bus_pm_complete(struct device *dev)
  366. {
  367. struct device_driver *drv = dev->driver;
  368. if (drv && drv->pm && drv->pm->complete)
  369. drv->pm->complete(dev);
  370. }
  371. #ifdef CONFIG_SUSPEND
  372. static int ibmebus_bus_pm_suspend(struct device *dev)
  373. {
  374. struct device_driver *drv = dev->driver;
  375. int ret = 0;
  376. if (!drv)
  377. return 0;
  378. if (drv->pm) {
  379. if (drv->pm->suspend)
  380. ret = drv->pm->suspend(dev);
  381. } else {
  382. ret = ibmebus_bus_legacy_suspend(dev, PMSG_SUSPEND);
  383. }
  384. return ret;
  385. }
  386. static int ibmebus_bus_pm_suspend_noirq(struct device *dev)
  387. {
  388. struct device_driver *drv = dev->driver;
  389. int ret = 0;
  390. if (!drv)
  391. return 0;
  392. if (drv->pm) {
  393. if (drv->pm->suspend_noirq)
  394. ret = drv->pm->suspend_noirq(dev);
  395. }
  396. return ret;
  397. }
  398. static int ibmebus_bus_pm_resume(struct device *dev)
  399. {
  400. struct device_driver *drv = dev->driver;
  401. int ret = 0;
  402. if (!drv)
  403. return 0;
  404. if (drv->pm) {
  405. if (drv->pm->resume)
  406. ret = drv->pm->resume(dev);
  407. } else {
  408. ret = ibmebus_bus_legacy_resume(dev);
  409. }
  410. return ret;
  411. }
  412. static int ibmebus_bus_pm_resume_noirq(struct device *dev)
  413. {
  414. struct device_driver *drv = dev->driver;
  415. int ret = 0;
  416. if (!drv)
  417. return 0;
  418. if (drv->pm) {
  419. if (drv->pm->resume_noirq)
  420. ret = drv->pm->resume_noirq(dev);
  421. }
  422. return ret;
  423. }
  424. #else /* !CONFIG_SUSPEND */
  425. #define ibmebus_bus_pm_suspend NULL
  426. #define ibmebus_bus_pm_resume NULL
  427. #define ibmebus_bus_pm_suspend_noirq NULL
  428. #define ibmebus_bus_pm_resume_noirq NULL
  429. #endif /* !CONFIG_SUSPEND */
  430. #ifdef CONFIG_HIBERNATE_CALLBACKS
  431. static int ibmebus_bus_pm_freeze(struct device *dev)
  432. {
  433. struct device_driver *drv = dev->driver;
  434. int ret = 0;
  435. if (!drv)
  436. return 0;
  437. if (drv->pm) {
  438. if (drv->pm->freeze)
  439. ret = drv->pm->freeze(dev);
  440. } else {
  441. ret = ibmebus_bus_legacy_suspend(dev, PMSG_FREEZE);
  442. }
  443. return ret;
  444. }
  445. static int ibmebus_bus_pm_freeze_noirq(struct device *dev)
  446. {
  447. struct device_driver *drv = dev->driver;
  448. int ret = 0;
  449. if (!drv)
  450. return 0;
  451. if (drv->pm) {
  452. if (drv->pm->freeze_noirq)
  453. ret = drv->pm->freeze_noirq(dev);
  454. }
  455. return ret;
  456. }
  457. static int ibmebus_bus_pm_thaw(struct device *dev)
  458. {
  459. struct device_driver *drv = dev->driver;
  460. int ret = 0;
  461. if (!drv)
  462. return 0;
  463. if (drv->pm) {
  464. if (drv->pm->thaw)
  465. ret = drv->pm->thaw(dev);
  466. } else {
  467. ret = ibmebus_bus_legacy_resume(dev);
  468. }
  469. return ret;
  470. }
  471. static int ibmebus_bus_pm_thaw_noirq(struct device *dev)
  472. {
  473. struct device_driver *drv = dev->driver;
  474. int ret = 0;
  475. if (!drv)
  476. return 0;
  477. if (drv->pm) {
  478. if (drv->pm->thaw_noirq)
  479. ret = drv->pm->thaw_noirq(dev);
  480. }
  481. return ret;
  482. }
  483. static int ibmebus_bus_pm_poweroff(struct device *dev)
  484. {
  485. struct device_driver *drv = dev->driver;
  486. int ret = 0;
  487. if (!drv)
  488. return 0;
  489. if (drv->pm) {
  490. if (drv->pm->poweroff)
  491. ret = drv->pm->poweroff(dev);
  492. } else {
  493. ret = ibmebus_bus_legacy_suspend(dev, PMSG_HIBERNATE);
  494. }
  495. return ret;
  496. }
  497. static int ibmebus_bus_pm_poweroff_noirq(struct device *dev)
  498. {
  499. struct device_driver *drv = dev->driver;
  500. int ret = 0;
  501. if (!drv)
  502. return 0;
  503. if (drv->pm) {
  504. if (drv->pm->poweroff_noirq)
  505. ret = drv->pm->poweroff_noirq(dev);
  506. }
  507. return ret;
  508. }
  509. static int ibmebus_bus_pm_restore(struct device *dev)
  510. {
  511. struct device_driver *drv = dev->driver;
  512. int ret = 0;
  513. if (!drv)
  514. return 0;
  515. if (drv->pm) {
  516. if (drv->pm->restore)
  517. ret = drv->pm->restore(dev);
  518. } else {
  519. ret = ibmebus_bus_legacy_resume(dev);
  520. }
  521. return ret;
  522. }
  523. static int ibmebus_bus_pm_restore_noirq(struct device *dev)
  524. {
  525. struct device_driver *drv = dev->driver;
  526. int ret = 0;
  527. if (!drv)
  528. return 0;
  529. if (drv->pm) {
  530. if (drv->pm->restore_noirq)
  531. ret = drv->pm->restore_noirq(dev);
  532. }
  533. return ret;
  534. }
  535. #else /* !CONFIG_HIBERNATE_CALLBACKS */
  536. #define ibmebus_bus_pm_freeze NULL
  537. #define ibmebus_bus_pm_thaw NULL
  538. #define ibmebus_bus_pm_poweroff NULL
  539. #define ibmebus_bus_pm_restore NULL
  540. #define ibmebus_bus_pm_freeze_noirq NULL
  541. #define ibmebus_bus_pm_thaw_noirq NULL
  542. #define ibmebus_bus_pm_poweroff_noirq NULL
  543. #define ibmebus_bus_pm_restore_noirq NULL
  544. #endif /* !CONFIG_HIBERNATE_CALLBACKS */
  545. static struct dev_pm_ops ibmebus_bus_dev_pm_ops = {
  546. .prepare = ibmebus_bus_pm_prepare,
  547. .complete = ibmebus_bus_pm_complete,
  548. .suspend = ibmebus_bus_pm_suspend,
  549. .resume = ibmebus_bus_pm_resume,
  550. .freeze = ibmebus_bus_pm_freeze,
  551. .thaw = ibmebus_bus_pm_thaw,
  552. .poweroff = ibmebus_bus_pm_poweroff,
  553. .restore = ibmebus_bus_pm_restore,
  554. .suspend_noirq = ibmebus_bus_pm_suspend_noirq,
  555. .resume_noirq = ibmebus_bus_pm_resume_noirq,
  556. .freeze_noirq = ibmebus_bus_pm_freeze_noirq,
  557. .thaw_noirq = ibmebus_bus_pm_thaw_noirq,
  558. .poweroff_noirq = ibmebus_bus_pm_poweroff_noirq,
  559. .restore_noirq = ibmebus_bus_pm_restore_noirq,
  560. };
  561. #define IBMEBUS_BUS_PM_OPS_PTR (&ibmebus_bus_dev_pm_ops)
  562. #else /* !CONFIG_PM_SLEEP */
  563. #define IBMEBUS_BUS_PM_OPS_PTR NULL
  564. #endif /* !CONFIG_PM_SLEEP */
  565. struct bus_type ibmebus_bus_type = {
  566. .name = "ibmebus",
  567. .uevent = of_device_uevent,
  568. .bus_attrs = ibmebus_bus_attrs,
  569. .match = ibmebus_bus_bus_match,
  570. .probe = ibmebus_bus_device_probe,
  571. .remove = ibmebus_bus_device_remove,
  572. .shutdown = ibmebus_bus_device_shutdown,
  573. .dev_attrs = ibmebus_bus_device_attrs,
  574. .pm = IBMEBUS_BUS_PM_OPS_PTR,
  575. };
  576. EXPORT_SYMBOL(ibmebus_bus_type);
  577. static int __init ibmebus_bus_init(void)
  578. {
  579. int err;
  580. printk(KERN_INFO "IBM eBus Device Driver\n");
  581. err = bus_register(&ibmebus_bus_type);
  582. if (err) {
  583. printk(KERN_ERR "%s: failed to register IBM eBus.\n",
  584. __func__);
  585. return err;
  586. }
  587. err = device_register(&ibmebus_bus_device);
  588. if (err) {
  589. printk(KERN_WARNING "%s: device_register returned %i\n",
  590. __func__, err);
  591. bus_unregister(&ibmebus_bus_type);
  592. return err;
  593. }
  594. err = ibmebus_create_devices(ibmebus_matches);
  595. if (err) {
  596. device_unregister(&ibmebus_bus_device);
  597. bus_unregister(&ibmebus_bus_type);
  598. return err;
  599. }
  600. return 0;
  601. }
  602. postcore_initcall(ibmebus_bus_init);