// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2019 MediaTek Inc. */ #include #include #include #if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV) static struct regulator *disp_bias_pos; static struct regulator *disp_bias_neg; static int regulator_inited; int display_bias_regulator_init(void) { int ret = 0; if (regulator_inited) return ret; /* please only get regulator once in a driver */ disp_bias_pos = regulator_get(NULL, "dsv_pos"); if (IS_ERR(disp_bias_pos)) { /* handle return value */ ret = PTR_ERR(disp_bias_pos); pr_info("get dsv_pos fail, error: %d\n", ret); return ret; } disp_bias_neg = regulator_get(NULL, "dsv_neg"); if (IS_ERR(disp_bias_neg)) { /* handle return value */ ret = PTR_ERR(disp_bias_neg); pr_info("get dsv_neg fail, error: %d\n", ret); return ret; } regulator_inited = 1; return ret; /* must be 0 */ } EXPORT_SYMBOL(display_bias_regulator_init); int disp_late_bias_enable(void) { int ret = 0; int retval = 0; display_bias_regulator_init(); ret = regulator_enable(disp_bias_pos); if (ret < 0) pr_info("enable regulator disp_bias_pos fail, ret = %d\n", ret); retval |= ret; ret = regulator_enable(disp_bias_neg); if (ret < 0) pr_info("enable regulator disp_bias_neg fail, ret = %d\n", ret); retval |= ret; return retval; } EXPORT_SYMBOL(disp_late_bias_enable); int display_bias_enable(void) { int ret = 0; int retval = 0; display_bias_regulator_init(); /* set voltage with min & max*/ ret = regulator_set_voltage(disp_bias_pos, 5400000, 5400000); if (ret < 0) pr_info("set voltage disp_bias_pos fail, ret = %d\n", ret); retval |= ret; ret = regulator_set_voltage(disp_bias_neg, 5400000, 5400000); if (ret < 0) pr_info("set voltage disp_bias_neg fail, ret = %d\n", ret); retval |= ret; /* enable regulator */ ret = regulator_enable(disp_bias_pos); if (ret < 0) pr_info("enable regulator disp_bias_pos fail, ret = %d\n", ret); retval |= ret; ret = regulator_enable(disp_bias_neg); if (ret < 0) pr_info("enable regulator disp_bias_neg fail, ret = %d\n", ret); retval |= ret; return retval; } EXPORT_SYMBOL(display_bias_enable); int display_bias_disable(void) { int ret = 0; int retval = 0; display_bias_regulator_init(); ret = regulator_disable(disp_bias_neg); if (ret < 0) pr_info("disable regulator disp_bias_neg fail, ret = %d\n", ret); retval |= ret; ret = regulator_disable(disp_bias_pos); if (ret < 0) pr_info("disable regulator disp_bias_pos fail, ret = %d\n", ret); retval |= ret; return retval; } EXPORT_SYMBOL(display_bias_disable); #else int display_bias_regulator_init(void) { return 0; } EXPORT_SYMBOL(display_bias_regulator_init); int display_bias_enable(void) { return 0; } EXPORT_SYMBOL(display_bias_enable); int disp_late_bias_enable(void) { return 0; } EXPORT_SYMBOL(disp_late_bias_enable); int display_bias_disable(void) { return 0; } EXPORT_SYMBOL(display_bias_disable); #endif