2 * Driver for the media bay on the PowerBook 3400 and 2400.
4 * Copyright (C) 1998 Paul Mackerras.
6 * Various evolutions by Benjamin Herrenschmidt & Henry Worth
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.
13 #include <linux/config.h>
14 #include <linux/types.h>
15 #include <linux/errno.h>
16 #include <linux/kernel.h>
17 #include <linux/delay.h>
18 #include <linux/sched.h>
19 #include <linux/timer.h>
20 #include <linux/hdreg.h>
21 #include <linux/stddef.h>
22 #include <linux/init.h>
23 #include <linux/ide.h>
25 #include <asm/pgtable.h>
27 #include <asm/machdep.h>
28 #include <asm/pmac_feature.h>
29 #include <asm/mediabay.h>
30 #include <asm/sections.h>
31 #include <asm/ohare.h>
32 #include <asm/heathrow.h>
33 #include <asm/keylargo.h>
34 #include <linux/adb.h>
35 #include <linux/pmu.h>
39 #define MB_IGNORE_SIGNALS
42 #define MBDBG(fmt, arg...) printk(KERN_INFO fmt , ## arg)
44 #define MBDBG(fmt, arg...) do { } while (0)
47 #define MB_FCR32(bay, r) ((bay)->base + ((r) >> 2))
48 #define MB_FCR8(bay, r) (((volatile u8*)((bay)->base)) + (r))
50 #define MB_IN32(bay,r) (in_le32(MB_FCR32(bay,r)))
51 #define MB_OUT32(bay,r,v) (out_le32(MB_FCR32(bay,r), (v)))
52 #define MB_BIS(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) | (v)))
53 #define MB_BIC(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) & ~(v)))
54 #define MB_IN8(bay,r) (in_8(MB_FCR8(bay,r)))
55 #define MB_OUT8(bay,r,v) (out_8(MB_FCR8(bay,r), (v)))
57 struct media_bay_info;
61 void (*init)(struct media_bay_info *bay);
62 u8 (*content)(struct media_bay_info *bay);
63 void (*power)(struct media_bay_info *bay, int on_off);
64 int (*setup_bus)(struct media_bay_info *bay, u8 device_id);
65 void (*un_reset)(struct media_bay_info *bay);
66 void (*un_reset_ide)(struct media_bay_info *bay);
69 struct media_bay_info {
76 struct macio_dev *mdev;
81 struct semaphore lock;
82 #ifdef CONFIG_BLK_DEV_IDE
83 unsigned long cd_base;
93 static struct media_bay_info media_bays[MAX_BAYS];
94 int media_bay_count = 0;
96 #ifdef CONFIG_BLK_DEV_IDE
97 /* check the busy bit in the media-bay ide interface
98 (assumes the media-bay contains an ide device) */
99 #define MB_IDE_READY(i) ((readb(media_bays[i].cd_base + 0x70) & 0x80) == 0)
102 /* Note: All delays are not in milliseconds and converted to HZ relative
103 * values by the macro below
105 #define MS_TO_HZ(ms) ((ms * HZ + 999) / 1000)
108 * Wait that number of ms between each step in normal polling mode
110 #define MB_POLL_DELAY 25
113 * Consider the media-bay ID value stable if it is the same for
114 * this number of milliseconds
116 #define MB_STABLE_DELAY 100
118 /* Wait after powering up the media bay this delay in ms
119 * timeout bumped for some powerbooks
121 #define MB_POWER_DELAY 200
124 * Hold the media-bay reset signal true for this many ticks
125 * after a device is inserted before releasing it.
127 #define MB_RESET_DELAY 50
130 * Wait this long after the reset signal is released and before doing
131 * further operations. After this delay, the IDE reset signal is released
132 * too for an IDE device
134 #define MB_SETUP_DELAY 100
137 * Wait this many ticks after an IDE device (e.g. CD-ROM) is inserted
138 * (or until the device is ready) before waiting for busy bit to disappear
140 #define MB_IDE_WAIT 1000
143 * Timeout waiting for busy bit of an IDE device to go down
145 #define MB_IDE_TIMEOUT 5000
148 * Max retries of the full power up/down sequence for an IDE device
150 #define MAX_CD_RETRIES 3
153 * States of a media bay
156 mb_empty = 0, /* Idle */
157 mb_powering_up, /* power bit set, waiting MB_POWER_DELAY */
158 mb_enabling_bay, /* enable bits set, waiting MB_RESET_DELAY */
159 mb_resetting, /* reset bit unset, waiting MB_SETUP_DELAY */
160 mb_ide_resetting, /* IDE reset bit unser, waiting MB_IDE_WAIT */
161 mb_ide_waiting, /* Waiting for BUSY bit to go away until MB_IDE_TIMEOUT */
162 mb_up, /* Media bay full */
163 mb_powering_down /* Powering down (avoid too fast down/up) */
166 #define MB_POWER_SOUND 0x08
167 #define MB_POWER_FLOPPY 0x04
168 #define MB_POWER_ATA 0x02
169 #define MB_POWER_PCI 0x01
170 #define MB_POWER_OFF 0x00
173 * Functions for polling content of media bay
177 ohare_mb_content(struct media_bay_info *bay)
179 return (MB_IN32(bay, OHARE_MBCR) >> 12) & 7;
183 heathrow_mb_content(struct media_bay_info *bay)
185 return (MB_IN32(bay, HEATHROW_MBCR) >> 12) & 7;
189 keylargo_mb_content(struct media_bay_info *bay)
193 new_gpio = MB_IN8(bay, KL_GPIO_MEDIABAY_IRQ) & KEYLARGO_GPIO_INPUT_DATA;
195 bay->cached_gpio = new_gpio;
197 } else if (bay->cached_gpio != new_gpio) {
198 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
199 (void)MB_IN32(bay, KEYLARGO_MBCR);
201 MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F);
202 (void)MB_IN32(bay, KEYLARGO_MBCR);
204 bay->cached_gpio = new_gpio;
206 return (MB_IN32(bay, KEYLARGO_MBCR) >> 4) & 7;
210 * Functions for powering up/down the bay, puts the bay device
211 * into reset state as well
215 ohare_mb_power(struct media_bay_info* bay, int on_off)
218 /* Power up device, assert it's reset line */
219 MB_BIC(bay, OHARE_FCR, OH_BAY_RESET_N);
220 MB_BIC(bay, OHARE_FCR, OH_BAY_POWER_N);
222 /* Disable all devices */
223 MB_BIC(bay, OHARE_FCR, OH_BAY_DEV_MASK);
224 MB_BIC(bay, OHARE_FCR, OH_FLOPPY_ENABLE);
225 /* Cut power from bay, release reset line */
226 MB_BIS(bay, OHARE_FCR, OH_BAY_POWER_N);
227 MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N);
228 MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N);
230 MB_BIC(bay, OHARE_MBCR, 0x00000F00);
234 heathrow_mb_power(struct media_bay_info* bay, int on_off)
237 /* Power up device, assert it's reset line */
238 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
239 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_POWER_N);
241 /* Disable all devices */
242 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_DEV_MASK);
243 MB_BIC(bay, HEATHROW_FCR, HRW_SWIM_ENABLE);
244 /* Cut power from bay, release reset line */
245 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_POWER_N);
246 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
247 MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
249 MB_BIC(bay, HEATHROW_MBCR, 0x00000F00);
253 keylargo_mb_power(struct media_bay_info* bay, int on_off)
256 /* Power up device, assert it's reset line */
257 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
258 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER);
260 /* Disable all devices */
261 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK);
262 MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE);
263 /* Cut power from bay, release reset line */
264 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER);
265 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
266 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
268 MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F);
272 * Functions for configuring the media bay for a given type of device,
273 * enable the related busses
277 ohare_mb_setup_bus(struct media_bay_info* bay, u8 device_id)
282 MB_BIS(bay, OHARE_FCR, OH_BAY_FLOPPY_ENABLE);
283 MB_BIS(bay, OHARE_FCR, OH_FLOPPY_ENABLE);
286 MB_BIC(bay, OHARE_FCR, OH_IDE1_RESET_N);
287 MB_BIS(bay, OHARE_FCR, OH_BAY_IDE_ENABLE);
290 MB_BIS(bay, OHARE_FCR, OH_BAY_PCI_ENABLE);
297 heathrow_mb_setup_bus(struct media_bay_info* bay, u8 device_id)
302 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_FLOPPY_ENABLE);
303 MB_BIS(bay, HEATHROW_FCR, HRW_SWIM_ENABLE);
306 MB_BIC(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
307 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_IDE_ENABLE);
310 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_PCI_ENABLE);
317 keylargo_mb_setup_bus(struct media_bay_info* bay, u8 device_id)
321 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_IDE_ENABLE);
322 MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
323 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE);
326 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_PCI_ENABLE);
329 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_SOUND_ENABLE);
336 * Functions for tweaking resets
340 ohare_mb_un_reset(struct media_bay_info* bay)
342 MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N);
345 static void __pmac keylargo_mb_init(struct media_bay_info *bay)
347 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
350 static void __pmac heathrow_mb_un_reset(struct media_bay_info* bay)
352 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
355 static void __pmac keylargo_mb_un_reset(struct media_bay_info* bay)
357 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
360 static void __pmac ohare_mb_un_reset_ide(struct media_bay_info* bay)
362 MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N);
365 static void __pmac heathrow_mb_un_reset_ide(struct media_bay_info* bay)
367 MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
370 static void __pmac keylargo_mb_un_reset_ide(struct media_bay_info* bay)
372 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
375 static inline void __pmac set_mb_power(struct media_bay_info* bay, int onoff)
377 /* Power up up and assert the bay reset line */
379 bay->ops->power(bay, 1);
380 bay->state = mb_powering_up;
381 MBDBG("mediabay%d: powering up\n", bay->index);
383 /* Make sure everything is powered down & disabled */
384 bay->ops->power(bay, 0);
385 bay->state = mb_powering_down;
386 MBDBG("mediabay%d: powering down\n", bay->index);
388 bay->timer = MS_TO_HZ(MB_POWER_DELAY);
391 static void __pmac poll_media_bay(struct media_bay_info* bay)
393 int id = bay->ops->content(bay);
395 if (id == bay->last_value) {
396 if (id != bay->content_id) {
397 bay->value_count += MS_TO_HZ(MB_POLL_DELAY);
398 if (bay->value_count >= MS_TO_HZ(MB_STABLE_DELAY)) {
399 /* If the device type changes without going thru
400 * "MB_NO", we force a pass by "MB_NO" to make sure
401 * things are properly reset
403 if ((id != MB_NO) && (bay->content_id != MB_NO)) {
405 MBDBG("mediabay%d: forcing MB_NO\n", bay->index);
407 MBDBG("mediabay%d: switching to %d\n", bay->index, id);
408 set_mb_power(bay, id != MB_NO);
409 bay->content_id = id;
411 #ifdef CONFIG_BLK_DEV_IDE
414 printk(KERN_INFO "media bay %d is empty\n", bay->index);
419 bay->last_value = id;
420 bay->value_count = 0;
424 int __pmac check_media_bay(struct device_node *which_bay, int what)
426 #ifdef CONFIG_BLK_DEV_IDE
429 for (i=0; i<media_bay_count; i++)
430 if (media_bays[i].mdev && which_bay == media_bays[i].mdev->ofdev.node) {
431 if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up)
433 media_bays[i].cd_index = -1;
436 #endif /* CONFIG_BLK_DEV_IDE */
439 EXPORT_SYMBOL(check_media_bay);
441 int __pmac check_media_bay_by_base(unsigned long base, int what)
443 #ifdef CONFIG_BLK_DEV_IDE
446 for (i=0; i<media_bay_count; i++)
447 if (media_bays[i].mdev && base == media_bays[i].cd_base) {
448 if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up)
450 media_bays[i].cd_index = -1;
458 int __pmac media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
461 #ifdef CONFIG_BLK_DEV_IDE
464 for (i=0; i<media_bay_count; i++) {
465 struct media_bay_info* bay = &media_bays[i];
467 if (bay->mdev && which_bay == bay->mdev->ofdev.node) {
475 if ((MB_CD != bay->content_id) || bay->state != mb_up) {
479 printk(KERN_DEBUG "Registered ide%d for media bay %d\n", index, i);
481 if (MB_IDE_READY(i)) {
482 bay->cd_index = index;
488 printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i);
493 #endif /* CONFIG_BLK_DEV_IDE */
498 static void __pmac media_bay_step(int i)
500 struct media_bay_info* bay = &media_bays[i];
502 /* We don't poll when powering down */
503 if (bay->state != mb_powering_down)
506 /* If timer expired or polling IDE busy, run state machine */
507 if ((bay->state != mb_ide_waiting) && (bay->timer != 0)) {
508 bay->timer -= MS_TO_HZ(MB_POLL_DELAY);
516 if (bay->ops->setup_bus(bay, bay->last_value) < 0) {
517 MBDBG("mediabay%d: device not supported (kind:%d)\n", i, bay->content_id);
518 set_mb_power(bay, 0);
521 bay->timer = MS_TO_HZ(MB_RESET_DELAY);
522 bay->state = mb_enabling_bay;
523 MBDBG("mediabay%d: enabling (kind:%d)\n", i, bay->content_id);
525 case mb_enabling_bay:
526 bay->ops->un_reset(bay);
527 bay->timer = MS_TO_HZ(MB_SETUP_DELAY);
528 bay->state = mb_resetting;
529 MBDBG("mediabay%d: waiting reset (kind:%d)\n", i, bay->content_id);
533 if (bay->content_id != MB_CD) {
534 MBDBG("mediabay%d: bay is up (kind:%d)\n", i, bay->content_id);
538 #ifdef CONFIG_BLK_DEV_IDE
539 MBDBG("mediabay%d: waiting IDE reset (kind:%d)\n", i, bay->content_id);
540 bay->ops->un_reset_ide(bay);
541 bay->timer = MS_TO_HZ(MB_IDE_WAIT);
542 bay->state = mb_ide_resetting;
544 printk(KERN_DEBUG "media-bay %d is ide (not compiled in kernel)\n", i);
545 set_mb_power(bay, 0);
546 #endif /* CONFIG_BLK_DEV_IDE */
549 #ifdef CONFIG_BLK_DEV_IDE
550 case mb_ide_resetting:
551 bay->timer = MS_TO_HZ(MB_IDE_TIMEOUT);
552 bay->state = mb_ide_waiting;
553 MBDBG("mediabay%d: waiting IDE ready (kind:%d)\n", i, bay->content_id);
557 if (bay->cd_base == 0) {
560 MBDBG("mediabay%d: up before IDE init\n", i);
562 } else if (MB_IDE_READY(i)) {
565 if (bay->cd_index < 0) {
568 printk("mediabay %d, registering IDE...\n", i);
570 ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL);
571 hw.irq = bay->cd_irq;
572 hw.chipset = ide_pmac;
573 bay->cd_index = ide_register_hw(&hw, &bay->cd_hwif);
576 if (bay->cd_index == -1) {
577 /* We eventually do a retry */
579 printk("IDE register error\n");
580 set_mb_power(bay, 0);
582 printk(KERN_DEBUG "media-bay %d is ide%d\n", i, bay->cd_index);
583 MBDBG("mediabay %d IDE ready\n", i);
586 } else if (bay->timer > 0)
587 bay->timer -= MS_TO_HZ(MB_POLL_DELAY);
588 if (bay->timer <= 0) {
589 printk("\nIDE Timeout in bay %d !, IDE state is: 0x%02x\n",
590 i, readb(bay->cd_base + 0x70));
591 MBDBG("mediabay%d: nIDE Timeout !\n", i);
592 set_mb_power(bay, 0);
596 #endif /* CONFIG_BLK_DEV_IDE */
598 case mb_powering_down:
599 bay->state = mb_empty;
600 #ifdef CONFIG_BLK_DEV_IDE
601 if (bay->cd_index >= 0) {
602 printk(KERN_DEBUG "Unregistering mb %d ide, index:%d\n", i,
604 ide_unregister_hwif(bay->cd_hwif);
608 if (bay->cd_retry > MAX_CD_RETRIES) {
609 /* Should add an error sound (sort of beep in dmasound) */
610 printk("\nmedia-bay %d, IDE device badly inserted or unrecognised\n", i);
612 /* Force a new power down/up sequence */
613 bay->content_id = MB_NO;
616 #endif /* CONFIG_BLK_DEV_IDE */
617 MBDBG("mediabay%d: end of power down\n", i);
623 * This procedure runs as a kernel thread to poll the media bay
624 * once each tick and register and unregister the IDE interface
625 * with the IDE driver. It needs to be a thread because
626 * ide_register can't be called from interrupt context.
628 static int __pmac media_bay_task(void *x)
632 strcpy(current->comm, "media-bay");
633 #ifdef MB_IGNORE_SIGNALS
634 sigfillset(¤t->blocked);
638 for (i = 0; i < media_bay_count; ++i) {
639 down(&media_bays[i].lock);
640 if (!media_bays[i].sleeping)
642 up(&media_bays[i].lock);
645 current->state = TASK_INTERRUPTIBLE;
646 schedule_timeout(MS_TO_HZ(MB_POLL_DELAY));
647 if (signal_pending(current))
652 static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_match *match)
654 struct media_bay_info* bay;
655 volatile u32 *regbase;
656 struct device_node *ofnode;
659 ofnode = mdev->ofdev.node;
661 if (macio_resource_count(mdev) < 1)
663 if (macio_request_resources(mdev, "media-bay"))
665 /* Media bay registers are located at the beginning of the
666 * mac-io chip, we get the parent address for now (hrm...)
668 regbase = (volatile u32 *)ioremap(ofnode->parent->addrs[0].address, 0x100);
669 if (regbase == NULL) {
670 macio_release_resources(mdev);
674 i = media_bay_count++;
675 bay = &media_bays[i];
679 bay->ops = match->data;
681 init_MUTEX(&bay->lock);
683 /* Init HW probing */
687 printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", i, bay->ops->name);
689 /* Force an immediate detect */
690 set_mb_power(bay, 0);
691 msleep(MB_POWER_DELAY);
692 bay->content_id = MB_NO;
693 bay->last_value = bay->ops->content(bay);
694 bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
695 bay->state = mb_empty;
697 msleep(MB_POLL_DELAY);
699 } while((bay->state != mb_empty) &&
700 (bay->state != mb_up));
702 /* Mark us ready by filling our mdev data */
703 macio_set_drvdata(mdev, bay);
705 /* Startup kernel thread */
707 kernel_thread(media_bay_task, NULL, CLONE_KERNEL);
713 static int __pmac media_bay_suspend(struct macio_dev *mdev, u32 state)
715 struct media_bay_info *bay = macio_get_drvdata(mdev);
717 if (state != mdev->ofdev.dev.power_state && state >= 2) {
720 set_mb_power(bay, 0);
722 msleep(MB_POLL_DELAY);
723 mdev->ofdev.dev.power_state = state;
728 static int __pmac media_bay_resume(struct macio_dev *mdev)
730 struct media_bay_info *bay = macio_get_drvdata(mdev);
732 if (mdev->ofdev.dev.power_state != 0) {
733 mdev->ofdev.dev.power_state = 0;
735 /* We re-enable the bay using it's previous content
736 only if it did not change. Note those bozo timings,
737 they seem to help the 3400 get it right.
739 /* Force MB power to 0 */
741 set_mb_power(bay, 0);
742 msleep(MB_POWER_DELAY);
743 if (bay->ops->content(bay) != bay->content_id) {
744 printk("mediabay%d: content changed during sleep...\n", bay->index);
748 set_mb_power(bay, 1);
749 bay->last_value = bay->content_id;
750 bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
751 bay->timer = MS_TO_HZ(MB_POWER_DELAY);
752 #ifdef CONFIG_BLK_DEV_IDE
756 msleep(MB_POLL_DELAY);
757 media_bay_step(bay->index);
758 } while((bay->state != mb_empty) &&
759 (bay->state != mb_up));
767 /* Definitions of "ops" structures.
769 static struct mb_ops ohare_mb_ops __pmacdata = {
771 .content = ohare_mb_content,
772 .power = ohare_mb_power,
773 .setup_bus = ohare_mb_setup_bus,
774 .un_reset = ohare_mb_un_reset,
775 .un_reset_ide = ohare_mb_un_reset_ide,
778 static struct mb_ops heathrow_mb_ops __pmacdata = {
780 .content = heathrow_mb_content,
781 .power = heathrow_mb_power,
782 .setup_bus = heathrow_mb_setup_bus,
783 .un_reset = heathrow_mb_un_reset,
784 .un_reset_ide = heathrow_mb_un_reset_ide,
787 static struct mb_ops keylargo_mb_ops __pmacdata = {
789 .init = keylargo_mb_init,
790 .content = keylargo_mb_content,
791 .power = keylargo_mb_power,
792 .setup_bus = keylargo_mb_setup_bus,
793 .un_reset = keylargo_mb_un_reset,
794 .un_reset_ide = keylargo_mb_un_reset_ide,
798 * It seems that the bit for the media-bay interrupt in the IRQ_LEVEL
799 * register is always set when there is something in the media bay.
800 * This causes problems for the interrupt code if we attach an interrupt
801 * handler to the media-bay interrupt, because it tends to go into
802 * an infinite loop calling the media bay interrupt handler.
803 * Therefore we do it all by polling the media bay once each tick.
806 static struct of_match media_bay_match[] =
810 .type = OF_ANY_MATCH,
811 .compatible = "keylargo-media-bay",
812 .data = &keylargo_mb_ops,
816 .type = OF_ANY_MATCH,
817 .compatible = "heathrow-media-bay",
818 .data = &heathrow_mb_ops,
822 .type = OF_ANY_MATCH,
823 .compatible = "ohare-media-bay",
824 .data = &ohare_mb_ops,
829 static struct macio_driver media_bay_driver =
832 .match_table = media_bay_match,
833 .probe = media_bay_attach,
834 .suspend = media_bay_suspend,
835 .resume = media_bay_resume
838 static int __init media_bay_init(void)
842 for (i=0; i<MAX_BAYS; i++) {
843 memset((char *)&media_bays[i], 0, sizeof(struct media_bay_info));
844 media_bays[i].content_id = -1;
845 #ifdef CONFIG_BLK_DEV_IDE
846 media_bays[i].cd_index = -1;
849 if (_machine != _MACH_Pmac)
852 macio_register_driver(&media_bay_driver);
857 device_initcall(media_bay_init);