Files
android/drivers/misc/mediatek/lcm/lcm_pmic.c
T
threeeye bc1d038eac REVVL 6 Pro kernel bring-up: full working tree snapshot (2026-09-12)
Squashed backup commit (no shallow-clone history issues) of
xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream
commit 9eece662e) plus all fixes applied to get everpal_defconfig building
clean against a modern (GCC 15.2.0) toolchain -- see the previous commit
message on the lineage-23.2 branch (also in this repo history is not
available here since this is a squashed snapshot; full incremental history
lives in the local DL380 checkout and the upstream GitHub remote).

Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
2026-09-12 13:36:46 +00:00

170 lines
3.7 KiB
C

/*
* Copyright (C) 2015 MediaTek Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/regulator/consumer.h>
#include <linux/string.h>
#include <linux/kernel.h>
#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;
#if 0
/* get voltage */
ret = mtk_regulator_get_voltage(&disp_bias_pos);
if (ret < 0)
pr_info("get voltage disp_bias_pos fail\n");
pr_debug("pos voltage = %d\n", ret);
ret = mtk_regulator_get_voltage(&disp_bias_neg);
if (ret < 0)
pr_info("get voltage disp_bias_neg fail\n");
pr_debug("neg voltage = %d\n", ret);
#endif
/* 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