All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen-Yu Tsai <wens@kernel.org>
To: Vinod Koul <vkoul@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Chen-Yu Tsai <wens@kernel.org>,
	Jernej Skrabec <jernej@kernel.org>,
	Samuel Holland <samuel@sholland.org>
Cc: linux-phy@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, "Ondřej Jirman" <megi@xff.cz>,
	"Andre Przywara" <andre.przywara@arm.com>
Subject: [PATCH] phy: sun4i-usb: Avoid polling just for ID pin without OTG mode
Date: Sun,  6 Dec 2026 12:31:28 +0800	[thread overview]
Message-ID: <20261206043129.1383610-1-wens@kernel.org> (raw)

On some devices only the ID pin is hooked up, and there is no VBUS
sensing or control, with VBUS directly tied to system 5V. On these
devices we typically just force the OTG controller to host mode only.

There is no point in polling just the ID pin if the result is never
going to be used. So skip polling if the mode is not OTG and the ID pin
is the only thing that needs to be polled.

Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
---
 drivers/phy/allwinner/phy-sun4i-usb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index f26eed0db17e..66454653bfc4 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -441,8 +441,11 @@ static bool sun4i_usb_phy0_have_vbus_det(struct sun4i_usb_phy_data *data)
 
 static bool sun4i_usb_phy0_poll(struct sun4i_usb_phy_data *data)
 {
-	if ((data->id_det_gpio && data->id_det_irq <= 0) ||
-	    (data->vbus_det_gpio && data->vbus_det_irq <= 0))
+	if (data->dr_mode == USB_DR_MODE_OTG &&
+	    data->id_det_gpio && data->id_det_irq <= 0)
+		return true;
+
+	if (data->vbus_det_gpio && data->vbus_det_irq <= 0)
 		return true;
 
 	/*
-- 
2.53.0


WARNING: multiple messages have this Message-ID (diff)
From: Chen-Yu Tsai <wens@kernel.org>
To: Vinod Koul <vkoul@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Chen-Yu Tsai <wens@kernel.org>,
	Jernej Skrabec <jernej@kernel.org>,
	Samuel Holland <samuel@sholland.org>
Cc: linux-phy@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, "Ondřej Jirman" <megi@xff.cz>,
	"Andre Przywara" <andre.przywara@arm.com>
Subject: [PATCH] phy: sun4i-usb: Avoid polling just for ID pin without OTG mode
Date: Sun,  6 Dec 2026 12:31:28 +0800	[thread overview]
Message-ID: <20261206043129.1383610-1-wens@kernel.org> (raw)

On some devices only the ID pin is hooked up, and there is no VBUS
sensing or control, with VBUS directly tied to system 5V. On these
devices we typically just force the OTG controller to host mode only.

There is no point in polling just the ID pin if the result is never
going to be used. So skip polling if the mode is not OTG and the ID pin
is the only thing that needs to be polled.

Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
---
 drivers/phy/allwinner/phy-sun4i-usb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index f26eed0db17e..66454653bfc4 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -441,8 +441,11 @@ static bool sun4i_usb_phy0_have_vbus_det(struct sun4i_usb_phy_data *data)
 
 static bool sun4i_usb_phy0_poll(struct sun4i_usb_phy_data *data)
 {
-	if ((data->id_det_gpio && data->id_det_irq <= 0) ||
-	    (data->vbus_det_gpio && data->vbus_det_irq <= 0))
+	if (data->dr_mode == USB_DR_MODE_OTG &&
+	    data->id_det_gpio && data->id_det_irq <= 0)
+		return true;
+
+	if (data->vbus_det_gpio && data->vbus_det_irq <= 0)
 		return true;
 
 	/*
-- 
2.53.0


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

             reply	other threads:[~2026-12-06  4:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  4:31 Chen-Yu Tsai [this message]
2026-12-06  4:31 ` [PATCH] phy: sun4i-usb: Avoid polling just for ID pin without OTG mode Chen-Yu Tsai

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=20261206043129.1383610-1-wens@kernel.org \
    --to=wens@kernel.org \
    --cc=andre.przywara@arm.com \
    --cc=jernej@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mani@kernel.org \
    --cc=megi@xff.cz \
    --cc=neil.armstrong@linaro.org \
    --cc=samuel@sholland.org \
    --cc=vkoul@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.