Exemplo n.º 1
0
int msm_spm_set_vdd(unsigned int vlevel)
{
    unsigned long flags;
    struct msm_spm_device *dev;
    uint32_t timeout_us;

    local_irq_save(flags);

    dev = &__get_cpu_var(msm_spm_devices);

    if (msm_spm_debug_mask & MSM_SPM_DEBUG_VCTL)
        pr_info("%s: requesting vlevel 0x%x\n", __func__, vlevel);

    msm_spm_set_vctl(dev, vlevel);
    msm_spm_flush_shadow(dev, MSM_SPM_REG_SAW_VCTL);

    /* Wait for PMIC state to return to idle or until timeout */
    timeout_us = dev->vctl_timeout_us;
    msm_spm_load_shadow(dev, MSM_SPM_REG_SAW_STS);
    while (msm_spm_get_sts_pmic_state(dev) != MSM_SPM_PMIC_STATE_IDLE) {
        if (!timeout_us)
            goto set_vdd_bail;

        if (timeout_us > 10) {
            udelay(10);
            timeout_us -= 10;
        } else {
            udelay(timeout_us);
            timeout_us = 0;
        }
        msm_spm_load_shadow(dev, MSM_SPM_REG_SAW_STS);
    }

    if (msm_spm_get_sts_curr_pmic_data(dev) != vlevel)
        goto set_vdd_bail;

    dev->awake_vlevel = vlevel;
    dev->dirty = true;

    if (msm_spm_debug_mask & MSM_SPM_DEBUG_VCTL)
        pr_info("%s: done, remaining timeout %uus\n", __func__,
                timeout_us);

    local_irq_restore(flags);
    return 0;

set_vdd_bail:
    pr_err("%s: failed, remaining timeout %uus, vlevel 0x%x\n",
           __func__, timeout_us, msm_spm_get_sts_curr_pmic_data(dev));
    local_irq_restore(flags);
    return -EIO;
}
Exemplo n.º 2
0
int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel)
{
	struct msm_spm_device *dev;
	uint32_t timeout_us;

	dev = &per_cpu(msm_spm_devices, cpu);

	if (msm_spm_debug_mask & MSM_SPM_DEBUG_VCTL)
		pr_info("%s: requesting cpu %u vlevel 0x%x\n",
			__func__, cpu, vlevel);

	msm_spm_set_vctl(dev, vlevel);
	msm_spm_flush_shadow(dev, MSM_SPM_REG_SAW_VCTL);

	
	timeout_us = dev->vctl_timeout_us;
	msm_spm_load_shadow(dev, MSM_SPM_REG_SAW_STS);
	while (msm_spm_get_sts_pmic_state(dev) != MSM_SPM_PMIC_STATE_IDLE) {
		if (!timeout_us)
			goto set_vdd_bail;

		if (timeout_us > 10) {
			udelay(10);
			timeout_us -= 10;
		} else {
			udelay(timeout_us);
			timeout_us = 0;
		}
		msm_spm_load_shadow(dev, MSM_SPM_REG_SAW_STS);
	}

	if (msm_spm_get_sts_curr_pmic_data(dev) != vlevel)
		goto set_vdd_bail;

	dev->awake_vlevel = vlevel;
	dev->dirty = true;

	if (msm_spm_debug_mask & MSM_SPM_DEBUG_VCTL)
		pr_info("%s: cpu %u done, remaining timeout %uus\n",
			__func__, cpu, timeout_us);

	return 0;

set_vdd_bail:
	pr_err("%s: cpu %u failed, remaining timeout %uus, vlevel 0x%x\n",
	       __func__, cpu, timeout_us, msm_spm_get_sts_curr_pmic_data(dev));

	return -EIO;
}
Exemplo n.º 3
0
int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel)
{
	unsigned long flags;
	struct msm_spm_device *dev;
	uint32_t timeout_us;

	local_irq_save(flags);

	if (!atomic_read(&msm_spm_set_vdd_x_cpu_allowed) &&
				unlikely(smp_processor_id() != cpu)) {
		if (msm_spm_debug_mask & MSM_SPM_DEBUG_VCTL)
			pr_info("%s: attempting to set vdd of cpu %u from "
				"cpu %u\n", __func__, cpu, smp_processor_id());
		goto set_vdd_x_cpu_bail;
	}

	dev = &per_cpu(msm_spm_devices, cpu);

	if (msm_spm_debug_mask & MSM_SPM_DEBUG_VCTL)
		pr_info("%s: requesting cpu %u vlevel 0x%x\n",
			__func__, cpu, vlevel);

	msm_spm_set_vctl(dev, vlevel);
	msm_spm_flush_shadow(dev, MSM_SPM_REG_SAW_VCTL);

	/* Wait for PMIC state to return to idle or until timeout */
	timeout_us = dev->vctl_timeout_us;
	msm_spm_load_shadow(dev, MSM_SPM_REG_SAW_STS);
	while (msm_spm_get_sts_pmic_state(dev) != MSM_SPM_PMIC_STATE_IDLE) {
		if (!timeout_us)
			goto set_vdd_bail;

		if (timeout_us > 10) {
			udelay(10);
			timeout_us -= 10;
		} else {
			udelay(timeout_us);
			timeout_us = 0;
		}
		msm_spm_load_shadow(dev, MSM_SPM_REG_SAW_STS);
	}

	if (msm_spm_get_sts_curr_pmic_data(dev) != vlevel)
		goto set_vdd_bail;

	dev->awake_vlevel = vlevel;
	dev->dirty = true;

	if (msm_spm_debug_mask & MSM_SPM_DEBUG_VCTL)
		pr_info("%s: cpu %u done, remaining timeout %uus\n",
			__func__, cpu, timeout_us);

	local_irq_restore(flags);
	return 0;

set_vdd_bail:
	pr_err("%s: cpu %u failed, remaining timeout %uus, vlevel 0x%x\n",
	       __func__, cpu, timeout_us, msm_spm_get_sts_curr_pmic_data(dev));

set_vdd_x_cpu_bail:
	local_irq_restore(flags);
	return -EIO;
}