regulator: rk806: Solve the initialization of non integer multiple step voltage

Resolve system error caused by the set voltage not being an integer
multiple of the uV_step.

Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Change-Id: Icdae0985e0173289c66c1d6cc182da92508acd4c
This commit is contained in:
shengfei Xu
2024-03-31 17:15:27 +08:00
committed by Tao Huang
parent 3a4532abef
commit 205aaf1b9b

View File

@@ -681,7 +681,9 @@ static int rk806_regulator_resume(struct regulator_dev *rdev)
static int rk806_set_suspend_voltage_range(struct regulator_dev *rdev, int uv)
{
struct rk806_regulator_data *pdata = rdev_get_drvdata(rdev);
int sel = regulator_map_voltage_linear_range(rdev, uv, uv);
int sel = regulator_map_voltage_linear_range(rdev,
uv,
rdev->constraints->max_uV);
struct rk806 *rk806 = pdata->rk806;
int rid = rdev_get_id(rdev);
int reg_offset;
@@ -725,6 +727,8 @@ static int rk806_set_voltage(struct regulator_dev *rdev,
int ret;
int sel;
if (req_min_uV == req_max_uV)
req_max_uV = rdev->constraints->max_uV;
ret = regulator_map_voltage_linear_range(rdev, req_min_uV, req_max_uV);
if (ret >= 0) {
*selector = ret;