Re: [PATCH 2/4] regulator: Introduce Qualcomm REFGEN regulator driver
From: Mark Brown
Date: Wed Jun 28 2023 - 15:29:03 EST
On Wed, Jun 28, 2023 at 06:29:46PM +0200, Konrad Dybcio wrote:
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2017, 2019-2020, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2023, Linaro Limited
> + */
Please use a C++ comment for the whole thing for consistency.
> +static int qcom_sdm845_refgen_enable(struct regulator_dev *rdev)
> +{
> + struct qcom_refgen *vreg = rdev_get_drvdata(rdev);
> +
> + regmap_update_bits(vreg->base, REFGEN_REG_BG_CTRL,
> + REFGEN_BG_CTRL_MASK, REFGEN_BG_CTRL_ENABLE);
> + regmap_write(vreg->base, REFGEN_REG_BIAS_EN, REFGEN_BIAS_EN_ENABLE);
For the enable and disable operations we use a mix of _update_bits() and
absolute writes with no FIELD_PREP()...
> +static int qcom_sdm845_refgen_is_enabled(struct regulator_dev *rdev)
> +{
> + struct qcom_refgen *vreg = rdev_get_drvdata(rdev);
> + u32 val;
> +
> + regmap_read(vreg->base, REFGEN_REG_BG_CTRL, &val);
> + if (FIELD_GET(REFGEN_BG_CTRL_MASK, val) != REFGEN_BG_CTRL_ENABLE)
> + return 0;
> +
> + regmap_read(vreg->base, REFGEN_REG_BIAS_EN, &val);
> + if (FIELD_GET(REFGEN_BIAS_EN_MASK, val) != REFGEN_BIAS_EN_ENABLE)
> + return 0;
...but when we read back the status we use FIELD_GET(). This looks like
a bug, and given that one of the fields starts at bit 1 it presumably is
one - FIELD_GET() will do shifting.
> +static int qcom_sm8250_refgen_enable(struct regulator_dev *rdev)
> +{
> + struct qcom_refgen *vreg = rdev_get_drvdata(rdev);
> +
> + regmap_update_bits(vreg->base, REFGEN_REG_PWRDWN_CTRL5,
> + REFGEN_PWRDWN_CTRL5_MASK, REFGEN_PWRDWN_CTRL5_ENABLE);
This is a single bit in a single register so could use the standard
helpers rather than open coding, the sdm845 does need custom operations
due to having two fields to manage.
Attachment:
signature.asc
Description: PGP signature