Beispiel #1
0
/**
* omap_hsi_is_io_wakeup_from_hsi - Indicates an IO wakeup from HSI CAWAKE
*
* @hsi_port - returns port number which triggered wakeup. Range [1, 2].
*	      Only valid if return value is 1 (HSI wakeup detected)
*
* Return value :* false if CAWAKE Padconf has not been found or no IOWAKEUP event
*		occured for CAWAKE.
*		* true if HSI wakeup detected on port *hsi_port
*/
bool omap_hsi_is_io_wakeup_from_hsi(int *hsi_port)
{
	struct hsi_port_ctx *port_ctx;
	u16 val;
	int i;

	for (i = 0; i < omap_hsi_platform_data.num_ports; i++) {
		port_ctx = &omap_hsi_platform_data.ctx->pctx[i];

	/* Check for IO pad wakeup */
		val = omap_mux_read_signal(port_ctx->cawake_padconf_name);
	if (val == -ENODEV)
			continue;

	/* Continue only if CAWAKE is muxed */
		if ((val & OMAP_MUX_MODE_MASK) !=
					port_ctx->cawake_padconf_hsi_mode)
			continue;

		if (val & OMAP44XX_PADCONF_WAKEUPEVENT0) {
			*hsi_port = port_ctx->port_number;
		return true;
		}
	}

	*hsi_port = 0;

	return false;
}
/**
* omap_hsi_is_io_pad_hsi - Indicates if IO Pad has been muxed for HSI CAWAKE
*
* Return value :* 0 if CAWAKE Padconf has not been found or CAWAKE not muxed for
*		CAWAKE
*		* else 1
*/
static int omap_hsi_is_io_pad_hsi(void)
{
	u16 val;

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

	/* Continue only if CAWAKE is muxed */
	if ((val & OMAP_MUX_MODE_MASK) != OMAP_HSI_PADCONF_CAWAKE_MODE)
		return 0;

	return 1;
}
/**
* omap_hsi_is_io_wakeup_from_hsi - Indicates an IO wakeup from HSI CAWAKE
*
* Return value :* 0 if CAWAKE Padconf has not been found or no IOWAKEUP event
*		occured for CAWAKE
*		* else 1
*/
int omap_hsi_is_io_wakeup_from_hsi(void)
{
	u16 val;

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

	/* Continue only if CAWAKE is muxed */
	if ((val & OMAP_MUX_MODE_MASK) != OMAP_HSI_PADCONF_CAWAKE_MODE)
		return 0;

	if (val & OMAP44XX_PADCONF_WAKEUPEVENT0)
		return 1;

	return 0;
}
Beispiel #4
0
/**
* omap_hsi_is_io_pad_hsi - Indicates if IO Pad has been muxed for HSI CAWAKE
*
* @hsi_port - port number to check for HSI muxing. Range [1, 2]
*
* Return value :* 0 if CAWAKE Padconf has not been found or CAWAKE not muxed for
*		CAWAKE
*		* else 1
*/
static int omap_hsi_is_io_pad_hsi(int hsi_port)
{
	struct hsi_port_ctx *port_ctx;
	u16 val;

	port_ctx = hsi_get_hsi_port_ctx_data(hsi_port);
	if (!port_ctx)
		return 0;

	/* Check for IO pad */
	val = omap_mux_read_signal(port_ctx->cawake_padconf_name);
	if (val == -ENODEV)
		return 0;

	/* Continue only if CAWAKE is muxed */
	if ((val & OMAP_MUX_MODE_MASK) != port_ctx->cawake_padconf_hsi_mode)
		return 0;

	return 1;
}
Beispiel #5
0
/**
* omap_hsi_resume_idle - Prepare HSI for wakeup from low power
*
* Return value :* -ENODEV if HSI platform device or HSI controller or CAWAKE
*		  Padconf has not been found
*		* -EPERM if HSI is not allowed to wakeup the platform.
*		* else 0.
*
*/
int omap_hsi_resume_idle(void)
{
	struct platform_device *pdev;
	struct hsi_dev *hsi_ctrl;
	u16 val;

	pdev = hsi_get_hsi_platform_device();
	if (!pdev)
		return -ENODEV;
	if (!device_may_wakeup(&pdev->dev))
		return -EPERM;

	hsi_ctrl = hsi_get_hsi_controller_data(pdev);
	if (!hsi_ctrl)
		return -ENODEV;

	/* Check for IO pad wakeup */
	val = omap_mux_read_signal(OMAP_HSI_PADCONF_CAWAKE_PIN);

	if (val == -ENODEV)
		return val;

	if (val & OMAP44XX_PADCONF_WAKEUPEVENT0) {
		dev_dbg(hsi_ctrl->dev, "HSI WAKEUP DETECTED from PADCONF : "
				       "0x%04x\n", val);

		/* CAWAKE falling or rising edge detected */
		hsi_ctrl->hsi_port->cawake_off_event = true;
		tasklet_hi_schedule(&hsi_ctrl->hsi_port->hsi_tasklet);

		/* Disable interrupt until Bottom Half has cleared */
		/* the IRQ status register */
		disable_irq_nosync(hsi_ctrl->hsi_port->irq);
	}

	return 0;
}
/**
* 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;
}
/**
* omap_hsi_is_io_wakeup_from_hsi - Indicates an IO wakeup from HSI CAWAKE
*
* Return value :* 0 if CAWAKE Padconf has not been found or no IOWAKEUP event
*		occured for CAWAKE
*		* else 1
*/
int omap_hsi_is_io_wakeup_from_hsi(void)
{
	u16 val = 0;

	/* Check for IO pad wakeup */
#ifdef CONFIG_OMAP_MUX
	val = omap_mux_read_signal(OMAP_HSI_PADCONF_CAWAKE_PIN);
#else
	if (cpu_is_omap44xx())
		val = omap_readw(OMAP443X_CTRL_BASE +
			OMAP4_CTRL_MODULE_PAD_USBB1_ULPITLL_CLK_OFFSET);
#endif
	if (val == -ENODEV)
		return 0;

	/* Continue only if CAWAKE is muxed */
	if ((val & OMAP_MUX_MODE_MASK) != OMAP_HSI_PADCONF_CAWAKE_MODE)
		return 0;

	if (val & OMAP44XX_PADCONF_WAKEUPEVENT0)
		return 1;

	return 0;
}