From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Alexandre Mergnat <amergnat@baylibre.com>,
Flora Fu <flora.fu@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Tianping Fang <tianping.fang@mediatek.com>,
Fabien Parent <fabien.parent@linaro.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Mark Brown <broonie@kernel.org>,
Sean Wang <sean.wang@mediatek.com>,
Chen Zhong <chen.zhong@mediatek.com>, Pavel Machek <pavel@ucw.cz>,
Lee Jones <lee@kernel.org>,
Alessandro Zummo <a.zummo@towertech.it>,
Rob Herring <robh+dt@kernel.org>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Rob Herring <robh@kernel.org>,
Mattijs Korpershoek <mkorpershoek@baylibre.com>,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-leds@vger.kernel.org, Fabien Parent <fparent@baylibre.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-rtc@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH v5 09/10] regulator: add mt6357 regulator
Date: Wed, 16 Nov 2022 16:17:02 +0200 [thread overview]
Message-ID: <d61d8c22-fce5-74d5-6d2b-0eda6f2ace9e@gmail.com> (raw)
In-Reply-To: <20221005-mt6357-support-v5-9-8210d955dd3d@baylibre.com>
Hi Alexandre, All
Please, treat my review more as initiation for discussion than 'hard
requirements' for this driver. I am in no point or no "confidence level"
to give you any requirements ;)
On 11/16/22 14:33, Alexandre Mergnat wrote:
> From: Fabien Parent <fparent@baylibre.com>
>
> Add regulator driver for the MT6357 PMIC.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> ---
//snip
> +/*
> + * MT6357 regulators' information
> + *
> + * @desc: standard fields of regulator description.
> + * @da_vsel_reg: Monitor register for query buck's voltage.
> + * @da_vsel_mask: Mask for query buck's voltage.
> + */
> +struct mt6357_regulator_info {
> + struct regulator_desc desc;
> + u32 da_vsel_reg;
> + u32 da_vsel_mask;
> +};
> +
//snip
> +/**
> + * mt6357_get_buck_voltage_sel - get_voltage_sel for regmap users
> + *
> + * @rdev: regulator to operate on
> + *
> + * Regulators that use regmap for their register I/O can set the
> + * da_vsel_reg and da_vsel_mask fields in the info structure and
> + * then use this as their get_voltage_vsel operation.
> + */
> +static int mt6357_get_buck_voltage_sel(struct regulator_dev *rdev)
> +{
> + int ret, regval;
> + struct mt6357_regulator_info *info = rdev_get_drvdata(rdev);
> +
> + ret = regmap_read(rdev->regmap, info->da_vsel_reg, ®val);
> + if (ret != 0) {
> + dev_err(&rdev->dev,
> + "Failed to get mt6357 Buck %s vsel reg: %d\n",
> + info->desc.name, ret);
> + return ret;
> + }
> +
> + regval &= info->da_vsel_mask;
> + regval >>= ffs(info->da_vsel_mask) - 1;
> +
> + return regval;
> +}
If I read this right, the device has separate register(s) for writing
and reading the voltage? I wonder if this is a completely unique setup?
If this is not unique, then it might be worth adding another field for
'vsel_get' register and a flag in regulator desc - and modify the
generic regmap helpers to handle this in common code if the special
register? Not sure if this HW design is common enough to warrant the
added confusion though. You and Mark may have more insight.
> +
> +static const struct linear_range buck_volt_range1[] = {
> + REGULATOR_LINEAR_RANGE(518750, 0, 0x7f, 6250),
> +};
> +
> +static const struct linear_range buck_volt_range2[] = {
> + REGULATOR_LINEAR_RANGE(500000, 0, 0x7f, 6250),
> +};
> +
> +static const struct linear_range buck_volt_range3[] = {
> + REGULATOR_LINEAR_RANGE(500000, 0, 0x3f, 50000),
> +};
> +
> +static const struct linear_range buck_volt_range4[] = {
> + REGULATOR_LINEAR_RANGE(1200000, 0, 0x7f, 12500),
> +};
I am unsure if we should aim for dropping the REGULATOR_LINEAR_RANGE()
and using the LINEAR_RANGE(). If yes, then it might simplify things if
new drivers used LINEAR_RANGE() from the day 1. If we don't, then it
makes sense to keep consistently using REGULATOR_LINEAR_RANGE() for all
of the drivers. I am not sure which way is the right way.
> +static int mt6357_regulator_probe(struct platform_device *pdev)
> +{
> + struct mt6397_chip *mt6357 = dev_get_drvdata(pdev->dev.parent);
I am unsure what data do you need from the parent. If it is just the
regmap / device-tree node / device, then it does not (in my opinion)
really warrant using parent's drvdata. One can often get away with the
dev_get_regmap(pdev->dev.parent, NULL).
Anyways, the driver looks good to me.
Yours,
-- Matti Vaittinen
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2022-11-16 14:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 12:32 [PATCH v5 00/10] Add MediaTek MT6357 PMIC support Alexandre Mergnat
2022-11-16 12:32 ` [PATCH v5 01/10] dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC Alexandre Mergnat
2022-11-16 12:32 ` [PATCH v5 02/10] dt-bindings: rtc: mediatek: convert MT6397 rtc documentation Alexandre Mergnat
2022-11-17 15:39 ` Rob Herring
2022-11-16 12:32 ` [PATCH v5 03/10] dt-bindings: rtc: mediatek: add MT6357 support Alexandre Mergnat
2022-11-20 16:44 ` Rob Herring
2022-11-16 12:32 ` [PATCH v5 04/10] regulator: dt-bindings: Add binding schema for mt6357 regulators Alexandre Mergnat
2022-11-16 12:32 ` [PATCH v5 05/10] dt-bindings: mfd: mediatek: Add bindings for MT6357 PMIC Alexandre Mergnat
2022-11-16 16:03 ` Rob Herring
2022-11-16 16:26 ` Alexandre Mergnat
2022-11-16 12:33 ` [PATCH v5 06/10] dt-bindings: soc: mediatek: convert pwrap documentation Alexandre Mergnat
2022-11-17 16:00 ` Rob Herring
2022-11-17 16:06 ` Matthias Brugger
2022-11-22 8:14 ` Alexandre Mergnat
2022-11-22 15:37 ` Alexandre Mergnat
2022-11-16 12:33 ` [PATCH v5 07/10] arm64: dts: mt6358: change node names Alexandre Mergnat
2022-11-17 16:02 ` Matthias Brugger
2022-11-16 12:33 ` [PATCH v5 08/10] arm64: dts: mt8173: change node name Alexandre Mergnat
2022-11-17 15:56 ` Matthias Brugger
2022-11-16 12:33 ` [PATCH v5 09/10] regulator: add mt6357 regulator Alexandre Mergnat
2022-11-16 14:17 ` Matti Vaittinen [this message]
2022-11-22 10:17 ` Alexandre Mergnat
2022-11-16 12:33 ` [PATCH v5 10/10] Input: mtk-pmic-keys: add MT6357 support Alexandre Mergnat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d61d8c22-fce5-74d5-6d2b-0eda6f2ace9e@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=amergnat@baylibre.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=chen.zhong@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=fabien.parent@linaro.org \
--cc=flora.fu@mediatek.com \
--cc=fparent@baylibre.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-rtc@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=mkorpershoek@baylibre.com \
--cc=pavel@ucw.cz \
--cc=robh+dt@kernel.org \
--cc=robh@kernel.org \
--cc=sean.wang@mediatek.com \
--cc=tianping.fang@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).