linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] regulator: rt5033: Use linear ranges to map all voltage selection
@ 2021-07-06  6:45 cy_huang
  2021-07-06  6:49 ` Axel Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: cy_huang @ 2021-07-06  6:45 UTC (permalink / raw)
  To: lee.jones, broonie; +Cc: linux-kernel, lgirdwood, axel.lin, cy_huang

From: ChiYuan Huang <cy_huang@richtek.com>

Instead of linear mapping, Use linear range to map all voltage selection.

Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
Since v2
- recover the volt number back in rt5033-private.h
- Add the n_voltages from v1 back.

Even though commit 6549c46af855 ("regulator: rt5033: Fix n_voltages settings for BUCK and LDO")
can fix the linear mapping to the correct min/max voltage
But there're still non-step ranges for the reserved value.

To use the linear range can fix it for mapping all voltage selection.
---
 drivers/regulator/rt5033-regulator.c | 21 +++++++++++++++------
 include/linux/mfd/rt5033-private.h   |  4 ++--
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/regulator/rt5033-regulator.c b/drivers/regulator/rt5033-regulator.c
index 0e73116..da4cf5a 100644
--- a/drivers/regulator/rt5033-regulator.c
+++ b/drivers/regulator/rt5033-regulator.c
@@ -13,6 +13,16 @@
 #include <linux/mfd/rt5033-private.h>
 #include <linux/regulator/of_regulator.h>
 
+static const struct linear_range rt5033_buck_ranges[] = {
+	REGULATOR_LINEAR_RANGE(1000000, 0, 20, 100000),
+	REGULATOR_LINEAR_RANGE(3000000, 21, 31, 0),
+};
+
+static const struct linear_range rt5033_ldo_ranges[] = {
+	REGULATOR_LINEAR_RANGE(1200000, 0, 18, 100000),
+	REGULATOR_LINEAR_RANGE(3000000, 19, 31, 0),
+};
+
 static const struct regulator_ops rt5033_safe_ldo_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
@@ -24,8 +34,7 @@ static const struct regulator_ops rt5033_buck_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
-	.list_voltage		= regulator_list_voltage_linear,
-	.map_voltage		= regulator_map_voltage_linear,
+	.list_voltage		= regulator_list_voltage_linear_range,
 	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
 	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
 };
@@ -40,8 +49,8 @@ static const struct regulator_desc rt5033_supported_regulators[] = {
 		.type		= REGULATOR_VOLTAGE,
 		.owner		= THIS_MODULE,
 		.n_voltages	= RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM,
-		.min_uV		= RT5033_REGULATOR_BUCK_VOLTAGE_MIN,
-		.uV_step	= RT5033_REGULATOR_BUCK_VOLTAGE_STEP,
+		.linear_ranges	= rt5033_buck_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rt5033_buck_ranges),
 		.enable_reg	= RT5033_REG_CTRL,
 		.enable_mask	= RT5033_CTRL_EN_BUCK_MASK,
 		.vsel_reg	= RT5033_REG_BUCK_CTRL,
@@ -56,8 +65,8 @@ static const struct regulator_desc rt5033_supported_regulators[] = {
 		.type		= REGULATOR_VOLTAGE,
 		.owner		= THIS_MODULE,
 		.n_voltages	= RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM,
-		.min_uV		= RT5033_REGULATOR_LDO_VOLTAGE_MIN,
-		.uV_step	= RT5033_REGULATOR_LDO_VOLTAGE_STEP,
+		.linear_ranges	= rt5033_ldo_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rt5033_ldo_ranges),
 		.enable_reg	= RT5033_REG_CTRL,
 		.enable_mask	= RT5033_CTRL_EN_LDO_MASK,
 		.vsel_reg	= RT5033_REG_LDO_CTRL,
diff --git a/include/linux/mfd/rt5033-private.h b/include/linux/mfd/rt5033-private.h
index 40a0c2d..2d1895c 100644
--- a/include/linux/mfd/rt5033-private.h
+++ b/include/linux/mfd/rt5033-private.h
@@ -200,13 +200,13 @@ enum rt5033_reg {
 #define RT5033_REGULATOR_BUCK_VOLTAGE_MIN		1000000U
 #define RT5033_REGULATOR_BUCK_VOLTAGE_MAX		3000000U
 #define RT5033_REGULATOR_BUCK_VOLTAGE_STEP		100000U
-#define RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM		21
+#define RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM		32
 
 /* RT5033 regulator LDO output voltage uV */
 #define RT5033_REGULATOR_LDO_VOLTAGE_MIN		1200000U
 #define RT5033_REGULATOR_LDO_VOLTAGE_MAX		3000000U
 #define RT5033_REGULATOR_LDO_VOLTAGE_STEP		100000U
-#define RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM		19
+#define RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM		32
 
 /* RT5033 regulator SAFE LDO output voltage uV */
 #define RT5033_REGULATOR_SAFE_LDO_VOLTAGE		4900000U
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] regulator: rt5033: Use linear ranges to map all voltage selection
  2021-07-06  6:45 [PATCH v2] regulator: rt5033: Use linear ranges to map all voltage selection cy_huang
@ 2021-07-06  6:49 ` Axel Lin
  2021-07-06  8:24 ` Lee Jones
  2021-07-12 10:45 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2021-07-06  6:49 UTC (permalink / raw)
  To: cy_huang; +Cc: Lee Jones, Mark Brown, LKML, Liam Girdwood, ChiYuan Huang

cy_huang <u0084500@gmail.com> 於 2021年7月6日 週二 下午2:45寫道:
>
> From: ChiYuan Huang <cy_huang@richtek.com>
>
> Instead of linear mapping, Use linear range to map all voltage selection.
>
> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
Reviewed-by: Axel Lin <axel.lin@ingics.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] regulator: rt5033: Use linear ranges to map all voltage selection
  2021-07-06  6:45 [PATCH v2] regulator: rt5033: Use linear ranges to map all voltage selection cy_huang
  2021-07-06  6:49 ` Axel Lin
