78 lines
2.8 KiB
Diff
78 lines
2.8 KiB
Diff
From a6c3f6843636534cb83b3a8b60828d6424780cf2 Mon Sep 17 00:00:00 2001
|
|
From: Ondrej Jirman <megous@megous.com>
|
|
Date: Mon, 26 Apr 2021 01:24:09 +0200
|
|
Subject: [PATCH 353/478] anx7688: Don't reset input current limit to 500mA on
|
|
probe
|
|
|
|
This cancels the result of the current result of BC1.2 detection,
|
|
and doesn't help with anything really.
|
|
|
|
With this patch, if the phone was plugged to a dumb charger when
|
|
off, and then booted, the initial BC1.2 detection result done during the
|
|
charger plugin will be kept.
|
|
|
|
Also fix race between interrupt and "enabling USB BC 1.2 detection\n"
|
|
|
|
Signed-off-by: Ondrej Jirman <megous@megous.com>
|
|
---
|
|
drivers/usb/typec/anx7688.c | 36 ++++++++++++------------------------
|
|
1 file changed, 12 insertions(+), 24 deletions(-)
|
|
|
|
diff --git a/drivers/usb/typec/anx7688.c b/drivers/usb/typec/anx7688.c
|
|
index 5aaea9e257b0..cacf4225dc76 100644
|
|
--- a/drivers/usb/typec/anx7688.c
|
|
+++ b/drivers/usb/typec/anx7688.c
|
|
@@ -2045,6 +2045,18 @@ static int anx7688_i2c_probe(struct i2c_client *client,
|
|
typec_set_pwr_opmode(anx7688->port, TYPEC_PWR_MODE_USB);
|
|
typec_set_vconn_role(anx7688->port, TYPEC_SINK);
|
|
|
|
+ // make sure BC1.2 detection in PMIC is enabled
|
|
+ anx7688->last_bc_result = -1;
|
|
+ psy_val.intval = 1;
|
|
+ dev_dbg(dev, "enabling USB BC 1.2 detection\n");
|
|
+ ret = power_supply_set_property(anx7688->vbus_in_supply,
|
|
+ POWER_SUPPLY_PROP_USB_BC_ENABLED,
|
|
+ &psy_val);
|
|
+ if (ret) {
|
|
+ dev_err(anx7688->dev, "failed to enable BC1.2 detection\n");
|
|
+ goto err_cport;
|
|
+ }
|
|
+
|
|
ret = devm_request_irq(dev, irq_cabledet, anx7688_irq_plug_handler,
|
|
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
|
"anx7688-cabledet", anx7688);
|
|
@@ -2061,30 +2073,6 @@ static int anx7688_i2c_probe(struct i2c_client *client,
|
|
goto err_cport;
|
|
}
|
|
|
|
- // enable BC1.2 detection in PMIC and set current limit to 500mA until
|
|
- // proper limit is established via BC1.2 or USB-PD
|
|
- psy_val.intval = 1;
|
|
- dev_dbg(dev, "enabling USB BC 1.2 detection\n");
|
|
- ret = power_supply_set_property(anx7688->vbus_in_supply,
|
|
- POWER_SUPPLY_PROP_USB_BC_ENABLED,
|
|
- &psy_val);
|
|
- if (ret) {
|
|
- dev_err(anx7688->dev, "failed to disable BC1.2 detection\n");
|
|
- goto err_cport;
|
|
- }
|
|
-
|
|
- psy_val.intval = 500000;
|
|
- dev_dbg(dev, "setting vbus_in current limit to %d mA\n", psy_val.intval);
|
|
- ret = power_supply_set_property(anx7688->vbus_in_supply,
|
|
- POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
|
|
- &psy_val);
|
|
- if (ret) {
|
|
- dev_err(anx7688->dev, "failed to set vbus_in current to %d mA\n",
|
|
- psy_val.intval / 1000);
|
|
- goto err_cport;
|
|
- }
|
|
-
|
|
- anx7688->last_bc_result = -1;
|
|
anx7688->vbus_in_nb.notifier_call = anx7688_vbus_in_notify;
|
|
anx7688->vbus_in_nb.priority = 0;
|
|
ret = power_supply_reg_notifier(&anx7688->vbus_in_nb);
|
|
--
|
|
2.35.3
|
|
|