Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / macintosh / mediabay.c
blobeab7e83c11c4f029de7cd0ee0165ebac02c6942a
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Driver for the media bay on the PowerBook 3400 and 2400.
5 * Copyright (C) 1998 Paul Mackerras.
7 * Various evolutions by Benjamin Herrenschmidt & Henry Worth
8 */
9 #include <linux/types.h>
10 #include <linux/errno.h>
11 #include <linux/kernel.h>
12 #include <linux/delay.h>
13 #include <linux/sched.h>
14 #include <linux/timer.h>
15 #include <linux/stddef.h>
16 #include <linux/init.h>
17 #include <linux/kthread.h>
18 #include <linux/mutex.h>
19 #include <linux/pgtable.h>
20 #include <asm/prom.h>
21 #include <asm/io.h>
22 #include <asm/machdep.h>
23 #include <asm/pmac_feature.h>
24 #include <asm/mediabay.h>
25 #include <asm/sections.h>
26 #include <asm/ohare.h>
27 #include <asm/heathrow.h>
28 #include <asm/keylargo.h>
29 #include <linux/adb.h>
30 #include <linux/pmu.h>
32 #define MB_FCR32(bay, r) ((bay)->base + ((r) >> 2))
33 #define MB_FCR8(bay, r) (((volatile u8 __iomem *)((bay)->base)) + (r))
35 #define MB_IN32(bay,r) (in_le32(MB_FCR32(bay,r)))
36 #define MB_OUT32(bay,r,v) (out_le32(MB_FCR32(bay,r), (v)))
37 #define MB_BIS(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) | (v)))
38 #define MB_BIC(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) & ~(v)))
39 #define MB_IN8(bay,r) (in_8(MB_FCR8(bay,r)))
40 #define MB_OUT8(bay,r,v) (out_8(MB_FCR8(bay,r), (v)))
42 struct media_bay_info;
44 struct mb_ops {
45 char* name;
46 void (*init)(struct media_bay_info *bay);
47 u8 (*content)(struct media_bay_info *bay);
48 void (*power)(struct media_bay_info *bay, int on_off);
49 int (*setup_bus)(struct media_bay_info *bay, u8 device_id);
50 void (*un_reset)(struct media_bay_info *bay);
51 void (*un_reset_ide)(struct media_bay_info *bay);
54 struct media_bay_info {
55 u32 __iomem *base;
56 int content_id;
57 int state;
58 int last_value;
59 int value_count;
60 int timer;
61 struct macio_dev *mdev;
62 const struct mb_ops* ops;
63 int index;
64 int cached_gpio;
65 int sleeping;
66 int user_lock;
67 struct mutex lock;
70 #define MAX_BAYS 2
72 static struct media_bay_info media_bays[MAX_BAYS];
73 static int media_bay_count = 0;
76 * Wait that number of ms between each step in normal polling mode
78 #define MB_POLL_DELAY 25
81 * Consider the media-bay ID value stable if it is the same for
82 * this number of milliseconds
84 #define MB_STABLE_DELAY 100
86 /* Wait after powering up the media bay this delay in ms
87 * timeout bumped for some powerbooks
89 #define MB_POWER_DELAY 200
92 * Hold the media-bay reset signal true for this many ticks
93 * after a device is inserted before releasing it.
95 #define MB_RESET_DELAY 50
98 * Wait this long after the reset signal is released and before doing
99 * further operations. After this delay, the IDE reset signal is released
100 * too for an IDE device
102 #define MB_SETUP_DELAY 100
105 * Wait this many ticks after an IDE device (e.g. CD-ROM) is inserted
106 * (or until the device is ready) before calling into the driver
108 #define MB_IDE_WAIT 1000
111 * States of a media bay
113 enum {
114 mb_empty = 0, /* Idle */
115 mb_powering_up, /* power bit set, waiting MB_POWER_DELAY */
116 mb_enabling_bay, /* enable bits set, waiting MB_RESET_DELAY */
117 mb_resetting, /* reset bit unset, waiting MB_SETUP_DELAY */
118 mb_ide_resetting, /* IDE reset bit unser, waiting MB_IDE_WAIT */
119 mb_up, /* Media bay full */
120 mb_powering_down /* Powering down (avoid too fast down/up) */
123 #define MB_POWER_SOUND 0x08
124 #define MB_POWER_FLOPPY 0x04
125 #define MB_POWER_ATA 0x02
126 #define MB_POWER_PCI 0x01
127 #define MB_POWER_OFF 0x00
130 * Functions for polling content of media bay
133 static u8
134 ohare_mb_content(struct media_bay_info *bay)
136 return (MB_IN32(bay, OHARE_MBCR) >> 12) & 7;
139 static u8
140 heathrow_mb_content(struct media_bay_info *bay)
142 return (MB_IN32(bay, HEATHROW_MBCR) >> 12) & 7;
145 static u8
146 keylargo_mb_content(struct media_bay_info *bay)
148 int new_gpio;
150 new_gpio = MB_IN8(bay, KL_GPIO_MEDIABAY_IRQ) & KEYLARGO_GPIO_INPUT_DATA;
151 if (new_gpio) {
152 bay->cached_gpio = new_gpio;
153 return MB_NO;
154 } else if (bay->cached_gpio != new_gpio) {
155 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
156 (void)MB_IN32(bay, KEYLARGO_MBCR);
157 udelay(5);
158 MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F);
159 (void)MB_IN32(bay, KEYLARGO_MBCR);
160 udelay(5);
161 bay->cached_gpio = new_gpio;
163 return (MB_IN32(bay, KEYLARGO_MBCR) >> 4) & 7;
167 * Functions for powering up/down the bay, puts the bay device
168 * into reset state as well
171 static void
172 ohare_mb_power(struct media_bay_info* bay, int on_off)
174 if (on_off) {
175 /* Power up device, assert it's reset line */
176 MB_BIC(bay, OHARE_FCR, OH_BAY_RESET_N);
177 MB_BIC(bay, OHARE_FCR, OH_BAY_POWER_N);
178 } else {
179 /* Disable all devices */
180 MB_BIC(bay, OHARE_FCR, OH_BAY_DEV_MASK);
181 MB_BIC(bay, OHARE_FCR, OH_FLOPPY_ENABLE);
182 /* Cut power from bay, release reset line */
183 MB_BIS(bay, OHARE_FCR, OH_BAY_POWER_N);
184 MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N);
185 MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N);
187 MB_BIC(bay, OHARE_MBCR, 0x00000F00);
190 static void
191 heathrow_mb_power(struct media_bay_info* bay, int on_off)
193 if (on_off) {
194 /* Power up device, assert it's reset line */
195 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
196 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_POWER_N);
197 } else {
198 /* Disable all devices */
199 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_DEV_MASK);
200 MB_BIC(bay, HEATHROW_FCR, HRW_SWIM_ENABLE);
201 /* Cut power from bay, release reset line */
202 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_POWER_N);
203 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
204 MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
206 MB_BIC(bay, HEATHROW_MBCR, 0x00000F00);
209 static void
210 keylargo_mb_power(struct media_bay_info* bay, int on_off)
212 if (on_off) {
213 /* Power up device, assert it's reset line */
214 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
215 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER);
216 } else {
217 /* Disable all devices */
218 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK);
219 MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE);
220 /* Cut power from bay, release reset line */
221 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER);
222 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
223 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
225 MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F);
229 * Functions for configuring the media bay for a given type of device,
230 * enable the related busses
233 static int
234 ohare_mb_setup_bus(struct media_bay_info* bay, u8 device_id)
236 switch(device_id) {
237 case MB_FD:
238 case MB_FD1:
239 MB_BIS(bay, OHARE_FCR, OH_BAY_FLOPPY_ENABLE);
240 MB_BIS(bay, OHARE_FCR, OH_FLOPPY_ENABLE);
241 return 0;
242 case MB_CD:
243 MB_BIC(bay, OHARE_FCR, OH_IDE1_RESET_N);
244 MB_BIS(bay, OHARE_FCR, OH_BAY_IDE_ENABLE);
245 return 0;
246 case MB_PCI:
247 MB_BIS(bay, OHARE_FCR, OH_BAY_PCI_ENABLE);
248 return 0;
250 return -ENODEV;
253 static int
254 heathrow_mb_setup_bus(struct media_bay_info* bay, u8 device_id)
256 switch(device_id) {
257 case MB_FD:
258 case MB_FD1:
259 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_FLOPPY_ENABLE);
260 MB_BIS(bay, HEATHROW_FCR, HRW_SWIM_ENABLE);
261 return 0;
262 case MB_CD:
263 MB_BIC(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
264 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_IDE_ENABLE);
265 return 0;
266 case MB_PCI:
267 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_PCI_ENABLE);
268 return 0;
270 return -ENODEV;
273 static int
274 keylargo_mb_setup_bus(struct media_bay_info* bay, u8 device_id)
276 switch(device_id) {
277 case MB_CD:
278 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_IDE_ENABLE);
279 MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
280 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE);
281 return 0;
282 case MB_PCI:
283 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_PCI_ENABLE);
284 return 0;
285 case MB_SOUND:
286 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_SOUND_ENABLE);
287 return 0;
289 return -ENODEV;
293 * Functions for tweaking resets
296 static void
297 ohare_mb_un_reset(struct media_bay_info* bay)
299 MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N);
302 static void keylargo_mb_init(struct media_bay_info *bay)
304 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
307 static void heathrow_mb_un_reset(struct media_bay_info* bay)
309 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
312 static void keylargo_mb_un_reset(struct media_bay_info* bay)
314 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
317 static void ohare_mb_un_reset_ide(struct media_bay_info* bay)
319 MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N);
322 static void heathrow_mb_un_reset_ide(struct media_bay_info* bay)
324 MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
327 static void keylargo_mb_un_reset_ide(struct media_bay_info* bay)
329 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
332 static inline void set_mb_power(struct media_bay_info* bay, int onoff)
334 /* Power up up and assert the bay reset line */
335 if (onoff) {
336 bay->ops->power(bay, 1);
337 bay->state = mb_powering_up;
338 pr_debug("mediabay%d: powering up\n", bay->index);
339 } else {
340 /* Make sure everything is powered down & disabled */
341 bay->ops->power(bay, 0);
342 bay->state = mb_powering_down;
343 pr_debug("mediabay%d: powering down\n", bay->index);
345 bay->timer = msecs_to_jiffies(MB_POWER_DELAY);
348 static void poll_media_bay(struct media_bay_info* bay)
350 int id = bay->ops->content(bay);
352 static char *mb_content_types[] = {
353 "a floppy drive",
354 "a floppy drive",
355 "an unsupported audio device",
356 "an ATA device",
357 "an unsupported PCI device",
358 "an unknown device",
361 if (id != bay->last_value) {
362 bay->last_value = id;
363 bay->value_count = 0;
364 return;
366 if (id == bay->content_id)
367 return;
369 bay->value_count += msecs_to_jiffies(MB_POLL_DELAY);
370 if (bay->value_count >= msecs_to_jiffies(MB_STABLE_DELAY)) {
371 /* If the device type changes without going thru
372 * "MB_NO", we force a pass by "MB_NO" to make sure
373 * things are properly reset
375 if ((id != MB_NO) && (bay->content_id != MB_NO)) {
376 id = MB_NO;
377 pr_debug("mediabay%d: forcing MB_NO\n", bay->index);
379 pr_debug("mediabay%d: switching to %d\n", bay->index, id);
380 set_mb_power(bay, id != MB_NO);
381 bay->content_id = id;
382 if (id >= MB_NO || id < 0)
383 printk(KERN_INFO "mediabay%d: Bay is now empty\n", bay->index);
384 else
385 printk(KERN_INFO "mediabay%d: Bay contains %s\n",
386 bay->index, mb_content_types[id]);
390 int check_media_bay(struct macio_dev *baydev)
392 struct media_bay_info* bay;
393 int id;
395 if (baydev == NULL)
396 return MB_NO;
398 /* This returns an instant snapshot, not locking, sine
399 * we may be called with the bay lock held. The resulting
400 * fuzzyness of the result if called at the wrong time is
401 * not actually a huge deal
403 bay = macio_get_drvdata(baydev);
404 if (bay == NULL)
405 return MB_NO;
406 id = bay->content_id;
407 if (bay->state != mb_up)
408 return MB_NO;
409 if (id == MB_FD1)
410 return MB_FD;
411 return id;
413 EXPORT_SYMBOL_GPL(check_media_bay);
415 void lock_media_bay(struct macio_dev *baydev)
417 struct media_bay_info* bay;
419 if (baydev == NULL)
420 return;
421 bay = macio_get_drvdata(baydev);
422 if (bay == NULL)
423 return;
424 mutex_lock(&bay->lock);
425 bay->user_lock = 1;
427 EXPORT_SYMBOL_GPL(lock_media_bay);
429 void unlock_media_bay(struct macio_dev *baydev)
431 struct media_bay_info* bay;
433 if (baydev == NULL)
434 return;
435 bay = macio_get_drvdata(baydev);
436 if (bay == NULL)
437 return;
438 if (bay->user_lock) {
439 bay->user_lock = 0;
440 mutex_unlock(&bay->lock);
443 EXPORT_SYMBOL_GPL(unlock_media_bay);
445 static int mb_broadcast_hotplug(struct device *dev, void *data)
447 struct media_bay_info* bay = data;
448 struct macio_dev *mdev;
449 struct macio_driver *drv;
450 int state;
452 if (dev->bus != &macio_bus_type)
453 return 0;
455 state = bay->state == mb_up ? bay->content_id : MB_NO;
456 if (state == MB_FD1)
457 state = MB_FD;
458 mdev = to_macio_device(dev);
459 drv = to_macio_driver(dev->driver);
460 if (dev->driver && drv->mediabay_event)
461 drv->mediabay_event(mdev, state);
462 return 0;
465 static void media_bay_step(int i)
467 struct media_bay_info* bay = &media_bays[i];
469 /* We don't poll when powering down */
470 if (bay->state != mb_powering_down)
471 poll_media_bay(bay);
473 /* If timer expired run state machine */
474 if (bay->timer != 0) {
475 bay->timer -= msecs_to_jiffies(MB_POLL_DELAY);
476 if (bay->timer > 0)
477 return;
478 bay->timer = 0;
481 switch(bay->state) {
482 case mb_powering_up:
483 if (bay->ops->setup_bus(bay, bay->last_value) < 0) {
484 pr_debug("mediabay%d: device not supported (kind:%d)\n",
485 i, bay->content_id);
486 set_mb_power(bay, 0);
487 break;
489 bay->timer = msecs_to_jiffies(MB_RESET_DELAY);
490 bay->state = mb_enabling_bay;
491 pr_debug("mediabay%d: enabling (kind:%d)\n", i, bay->content_id);
492 break;
493 case mb_enabling_bay:
494 bay->ops->un_reset(bay);
495 bay->timer = msecs_to_jiffies(MB_SETUP_DELAY);
496 bay->state = mb_resetting;
497 pr_debug("mediabay%d: releasing bay reset (kind:%d)\n",
498 i, bay->content_id);
499 break;
500 case mb_resetting:
501 if (bay->content_id != MB_CD) {
502 pr_debug("mediabay%d: bay is up (kind:%d)\n", i,
503 bay->content_id);
504 bay->state = mb_up;
505 device_for_each_child(&bay->mdev->ofdev.dev,
506 bay, mb_broadcast_hotplug);
507 break;
509 pr_debug("mediabay%d: releasing ATA reset (kind:%d)\n",
510 i, bay->content_id);
511 bay->ops->un_reset_ide(bay);
512 bay->timer = msecs_to_jiffies(MB_IDE_WAIT);
513 bay->state = mb_ide_resetting;
514 break;
516 case mb_ide_resetting:
517 pr_debug("mediabay%d: bay is up (kind:%d)\n", i, bay->content_id);
518 bay->state = mb_up;
519 device_for_each_child(&bay->mdev->ofdev.dev,
520 bay, mb_broadcast_hotplug);
521 break;
523 case mb_powering_down:
524 bay->state = mb_empty;
525 device_for_each_child(&bay->mdev->ofdev.dev,
526 bay, mb_broadcast_hotplug);
527 pr_debug("mediabay%d: end of power down\n", i);
528 break;
533 * This procedure runs as a kernel thread to poll the media bay
534 * once each tick and register and unregister the IDE interface
535 * with the IDE driver. It needs to be a thread because
536 * ide_register can't be called from interrupt context.
538 static int media_bay_task(void *x)
540 int i;
542 while (!kthread_should_stop()) {
543 for (i = 0; i < media_bay_count; ++i) {
544 mutex_lock(&media_bays[i].lock);
545 if (!media_bays[i].sleeping)
546 media_bay_step(i);
547 mutex_unlock(&media_bays[i].lock);
550 msleep_interruptible(MB_POLL_DELAY);
552 return 0;
555 static int media_bay_attach(struct macio_dev *mdev,
556 const struct of_device_id *match)
558 struct media_bay_info* bay;
559 u32 __iomem *regbase;
560 struct device_node *ofnode;
561 unsigned long base;
562 int i;
564 ofnode = mdev->ofdev.dev.of_node;
566 if (macio_resource_count(mdev) < 1)
567 return -ENODEV;
568 if (macio_request_resources(mdev, "media-bay"))
569 return -EBUSY;
570 /* Media bay registers are located at the beginning of the
571 * mac-io chip, for now, we trick and align down the first
572 * resource passed in
574 base = macio_resource_start(mdev, 0) & 0xffff0000u;
575 regbase = (u32 __iomem *)ioremap(base, 0x100);
576 if (regbase == NULL) {
577 macio_release_resources(mdev);
578 return -ENOMEM;
581 i = media_bay_count++;
582 bay = &media_bays[i];
583 bay->mdev = mdev;
584 bay->base = regbase;
585 bay->index = i;
586 bay->ops = match->data;
587 bay->sleeping = 0;
588 mutex_init(&bay->lock);
590 /* Init HW probing */
591 if (bay->ops->init)
592 bay->ops->init(bay);
594 printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", i, bay->ops->name);
596 /* Force an immediate detect */
597 set_mb_power(bay, 0);
598 msleep(MB_POWER_DELAY);
599 bay->content_id = MB_NO;
600 bay->last_value = bay->ops->content(bay);
601 bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY);
602 bay->state = mb_empty;
604 /* Mark us ready by filling our mdev data */
605 macio_set_drvdata(mdev, bay);
607 /* Startup kernel thread */
608 if (i == 0)
609 kthread_run(media_bay_task, NULL, "media-bay");
611 return 0;
615 static int media_bay_suspend(struct macio_dev *mdev, pm_message_t state)
617 struct media_bay_info *bay = macio_get_drvdata(mdev);
619 if (state.event != mdev->ofdev.dev.power.power_state.event
620 && (state.event & PM_EVENT_SLEEP)) {
621 mutex_lock(&bay->lock);
622 bay->sleeping = 1;
623 set_mb_power(bay, 0);
624 mutex_unlock(&bay->lock);
625 msleep(MB_POLL_DELAY);
626 mdev->ofdev.dev.power.power_state = state;
628 return 0;
631 static int media_bay_resume(struct macio_dev *mdev)
633 struct media_bay_info *bay = macio_get_drvdata(mdev);
635 if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) {
636 mdev->ofdev.dev.power.power_state = PMSG_ON;
638 /* We re-enable the bay using it's previous content
639 only if it did not change. Note those bozo timings,
640 they seem to help the 3400 get it right.
642 /* Force MB power to 0 */
643 mutex_lock(&bay->lock);
644 set_mb_power(bay, 0);
645 msleep(MB_POWER_DELAY);
646 if (bay->ops->content(bay) != bay->content_id) {
647 printk("mediabay%d: Content changed during sleep...\n", bay->index);
648 mutex_unlock(&bay->lock);
649 return 0;
651 set_mb_power(bay, 1);
652 bay->last_value = bay->content_id;
653 bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY);
654 bay->timer = msecs_to_jiffies(MB_POWER_DELAY);
655 do {
656 msleep(MB_POLL_DELAY);
657 media_bay_step(bay->index);
658 } while((bay->state != mb_empty) &&
659 (bay->state != mb_up));
660 bay->sleeping = 0;
661 mutex_unlock(&bay->lock);
663 return 0;
667 /* Definitions of "ops" structures.
669 static const struct mb_ops ohare_mb_ops = {
670 .name = "Ohare",
671 .content = ohare_mb_content,
672 .power = ohare_mb_power,
673 .setup_bus = ohare_mb_setup_bus,
674 .un_reset = ohare_mb_un_reset,
675 .un_reset_ide = ohare_mb_un_reset_ide,
678 static const struct mb_ops heathrow_mb_ops = {
679 .name = "Heathrow",
680 .content = heathrow_mb_content,
681 .power = heathrow_mb_power,
682 .setup_bus = heathrow_mb_setup_bus,
683 .un_reset = heathrow_mb_un_reset,
684 .un_reset_ide = heathrow_mb_un_reset_ide,
687 static const struct mb_ops keylargo_mb_ops = {
688 .name = "KeyLargo",
689 .init = keylargo_mb_init,
690 .content = keylargo_mb_content,
691 .power = keylargo_mb_power,
692 .setup_bus = keylargo_mb_setup_bus,
693 .un_reset = keylargo_mb_un_reset,
694 .un_reset_ide = keylargo_mb_un_reset_ide,
698 * It seems that the bit for the media-bay interrupt in the IRQ_LEVEL
699 * register is always set when there is something in the media bay.
700 * This causes problems for the interrupt code if we attach an interrupt
701 * handler to the media-bay interrupt, because it tends to go into
702 * an infinite loop calling the media bay interrupt handler.
703 * Therefore we do it all by polling the media bay once each tick.
706 static struct of_device_id media_bay_match[] =
709 .name = "media-bay",
710 .compatible = "keylargo-media-bay",
711 .data = &keylargo_mb_ops,
714 .name = "media-bay",
715 .compatible = "heathrow-media-bay",
716 .data = &heathrow_mb_ops,
719 .name = "media-bay",
720 .compatible = "ohare-media-bay",
721 .data = &ohare_mb_ops,
726 static struct macio_driver media_bay_driver =
728 .driver = {
729 .name = "media-bay",
730 .of_match_table = media_bay_match,
732 .probe = media_bay_attach,
733 .suspend = media_bay_suspend,
734 .resume = media_bay_resume
737 static int __init media_bay_init(void)
739 int i;
741 for (i=0; i<MAX_BAYS; i++) {
742 memset((char *)&media_bays[i], 0, sizeof(struct media_bay_info));
743 media_bays[i].content_id = -1;
745 if (!machine_is(powermac))
746 return 0;
748 macio_register_driver(&media_bay_driver);
750 return 0;
753 device_initcall(media_bay_init);