コード例 #1
0
int desirec_wifi_power(int on)
{
	int rc;

	printk(KERN_INFO "%s: %d\n", __func__, on);

	if (on) {
		config_gpio_table(wifi_on_gpio_table,
				  ARRAY_SIZE(wifi_on_gpio_table));
		mdelay(50);
		rc = vreg_enable(vreg_wifi_osc);
		vreg_set_level(vreg_wifi_osc, 1800);
		mdelay(50);
		if (rc)
			return rc;
		htc_pwrsink_set(PWRSINK_WIFI, 70);
	} else {
		config_gpio_table(wifi_off_gpio_table,
				  ARRAY_SIZE(wifi_off_gpio_table));
		htc_pwrsink_set(PWRSINK_WIFI, 0);
	}

	gpio_set_value(DESIREC_GPIO_WIFI_EN, on);
	mdelay(100);

	if (!on) {
		if(!desirec_bt_power_state)
			vreg_disable(vreg_wifi_osc);
		else
			printk(KERN_ERR "WiFi shouldn't disable "
				"vreg_wifi_osc. BT is using it!!\n");
	}
	desirec_wifi_power_state = on;
	return 0;
}
コード例 #2
0
int sapphire_wifi_power(int on)
{
	int rc;

	printk(KERN_DEBUG "%s: %d\n", __func__, on);

	if (on) {
		config_gpio_table(wifi_on_gpio_table,
				  ARRAY_SIZE(wifi_on_gpio_table));
		rc = vreg_enable(vreg_wifi_osc);
		if (rc)
			return rc;
		htc_pwrsink_set(PWRSINK_WIFI, 70);
	} else {
		config_gpio_table(wifi_off_gpio_table,
				  ARRAY_SIZE(wifi_off_gpio_table));
		htc_pwrsink_set(PWRSINK_WIFI, 0);
	}
	gpio_set_value(SAPPHIRE_GPIO_MAC_32K_EN, on);
	mdelay(100);
	gpio_set_value(SAPPHIRE_GPIO_WIFI_EN, on);
	mdelay(100);
	if (!on) {
		if(!sapphire_bt_power_state)
		{
		vreg_disable(vreg_wifi_osc);
			printk("WiFi disable vreg_wifi_osc.\n");
		}
		else
			printk("WiFi shouldn't disable vreg_wifi_osc. BT is using it!!\n");
	}
	sapphire_wifi_power_state = on;
	return 0;
}
コード例 #3
0
int trout_wifi_power(int on)
{
	int rc;

	printk("%s: %d\n", __func__, on);

	if (on) {
		config_gpio_table(wifi_on_gpio_table,
				  ARRAY_SIZE(wifi_on_gpio_table));
		rc = vreg_enable(vreg_wifi_osc);
		if (rc)
			return rc;
		htc_pwrsink_set(PWRSINK_WIFI, 70);
	} else {
		config_gpio_table(wifi_off_gpio_table,
				  ARRAY_SIZE(wifi_off_gpio_table));
		htc_pwrsink_set(PWRSINK_WIFI, 0);
	}
	gpio_set_value( TROUT_GPIO_MAC_32K_EN, on);
	mdelay(100);
	gpio_set_value( TROUT_GPIO_WIFI_EN, on);
	mdelay(100);
	if (!on) {
		vreg_disable(vreg_wifi_osc);
	}
	trout_wifi_power_state = on;
	return 0;
}
コード例 #4
0
ファイル: board-trout-gpio.c プロジェクト: Soaa-/-lightspeed
static void update_pwrsink(unsigned gpio, unsigned on)
{
	switch(gpio) {
	case TROUT_GPIO_UI_LED_EN:
		htc_pwrsink_set(PWRSINK_LED_BUTTON, on ? 100 : 0);
		break;
	case TROUT_GPIO_QTKEY_LED_EN:
		htc_pwrsink_set(PWRSINK_LED_KEYBOARD, on ? 100 : 0);
		break;
	}
}
コード例 #5
0
/* must be called with audio->lock held */
static int audio_enable(struct audio *audio)
{
	pr_info("audio_enable\n");

	if (audio->enabled)
		return 0;

	/* refuse to start if we're not ready */
	if (!audio->out[0].used || !audio->out[1].used)
		return -EIO;

	/* we start buffers 0 and 1, so buffer 0 will be the
	 * next one the dsp will want
	 */
	audio->out_tail = 0;
	audio->out_needed = 0;

	audio_prevent_sleep(audio);

	if (audpp_enable(-1, audio_dsp_event, audio)) {
		MM_ERR("audpp_enable() failed\n");
		audio_allow_sleep(audio);
		return -ENODEV;
	}

	audio->enabled = 1;
	htc_pwrsink_set(PWRSINK_AUDIO, 100);
	return 0;
}
コード例 #6
0
ファイル: audio_out.c プロジェクト: Mcjesus15/Zio_Kernel
/* must be called with audio->lock held */
static int audio_enable(struct audio *audio)
{
	struct audmgr_config cfg;
	int rc;

	MM_INFO("[CLK]\n"); /* Macro prints the file name and function */

	if (audio->enabled)
		return 0;	

	/* refuse to start if we're not ready */
	if (!audio->out[0].used || !audio->out[1].used)
		return -EIO;

	/* we start buffers 0 and 1, so buffer 0 will be the
	 * next one the dsp will want
	 */
	audio->out_tail = 0;
	audio->out_needed = 0;

	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
	cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM;
	cfg.codec = RPC_AUD_DEF_CODEC_PCM;
	cfg.snd_method = RPC_SND_METHOD_MIDI;

	audio_prevent_sleep(audio);	
	rc = audmgr_enable(&audio->audmgr, &cfg);
	if (rc < 0) {
		audio_allow_sleep(audio);
		return rc;
	}

#ifdef CONFIG_CCI_SPEAKER
	/*cci.johnny_lee, for pop-noise issue */
	MM_INFO("[CLK] speaker_audmgr_enable(true)\n");
	if (speaker_audmgr_enable(true) < 0)
	{
		MM_ERR("[CLK] speaker_audmgr_enable return failed, we will retry after 600ms\n");
	}
	else
	{
		msleep(80);
	}
#endif

	if (audpp_enable(-1, audio_dsp_event, audio)) {
		MM_ERR("audpp_enable() failed\n");
		audmgr_disable(&audio->audmgr);
		audio_allow_sleep(audio);
		return -ENODEV;
	}

	audio->enabled = 1;
	htc_pwrsink_set(PWRSINK_AUDIO, 100);
	return 0;
}
コード例 #7
0
ファイル: htc_pwrsink.c プロジェクト: robcore/machinex
int htc_pwrsink_resume_early(struct platform_device *pdev)
{
	struct pwr_sink_platform_data *pdata = pdev->dev.platform_data;

	if (pdata && pdata->resume_early)
		pdata->resume_early(pdev);
	else
		htc_pwrsink_set(PWRSINK_SYSTEM_LOAD, 70);
	return 0;
}
コード例 #8
0
ファイル: htc_pwrsink.c プロジェクト: robcore/machinex
int htc_pwrsink_suspend_late(struct platform_device *pdev, pm_message_t state)
{
	struct pwr_sink_platform_data *pdata = pdev->dev.platform_data;

	if (pdata && pdata->suspend_late)
		pdata->suspend_late(pdev, state);
	else
		htc_pwrsink_set(PWRSINK_SYSTEM_LOAD, 13);
	return 0;
}
コード例 #9
0
ファイル: htc_pwrsink.c プロジェクト: robcore/machinex
static void compute_audio_current(void)
{
	/* unsigned long flags; */
	unsigned max_percent = 0;
	int i, active_audio_sinks = 0;
	pwrsink_audio_id_type last_active_audio_sink = 0;

	/* Make sure this segment will be spinlocked
	before computing by calling function. */
	/* spin_lock_irqsave(&audio_sink_lock, flags); */
	for (i = 0; i <= PWRSINK_AUDIO_LAST; ++i) {
		max_percent = (audio_sink_array[i].percent > max_percent) ?
				audio_sink_array[i].percent : max_percent;
		if (audio_sink_array[i].percent > 0) {
			active_audio_sinks++;
			last_active_audio_sink = i;
		}
	}
	if (active_audio_sinks == 0)
		htc_pwrsink_set(PWRSINK_AUDIO, 0);
	else if (active_audio_sinks == 1) {
		pwrsink_audio_id_type laas =  last_active_audio_sink;
		/* TODO: add volume and routing path current. */
		if (audio_path == 1)	/* Speaker */
			htc_pwrsink_set(PWRSINK_AUDIO,
				audio_sink_array[laas].percent);
		else
			htc_pwrsink_set(PWRSINK_AUDIO,
				audio_sink_array[laas].percent * 9 / 10);
	} else if (active_audio_sinks > 1) {
		/* TODO: add volume and routing path current. */
		if (audio_path == 1)	/* Speaker */
			htc_pwrsink_set(PWRSINK_AUDIO, max_percent);
		else
			htc_pwrsink_set(PWRSINK_AUDIO, max_percent * 9 / 10);
	}
	/* spin_unlock_irqrestore(&audio_sink_lock, flags); */

	if (pwrsink_debug_mask & PWRSINK_DEBUG_CURR_CHANGE_AUDIO)
		pr_info("%s: active_audio_sinks=%d, audio_path=%d\n", __func__,
				active_audio_sinks, audio_path);
}
コード例 #10
0
ファイル: audio_out.c プロジェクト: chraso/GT-I5500_
/* must be called with audio->lock held */
static int audio_enable(struct audio *audio)
{
	struct audmgr_config cfg;
	int rc;

	MM_INFO("\n"); /* Macro prints the file name and function */

	if (audio->enabled)
		return 0;	

	/* refuse to start if we're not ready */
	if (!audio->out[0].used || !audio->out[1].used)
		return -EIO;

	/* we start buffers 0 and 1, so buffer 0 will be the
	 * next one the dsp will want
	 */
	audio->out_tail = 0;
	audio->out_needed = 0;

	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
	cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM;
	cfg.codec = RPC_AUD_DEF_CODEC_PCM;
	cfg.snd_method = RPC_SND_METHOD_MIDI;

	audio_prevent_sleep(audio);	
	rc = audmgr_enable(&audio->audmgr, &cfg);
	if (rc < 0) {
		audio_allow_sleep(audio);
		return rc;
	}

#ifdef CONFIG_AMP_MAX97000
	if(!audio_enabled)
	{
		audio_enabled = 1;
		//max97000_resume();
	}
#endif
	if (audpp_enable(-1, audio_dsp_event, audio)) {
		MM_ERR("audpp_enable() failed\n");
		audmgr_disable(&audio->audmgr);
		audio_allow_sleep(audio);
		return -ENODEV;
	}

	audio->enabled = 1;
	htc_pwrsink_set(PWRSINK_AUDIO, 100);
	return 0;
}
コード例 #11
0
int legend_wifi_power(int on)
{
	int rc = 0;

	printk(KERN_INFO "%s: %d\n", __func__, on);

	if (on) {
		config_gpio_table(wifi_on_gpio_table,
				  ARRAY_SIZE(wifi_on_gpio_table));

		fast_clk_ctl(1, ID_WIFI);
		mdelay(100);

		gpio_set_value(LEGEND_GPIO_WIFI_EN, 1);
		mdelay(50);
		gpio_set_value(LEGEND_GPIO_WIFI_EN, 0);
		mdelay(1);
		gpio_set_value(LEGEND_GPIO_WIFI_EN, 1);
		mdelay(200);
		htc_pwrsink_set(PWRSINK_WIFI, 70);


		if (rc)
			return rc;
	} else {
		config_gpio_table(wifi_off_gpio_table,
				  ARRAY_SIZE(wifi_off_gpio_table));
		gpio_set_value(LEGEND_GPIO_WIFI_EN, on);
		mdelay(10);

		htc_pwrsink_set(PWRSINK_WIFI, 0);

		fast_clk_ctl(0, ID_WIFI);
	}

	return 0;
}
コード例 #12
0
int bahamas_wifi_power(int on)
{
	int rc;

	printk("%s: %d\n", __func__, on);

	if (on) {
		config_gpio_table(wifi_on_gpio_table,
				  ARRAY_SIZE(wifi_on_gpio_table));
		vreg_enable(vreg_wifi_batpa);
		vreg_set_level(vreg_wifi_batpa, 3000);
		mdelay(50);
		rc = vreg_enable(vreg_wifi_osc);
		vreg_set_level(vreg_wifi_osc, 1800);
		mdelay(50);
		htc_pwrsink_set(PWRSINK_WIFI, 70);
		if (rc)
			return rc;
	} else {
		config_gpio_table(wifi_off_gpio_table,
				  ARRAY_SIZE(wifi_off_gpio_table));
		htc_pwrsink_set(PWRSINK_WIFI, 0);
	}
	mdelay(100);
	gpio_set_value( BAHAMAS_GPIO_WIFI_EN, on);
	mdelay(100);
	if (!on) {
		if (!bahamas_bt_power_state) {
			vreg_disable(vreg_wifi_osc);
			vreg_disable(vreg_wifi_batpa);
			printk("WiFi disable vreg_wifi_osc.\n");
		} else
			printk("WiFi shouldn't disable vreg_wifi_osc. BT is using it!!\n");
	}
	bahamas_wifi_power_state = on;
	return 0;
}
コード例 #13
0
ファイル: audio_out.c プロジェクト: Redux/rx-kernel
/* must be called with audio->lock held */
static int audio_enable(struct audio *audio)
{
	struct audmgr_config cfg;
	int rc;

	pr_info("audio_enable()\n");

	if (audio->enabled)
		return 0;	

	/* refuse to start if we're not ready */
	if (!audio->out[0].used || !audio->out[1].used)
		return -EIO;

	/* we start buffers 0 and 1, so buffer 0 will be the
	 * next one the dsp will want
	 */
	audio->out_tail = 0;
	audio->out_needed = 0;

	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
	cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM;
	cfg.codec = RPC_AUD_DEF_CODEC_PCM;
	cfg.snd_method = RPC_SND_METHOD_MIDI;

	audio_prevent_sleep(audio);	
	rc = audmgr_enable(&audio->audmgr, &cfg);
	if (rc < 0) {
		audio_allow_sleep(audio);
		return rc;
	}

	if (audpp_enable(-1, audio_dsp_event, audio)) {
		pr_err("audio: audpp_enable() failed\n");
		audmgr_disable(&audio->audmgr);
		audio_allow_sleep(audio);
		return -ENODEV;
	}

	audio->enabled = 1;
	htc_pwrsink_set(PWRSINK_AUDIO, 100);
	return 0;
}
コード例 #14
0
ファイル: htc_pwrsink.c プロジェクト: robcore/machinex
void htc_pwrsink_suspend_early(struct power_suspend *h)
{
	htc_pwrsink_set(PWRSINK_SYSTEM_LOAD, 70);
}
コード例 #15
0
static void
msmsdcc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
	struct msmsdcc_host *host = mmc_priv(mmc);
	u32 clk = 0, pwr = 0;
	int rc;

	DBG(host, "ios->clock = %u\n", ios->clock);

	if (ios->clock) {

		if (!host->clks_on) {
			clk_enable(host->pclk);
			clk_enable(host->clk);
			host->clks_on = 1;
		}

		if ((ios->clock < msmsdcc_fmax) && (ios->clock > msmsdcc_fmid))
			ios->clock = msmsdcc_fmid;

		if (ios->clock != host->clk_rate) {
			rc = clk_set_rate(host->clk, ios->clock);
			if (rc < 0) {
				rc = clk_set_rate(host->clk, msmsdcc_temp);
				WARN_ON(rc < 0);
				host->clk_rate = msmsdcc_temp;
			} else
				host->clk_rate = ios->clock;
		}
		clk |= MCI_CLK_ENABLE;
	}

	if (ios->bus_width == MMC_BUS_WIDTH_8)
		clk |= MCI_CLK_WIDEBUS_8;
	else if (ios->bus_width == MMC_BUS_WIDTH_4)
		clk |= MCI_CLK_WIDEBUS_4;
	else
		clk |= MCI_CLK_WIDEBUS_1;

	if (ios->clock > 400000 && msmsdcc_pwrsave)
		clk |= MCI_CLK_PWRSAVE;

	clk |= MCI_CLK_FLOWENA;
	clk |= MCI_CLK_SELECTIN; /* feedback clock */

	if (host->plat->translate_vdd)
		pwr |= host->plat->translate_vdd(mmc_dev(mmc), ios->vdd);

	switch (ios->power_mode) {
	case MMC_POWER_OFF:
		htc_pwrsink_set(PWRSINK_SDCARD, 0);
		break;
	case MMC_POWER_UP:
		pwr |= MCI_PWR_UP;
		break;
	case MMC_POWER_ON:
		htc_pwrsink_set(PWRSINK_SDCARD, 100);
		pwr |= MCI_PWR_ON;
		break;
	}

	if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
		pwr |= MCI_OD;

	writel(clk, host->base + MMCICLOCK);

	if (host->pwr != pwr) {
		host->pwr = pwr;
		writel(pwr, host->base + MMCIPOWER);
	}

	if (!(clk & MCI_CLK_ENABLE) && host->clks_on) {
		clk_disable(host->clk);
		clk_disable(host->pclk);
		host->clks_on = 0;
	}
}
コード例 #16
0
static void
msmsdcc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
	struct msmsdcc_host *host = mmc_priv(mmc);
	u32 clk = 0, pwr = 0;
	int rc;

	if (ios->clock) {

		if (!host->clks_on) {
			clk_enable(host->pclk);
			clk_enable(host->clk);
			host->clks_on = 1;
		}
		if (ios->clock != host->clk_rate) {
			rc = clk_set_rate(host->clk, ios->clock);
			if (rc < 0)
				printk(KERN_ERR
				       "Error setting clock rate (%d)\n", rc);
			else
				host->clk_rate = ios->clock;
		}
		clk |= MCI_CLK_ENABLE;
	}

	if (ios->bus_width == MMC_BUS_WIDTH_4)
		clk |= (2 << 10); /* Set WIDEBUS */

	if (ios->clock > 400000 && msmsdcc_pwrsave)
		clk |= (1 << 9); /* PWRSAVE */

	clk |= (1 << 12); /* FLOW_ENA */
	clk |= (1 << 15); /* feedback clock */

	if (host->plat->translate_vdd)
		pwr |= host->plat->translate_vdd(mmc_dev(mmc), ios->vdd);

	switch (ios->power_mode) {
	case MMC_POWER_OFF:
		htc_pwrsink_set(PWRSINK_SDCARD, 0);
		break;
	case MMC_POWER_UP:
		pwr |= MCI_PWR_UP;
		break;
	case MMC_POWER_ON:
		htc_pwrsink_set(PWRSINK_SDCARD, 100);
		pwr |= MCI_PWR_ON;
		break;
	}

	if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
		pwr |= MCI_OD;

	writel(clk, host->base + MMCICLOCK);

	if (host->pwr != pwr) {
		host->pwr = pwr;
		writel(pwr, host->base + MMCIPOWER);
	}

	if (!(clk & MCI_CLK_ENABLE) && host->clks_on) {
		clk_disable(host->clk);
		clk_disable(host->pclk);
		host->clks_on = 0;
	}
}
コード例 #17
0
static int marvelc_pwrsink_suspend_late(struct platform_device *pdev, pm_message_t state)
{
	htc_pwrsink_set(PWRSINK_SYSTEM_LOAD, 1);
	return 0;
}
コード例 #18
0
static void marvelc_pwrsink_suspend_early(struct early_suspend *h)
{
	htc_pwrsink_set(PWRSINK_SYSTEM_LOAD, 7);
}
コード例 #19
0
static void marvelc_pwrsink_resume_late(struct early_suspend *h)
{
	htc_pwrsink_set(PWRSINK_SYSTEM_LOAD, 38);
}
コード例 #20
0
ファイル: htc_pwrsink.c プロジェクト: robcore/machinex
void htc_pwrsink_resume_late(struct power_suspend *h)
{
	htc_pwrsink_set(PWRSINK_SYSTEM_LOAD, 100);
}
コード例 #21
0
ファイル: mmc.c プロジェクト: tripleoxygen/kernel_zeebo
//XXX: trout_wifi_power() is hard-coded in wlan driver
int trout_wifi_power(int on)
{
	int rc;

	printk("%s: %d\n", __func__, on);

	if (on) {
		config_gpio_table(mmc_pdata.sdc1_on_gpio_table,
				  mmc_pdata.sdc1_on_gpio_table_size);

		rc = vreg_enable(vreg_wifi_osc);
		if (rc)
			return rc;
		rc = vreg_enable(vreg_wifi_2);
		if (rc)
			return rc;

		if (machine_is_htctopaz()) {
			rc = vreg_enable(vreg_wifi_3);
			if (rc)
				return rc;
		}
		mdelay(100);
		htc_pwrsink_set(PWRSINK_WIFI, 70);
		gpio_direction_output(mmc_pdata.wifi_power_gpio1, 0);
		if (mmc_pdata.wifi_power_gpio2 >= 0) {
			mdelay(50);
			gpio_direction_output(mmc_pdata.wifi_power_gpio2, 0);
		}
		mdelay(200);

	} else {
		config_gpio_table(mmc_pdata.sdc1_off_gpio_table,
				  mmc_pdata.sdc1_off_gpio_table_size);
		htc_pwrsink_set(PWRSINK_WIFI, 0);
	}
	gpio_direction_output(mmc_pdata.wifi_power_gpio1, on);
	mdelay(50);
	if (mmc_pdata.wifi_power_gpio2 >= 0) {
		gpio_direction_output(mmc_pdata.wifi_power_gpio2, on);
	}
	if (!machine_is_htcrhodium()) {
		/* Only used for TI WLAN */
		gpio_direction_input(29);
		set_irq_wake(gpio_to_irq(29), on);
	}
	mdelay(150);

	if (!on) {
		if (machine_is_htctopaz()) {
			vreg_disable(vreg_wifi_3);
			//These vregs shuts the phone off raph/diam(/blac?)
			//So don't disable it for them.
			//The radio chip is fair enough not to drain everything anyway.
			//vreg_disable(vreg_wifi_osc);
			//vreg_disable(vreg_wifi_2);
		}
	}
	wifi_power_state = on;
	return 0;
}
コード例 #22
0
static int marvelc_pwrsink_resume_early(struct platform_device *pdev)
{
	htc_pwrsink_set(PWRSINK_SYSTEM_LOAD, 7);
	return 0;
}
コード例 #23
0
static void desirec_pwrsink_resume_late(struct early_suspend *h)
{
    printk(KERN_INFO "desirec_pwrsink_resume_late\n");
    gpio_direction_output(DESIREC_GPIO_TP_EN, 1); /* for melfas workarround*/
    htc_pwrsink_set(PWRSINK_SYSTEM_LOAD, 38);
}