static void max77803_haptic_power_onoff(int onoff) { int ret; #if defined(CONFIG_SEC_H_PROJECT) || defined(CONFIG_SEC_MONTBLANC_PROJECT) || defined(CONFIG_SEC_JS_PROJECT) || \ defined(CONFIG_MACH_FLTEEUR) || defined(CONFIG_MACH_FLTESKT) || defined(CONFIG_MACH_JVELTEEUR) ||\ defined(CONFIG_MACH_VIKALCU) || defined(CONFIG_SEC_LOCALE_KOR_FRESCO) static struct regulator *reg_l23; if (!reg_l23) { reg_l23 = regulator_get(NULL, "8941_l23"); #if defined(CONFIG_MACH_FLTESKT) ret = regulator_set_voltage(reg_l23, 3000000, 3000000); #elif defined(CONFIG_MACH_HLTEVZW) ret = regulator_set_voltage(reg_l23, 3100000, 3100000); #elif defined(CONFIG_SEC_LOCALE_KOR_FRESCO) ret = regulator_set_voltage(reg_l23, 2488000,2488000); #else ret = regulator_set_voltage(reg_l23, 2825000, 2825000); #endif if (IS_ERR(reg_l23)) { printk(KERN_ERR"could not get 8941_l23, rc = %ld\n", PTR_ERR(reg_l23)); return; } } if (onoff) { ret = regulator_enable(reg_l23); if (ret) { printk(KERN_ERR"enable l23 failed, rc=%d\n", ret); return; } printk(KERN_DEBUG"haptic power_on is finished.\n"); } else { if (regulator_is_enabled(reg_l23)) { ret = regulator_disable(reg_l23); if (ret) { printk(KERN_ERR"disable l23 failed, rc=%d\n", ret); return; } } printk(KERN_DEBUG"haptic power_off is finished.\n"); } #else static struct regulator *reg_l17; if (!reg_l17) { reg_l17 = regulator_get(NULL, "8941_l17"); ret = regulator_set_voltage(reg_l17, 3000000, 3000000); if (IS_ERR(reg_l17)) { printk(KERN_ERR"could not get 8941_l17, rc = %ld\n", PTR_ERR(reg_l17)); return; } } if (onoff) { ret = regulator_enable(reg_l17); if (ret) { printk(KERN_ERR"enable l17 failed, rc=%d\n", ret); return; } printk(KERN_DEBUG"haptic power_on is finished.\n"); } else { if (regulator_is_enabled(reg_l17)) { ret = regulator_disable(reg_l17); if (ret) { printk(KERN_ERR"disable l17 failed, rc=%d\n", ret); return; } } printk(KERN_DEBUG"haptic power_off is finished.\n"); } #endif }
static int c1_enable_regulator_for_usb_mipi(bool enable) { struct regulator *mipi11_regulator; struct regulator *mipi18_regulator; struct regulator *hsic12_regulator; struct regulator *usb33_regulator; int ret = 0; mipi11_regulator = regulator_get(NULL, "vmipi_1.1v"); if (IS_ERR(mipi11_regulator)) { pr_err("%s: failed to get %s\n", __func__, "vmipi_1.1v"); ret = -ENODEV; goto out4; } mipi18_regulator = regulator_get(NULL, "vmipi_1.8v"); if (IS_ERR(mipi18_regulator)) { pr_err("%s: failed to get %s\n", __func__, "vmipi_1.8v"); ret = -ENODEV; goto out3; } hsic12_regulator = regulator_get(NULL, "vhsic"); if (IS_ERR(hsic12_regulator)) { pr_err("%s: failed to get %s\n", __func__, "vhsic 1.2v"); ret = -ENODEV; goto out2; } usb33_regulator = regulator_get(NULL, "vusb_3.3v"); if (IS_ERR(usb33_regulator)) { pr_err("%s: failed to get %s\n", __func__, "vusb_3.3v"); ret = -ENODEV; goto out1; } if (enable) { /* Power On Sequence * MIPI 1.1V -> HSIC 1.2V -> MIPI 1.8V -> USB 3.3V */ pr_info("%s: enable LDOs\n", __func__); if (!regulator_is_enabled(mipi11_regulator)) regulator_enable(mipi11_regulator); if (!regulator_is_enabled(hsic12_regulator)) regulator_enable(hsic12_regulator); if (!regulator_is_enabled(mipi18_regulator)) regulator_enable(mipi18_regulator); if (!regulator_is_enabled(usb33_regulator)) regulator_enable(usb33_regulator); } else { /* Power Off Sequence * USB 3.3V -> MIPI 18V -> HSIC 1.2V -> MIPI 1.1V */ pr_info("%s: disable LDOs\n", __func__); regulator_force_disable(usb33_regulator); regulator_force_disable(mipi18_regulator); regulator_force_disable(hsic12_regulator); regulator_force_disable(mipi11_regulator); } regulator_put(usb33_regulator); out1: regulator_put(hsic12_regulator); out2: regulator_put(mipi18_regulator); out3: regulator_put(mipi11_regulator); out4: return ret; }
static int cyttsp5_hw_power(int on) { #ifdef MT04 int ret; ret = gpio_direction_output(31, on); if (ret) { pr_err("[TKEY]%s: unable to set_direction for vdd_led [%d]\n", __func__, 31); return -EINVAL; } ret = gpio_direction_output(45, on); if (ret) { pr_err("[TKEY]%s: unable to set_direction for vdd_led [%d]\n", __func__, 45); return -EINVAL; } msleep(100); #else struct regulator *regulator_vdd; struct regulator *regulator_avdd; if (enabled == on) return 0; regulator_vdd = regulator_get(NULL, "touch_1.8v"); if (IS_ERR(regulator_vdd)) { printk(KERN_ERR "[TSP]ts_power_on : tsp_vdd regulator_get failed\n"); return PTR_ERR(regulator_vdd); } regulator_avdd = regulator_get(NULL, "tsp_avdd"); if (IS_ERR(regulator_avdd)) { printk(KERN_ERR "[TSP]ts_power_on : tsp_avdd regulator_get failed\n"); regulator_put(regulator_vdd); return PTR_ERR(regulator_avdd); } printk(KERN_INFO "[TSP] %s %s\n", __func__, on ? "on" : "off"); if (on) { if (!regulator_is_enabled(regulator_vdd)) regulator_enable(regulator_vdd); if (!regulator_is_enabled(regulator_avdd)) regulator_enable(regulator_avdd); s3c_gpio_cfgpin(GPIO_TSP_nINT_SECURE, S3C_GPIO_SFN(0xf)); s3c_gpio_setpull(GPIO_TSP_nINT_SECURE, S3C_GPIO_PULL_NONE); } else { /* * TODO: If there is a case the regulator must be disabled * (e,g firmware update?), consider regulator_force_disable. */ if (regulator_is_enabled(regulator_vdd)) regulator_disable(regulator_vdd); if (regulator_is_enabled(regulator_avdd)) regulator_disable(regulator_avdd); s3c_gpio_cfgpin(GPIO_TSP_nINT_SECURE, S3C_GPIO_INPUT); s3c_gpio_setpull(GPIO_TSP_nINT_SECURE, S3C_GPIO_PULL_NONE); /* TODO: Delay time should be adjusted */ msleep(10); } enabled = on; regulator_put(regulator_vdd); regulator_put(regulator_avdd); #endif return 0; }
static int __devinit regulator_led_probe(struct platform_device *pdev) { struct led_regulator_platform_data *pdata = pdev->dev.platform_data; struct regulator_led *led; struct regulator *vcc; int ret = 0; if (pdata == NULL) { dev_err(&pdev->dev, "no platform data\n"); return -ENODEV; } vcc = regulator_get_exclusive(&pdev->dev, "vled"); if (IS_ERR(vcc)) { dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name); return PTR_ERR(vcc); } led = kzalloc(sizeof(*led), GFP_KERNEL); if (led == NULL) { ret = -ENOMEM; goto err_vcc; } led->cdev.max_brightness = led_regulator_get_max_brightness(vcc); if (pdata->brightness > led->cdev.max_brightness) { dev_err(&pdev->dev, "Invalid default brightness %d\n", pdata->brightness); ret = -EINVAL; goto err_led; } led->value = pdata->brightness; led->cdev.brightness_set = regulator_led_brightness_set; led->cdev.name = pdata->name; led->cdev.flags |= LED_CORE_SUSPENDRESUME; led->vcc = vcc; /* to handle correctly an already enabled regulator */ if (regulator_is_enabled(led->vcc)) led->enabled = 1; mutex_init(&led->mutex); INIT_WORK(&led->work, led_work); platform_set_drvdata(pdev, led); ret = led_classdev_register(&pdev->dev, &led->cdev); if (ret < 0) { cancel_work_sync(&led->work); goto err_led; } /* to expose the default value to userspace */ led->cdev.brightness = led->value; /* Set the default led status */ regulator_led_set_value(led); return 0; err_led: kfree(led); err_vcc: regulator_put(vcc); return ret; }
int fimc_is_af_i2c_write(struct i2c_client *client ,u8 addr, u8 data) { int retries = I2C_RETRY_COUNT; int ret = 0, err = 0; u8 buf[2] = {0,}; struct i2c_msg msg = { .addr = client->addr, .flags = 0, .len = 2, .buf = buf, }; buf[0] = addr; buf[1] = data; #if 0 pr_info("%s : W(0x%02X%02X)\n",__func__, buf[0], buf[1]); #endif do { ret = i2c_transfer(client->adapter, &msg, 1); if (likely(ret == 1)) break; usleep_range(10000,11000); err = ret; } while (--retries > 0); /* Retry occured */ if (unlikely(retries < I2C_RETRY_COUNT)) { err("i2c_write: error %d, write (%02X, %02X), retry %d\n", err, addr, data, I2C_RETRY_COUNT - retries); } if (unlikely(ret != 1)) { err("I2C does not work\n\n"); return -EIO; } return 0; } int fimc_is_af_ldo_enable(char *name, bool on) { struct fimc_is_core *core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev); struct regulator *regulator = NULL; struct platform_device *pdev = NULL; int ret = 0; BUG_ON(!core); BUG_ON(!core->pdev); pdev = core->pdev; regulator = regulator_get(&pdev->dev, name); if (IS_ERR_OR_NULL(regulator)) { err("%s : regulator_get(%s) fail\n", __func__, name); regulator_put(regulator); return -EINVAL; } if (on) { if (regulator_is_enabled(regulator)) { pr_info("%s: regulator is already enabled\n", name); goto exit; } ret = regulator_enable(regulator); if (ret) { err("%s : regulator_enable(%s) fail\n", __func__, name); goto exit; } } else { if (!regulator_is_enabled(regulator)) { pr_info("%s: regulator is already disabled\n", name); goto exit; } ret = regulator_disable(regulator); if (ret) { err("%s : regulator_disable(%s) fail\n", __func__, name); goto exit; } } exit: regulator_put(regulator); return ret; } int fimc_is_af_power(struct fimc_is_device_af *af_device, bool onoff) { int ret = 0; /*CAM_AF_2.8V_AP*/ ret = fimc_is_af_ldo_enable("CAM_AF_2.8V_AP", onoff); if (ret) { err("failed to power control CAM_AF_2.8V_AP, onoff = %d", onoff); return -EINVAL; } #ifdef CONFIG_OIS_USE /* OIS_VDD_2.8V */ ret = fimc_is_af_ldo_enable("OIS_VDD_2.8V", onoff); if (ret) { err("failed to power control OIS_VDD_2.8V, onoff = %d", onoff); return -EINVAL; } /* OIS_VM_2.8V */ ret = fimc_is_af_ldo_enable("OIS_VM_2.8V", onoff); if (ret) { err("failed to power control OIS_VM_2.8V, onoff = %d", onoff); return -EINVAL; } #endif /*CAM_IO_1.8V_AP*/ ret = fimc_is_af_ldo_enable("CAM_IO_1.8V_AP", onoff); if (ret) { err("failed to power control CAM_IO_1.8V_AP, onoff = %d", onoff); return -EINVAL; } usleep_range(5000,5000); return ret; }
int msm_dss_enable_vreg(struct dss_vreg *in_vreg, int num_vreg, int enable) { int i = 0, rc = 0; if (enable) { for (i = 0; i < num_vreg; i++) { rc = PTR_RET(in_vreg[i].vreg); if (rc) { DEV_ERR("%pS->%s: %s regulator error. rc=%d\n", __builtin_return_address(0), __func__, in_vreg[i].vreg_name, rc); goto vreg_set_opt_mode_fail; } if (in_vreg[i].pre_on_sleep) msleep(in_vreg[i].pre_on_sleep); rc = regulator_set_optimum_mode(in_vreg[i].vreg, in_vreg[i].enable_load); if (rc < 0) { DEV_ERR("%pS->%s: %s set opt m fail\n", __builtin_return_address(0), __func__, in_vreg[i].vreg_name); goto vreg_set_opt_mode_fail; } rc = regulator_enable(in_vreg[i].vreg); if (in_vreg[i].post_on_sleep) msleep(in_vreg[i].post_on_sleep); if (rc < 0) { DEV_ERR("%pS->%s: %s enable failed\n", __builtin_return_address(0), __func__, in_vreg[i].vreg_name); goto disable_vreg; } #if defined (CONFIG_MACH_MSM8X10_W5) || defined (CONFIG_MACH_MSM8X10_W6) // VCI toggle for W5 Display (both for Tovis Shrink/Non-Shrink panel) if (strcmp(in_vreg[i].vreg_name, "vdda") == 0) { if (is_first_booting) { rc = regulator_disable(in_vreg[i].vreg); } if (in_vreg[i].post_on_sleep) msleep(in_vreg[i].post_on_sleep); if (rc < 0) { DEV_ERR("%pS->%s: %s enable failed\n", __builtin_return_address(0), __func__, in_vreg[i].vreg_name); goto disable_vreg; } rc = regulator_enable(in_vreg[i].vreg); if (in_vreg[i].post_on_sleep) msleep(in_vreg[i].post_on_sleep); if (rc < 0) { DEV_ERR("%pS->%s: %s enable failed\n", __builtin_return_address(0), __func__, in_vreg[i].vreg_name); goto disable_vreg; } } #endif } } else { for (i = num_vreg-1; i >= 0; i--) if (regulator_is_enabled(in_vreg[i].vreg)) { if (in_vreg[i].pre_off_sleep) msleep(in_vreg[i].pre_off_sleep); regulator_set_optimum_mode(in_vreg[i].vreg, in_vreg[i].disable_load); regulator_disable(in_vreg[i].vreg); if (in_vreg[i].post_off_sleep) msleep(in_vreg[i].post_off_sleep); } } #if defined (CONFIG_MACH_MSM8X10_W5) || defined (CONFIG_MACH_MSM8X10_W6) is_first_booting = 1; #endif return rc; disable_vreg: regulator_set_optimum_mode(in_vreg[i].vreg, in_vreg[i].disable_load); vreg_set_opt_mode_fail: for (i--; i >= 0; i--) { if (in_vreg[i].pre_off_sleep) msleep(in_vreg[i].pre_off_sleep); regulator_set_optimum_mode(in_vreg[i].vreg, in_vreg[i].disable_load); regulator_disable(in_vreg[i].vreg); if (in_vreg[i].post_off_sleep) msleep(in_vreg[i].post_off_sleep); } return rc; } /* msm_dss_enable_vreg */
static int s5k4ecgx_power_down(void) { struct regulator *regulator; int ret = 0; pr_debug("%s: in", __func__); s5k4ecgx_gpio_request(); /* VT_CAM_nSTBY(1.3M EN) LOW */ ret = gpio_request(GPIO_VT_CAM_nSTBY, "GPM0"); if (ret) { pr_err("faile to request gpio(GPIO_VT_CAM_nSTBY)"); return ret; } ret = gpio_direction_output(GPIO_VT_CAM_nSTBY, 0); CAM_CHECK_ERR_RET(ret, "low VT_CAM_nSTBY"); /* CAM_VT_nRST(1.3M RESET) LOW */ ret = gpio_request(GPIO_CAM_VT_nRST, "GPM1"); if (ret) { pr_err("faile to request gpio(GPIO_CAM_VT_nRST)"); return ret; } ret = gpio_direction_output(GPIO_CAM_VT_nRST, 0); CAM_CHECK_ERR_RET(ret, "low CAM_VT_nRST"); /* 5M_CAM_RESET(5M RESET) LOW */ ret = gpio_direction_output(GPIO_5M_CAM_RESET, 0); CAM_CHECK_ERR_RET(ret, "low 5M_CAM_RESET"); mdelay(1); /* 50us */ /* 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"); /* 5M_CAM_nSTBY(5M STBY) LOW */ ret = gpio_direction_output(GPIO_5M_CAM_nSTBY, 0); CAM_CHECK_ERR_RET(ret, "low 5M_CAM_nSTBY"); /* CAM_AF_2.8V */ regulator = regulator_get(NULL, "cam_af_2.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_af_2.8v"); /* 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_IO_1.8V */ regulator = regulator_get(NULL, "cam_sensor_io_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 cam_sensor_io_1.8v"); /* 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"); /* CAM_ISP_CORE_1.2V */ regulator = regulator_get(NULL, "cam_isp_core_1.2v"); 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_isp_core_1.2v"); gpio_free(GPIO_VT_CAM_nSTBY); gpio_free(GPIO_CAM_VT_nRST); gpio_free(GPIO_5M_CAM_RESET); gpio_free(GPIO_5M_CAM_nSTBY); return ret; }