linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: Fix current limit for QCOM PMIC VBUS
@ 2021-04-23 16:06 Bryan O'Donoghue
  2021-04-23 16:32 ` Mark Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Bryan O'Donoghue @ 2021-04-23 16:06 UTC (permalink / raw)
  To: agross, bjorn.andersson, lgirdwood, broonie
  Cc: wcheng, linux-arm-msm, dmitry.baryshkov, bryan.odonoghue

VBUS current at +5 V on the pm8150b can be.

500 mA
1000 mA
1500 mA
2000 mA
2500 mA
3000 mA

Only 500 mA, 1 A, 1.5 A or 3 A is valid with respect to the standard.
Right now the first stage bootloader sets the value to 2 A. 2 A is just
fine until you connect a chunky enough type-c accessory.

Debugging a separate USB problem I noticed that a larger type-c dongle I
had was ramping VBUS up and then collapsing, never getting to +5 V.
Different dongles would get to +5 V and importantly downstream would
happily power the bigger dongle.

The root cause is failure to set the higher current limit to 3 A instead of
the defaulting 2 A from the bootloader.

Fixes: 4fe66d5a62fb ("regulator: Add support for QCOM PMIC VBUS booster")
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/regulator/qcom_usb_vbus-regulator.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/regulator/qcom_usb_vbus-regulator.c b/drivers/regulator/qcom_usb_vbus-regulator.c
index 457788b505720..2b19e0483fccd 100644
--- a/drivers/regulator/qcom_usb_vbus-regulator.c
+++ b/drivers/regulator/qcom_usb_vbus-regulator.c
@@ -16,6 +16,14 @@
 
 #define CMD_OTG				0x40
 #define OTG_EN				BIT(0)
+#define OTG_CURRENT_LIMIT_CFG		0x52
+#define OTG_CURRENT_LIMIT_500MA		0
+#define OTG_CURRENT_LIMIT_1000MA	BIT(0)
+#define OTG_CURRENT_LIMIT_1500MA	BIT(1)
+#define OTG_CURRENT_LIMIT_2000MA	(BIT(1) | BIT(0))
+#define OTG_CURRENT_LIMIT_2500MA	BIT(2)
+#define OTG_CURRENT_LIMIT_3000MA	(BIT(2) | BIT(0))
+#define OTG_CURRENT_LIMIT_MASK		(BIT(2) | BIT(0))
 #define OTG_CFG				0x53
 #define OTG_EN_SRC_CFG			BIT(1)
 
@@ -76,6 +84,10 @@ static int qcom_usb_vbus_regulator_probe(struct platform_device *pdev)
 	/* Disable HW logic for VBUS enable */
 	regmap_update_bits(regmap, base + OTG_CFG, OTG_EN_SRC_CFG, 0);
 
+	/* Set OTG current limit to 3000mA up from bootloader set 2000mA */
+	regmap_update_bits(regmap, base + OTG_CURRENT_LIMIT_CFG,
+			   OTG_CURRENT_LIMIT_MASK, OTG_CURRENT_LIMIT_3000MA);
+
 	return 0;
 }
 
-- 
2.30.1


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

end of thread, other threads:[~2021-04-26 12:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 16:06 [PATCH] regulator: Fix current limit for QCOM PMIC VBUS Bryan O'Donoghue
2021-04-23 16:32 ` Mark Brown
2021-04-23 20:24   ` Bryan O'Donoghue
2021-04-23 20:38     ` Bryan O'Donoghue
2021-04-26 11:55     ` Mark Brown
2021-04-26 12:03       ` Bryan O'Donoghue
2021-04-26 12:12         ` Mark Brown
2021-04-26 12:50           ` Bryan O'Donoghue

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