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