lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a13b5dfe-2296-156c-6cd0-8fe9c5973efe@collabora.com>
Date:   Thu, 6 Oct 2022 12:12:06 +0200
From:   AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>
To:     Alexandre Mergnat <amergnat@...libre.com>,
        Lee Jones <lee@...nel.org>, Mark Brown <broonie@...nel.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Rob Herring <robh+dt@...nel.org>,
        Liam Girdwood <lgirdwood@...il.com>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Chen Zhong <chen.zhong@...iatek.com>
Cc:     linux-mediatek@...ts.infradead.org, devicetree@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        Rob Herring <robh@...nel.org>, linux-kernel@...r.kernel.org,
        linux-input@...r.kernel.org, Fabien Parent <fparent@...libre.com>
Subject: Re: [PATCH v2 4/5] regulator: add mt6357 regulator

Il 05/10/22 16:57, Alexandre Mergnat ha scritto:
> From: Fabien Parent <fparent@...libre.com>
> 
> Add regulator driver for the MT6357 PMIC.
> 
> Signed-off-by: Fabien Parent <fparent@...libre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@...libre.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@...iatek.com>
> +// Author: Fabien Parent <fparent@...libre.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