[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <76e2f865-1a37-4517-b343-6aaea397fcf7@sirena.org.uk>
Date: Wed, 28 Jun 2023 20:28:48 +0100
From: Mark Brown <broonie@...nel.org>
To: Konrad Dybcio <konrad.dybcio@...aro.org>
Cc: Andy Gross <agross@...nel.org>,
Bjorn Andersson <andersson@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Rob Clark <robdclark@...il.com>,
Abhinav Kumar <quic_abhinavk@...cinc.com>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Sean Paul <sean@...rly.run>, David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
Krishna Manikandan <quic_mkrishn@...cinc.com>,
Marijn Suijten <marijn.suijten@...ainline.org>,
Konrad Dybcio <konradybcio@...nel.org>,
linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, dri-devel@...ts.freedesktop.org,
freedreno@...ts.freedesktop.org
Subject: Re: [PATCH 2/4] regulator: Introduce Qualcomm REFGEN regulator driver
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.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists