int muic_set_safeout(int safeout_path)
{
	struct regulator *regulator;
	int ret;

	pr_info("%s:MUIC safeout path=%d\n", __func__, safeout_path);

	if (safeout_path == MUIC_PATH_USB_CP) {
		regulator = regulator_get(NULL, "safeout1_range");
		if (IS_ERR(regulator) || regulator == NULL)
			return -ENODEV;

		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);

		regulator = regulator_get(NULL, "safeout2_range");
		if (IS_ERR(regulator) || regulator == NULL)
			return -ENODEV;

		if (!regulator_is_enabled(regulator)) {
			ret = regulator_enable(regulator);
			if (ret)
				goto err;
		}
		regulator_put(regulator);
	} else if (safeout_path == MUIC_PATH_USB_AP) {
		regulator = regulator_get(NULL, "safeout1_range");
		if (IS_ERR(regulator) || regulator == NULL)
			return -ENODEV;

		if (!regulator_is_enabled(regulator)) {
			ret = regulator_enable(regulator);
			if (ret)
				goto err;
		}
		regulator_put(regulator);

		regulator = regulator_get(NULL, "safeout2_range");
		if (IS_ERR(regulator) || regulator == NULL)
			return -ENODEV;

		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);
	}  else {
		pr_info("%s: not control safeout(%d)\n", __func__, safeout_path);
		return -EINVAL;
	}

	return 0;
