Skip to contentSkip to conversation

usb: typec: ucsi: set USB data role when partner type is power cable/ufp

PATCH In review Mayank Rana 2 participants 2 messages Mar 16, 2020 – Apr 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: typec: ucsi: set USB data role when partner type is power cable/ufp

Currently UCSI framework doesn't update USB data role when partner type is reported as power cable or power cable with ufp connected. This results into no USB host mode functionality. This is valid usecase where user wants to use legacy type c power cable with type a female connector to attach different USB devices like mouse, thumb drive etc. Hence update USB data role as host when partner type is reported as power cable or power cable with ufp connected.

---
 drivers/usb/typec/ucsi/ucsi.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/typec/ucsi/ucsi.c +6 -0
index d5a6aac..ce62732 100644
@@ -558,6 +558,8 @@ static void ucsi_partner_change(struct ucsi_connector *con)
 
 	switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
 	case UCSI_CONSTAT_PARTNER_TYPE_UFP:
+	case UCSI_CONSTAT_PARTNER_TYPE_CABLE:
+	case UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP:
 		typec_set_data_role(con->port, TYPEC_HOST);
 		break;
 	case UCSI_CONSTAT_PARTNER_TYPE_DFP:
@@ -619,6 +621,8 @@ static void ucsi_handle_connector_change(struct work_struct *work)
 
 		switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
 		case UCSI_CONSTAT_PARTNER_TYPE_UFP:
+		case UCSI_CONSTAT_PARTNER_TYPE_CABLE:
+		case UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP:
 			typec_set_data_role(con->port, TYPEC_HOST);
 			break;
 		case UCSI_CONSTAT_PARTNER_TYPE_DFP:
@@ -919,6 +923,8 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 
 	switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
 	case UCSI_CONSTAT_PARTNER_TYPE_UFP:
+	case UCSI_CONSTAT_PARTNER_TYPE_CABLE:
+	case UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP:
 		typec_set_data_role(con->port, TYPEC_HOST);
 		break;
 	case UCSI_CONSTAT_PARTNER_TYPE_DFP:
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#1 lore raw
Quoted 9 lines · Mayank Rana

Currently UCSI framework doesn't update USB data role when partner type is reported as power cable or power cable with ufp connected. This results into no USB host mode functionality. This is valid usecase where user wants to use legacy type c power cable with type a female connector to attach different USB devices like mouse, thumb drive etc. Hence update USB data role as host when partner type is reported as power cable or power cable with ufp connected.

I've now applied this to my ucsi branch:
https://github.com/krohei/linux/commit/fc5a9939c9b8bded598c39339992be470563604f

I will send it to Greg together with the other changes I have for this driver next week.

Quoted 27 lines
---
 drivers/usb/typec/ucsi/ucsi.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/typec/ucsi/ucsi.c +4 -0
index d5a6aac..ce62732 100644
@@ -558,6 +558,8 @@ static void ucsi_partner_change(struct ucsi_connector *con)
 
 	switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
 	case UCSI_CONSTAT_PARTNER_TYPE_UFP:
+	case UCSI_CONSTAT_PARTNER_TYPE_CABLE:
+	case UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP:
 		typec_set_data_role(con->port, TYPEC_HOST);
 		break;
 	case UCSI_CONSTAT_PARTNER_TYPE_DFP:
@@ -619,6 +621,8 @@ static void ucsi_handle_connector_change(struct work_struct *work)
 
 		switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
 		case UCSI_CONSTAT_PARTNER_TYPE_UFP:
+		case UCSI_CONSTAT_PARTNER_TYPE_CABLE:
+		case UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP:
 			typec_set_data_role(con->port, TYPEC_HOST);
 			break;
 		case UCSI_CONSTAT_PARTNER_TYPE_DFP:

drivers/usb/typec/ucsi/ucsi.c static int ucsi_register_port(struct ucsi *ucsi, int index) · line 930

Quoted 8 lines
drivers/usb/typec/ucsi/ucsi.c +2 -0
@@ -919,6 +923,8 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 
 	switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
 	case UCSI_CONSTAT_PARTNER_TYPE_UFP:
+	case UCSI_CONSTAT_PARTNER_TYPE_CABLE:
+	case UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP:
 		typec_set_data_role(con->port, TYPEC_HOST);
 		break;
 	case UCSI_CONSTAT_PARTNER_TYPE_DFP:

thanks,

Signature · 1 line
heikki