ibmebus.c 16 KB

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