err:
	pr_info("%s: cannot regulator_enable (%d)\n", __func__, ret);
	regulator_put(regulator);
	return ret;
}
Пример #2
0
static int db8131m_power_down(void)
{
	struct regulator *regulator;
	int ret = 0;

	pr_debug("%s: in", __func__);

	db8131m_gpio_request();

	/* VT_CAM_nSTBY(1.3M EN) DIS */
	ret = gpio_direction_output(GPIO_VT_CAM_nSTBY, 0);
	CAM_CHECK_ERR_RET(ret, "low VT_CAM_nSTBY");

	/* CAM_VT_nRST(1.3M RESET) DIS */
	ret = gpio_direction_output(GPIO_CAM_VT_nRST, 0);
	CAM_CHECK_ERR_RET(ret, "low CAM_VT_nRST");

	/* MCLK */
	ret = s3c_gpio_cfgpin(GPIO_CAM_MCLK, S3C_GPIO_INPUT);
	s3c_gpio_setpull(GPIO_CAM_MCLK, S3C_GPIO_PULL_DOWN);
	CAM_CHECK_ERR(ret, "cfg mclk");

	/* CAM_DVDD_1.5V(1.3M Core 1.8V) */
	regulator = regulator_get(NULL, "cam_dvdd_1.5v");
	if (IS_ERR(regulator))
		return -ENODEV;
	if (regulator_is_enabled(regulator))
		ret = regulator_force_disable(regulator);
	regulator_put(regulator);
	CAM_CHECK_ERR_RET(ret, "disable cam_dvdd_1.5v");

	/* CAM_SENSOR_A2.8V */
	regulator = regulator_get(NULL, "cam_sensor_a2.8v");
	if (IS_ERR(regulator))
		return -ENODEV;
	if (regulator_is_enabled(regulator))
		ret = regulator_force_disable(regulator);
	regulator_put(regulator);
	CAM_CHECK_ERR_RET(ret, "disable cam_sensor_a2.8v");

	/* VT_CAM_1.8V(VDDIO) */
	regulator = regulator_get(NULL, "vt_cam_1.8v");
	if (IS_ERR(regulator))
		return -ENODEV;
	if (regulator_is_enabled(regulator))
		ret = regulator_force_disable(regulator);
	regulator_put(regulator);
	CAM_CHECK_ERR_RET(ret, "disable vt_cam_1.8v");

	gpio_free(GPIO_VT_CAM_nSTBY);
	gpio_free(GPIO_CAM_VT_nRST);
	gpio_free(GPIO_VT_CAM_ID);

	return ret;
}
Пример #3
0
static int ts_power_off(void)
{
	struct regulator *regulator;

	regulator = regulator_get(NULL, "touch_avdd");
	if (IS_ERR(regulator)) {
		printk(KERN_ERR "[TSP]ts_power_off : regulator_get failed\n");
		return -EIO;
	}

	if (regulator_is_enabled(regulator))
		regulator_force_disable(regulator);

	regulator_put(regulator);

	/* CAUTION : EVT1 board has CHG_INT problem
	* so it need a workaround code to ensure charging during sleep mode
	*/
	if (system_rev != 2) {
		regulator = regulator_get(NULL, "touch_vdd_1.8v");
		if (IS_ERR(regulator)) {
			printk(KERN_ERR "[TSP]ts_power_on : regulator_get failed\n");
			return -EIO;
		}

		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);

		regulator_put(regulator);
	}

	/* touch interrupt pin */
	s3c_gpio_cfgpin(GPIO_TOUCH_CHG, S3C_GPIO_INPUT);
	s3c_gpio_setpull(GPIO_TOUCH_CHG, S3C_GPIO_PULL_NONE);

	/* touch reset pin */
	s3c_gpio_cfgpin(GPIO_TOUCH_RESET, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_TOUCH_RESET, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_TOUCH_RESET, 0);

	/* touch xvdd en pin */
	s3c_gpio_cfgpin(GPIO_TOUCH_EN, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_TOUCH_EN, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_TOUCH_EN, 0);

	printk(KERN_ERR "mxt_power_off is finished\n");

	return 0;
}
Пример #4
0
static void vibrator_work(struct work_struct *_work)
{
	struct vibrator_drvdata *data =
		container_of(_work, struct vibrator_drvdata, work);

	printk(KERN_DEBUG "[VIB] time = %dms\n", data->timeout);

	if (0 == data->timeout) {
		if (!data->running)
			return ;
		regulator_force_disable(data->regulator);
		pwm_disable(data->pwm);
		i2c_max8997_hapticmotor(data, false);
		if (data->pdata->motor_en)
			data->pdata->motor_en(false);
		data->running = false;

	} else {
		if (data->running)
			return ;
		if (data->pdata->motor_en)
			data->pdata->motor_en(true);
		i2c_max8997_hapticmotor(data, true);
		pwm_config(data->pwm,
			data->pdata->duty, data->pdata->period);
		pwm_enable(data->pwm);
		regulator_enable(data->regulator);
		data->running = true;
	}
}
Пример #5
0
int key_led_control(bool on)
{
	struct regulator *regulator;

	if (tsp_keyled_enabled == on)
		return 0;

	printk(KERN_DEBUG "[TSP] %s %s\n",
		__func__, on ? "on" : "off");

	regulator = regulator_get(NULL, "vtouch_3.3v");
	if (IS_ERR(regulator))
		return PTR_ERR(regulator);

	if (on) {
		regulator_enable(regulator);
	} else {
		if (regulator_is_enabled(regulator))
			regulator_disable(regulator);
		else
			regulator_force_disable(regulator);
	}
	regulator_put(regulator);

	tsp_keyled_enabled = on;

	return 0;
}
static int vreg_diag_disable(int vreg_no)
{
	printk(DIAG_LOG_06 "[%04d]:%s() start.  vreg_no = %d\n", __LINE__,
							__func__, vreg_no);
	vreg_no -= 1;
	if (!reg_store[vreg_no]) {
		reg_store[vreg_no] = regulator_get(NULL, vreg_data[vreg_no].id);
		if (IS_ERR(reg_store[vreg_no])) {
			reg_store[vreg_no] = NULL;
			printk(DIAG_LOG_01 "[%04d]:%s() ERR\n", __LINE__,
								__func__);
			return -ENODEV;
		}
	}
	if (vreg_data[vreg_no].vreg_type != PMIC_VREG_VS) {
		regulator_set_voltage(reg_store[vreg_no], 0,
						vreg_data[vreg_no].max_uV);
		regulator_force_disable(reg_store[vreg_no]);
	}
	else
		regulator_disable(reg_store[vreg_no]);

	regulator_put(reg_store[vreg_no]);
	reg_store[vreg_no] = NULL;
	reg_volt_set_check[vreg_no] = 0;
	printk(DIAG_LOG_06 "[%04d]:%s() end.\n", __LINE__, __func__);
	return 0;
}
static int touchkey_led_power_on(bool on)
{
#ifdef LED_LDO_WITH_REGULATOR
	struct regulator *regulator;

	if (on) {
		regulator = regulator_get(NULL, TK_LED_REGULATOR_NAME);
		if (IS_ERR(regulator)) {
			printk(KERN_ERR
			"[Touchkey] touchkey_led_power_on : TK_LED regulator_get failed\n");
			return -EIO;
		}

		regulator_enable(regulator);
		regulator_put(regulator);
	} else {
		regulator = regulator_get(NULL, TK_LED_REGULATOR_NAME);
		if (IS_ERR(regulator)) {
			printk(KERN_ERR
			"[Touchkey] touchkey_led_power_on : TK_LED regulator_get failed\n");
			return -EIO;
		}

		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);
	}
