Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1 3/3] usb: phy: mxs: optimize disconnect line condition
       [not found] <20191007124607.20618-1-igor.opaniuk@gmail.com>
@ 2019-10-07 12:46 ` Igor Opaniuk
  2019-10-07 12:52   ` Fabio Estevam
  0 siblings, 1 reply; 3+ messages in thread
From: Igor Opaniuk @ 2019-10-07 12:46 UTC (permalink / raw)
  To: linux-usb
  Cc: Felipe Balbi, Igor Opaniuk, Pengutronix Kernel Team, Stefan Agner,
	Marcel Ziswiler, Greg Kroah-Hartman, Sascha Hauer, linux-kernel,
	Oleksandr Suvorov, Philippe Schenker, NXP Linux Team,
	Max Krummenacher, Shawn Guo, Fabio Estevam, linux-arm-kernel,
	Li Jun

From: Igor Opaniuk <igor.opaniuk@toradex.com>

We only have below cases to disconnect line when suspend:
1. Device mode without connection to any host/charger(no vbus).
2. Device mode connect to a charger, usb suspend when
system is entering suspend.

This patch can fix cases, when usb phy wrongly does disconnect
line in case usb host enters suspend but vbus is off.

Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
---

 drivers/usb/phy/phy-mxs-usb.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 70b8c8248caf..d996666e09e6 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -204,6 +204,7 @@ struct mxs_phy {
 	int port_id;
 	u32 tx_reg_set;
 	u32 tx_reg_mask;
+	enum usb_current_mode mode;
 };
 
 static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
@@ -386,17 +387,6 @@ static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect)
 		usleep_range(500, 1000);
 }
 
-static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy)
-{
-	void __iomem *base = mxs_phy->phy.io_priv;
-	u32 phyctrl = readl(base + HW_USBPHY_CTRL);
-
-	if (IS_ENABLED(CONFIG_USB_OTG) &&
-			!(phyctrl & BM_USBPHY_CTRL_OTG_ID_VALUE))
-		return true;
-
-	return false;
-}
 
 static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
 {
@@ -412,13 +402,26 @@ static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
 
 	vbus_is_on = mxs_phy_get_vbus_status(mxs_phy);
 
-	if (on && !vbus_is_on && !mxs_phy_is_otg_host(mxs_phy))
+	if (on && ((!vbus_is_on && mxs_phy->mode != USB_MODE_HOST)))
 		__mxs_phy_disconnect_line(mxs_phy, true);
 	else
 		__mxs_phy_disconnect_line(mxs_phy, false);
 
 }
 
+/*
+ * Set the usb current role for phy.
+ */
+static int mxs_phy_set_mode(struct usb_phy *phy,
+		enum usb_current_mode mode)
+{
+	struct mxs_phy *mxs_phy = to_mxs_phy(phy);
+
+	mxs_phy->mode = mode;
+
+	return 0;
+}
+
 static int mxs_phy_init(struct usb_phy *phy)
 {
 	int ret;
@@ -796,6 +799,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
 	mxs_phy->phy.notify_disconnect	= mxs_phy_on_disconnect;
 	mxs_phy->phy.type		= USB_PHY_TYPE_USB2;
 	mxs_phy->phy.set_wakeup		= mxs_phy_set_wakeup;
+	mxs_phy->phy.set_mode		= mxs_phy_set_mode;
 	mxs_phy->phy.charger_detect	= mxs_phy_charger_detect;
 
 	mxs_phy->clk = clk;
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH v1 3/3] usb: phy: mxs: optimize disconnect line condition
  2019-10-07 12:46 ` [RFC PATCH v1 3/3] usb: phy: mxs: optimize disconnect line condition Igor Opaniuk
@ 2019-10-07 12:52   ` Fabio Estevam
  2019-10-07 13:38     ` Igor Opaniuk
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2019-10-07 12:52 UTC (permalink / raw)
  To: Igor Opaniuk
  Cc: Felipe Balbi, Igor Opaniuk, Pengutronix Kernel Team, Stefan Agner,
	Marcel Ziswiler, Greg Kroah-Hartman, Sascha Hauer, USB list,
	linux-kernel, Oleksandr Suvorov, Philippe Schenker,
	NXP Linux Team, Max Krummenacher, Shawn Guo,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE, Li Jun

Hi Igor,

On Mon, Oct 7, 2019 at 9:47 AM Igor Opaniuk <igor.opaniuk@gmail.com> wrote:
>
> From: Igor Opaniuk <igor.opaniuk@toradex.com>
>
> We only have below cases to disconnect line when suspend:
> 1. Device mode without connection to any host/charger(no vbus).
> 2. Device mode connect to a charger, usb suspend when
> system is entering suspend.
>
> This patch can fix cases, when usb phy wrongly does disconnect
> line in case usb host enters suspend but vbus is off.
>
> Signed-off-by: Li Jun <jun.li@nxp.com>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>

Who is the original author of this patch, is it you or Li Jun?

If it is Li Jun, then his name should appear in the From field.

Also, it seems a Fixes tag is needed here.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH v1 3/3] usb: phy: mxs: optimize disconnect line condition
  2019-10-07 12:52   ` Fabio Estevam
@ 2019-10-07 13:38     ` Igor Opaniuk
  0 siblings, 0 replies; 3+ messages in thread
From: Igor Opaniuk @ 2019-10-07 13:38 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Felipe Balbi, Igor Opaniuk, Pengutronix Kernel Team, Stefan Agner,
	Marcel Ziswiler, Greg Kroah-Hartman, Sascha Hauer, USB list,
	linux-kernel, Oleksandr Suvorov, Philippe Schenker,
	NXP Linux Team, Max Krummenacher, Shawn Guo,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE, Li Jun

HI Fabio,

On Mon, Oct 7, 2019 at 3:51 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> Hi Igor,
>
> On Mon, Oct 7, 2019 at 9:47 AM Igor Opaniuk <igor.opaniuk@gmail.com> wrote:
> >
> > From: Igor Opaniuk <igor.opaniuk@toradex.com>
> >
> > We only have below cases to disconnect line when suspend:
> > 1. Device mode without connection to any host/charger(no vbus).
> > 2. Device mode connect to a charger, usb suspend when
> > system is entering suspend.
> >
> > This patch can fix cases, when usb phy wrongly does disconnect
> > line in case usb host enters suspend but vbus is off.
> >
> > Signed-off-by: Li Jun <jun.li@nxp.com>
> > Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
>
> Who is the original author of this patch, is it you or Li Jun?
>
> If it is Li Jun, then his name should appear in the From field.
right, it's Li Jun, will fix in v1.

>
> Also, it seems a Fixes tag is needed here.
right, will do.

-- 
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk@gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-07 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20191007124607.20618-1-igor.opaniuk@gmail.com>
2019-10-07 12:46 ` [RFC PATCH v1 3/3] usb: phy: mxs: optimize disconnect line condition Igor Opaniuk
2019-10-07 12:52   ` Fabio Estevam
2019-10-07 13:38     ` Igor Opaniuk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox