static int xhci_msm_pm_resume(struct device *dev)
{
	dev_dbg(dev, "xhci-msm PM resume\n");

	if (pm_runtime_suspended(dev))
		return 0;

	if (phy)
		return usb_phy_set_suspend(phy, 0);

	return 0;
}
Exemple #2
0
static int __maybe_unused zynq_gpio_resume(struct device *dev)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct zynq_gpio *gpio = platform_get_drvdata(pdev);

	if (!device_may_wakeup(dev)) {
		if (!pm_runtime_suspended(dev))
			return clk_enable(gpio->clk);
	}

	return 0;
}
Exemple #3
0
static void exnos_usb_switch_worker(struct work_struct *work)
{
	struct exynos_usb_switch *usb_switch =
		container_of(work, struct exynos_usb_switch, switch_work);
	int cnt = 0;

	mutex_lock(&usb_switch->mutex);
	/* If already device detached or host_detected, */
	if (!is_device_detect(usb_switch) || is_host_detect(usb_switch))
		goto done;
	if (!usb_switch->ehci_dev || !usb_switch->ohci_dev)
		goto detect;

	while (!pm_runtime_suspended(usb_switch->ehci_dev) ||
		!pm_runtime_suspended(usb_switch->ohci_dev)) {

		mutex_unlock(&usb_switch->mutex);
		msleep(SWITCH_WAIT_TIME);
		mutex_lock(&usb_switch->mutex);

		/* If already device detached or host_detected, */
		if (!is_device_detect(usb_switch) || is_host_detect(usb_switch))
			goto done;

		if (cnt++ > WAIT_TIMES) {
			printk(KERN_ERR "%s:device not attached by host\n",
				__func__);
			goto done;
		}

	}

	if (cnt > 1)
		printk(KERN_INFO "Device wait host power during %d\n", (cnt-1));
detect:
	/* Check Device, VBUS PIN high active */
	exynos_change_usb_mode(usb_switch, USB_DEVICE_ATTACHED);
done:
	mutex_unlock(&usb_switch->mutex);
}
static int escore_system_suspend(struct device *dev)
{
	struct escore_priv *escore = &escore_priv;
	int ret = 0;
	pr_info("%s(): @@@@@@ Entry #####\n", __func__);
	dev_dbg(dev, "%s()\n", __func__);

	if (escore->dev != dev) {
		dev_dbg(dev, "%s() Invalid device\n", __func__);
		return 0;
	}

/*	if (!es_ready_to_suspend(escore)) {
		dev_dbg(dev, "%s() - Not ready for suspend\n", __func__);
		return -EBUSY;
	}

	if (escore->disable_codec_irq) {
		ret = escore->disable_codec_irq(escore);
		if (ret < 0) {
			dev_err(dev, "%s(): Disable irq failed\n",
				__func__);
			return -EBUSY;
		}
		pr_info("%s(): @@@@@@ disable_codec_irq #####\n", __func__);
	}*/

	if (!pm_runtime_suspended(dev)) {
		dev_dbg(dev, "%s() system suspend\n", __func__);
		mutex_lock(&escore->access_lock);
		ret = escore_runtime_suspend(dev);
		/*
		 * If runtime-PM still thinks it's active, then make sure its
		 * status is in sync with HW status.
		 * If runtime suspend is not executed yet, RPM status is
		 * RPM_ACTIVE. System suspend changes chip status to suspend
		 * and hence RPM status needs to be updated manually to match
		 * actual chip status. This can be done by disabling RPM,
		 * changing RPM status and enabling RPM again.
		 */
		if (!ret) {
			pm_runtime_disable(dev);
			pm_runtime_set_suspended(dev);
			pm_runtime_enable(dev);
		}
		mutex_unlock(&escore->access_lock);
	}

	dev_dbg(dev, "%s() complete %d\n", __func__, ret);
	pr_info("%s(): @@@@@@ Exit #####\n", __func__);
	return ret;
}
Exemple #5
0
static int omap_usb3_remove(struct platform_device *pdev)
{
	struct omap_usb *phy = platform_get_drvdata(pdev);

	clk_unprepare(phy->wkupclk);
	clk_unprepare(phy->optclk);
	usb_remove_phy(&phy->phy);
	if (!pm_runtime_suspended(&pdev->dev))
		pm_runtime_put(&pdev->dev);
	pm_runtime_disable(&pdev->dev);

	return 0;
}
Exemple #6
0
static ssize_t apds990x_prox_show(struct device *dev,
				 struct device_attribute *attr, char *buf)
{
	ssize_t ret;
	struct apds990x_chip *chip =  dev_get_drvdata(dev);
	if (pm_runtime_suspended(dev) || !chip->prox_en)
		return -EIO;

	mutex_lock(&chip->mutex);
	ret = sprintf(buf, "%d\n", chip->prox_data);
	mutex_unlock(&chip->mutex);
	return ret;
}
Exemple #7
0
static int xgpiops_suspend(struct device *dev)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct xgpiops *gpio = platform_get_drvdata(pdev);

	if (!device_may_wakeup(dev)) {
		if (!pm_runtime_suspended(dev))
			clk_disable(gpio->clk);
		return 0;
	}

	return 0;
}
static int lm3561_resume_sleep(struct device *dev)
{
	int rc;
	struct lm3561_platform_data *pdata = dev->platform_data;

	if (!pm_runtime_suspended(dev)) {
		pm_runtime_put(dev);
		rc = lm3561_resume(dev);
	} else
		rc = pdata->power ? pdata->power(dev, true) : 0;
	dev_dbg(dev, "%s: resumed (%d)\n", __func__, rc);
	return rc;
}
Exemple #9
0
static int __maybe_unused sirf_resume(struct device *dev)
{
	struct sirf_data *data = dev_get_drvdata(dev);
	int ret = 0;

	if (data->wakeup)
		enable_irq(data->irq);

	if (!pm_runtime_suspended(dev))
		ret = sirf_runtime_resume(dev);

	return ret;
}
Exemple #10
0
/* Called always with mutex locked */
static int apds990x_refresh_athres(struct apds990x_chip *chip)
{
	int ret;
	/* If the chip is not in use, don't try to access it */
	if (pm_runtime_suspended(&chip->client->dev))
		return 0;

	ret = apds990x_write_word(chip, APDS990X_AILTL,
			apds990x_lux_to_threshold(chip, chip->lux_thres_lo));
	ret |= apds990x_write_word(chip, APDS990X_AIHTL,
			apds990x_lux_to_threshold(chip, chip->lux_thres_hi));

	return ret;
}
static int atmel_hlcdc_dc_drm_resume(struct device *dev)
{
	struct drm_device *drm_dev = dev_get_drvdata(dev);
	struct drm_crtc *crtc;

	if (pm_runtime_suspended(dev))
		return 0;

	drm_modeset_lock_all(drm_dev);
	list_for_each_entry(crtc, &drm_dev->mode_config.crtc_list, head)
		atmel_hlcdc_crtc_resume(crtc);
	drm_modeset_unlock_all(drm_dev);
	return 0;
}
/**
 * exynos_drd_switch_is_host_off - check host's PM status.
 *
 * @otg: Pointer to the usb_otg structure.
 *
 * Before peripheral can start two conditions must be met:
 * 1. Host's completely resumed after system sleep.
 * 2. Host is runtime suspended.
 */
static bool exynos_drd_switch_is_host_off(struct usb_otg *otg)
{
    struct usb_hcd *hcd;
    struct device *dev;

    if (!otg->host)
        /* REVISIT: what should we return here? */
        return true;

    hcd = bus_to_hcd(otg->host);
    dev = hcd->self.controller;

    return pm_runtime_suspended(dev);
}
static ssize_t bh1770_prox_result_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{
	struct bh1770_chip *chip =  dev_get_drvdata(dev);
	ssize_t ret;

	mutex_lock(&chip->mutex);
	if (chip->prox_enable_count && !pm_runtime_suspended(dev))
		ret = sprintf(buf, "%d\n", chip->prox_data);
	else
		ret = -EIO;
	mutex_unlock(&chip->mutex);
	return ret;
}
/*
 * Following two functions converts raw lux values from HW to normalized
 * values. Purpose is to compensate differences between different sensor
 * versions and variants so that result means about the same between
 * versions. Chip->mutex is kept when this is called.
 */
static int bh1770_prox_set_threshold(struct bh1770_chip *chip)
{
	u8 tmp = 0;

	/* sysfs may call this when the chip is powered off */
	if (pm_runtime_suspended(&chip->client->dev))
		return 0;

	tmp = bh1770_psadjusted_to_raw(chip, chip->prox_threshold);
	chip->prox_threshold_hw = tmp;

	return	i2c_smbus_write_byte_data(chip->client, BH1770_PS_TH_LED1,
					tmp);
}
/* chip->mutex is always kept here */
static int bh1770_lux_rate(struct bh1770_chip *chip, int rate_index)
{
	/* sysfs may call this when the chip is powered off */
	if (pm_runtime_suspended(&chip->client->dev))
		return 0;

	/* Proper proximity response needs fastest lux rate (100ms) */
	if (chip->prox_enable_count)
		rate_index = 0;

	return i2c_smbus_write_byte_data(chip->client,
					BH1770_ALS_MEAS_RATE,
					rate_index);
}
static int exynos_xhci_suspend(struct device *dev)
{
	struct platform_device	*pdev = to_platform_device(dev);
	struct exynos_xhci_hcd	*exynos_xhci;
	struct usb_hcd		*hcd;
	struct xhci_hcd		*xhci;
	int			retval = 0;

#ifdef CONFIG_PM_RUNTIME
	dev_dbg(dev, "%s: usage_count = %d\n",
		      __func__, atomic_read(&dev->power.usage_count));
#endif
	exynos_xhci = dev_get_drvdata(dev);
	if (!exynos_xhci)
		return -EINVAL;

	hcd = exynos_xhci->hcd;
	if (!hcd)
		return -EINVAL;

	/* Prevent any more root-hub status calls from the timer
	 * The HCD might still restart the timer (if a port status change
	 * interrupt occurs), but usb_hcd_poll_rh_status() won't invoke
	 * the hub_status_data() callback.
	 */
	hcd->rh_pollable = 0;
	hcd->shared_hcd->rh_pollable = 0;

	xhci = hcd_to_xhci(hcd);

	if (hcd->state != HC_STATE_SUSPENDED ||
			xhci->shared_hcd->state != HC_STATE_SUSPENDED)
		dev_err(dev, "%s: HC state is not suspended!\n", __func__);
#ifdef CONFIG_USB_SUSPEND
	if (pm_runtime_suspended(dev)) {
		dev_dbg(dev, "xhci is runtime suspended\n");
		return 0;
	}
#endif
	retval = xhci_suspend(xhci, 0);
	if (retval < 0)
		dev_err(dev, "%s: cannot stop xHC\n", __func__);

	pm_runtime_put_sync(dev->parent);

	exynos_drd_put(pdev);

	return retval;
}
static int ak89xx_resume(struct device *dev)
{
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct inv_ak89xx_state_s *st = iio_priv(indio_dev);
	int rc;

	dev_dbg(dev, "%s\n", __func__);
	if (!pm_runtime_suspended(dev)) {
		rc = ak89xx_power_supply(st, 1);
	} else {
		dev_info(dev, "%s: was runtime-suspended.\n", __func__);
		rc = 0;
	}
	return rc ? -EAGAIN : 0;
}
Exemple #18
0
int hdmi_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
	struct hdmi_device *hdev = sd_to_hdmi_dev(sd);
	struct device *dev = hdev->dev;

	if (!pm_runtime_suspended(hdev->dev) && !hdev->hpd_user_checked)
		ctrl->value = hdmi_hpd_status(hdev);
	else
		ctrl->value = atomic_read(&hdev->hpd_state);

	dev_dbg(dev, "HDMI cable is %s\n", ctrl->value ?
			"connected" : "disconnected");

	return 0;
}
/* Resume the device when all power resources in _PR0 are on */
static void acpi_power_on_device(struct acpi_power_managed_device *device)
{
	struct acpi_device *acpi_dev;
	acpi_handle handle = device->handle;
	int state;

	if (acpi_bus_get_device(handle, &acpi_dev))
		return;

	if(acpi_power_get_inferred_state(acpi_dev, &state))
		return;

	if (state == ACPI_STATE_D0 && pm_runtime_suspended(device->dev))
		pm_request_resume(device->dev);
}
Exemple #20
0
static void st_tty_close(struct tty_struct *tty)
{
	unsigned char i = ST_MAX_CHANNELS;
	unsigned long flags = 0;
	struct	st_data_s *st_gdata = tty->disc_data;

	pr_info("%s ", __func__);

	/* TODO:
	 * if a protocol has been registered & line discipline
	 * un-installed for some reason - what should be done ?
	 */
	spin_lock_irqsave(&st_gdata->lock, flags);
	for (i = 0; i < ST_MAX_CHANNELS; i++) {
		if (st_gdata->is_registered[i] == true)
			pr_err("%d not un-registered", i);
		st_gdata->list[i] = NULL;
		st_gdata->is_registered[i] = false;
	}
	st_gdata->protos_registered = 0;
	spin_unlock_irqrestore(&st_gdata->lock, flags);
	/*
	 * signal to UIM via KIM that -
	 * N_TI_WL ldisc is un-installed
	 */
	st_kim_complete(st_gdata->kim_data);
	st_gdata->tty = NULL;
	/* Flush any pending characters in the driver and discipline. */
	tty_ldisc_flush(tty);
	tty_driver_flush_buffer(tty);

	spin_lock_irqsave(&st_gdata->lock, flags);
	/* empty out txq and tx_waitq */
	skb_queue_purge(&st_gdata->txq);
	skb_queue_purge(&st_gdata->tx_waitq);
	/* reset the TTY Rx states of ST */
	st_gdata->rx_count = 0;
	st_gdata->rx_state = ST_W4_PACKET_TYPE;
	kfree_skb(st_gdata->rx_skb);
	st_gdata->rx_skb = NULL;
	spin_unlock_irqrestore(&st_gdata->lock, flags);

	pm_runtime_put_noidle(st_gdata->tty_dev);
	if (!pm_runtime_suspended(st_gdata->tty_dev))
		__pm_runtime_idle(st_gdata->tty_dev, 0);

	pr_debug("%s: done ", __func__);
}
Exemple #21
0
static int lis3lv02d_i2c_resume(struct device *dev)
{
	struct i2c_client *client = container_of(dev, struct i2c_client, dev);
	struct lis3lv02d *lis3 = i2c_get_clientdata(client);

	/*
	 * pm_runtime documentation says that devices should always
	 * be powered on at resume. Pm_runtime turns them off after system
	 * wide resume is complete.
	 */
	if (!lis3->pdata || !lis3->pdata->wakeup_flags ||
		pm_runtime_suspended(dev))
		lis3lv02d_poweron(lis3);

	return 0;
}
Exemple #22
0
static int rockchip_spi_suspend(struct device *dev)
{
	int ret = 0;
	struct spi_master *master = dev_get_drvdata(dev);
	struct rockchip_spi *rs = spi_master_get_devdata(master);

	ret = spi_master_suspend(rs->master);
	if (ret)
		return ret;

	if (!pm_runtime_suspended(dev)) {
		clk_disable_unprepare(rs->spiclk);
		clk_disable_unprepare(rs->apb_pclk);
	}

	return ret;
}
static bool samsung_usb2phy_is_active(struct usb_phy *phy)
{
	struct samsung_usbphy *sphy = phy_to_sphy(phy);
	unsigned long flags;
	bool ret;

	spin_lock_irqsave(&sphy->lock, flags);

	if (!sphy->usage_count || pm_runtime_suspended(sphy->dev))
		ret = false;
	else
		ret = true;

	spin_unlock_irqrestore(&sphy->lock, flags);

	return ret;
}
Exemple #24
0
static int scsi_bus_suspend_common(struct device *dev, pm_message_t msg)
{
	int err = 0;

	if (scsi_is_sdev_device(dev)) {
		if (pm_runtime_suspended(dev)) {
			if (msg.event == PM_EVENT_SUSPEND ||
			    msg.event == PM_EVENT_HIBERNATE)
				return 0;	

			
			pm_runtime_resume(dev);
		}
		err = scsi_dev_type_suspend(dev, msg);
	}
	return err;
}
Exemple #25
0
static void usbhs_resume_work(struct work_struct *work)
{
	dev_dbg(usbhs_wake->dev, "USB IO PAD Wakeup event triggered\n");

	if (usbhs_wake->wakeup_ehci) {
		usbhs_wake->wakeup_ehci = 0;
		omap_hwmod_disable_ioring_wakeup(usbhs_wake->oh_ehci);
	}

	if (usbhs_wake->wakeup_ohci) {
		usbhs_wake->wakeup_ohci = 0;
		omap_hwmod_disable_ioring_wakeup(usbhs_wake->oh_ohci);
	}

	if (pm_runtime_suspended(usbhs_wake->dev))
		pm_runtime_get_sync(usbhs_wake->dev);
}
/**
 * cdns_i2c_clk_notifier_cb - Clock rate change callback
 * @nb:		Pointer to notifier block
 * @event:	Notification reason
 * @data:	Pointer to notification data object
 *
 * This function is called when the cdns_i2c input clock frequency changes.
 * The callback checks whether a valid bus frequency can be generated after the
 * change. If so, the change is acknowledged, otherwise the change is aborted.
 * New dividers are written to the HW in the pre- or post change notification
 * depending on the scaling direction.
 *
 * Return:	NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK
 *		to acknowedge the change, NOTIFY_DONE if the notification is
 *		considered irrelevant.
 */
static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
		event, void *data)
{
	struct clk_notifier_data *ndata = data;
	struct cdns_i2c *id = to_cdns_i2c(nb);

	if (pm_runtime_suspended(id->dev))
		return NOTIFY_OK;

	switch (event) {
	case PRE_RATE_CHANGE:
	{
		unsigned long input_clk = ndata->new_rate;
		unsigned long fscl = id->i2c_clk;
		unsigned int div_a, div_b;
		int ret;

		ret = cdns_i2c_calc_divs(&fscl, input_clk, &div_a, &div_b);
		if (ret) {
			dev_warn(id->adap.dev.parent,
					"clock rate change rejected\n");
			return NOTIFY_STOP;
		}

		/* scale up */
		if (ndata->new_rate > ndata->old_rate)
			cdns_i2c_setclk(ndata->new_rate, id);

		return NOTIFY_OK;
	}
	case POST_RATE_CHANGE:
		id->input_clk = ndata->new_rate;
		/* scale down */
		if (ndata->new_rate < ndata->old_rate)
			cdns_i2c_setclk(ndata->new_rate, id);
		return NOTIFY_OK;
	case ABORT_RATE_CHANGE:
		/* scale up */
		if (ndata->new_rate > ndata->old_rate)
			cdns_i2c_setclk(ndata->old_rate, id);
		return NOTIFY_OK;
	default:
		return NOTIFY_DONE;
	}
}
Exemple #27
0
static int bdisp_resume(struct device *dev)
{
	struct bdisp_dev *bdisp = dev_get_drvdata(dev);
	unsigned long flags;
	int opened;

	spin_lock_irqsave(&bdisp->slock, flags);
	opened = test_bit(ST_M2M_OPEN, &bdisp->state);
	spin_unlock_irqrestore(&bdisp->slock, flags);

	if (!opened)
		return 0;

	if (!pm_runtime_suspended(dev))
		return bdisp_runtime_resume(dev);

	return 0;
}
/**
 *  inv_ak89xx_remove() - remove function.
 */
