From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Marek Vasut <marex@nabladev.com>,
linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v3 2/2] usb: typec: mux: gpio-sbu: enable when only used for orientation
Date: Mon, 31 Aug 2026 12:11:42 +0200 [thread overview]
Message-ID: <apVTXnBDf20PcLgo@black.igk.intel.com> (raw)
In-Reply-To: <20260826-usb-fusb340-v1-v3-2-11927682504d@foss.st.com>
On Wed, Aug 26, 2026 at 02:16:36PM +0200, Fabrice Gasnier wrote:
> When used as orientation-switch only (no mode-switch, e.g. no altmode),
> the optional enable gpio remains disabled.
> Enable it from the switch_set() routine, in this case, when the
> orientation is set and the enable-gpios property has been provided.
> Move enable GPIO configuration after the swapped configuration has
> been done, to avoid possible glitches in case both signals are changed.
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> Changes in v3
> - Fix missed v2 update on probing mode-switch property.
> Changes in v2
> - fix issues reported by Sashiko: probe mode-switch property before
> registering Type-C switch, to avoid possible race. Configure enable
> GPIO after swapp GPIO has been configured, in case both transition.
> ---
> drivers/usb/typec/mux/gpio-sbu-mux.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/typec/mux/gpio-sbu-mux.c b/drivers/usb/typec/mux/gpio-sbu-mux.c
> index 1834f1a2dd9d..b1aa976aca24 100644
> --- a/drivers/usb/typec/mux/gpio-sbu-mux.c
> +++ b/drivers/usb/typec/mux/gpio-sbu-mux.c
> @@ -17,6 +17,7 @@ struct gpio_sbu_mux {
>
> struct typec_switch_dev *sw;
> struct typec_mux_dev *mux;
> + bool mode_switch;
>
> struct mutex lock; /* protect enabled and swapped */
> bool enabled;
> @@ -40,19 +41,24 @@ static int gpio_sbu_switch_set(struct typec_switch_dev *sw,
> enabled = false;
> break;
> case TYPEC_ORIENTATION_NORMAL:
> + if (!sbu_mux->mode_switch)
> + enabled = true;
> swapped = false;
> break;
> case TYPEC_ORIENTATION_REVERSE:
> + if (!sbu_mux->mode_switch)
> + enabled = true;
> swapped = true;
> break;
> }
>
> - if (enabled != sbu_mux->enabled)
> - gpiod_set_value_cansleep(sbu_mux->enable_gpio, enabled);
> -
> if (swapped != sbu_mux->swapped)
> gpiod_set_value_cansleep(sbu_mux->select_gpio, swapped);
>
> + /* If both enabled and swapped transition, set enable GPIO after to avoid glitches */
> + if (enabled != sbu_mux->enabled)
> + gpiod_set_value_cansleep(sbu_mux->enable_gpio, enabled);
> +
> sbu_mux->enabled = enabled;
> sbu_mux->swapped = swapped;
>
> @@ -120,6 +126,7 @@ static int gpio_sbu_mux_probe(struct platform_device *pdev)
> sw_desc.fwnode = dev_fwnode(dev);
> sw_desc.set = gpio_sbu_switch_set;
>
> + sbu_mux->mode_switch = device_property_read_bool(dev, "mode-switch");
> sbu_mux->sw = typec_switch_register(dev, &sw_desc);
> if (IS_ERR(sbu_mux->sw))
> return dev_err_probe(dev, PTR_ERR(sbu_mux->sw),
>
> --
> 2.43.0
--
heikki
next prev parent reply other threads:[~2026-08-31 10:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 12:16 [PATCH v3 0/2] usb: gpio-sbu-mux: add FUSB340 and enable option for orientation Fabrice Gasnier
2026-08-26 12:16 ` [PATCH v3 1/2] dt-bindings: usb: gpio-sbu-mux: Add compatible for FUSB340 Fabrice Gasnier
2026-09-01 6:31 ` Xu Yang
2026-09-01 8:02 ` Fabrice Gasnier
2026-09-01 10:08 ` Xu Yang
2026-08-26 12:16 ` [PATCH v3 2/2] usb: typec: mux: gpio-sbu: enable when only used for orientation Fabrice Gasnier
2026-08-26 12:30 ` sashiko-bot
2026-08-31 10:11 ` Heikki Krogerus [this message]
2026-09-01 14:02 ` [PATCH v3 0/2] usb: gpio-sbu-mux: add FUSB340 and enable option " Greg Kroah-Hartman
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=apVTXnBDf20PcLgo@black.igk.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fabrice.gasnier@foss.st.com \
--cc=gregkh@linuxfoundation.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-usb@vger.kernel.org \
--cc=marex@nabladev.com \
--cc=robh@kernel.org \
/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