@ 2021-07-06  8:24 ` Lee Jones
  2021-07-12 10:45 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2021-07-06  8:24 UTC (permalink / raw)
  To: cy_huang; +Cc: broonie, linux-kernel, lgirdwood, axel.lin, cy_huang

On Tue, 06 Jul 2021, cy_huang wrote:

> From: ChiYuan Huang <cy_huang@richtek.com>
> 
> Instead of linear mapping, Use linear range to map all voltage selection.
> 
> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
> ---
> Since v2
> - recover the volt number back in rt5033-private.h
> - Add the n_voltages from v1 back.
> 
> Even though commit 6549c46af855 ("regulator: rt5033: Fix n_voltages settings for BUCK and LDO")
> can fix the linear mapping to the correct min/max voltage
> But there're still non-step ranges for the reserved value.
> 
> To use the linear range can fix it for mapping all voltage selection.
> ---
>  drivers/regulator/rt5033-regulator.c | 21 +++++++++++++++------

>  include/linux/mfd/rt5033-private.h   |  4 ++--

Acked-by: Lee Jones <lee.jones@linaro.org>

>  2 files changed, 17 insertions(+), 8 deletions(-)

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] regulator: rt5033: Use linear ranges to map all voltage selection
  2021-07-06  6:45 [PATCH v2] regulator: rt5033: Use linear ranges to map all voltage selection cy_huang
  2021-07-06  6:49 ` Axel Lin
  2021-07-06  8:24 ` Lee Jones
@ 2021-07-12 10:45 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2021-07-12 10:45 UTC (permalink / raw)
  To: lee.jones, cy_huang
  Cc: Mark Brown, linux-kernel, cy_huang, axel.lin, lgirdwood

On Tue, 6 Jul 2021 14:45:39 +0800, cy_huang wrote:
> Instead of linear mapping, Use linear range to map all voltage selection.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: rt5033: Use linear ranges to map all voltage selection
      commit: 6eb891cf73bd2ecc877e9916951a19f3e4f3c493

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-12 10:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06  6:45 [PATCH v2] regulator: rt5033: Use linear ranges to map all voltage selection cy_huang
2021-07-06  6:49 ` Axel Lin
2021-07-06  8:24 ` Lee Jones
2021-07-12 10:45 ` Mark Brown

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).