static int inv_ak89xx_remove(struct i2c_client *client)
{
	struct iio_dev *indio_dev = i2c_get_clientdata(client);
	struct inv_ak89xx_state_s *st = iio_priv(indio_dev);
	cancel_delayed_work_sync(&st->work);
	iio_device_unregister(indio_dev);
	inv_ak89xx_remove_trigger(indio_dev);
	iio_buffer_unregister(indio_dev);
	inv_ak89xx_unconfigure_ring(indio_dev);
	if (!pm_runtime_suspended(&client->dev))
		ak89xx_power_supply(st, 0);
	pm_runtime_disable(&client->dev);

	iio_free_device(indio_dev);

	dev_info(&client->adapter->dev, "inv-ak89xx-iio module removed.\n");
	return 0;
}
int lis3lv02d_remove_fs(struct lis3lv02d *lis3)
{
	sysfs_remove_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group);
	platform_device_unregister(lis3->pdev);
	if (lis3->pm_dev) {
		/* Barrier after the sysfs remove */
		pm_runtime_barrier(lis3->pm_dev);

		/* SYSFS may have left chip running. Turn off if necessary */
		if (!pm_runtime_suspended(lis3->pm_dev))
			lis3lv02d_poweroff(&lis3_dev);

		pm_runtime_disable(lis3->pm_dev);
		pm_runtime_set_suspended(lis3->pm_dev);
	}
	kfree(lis3->reg_cache);
	return 0;
}
Exemple #30
0
static int scsi_bus_resume_common(struct device *dev,
		int (*cb)(struct device *, const struct dev_pm_ops *))
{
	async_func_t fn;

	if (!scsi_is_sdev_device(dev))
		fn = NULL;
	else if (cb == do_scsi_resume)
		fn = async_sdev_resume;
	else if (cb == do_scsi_thaw)
		fn = async_sdev_thaw;
	else if (cb == do_scsi_restore)
		fn = async_sdev_restore;
	else
		fn = NULL;

	/*
	 * Forcibly set runtime PM status of request queue to "active" to
	 * make sure we can again get requests from the queue (see also
	 * blk_pm_peek_request()).
	 *
	 * The resume hook will correct runtime PM status of the disk.
	 */
	if (scsi_is_sdev_device(dev) && pm_runtime_suspended(dev))
		blk_set_runtime_active(to_scsi_device(dev)->request_queue);

	if (fn) {
		async_schedule_domain(fn, dev, &scsi_sd_pm_domain);

		/*
		 * If a user has disabled async probing a likely reason
		 * is due to a storage enclosure that does not inject
		 * staggered spin-ups.  For safety, make resume
		 * synchronous as well in that case.
		 */
		if (strncmp(scsi_scan_type, "async", 5) != 0)
			async_synchronize_full_domain(&scsi_sd_pm_domain);
	} else {
		pm_runtime_disable(dev);
		pm_runtime_set_active(dev);
		pm_runtime_enable(dev);
	}
	return 0;
}