Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
From: Igor Opaniuk <igor.opaniuk@gmail.com>
To: linux-usb@vger.kernel.org
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>,
	Philippe Schenker <philippe.schenker@toradex.com>,
	Stefan Agner <stefan.agner@toradex.com>,
	Max Krummenacher <max.krummenacher@toradex.com>,
	Oleksandr Suvorov <oleksandr.suvorov@toradex.com>,
	Igor Opaniuk <igor.opaniuk@toradex.com>, Li Jun <jun.li@nxp.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Peter Chen <Peter.Chen@nxp.com>,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH v1 2/3] usb: chipidea: set mode for usb phy driver
Date: Mon,  7 Oct 2019 15:46:06 +0300
Message-ID: <20191007124607.20618-2-igor.opaniuk@gmail.com> (raw)
In-Reply-To: <20191007124607.20618-1-igor.opaniuk@gmail.com>

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

After enters one specific role, notify usb phy driver.

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

 drivers/usb/chipidea/ci.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 6911aef500e9..a11d23910b12 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -275,9 +275,21 @@ static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role)
 		return -ENXIO;
 
 	ret = ci->roles[role]->start(ci);
-	if (!ret)
-		ci->role = role;
-	return ret;
+	if (ret)
+		return ret;
+
+	ci->role = role;
+
+	if (ci->usb_phy) {
+		if (role == CI_ROLE_HOST)
+			usb_phy_set_mode(ci->usb_phy,
+					USB_MODE_HOST);
+		else
+			usb_phy_set_mode(ci->usb_phy,
+					USB_MODE_DEVICE);
+	}
+
+	return 0;
 }
 
 static inline void ci_role_stop(struct ci_hdrc *ci)
@@ -290,6 +302,9 @@ static inline void ci_role_stop(struct ci_hdrc *ci)
 	ci->role = CI_ROLE_END;
 
 	ci->roles[role]->stop(ci);
+
+	if (ci->usb_phy)
+		usb_phy_set_mode(ci->usb_phy, USB_MODE_NONE);
 }
 
 static inline enum usb_role ci_role_to_usb_role(struct ci_hdrc *ci)
-- 
2.17.1


  reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07 12:46 [RFC PATCH v1 1/3] usb: phy: add usb mode for usb_phy Igor Opaniuk
2019-10-07 12:46 ` Igor Opaniuk [this message]
2019-10-08  3:23   ` [RFC PATCH v1 2/3] usb: chipidea: set mode for usb phy driver Peter Chen
2019-10-08  9:40     ` Igor Opaniuk
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

Reply instructions:

You may reply publically 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=20191007124607.20618-2-igor.opaniuk@gmail.com \
    --to=igor.opaniuk@gmail.com \
    --cc=Peter.Chen@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=igor.opaniuk@toradex.com \
    --cc=jun.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=marcel.ziswiler@toradex.com \
    --cc=max.krummenacher@toradex.com \
    --cc=oleksandr.suvorov@toradex.com \
    --cc=philippe.schenker@toradex.com \
    --cc=stefan.agner@toradex.com \
    /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

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git