From: Mark Brown <broonie@kernel.org>
To: Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com>
Cc: Lee Jones <lee.jones@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Eddie Huang <eddie.huang@mediatek.com>,
Marc Zyngier <marc.zyngier@arm.com>,
srv_heupstream@mediatek.com, linux-mediatek@lists.infradead.org,
linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
Sean Wang <sean.wang@mediatek.com>,
Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v2 6/9] regulator: mt6358: Add support for MT6358 regulator
Date: Wed, 13 Mar 2019 15:01:32 +0000 [thread overview]
Message-ID: <20190313150132.GA5951@sirena.org.uk> (raw)
In-Reply-To: <1552275991-34648-7-git-send-email-hsin-hsiung.wang@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 2264 bytes --]
On Mon, Mar 11, 2019 at 11:46:28AM +0800, Hsin-Hsiung Wang wrote:
> +static const u32 vefuse_voltages[] = {
> + 1700000, 1800000, 1900000,
> +};
This and a bunch of the other regulators look like they're just linear
ranges and could use the linear range helpers.
> +static const u32 vcn33_bt_voltages[] = {
> + 3300000, 3400000, 3500000,
> +};
> +
> +static const u32 vcn33_wifi_voltages[] = {
> + 3300000, 3400000, 3500000,
> +};
These also have the same range so no matter which helpers are used I'd
expect the data to be shared, I think some of the other regulators might
have shared tables but didn't confirm.
> +static inline unsigned int mt6358_map_mode(unsigned int mode)
> +{
> + return mode == MT6358_BUCK_MODE_FORCE_PWM ?
> + REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL;
> +}
Please write normal if statements, it makes the code more readable.
> +static int mt6358_set_voltage_sel(struct regulator_dev *rdev,
> + unsigned int selector)
> +{
> + int idx, ret;
> + const u32 *pvol;
> + struct mt6358_regulator_info *info = rdev_get_drvdata(rdev);
> +
> + pvol = (const u32 *)info->index_table;
> +
> + idx = pvol[selector];
> + ret = regmap_update_bits(rdev->regmap, info->desc.vsel_reg,
> + info->desc.vsel_mask,
> + idx << info->vsel_shift);
> +
> + return ret;
> +}
This looks like something other devices might do - rather than implement
it in the driver it would be a bit better to add it to helpers.c as a
reusable function.
> +static int mt6358_get_buck_voltage_sel(struct regulator_dev *rdev)
> +{
> + int ret, regval;
> + struct mt6358_regulator_info *info = rdev_get_drvdata(rdev);
> +
> + ret = regmap_read(rdev->regmap, info->da_vsel_reg, ®val);
> + if (ret != 0) {
> + dev_info(&rdev->dev,
> + "Failed to get mt6358 Buck %s vsel reg: %d\n",
> + info->desc.name, ret);
> + return ret;
> + }
> +
> + ret = (regval >> info->da_vsel_shift) & info->da_vsel_mask;
> +
> + return ret;
> +}
This is just the generic get_voltage_sel() as far as I can see?
> + /* Read PMIC chip revision to update constraints and voltage table */
> + if (regmap_read(mt6397->regmap, MT6358_SWCID, ®_value) < 0) {
> + dev_err(&pdev->dev, "Failed to read Chip ID\n");
> + return -EIO;
> + }
We never use the value we read here?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-03-13 15:02 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-11 3:46 [PATCH v2 0/9] Add Support for MediaTek PMIC MT6358 Hsin-Hsiung Wang
2019-03-11 3:46 ` [PATCH v2 1/9] mfd: mt6397: clean up code Hsin-Hsiung Wang
2019-03-11 19:01 ` Sean Wang
2019-03-12 14:49 ` Matthias Brugger
2019-04-02 6:48 ` Lee Jones
2019-03-11 3:46 ` [PATCH v2 2/9] mfd: mt6397: extract irq related code from core driver Hsin-Hsiung Wang
2019-03-11 19:10 ` Sean Wang
2019-03-14 23:25 ` Nicolas Boichat
2019-03-11 3:46 ` [PATCH v2 3/9] dt-bindings: mfd: Add compatible for the MediaTek MT6358 PMIC Hsin-Hsiung Wang
2019-03-11 19:19 ` Sean Wang
2019-03-11 22:06 ` Rob Herring
2019-03-12 2:25 ` Sean Wang
2019-04-02 7:00 ` Lee Jones
2019-03-11 3:46 ` [PATCH v2 4/9] regulator: Add document for MT6358 regulator Hsin-Hsiung Wang
2019-03-11 19:43 ` Sean Wang
2019-03-11 3:46 ` [PATCH v2 5/9] mfd: Add support for the MediaTek MT6358 PMIC Hsin-Hsiung Wang
2019-03-11 8:22 ` Nicolas Boichat
2019-03-11 20:05 ` Sean Wang
2019-03-15 7:10 ` Nicolas Boichat
2019-03-15 7:37 ` Claire Chang
2019-03-11 3:46 ` [PATCH v2 6/9] regulator: mt6358: Add support for MT6358 regulator Hsin-Hsiung Wang
2019-03-13 15:01 ` Mark Brown [this message]
2019-03-11 3:46 ` [PATCH v2 7/9] arm64: dts: mt6358: add PMIC MT6358 related nodes Hsin-Hsiung Wang
2019-03-11 20:23 ` Sean Wang
2019-03-11 3:46 ` [PATCH v2 8/9] rtc: mt6397: fix alarm register overwrite Hsin-Hsiung Wang
2019-03-11 6:05 ` Eddie Huang
2019-03-11 20:50 ` Sean Wang
2019-03-14 2:46 ` mtk14576
2019-04-02 14:07 ` Alexandre Belloni
2019-03-11 3:46 ` [PATCH v2 9/9] rtc: Add support for the MediaTek MT6358 RTC Hsin-Hsiung Wang
2019-03-11 6:10 ` Eddie Huang
2019-03-21 9:51 ` Yingjoe Chen
2019-04-02 14:06 ` Alexandre Belloni
2019-03-11 21:21 ` [PATCH v2 0/9] Add Support for MediaTek PMIC MT6358 Alexandre Belloni
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=20190313150132.GA5951@sirena.org.uk \
--to=broonie@kernel.org \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=eddie.huang@mediatek.com \
--cc=hsin-hsiung.wang@mediatek.com \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-rtc@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=sean.wang@mediatek.com \
--cc=srv_heupstream@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
all inboxes | Powered by JetHome®