macio_asic.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. /*
  2. * Bus & driver management routines for devices within
  3. * a MacIO ASIC. Interface to new driver model mostly
  4. * stolen from the PCI version.
  5. *
  6. * TODO:
  7. *
  8. * - Don't probe below media bay by default, but instead provide
  9. * some hooks for media bay to dynamically add/remove it's own
  10. * sub-devices.
  11. */
  12. #include <linux/config.h>
  13. #include <linux/string.h>
  14. #include <linux/kernel.h>
  15. #include <linux/pci.h>
  16. #include <linux/pci_ids.h>
  17. #include <linux/init.h>
  18. #include <linux/module.h>
  19. #include <asm/machdep.h>
  20. #include <asm/macio.h>
  21. #include <asm/pmac_feature.h>
  22. #include <asm/prom.h>
  23. #include <asm/pci-bridge.h>
  24. #undef DEBUG
  25. #define MAX_NODE_NAME_SIZE (BUS_ID_SIZE - 12)
  26. static struct macio_chip *macio_on_hold;
  27. static int macio_bus_match(struct device *dev, struct device_driver *drv)
  28. {
  29. struct macio_dev * macio_dev = to_macio_device(dev);
  30. struct macio_driver * macio_drv = to_macio_driver(drv);
  31. const struct of_device_id * matches = macio_drv->match_table;
  32. if (!matches)
  33. return 0;
  34. return of_match_device(matches, &macio_dev->ofdev) != NULL;
  35. }
  36. struct macio_dev *macio_dev_get(struct macio_dev *dev)
  37. {
  38. struct device *tmp;
  39. if (!dev)
  40. return NULL;
  41. tmp = get_device(&dev->ofdev.dev);
  42. if (tmp)
  43. return to_macio_device(tmp);
  44. else
  45. return NULL;
  46. }
  47. void macio_dev_put(struct macio_dev *dev)
  48. {
  49. if (dev)
  50. put_device(&dev->ofdev.dev);
  51. }
  52. static int macio_device_probe(struct device *dev)
  53. {
  54. int error = -ENODEV;
  55. struct macio_driver *drv;
  56. struct macio_dev *macio_dev;
  57. const struct of_device_id *match;
  58. drv = to_macio_driver(dev->driver);
  59. macio_dev = to_macio_device(dev);
  60. if (!drv->probe)
  61. return error;
  62. macio_dev_get(macio_dev);
  63. match = of_match_device(drv->match_table, &macio_dev->ofdev);
  64. if (match)
  65. error = drv->probe(macio_dev, match);
  66. if (error)
  67. macio_dev_put(macio_dev);
  68. return error;
  69. }
  70. static int macio_device_remove(struct device *dev)
  71. {
  72. struct macio_dev * macio_dev = to_macio_device(dev);
  73. struct macio_driver * drv = to_macio_driver(dev->driver);
  74. if (dev->driver && drv->remove)
  75. drv->remove(macio_dev);
  76. macio_dev_put(macio_dev);
  77. return 0;
  78. }
  79. static void macio_device_shutdown(struct device *dev)
  80. {
  81. struct macio_dev * macio_dev = to_macio_device(dev);
  82. struct macio_driver * drv = to_macio_driver(dev->driver);
  83. if (dev->driver && drv->shutdown)
  84. drv->shutdown(macio_dev);
  85. }
  86. static int macio_device_suspend(struct device *dev, pm_message_t state)
  87. {
  88. struct macio_dev * macio_dev = to_macio_device(dev);
  89. struct macio_driver * drv = to_macio_driver(dev->driver);
  90. if (dev->driver && drv->suspend)
  91. return drv->suspend(macio_dev, state);
  92. return 0;
  93. }
  94. static int macio_device_resume(struct device * dev)
  95. {
  96. struct macio_dev * macio_dev = to_macio_device(dev);
  97. struct macio_driver * drv = to_macio_driver(dev->driver);
  98. if (dev->driver && drv->resume)
  99. return drv->resume(macio_dev);
  100. return 0;
  101. }
  102. static int macio_hotplug (struct device *dev, char **envp, int num_envp,
  103. char *buffer, int buffer_size)
  104. {
  105. struct macio_dev * macio_dev;
  106. struct of_device * of;
  107. char *scratch, *compat;
  108. int i = 0;
  109. int length = 0;
  110. int cplen, seen = 0;
  111. if (!dev)
  112. return -ENODEV;
  113. macio_dev = to_macio_device(dev);
  114. if (!macio_dev)
  115. return -ENODEV;
  116. of = &macio_dev->ofdev;
  117. scratch = buffer;
  118. /* stuff we want to pass to /sbin/hotplug */
  119. envp[i++] = scratch;
  120. length += scnprintf (scratch, buffer_size - length, "OF_NAME=%s",
  121. of->node->name);
  122. if ((buffer_size - length <= 0) || (i >= num_envp))
  123. return -ENOMEM;
  124. ++length;
  125. scratch += length;
  126. envp[i++] = scratch;
  127. length += scnprintf (scratch, buffer_size - length, "OF_TYPE=%s",
  128. of->node->type);
  129. if ((buffer_size - length <= 0) || (i >= num_envp))
  130. return -ENOMEM;
  131. ++length;
  132. scratch += length;
  133. /* Since the compatible field can contain pretty much anything
  134. * it's not really legal to split it out with commas. We split it
  135. * up using a number of environment variables instead. */
  136. compat = (char *) get_property(of->node, "compatible", &cplen);
  137. while (compat && cplen > 0) {
  138. int l;
  139. envp[i++] = scratch;
  140. length += scnprintf (scratch, buffer_size - length,
  141. "OF_COMPATIBLE_%d=%s", seen, compat);
  142. if ((buffer_size - length <= 0) || (i >= num_envp))
  143. return -ENOMEM;
  144. length++;
  145. scratch += length;
  146. l = strlen (compat) + 1;
  147. compat += l;
  148. cplen -= l;
  149. seen++;
  150. }
  151. envp[i++] = scratch;
  152. length += scnprintf (scratch, buffer_size - length,
  153. "OF_COMPATIBLE_N=%d", seen);
  154. if ((buffer_size - length <= 0) || (i >= num_envp))
  155. return -ENOMEM;
  156. ++length;
  157. scratch += length;
  158. envp[i] = NULL;
  159. return 0;
  160. }
  161. extern struct device_attribute macio_dev_attrs[];
  162. struct bus_type macio_bus_type = {
  163. .name = "macio",
  164. .match = macio_bus_match,
  165. .hotplug = macio_hotplug,
  166. .suspend = macio_device_suspend,
  167. .resume = macio_device_resume,
  168. .dev_attrs = macio_dev_attrs,
  169. };
  170. static int __init macio_bus_driver_init(void)
  171. {
  172. return bus_register(&macio_bus_type);
  173. }
  174. postcore_initcall(macio_bus_driver_init);
  175. /**
  176. * macio_release_dev - free a macio device structure when all users of it are finished.
  177. * @dev: device that's been disconnected
  178. *
  179. * Will be called only by the device core when all users of this macio device are
  180. * done. This currently means never as we don't hot remove any macio device yet,
  181. * though that will happen with mediabay based devices in a later implementation.
  182. */
  183. static void macio_release_dev(struct device *dev)
  184. {
  185. struct macio_dev *mdev;
  186. mdev = to_macio_device(dev);
  187. kfree(mdev);
  188. }
  189. /**
  190. * macio_resource_quirks - tweak or skip some resources for a device
  191. * @np: pointer to the device node
  192. * @res: resulting resource
  193. * @index: index of resource in node
  194. *
  195. * If this routine returns non-null, then the resource is completely
  196. * skipped.
  197. */
  198. static int macio_resource_quirks(struct device_node *np, struct resource *res, int index)
  199. {
  200. if (res->flags & IORESOURCE_MEM) {
  201. /* Grand Central has too large resource 0 on some machines */
  202. if (index == 0 && !strcmp(np->name, "gc")) {
  203. np->addrs[0].size = 0x20000;
  204. res->end = res->start + 0x1ffff;
  205. }
  206. /* Airport has bogus resource 2 */
  207. if (index >= 2 && !strcmp(np->name, "radio"))
  208. return 1;
  209. /* DBDMAs may have bogus sizes */
  210. if ((res->start & 0x0001f000) == 0x00008000) {
  211. np->addrs[index].size = 0x100;
  212. res->end = res->start + 0xff;
  213. }
  214. /* ESCC parent eats child resources. We could have added a level of hierarchy,
  215. * but I don't really feel the need for it */
  216. if (!strcmp(np->name, "escc"))
  217. return 1;
  218. /* ESCC has bogus resources >= 3 */
  219. if (index >= 3 && !(strcmp(np->name, "ch-a") && strcmp(np->name, "ch-b")))
  220. return 1;
  221. /* Media bay has too many resources, keep only first one */
  222. if (index > 0 && !strcmp(np->name, "media-bay"))
  223. return 1;
  224. /* Some older IDE resources have bogus sizes */
  225. if (!(strcmp(np->name, "IDE") && strcmp(np->name, "ATA") &&
  226. strcmp(np->type, "ide") && strcmp(np->type, "ata"))) {
  227. if (index == 0 && np->addrs[0].size > 0x1000) {
  228. np->addrs[0].size = 0x1000;
  229. res->end = res->start + 0xfff;
  230. }
  231. if (index == 1 && np->addrs[1].size > 0x100) {
  232. np->addrs[1].size = 0x100;
  233. res->end = res->start + 0xff;
  234. }
  235. }
  236. }
  237. return 0;
  238. }
  239. /**
  240. * macio_add_one_device - Add one device from OF node to the device tree
  241. * @chip: pointer to the macio_chip holding the device
  242. * @np: pointer to the device node in the OF tree
  243. * @in_bay: set to 1 if device is part of a media-bay
  244. *
  245. * When media-bay is changed to hotswap drivers, this function will
  246. * be exposed to the bay driver some way...
  247. */
  248. static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct device *parent,
  249. struct device_node *np, struct macio_dev *in_bay,
  250. struct resource *parent_res)
  251. {
  252. struct macio_dev *dev;
  253. int i, j;
  254. u32 *reg;
  255. if (np == NULL)
  256. return NULL;
  257. dev = kmalloc(sizeof(*dev), GFP_KERNEL);
  258. if (!dev)
  259. return NULL;
  260. memset(dev, 0, sizeof(*dev));
  261. dev->bus = &chip->lbus;
  262. dev->media_bay = in_bay;
  263. dev->ofdev.node = np;
  264. dev->ofdev.dma_mask = 0xffffffffUL;
  265. dev->ofdev.dev.dma_mask = &dev->ofdev.dma_mask;
  266. dev->ofdev.dev.parent = parent;
  267. dev->ofdev.dev.bus = &macio_bus_type;
  268. dev->ofdev.dev.release = macio_release_dev;
  269. #ifdef DEBUG
  270. printk("preparing mdev @%p, ofdev @%p, dev @%p, kobj @%p\n",
  271. dev, &dev->ofdev, &dev->ofdev.dev, &dev->ofdev.dev.kobj);
  272. #endif
  273. /* MacIO itself has a different reg, we use it's PCI base */
  274. if (np == chip->of_node) {
  275. sprintf(dev->ofdev.dev.bus_id, "%1d.%08lx:%.*s", chip->lbus.index,
  276. #ifdef CONFIG_PCI
  277. pci_resource_start(chip->lbus.pdev, 0),
  278. #else
  279. 0, /* NuBus may want to do something better here */
  280. #endif
  281. MAX_NODE_NAME_SIZE, np->name);
  282. } else {
  283. reg = (u32 *)get_property(np, "reg", NULL);
  284. sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s", chip->lbus.index,
  285. reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name);
  286. }
  287. /* For now, we use pre-parsed entries in the device-tree for
  288. * interrupt routing and addresses, but we should change that
  289. * to dynamically parsed entries and so get rid of most of the
  290. * clutter in struct device_node
  291. */
  292. for (i = j = 0; i < np->n_intrs; i++) {
  293. struct resource *res = &dev->interrupt[j];
  294. if (j >= MACIO_DEV_COUNT_IRQS)
  295. break;
  296. res->start = np->intrs[i].line;
  297. res->flags = IORESOURCE_IO;
  298. if (np->intrs[j].sense)
  299. res->flags |= IORESOURCE_IRQ_LOWLEVEL;
  300. else
  301. res->flags |= IORESOURCE_IRQ_HIGHEDGE;
  302. res->name = dev->ofdev.dev.bus_id;
  303. if (macio_resource_quirks(np, res, i))
  304. memset(res, 0, sizeof(struct resource));
  305. else
  306. j++;
  307. }
  308. dev->n_interrupts = j;
  309. for (i = j = 0; i < np->n_addrs; i++) {
  310. struct resource *res = &dev->resource[j];
  311. if (j >= MACIO_DEV_COUNT_RESOURCES)
  312. break;
  313. res->start = np->addrs[i].address;
  314. res->end = np->addrs[i].address + np->addrs[i].size - 1;
  315. res->flags = IORESOURCE_MEM;
  316. res->name = dev->ofdev.dev.bus_id;
  317. if (macio_resource_quirks(np, res, i))
  318. memset(res, 0, sizeof(struct resource));
  319. else {
  320. j++;
  321. /* Currently, we consider failure as harmless, this may
  322. * change in the future, once I've found all the device
  323. * tree bugs in older machines & worked around them
  324. */
  325. if (insert_resource(parent_res, res))
  326. printk(KERN_WARNING "Can't request resource %d for MacIO"
  327. " device %s\n", i, dev->ofdev.dev.bus_id);
  328. }
  329. }
  330. dev->n_resources = j;
  331. if (of_device_register(&dev->ofdev) != 0) {
  332. printk(KERN_DEBUG"macio: device registration error for %s!\n",
  333. dev->ofdev.dev.bus_id);
  334. kfree(dev);
  335. return NULL;
  336. }
  337. return dev;
  338. }
  339. static int macio_skip_device(struct device_node *np)
  340. {
  341. if (strncmp(np->name, "battery", 7) == 0)
  342. return 1;
  343. if (strncmp(np->name, "escc-legacy", 11) == 0)
  344. return 1;
  345. return 0;
  346. }
  347. /**
  348. * macio_pci_add_devices - Adds sub-devices of mac-io to the device tree
  349. * @chip: pointer to the macio_chip holding the devices
  350. *
  351. * This function will do the job of extracting devices from the
  352. * Open Firmware device tree, build macio_dev structures and add
  353. * them to the Linux device tree.
  354. *
  355. * For now, childs of media-bay are added now as well. This will
  356. * change rsn though.
  357. */
  358. static void macio_pci_add_devices(struct macio_chip *chip)
  359. {
  360. struct device_node *np, *pnode;
  361. struct macio_dev *rdev, *mdev, *mbdev = NULL, *sdev = NULL;
  362. struct device *parent = NULL;
  363. struct resource *root_res = &iomem_resource;
  364. /* Add a node for the macio bus itself */
  365. #ifdef CONFIG_PCI
  366. if (chip->lbus.pdev) {
  367. parent = &chip->lbus.pdev->dev;
  368. root_res = &chip->lbus.pdev->resource[0];
  369. }
  370. #endif
  371. pnode = of_node_get(chip->of_node);
  372. if (pnode == NULL)
  373. return;
  374. /* Add macio itself to hierarchy */
  375. rdev = macio_add_one_device(chip, parent, pnode, NULL, root_res);
  376. if (rdev == NULL)
  377. return;
  378. root_res = &rdev->resource[0];
  379. /* First scan 1st level */
  380. for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) {
  381. if (!macio_skip_device(np)) {
  382. of_node_get(np);
  383. mdev = macio_add_one_device(chip, &rdev->ofdev.dev, np, NULL, root_res);
  384. if (mdev == NULL)
  385. of_node_put(np);
  386. else if (strncmp(np->name, "media-bay", 9) == 0)
  387. mbdev = mdev;
  388. else if (strncmp(np->name, "escc", 4) == 0)
  389. sdev = mdev;
  390. }
  391. }
  392. /* Add media bay devices if any */
  393. if (mbdev)
  394. for (np = NULL; (np = of_get_next_child(mbdev->ofdev.node, np)) != NULL;)
  395. if (!macio_skip_device(np)) {
  396. of_node_get(np);
  397. if (macio_add_one_device(chip, &mbdev->ofdev.dev, np, mbdev,
  398. root_res) == NULL)
  399. of_node_put(np);
  400. }
  401. /* Add serial ports if any */
  402. if (sdev) {
  403. for (np = NULL; (np = of_get_next_child(sdev->ofdev.node, np)) != NULL;)
  404. if (!macio_skip_device(np)) {
  405. of_node_get(np);
  406. if (macio_add_one_device(chip, &sdev->ofdev.dev, np, NULL,
  407. root_res) == NULL)
  408. of_node_put(np);
  409. }
  410. }
  411. }
  412. /**
  413. * macio_register_driver - Registers a new MacIO device driver
  414. * @drv: pointer to the driver definition structure
  415. */
  416. int macio_register_driver(struct macio_driver *drv)
  417. {
  418. int count = 0;
  419. /* initialize common driver fields */
  420. drv->driver.name = drv->name;
  421. drv->driver.bus = &macio_bus_type;
  422. drv->driver.probe = macio_device_probe;
  423. drv->driver.remove = macio_device_remove;
  424. drv->driver.shutdown = macio_device_shutdown;
  425. /* register with core */
  426. count = driver_register(&drv->driver);
  427. return count ? count : 1;
  428. }
  429. /**
  430. * macio_unregister_driver - Unregisters a new MacIO device driver
  431. * @drv: pointer to the driver definition structure
  432. */
  433. void macio_unregister_driver(struct macio_driver *drv)
  434. {
  435. driver_unregister(&drv->driver);
  436. }
  437. /**
  438. * macio_request_resource - Request an MMIO resource
  439. * @dev: pointer to the device holding the resource
  440. * @resource_no: resource number to request
  441. * @name: resource name
  442. *
  443. * Mark memory region number @resource_no associated with MacIO
  444. * device @dev as being reserved by owner @name. Do not access
  445. * any address inside the memory regions unless this call returns
  446. * successfully.
  447. *
  448. * Returns 0 on success, or %EBUSY on error. A warning
  449. * message is also printed on failure.
  450. */
  451. int macio_request_resource(struct macio_dev *dev, int resource_no, const char *name)
  452. {
  453. if (macio_resource_len(dev, resource_no) == 0)
  454. return 0;
  455. if (!request_mem_region(macio_resource_start(dev, resource_no),
  456. macio_resource_len(dev, resource_no),
  457. name))
  458. goto err_out;
  459. return 0;
  460. err_out:
  461. printk (KERN_WARNING "MacIO: Unable to reserve resource #%d:%lx@%lx"
  462. " for device %s\n",
  463. resource_no,
  464. macio_resource_len(dev, resource_no),
  465. macio_resource_start(dev, resource_no),
  466. dev->ofdev.dev.bus_id);
  467. return -EBUSY;
  468. }
  469. /**
  470. * macio_release_resource - Release an MMIO resource
  471. * @dev: pointer to the device holding the resource
  472. * @resource_no: resource number to release
  473. */
  474. void macio_release_resource(struct macio_dev *dev, int resource_no)
  475. {
  476. if (macio_resource_len(dev, resource_no) == 0)
  477. return;
  478. release_mem_region(macio_resource_start(dev, resource_no),
  479. macio_resource_len(dev, resource_no));
  480. }
  481. /**
  482. * macio_request_resources - Reserve all memory resources
  483. * @dev: MacIO device whose resources are to be reserved
  484. * @name: Name to be associated with resource.
  485. *
  486. * Mark all memory regions associated with MacIO device @dev as
  487. * being reserved by owner @name. Do not access any address inside
  488. * the memory regions unless this call returns successfully.
  489. *
  490. * Returns 0 on success, or %EBUSY on error. A warning
  491. * message is also printed on failure.
  492. */
  493. int macio_request_resources(struct macio_dev *dev, const char *name)
  494. {
  495. int i;
  496. for (i = 0; i < dev->n_resources; i++)
  497. if (macio_request_resource(dev, i, name))
  498. goto err_out;
  499. return 0;
  500. err_out:
  501. while(--i >= 0)
  502. macio_release_resource(dev, i);
  503. return -EBUSY;
  504. }
  505. /**
  506. * macio_release_resources - Release reserved memory resources
  507. * @dev: MacIO device whose resources were previously reserved
  508. */
  509. void macio_release_resources(struct macio_dev *dev)
  510. {
  511. int i;
  512. for (i = 0; i < dev->n_resources; i++)
  513. macio_release_resource(dev, i);
  514. }
  515. #ifdef CONFIG_PCI
  516. static int __devinit macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  517. {
  518. struct device_node* np;
  519. struct macio_chip* chip;
  520. if (ent->vendor != PCI_VENDOR_ID_APPLE)
  521. return -ENODEV;
  522. /* Note regarding refcounting: We assume pci_device_to_OF_node() is ported
  523. * to new OF APIs and returns a node with refcount incremented. This isn't
  524. * the case today, but on the other hand ppc32 doesn't do refcounting. This
  525. * will have to be fixed when going to ppc64. --BenH.
  526. */
  527. np = pci_device_to_OF_node(pdev);
  528. if (np == NULL)
  529. return -ENODEV;
  530. /* This assumption is wrong, fix that here for now until I fix the arch */
  531. of_node_get(np);
  532. /* We also assume that pmac_feature will have done a get() on nodes stored
  533. * in the macio chips array
  534. */
  535. chip = macio_find(np, macio_unknown);
  536. of_node_put(np);
  537. if (chip == NULL)
  538. return -ENODEV;
  539. /* XXX Need locking ??? */
  540. if (chip->lbus.pdev == NULL) {
  541. chip->lbus.pdev = pdev;
  542. chip->lbus.chip = chip;
  543. pci_set_drvdata(pdev, &chip->lbus);
  544. pci_set_master(pdev);
  545. }
  546. printk(KERN_INFO "MacIO PCI driver attached to %s chipset\n",
  547. chip->name);
  548. /*
  549. * HACK ALERT: The WallStreet PowerBook and some OHare based machines
  550. * have 2 macio ASICs. I must probe the "main" one first or IDE ordering
  551. * will be incorrect. So I put on "hold" the second one since it seem to
  552. * appear first on PCI
  553. */
  554. if (chip->type == macio_gatwick || chip->type == macio_ohareII)
  555. if (macio_chips[0].lbus.pdev == NULL) {
  556. macio_on_hold = chip;
  557. return 0;
  558. }
  559. macio_pci_add_devices(chip);
  560. if (macio_on_hold && macio_chips[0].lbus.pdev != NULL) {
  561. macio_pci_add_devices(macio_on_hold);
  562. macio_on_hold = NULL;
  563. }
  564. return 0;
  565. }
  566. static void __devexit macio_pci_remove(struct pci_dev* pdev)
  567. {
  568. panic("removing of macio-asic not supported !\n");
  569. }
  570. /*
  571. * MacIO is matched against any Apple ID, it's probe() function
  572. * will then decide wether it applies or not
  573. */
  574. static const struct pci_device_id __devinitdata pci_ids [] = { {
  575. .vendor = PCI_VENDOR_ID_APPLE,
  576. .device = PCI_ANY_ID,
  577. .subvendor = PCI_ANY_ID,
  578. .subdevice = PCI_ANY_ID,
  579. }, { /* end: all zeroes */ }
  580. };
  581. MODULE_DEVICE_TABLE (pci, pci_ids);
  582. /* pci driver glue; this is a "new style" PCI driver module */
  583. static struct pci_driver macio_pci_driver = {
  584. .name = (char *) "macio",
  585. .id_table = pci_ids,
  586. .probe = macio_pci_probe,
  587. .remove = macio_pci_remove,
  588. };
  589. #endif /* CONFIG_PCI */
  590. static int __init macio_module_init (void)
  591. {
  592. #ifdef CONFIG_PCI
  593. int rc;
  594. rc = pci_register_driver(&macio_pci_driver);
  595. if (rc)
  596. return rc;
  597. #endif /* CONFIG_PCI */
  598. return 0;
  599. }
  600. module_init(macio_module_init);
  601. EXPORT_SYMBOL(macio_register_driver);
  602. EXPORT_SYMBOL(macio_unregister_driver);
  603. EXPORT_SYMBOL(macio_dev_get);
  604. EXPORT_SYMBOL(macio_dev_put);
  605. EXPORT_SYMBOL(macio_request_resource);
  606. EXPORT_SYMBOL(macio_release_resource);
  607. EXPORT_SYMBOL(macio_request_resources);
  608. EXPORT_SYMBOL(macio_release_resources);