From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Alexandre Mergnat <amergnat@baylibre.com>,
Lee Jones <lee@kernel.org>, Mark Brown <broonie@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Chen Zhong <chen.zhong@mediatek.com>
Cc: linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Rob Herring <robh@kernel.org>,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
Fabien Parent <fparent@baylibre.com>
Subject: Re: [PATCH v2 4/5] regulator: add mt6357 regulator
Date: Thu, 6 Oct 2022 12:12:06 +0200 [thread overview]
Message-ID: <a13b5dfe-2296-156c-6cd0-8fe9c5973efe@collabora.com> (raw)
In-Reply-To: <20221005-mt6357-support-v2-4-f17ba2d2d0a9@baylibre.com>
Il 05/10/22 16:57, Alexandre Mergnat ha scritto:
> From: Fabien Parent <fparent@baylibre.com>
>
> Add regulator driver for the MT6357 PMIC.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> ---
> drivers/regulator/Kconfig | 9 +
> drivers/regulator/Makefile | 1 +
> drivers/regulator/mt6357-regulator.c | 485 +++++++++++++++++++++++++++++
> include/linux/regulator/mt6357-regulator.h | 51 +++
> 4 files changed, 546 insertions(+)
>
> diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
> index 070e4403c6c2..a659a57438f4 100644
> --- a/drivers/regulator/Kconfig
> +++ b/drivers/regulator/Kconfig
> @@ -805,6 +805,15 @@ config REGULATOR_MT6332
> This driver supports the control of different power rails of device
> through regulator interface
>
> +config REGULATOR_MT6357
> + tristate "MediaTek MT6357 PMIC"
> + depends on MFD_MT6397
> + help
> + Say y here to select this option to enable the power regulator of
> + MediaTek MT6357 PMIC.
> + This driver supports the control of different power rails of device
> + through regulator interface.
> +
> config REGULATOR_MT6358
> tristate "MediaTek MT6358 PMIC"
> depends on MFD_MT6397
> diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
> index 5962307e1130..e4d67b7b1af6 100644
> --- a/drivers/regulator/Makefile
> +++ b/drivers/regulator/Makefile
> @@ -97,6 +97,7 @@ obj-$(CONFIG_REGULATOR_MT6315) += mt6315-regulator.o
> obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o
> obj-$(CONFIG_REGULATOR_MT6331) += mt6331-regulator.o
> obj-$(CONFIG_REGULATOR_MT6332) += mt6332-regulator.o
> +obj-$(CONFIG_REGULATOR_MT6357) += mt6357-regulator.o
> obj-$(CONFIG_REGULATOR_MT6358) += mt6358-regulator.o
> obj-$(CONFIG_REGULATOR_MT6359) += mt6359-regulator.o
> obj-$(CONFIG_REGULATOR_MT6360) += mt6360-regulator.o
> diff --git a/drivers/regulator/mt6357-regulator.c b/drivers/regulator/mt6357-regulator.c
> new file mode 100644
> index 000000000000..4ecd41429448
> --- /dev/null
> +++ b/drivers/regulator/mt6357-regulator.c
> @@ -0,0 +1,485 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// Copyright (c) 2022 MediaTek Inc.
> +// Copyright (c) 2022 BayLibre, SAS.
> +// Author: Chen Zhong <chen.zhong@mediatek.com>
> +// Author: Fabien Parent <fparent@baylibre.com>
> +//
> +// Based on mt6397-regulator.c
> +//
> +
> +#include <linux/module.h>
> +#include <linux/linear_range.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/mfd/mt6397/core.h>
> +#include <linux/mfd/mt6357/registers.h>
> +#include <linux/regulator/driver.h>
> +#include <linux/regulator/machine.h>
> +#include <linux/regulator/mt6357-regulator.h>
> +#include <linux/regulator/of_regulator.h>
> +
> +/*
> + * MT6357 regulators' information
> + *
> + * @desc: standard fields of regulator description.
> + * @vselon_reg: Register sections for hardware control mode of bucks
> + * @vselctrl_reg: Register for controlling the buck control mode.
> + * @vselctrl_mask: Mask for query buck's voltage control mode.
> + */
> +struct mt6357_regulator_info {
> + struct regulator_desc desc;
> + const u32 *index_table;
> + unsigned int n_table;
> + u32 vsel_shift;
> + u32 da_vsel_reg;
> + u32 da_vsel_mask;
> + u32 da_vsel_shift;
> +};
> +
> +#define MT6357_BUCK(match, vreg, min, max, step, \
> + volt_ranges, vosel_reg, vosel_mask, _da_vsel_mask) \
> +[MT6357_ID_##vreg] = { \
> + .desc = { \
> + .name = #vreg, \
> + .of_match = of_match_ptr(match), \
> + .regulators_node = "regulators", \
> + .ops = &mt6357_volt_range_ops, \
> + .type = REGULATOR_VOLTAGE, \
> + .id = MT6357_ID_##vreg, \
> + .owner = THIS_MODULE, \
> + .n_voltages = ((max) - (min)) / (step) + 1, \
> + .linear_ranges = volt_ranges, \
> + .n_linear_ranges = ARRAY_SIZE(volt_ranges), \
> + .vsel_reg = vosel_reg, \
> + .vsel_mask = vosel_mask, \
> + .enable_reg = MT6357_BUCK_##vreg##_CON0, \
> + .enable_mask = BIT(0), \
> + }, \
> + .da_vsel_reg = MT6357_BUCK_##vreg##_DBG0, \
> + .da_vsel_mask = vosel_mask, \
> + .da_vsel_shift = 0, \
> +}
> +
> +#define MT6357_LDO(match, vreg, ldo_volt_table, \
> + ldo_index_table, enreg, vosel, \
> + vosel_mask) \
> +[MT6357_ID_##vreg] = { \
> + .desc = { \
> + .name = #vreg, \
> + .of_match = of_match_ptr(match), \
> + .regulators_node = "regulators", \
> + .ops = &mt6357_volt_table_ops, \
> + .type = REGULATOR_VOLTAGE, \
> + .id = MT6357_ID_##vreg, \
> + .owner = THIS_MODULE, \
> + .n_voltages = ARRAY_SIZE(ldo_volt_table), \
> + .volt_table = ldo_volt_table, \
> + .vsel_reg = vosel, \
> + .vsel_mask = vosel_mask << 8, \
> + .enable_reg = enreg, \
> + .enable_mask = BIT(0), \
> + }, \
> + .index_table = ldo_index_table, \
> + .n_table = ARRAY_SIZE(ldo_index_table), \
> +}
> +
> +#define MT6357_LDO1(match, vreg, min, max, step, volt_ranges, \
> + enreg, vosel, vosel_mask) \
> +[MT6357_ID_##vreg] = { \
> + .desc = { \
> + .name = #vreg, \
> + .of_match = of_match_ptr(match), \
> + .regulators_node = "regulators", \
> + .ops = &mt6357_volt_range_ops, \
> + .type = REGULATOR_VOLTAGE, \
> + .id = MT6357_ID_##vreg, \
> + .owner = THIS_MODULE, \
> + .n_voltages = ((max) - (min)) / (step) + 1, \
> + .linear_ranges = volt_ranges, \
> + .n_linear_ranges = ARRAY_SIZE(volt_ranges), \
> + .vsel_reg = vosel, \
> + .vsel_mask = vosel_mask, \
> + .enable_reg = enreg, \
> + .enable_mask = BIT(0), \
> + }, \
> + .da_vsel_reg = MT6357_LDO_##vreg##_DBG0, \
> + .da_vsel_mask = 0x7f, \
> + .da_vsel_shift = 8, \
There's something wrong here: ((val & 0x7f) >> 8) is always zero,
and you're using mt6357_volt_range_ops, that is using function
mt6357_get_buck_voltage_sel, which is doing exactly that.
Regards,
Angelo
next prev parent reply other threads:[~2022-10-06 10:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-05 14:57 [PATCH v2 0/5] Add MediaTek MT6357 PMIC support Alexandre Mergnat
2022-10-05 14:57 ` [PATCH v2 1/5] dt-bindings: mfd: mt6397: add binding for MT6357 Alexandre Mergnat
2022-10-24 12:51 ` Lee Jones
2022-10-05 14:57 ` [PATCH v2 2/5] dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC Alexandre Mergnat
2022-10-10 18:03 ` Dmitry Torokhov
2022-10-05 14:57 ` [PATCH v2 3/5] dt-bindings: regulator: Add binding schema for mt6357 regulators Alexandre Mergnat
2022-10-05 16:02 ` Krzysztof Kozlowski
2022-10-11 9:30 ` Alexandre Mergnat
2022-10-11 10:36 ` Mark Brown
2022-10-11 12:03 ` Krzysztof Kozlowski
2022-10-05 14:57 ` [PATCH v2 4/5] regulator: add mt6357 regulator Alexandre Mergnat
2022-10-05 15:09 ` Mark Brown
2022-10-06 10:12 ` AngeloGioacchino Del Regno [this message]
2022-10-05 14:57 ` [PATCH v2 5/5] Input: mtk-pmic-keys: add MT6357 support Alexandre Mergnat
2022-10-06 7:40 ` Mattijs Korpershoek
2022-10-06 10:12 ` AngeloGioacchino Del Regno
2022-10-10 18:04 ` Dmitry Torokhov
2022-10-24 12:50 ` Lee Jones
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=a13b5dfe-2296-156c-6cd0-8fe9c5973efe@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=amergnat@baylibre.com \
--cc=broonie@kernel.org \
--cc=chen.zhong@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=fparent@baylibre.com \
--cc=krzysztof.kozlowski+dt@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-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=robh@kernel.org \
/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).