ibmebus.c 16 KB

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