Linux USB
 help / color / mirror / Atom feed
From: Xu Yang <xu.yang_2@nxp.com>
To: linux@roeck-us.net, heikki.krogerus@linux.intel.com
Cc: gregkh@linuxfoundation.org, linux-imx@nxp.com,
	linux-usb@vger.kernel.org, jun.li@nxp.com, xu.yang_2@nxp.com,
	zhipeng.wang_1@nxp.com, faqiang.zhu@nxp.com
Subject: [PATCH] usb: typec: tcpci: allow drp toggling for non-drp port
Date: Thu,  8 Jun 2023 19:28:58 +0800	[thread overview]
Message-ID: <20230608112858.4405-1-xu.yang_2@nxp.com> (raw)

Some single power role Type-C port with dual data role, this kind of
port connects non Type-C port for usb data will need tcpm to work to
get polarity for orientation change and let Type-C port keep at fake
power role to provide another non-default data role, so remove the drp
port condition for now.

Has anyone encountered this use case? How do you handle this limitation
in current tcpm with a better way? Please kindly share your thoughts.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/tcpm/tcpci.c | 3 ---
 drivers/usb/typec/tcpm/tcpm.c  | 6 +++++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index fc708c289a73..88559e749120 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -175,9 +175,6 @@ static int tcpci_start_toggling(struct tcpc_dev *tcpc,
 	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
 	unsigned int reg = TCPC_ROLE_CTRL_DRP;
 
-	if (port_type != TYPEC_PORT_DRP)
-		return -EOPNOTSUPP;
-
 	/* Handle vendor drp toggling */
 	if (tcpci->data->start_drp_toggling) {
 		ret = tcpci->data->start_drp_toggling(tcpci, tcpci->data, cc);
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 3c6b0c8e2d3a..6aa62132e69a 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4274,7 +4274,11 @@ static void run_state_machine(struct tcpm_port *port)
 		ret = tcpm_snk_attach(port);
 		if (ret < 0)
 			tcpm_set_state(port, SNK_UNATTACHED, 0);
-		else
+		else if (port->port_type == TYPEC_PORT_SRC &&
+			 port->typec_caps.data == TYPEC_PORT_DRD) {
+			tcpm_typec_connect(port);
+			tcpm_log(port, "Keep at SNK_ATTACHED for USB data.");
+		} else
 			tcpm_set_state(port, SNK_STARTUP, 0);
 		break;
 	case SNK_STARTUP:
-- 
2.34.1


             reply	other threads:[~2023-06-08 11:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08 11:28 Xu Yang [this message]
2023-06-08 13:23 ` [PATCH] usb: typec: tcpci: allow drp toggling for non-drp port Guenter Roeck
2023-06-09  2:14   ` [EXT] " Xu Yang
2023-06-20  3:10     ` Xu Yang
2023-06-20  8:35       ` Hans de Goede
2023-06-20  9:38         ` Xu Yang
2023-06-20  9:52           ` Hans de Goede
2023-06-20 10:43             ` Xu Yang

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=20230608112858.4405-1-xu.yang_2@nxp.com \
    --to=xu.yang_2@nxp.com \
    --cc=faqiang.zhu@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jun.li@nxp.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=zhipeng.wang_1@nxp.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
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