diff options
| author | Jan Remmet <j.remmet@phytec.de> | 2026-01-15 14:11:21 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-01-23 17:16:18 +0100 |
| commit | 27fbc19e52b9a76b79a1de691b0b978e335c4c35 (patch) | |
| tree | ed4c56e3ef6a375d71dbee69cddcd724034b7aa2 /drivers/usb | |
| parent | 4298475deecbd12f7d5a83b340f59ae644c37a5e (diff) | |
| download | linux-next-27fbc19e52b9a76b79a1de691b0b978e335c4c35.tar.gz linux-next-27fbc19e52b9a76b79a1de691b0b978e335c4c35.zip | |
usb: typec: hd3ss3220: Enable VBUS based on role state
For systems where the ID pin isn't available as gpio use the ATTACHED_STATE
register instead to control vbus.
>From the datasheet:
"This is an additional method to communicate attach other
than the ID pin. These bits can be read by the application to
determine what was attached."
Use this method if id-gpios property is not set, but the connector node
has vbus-supply defined.
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://patch.msgid.link/20260115-wip-jremmet-hd3ss3220_vbus-v1-1-b7d9adfbe346@phytec.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
| -rw-r--r-- | drivers/usb/typec/hd3ss3220.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c index 3876f4faead6..a7c54aa8635f 100644 --- a/drivers/usb/typec/hd3ss3220.c +++ b/drivers/usb/typec/hd3ss3220.c @@ -204,6 +204,20 @@ static const struct typec_operations hd3ss3220_ops = { .port_type_set = hd3ss3220_port_type_set, }; +static void hd3ss3220_regulator_control(struct hd3ss3220 *hd3ss3220, bool on) +{ + int ret; + + if (on) + ret = regulator_enable(hd3ss3220->vbus); + else + ret = regulator_disable(hd3ss3220->vbus); + + if (ret) + dev_err(hd3ss3220->dev, + "vbus regulator %s failed: %d\n", on ? "disable" : "enable", ret); +} + static void hd3ss3220_set_role(struct hd3ss3220 *hd3ss3220) { enum usb_role role_state = hd3ss3220_get_attached_state(hd3ss3220); @@ -221,6 +235,9 @@ static void hd3ss3220_set_role(struct hd3ss3220 *hd3ss3220) break; } + if (hd3ss3220->vbus && !hd3ss3220->id_gpiod) + hd3ss3220_regulator_control(hd3ss3220, role_state == USB_ROLE_HOST); + hd3ss3220->role_state = role_state; } @@ -330,18 +347,10 @@ static const struct regmap_config config = { static irqreturn_t hd3ss3220_id_isr(int irq, void *dev_id) { struct hd3ss3220 *hd3ss3220 = dev_id; - int ret; int id; id = gpiod_get_value_cansleep(hd3ss3220->id_gpiod); - if (!id) - ret = regulator_enable(hd3ss3220->vbus); - else - ret = regulator_disable(hd3ss3220->vbus); - - if (ret) - dev_err(hd3ss3220->dev, - "vbus regulator %s failed: %d\n", id ? "disable" : "enable", ret); + hd3ss3220_regulator_control(hd3ss3220, !id); return IRQ_HANDLED; } |