#else
	if (on)
		gpio_direction_output(GPIO_3_TOUCH_EN, 1);
	else
		gpio_direction_output(GPIO_3_TOUCH_EN, 0);
#endif
	return 1;
}
Пример #8
0
int touchkey_ldo_on(bool on)
{
	struct regulator *regulator;

	if (on) {
		regulator = regulator_get(NULL, "touch");
		if (IS_ERR(regulator)){
			printk(KERN_ERR "[TouchKey] touchkey_ldo_on(1): regulator error \n");
			return 0;
		}
		regulator_enable(regulator);
		regulator_put(regulator);
	} else {
		regulator = regulator_get(NULL, "touch");
		if (IS_ERR(regulator)) {
			printk(KERN_ERR "[TouchKey] touchkey_ldo_on(0): regulator error \n");
			return 0;
		}
		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);
	}

	return 1;
}
static int usi_bm01a_power_onoff(int onoff)
{
	struct regulator* wifi_ldo = NULL;
	static int first = 1;
	  
#ifndef CONFIG_AW_AXP
	usi_msg("AXP driver is disabled, pls check !!\n");
	return 0;
#endif

	usi_msg("usi_bm01a_power_onoff\n");
	wifi_ldo = regulator_get(NULL, "axp20_pll");
	if (!wifi_ldo)
		usi_msg("Get power regulator failed\n");
	if (first) {
		usi_msg("first time\n");
		regulator_force_disable(wifi_ldo);
		first = 0;
	}
	if (onoff) {
		usi_msg("regulator on\n");
		regulator_set_voltage(wifi_ldo, 3300000, 3300000);
		regulator_enable(wifi_ldo);
	} else {
		usi_msg("regulator off\n");
		regulator_disable(wifi_ldo);
	}
	return 0;
}
Пример #10
0
static void pmic_safeout2(int onoff)
{
	struct regulator *regulator;

	regulator = regulator_get(NULL, "safeout2");
	BUG_ON(IS_ERR_OR_NULL(regulator));

	if (onoff) {
		if (!regulator_is_enabled(regulator)) {
			regulator_enable(regulator);
		} else {
			pr_err("%s: onoff:%d No change in safeout2\n",
			       __func__, onoff);
		}
	} else {
		if (regulator_is_enabled(regulator)) {
			regulator_force_disable(regulator);
		} else {
			pr_err("%s: onoff:%d No change in safeout2\n",
			       __func__, onoff);
		}
	}

	regulator_put(regulator);
}
Пример #11
0
static int ts_led_power_on(bool on)
{
	struct regulator *regulator;

	if (on) {
		regulator = regulator_get(NULL, "key_led_3.3v");
		if (IS_ERR(regulator)) {
			printk(KERN_ERR "[TSP_KEY] ts_led_power_on : TK_LED regulator_get failed\n");
			return -EIO;
		}

		regulator_enable(regulator);
		regulator_put(regulator);
	} else {
		regulator = regulator_get(NULL, "key_led_3.3v");
		if (IS_ERR(regulator)) {
			printk(KERN_ERR "[TSP_KEY] ts_led_power_on : TK_LED regulator_get failed\n");
			return -EIO;
		}

		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);
	}

	printk(KERN_ERR "[TSP_KEY] %s %s\n", __func__, on ? "on" : "off");

	return 0;
}
Пример #12
0
static void vibrator_work(struct work_struct *_work)
{
	struct vibrator_drvdata *data =
		container_of(_work, struct vibrator_drvdata, work);

	pr_debug("[VIB] time = %dms\n", data->timeout);

	if (0 == data->timeout) {
		if (!data->running)
			return ;
		pwm_disable(data->pwm);
		i2c_max8997_hapticmotor(data, false);
		if (data->pdata->motor_en)
			data->pdata->motor_en(false);
		else
			regulator_force_disable(data->regulator);
		data->running = false;

	} else {
		if (data->running)
			return ;
		if (data->pdata->motor_en)
			data->pdata->motor_en(true);
		else
			regulator_enable(data->regulator);
		i2c_max8997_hapticmotor(data, true);
		pwm_config(data->pwm, pwm_duty, data->pdata->period);
		pr_info("[VIB] %s: pwm_config duty=%d\n", __func__, pwm_duty);
		pwm_enable(data->pwm);

		data->running = true;
	}
}
int wacom_power(bool on)
{
#ifdef GPIO_PEN_LDO_EN
	gpio_direction_output(GPIO_PEN_LDO_EN, on);
#else
	struct regulator *regulator_vdd;

	if (wacom_power_enabled == on) {
		printk(KERN_DEBUG "epen: %s %s\n",
			__func__, on ? "on" : "off");
		return 0;
	}

	regulator_vdd = regulator_get(NULL, "wacom_3.0v");
	if (IS_ERR(regulator_vdd)) {
		printk(KERN_ERR"epen: %s reg get err\n", __func__);
		return PTR_ERR(regulator_vdd);
	}

	if (on) {
		regulator_enable(regulator_vdd);
	} else {
		if (regulator_is_enabled(regulator_vdd))
			regulator_disable(regulator_vdd);
		else
			regulator_force_disable(regulator_vdd);
	}
	regulator_put(regulator_vdd);
	printk(KERN_DEBUG "epen: %s %s\n",
		__func__, on ? "on" : "off");

	wacom_power_enabled = on;
#endif
	return 0;
}
Пример #14
0
void vibtonz_en(bool en)
{
	struct vibrator_drvdata	*data = g_data;

	if (en) {
		if (data->running)
			return ;
		if (data->pdata->motor_en)
			data->pdata->motor_en(true);
		else
			regulator_enable(data->regulator);
		i2c_max8997_hapticmotor(data, true);
		pwm_enable(data->pwm);
		data->running = true;
	} else {
		if (!data->running)
			return ;

		pwm_disable(data->pwm);
		i2c_max8997_hapticmotor(data, false);
		if (data->pdata->motor_en)
			data->pdata->motor_en(false);
		else
			regulator_force_disable(data->regulator);
		data->running = false;
	}
}
static int lcd_power_on(struct lcd_device *ld, int enable)
{
	struct regulator *regulator;

	if (ld == NULL) {
		printk(KERN_ERR "lcd device object is NULL.\n");
		return 0;
	}

	if (enable) {
		regulator = regulator_get(NULL, "vlcd_3.0v");
		if (IS_ERR(regulator))
			return 0;

		regulator_enable(regulator);
		regulator_put(regulator);
	} else {
		regulator = regulator_get(NULL, "vlcd_3.0v");

	if (IS_ERR(regulator))
		return 0;

	if (regulator_is_enabled(regulator))
		regulator_force_disable(regulator);

		regulator_put(regulator);
	}

	return 1;
}
Пример #16
0
static int mxt_power_off(void)
{
	struct regulator *regulator;

#if defined(TSP_DEBUG_LOG)
	printk(KERN_DEBUG "[TSP] %s\n", __func__);
#endif

	gpio_set_value(GPIO_TOUCH_RESET, 0);

	/* disable XVDD */
	gpio_set_value(GPIO_TOUCH_EN, 0);
	usleep_range(3000, 3000);
	gpio_set_value(GPIO_TOUCH_EN_1, 0);
	usleep_range(3000, 3000);

	/* disable I2C pullup */
	regulator = regulator_get(NULL, "tsp_vdd_1.8v");
	if (IS_ERR(regulator)) {
		printk(KERN_ERR "[TSP] %s : regulator_get failed\n",
			__func__);
		return -EIO;
	}

	if (regulator_is_enabled(regulator))
		regulator_disable(regulator);
	else
		regulator_force_disable(regulator);
	regulator_put(regulator);

	/* touch interrupt pin */
	s3c_gpio_cfgpin(GPIO_TOUCH_CHG, S3C_GPIO_INPUT);
	s3c_gpio_setpull(GPIO_TOUCH_CHG, S3C_GPIO_PULL_NONE);
	return 0;
}
static int ts_led_power_on(bool on)
{
	struct regulator *regulator;

	if (on) {
		regulator = regulator_get(NULL, "touchkey_led");
		if (IS_ERR(regulator)) {
			printk(KERN_ERR "[TSP_KEY] ts_led_power_on : TK_LED regulator_get failed\n");
			return -EIO;
		}

		regulator_enable(regulator);
		regulator_put(regulator);
	} else {
		regulator = regulator_get(NULL, "touchkey_led");
		if (IS_ERR(regulator)) {
			printk(KERN_ERR "[TSP_KEY] ts_led_power_on : TK_LED regulator_get failed\n");
			return -EIO;
		}

		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);
	}

	return 0;
}
Пример #18
0
static int rtl8723as_module_power(int onoff)
{
	struct regulator* wifi_ldo = NULL;
	static int first = 1;
	int ret = 0;

	rtl8723as_msg("rtl8723as module power set by axp.\n");
	wifi_ldo = regulator_get(NULL, axp_name);
	if (!wifi_ldo) {
		rtl8723as_msg("get power regulator failed.\n");
		return -ret;
	}

	if (first) {
		rtl8723as_msg("first time\n");
		ret = regulator_force_disable(wifi_ldo);
		if (ret < 0) {
			rtl8723as_msg("regulator_force_disable fail, return %d.\n", ret);
			regulator_put(wifi_ldo);
			return ret;
		}
		regulator_put(wifi_ldo);
		first = 0;
		return ret;
	}

	if (onoff) {
		if (axp_power_on == false) {
			rtl8723as_msg("regulator on.\n");
			ret = regulator_set_voltage(wifi_ldo, 3300000, 3300000);
			if (ret < 0) {
				rtl8723as_msg("regulator_set_voltage fail, return %d.\n", ret);
			regulator_put(wifi_ldo);
				return ret;
			}

			ret = regulator_enable(wifi_ldo);
			if (ret < 0) {
				rtl8723as_msg("regulator_enable fail, return %d.\n", ret);
			regulator_put(wifi_ldo);
				return ret;
			}
			axp_power_on = true;
		}
	} else {
		if (axp_power_on == true) {
			rtl8723as_msg("regulator off.\n");
			ret = regulator_disable(wifi_ldo);
			if (ret < 0) {
				rtl8723as_msg("regulator_disable fail, return %d.\n", ret);
			regulator_put(wifi_ldo);
				return ret;
			}
			axp_power_on = false;
		}
	}
	regulator_put(wifi_ldo);
	return ret;
}
Пример #19
0
static int lcd_power_on(void *ld, int enable)
{
	struct regulator *regulator;
	int err;

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

	err = gpio_request(GPIO_LCD_BL_EN, "LCD_BL_EN");
	if (err) {
		printk(KERN_ERR "failed to request GPF0[5] for "
		"LCD_BL_EN control\n");
		return -EPERM;
	}
	err = gpio_request(GPIO_MLCD_RST, "MLCD_RST");
	if (err) {
		printk(KERN_ERR "failed to request GPY4[5] for "
			"MLCD_RST control\n");
		return -EPERM;
	}

	err = gpio_request(GPIO_LCD_22V_EN_00, "LCD_EN");
	if (err) {
		printk(KERN_ERR "failed to request GPM4[4] for "
			"LCD_2.2V_EN control\n");
		return -EPERM;
	}

	if (enable) {
		gpio_set_value(GPIO_LCD_22V_EN_00, GPIO_LEVEL_HIGH);
		msleep(25);
		regulator = regulator_get(NULL, "vlcd_3.3v");
		if (IS_ERR(regulator))
			goto out;
		regulator_enable(regulator);
		regulator_put(regulator);
	gpio_set_value(GPIO_LCD_BL_EN, 1);
	} else {
		regulator = regulator_get(NULL, "vlcd_3.3v");
		if (IS_ERR(regulator))
			goto out;
		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);

		gpio_set_value(GPIO_LCD_22V_EN_00, GPIO_LEVEL_LOW);
		gpio_set_value(GPIO_MLCD_RST, 0);
		gpio_set_value(GPIO_LCD_BL_EN, 0);
	}

