Ejemplo n.º 1
0
static void cpcap_audio_configure_power(int power)
{
	static int previous_power = -1;

	CPCAP_AUDIO_DEBUG_LOG("%s() called with power= %d\n", __func__, power);

	if (power != previous_power) {

		if (IS_ERR(audio_reg)) {
			CPCAP_AUDIO_ERROR_LOG("audio_reg not valid for"
							"regulator setup\n");
			return;
		}

		if (power) {
			regulator_enable(audio_reg);
			regulator_set_mode(audio_reg, REGULATOR_MODE_NORMAL);
		} else {
			printk(KERN_DEBUG "turning off regulator\n");
			regulator_set_mode(audio_reg, REGULATOR_MODE_STANDBY);
			regulator_disable(audio_reg);
		}

		previous_power = power;

		if (power)
			mdelay(SLEEP_ACTIVATE_POWER);
	}
}
int tegra_bbc_proxy_set_rf_mode(struct device *dev, bool fpwm)
{
	struct tegra_bbc_proxy *bbc = dev_get_drvdata(dev);

	if (!bbc)
		return -EAGAIN;

	if (!bbc->rf1v7 || !bbc->rf2v65)
		return -EINVAL;

	if (fpwm == bbc->fpwm)
		return 0;

	if (fpwm) {
		if (regulator_set_mode(bbc->rf1v7, REGULATOR_MODE_NORMAL))
			return -EINVAL;
		if (regulator_set_mode(bbc->rf2v65, REGULATOR_MODE_NORMAL))
			return -EINVAL;
	} else {
		if (regulator_set_mode(bbc->rf1v7, REGULATOR_MODE_FAST))
			return -EINVAL;
		if (regulator_set_mode(bbc->rf2v65, REGULATOR_MODE_FAST))
			return -EINVAL;
	}
	bbc->fpwm = fpwm;

	return 0;
}
static ssize_t pt_mode_set(struct device *d, struct device_attribute *attr,
					const char *buf, size_t size)
{
	REG_GET();
	if (buf[0] == 'f')
		regulator_set_mode(reg, REGULATOR_MODE_FAST);
	else
		regulator_set_mode(reg, REGULATOR_MODE_NORMAL);
	return size;
}
Ejemplo n.º 4
0
static int twl_mmc23_set_sleep(struct device *dev, int slot, int sleep, int vdd,
			       int cardsleep)
{
	struct twl_mmc_controller *c = NULL;
	struct omap_mmc_platform_data *mmc = dev->platform_data;
	int i, err, mode;

	if (cpu_is_omap44xx())
		return 0;

	for (i = 1; i < ARRAY_SIZE(hsmmc); i++) {
		if (mmc == hsmmc[i].mmc) {
			c = &hsmmc[i];
			break;
		}
	}

	if (c == NULL)
		return -ENODEV;

	/*
	 * If we don't see a Vcc regulator, assume it's a fixed
	 * voltage always-on regulator.
	 */
	if (!c->vcc)
		return 0;

	mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL;

	if (!c->vcc_aux)
		return regulator_set_mode(c->vcc, mode);

	if (cardsleep) {
		/* VCC can be turned off if card is asleep */
		struct regulator *vcc_aux = c->vcc_aux;

		c->vcc_aux = NULL;
		if (sleep)
			err = twl_mmc23_set_power(dev, slot, 0, 0);
		else
			err = twl_mmc23_set_power(dev, slot, 1, vdd);
		c->vcc_aux = vcc_aux;
	} else
		err = regulator_set_mode(c->vcc, mode);
	if (err)
		return err;
	return regulator_set_mode(c->vcc_aux, mode);
}
Ejemplo n.º 5
0
static int twl_mmc2_set_power(struct device *dev, int slot, int power_on,
				int vdd)
{
	int ret = 0;
	struct twl_mmc_controller *c = &hsmmc[1];
	struct omap_mmc_platform_data *mmc = dev->platform_data;
	int mode;

	pr_debug("%s %s power_on:%d", __func__, c->name, power_on);

	if (power_on) {
		/* only MMC2 supports a CLKIN */
		if (mmc->slots[0].internal_clock) {
			u32 reg;

			reg = omap_ctrl_readl(control_devconf1_offset);
			reg |= OMAP2_MMCSDIO2ADPCLKISEL;
			omap_ctrl_writel(reg, control_devconf1_offset);
		}
	}

#if 0
	mode = power_on ? regulator_enable(c->vcc): regulator_disable(c->vcc);
#else
	mode = power_on ? REGULATOR_MODE_NORMAL : REGULATOR_MODE_STANDBY;
	ret = regulator_set_mode(c->vcc, mode);
#endif

	return ret;
}
Ejemplo n.º 6
0
void shtps_device_sleep(struct device* dev)
{
	int ret = 0;
	int enabled = 0;
	struct regulator *reg;

	reg = regulator_get(dev, SHTPS_PWR_PMIC_PORT_NAME);
	if (IS_ERR(reg)) {
		pr_err("Unable to get %s regulator\n", SHTPS_PWR_PMIC_PORT_NAME);
		return;
	}

	enabled = regulator_is_enabled(reg);

	if (enabled){
		ret = regulator_set_mode(reg, REGULATOR_MODE_IDLE);
	}else{
		WARN_ON(!enabled);
	}

	if(ret != 0) {
		pr_err("regulator_set_mode fail, ret=%d, mode=%d\n", ret, REGULATOR_MODE_IDLE);
	}

	regulator_put(reg);
}
static ssize_t set_mode(struct device *dev, struct device_attribute *attr,
			const char *buf, size_t count)
{
	struct virtual_consumer_data *data = dev_get_drvdata(dev);
	unsigned int mode;
	int ret;

	/*
	 * sysfs_streq() doesn't need the \n's, but we add them so the strings
	 * will be shared with show_mode(), above.
	 */
	if (sysfs_streq(buf, "fast\n"))
		mode = REGULATOR_MODE_FAST;
	else if (sysfs_streq(buf, "normal\n"))
		mode = REGULATOR_MODE_NORMAL;
	else if (sysfs_streq(buf, "idle\n"))
		mode = REGULATOR_MODE_IDLE;
	else if (sysfs_streq(buf, "standby\n"))
		mode = REGULATOR_MODE_STANDBY;
	else {
		dev_err(dev, "Configuring invalid mode\n");
		return count;
	}

	mutex_lock(&data->lock);
	ret = regulator_set_mode(data->regulator, mode);
	if (ret == 0)
		data->mode = mode;
	else
		dev_err(dev, "Failed to configure mode: %d\n", ret);
	mutex_unlock(&data->lock);

	return count;
}
Ejemplo n.º 8
0
static int s5pc210_phy_control(int on)
{
	struct udevice *dev;
	int ret;

	ret = regulator_get_by_platname("VDD_UOTG_3.0V", &dev);
	if (ret) {
		error("Regulator get error: %d", ret);
		return ret;
	}

	if (on)
		return regulator_set_mode(dev, OPMODE_ON);
	else
		return regulator_set_mode(dev, OPMODE_LPM);
}
int __init sc8825_ldo_slp_init(void)
{
	int i;

	static struct {
		const char *vdd_name;
		/*
		  * 0: slp pd disable, very light loads when in STANDBY mode
		  * 1: slp pd enable, this is chip default config for most of LDOs
		  */
		bool pd_en;
	} ldo_slp_config[] __initdata = {
		{"vddsim0",		0},
		{"vddsim1",		0},
		{"avddvb",		0},
	};

	for (i = 0; i < ARRAY_SIZE(ldo_slp_config); i++) {
		if (0 == ldo_slp_config[i].pd_en) {
			struct regulator *ldo =
			    regulator_get(NULL, ldo_slp_config[i].vdd_name);
			if (!WARN_ON(IS_ERR(ldo))) {
				regulator_set_mode(ldo, REGULATOR_MODE_STANDBY);
				regulator_put(ldo);
			}
			pr_info("%s slp pd disable\n", ldo_slp_config[i].vdd_name);
		}
	}
	return 0;
}
/* Control the BT_VDDIO and WLAN_VDDIO
Always power on  According to spec
*/
static int wlan_ldo_enable(void)
{
	int err;

#ifdef CONFIG_ARCH_SCX35
	/*temp config for clk_aux0, waiting for SC8830 pin config*/
//	pinmap_set(0x400, 0x0101);

	wlan_regulator_18 = regulator_get(NULL, "vdd18");
#else
	wlan_regulator_18 = regulator_get(NULL, "vddsd1");
#endif

	if (IS_ERR(wlan_regulator_18)) {
		pr_err("can't get wlan 1.8V regulator\n");
		return -1;
	}

	err = regulator_set_voltage(wlan_regulator_18,1800000,1800000);
	if (err){
		pr_err("can't set wlan to 1.8V.\n");
		return -1;
	}

	regulator_set_mode(wlan_regulator_18, REGULATOR_MODE_STANDBY);
	regulator_enable(wlan_regulator_18);
	return 0;
}
Ejemplo n.º 11
0
static ssize_t set_mode(struct device *dev, struct device_attribute *attr,
			const char *buf, size_t count)
{
	struct virtual_consumer_data *data = dev_get_drvdata(dev);
	unsigned int mode;
	int ret;

	if (strncmp(buf, "fast", strlen("fast")) == 0)
		mode = REGULATOR_MODE_FAST;
	else if (strncmp(buf, "normal", strlen("normal")) == 0)
		mode = REGULATOR_MODE_NORMAL;
	else if (strncmp(buf, "idle", strlen("idle")) == 0)
		mode = REGULATOR_MODE_IDLE;
	else if (strncmp(buf, "standby", strlen("standby")) == 0)
		mode = REGULATOR_MODE_STANDBY;
	else {
		dev_err(dev, "Configuring invalid mode\n");
		return count;
	}

	mutex_lock(&data->lock);
	ret = regulator_set_mode(data->regulator, mode);
	if (ret == 0)
		data->mode = mode;
	else
		dev_err(dev, "Failed to configure mode: %d\n", ret);
	mutex_unlock(&data->lock);

	return count;
}
Ejemplo n.º 12
0
Result_t SetLDORegulator(enum SYS_LDO_Cmd_Type_t cmdType,
	const char *name, unsigned int mode)
{
	Result_t result = RESULT_OK;
	struct regulator *reg_handle;

	printk(KERN_INFO "Excuting LDO %s cmd type=%d\n",
		name, (int)cmdType);
	reg_handle = regulator_get(NULL, name);
	if (reg_handle != NULL) {
		if (cmdType == SYS_LDO_OFF) {
			printk(KERN_INFO "Turn off LDO\n");
			regulator_disable(reg_handle);
		} else if (cmdType == SYS_LDO_ON) {
			printk(KERN_INFO "Turn on LDO\n");
			regulator_enable(reg_handle);
			/*Set LDO mode to LPM */
			printk(KERN_INFO "Set mode LDO\n");
			regulator_set_mode(reg_handle,
				mode);
		} else {
			printk(KERN_INFO "Invalid command type - not updated\n");
		}
		regulator_put(reg_handle);
	} else {
		printk(KERN_INFO "LDO handle is not valid!\n");
		result = RESULT_ERROR;
	}

	return result;
}
Ejemplo n.º 13
0
static void audio_low_power_clear(struct cpcap_3mm5_data *data,
				  unsigned char *flag)
{
	if (*flag) {
		regulator_set_mode(data->regulator, REGULATOR_MODE_NORMAL);
		*flag = 0;
	}
}
Ejemplo n.º 14
0
static void audio_low_power_set(struct cpcap_3mm5_data *data,
				unsigned char *flag)
{
	if (!(*flag)) {
		regulator_set_mode(data->regulator, REGULATOR_MODE_STANDBY);
		*flag = 1;
	}
}
Ejemplo n.º 15
0
static int twl_mmc1_set_sleep(struct device *dev, int slot, int sleep, int vdd,
			      int cardsleep)
{
	struct twl_mmc_controller *c = &hsmmc[0];
	int mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL;

	return regulator_set_mode(c->vcc, mode);
}
Ejemplo n.º 16
0
void wm831x_pmu_early_resume(struct early_suspend *h)
{
	struct regulator *dcdc;
	struct regulator *ldo;
	printk("%s\n", __func__);
	
	dcdc = regulator_get(NULL, "dcdc4");	//vcc_io
	#ifdef CONFIG_MACH_RK3066_SDK
	regulator_set_voltage(dcdc, 3300000, 3300000);
	#else
	regulator_set_voltage(dcdc, 3000000, 3000000);
	#endif
	regulator_set_mode(dcdc, REGULATOR_MODE_FAST);
	regulator_enable(dcdc);
	printk("%s set dcdc4 vcc_io=%dmV end\n", __func__, regulator_get_voltage(dcdc));
	regulator_put(dcdc);
	udelay(100);

	ldo = regulator_get(NULL, "ldo1");	//
	regulator_set_mode(ldo, REGULATOR_MODE_NORMAL);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);

	ldo = regulator_get(NULL, "ldo4");
	regulator_set_mode(ldo, REGULATOR_MODE_NORMAL);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);

	ldo = regulator_get(NULL, "ldo6");
	regulator_set_mode(ldo, REGULATOR_MODE_NORMAL);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);

	ldo = regulator_get(NULL, "ldo8");
	regulator_set_mode(ldo, REGULATOR_MODE_NORMAL);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);	
}
Ejemplo n.º 17
0
/* Helper routine to turn off all WCNSS vregs e.g. IRIS, Riva */
static void wcnss_vregs_off(struct vregs_info regulators[], uint size)
{
    int i, rc = 0;

    /* Regulators need to be turned off in the reverse order */
    for (i = (size-1); i >= 0; i--) {
        if (regulators[i].state == VREG_NULL_CONFIG)
            continue;

        /* Remove PWM mode */
        if (regulators[i].state & VREG_OPTIMUM_MODE_MASK) {
            rc = regulator_set_optimum_mode(
                     regulators[i].regulator, 0);
            if (rc)
                pr_err("regulator_set_optimum_mode(%s) failed (%d)\n",
                       regulators[i].name, rc);
        }

        /* Remove pin control */
        if (regulators[i].state & VREG_PIN_CONTROL_MASK) {
            rc = regulator_set_mode(regulators[i].regulator,
                                    REGULATOR_MODE_NORMAL);
            if (rc)
                pr_err("regulator_set_mode(%s) failed (%d)\n",
                       regulators[i].name, rc);
        }

        /* Set voltage to lowest level */
        if (regulators[i].state & VREG_SET_VOLTAGE_MASK) {
            rc = regulator_set_voltage(regulators[i].regulator,
                                       regulators[i].low_power_min,
                                       regulators[i].max_voltage);
            if (rc)
                pr_err("regulator_set_voltage(%s) failed (%d)\n",
                       regulators[i].name, rc);
        }

        /* Disable regulator */
        if (regulators[i].state & VREG_ENABLE_MASK) {
            rc = regulator_disable(regulators[i].regulator);
            if (rc < 0)
                pr_err("vreg %s disable failed (%d)\n",
                       regulators[i].name, rc);
        }

        /* Free the regulator source */
        if (regulators[i].state & VREG_GET_REGULATOR_MASK)
            regulator_put(regulators[i].regulator);

        regulators[i].state = VREG_NULL_CONFIG;
    }
}
Ejemplo n.º 18
0
void wm831x_pmu_early_suspend(struct early_suspend *h)
{
	struct regulator *dcdc;
	struct regulator *ldo;
	printk("%s\n", __func__);
	
	dcdc = regulator_get(NULL, "dcdc4");	//vcc_io
	regulator_set_voltage(dcdc, 2800000, 2800000);
	regulator_set_mode(dcdc, REGULATOR_MODE_STANDBY);
	regulator_enable(dcdc);
	printk("%s set dcdc4 vcc_io=%dmV end\n", __func__, regulator_get_voltage(dcdc));
	regulator_put(dcdc);
	udelay(100);

	ldo = regulator_get(NULL, "ldo1");	//
	regulator_set_mode(ldo, REGULATOR_MODE_IDLE);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);
	
	ldo = regulator_get(NULL, "ldo4");
	regulator_set_mode(ldo, REGULATOR_MODE_IDLE);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);
	
	ldo = regulator_get(NULL, "ldo6");
	regulator_set_mode(ldo, REGULATOR_MODE_IDLE);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);

	ldo = regulator_get(NULL, "ldo8");
	regulator_set_mode(ldo, REGULATOR_MODE_IDLE);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);	
		
}
Ejemplo n.º 19
0
static void __init_reg(struct device *dev, struct regulator **pp_reg)
{
	struct regulator *reg = *pp_reg;

	if (!reg) {
		reg = regulator_get(NULL, "mmc_ssp-1");
		if (reg && !IS_ERR(reg))
			regulator_set_mode(reg, REGULATOR_MODE_NORMAL);
		else
			reg = NULL;
		*pp_reg = reg;
	}
}
Ejemplo n.º 20
0
static int omap_hsmmc_1_set_sleep(struct device *dev, int slot, int sleep,
				  int vdd, int cardsleep)
{
#if 0
	struct omap_hsmmc_host *host =
		platform_get_drvdata(to_platform_device(dev));
	int mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL;

	return regulator_set_mode(host->vcc, mode);
#else
	return 0;
#endif
}
void wm831x_pmu_early_resume(struct regulator_dev *rdev)
{
	struct regulator *dcdc;
	struct regulator *ldo;
	printk("%s\n", __func__);
	
	dcdc = regulator_get(NULL, "dcdc4");	//vcc_io
	regulator_set_voltage(dcdc, 3000000, 3000000);
	regulator_set_mode(dcdc, REGULATOR_MODE_FAST);
	regulator_enable(dcdc);
	printk("%s set dcdc4 vcc_io=%dmV end\n", __func__, regulator_get_voltage(dcdc));
	regulator_put(dcdc);
	udelay(100);

	ldo = regulator_get(NULL, "ldo1");	//
	regulator_set_mode(ldo, REGULATOR_MODE_NORMAL);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);

	ldo = regulator_get(NULL, "ldo4");
	regulator_set_mode(ldo, REGULATOR_MODE_NORMAL);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);

	ldo = regulator_get(NULL, "ldo6");
	regulator_set_mode(ldo, REGULATOR_MODE_NORMAL);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);

	ldo = regulator_get(NULL, "ldo8");
	regulator_set_mode(ldo, REGULATOR_MODE_NORMAL);
	regulator_enable(ldo);
	regulator_put(ldo);
	udelay(100);	
}
/*
 **************************************************************************
 * FunctionName: ispv1_io_power_sensor;
 * Description : ldo open or eco;
 * Input       : power_state: on/off
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
static int ispv1_io_power_sensor(camera_power_state power_state, char *ldo_name)
{
	int i = 0;
	int ret = 0;
	u32 mode = REGULATOR_MODE_NORMAL;

	print_info("%s config LDO: ldo_name=%s ldo_count=%d power_state=%d",
		   __func__, ldo_name, ispv1_io.ldo_count, power_state);

	if (power_state == POWER_ON) {
		for (i = 0; i < ispv1_io.ldo_count; i++) {
			if (0 == strcmp(ldo_name, ispv1_io.ldo[i].name)) {
				ret |= regulator_set_mode(ispv1_io.ldo[i].regulator, mode);
				ret |= regulator_set_voltage(ispv1_io.ldo[i].regulator,
						ispv1_io.ldo[i].vol_min, ispv1_io.ldo[i].vol_max);
				/* enable ldo */
				ret = regulator_enable(ispv1_io.ldo[i].regulator);
				if (ret < 0) {
					print_error("%s: regulator enable failed\n", __func__);
					goto fail;
				}
				break;
			}
		}
	} else {
		for (i = 0; i < ispv1_io.ldo_count; i++) {
			if (0 == strcmp(ldo_name, ispv1_io.ldo[i].name)) {
				ret = regulator_disable(ispv1_io.ldo[i].regulator);
                if (ret < 0) {
                    print_error("%s: regulator disable failed\n", __func__);
                }
			}
		}
	}

	return ret;

