Lines Matching refs:bay

63 #define MB_FCR32(bay, r)	((bay)->base + ((r) >> 2))  argument
64 #define MB_FCR8(bay, r) (((volatile u8*)((bay)->base)) + (r)) argument
66 #define MB_IN32(bay,r) (in_le32(MB_FCR32(bay,r))) argument
67 #define MB_OUT32(bay,r,v) (out_le32(MB_FCR32(bay,r), (v))) argument
68 #define MB_BIS(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) | (v))) argument
69 #define MB_BIC(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) & ~(v))) argument
70 #define MB_IN8(bay,r) (in_8(MB_FCR8(bay,r))) argument
71 #define MB_OUT8(bay,r,v) (out_8(MB_FCR8(bay,r), (v))) argument
77 u8 (*content)(struct media_bay_info* bay);
78 void (*power)(struct media_bay_info* bay, int on_off);
79 int (*setup_bus)(struct media_bay_info* bay, u8 device_id);
80 void (*un_reset)(struct media_bay_info* bay);
81 void (*un_reset_ide)(struct media_bay_info* bay);
185 ohare_mb_content(struct media_bay_info *bay) in ohare_mb_content() argument
187 return (MB_IN32(bay, OHARE_MBCR) >> 12) & 7; in ohare_mb_content()
191 heathrow_mb_content(struct media_bay_info *bay) in heathrow_mb_content() argument
193 return (MB_IN32(bay, HEATHROW_MBCR) >> 12) & 7; in heathrow_mb_content()
197 keylargo_mb_content(struct media_bay_info *bay) in keylargo_mb_content() argument
201 new_gpio = MB_IN8(bay, KL_GPIO_MEDIABAY_IRQ) & KEYLARGO_GPIO_INPUT_DATA; in keylargo_mb_content()
203 bay->cached_gpio = new_gpio; in keylargo_mb_content()
205 } else if (bay->cached_gpio != new_gpio) { in keylargo_mb_content()
206 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE); in keylargo_mb_content()
207 (void)MB_IN32(bay, KEYLARGO_MBCR); in keylargo_mb_content()
209 MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F); in keylargo_mb_content()
210 (void)MB_IN32(bay, KEYLARGO_MBCR); in keylargo_mb_content()
212 bay->cached_gpio = new_gpio; in keylargo_mb_content()
214 return (MB_IN32(bay, KEYLARGO_MBCR) >> 4) & 7; in keylargo_mb_content()
223 ohare_mb_power(struct media_bay_info* bay, int on_off) in ohare_mb_power() argument
227 MB_BIC(bay, OHARE_FCR, OH_BAY_RESET_N); in ohare_mb_power()
228 MB_BIC(bay, OHARE_FCR, OH_BAY_POWER_N); in ohare_mb_power()
231 MB_BIC(bay, OHARE_FCR, OH_BAY_DEV_MASK); in ohare_mb_power()
232 MB_BIC(bay, OHARE_FCR, OH_FLOPPY_ENABLE); in ohare_mb_power()
234 MB_BIS(bay, OHARE_FCR, OH_BAY_POWER_N); in ohare_mb_power()
235 MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N); in ohare_mb_power()
236 MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N); in ohare_mb_power()
238 MB_BIC(bay, OHARE_MBCR, 0x00000F00); in ohare_mb_power()
242 heathrow_mb_power(struct media_bay_info* bay, int on_off) in heathrow_mb_power() argument
246 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_RESET_N); in heathrow_mb_power()
247 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_POWER_N); in heathrow_mb_power()
250 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_DEV_MASK); in heathrow_mb_power()
251 MB_BIC(bay, HEATHROW_FCR, HRW_SWIM_ENABLE); in heathrow_mb_power()
253 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_POWER_N); in heathrow_mb_power()
254 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N); in heathrow_mb_power()
255 MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N); in heathrow_mb_power()
257 MB_BIC(bay, HEATHROW_MBCR, 0x00000F00); in heathrow_mb_power()
261 keylargo_mb_power(struct media_bay_info* bay, int on_off) in keylargo_mb_power() argument
265 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET); in keylargo_mb_power()
266 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER); in keylargo_mb_power()
269 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK); in keylargo_mb_power()
270 MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE); in keylargo_mb_power()
272 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER); in keylargo_mb_power()
273 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET); in keylargo_mb_power()
274 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N); in keylargo_mb_power()
276 MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F); in keylargo_mb_power()
285 ohare_mb_setup_bus(struct media_bay_info* bay, u8 device_id) in ohare_mb_setup_bus() argument
290 MB_BIS(bay, OHARE_FCR, OH_BAY_FLOPPY_ENABLE); in ohare_mb_setup_bus()
291 MB_BIS(bay, OHARE_FCR, OH_FLOPPY_ENABLE); in ohare_mb_setup_bus()
294 MB_BIC(bay, OHARE_FCR, OH_IDE1_RESET_N); in ohare_mb_setup_bus()
295 MB_BIS(bay, OHARE_FCR, OH_BAY_IDE_ENABLE); in ohare_mb_setup_bus()
298 MB_BIS(bay, OHARE_FCR, OH_BAY_PCI_ENABLE); in ohare_mb_setup_bus()
305 heathrow_mb_setup_bus(struct media_bay_info* bay, u8 device_id) in heathrow_mb_setup_bus() argument
310 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_FLOPPY_ENABLE); in heathrow_mb_setup_bus()
311 MB_BIS(bay, HEATHROW_FCR, HRW_SWIM_ENABLE); in heathrow_mb_setup_bus()
314 MB_BIC(bay, HEATHROW_FCR, HRW_IDE1_RESET_N); in heathrow_mb_setup_bus()
315 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_IDE_ENABLE); in heathrow_mb_setup_bus()
318 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_PCI_ENABLE); in heathrow_mb_setup_bus()
325 keylargo_mb_setup_bus(struct media_bay_info* bay, u8 device_id) in keylargo_mb_setup_bus() argument
329 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_IDE_ENABLE); in keylargo_mb_setup_bus()
330 MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N); in keylargo_mb_setup_bus()
331 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE); in keylargo_mb_setup_bus()
334 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_PCI_ENABLE); in keylargo_mb_setup_bus()
337 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_SOUND_ENABLE); in keylargo_mb_setup_bus()
348 ohare_mb_un_reset(struct media_bay_info* bay) in ohare_mb_un_reset() argument
350 MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N); in ohare_mb_un_reset()
354 heathrow_mb_un_reset(struct media_bay_info* bay) in heathrow_mb_un_reset() argument
356 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N); in heathrow_mb_un_reset()
360 keylargo_mb_un_reset(struct media_bay_info* bay) in keylargo_mb_un_reset() argument
362 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET); in keylargo_mb_un_reset()
366 ohare_mb_un_reset_ide(struct media_bay_info* bay) in ohare_mb_un_reset_ide() argument
368 MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N); in ohare_mb_un_reset_ide()
372 heathrow_mb_un_reset_ide(struct media_bay_info* bay) in heathrow_mb_un_reset_ide() argument
374 MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N); in heathrow_mb_un_reset_ide()
378 keylargo_mb_un_reset_ide(struct media_bay_info* bay) in keylargo_mb_un_reset_ide() argument
380 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N); in keylargo_mb_un_reset_ide()
384 set_mb_power(struct media_bay_info* bay, int onoff) in set_mb_power() argument
388 bay->ops->power(bay, 1); in set_mb_power()
389 bay->state = mb_powering_up; in set_mb_power()
390 MBDBG("mediabay%d: powering up\n", bay->index); in set_mb_power()
393 bay->ops->power(bay, 0); in set_mb_power()
394 bay->state = mb_powering_down; in set_mb_power()
395 MBDBG("mediabay%d: powering down\n", bay->index); in set_mb_power()
397 bay->timer = MS_TO_HZ(MB_POWER_DELAY); in set_mb_power()
401 poll_media_bay(struct media_bay_info* bay) in poll_media_bay() argument
403 int id = bay->ops->content(bay); in poll_media_bay()
405 if (id == bay->last_value) { in poll_media_bay()
406 if (id != bay->content_id in poll_media_bay()
407 && ++bay->value_count >= MS_TO_HZ(MB_STABLE_DELAY)) { in poll_media_bay()
410 if ((id != MB_NO) && (bay->content_id != MB_NO)) { in poll_media_bay()
412 MBDBG("mediabay%d: forcing MB_NO\n", bay->index); in poll_media_bay()
414 MBDBG("mediabay%d: switching to %d\n", bay->index, id); in poll_media_bay()
415 set_mb_power(bay, id != MB_NO); in poll_media_bay()
416 bay->content_id = id; in poll_media_bay()
419 bay->cd_retry = 0; in poll_media_bay()
421 printk(KERN_INFO "media bay %d is empty\n", bay->index); in poll_media_bay()
425 bay->last_value = id; in poll_media_bay()
426 bay->value_count = 0; in poll_media_bay()
504 struct media_bay_info* bay = &media_bays[i]; in media_bay_step() local
507 if (bay->state != mb_powering_down) in media_bay_step()
508 poll_media_bay(bay); in media_bay_step()
511 if ((bay->state != mb_ide_waiting) && (bay->timer != 0) && ((--bay->timer) != 0)) in media_bay_step()
514 switch(bay->state) { in media_bay_step()
516 if (bay->ops->setup_bus(bay, bay->last_value) < 0) { in media_bay_step()
517 MBDBG("mediabay%d: device not supported (kind:%d)\n", i, bay->content_id); in media_bay_step()
518 set_mb_power(bay, 0); in media_bay_step()
521 bay->timer = MS_TO_HZ(MB_RESET_DELAY); in media_bay_step()
522 bay->state = mb_enabling_bay; in media_bay_step()
523 MBDBG("mediabay%d: enabling (kind:%d)\n", i, bay->content_id); in media_bay_step()
526 bay->ops->un_reset(bay); in media_bay_step()
527 bay->timer = MS_TO_HZ(MB_SETUP_DELAY); in media_bay_step()
528 bay->state = mb_resetting; in media_bay_step()
529 MBDBG("mediabay%d: waiting reset (kind:%d)\n", i, bay->content_id); in media_bay_step()
533 if (bay->content_id != MB_CD) { in media_bay_step()
534 MBDBG("mediabay%d: bay is up (kind:%d)\n", i, bay->content_id); in media_bay_step()
535 bay->state = mb_up; in media_bay_step()
539 MBDBG("mediabay%d: waiting IDE reset (kind:%d)\n", i, bay->content_id); in media_bay_step()
540 bay->ops->un_reset_ide(bay); in media_bay_step()
541 bay->timer = MS_TO_HZ(MB_IDE_WAIT); in media_bay_step()
542 bay->state = mb_ide_resetting; in media_bay_step()
545 set_mb_power(bay, 0); in media_bay_step()
551 bay->timer = MS_TO_HZ(MB_IDE_TIMEOUT); in media_bay_step()
552 bay->state = mb_ide_waiting; in media_bay_step()
553 MBDBG("mediabay%d: waiting IDE ready (kind:%d)\n", i, bay->content_id); in media_bay_step()
557 if (bay->cd_base == 0) { in media_bay_step()
558 bay->timer = 0; in media_bay_step()
559 bay->state = mb_up; in media_bay_step()
563 bay->timer = 0; in media_bay_step()
564 bay->state = mb_up; in media_bay_step()
565 if (bay->cd_index < 0) { in media_bay_step()
567 bay->cd_index = ide_register(bay->cd_base, 0, bay->cd_irq); in media_bay_step()
570 if (bay->cd_index == -1) { in media_bay_step()
572 bay->cd_retry++; in media_bay_step()
574 set_mb_power(bay, 0); in media_bay_step()
576 printk(KERN_DEBUG "media-bay %d is ide %d\n", i, bay->cd_index); in media_bay_step()
580 } else if (bay->timer > 0) in media_bay_step()
581 bay->timer--; in media_bay_step()
582 if (bay->timer == 0) { in media_bay_step()
585 set_mb_power(bay, 0); in media_bay_step()
591 bay->state = mb_empty; in media_bay_step()
593 if (bay->cd_index >= 0) { in media_bay_step()
595 bay->cd_index); in media_bay_step()
596 ide_unregister(bay->cd_index); in media_bay_step()
597 bay->cd_index = -1; in media_bay_step()
599 if (bay->cd_retry) { in media_bay_step()
600 if (bay->cd_retry > MAX_CD_RETRIES) { in media_bay_step()
605 bay->content_id = MB_NO; in media_bay_step()
655 struct media_bay_info* bay; in mb_notify_sleep() local
665 bay = &media_bays[i]; in mb_notify_sleep()
666 set_mb_power(bay, 0); in mb_notify_sleep()
672 bay = &media_bays[i]; in mb_notify_sleep()
678 set_mb_power(bay, 0); in mb_notify_sleep()
680 if (bay->ops->content(bay) != bay->content_id) in mb_notify_sleep()
682 set_mb_power(bay, 1); in mb_notify_sleep()
683 bay->last_value = bay->content_id; in mb_notify_sleep()
684 bay->value_count = MS_TO_HZ(MB_STABLE_DELAY); in mb_notify_sleep()
685 bay->timer = MS_TO_HZ(MB_POWER_DELAY); in mb_notify_sleep()
687 bay->cd_retry = 0; in mb_notify_sleep()
757 struct media_bay_info* bay = &media_bays[n]; in media_bay_init() local
763 bay->mb_type = mb_ohare; in media_bay_init()
766 bay->mb_type = mb_keylargo; in media_bay_init()
767 bay->ops = &keylargo_mb_ops; in media_bay_init()
769 bay->mb_type = mb_heathrow; in media_bay_init()
770 bay->ops = &heathrow_mb_ops; in media_bay_init()
772 bay->mb_type = mb_ohare; in media_bay_init()
773 bay->ops = &ohare_mb_ops; in media_bay_init()
779 bay->base = (volatile u32*)ioremap(np->parent->addrs[0].address, 0x1000); in media_bay_init()
782 if (bay->mb_type == mb_keylargo) in media_bay_init()
783 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE); in media_bay_init()
800 printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", n, bay->ops->name); in media_bay_init()
801 bay->dev_node = np; in media_bay_init()
802 bay->index = n; in media_bay_init()
805 set_mb_power(bay, 0); in media_bay_init()
807 bay->content_id = MB_NO; in media_bay_init()
808 bay->last_value = bay->ops->content(bay); in media_bay_init()
809 bay->value_count = MS_TO_HZ(MB_STABLE_DELAY); in media_bay_init()
810 bay->state = mb_empty; in media_bay_init()
814 } while((bay->state != mb_empty) && in media_bay_init()
815 (bay->state != mb_up)); in media_bay_init()