Lines Matching +full:reset +full:- +full:assert +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0-or-later
32 #define MB_FCR32(bay, r) ((bay)->base + ((r) >> 2))
33 #define MB_FCR8(bay, r) (((volatile u8 __iomem *)((bay)->base)) + (r))
76 * Wait that number of ms between each step in normal polling mode
81 * Consider the media-bay ID value stable if it is the same for
86 /* Wait after powering up the media bay this delay in ms
92 * Hold the media-bay reset signal true for this many ticks
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
105 * Wait this many ticks after an IDE device (e.g. CD-ROM) is inserted
117 mb_resetting, /* reset bit unset, waiting MB_SETUP_DELAY */
118 mb_ide_resetting, /* IDE reset bit unser, waiting MB_IDE_WAIT */
152 bay->cached_gpio = new_gpio; in keylargo_mb_content()
154 } else if (bay->cached_gpio != new_gpio) { in keylargo_mb_content()
161 bay->cached_gpio = new_gpio; in keylargo_mb_content()
168 * into reset state as well
175 /* Power up device, assert it's reset line */ in ohare_mb_power()
182 /* Cut power from bay, release reset line */ in ohare_mb_power()
194 /* Power up device, assert it's reset line */ in heathrow_mb_power()
201 /* Cut power from bay, release reset line */ in heathrow_mb_power()
213 /* Power up device, assert it's reset line */ in keylargo_mb_power()
220 /* Cut power from bay, release reset line */ in keylargo_mb_power()
250 return -ENODEV; in ohare_mb_setup_bus()
270 return -ENODEV; in heathrow_mb_setup_bus()
289 return -ENODEV; in keylargo_mb_setup_bus()
334 /* Power up up and assert the bay reset line */ in set_mb_power()
336 bay->ops->power(bay, 1); in set_mb_power()
337 bay->state = mb_powering_up; in set_mb_power()
338 pr_debug("mediabay%d: powering up\n", bay->index); in set_mb_power()
341 bay->ops->power(bay, 0); in set_mb_power()
342 bay->state = mb_powering_down; in set_mb_power()
343 pr_debug("mediabay%d: powering down\n", bay->index); in set_mb_power()
345 bay->timer = msecs_to_jiffies(MB_POWER_DELAY); in set_mb_power()
350 int id = bay->ops->content(bay); in poll_media_bay()
361 if (id != bay->last_value) { in poll_media_bay()
362 bay->last_value = id; in poll_media_bay()
363 bay->value_count = 0; in poll_media_bay()
366 if (id == bay->content_id) in poll_media_bay()
369 bay->value_count += msecs_to_jiffies(MB_POLL_DELAY); in poll_media_bay()
370 if (bay->value_count >= msecs_to_jiffies(MB_STABLE_DELAY)) { in poll_media_bay()
373 * things are properly reset in poll_media_bay()
375 if ((id != MB_NO) && (bay->content_id != MB_NO)) { in poll_media_bay()
377 pr_debug("mediabay%d: forcing MB_NO\n", bay->index); in poll_media_bay()
379 pr_debug("mediabay%d: switching to %d\n", bay->index, id); in poll_media_bay()
381 bay->content_id = id; in poll_media_bay()
383 printk(KERN_INFO "mediabay%d: Bay is now empty\n", bay->index); in poll_media_bay()
386 bay->index, mb_content_types[id]); in poll_media_bay()
406 id = bay->content_id; in check_media_bay()
407 if (bay->state != mb_up) in check_media_bay()
424 mutex_lock(&bay->lock); in lock_media_bay()
425 bay->user_lock = 1; in lock_media_bay()
438 if (bay->user_lock) { in unlock_media_bay()
439 bay->user_lock = 0; in unlock_media_bay()
440 mutex_unlock(&bay->lock); in unlock_media_bay()
452 if (dev->bus != &macio_bus_type) in mb_broadcast_hotplug()
455 state = bay->state == mb_up ? bay->content_id : MB_NO; in mb_broadcast_hotplug()
459 drv = to_macio_driver(dev->driver); in mb_broadcast_hotplug()
460 if (dev->driver && drv->mediabay_event) in mb_broadcast_hotplug()
461 drv->mediabay_event(mdev, state); in mb_broadcast_hotplug()
470 if (bay->state != mb_powering_down) in media_bay_step()
474 if (bay->timer != 0) { in media_bay_step()
475 bay->timer -= msecs_to_jiffies(MB_POLL_DELAY); in media_bay_step()
476 if (bay->timer > 0) in media_bay_step()
478 bay->timer = 0; in media_bay_step()
481 switch(bay->state) { in media_bay_step()
483 if (bay->ops->setup_bus(bay, bay->last_value) < 0) { in media_bay_step()
485 i, bay->content_id); in media_bay_step()
489 bay->timer = msecs_to_jiffies(MB_RESET_DELAY); in media_bay_step()
490 bay->state = mb_enabling_bay; in media_bay_step()
491 pr_debug("mediabay%d: enabling (kind:%d)\n", i, bay->content_id); in media_bay_step()
494 bay->ops->un_reset(bay); in media_bay_step()
495 bay->timer = msecs_to_jiffies(MB_SETUP_DELAY); in media_bay_step()
496 bay->state = mb_resetting; in media_bay_step()
497 pr_debug("mediabay%d: releasing bay reset (kind:%d)\n", in media_bay_step()
498 i, bay->content_id); in media_bay_step()
501 if (bay->content_id != MB_CD) { in media_bay_step()
503 bay->content_id); in media_bay_step()
504 bay->state = mb_up; in media_bay_step()
505 device_for_each_child(&bay->mdev->ofdev.dev, in media_bay_step()
509 pr_debug("mediabay%d: releasing ATA reset (kind:%d)\n", in media_bay_step()
510 i, bay->content_id); in media_bay_step()
511 bay->ops->un_reset_ide(bay); in media_bay_step()
512 bay->timer = msecs_to_jiffies(MB_IDE_WAIT); in media_bay_step()
513 bay->state = mb_ide_resetting; in media_bay_step()
517 pr_debug("mediabay%d: bay is up (kind:%d)\n", i, bay->content_id); in media_bay_step()
518 bay->state = mb_up; in media_bay_step()
519 device_for_each_child(&bay->mdev->ofdev.dev, in media_bay_step()
524 bay->state = mb_empty; in media_bay_step()
525 device_for_each_child(&bay->mdev->ofdev.dev, in media_bay_step()
564 ofnode = mdev->ofdev.dev.of_node; in media_bay_attach()
567 return -ENODEV; in media_bay_attach()
568 if (macio_request_resources(mdev, "media-bay")) in media_bay_attach()
569 return -EBUSY; in media_bay_attach()
571 * mac-io chip, for now, we trick and align down the first in media_bay_attach()
578 return -ENOMEM; in media_bay_attach()
583 bay->mdev = mdev; in media_bay_attach()
584 bay->base = regbase; in media_bay_attach()
585 bay->index = i; in media_bay_attach()
586 bay->ops = match->data; in media_bay_attach()
587 bay->sleeping = 0; in media_bay_attach()
588 mutex_init(&bay->lock); in media_bay_attach()
591 if (bay->ops->init) in media_bay_attach()
592 bay->ops->init(bay); in media_bay_attach()
594 printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", i, bay->ops->name); in media_bay_attach()
599 bay->content_id = MB_NO; in media_bay_attach()
600 bay->last_value = bay->ops->content(bay); in media_bay_attach()
601 bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY); in media_bay_attach()
602 bay->state = mb_empty; in media_bay_attach()
609 kthread_run(media_bay_task, NULL, "media-bay"); in media_bay_attach()
619 if (state.event != mdev->ofdev.dev.power.power_state.event in media_bay_suspend()
621 mutex_lock(&bay->lock); in media_bay_suspend()
622 bay->sleeping = 1; in media_bay_suspend()
624 mutex_unlock(&bay->lock); in media_bay_suspend()
626 mdev->ofdev.dev.power.power_state = state; in media_bay_suspend()
635 if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) { in media_bay_resume()
636 mdev->ofdev.dev.power.power_state = PMSG_ON; in media_bay_resume()
638 /* We re-enable the bay using it's previous content in media_bay_resume()
643 mutex_lock(&bay->lock); in media_bay_resume()
646 if (bay->ops->content(bay) != bay->content_id) { in media_bay_resume()
647 printk("mediabay%d: Content changed during sleep...\n", bay->index); in media_bay_resume()
648 mutex_unlock(&bay->lock); in media_bay_resume()
652 bay->last_value = bay->content_id; in media_bay_resume()
653 bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY); in media_bay_resume()
654 bay->timer = msecs_to_jiffies(MB_POWER_DELAY); in media_bay_resume()
657 media_bay_step(bay->index); in media_bay_resume()
658 } while((bay->state != mb_empty) && in media_bay_resume()
659 (bay->state != mb_up)); in media_bay_resume()
660 bay->sleeping = 0; in media_bay_resume()
661 mutex_unlock(&bay->lock); in media_bay_resume()
698 * It seems that the bit for the media-bay interrupt in the IRQ_LEVEL
701 * handler to the media-bay interrupt, because it tends to go into
709 .name = "media-bay",
710 .compatible = "keylargo-media-bay",
714 .name = "media-bay",
715 .compatible = "heathrow-media-bay",
719 .name = "media-bay",
720 .compatible = "ohare-media-bay",
729 .name = "media-bay",
743 media_bays[i].content_id = -1; in media_bay_init()