static void msm_sensor_misc_regulator( struct msm_sensor_ctrl_t *sctrl, uint32_t enable) { int32_t rc = 0; if (enable) { sctrl->misc_regulator = (void *)rpm_regulator_get( &sctrl->pdev->dev, sctrl->sensordata->misc_regulator); if (sctrl->misc_regulator) { rc = rpm_regulator_set_mode(sctrl->misc_regulator, RPM_REGULATOR_MODE_HPM); if (rc < 0) { pr_err("%s: Failed to set for rpm regulator on %s: %d\n", __func__, sctrl->sensordata->misc_regulator, rc); rpm_regulator_put(sctrl->misc_regulator); } } else { pr_err("%s: Failed to vote for rpm regulator on %s: %d\n", __func__, sctrl->sensordata->misc_regulator, rc); } } else { if (sctrl->misc_regulator) { rc = rpm_regulator_set_mode( (struct rpm_regulator *)sctrl->misc_regulator, RPM_REGULATOR_MODE_AUTO); if (rc < 0) pr_err("%s: Failed to set for rpm regulator on %s: %d\n", __func__, sctrl->sensordata->misc_regulator, rc); rpm_regulator_put(sctrl->misc_regulator); } } }
static void __init oppo_config_sns_power(void) { int ret; sns_reg = rpm_regulator_get(NULL, "8941_l18"); if (IS_ERR_OR_NULL(sns_reg)) { ret = PTR_ERR(sns_reg); pr_err("8941_l18 rpm_regulator_get failed (%d)\n", ret); sns_reg = 0; } else { ret = rpm_regulator_enable(sns_reg); if (ret) pr_err("8941_l18 rpm_regulator_enable failed (%d)\n", ret); INIT_DELAYED_WORK(&sns_dwork, oppo_config_sns_reg_release); schedule_delayed_work(&sns_dwork, msecs_to_jiffies(30000)); } }
static int psm_reg_init(struct platform_device *pdev) { int ret = 0; int i = 0; int j = 0; for (i = 0; i < psm_rails_cnt; i++) { psm_rails[i].reg = rpm_regulator_get(&pdev->dev, psm_rails[i].name); if (IS_ERR_OR_NULL(psm_rails[i].reg)) { ret = PTR_ERR(psm_rails[i].reg); if (ret != -EPROBE_DEFER) { pr_err("%s, could not get rpm regulator: %s\n", psm_rails[i].name, __func__); psm_rails[i].reg = NULL; goto psm_reg_exit; } return ret; } /* Apps default vote for PWM mode */ psm_rails[i].init = PMIC_PWM_MODE; ret = rpm_regulator_set_mode(psm_rails[i].reg, psm_rails[i].init); if (ret) { pr_err("%s: Cannot set PMIC PWM mode\n", __func__); return ret; } else psm_rails[i].mode = PMIC_PWM_MODE; } return ret; psm_reg_exit: if (ret) { for (j = 0; j < i; j++) { if (psm_rails[j].reg != NULL) rpm_regulator_put(psm_rails[j].reg); } } return ret; }
static int get_vbus_detect_gpio(struct dwc3_msm *dwcm, struct device *dev) { int ret; struct device_node *np = dev->of_node; gpio_usb_vbus_msm = of_get_named_gpio(np, "qcom,vbus-detect-gpio", 0); if (gpio_usb_vbus_msm < 0) { pr_err("%s, cannot get vbus-detect-gpio, ret=%d\n", __func__, gpio_usb_vbus_msm); return gpio_usb_vbus_msm; } else pr_info("%s, can get vbus-detect-gpio, ret=%d\n", __func__, gpio_usb_vbus_msm); ret = gpio_tlmm_config(GPIO_CFG(gpio_usb_vbus_msm, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1); if (unlikely(ret)) { pr_err("%s gpio_usb_vbus_msm gpio_tlmm_config failed. ret=%d\n", __func__, ret); return ret; } pr_info("%s usb_vbus_msm=%d\n", __func__, gpio_get_value(gpio_usb_vbus_msm)); ret = request_threaded_irq(gpio_to_irq(gpio_usb_vbus_msm), NULL, msm_usb_vbus_msm_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "usb_vbus_msm", dwcm); if (ret) pr_err("%s request irq failed for usb_vbus_msm\n", __func__); else pr_info("%s request irq succeed for usb_vbus_msm\n", __func__); #if defined(CONFIG_MACH_VIENNA) s2a_regulator = rpm_regulator_get(NULL, "8941_s2"); if (IS_ERR_OR_NULL(s2a_regulator)) pr_err("%s, could not get rpm regulator err\n", __func__); usb_vbus_s2a_force_pwm(gpio_get_value(gpio_usb_vbus_msm)); #endif return ret; }