Beispiel #1
0
/**
* omap_hsi_prepare_suspend - Prepare HSI for suspend mode
*
* @hsi_port - reference to the HSI port. Range [1, 2]
* @dev_may_wakeup - value of sysfs flag indicating device wakeup capability
*
* Return value :* 0 if CAWAKE padconf has been configured properly
*		* -ENODEV if CAWAKE is not muxed on padconf.
*
*/
int omap_hsi_prepare_suspend(int hsi_port, bool dev_may_wakeup)
{
	int ret;

	if (dev_may_wakeup)
		ret = omap_hsi_wakeup_enable(hsi_port);
	else
		ret = omap_hsi_wakeup_disable(hsi_port);

	return ret;
}
/**
* omap_hsi_prepare_suspend - Prepare HSI for suspend mode (OFF)
*
* Return value : -ENODEV if HSI controller has not been found, else 0.
*
*/
int omap_hsi_prepare_suspend(void)
{
	struct platform_device *pdev;
	struct hsi_dev *hsi_ctrl;
	u16 val;

	pdev = hsi_get_hsi_platform_device();
	hsi_ctrl = hsi_get_hsi_controller_data(pdev);

	if (!hsi_ctrl)
		return -ENODEV;

	/* If HSI is enabled, CAWAKE IO wakeup has been disabled and */
	/* we don't want to re-enable it here. HSI interrupt shall be */
	/* generated normally because HSI HW is ON. */
	if (hsi_ctrl->clock_enabled) {
		dev_info(hsi_ctrl->dev, "Platform Suspend while HSI active\n");
		return 0;
	}

	/* Check for IO pad wakeup */
	val = omap_mux_read_signal(OMAP_HSI_PADCONF_CAWAKE_PIN);
	if (val == -ENODEV)
		return -ENODEV;

	/* HSI can only wakeup OMAP if CAWAKE is muxed */
	if ((val & OMAP_MUX_MODE_MASK) != OMAP_HSI_PADCONF_CAWAKE_MODE)
		return 0;

	if (device_may_wakeup(&pdev->dev))
		omap_hsi_wakeup_enable(hsi_ctrl, 0);
	else
		omap_hsi_wakeup_disable(hsi_ctrl, 0);

	return 0;
}