macio_asic.c 19 KB

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