out:
/* Release GPIO */
	gpio_free(GPIO_MLCD_RST);
	gpio_free(GPIO_LCD_22V_EN_00);
	gpio_free(GPIO_LCD_BL_EN);
return 0;

}
Пример #20
0
static int set_vibetonz(int timeout)
{
#ifndef CONFIG_MACH_Q1_REV02
    struct regulator *regulator;
#endif

    if (!timeout) {
        vibe_control_max8997(Immvib_pwm, 0);

        if (regulator_hapticmotor_enabled == 1) {
#ifdef CONFIG_MACH_Q1_REV02
            gpio_direction_output(GPIO_MOTOR_EN, 0);
#else
            regulator = regulator_get(NULL, "vmotor");

            if (IS_ERR(regulator)) {
                DbgOut((KERN_ERR "Failed to get vmoter regulator.\n"));
                return 0;
            }

            regulator_force_disable(regulator);
            regulator_put(regulator);

            regulator_hapticmotor_enabled = 0;
#endif
            DbgOut((KERN_INFO "tspdrv: DISABLE\n"));
            wake_unlock(&vib_wake_lock);
        }
    } else {
        wake_lock(&vib_wake_lock);

        _pwm_config(Immvib_pwm, VIBRATOR_DUTY, VIBRATOR_PERIOD);
        vibe_control_max8997(Immvib_pwm, 1);
#ifdef CONFIG_MACH_Q1_REV02
        gpio_direction_output(GPIO_MOTOR_EN, 1);
#else
        regulator = regulator_get(NULL, "vmotor");

        if (IS_ERR(regulator)) {
            DbgOut((KERN_ERR "Failed to get vmoter regulator.\n"));
            return 0;
        }

        regulator_enable(regulator);
        regulator_put(regulator);
#endif
        regulator_hapticmotor_enabled = 1;

        DbgOut((KERN_INFO "tspdrv: ENABLE\n"));
    }

    vibrator_value = timeout;

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

    return 0;
}
Пример #21
0
int a6xx_gmu_reset(struct a6xx_gpu *a6xx_gpu)
{
	struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
	int ret;
	u32 val;

	/* Flush all the queues */
	a6xx_hfi_stop(gmu);

	/* Stop the interrupts */
	a6xx_gmu_irq_disable(gmu);

	/* Force off SPTP in case the GMU is managing it */
	a6xx_sptprac_disable(gmu);

	/* Make sure there are no outstanding RPMh votes */
	gmu_poll_timeout(gmu, REG_A6XX_RSCC_TCS0_DRV0_STATUS, val,
		(val & 1), 100, 10000);
	gmu_poll_timeout(gmu, REG_A6XX_RSCC_TCS1_DRV0_STATUS, val,
		(val & 1), 100, 10000);
	gmu_poll_timeout(gmu, REG_A6XX_RSCC_TCS2_DRV0_STATUS, val,
		(val & 1), 100, 10000);
	gmu_poll_timeout(gmu, REG_A6XX_RSCC_TCS3_DRV0_STATUS, val,
		(val & 1), 100, 1000);

	/* Force off the GX GSDC */
	regulator_force_disable(gmu->gx);

	/* Disable the resources */
	clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
	pm_runtime_put_sync(gmu->dev);

	/* Re-enable the resources */
	pm_runtime_get_sync(gmu->dev);

	/* Use a known rate to bring up the GMU */
	clk_set_rate(gmu->core_clk, 200000000);
	ret = clk_bulk_prepare_enable(gmu->nr_clocks, gmu->clocks);
	if (ret)
		goto out;

	a6xx_gmu_irq_enable(gmu);

	ret = a6xx_gmu_fw_start(gmu, GMU_RESET);
	if (!ret)
		ret = a6xx_hfi_start(gmu, GMU_COLD_BOOT);

	/* Set the GPU back to the highest power frequency */
	a6xx_gmu_set_freq(gmu, gmu->nr_gpu_freqs - 1);

out:
	if (ret)
		a6xx_gmu_clear_oob(gmu, GMU_OOB_BOOT_SLUMBER);

	return ret;
}
static int hisi_pmic_sdcard_ocp_handler(char *power_name)
{
    static struct regulator *power_sd = NULL;
    static struct regulator *power_sdio = NULL;
    int ret = 0;

    if (NULL == power_sd) {
        power_sd = regulator_get(NULL, SUPPLY_SD);
        if (IS_ERR(power_sd)) {
            pr_err("[%s]sd regulator found.\n", __func__);
            return ENODEV;
        }
    }
    if (IS_ERR(power_sd)) {
        pr_err("[%s]sd regulator found.\n", __func__);
        return ENODEV;
    }
    ret = regulator_force_disable(power_sd);
    if (ret) {
        pr_err("[%s]disable sd regulator error.\n", __func__);
        return ret;
    }

    if (NULL == power_sdio) {
        power_sdio = regulator_get(NULL, SUPPLY_SD_IO);
        if (IS_ERR(power_sdio)) {
            pr_err("[%s]sdio regulator found.\n", __func__);
            return ENODEV;
        }
    }
    if (IS_ERR(power_sdio)) {
            pr_err("[%s]sdio regulator found.\n", __func__);
        return ENODEV;
    }
    ret = regulator_force_disable(power_sdio);
    if (ret) {
        pr_err("[%s]disable sdio regulator error.\n", __func__);
        return ret;
    }

    return ret;
}
Пример #23
0
static int set_vibetonz(int timeout)
{
	struct regulator *regulator;

	if (!timeout) {
		vibe_control_max8997(Immvib_pwm, 0);

		if (regulator_hapticmotor_enabled == 1) {
			regulator = regulator_get(NULL, "vmotor");

			if (IS_ERR(regulator)) {
				DbgOut((KERN_ERR "Failed to get vmoter regulator.\n"));
				return 0;
			}

			regulator_force_disable(regulator);
			regulator_put(regulator);

			regulator_hapticmotor_enabled = 0;

			DbgOut((KERN_INFO "tspdrv: DISABLE\n"));
			wake_unlock(&vib_wake_lock);
		}
	} else {
		wake_lock(&vib_wake_lock);
#if defined(CONFIG_BUILD_TARGET_CM7)
    _pwm_config(Immvib_pwm, vibrator_duty_levels[vibrator_level], VIBRATOR_PERIOD);
#else
		_pwm_config(Immvib_pwm, VIBRATOR_DUTY, VIBRATOR_PERIOD);
#endif
		vibe_control_max8997(Immvib_pwm, 1);

		regulator = regulator_get(NULL, "vmotor");

		if (IS_ERR(regulator)) {
			DbgOut((KERN_ERR "Failed to get vmoter regulator.\n"));
			return 0;
		}

		regulator_enable(regulator);
		regulator_put(regulator);

		regulator_hapticmotor_enabled = 1;

		DbgOut((KERN_INFO "tspdrv: ENABLE\n"));
	}

	vibrator_value = timeout;

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

	return 0;
}
Пример #24
0
int melfas_power(bool on)
{
	struct regulator *regulator_vdd;
	struct regulator *regulator_pullup;

	if (tsp_power_enabled == on)
		return 0;

	printk(KERN_DEBUG "[TSP] %s %s\n",
		__func__, on ? "on" : "off");

	regulator_vdd = regulator_get(NULL, "tsp_vdd_3.3v");
	if (IS_ERR(regulator_vdd))
		return PTR_ERR(regulator_vdd);
	regulator_pullup = regulator_get(NULL, "tsp_vdd_1.8v");
	if (IS_ERR(regulator_pullup))
		return PTR_ERR(regulator_pullup);

	if (on) {
		regulator_enable(regulator_vdd);
		usleep_range(2500, 3000);
		regulator_enable(regulator_pullup);
	} else {
		if (regulator_is_enabled(regulator_vdd))
			regulator_disable(regulator_vdd);
		else
			regulator_force_disable(regulator_vdd);

		if (regulator_is_enabled(regulator_pullup))
			regulator_disable(regulator_pullup);
		else
			regulator_force_disable(regulator_pullup);
	}
	regulator_put(regulator_vdd);
	regulator_put(regulator_pullup);

	tsp_power_enabled = on;

	return 0;
}
Пример #25
0
int max77693_muic_set_safeout(int path)
{
	struct regulator *regulator;

	MUIC_PRINT_LOG();
	pr_info("MUIC safeout path=%d\n", path);

	if (path == CP_USB_MODE) {
		regulator = regulator_get(NULL, "safeout1");
		if (IS_ERR(regulator))
			return -ENODEV;
		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);

		regulator = regulator_get(NULL, "safeout2");
		if (IS_ERR(regulator))
			return -ENODEV;
		if (!regulator_is_enabled(regulator))
			regulator_enable(regulator);
		regulator_put(regulator);
	} else {
		/* AP_USB_MODE || AUDIO_MODE */
		regulator = regulator_get(NULL, "safeout1");
		if (IS_ERR(regulator))
			return -ENODEV;
		if (!regulator_is_enabled(regulator))
			regulator_enable(regulator);
		regulator_put(regulator);

		regulator = regulator_get(NULL, "safeout2");
		if (IS_ERR(regulator))
			return -ENODEV;
		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);
	}

	return 0;
}
// power control by axp
static int ap6xxx_module_power(int onoff)
{
	struct regulator* wifi_ldo = NULL;
	static int first = 1;
	int ret = 0;

	ap6xxx_msg("ap6xxx module power set by axp.\n");
	wifi_ldo = regulator_get(NULL, axp_name);
	if (!wifi_ldo) {
		ap6xxx_msg("get power regulator failed.\n");
		return -ret;
	}

	if (first) {
		ap6xxx_msg("first time\n");
		ret = regulator_force_disable(wifi_ldo);
		if (ret < 0) {
			ap6xxx_msg("regulator_force_disable fail, return %d.\n", ret);
			regulator_put(wifi_ldo);
			return ret;
		}
		first = 0; 
	}

	if (onoff) {
		ap6xxx_msg("regulator on.\n");
		ret = regulator_set_voltage(wifi_ldo, 3300000, 3300000);
		if (ret < 0) {
			ap6xxx_msg("regulator_set_voltage fail, return %d.\n", ret);
			regulator_put(wifi_ldo);
			return ret;
		}

		ret = regulator_enable(wifi_ldo);
		if (ret < 0) {
			ap6xxx_msg("regulator_enable fail, return %d.\n", ret);
			regulator_put(wifi_ldo);
			return ret;
		}
	} else {
		ap6xxx_msg("regulator off.\n");
		ret = regulator_disable(wifi_ldo);
		if (ret < 0) {
			ap6xxx_msg("regulator_disable fail, return %d.\n", ret);
			regulator_put(wifi_ldo);
			return ret;
		}
	}
	regulator_put(wifi_ldo);
	return ret;
}
Пример #27
0
static int archos_camera_glue_probe(struct platform_device * pdev)
{
	cam_vdd = regulator_get(&pdev->dev, "cam_vdd");
	if (IS_ERR(cam_vdd)) {
		dev_err(&pdev->dev, "no cam_vdd rail, abort.\n");
		return -ENODEV;
	}

	regulator_force_disable(cam_vdd);

	cam_1v8 = regulator_get(&pdev->dev, "cam_1v8");
	if (IS_ERR(cam_1v8))
		dev_info(&pdev->dev, "no cam_1v8 rail, skip.\n");
	else
		regulator_force_disable(cam_1v8);

	// assert that power rails are low
	msleep(20);

	enable(1);

	return 0;
}
Пример #28
0
int max77803_muic_set_safeout(int path)
{
	struct regulator *regulator;

	if (path == CP_USB_MODE) {
		regulator = regulator_get(NULL, "safeout1");
		if (IS_ERR(regulator))
			return -ENODEV;
		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);

		regulator = regulator_get(NULL, "safeout2");
		if (IS_ERR(regulator))
			return -ENODEV;
		if (!regulator_is_enabled(regulator))
			regulator_enable(regulator);
		regulator_put(regulator);
	} else {
		/* AP_USB_MODE || AUDIO_MODE */
		regulator = regulator_get(NULL, "safeout1");
		if (IS_ERR(regulator))
			return -ENODEV;
		if (!regulator_is_enabled(regulator))
			regulator_enable(regulator);
		regulator_put(regulator);

		regulator = regulator_get(NULL, "safeout2");
		if (IS_ERR(regulator))
			return -ENODEV;
		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);
	}

	return 0;
}
Пример #29
0
static ssize_t u1_switch_store_vbus(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t count)
{
	int disable, ret, usb_mode;
	struct regulator *regulator;
	/* struct s3c_udc *udc = platform_get_drvdata(&s3c_device_usbgadget); */

	MUIC_PRINT_LOG();
	if (!strncmp(buf, "0", 1))
		disable = 0;
	else if (!strncmp(buf, "1", 1))
		disable = 1;
	else {
		pr_warn("%s: Wrong command\n", __func__);
		return count;
	}

	pr_info("%s: disable=%d\n", __func__, disable);
	usb_mode =
	    disable ? USB_CABLE_DETACHED_WITHOUT_NOTI : USB_CABLE_ATTACHED;
	/* ret = udc->change_usb_mode(usb_mode); */
	ret = -1;
	if (ret < 0)
		pr_err("%s: fail to change mode!!!\n", __func__);

	regulator = regulator_get(NULL, "safeout1");
	if (IS_ERR(regulator)) {
		pr_warn("%s: fail to get regulator\n", __func__);
		return count;
	}

	if (disable) {
		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		if (!regulator_is_enabled(regulator))
			regulator_enable(regulator);
	} else {
		if (!regulator_is_enabled(regulator))
			regulator_enable(regulator);
	}
	regulator_put(regulator);

	return count;
}
Пример #30
0
static void irda_vdd_onoff(bool onoff)
{
        static struct regulator *vled_ic;

        if (onoff) {
                vled_ic = regulator_get(NULL, "vled_ic_1.9v");
                if (IS_ERR(vled_ic)) {
                        pr_err("could not get regulator vled_ic_1.9v\n");
                        return;
                }
                regulator_enable(vled_ic);
                vled_ic_onoff = 1;
        } else if (vled_ic_onoff == 1) {
                regulator_force_disable(vled_ic);
                regulator_put(vled_ic);
                vled_ic_onoff = 0;
        }
}