From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Jan Remmet <j.remmet@phytec.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
upstream@lists.phytec.de
Subject: Re: [PATCH] usb: typec: hd3ss3220: Enable VBUS based on role state
Date: Mon, 19 Jan 2026 15:19:38 +0200 [thread overview]
Message-ID: <aW4vauth0USYYy5x@kuha> (raw)
In-Reply-To: <20260115-wip-jremmet-hd3ss3220_vbus-v1-1-b7d9adfbe346@phytec.de>
Thu, Jan 15, 2026 at 02:11:21PM +0100, Jan Remmet kirjoitti:
> 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>
> ---
> drivers/usb/typec/hd3ss3220.c | 27 ++++++++++++++++++---------
> 1 file changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
> index 3876f4faead679e6c04062ab2bcf2ae928913a0a..a7c54aa8635f70d6979d98c95f80d4dac277fef2 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;
> }
>
> ---
> base-commit: 944aacb68baf7624ab8d277d0ebf07f025ca137c
> change-id: 20260115-wip-jremmet-hd3ss3220_vbus-732f74894acc
>
> Best regards,
> --
> Jan Remmet <j.remmet@phytec.de>
--
heikki
prev parent reply other threads:[~2026-01-19 13:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 13:11 [PATCH] usb: typec: hd3ss3220: Enable VBUS based on role state Jan Remmet
2026-01-19 13:19 ` Heikki Krogerus [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aW4vauth0USYYy5x@kuha \
--to=heikki.krogerus@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=j.remmet@phytec.de \
--cc=krishna.kurapati@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=upstream@lists.phytec.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox