Esempio n. 1
0
/**
* hsi_clocks_enable_channel - virtual wrapper for enabling HSI clocks for
* a given channel
* @dev - reference to the hsi device.
* @channel_number - channel number which requests clock to be enabled
*		    0xFF means no particular channel
*
* Returns: -EEXIST if clocks were already active
*	   0 if clocks were previously inactive
*
* Note : there is no real HW clock management per HSI channel, this is only
* virtual to keep track of active channels and ease debug
*
* Function to be called with lock
*/
int hsi_clocks_enable_channel(struct device *dev, u8 channel_number,
				const char *s)
{
	struct platform_device *pd = to_platform_device(dev);
	struct hsi_dev *hsi_ctrl = platform_get_drvdata(pd);

	if (channel_number != HSI_CH_NUMBER_NONE)
		dev_dbg(dev, "CLK: hsi_clocks_enable for "
			"channel %d: %s\n", channel_number, s);
	else
		dev_dbg(dev, "CLK: hsi_clocks_enable: %s\n", s);

	if (hsi_ctrl->clock_enabled) {
		dev_dbg(dev, "Clocks already enabled, skipping...\n");
		return -EEXIST;
	}

#ifdef K3_0_PORTING_HSI_MISSING_FEATURE
	/* Prevent Fclk change */
	if (dpll_cascading_blocker_hold(dev) < 0)
		dev_warn(dev, "Error holding DPLL cascading constraint\n");
#endif

	return pm_runtime_get_sync(dev);
}
Esempio n. 2
0
/**
* hsi_clocks_enable_channel - virtual wrapper for enabling HSI clocks for
* a given channel
* @dev - reference to the hsi device.
* @channel_number - channel number which requests clock to be enabled
*		    0xFF means no particular channel
*
* Returns: 1 if clocks were already active
*	   0 if clocks were previously inactive
*	   < 0 if failed to activate clocks
*
* Note : there is no real HW clock management per HSI channel, this is only
* virtual to keep track of active channels and ease debug
*
* Function to be called with lock
*/
int hsi_clocks_enable_channel(struct device *dev, u8 channel_number,
				const char *s)
{
	struct platform_device *pd = to_platform_device(dev);
	struct hsi_platform_data *pdata = dev_get_platdata(dev);
	struct hsi_dev *hsi_ctrl = platform_get_drvdata(pd);
	int ret;

	if (channel_number != HSI_CH_NUMBER_NONE)
		dev_dbg(dev, "CLK: hsi_clocks_enable for "
			"channel %d: %s\n", channel_number, s);
	else
		dev_dbg(dev, "CLK: hsi_clocks_enable: %s\n", s);

	if (hsi_ctrl->clock_enabled) {
		dev_dbg(dev, "Clocks already enabled, skipping...\n");
		return 1;
	}

#ifdef CONFIG_PM
	/* Prevent Fclk change */
	if (dpll_cascading_blocker_hold(dev) < 0)
		dev_warn(dev, "Error holding DPLL cascading constraint\n");
#endif /* CONFIG_PM */

#ifndef USE_PM_RUNTIME_FOR_HSI
	ret = pdata->device_enable(pd);
	if (ret < 0) {
		dev_err(dev, "Failed to enable device: %s %d\n", s, ret);
		return ret;
	}
	hsi_runtime_resume(dev);
	return 0;
#else
	return pm_runtime_get_sync(dev);
#endif
}
static int bluetooth_set_power(void *data, enum rfkill_user_states state)
{
	int ret = 0;

	switch (state) {

	case RFKILL_USER_STATE_UNBLOCKED:
		pr_info("[BT] Device Powering ON\n");

		if (gpio_is_valid(OMAP_GPIO_BT_EN))
			gpio_direction_output(OMAP_GPIO_BT_EN, GPIO_LEVEL_HIGH);

		if (gpio_is_valid(OMAP_GPIO_BT_nRST))
			gpio_direction_output(OMAP_GPIO_BT_nRST, GPIO_LEVEL_HIGH);

		pr_debug("[BT] GPIO_BT_nRST = %d\n",
				gpio_get_value(OMAP_GPIO_BT_nRST));
		pr_debug("[BT] GPIO_BT_EN = %d\n",
				gpio_get_value(OMAP_GPIO_BT_EN));

		/* BT reset toggle for preventing BT on fail... */
		if (gpio_is_valid(OMAP_GPIO_BT_nRST))
			gpio_direction_output(OMAP_GPIO_BT_nRST, GPIO_LEVEL_LOW);
		msleep(20);
		if (gpio_is_valid(OMAP_GPIO_BT_nRST))
			gpio_direction_output(OMAP_GPIO_BT_nRST, GPIO_LEVEL_HIGH);

		ret = enable_irq_wake(irq);
		if (ret < 0)
			pr_err("[BT] set wakeup src failed\n");

		enable_irq(irq);

		dpll_cascading_blocker_hold(&bt_dev->dev);

		break;

	case RFKILL_USER_STATE_SOFT_BLOCKED:
		pr_info("[BT] Device Powering OFF\n");

		ret = disable_irq_wake(irq);
		if (ret < 0)
			pr_err("[BT] unset wakeup src failed\n");

		disable_irq(irq);
		wake_unlock(&rfkill_wake_lock);

		gpio_direction_output(OMAP_GPIO_BT_nRST, GPIO_LEVEL_LOW);
		pr_debug("[BT] GPIO_BT_nRST = %d\n",
				gpio_get_value(OMAP_GPIO_BT_nRST));

		gpio_direction_output(OMAP_GPIO_BT_EN, GPIO_LEVEL_LOW);
		pr_debug("[BT] GPIO_BT_EN = %d\n",
				gpio_get_value(OMAP_GPIO_BT_EN));

		dpll_cascading_blocker_release(&bt_dev->dev);

		break;

	default:
		pr_err("[BT] Bad bluetooth rfkill state %d\n", state);
	}

	return 0;
}