ssize_t clk_volt_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { char cmd[20], regulator_name[20]; unsigned int volt; int ret = 0; int need_put_regulator=0; struct regulator *regulator; printk("%s: %s\n", __func__, buf); sscanf(buf, "%s %s %u", cmd, regulator_name, &volt); regulator = dvfs_get_regulator(regulator_name); if (IS_ERR_OR_NULL(regulator)) { regulator = regulator_get(NULL, regulator_name); if (IS_ERR(regulator)){ PM_ERR("%s get dvfs_regulator %s error\n", __func__, regulator_name); return n; } need_put_regulator = 1; } if (0 == strncmp(cmd, "set", strlen("set"))){ if (volt & SET_SUSPEND_VOLT_FLAG){ volt &= ~SET_SUSPEND_VOLT_FLAG; //ret = regulator_set_suspend_voltage(regulator, volt); if (!ret) printk("set %s suspend volt to %uuV ok\n", regulator_name, volt); else printk("regulator_set_suspend_voltage err:%d\n", ret); }else{ ret = regulator_set_voltage(regulator, volt, volt); if (!ret) printk("set %s volt to %uuV ok\n", regulator_name, regulator_get_voltage(regulator)); else printk("regulator_set_voltage err:%d\n", ret); } } if (0 == strncmp(cmd, "get", strlen("get"))){ printk("%s:%duV\n", regulator_name, regulator_get_voltage(regulator)); } if (need_put_regulator) regulator_put(regulator); // if (0 == strncmp(cmd, "enable", strlen("enable"))) { return n; }
static int ak09911c_regulator_onoff(struct device *dev, bool onoff) { struct regulator *vdd; struct regulator *vio; int ret = 0; pr_info("%s %s\n", __func__, (onoff) ? "on" : "off"); vdd = devm_regulator_get(dev, "ak09911c,vdd"); if (IS_ERR(vdd)) { pr_err("%s: cannot get vdd\n", __func__); ret = -ENOMEM; goto err_vdd; } else if (!regulator_get_voltage(vdd)) { ret = regulator_set_voltage(vdd, 2850000, 2850000); } vio = devm_regulator_get(dev, "ak09911c,vio"); if (IS_ERR(vio)) { pr_err("%s: cannot get vio\n", __func__); ret = -ENOMEM; goto err_vio; } else if (!regulator_get_voltage(vio)) { ret = regulator_set_voltage(vio, 1800000, 1800000); } if (onoff) { ret = regulator_enable(vdd); if (ret) pr_err("%s: Failed to enable vdd.\n", __func__); ret = regulator_enable(vio); if (ret) pr_err("%s: Failed to enable vio.\n", __func__); } else { ret = regulator_disable(vdd); if (ret) pr_err("%s: Failed to enable vdd.\n", __func__); ret = regulator_disable(vio); if (ret) pr_err("%s: Failed to enable vio.\n", __func__); } msleep(20); devm_regulator_put(vio); err_vio: devm_regulator_put(vdd); err_vdd: return ret; }
void hw_tp_power_get_info(char * buf, ssize_t len) { struct hw_tp_power_data * pd = NULL; struct hw_tp_power_node * pn =NULL; char str_tmp[MAX_POWER_TMP_STR_LEN] = {0}; ssize_t size = 0; pd = hw_tp_get_power_data(); if(!pd) { tp_log_err("%s#%d: get power data fail!\n",__func__,__LINE__); return; } pn = pd->pnode_list; while(pn) { snprintf(str_tmp,sizeof(str_tmp), "power-name=%s; power-type=%d; power-gpio=%d; power-volt=%d; " "gpio-value=%d; is-initialized = %d; ", pn->power_name, pn->power_type, pn->power_gpio, pn->power_volt, gpio_get_value(pn->power_gpio), pn->is_initialized); strncat(buf,str_tmp, len-size); size += strlen(str_tmp); if(pn->preg) { snprintf(str_tmp,sizeof(str_tmp), "power-reg-enable=%d; power-reg-value=%d\n", regulator_get_voltage(pn->preg), pn->power_volt); strncat(buf,str_tmp, len-size); size += strlen(str_tmp); } else { strncat(buf,"\n",1); size++; } pn = pn->next; } }
int sensor_VDD_control(int on) { static struct regulator *vreg_vdd; int rc = -EINVAL; vreg_vdd = regulator_get(NULL, "8038_l10"); if (IS_ERR(vreg_vdd)) { pr_err("%s: regulator get of sensor_3(VDD) failed (%ld)\n" , __func__, PTR_ERR(vreg_vdd)); rc = PTR_ERR(vreg_vdd); return rc; } pr_info("%s: regulator_get end\n", __func__); if(on == 1) rc = regulator_enable(vreg_vdd); else rc = regulator_disable(vreg_vdd); if(rc != 0){ pr_err("%s: SENSOR_LDO_EN(%d) %s fail\n", __func__, SENSOR_LDO_EN, on ? "ON":"OFF"); return -1; } mdelay(10); pr_info("%s: SENSOR_VDD(%d) is set to %d\n", __func__, SENSOR_VDD, regulator_get_voltage(vreg_vdd)); return 1; }
void regulator_status(int id, int type) { struct regulator *regulator = NULL; int status = 0, voltage = 0; id = (type << REGULATOR_SHIFT) | id; regulator = regulator_get_by_id(id); if (NULL == regulator) { regu_pr_info("get regulator failed---->id is :%d\n", id); return; } status = regulator_is_enabled(regulator); if (type != REGULATOR_TYPE_P531_MTCMOS && type != REGULATOR_TYPE_V7R2_MTCMOS) { voltage = regulator_get_voltage(regulator); } else { voltage = -1; } printf("id\t name\t\t use_count\t status\t voltage\t\n"); printf("%-d\t %-s\t %-d\t\t %-d\t %-d\t\n", regulator->id, regulator->name, regulator->use_count, status, voltage); }
int gk20a_volt_new(struct nvkm_device *device, int index, struct nvkm_volt **pvolt) { struct nvkm_device_tegra *tdev = device->func->tegra(device); struct gk20a_volt *volt; int i, uv; if (!(volt = kzalloc(sizeof(*volt), GFP_KERNEL))) return -ENOMEM; nvkm_volt_ctor(&gk20a_volt, device, index, &volt->base); *pvolt = &volt->base; uv = regulator_get_voltage(tdev->vdd); nvkm_info(&volt->base.subdev, "The default voltage is %duV\n", uv); volt->vdd = tdev->vdd; volt->base.vid_nr = ARRAY_SIZE(gk20a_cvb_coef); nvkm_debug(&volt->base.subdev, "%s - vid_nr = %d\n", __func__, volt->base.vid_nr); for (i = 0; i < volt->base.vid_nr; i++) { volt->base.vid[i].vid = i; volt->base.vid[i].uv = gk20a_volt_calc_voltage(&gk20a_cvb_coef[i], tdev->gpu_speedo); nvkm_debug(&volt->base.subdev, "%2d: vid=%d, uv=%d\n", i, volt->base.vid[i].vid, volt->base.vid[i].uv); } return 0; }
static void sht15_update_voltage(struct work_struct *work_s) { struct sht15_data *data = container_of(work_s, struct sht15_data, update_supply_work); data->supply_uV = regulator_get_voltage(data->reg); }
static int adc128_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *channel, int *val, int *val2, long mask) { struct adc128 *adc = iio_priv(indio_dev); int ret; switch (mask) { case IIO_CHAN_INFO_RAW: ret = adc128_adc_conversion(adc, channel->channel); if (ret < 0) return ret; *val = ret; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: ret = regulator_get_voltage(adc->reg); if (ret < 0) return ret; *val = ret / 1000; *val2 = 12; return IIO_VAL_FRACTIONAL_LOG2; default: return -EINVAL; } }
int tse850_get_ana(struct snd_kcontrol *kctrl, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kctrl); struct snd_soc_card *card = dapm->card; struct tse850_priv *tse850 = snd_soc_card_get_drvdata(card); int ret; ret = regulator_get_voltage(tse850->ana); if (ret < 0) return ret; /* * Map regulator output values like so: * -11.5V to "Low" (enum 0) * 11.5V-12.5V to "12V" (enum 1) * 12.5V-13.5V to "13V" (enum 2) * ... * 18.5V-19.5V to "19V" (enum 8) * 19.5V- to "20V" (enum 9) */ if (ret < 11000000) ret = 11000000; else if (ret > 20000000) ret = 20000000; ret -= 11000000; ret = (ret + 500000) / 1000000; ucontrol->value.enumerated.item[0] = ret; return 0; }
static int omap_cpufreq_probe(struct platform_device *pdev) { mpu_dev = get_cpu_device(0); if (!mpu_dev) { pr_warning("%s: unable to get the mpu device\n", __func__); return -EINVAL; } mpu_reg = regulator_get(mpu_dev, "vcc"); if (IS_ERR(mpu_reg)) { pr_warning("%s: unable to get MPU regulator\n", __func__); mpu_reg = NULL; } else { /* * Ensure physical regulator is present. * (e.g. could be dummy regulator.) */ if (regulator_get_voltage(mpu_reg) < 0) { pr_warn("%s: physical regulator not present for MPU\n", __func__); regulator_put(mpu_reg); mpu_reg = NULL; } } return cpufreq_register_driver(&omap_driver); }
void mali_regulator_set_voltage(int min_uV, int max_uV) { int voltage; _mali_osk_lock_wait(mali_dvfs_lock, _MALI_OSK_LOCKMODE_RW); if( IS_ERR_OR_NULL(g3d_regulator) ) { MALI_DEBUG_PRINT(1, ("error on mali_regulator_set_voltage : g3d_regulator is null\n")); return; } MALI_DEBUG_PRINT(2, ("= regulator_set_voltage: %d, %d \n",min_uV, max_uV)); #if MALI_TIMELINE_PROFILING_ENABLED _mali_profiling_add_event( MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_EVENT_CHANNEL_SOFTWARE | MALI_PROFILING_EVENT_REASON_SINGLE_SW_GPU_VOLTS, min_uV, max_uV, 0, 0, 0); #endif regulator_set_voltage(g3d_regulator,min_uV,max_uV); voltage = regulator_get_voltage(g3d_regulator); #if MALI_TIMELINE_PROFILING_ENABLED _mali_profiling_add_event( MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_EVENT_CHANNEL_SOFTWARE | MALI_PROFILING_EVENT_REASON_SINGLE_SW_GPU_VOLTS, voltage, 0, 1, 0, 0); #endif mali_gpu_vol = voltage; MALI_DEBUG_PRINT(1, ("= regulator_get_voltage: %d \n",mali_gpu_vol)); _mali_osk_lock_signal(mali_dvfs_lock, _MALI_OSK_LOCKMODE_RW); }
int soc_pcmcia_regulator_set(struct soc_pcmcia_socket *skt, struct soc_pcmcia_regulator *r, int v) { bool on; int ret; if (!r->reg) return 0; on = v != 0; if (r->on == on) return 0; if (on) { ret = regulator_set_voltage(r->reg, v * 100000, v * 100000); if (ret) { int vout = regulator_get_voltage(r->reg) / 100000; dev_warn(&skt->socket.dev, "CS requested %s=%u.%uV, applying %u.%uV\n", r == &skt->vcc ? "Vcc" : "Vpp", v / 10, v % 10, vout / 10, vout % 10); } ret = regulator_enable(r->reg); } else { regulator_disable(r->reg); } if (ret == 0) r->on = on; return ret; }
static int max11100_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long info) { int ret, vref_uv; struct max11100_state *state = iio_priv(indio_dev); switch (info) { case IIO_CHAN_INFO_RAW: ret = max11100_read_single(indio_dev, val); if (ret) return ret; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: vref_uv = regulator_get_voltage(state->vref_reg); if (vref_uv < 0) /* dummy regulator "get_voltage" returns -EINVAL */ return -EINVAL; *val = vref_uv / 1000; *val2 = MAX11100_LSB_DIV; return IIO_VAL_FRACTIONAL; } return -EINVAL; }
static ssize_t show_min_uV(struct device *dev, struct device_attribute *attr, char *buf) { struct virtual_consumer_data *data = dev_get_drvdata(dev); data->min_uV = regulator_get_voltage(data->regulator); return sprintf(buf, "%d\n", data->min_uV); }
int lcm_vgp_supply_enable(void) { int ret; unsigned int volt; pr_debug("LCM: lcm_vgp_supply_enable\n"); if (NULL == lcm_vgp) return 0; pr_debug("LCM: set regulator voltage lcm_vgp voltage to 2.8V\n"); /* set(vgp1) voltage to 2.8V */ ret = regulator_set_voltage(lcm_vgp, 3300000, 3300000); if (ret != 0) { pr_err("LCM: lcm failed to set lcm_vgp voltage: %d\n", ret); return ret; } /* get(vgp1) voltage settings again */ volt = regulator_get_voltage(lcm_vgp); if (volt == 3300000) pr_err("LCM: check voltage=%d pass!\n", volt); else pr_err("LCM: check voltage=%d fail!\n", volt); ret = regulator_enable(lcm_vgp); if (ret != 0) { pr_err("LCM: Failed to enable lcm_vgp: %d\n", ret); return ret; } return ret; }
/* *************************************************************** @Function :sunxi_mali_platform_device_register @Description :Register mali platform device @Input :None @Return :0 or error code *************************************************************** */ int sunxi_mali_platform_device_register(void) { int err; unsigned long mem_size = 0; struct __fb_addr_para fb_addr_para={0}; sunxi_get_fb_addr_para(&fb_addr_para); err = platform_device_add_resources(&mali_gpu_device, mali_gpu_resources, sizeof(mali_gpu_resources) / sizeof(mali_gpu_resources[0])); if (0 == err){ mali_gpu_data.fb_start = fb_addr_para.fb_paddr; mali_gpu_data.fb_size = fb_addr_para.fb_size; mem_size = (totalram_pages * PAGE_SIZE )/1024; /* KB */ if(mem_size > 512*1024) { mali_gpu_data.shared_mem_size = 1024*1024*1024; } else { mali_gpu_data.shared_mem_size = 512*1024*1024; } err = platform_device_add_data(&mali_gpu_device, &mali_gpu_data, sizeof(mali_gpu_data)); if(0 == err) { err = platform_device_register(&mali_gpu_device); if (0 == err){ if(_MALI_OSK_ERR_OK != mali_platform_init()) { return _MALI_OSK_ERR_FAULT; } #ifdef CONFIG_PM_RUNTIME #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) pm_runtime_set_autosuspend_delay(&(mali_gpu_device.dev), 1000); pm_runtime_use_autosuspend(&(mali_gpu_device.dev)); #endif pm_runtime_enable(&(mali_gpu_device.dev)); #endif /* CONFIG_PM_RUNTIME */ /* print mali gpu information */ printk(KERN_INFO "=========================================================\n"); printk(KERN_INFO " Mali GPU Information \n"); printk(KERN_INFO "voltage : %d mV\n", regulator_get_voltage(mali_regulator)/1000); printk(KERN_INFO "initial frequency : %ld MHz\n", clk_get_rate(h_mali_clk)/(1000*1000)); printk(KERN_INFO "frame buffer address: 0x%lx - 0x%lx\n", mali_gpu_data.fb_start, mali_gpu_data.fb_start + mali_gpu_data.shared_mem_size); printk(KERN_INFO "frame buffer size : %ld MB\n", mali_gpu_data.shared_mem_size/(1024*1024)); printk(KERN_INFO "=========================================================\n"); return 0; } } platform_device_unregister(&mali_gpu_device); } #ifdef CONFIG_CPU_BUDGET_THERMAL register_budget_cooling_notifier(&mali_throttle_notifier); #endif /* CONFIG_CPU_BUDGET_THERMAL */ return err; }
int _gk20a_volt_ctor(struct nvkm_device *device, int index, const struct cvb_coef *coefs, int nb_coefs, struct gk20a_volt *volt) { struct nvkm_device_tegra *tdev = device->func->tegra(device); int i, uv; nvkm_volt_ctor(&gk20a_volt, device, index, &volt->base); uv = regulator_get_voltage(tdev->vdd); nvkm_debug(&volt->base.subdev, "the default voltage is %duV\n", uv); volt->vdd = tdev->vdd; volt->base.vid_nr = nb_coefs; for (i = 0; i < volt->base.vid_nr; i++) { volt->base.vid[i].vid = i; volt->base.vid[i].uv = gk20a_volt_calc_voltage(&coefs[i], tdev->gpu_speedo); nvkm_debug(&volt->base.subdev, "%2d: vid=%d, uv=%d\n", i, volt->base.vid[i].vid, volt->base.vid[i].uv); } return 0; }
static int __devinit ad5624r_probe(struct spi_device *spi) { struct ad5624r_state *st; struct iio_dev *indio_dev; struct regulator *reg; int ret, voltage_uv = 0; reg = regulator_get(&spi->dev, "vcc"); if (!IS_ERR(reg)) { ret = regulator_enable(reg); if (ret) goto error_put_reg; voltage_uv = regulator_get_voltage(reg); } indio_dev = iio_allocate_device(sizeof(*st)); if (indio_dev == NULL) { ret = -ENOMEM; goto error_disable_reg; } st = iio_priv(indio_dev); st->reg = reg; spi_set_drvdata(spi, indio_dev); st->chip_info = &ad5624r_chip_info_tbl[spi_get_device_id(spi)->driver_data]; if (voltage_uv) st->vref_mv = voltage_uv / 1000; else st->vref_mv = st->chip_info->int_vref_mv; st->us = spi; indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad5624r_info; indio_dev->modes = INDIO_DIRECT_MODE; ret = iio_device_register(indio_dev); if (ret) goto error_free_dev; ret = ad5624r_spi_write(spi, AD5624R_CMD_INTERNAL_REFER_SETUP, 0, !!voltage_uv, 16); if (ret) goto error_free_dev; return 0; error_free_dev: iio_free_device(indio_dev); error_disable_reg: if (!IS_ERR(reg)) regulator_disable(reg); error_put_reg: if (!IS_ERR(reg)) regulator_put(reg); return ret; }
static void papyrus_gettemp_work(struct work_struct *work) { int ret = 0; signed int temp = 0; /* i2c bus is suspended */ if (mxc_i2c_suspended) return; ret = regulator_enable(display_regulator); if (ret < 0) { printk(KERN_ERR "Error enabling display_regulator\n"); goto out; } temp = regulator_get_voltage(temp_regulator); if (temp >= 246) temp = (temp - 256); regulator_disable(display_regulator); papyrus_temp = temp; if (papyrus_temp >= PAPYRUS_TEMP_LOGGING) printk(KERN_DEBUG "Papyrus temperature: %d\n", papyrus_temp); out: schedule_delayed_work(&papyrus_temp_work, msecs_to_jiffies(PAPYRUS_TEMP_THRESHOLD)); }
static int irrc_power_set(bool enable) { int rc = -EINVAL; if (NULL == vreg_l8) { vreg_l8 = regulator_get(NULL, "sw_irrc"); //2.6 ~ 3V INFO_MSG("enable=%d\n", enable); if (IS_ERR(vreg_l8)) { pr_err("%s: regulator get of sw_irrc failed (%ld)\n" , __func__, PTR_ERR(vreg_l8)); printk("%s ERROR\n", __FUNCTION__); rc = PTR_ERR(vreg_l8); return rc; } } rc = regulator_set_voltage(vreg_l8, 2800000, 2800000); if (enable == snddev_reg_8921_l8_status) return 0; if (enable) { rc = regulator_set_voltage(vreg_l8, 2800000, 2800000); if (rc < 0) pr_err("LGE: VIB %s: regulator_set_voltage(l8) failed (%d)\n", __func__, rc); rc = regulator_enable(vreg_l8); if (rc < 0) pr_err("LGE: VIB %s: regulator_enable(l8) failed (%d)\n", __func__, rc); snddev_reg_8921_l8_status = true; printk(KERN_INFO "ooooo %s_ regulator(l8) volatage = %d ooooo\n", __FUNCTION__, regulator_get_voltage(vreg_l8)); } else { rc = regulator_disable(vreg_l8); if (rc < 0) pr_err("%s: regulator_disable(l8) failed (%d)\n", __func__, rc); snddev_reg_8921_l8_status = false; printk(KERN_INFO "ooooo %s_ regulator(l8) volatage = %d ooooo\n", __FUNCTION__, regulator_get_voltage(vreg_l8)); } return 0; }
static void rk_cif_powerdowen(int on) { struct regulator *ldo_28; ldo_28 = regulator_get(NULL, "vpll"); // vcc28_cif if (ldo_28 == NULL || IS_ERR(ldo_28) ) { printk("get cif vpll ldo failed!\n"); return; } // if((res->gpio_flag & RK29_CAM_POWERDNACTIVE_MASK) == RK29_CAM_POWERDNACTIVE_H) { if( CONFIG_SENSOR_POWERDNACTIVE_LEVEL_PMU ) { printk("hjc:%s[%d],on=%d\n",__func__,__LINE__,on); if(on == 0) { //enable camera regulator_set_voltage(ldo_28, 2500000, 2500000); regulator_enable(ldo_28); printk(" %s set vpll vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_28)); regulator_put(ldo_28); } else { //disable camera if(regulator_is_enabled(ldo_28)>0) { printk("%s[%d]\n",__func__,__LINE__); int a = regulator_disable(ldo_28); } // return; regulator_put(ldo_28); mdelay(500); } } else { printk("hjc:%s[%d],on=%d\n",__func__,__LINE__,on); if(on == 1) { //enable camera regulator_set_voltage(ldo_28, 2500000, 2500000); regulator_enable(ldo_28); printk(" %s set vpll vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_28)); regulator_put(ldo_28); } else { //disable camera if(regulator_is_enabled(ldo_28)>0) { regulator_disable(ldo_28); } regulator_put(ldo_28); mdelay(500); } } }
void mali_regulator_set_voltage(int min_uV, int max_uV) { int voltage; #if !MALI_DVFS_ENABLED min_uV = mali_gpu_vol; max_uV = mali_gpu_vol; #endif /* #if MALI_VOLTAGE_LOCK if (mali_vol_lock_flag == MALI_FALSE) { if (min_uV < MALI_BOTTOMLOCK_VOL || max_uV < MALI_BOTTOMLOCK_VOL) { min_uV = MALI_BOTTOMLOCK_VOL; max_uV = MALI_BOTTOMLOCK_VOL; } } else if (_mali_osk_atomic_read(&voltage_lock_status) > 0 ) { if (min_uV < mali_lock_vol || max_uV < mali_lock_vol) { #if MALI_DVFS_ENABLED int mali_vol_get; mali_vol_get = mali_vol_get_from_table(mali_lock_vol); if (mali_vol_get) { min_uV = mali_vol_get; max_uV = mali_vol_get; } #else min_uV = mali_lock_vol; max_uV = mali_lock_vol; #endif } } #endif */ _mali_osk_lock_wait(mali_dvfs_lock, _MALI_OSK_LOCKMODE_RW); if( IS_ERR_OR_NULL(g3d_regulator) ) { MALI_DEBUG_PRINT(1, ("error on mali_regulator_set_voltage : g3d_regulator is null\n")); return; } MALI_DEBUG_PRINT(2, ("= regulator_set_voltage: %d, %d \n",min_uV, max_uV)); regulator_set_voltage(g3d_regulator,min_uV,max_uV); voltage = regulator_get_voltage(g3d_regulator); #if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED gVolt = voltage/1000; _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_EVENT_CHANNEL_GPU | MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE, gFreq, gVolt, 0, 0, 0); #endif mali_gpu_vol = voltage; MALI_DEBUG_PRINT(1, ("= regulator_get_voltage: %d \n",mali_gpu_vol)); _mali_osk_lock_signal(mali_dvfs_lock, _MALI_OSK_LOCKMODE_RW); }
static unsigned long get_gpu_vdd(void) { unsigned long vdd = 0; if(gpu_regulator!=NULL) { vdd = regulator_get_voltage(gpu_regulator); } return vdd; }
static int act8931_set_init(struct act8931 *act8931) { 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_ACT8931; #endif printk("%s:g_pmic_type=%d\n",__func__,g_pmic_type); #ifdef CONFIG_RK30_PWM_REGULATOR platform_device_register(&pwm_regulator_device[0]); #endif for(i = 0; i < ARRAY_SIZE(act8931_dcdc_info); i++) { if(act8931_dcdc_info[i].min_uv == 0 && act8931_dcdc_info[i].max_uv == 0) continue; dcdc =regulator_get(NULL, act8931_dcdc_info[i].name); regulator_set_voltage(dcdc, act8931_dcdc_info[i].min_uv, act8931_dcdc_info[i].max_uv); regulator_enable(dcdc); printk("%s %s =%dmV end\n", __func__,act8931_dcdc_info[i].name, regulator_get_voltage(dcdc)); regulator_put(dcdc); udelay(100); } for(i = 0; i < ARRAY_SIZE(act8931_ldo_info); i++) { if(act8931_ldo_info[i].min_uv == 0 && act8931_ldo_info[i].max_uv == 0) continue; ldo =regulator_get(NULL, act8931_ldo_info[i].name); regulator_set_voltage(ldo, act8931_ldo_info[i].min_uv, act8931_ldo_info[i].max_uv); regulator_enable(ldo); printk("%s %s =%dmV end\n", __func__,act8931_ldo_info[i].name, regulator_get_voltage(ldo)); regulator_put(ldo); } printk("%s,line=%d END\n", __func__,__LINE__); return 0; }
int sensor_power(int on) { int rc = -EINVAL; static struct regulator *vreg_vdd; /* */ /* static struct regulator *vreg_vio; vreg_vio = regulator_get(NULL, "8038_lvs2"); if (IS_ERR(vreg_vio)) { pr_err("%s: regulator get of sensor_(%d) failed (%ld)\n" , __func__, SENSOR_VIO, PTR_ERR(vreg_vio)); rc = PTR_ERR(vreg_vio); return rc; } rc = regulator_set_voltage(vreg_vio, SENSOR_VIO, SENSOR_VIO); rc = regulator_enable(vreg_vio); */ /* * set gpio value to 1 to enable sensor ldo */ rc = gpio_request(SENSOR_LDO_EN, "sensor_ldo"); if(rc < 0) { pr_err("%s: SENSOR_LDO_EN(%d) request fail\n", __func__, SENSOR_LDO_EN); return rc; } gpio_direction_output(SENSOR_LDO_EN, 1); gpio_set_value(SENSOR_LDO_EN, on); pr_info("%s: SENSOR_LDO_EN(%d) is set to %d\n", __func__, SENSOR_LDO_EN, on); mdelay(5); pr_info("%s: SENSOR_LDO_EN(%d) is set and gpio_get_value is %d\n", __func__, SENSOR_LDO_EN, gpio_get_value(SENSOR_LDO_EN)); vreg_vdd = regulator_get(NULL, "8038_l10"); if (IS_ERR(vreg_vdd)) { pr_err("%s: regulator get of sensor_3(VDD) failed (%ld)\n" , __func__, PTR_ERR(vreg_vdd)); rc = PTR_ERR(vreg_vdd); return rc; } pr_info("%s: regulator_get end\n", __func__); rc = regulator_set_voltage(vreg_vdd, SENSOR_VDD, SENSOR_VDD); pr_info("%s: SENSOR_VDD(%d) is set to %d\n", __func__, SENSOR_VDD, rc); rc = regulator_enable(vreg_vdd); pr_info("%s: SENSOR_VDD(%d) is set to %d, %d\n", __func__, SENSOR_VDD, rc, regulator_get_voltage(vreg_vdd)); return rc; }
static void rk_cif_powerdowen(int on) { struct regulator *ldo_28; ldo_28 = regulator_get(NULL, "vpll"); // vcc28_cif printk("rk_cif_powerdowen!!!!!!!!!!!!!!!!!!!!\n"); if (ldo_28 == NULL || IS_ERR(ldo_28) ){ printk("get cif vpll ldo failed!\n"); return; } if( CONFIG_SENSOR_POWERDNACTIVE_LEVEL_PMU ) { if(on == 0){//enable camera //if(0){ regulator_set_voltage(ldo_28, 2500000, 2500000); regulator_enable(ldo_28); printk(" %s set vpll vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_28)); regulator_put(ldo_28); }else{//disable camera while(regulator_is_enabled(ldo_28)>0){ int a = regulator_disable(ldo_28); } regulator_put(ldo_28); mdelay(500); printk("rk_cif_powerdowen disable camera (on==0)!!!!!!!!!!!!!!!!!!!!\n"); } }else{ printk("rk_cif_powerdowen disable camera (else)!!!!!!!!!!!!!!!!!!!!\n"); if(on == 1){//enable camera regulator_set_voltage(ldo_28, 2500000, 2500000); regulator_enable(ldo_28); printk(" %s set vpll vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_28)); regulator_put(ldo_28); }else{//disable camera while(regulator_is_enabled(ldo_28)>0){ regulator_disable(ldo_28); } regulator_put(ldo_28); mdelay(500); printk("rk_cif_powerdowen disable camera (else)!!!!!!!!!!!!!!!!!!!!\n"); } } }
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; }
static void twl6040_vibra_set_effect(struct vibra_info *info) { struct twl6040 *twl6040 = info->twl6040; u8 vibdatl, vibdatr; int volt; /* weak motor */ volt = regulator_get_voltage(info->supplies[0].consumer) / 1000; vibdatl = twl6040_vibra_code(volt, info->vibldrv_res, info->viblmotor_res, info->weak_speed, info->direction); /* strong motor */ volt = regulator_get_voltage(info->supplies[1].consumer) / 1000; vibdatr = twl6040_vibra_code(volt, info->vibrdrv_res, info->vibrmotor_res, info->strong_speed, info->direction); twl6040_reg_write(twl6040, TWL6040_REG_VIBDATL, vibdatl); twl6040_reg_write(twl6040, TWL6040_REG_VIBDATR, vibdatr); }
/* Start DPTC unconditionally */ static int start_dptc(struct device *dev) { struct mxc_dptc_data *dptc_data = dev->platform_data; struct dptc_device *drv_data = dev->driver_data; u32 dptccr; unsigned long flags; unsigned long clk_rate; int voltage_uV; /* Get the voltage */ voltage_uV = regulator_get_voltage(drv_data->dptc_reg); drv_data->curr_wp = (dptc_data->dptc_wp_allfreq[0].voltage - (voltage_uV / 1000)) / 25; update_dptc_wp(drv_data, drv_data->curr_wp); /* Set the voltage */ spin_lock_irqsave(&drv_data->lock, flags); clk_rate = clk_get_rate(drv_data->dptc_clk); if (clk_rate < dptc_data->clk_max_val) goto err; if (dptc_data->gpc_irq_bit != 0x0) { /* Enable ARM domain frequency and/or voltage update needed and enable ARM IRQ */ __raw_writel(dptc_data->gpc_irq_bit | dptc_data->gpc_adu, dptc_data->gpc_cntr_reg_addr); } dptccr = __raw_readl(drv_data->membase + dptc_data->dptccr_reg_addr); /* Enable DPTC and unmask its interrupt */ dptccr = ((dptccr & ~(dptc_data->irq_mask)) | dptc_data->enable_config); __raw_writel(dptccr, drv_data->membase + dptc_data->dptccr_reg_addr); spin_unlock_irqrestore(&drv_data->lock, flags); drv_data->dptc_is_active = 1; drv_data->turbo_mode_active = 1; pr_info("DPTC has been started \n"); return 0; err: spin_unlock_irqrestore(&drv_data->lock, flags); pr_info("DPTC is not enabled\n"); return -1; }
/** * mmc_regulator_set_ocr - set regulator to match host->ios voltage * @mmc: the host to regulate * @supply: regulator to use * @vdd_bit: zero for power off, else a bit number (host->ios.vdd) * * Returns zero on success, else negative errno. * * MMC host drivers may use this to enable or disable a regulator using * a particular supply voltage. This would normally be called from the * set_ios() method. */ int mmc_regulator_set_ocr(struct mmc_host *mmc, struct regulator *supply, unsigned short vdd_bit) { int result = 0; int min_uV, max_uV; if (vdd_bit) { int tmp; int voltage; /* REVISIT mmc_vddrange_to_ocrmask() may have set some * bits this regulator doesn't quite support ... don't * be too picky, most cards and regulators are OK with * a 0.1V range goof (it's a small error percentage). */ tmp = vdd_bit - ilog2(MMC_VDD_165_195); if (tmp == 0) { min_uV = 1650 * 1000; max_uV = 1950 * 1000; } else { min_uV = 1900 * 1000 + tmp * 100 * 1000; max_uV = min_uV + 100 * 1000; } /* avoid needless changes to this voltage; the regulator * might not allow this operation */ voltage = regulator_get_voltage(supply); if (voltage < 0) result = voltage; else if (voltage < min_uV || voltage > max_uV) result = regulator_set_voltage(supply, min_uV, max_uV); else result = 0; if (result == 0 && !mmc->regulator_enabled) { result = regulator_enable(supply); if (!result) mmc->regulator_enabled = true; } } else if (mmc->regulator_enabled) { result = regulator_disable(supply); if (result == 0) mmc->regulator_enabled = false; } if (result) dev_err(mmc_dev(mmc), "could not set regulator OCR (%d)\n", result); return result; }