Linux-mediatek Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] regulator: mt6397: Implement of_map_mode regulator_desc function
@ 2020-06-30  1:10 Anand K Mistry
  2020-06-30 10:38 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Anand K Mistry @ 2020-06-30  1:10 UTC (permalink / raw)
  To: linux-mediatek
  Cc: drinkcat, Anand K Mistry, Liam Girdwood, linux-kernel, broonie,
	linux-arm-kernel, Matthias Brugger, hsin-hsiung.wang

Without a of_map_mode implementation, the regulator-allowed-modes
devicetree field is skipped, and attempting to change the regulator mode
results in an error:
[    1.439165] vpca15: mode operation not allowed

Signed-off-by: Anand K Mistry <amistry@google.com>

---

 drivers/regulator/mt6397-regulator.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/regulator/mt6397-regulator.c b/drivers/regulator/mt6397-regulator.c
index 269c2a6028e8..5c60b52addf1 100644
--- a/drivers/regulator/mt6397-regulator.c
+++ b/drivers/regulator/mt6397-regulator.c
@@ -55,6 +55,7 @@ struct mt6397_regulator_info {
 		.vsel_mask = vosel_mask,				\
 		.enable_reg = enreg,					\
 		.enable_mask = BIT(0),					\
+		.of_map_mode = mt6397_map_mode,				\
 	},								\
 	.qi = BIT(13),							\
 	.vselon_reg = voselon,						\
@@ -146,6 +147,12 @@ static const unsigned int ldo_volt_table7[] = {
 	1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000,
 };
 
+static unsigned int mt6397_map_mode(unsigned int mode)
+{
+	return mode == MT6397_BUCK_MODE_AUTO ?
+		REGULATOR_MODE_NORMAL : REGULATOR_MODE_FAST;
+}
+
 static int mt6397_regulator_set_mode(struct regulator_dev *rdev,
 				     unsigned int mode)
 {
-- 
2.27.0.212.ge8ba1cc988-goog


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH] regulator: mt6397: Implement of_map_mode regulator_desc function
  2020-06-30  1:10 [PATCH] regulator: mt6397: Implement of_map_mode regulator_desc function Anand K Mistry
@ 2020-06-30 10:38 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-06-30 10:38 UTC (permalink / raw)
  To: Anand K Mistry
  Cc: drinkcat, Liam Girdwood, linux-kernel, linux-mediatek,
	linux-arm-kernel, Matthias Brugger, hsin-hsiung.wang

[-- Attachment #1.1: Type: text/plain, Size: 702 bytes --]

On Tue, Jun 30, 2020 at 11:10:51AM +1000, Anand K Mistry wrote:
> Without a of_map_mode implementation, the regulator-allowed-modes
> devicetree field is skipped, and attempting to change the regulator mode
> results in an error:
> [    1.439165] vpca15: mode operation not allowed

The modes aren't documented in the binding document, any new device tree
property needs to be added to the binding document.

> +static unsigned int mt6397_map_mode(unsigned int mode)
> +{
> +	return mode == MT6397_BUCK_MODE_AUTO ?
> +		REGULATOR_MODE_NORMAL : REGULATOR_MODE_FAST;
> +}
> +

Please write normal conditional statements to improve legibility, the
ternery operator has uses but they're pretty specialist.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30  1:10 [PATCH] regulator: mt6397: Implement of_map_mode regulator_desc function Anand K Mistry
2020-06-30 10:38 ` Mark Brown

Linux-mediatek Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mediatek/0 linux-mediatek/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mediatek linux-mediatek/ https://lore.kernel.org/linux-mediatek \
		linux-mediatek@lists.infradead.org
	public-inbox-index linux-mediatek

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mediatek


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git