Lines Matching refs:bay
36 #define MB_FCR32(bay, r) ((bay)->base + ((r) >> 2)) argument
37 #define MB_FCR8(bay, r) (((volatile u8 __iomem *)((bay)->base)) + (r)) argument
39 #define MB_IN32(bay,r) (in_le32(MB_FCR32(bay,r))) argument
40 #define MB_OUT32(bay,r,v) (out_le32(MB_FCR32(bay,r), (v))) argument
41 #define MB_BIS(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) | (v))) argument
42 #define MB_BIC(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) & ~(v))) argument
43 #define MB_IN8(bay,r) (in_8(MB_FCR8(bay,r))) argument
44 #define MB_OUT8(bay,r,v) (out_8(MB_FCR8(bay,r), (v))) argument
50 void (*init)(struct media_bay_info *bay);
51 u8 (*content)(struct media_bay_info *bay);
52 void (*power)(struct media_bay_info *bay, int on_off);
53 int (*setup_bus)(struct media_bay_info *bay, u8 device_id);
54 void (*un_reset)(struct media_bay_info *bay);
55 void (*un_reset_ide)(struct media_bay_info *bay);
138 ohare_mb_content(struct media_bay_info *bay) in ohare_mb_content() argument
140 return (MB_IN32(bay, OHARE_MBCR) >> 12) & 7; in ohare_mb_content()
144 heathrow_mb_content(struct media_bay_info *bay) in heathrow_mb_content() argument
146 return (MB_IN32(bay, HEATHROW_MBCR) >> 12) & 7; in heathrow_mb_content()
150 keylargo_mb_content(struct media_bay_info *bay) in keylargo_mb_content() argument
154 new_gpio = MB_IN8(bay, KL_GPIO_MEDIABAY_IRQ) & KEYLARGO_GPIO_INPUT_DATA; in keylargo_mb_content()
156 bay->cached_gpio = new_gpio; in keylargo_mb_content()
158 } else if (bay->cached_gpio != new_gpio) { in keylargo_mb_content()
159 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE); in keylargo_mb_content()
160 (void)MB_IN32(bay, KEYLARGO_MBCR); in keylargo_mb_content()
162 MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F); in keylargo_mb_content()
163 (void)MB_IN32(bay, KEYLARGO_MBCR); in keylargo_mb_content()
165 bay->cached_gpio = new_gpio; in keylargo_mb_content()
167 return (MB_IN32(bay, KEYLARGO_MBCR) >> 4) & 7; in keylargo_mb_content()
176 ohare_mb_power(struct media_bay_info* bay, int on_off) in ohare_mb_power() argument
180 MB_BIC(bay, OHARE_FCR, OH_BAY_RESET_N); in ohare_mb_power()
181 MB_BIC(bay, OHARE_FCR, OH_BAY_POWER_N); in ohare_mb_power()
184 MB_BIC(bay, OHARE_FCR, OH_BAY_DEV_MASK); in ohare_mb_power()
185 MB_BIC(bay, OHARE_FCR, OH_FLOPPY_ENABLE); in ohare_mb_power()
187 MB_BIS(bay, OHARE_FCR, OH_BAY_POWER_N); in ohare_mb_power()
188 MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N); in ohare_mb_power()
189 MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N); in ohare_mb_power()
191 MB_BIC(bay, OHARE_MBCR, 0x00000F00); in ohare_mb_power()
195 heathrow_mb_power(struct media_bay_info* bay, int on_off) in heathrow_mb_power() argument
199 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_RESET_N); in heathrow_mb_power()
200 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_POWER_N); in heathrow_mb_power()
203 MB_BIC(bay, HEATHROW_FCR, HRW_BAY_DEV_MASK); in heathrow_mb_power()
204 MB_BIC(bay, HEATHROW_FCR, HRW_SWIM_ENABLE); in heathrow_mb_power()
206 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_POWER_N); in heathrow_mb_power()
207 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N); in heathrow_mb_power()
208 MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N); in heathrow_mb_power()
210 MB_BIC(bay, HEATHROW_MBCR, 0x00000F00); in heathrow_mb_power()
214 keylargo_mb_power(struct media_bay_info* bay, int on_off) in keylargo_mb_power() argument
218 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET); in keylargo_mb_power()
219 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER); in keylargo_mb_power()
222 MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK); in keylargo_mb_power()
223 MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE); in keylargo_mb_power()
225 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER); in keylargo_mb_power()
226 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET); in keylargo_mb_power()
227 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N); in keylargo_mb_power()
229 MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F); in keylargo_mb_power()
238 ohare_mb_setup_bus(struct media_bay_info* bay, u8 device_id) in ohare_mb_setup_bus() argument
243 MB_BIS(bay, OHARE_FCR, OH_BAY_FLOPPY_ENABLE); in ohare_mb_setup_bus()
244 MB_BIS(bay, OHARE_FCR, OH_FLOPPY_ENABLE); in ohare_mb_setup_bus()
247 MB_BIC(bay, OHARE_FCR, OH_IDE1_RESET_N); in ohare_mb_setup_bus()
248 MB_BIS(bay, OHARE_FCR, OH_BAY_IDE_ENABLE); in ohare_mb_setup_bus()
251 MB_BIS(bay, OHARE_FCR, OH_BAY_PCI_ENABLE); in ohare_mb_setup_bus()
258 heathrow_mb_setup_bus(struct media_bay_info* bay, u8 device_id) in heathrow_mb_setup_bus() argument
263 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_FLOPPY_ENABLE); in heathrow_mb_setup_bus()
264 MB_BIS(bay, HEATHROW_FCR, HRW_SWIM_ENABLE); in heathrow_mb_setup_bus()
267 MB_BIC(bay, HEATHROW_FCR, HRW_IDE1_RESET_N); in heathrow_mb_setup_bus()
268 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_IDE_ENABLE); in heathrow_mb_setup_bus()
271 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_PCI_ENABLE); in heathrow_mb_setup_bus()
278 keylargo_mb_setup_bus(struct media_bay_info* bay, u8 device_id) in keylargo_mb_setup_bus() argument
282 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_IDE_ENABLE); in keylargo_mb_setup_bus()
283 MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N); in keylargo_mb_setup_bus()
284 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE); in keylargo_mb_setup_bus()
287 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_PCI_ENABLE); in keylargo_mb_setup_bus()
290 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_SOUND_ENABLE); in keylargo_mb_setup_bus()
301 ohare_mb_un_reset(struct media_bay_info* bay) in ohare_mb_un_reset() argument
303 MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N); in ohare_mb_un_reset()
306 static void keylargo_mb_init(struct media_bay_info *bay) in keylargo_mb_init() argument
308 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE); in keylargo_mb_init()
311 static void heathrow_mb_un_reset(struct media_bay_info* bay) in heathrow_mb_un_reset() argument
313 MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N); in heathrow_mb_un_reset()
316 static void keylargo_mb_un_reset(struct media_bay_info* bay) in keylargo_mb_un_reset() argument
318 MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET); in keylargo_mb_un_reset()
321 static void ohare_mb_un_reset_ide(struct media_bay_info* bay) in ohare_mb_un_reset_ide() argument
323 MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N); in ohare_mb_un_reset_ide()
326 static void heathrow_mb_un_reset_ide(struct media_bay_info* bay) in heathrow_mb_un_reset_ide() argument
328 MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N); in heathrow_mb_un_reset_ide()
331 static void keylargo_mb_un_reset_ide(struct media_bay_info* bay) in keylargo_mb_un_reset_ide() argument
333 MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N); in keylargo_mb_un_reset_ide()
336 static inline void set_mb_power(struct media_bay_info* bay, int onoff) in set_mb_power() argument
340 bay->ops->power(bay, 1); in set_mb_power()
341 bay->state = mb_powering_up; in set_mb_power()
342 pr_debug("mediabay%d: powering up\n", bay->index); in set_mb_power()
345 bay->ops->power(bay, 0); in set_mb_power()
346 bay->state = mb_powering_down; in set_mb_power()
347 pr_debug("mediabay%d: powering down\n", bay->index); in set_mb_power()
349 bay->timer = msecs_to_jiffies(MB_POWER_DELAY); in set_mb_power()
352 static void poll_media_bay(struct media_bay_info* bay) in poll_media_bay() argument
354 int id = bay->ops->content(bay); in poll_media_bay()
365 if (id != bay->last_value) { in poll_media_bay()
366 bay->last_value = id; in poll_media_bay()
367 bay->value_count = 0; in poll_media_bay()
370 if (id == bay->content_id) in poll_media_bay()
373 bay->value_count += msecs_to_jiffies(MB_POLL_DELAY); in poll_media_bay()
374 if (bay->value_count >= msecs_to_jiffies(MB_STABLE_DELAY)) { in poll_media_bay()
379 if ((id != MB_NO) && (bay->content_id != MB_NO)) { in poll_media_bay()
381 pr_debug("mediabay%d: forcing MB_NO\n", bay->index); in poll_media_bay()
383 pr_debug("mediabay%d: switching to %d\n", bay->index, id); in poll_media_bay()
384 set_mb_power(bay, id != MB_NO); in poll_media_bay()
385 bay->content_id = id; in poll_media_bay()
387 printk(KERN_INFO "mediabay%d: Bay is now empty\n", bay->index); in poll_media_bay()
390 bay->index, mb_content_types[id]); in poll_media_bay()
396 struct media_bay_info* bay; in check_media_bay() local
407 bay = macio_get_drvdata(baydev); in check_media_bay()
408 if (bay == NULL) in check_media_bay()
410 id = bay->content_id; in check_media_bay()
411 if (bay->state != mb_up) in check_media_bay()
421 struct media_bay_info* bay; in lock_media_bay() local
425 bay = macio_get_drvdata(baydev); in lock_media_bay()
426 if (bay == NULL) in lock_media_bay()
428 mutex_lock(&bay->lock); in lock_media_bay()
429 bay->user_lock = 1; in lock_media_bay()
435 struct media_bay_info* bay; in unlock_media_bay() local
439 bay = macio_get_drvdata(baydev); in unlock_media_bay()
440 if (bay == NULL) in unlock_media_bay()
442 if (bay->user_lock) { in unlock_media_bay()
443 bay->user_lock = 0; in unlock_media_bay()
444 mutex_unlock(&bay->lock); in unlock_media_bay()
451 struct media_bay_info* bay = data; in mb_broadcast_hotplug() local
459 state = bay->state == mb_up ? bay->content_id : MB_NO; in mb_broadcast_hotplug()
471 struct media_bay_info* bay = &media_bays[i]; in media_bay_step() local
474 if (bay->state != mb_powering_down) in media_bay_step()
475 poll_media_bay(bay); in media_bay_step()
478 if (bay->timer != 0) { in media_bay_step()
479 bay->timer -= msecs_to_jiffies(MB_POLL_DELAY); in media_bay_step()
480 if (bay->timer > 0) in media_bay_step()
482 bay->timer = 0; in media_bay_step()
485 switch(bay->state) { in media_bay_step()
487 if (bay->ops->setup_bus(bay, bay->last_value) < 0) { in media_bay_step()
489 i, bay->content_id); in media_bay_step()
490 set_mb_power(bay, 0); in media_bay_step()
493 bay->timer = msecs_to_jiffies(MB_RESET_DELAY); in media_bay_step()
494 bay->state = mb_enabling_bay; in media_bay_step()
495 pr_debug("mediabay%d: enabling (kind:%d)\n", i, bay->content_id); in media_bay_step()
498 bay->ops->un_reset(bay); in media_bay_step()
499 bay->timer = msecs_to_jiffies(MB_SETUP_DELAY); in media_bay_step()
500 bay->state = mb_resetting; in media_bay_step()
502 i, bay->content_id); in media_bay_step()
505 if (bay->content_id != MB_CD) { in media_bay_step()
507 bay->content_id); in media_bay_step()
508 bay->state = mb_up; in media_bay_step()
509 device_for_each_child(&bay->mdev->ofdev.dev, in media_bay_step()
510 bay, mb_broadcast_hotplug); in media_bay_step()
514 i, bay->content_id); in media_bay_step()
515 bay->ops->un_reset_ide(bay); in media_bay_step()
516 bay->timer = msecs_to_jiffies(MB_IDE_WAIT); in media_bay_step()
517 bay->state = mb_ide_resetting; in media_bay_step()
521 pr_debug("mediabay%d: bay is up (kind:%d)\n", i, bay->content_id); in media_bay_step()
522 bay->state = mb_up; in media_bay_step()
523 device_for_each_child(&bay->mdev->ofdev.dev, in media_bay_step()
524 bay, mb_broadcast_hotplug); in media_bay_step()
528 bay->state = mb_empty; in media_bay_step()
529 device_for_each_child(&bay->mdev->ofdev.dev, in media_bay_step()
530 bay, mb_broadcast_hotplug); in media_bay_step()
562 struct media_bay_info* bay; in media_bay_attach() local
586 bay = &media_bays[i]; in media_bay_attach()
587 bay->mdev = mdev; in media_bay_attach()
588 bay->base = regbase; in media_bay_attach()
589 bay->index = i; in media_bay_attach()
590 bay->ops = match->data; in media_bay_attach()
591 bay->sleeping = 0; in media_bay_attach()
592 mutex_init(&bay->lock); in media_bay_attach()
595 if (bay->ops->init) in media_bay_attach()
596 bay->ops->init(bay); in media_bay_attach()
598 printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", i, bay->ops->name); in media_bay_attach()
601 set_mb_power(bay, 0); in media_bay_attach()
603 bay->content_id = MB_NO; in media_bay_attach()
604 bay->last_value = bay->ops->content(bay); in media_bay_attach()
605 bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY); in media_bay_attach()
606 bay->state = mb_empty; in media_bay_attach()
609 macio_set_drvdata(mdev, bay); in media_bay_attach()
621 struct media_bay_info *bay = macio_get_drvdata(mdev); in media_bay_suspend() local
625 mutex_lock(&bay->lock); in media_bay_suspend()
626 bay->sleeping = 1; in media_bay_suspend()
627 set_mb_power(bay, 0); in media_bay_suspend()
628 mutex_unlock(&bay->lock); in media_bay_suspend()
637 struct media_bay_info *bay = macio_get_drvdata(mdev); in media_bay_resume() local
647 mutex_lock(&bay->lock); in media_bay_resume()
648 set_mb_power(bay, 0); in media_bay_resume()
650 if (bay->ops->content(bay) != bay->content_id) { in media_bay_resume()
651 printk("mediabay%d: Content changed during sleep...\n", bay->index); in media_bay_resume()
652 mutex_unlock(&bay->lock); in media_bay_resume()
655 set_mb_power(bay, 1); in media_bay_resume()
656 bay->last_value = bay->content_id; in media_bay_resume()
657 bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY); in media_bay_resume()
658 bay->timer = msecs_to_jiffies(MB_POWER_DELAY); in media_bay_resume()
661 media_bay_step(bay->index); in media_bay_resume()
662 } while((bay->state != mb_empty) && in media_bay_resume()
663 (bay->state != mb_up)); in media_bay_resume()
664 bay->sleeping = 0; in media_bay_resume()
665 mutex_unlock(&bay->lock); in media_bay_resume()