fail:
	for (i = 0; i < ispv1_io.ldo_count; i++) {
		if (ispv1_io.ldo[i].regulator != NULL) {
			ret = regulator_disable(ispv1_io.ldo[i].regulator);
		}
        if (ret < 0) {
            print_error("%s: regulator disable failed\n", __func__);
        }
	}

	return -EINVAL;
}
Ejemplo n.º 23
0
/* Test regulator set and get mode method */
static int dm_test_power_regulator_set_get_mode(struct unit_test_state *uts)
{
	const char *platname;
	struct udevice *dev;
	int val_set = LDO_OM_SLEEP;

	/* Set the mode id to LDO_OM_SLEEP of LDO1 - default is LDO_OM_OFF */
	platname = regulator_names[LDO1][PLATNAME];
	ut_assertok(regulator_get_by_platname(platname, &dev));
	ut_assertok(regulator_set_mode(dev, val_set));

	/* Get the mode id of LDO1 and compare it with the requested one */
	ut_asserteq(regulator_get_mode(dev), val_set);

	return 0;
}
Ejemplo n.º 24
0
static int bc_sm_restart(struct stmp3xxx_info *info)
{
	ddi_bc_Status_t bcret;
	int ret = 0;

	mutex_lock(&info->sm_lock);

	/* ungate power clk */
	ddi_power_SetPowerClkGate(0);

	/*
	 * config battery charger state machine and move it to the Disabled
	 * state. This must be done before starting the state machine.
	 */
	bcret = ddi_bc_Init(info->sm_cfg);
	if (bcret != DDI_BC_STATUS_SUCCESS) {
		dev_err(info->dev, "battery charger init failed: %d\n", bcret);
		ret = -EIO;
		goto out;
	} else {

		if (!info->regulator) {
			info->regulator = regulator_get(NULL, "charger-1");
			if (!info->regulator || IS_ERR(info->regulator)) {
				dev_err(info->dev,
				"%s: failed to get regulator\n", __func__);
				info->regulator = NULL;
			} else {
				regulator_set_current_limit(
						info->regulator, 0, 0);
				regulator_set_mode(info->regulator,
						   REGULATOR_MODE_FAST);
			}
		}
	}



	/* schedule first call to state machine */
	mod_timer(&info->sm_timer, jiffies + 1);
out:
	mutex_unlock(&info->sm_lock);
	return ret;
}
/* Control the BT_VDDIO and WLAN_VDDIO
Always power on  According to spec
*/
static int wlan_ldo_enable(void)
{
	int err;
	wlan_regulator_18 = regulator_get(NULL, "vddsd1");

	if (IS_ERR(wlan_regulator_18)) {
		pr_err("can't get wlan 1.8V regulator\n");
		return -1;
	}

	err = regulator_set_voltage(wlan_regulator_18,1800000,1800000);
	if (err){
		pr_err("can't set wlan to 1.8V.\n");
		return -1;
	}
	regulator_set_mode(wlan_regulator_18, REGULATOR_MODE_STANDBY);
	regulator_enable(wlan_regulator_18);
	return 0;
}
Ejemplo n.º 26
0
static int rt5025_post_init(void)
{
	struct regulator *dcdc;
	struct regulator *ldo;
	int i = 0;
	printk("%s,line=%d\n", __func__,__LINE__);

	#ifndef CONFIG_RK_CONFIG
	g_pmic_type = PMIC_TYPE_RT5025;
	#endif
	printk("%s:g_pmic_type=%d\n",__func__,g_pmic_type);
	
	for(i = 0; i < ARRAY_SIZE(rt5025_dcdc_info); i++)
	{
                if(rt5025_dcdc_info[i].min_uv == 0 && rt5025_dcdc_info[i].max_uv == 0)
                        continue;
	        dcdc =regulator_get(NULL, rt5025_dcdc_info[i].name);

	        regulator_set_voltage(dcdc, rt5025_dcdc_info[i].min_uv, rt5025_dcdc_info[i].max_uv);

		regulator_set_mode(dcdc, REGULATOR_MODE_NORMAL);
	        regulator_enable(dcdc);
	        printk("%s  %s =%duV end\n", __func__,rt5025_dcdc_info[i].name, regulator_get_voltage(dcdc));
	        regulator_put(dcdc);
	        udelay(100);
	}
	
	for(i = 0; i < ARRAY_SIZE(rt5025_ldo_info); i++)
	{
                if(rt5025_ldo_info[i].min_uv == 0 && rt5025_ldo_info[i].max_uv == 0)
                        continue;
	        ldo =regulator_get(NULL, rt5025_ldo_info[i].name);
	        regulator_set_voltage(ldo, rt5025_ldo_info[i].min_uv, rt5025_ldo_info[i].max_uv);
	        regulator_enable(ldo);
	        printk("%s  %s =%duV end\n", __func__,rt5025_ldo_info[i].name, regulator_get_voltage(ldo));
	        regulator_put(ldo);
	}
	
	printk("%s,line=%d END\n", __func__,__LINE__);
	
	return 0;
}
Ejemplo n.º 27
0
static void power_on_cmmb1v8(void)
{
      
	  int enable;
      struct regulator* cmmb_regulator_1v8;
	  cmmb_regulator_1v8 = regulator_get(NULL, "vddcmmb1p8");

	  enable = regulator_is_enabled(cmmb_regulator_1v8);

      printk("[WIFI] power_on_cmmb1v8 is %d\n",enable);
	  
      regulator_set_voltage(cmmb_regulator_1v8, 1800000, 1800000);
      
      
      
      
      regulator_set_mode(cmmb_regulator_1v8, REGULATOR_MODE_STANDBY);
      regulator_enable(cmmb_regulator_1v8);
      msleep(5);
}
Ejemplo n.º 28
0
static ssize_t
store_rgltr(struct device *dev, struct device_attribute *attr,
				const char *buf, size_t count)
{
	int volt, mode, enable;
	char name[10];
	struct regulator *rgltr;
	sscanf(buf, "%d, %d, %d, %s", &volt, &mode, &enable, name);
	rgltr = regulator_get(NULL, name);
	if (IS_ERR(rgltr))
		printk(KERN_INFO "%s: regulator_get failed\n", __func__);
	else {
		if (enable != 0)
			regulator_enable(rgltr);
		else
			regulator_disable(rgltr);
		regulator_set_mode(rgltr, mode);
		regulator_set_voltage(rgltr, volt*1000, volt*1000);
	}
	regulator_put(rgltr);
	return count;
}
static ssize_t pt_val_fset(struct device *d, struct device_attribute *attr,
					const char *buf, size_t size)
{
	int i, ret;
	ret = sscanf(buf, "%u", &i);
	if (ret != 1)
		return -EINVAL;

	if (!freg) {
		freg = regulator_get(NULL, "stmp3xxx-bl-1");
		if (!freg || IS_ERR(freg)) {
			freg = NULL ; return -ENODEV;
		}
	}
	regulator_set_mode(freg, REGULATOR_MODE_NORMAL);

	if (!regulator_set_current_limit(freg, i, i))
		printk(KERN_ERR "got backlight reg\n");
	else
		printk(KERN_ERR "failed to get backlight reg");

	return size;
}
Ejemplo n.º 30
0
int nfc_power_onoff(struct pn547_dev *data, bool onoff)
{
	int ret = -1;
	if (!data->L14) {
		data->L14 = devm_regulator_get(&data->client->dev, "nfc_ldo");
		if (!data->L14) {
			pr_err("[NFC] %s: regulator pointer null nfc_ldo, rc=%d\n",
				__func__, ret);
			return ret;
		}
		ret = regulator_set_voltage(data->L14, 3000000, 3000000);
		if (ret) {
			pr_err("[NFC] %s: set voltage failed on nfc_ldo, rc=%d\n",
				__func__, ret);
			return ret;
		}
	}

	if (onoff) {
		ret = regulator_enable(data->L14);
		regulator_set_mode(data->L14, REGULATOR_MODE_NORMAL);
		if (ret) {
			pr_err("[NFC] %s: Failed to enable regulator nfc_ldo.\n",
				__func__);
			return ret;
		}

	} else {
		ret = regulator_disable(data->L14);
		if (ret) {
			pr_err("[NFC] %s: Failed to disable regulator nfc_ldo.\n",
				__func__);
			return ret;
		}
	}
	return 0;
}