TypeC Connector Class driver improvements
v2 cover TypeC Connector Class driver improvements
Changes in v2:
* Patch 1: "platform/chrome: cros_ec_typec: Send enum values to
usb_role_switch_set_role()"
* Update the commit message to change 'USB_ROLE_HOST in case of UFP.' to 'USB_ROLE_HOST in case of DFP.'
* Patch 2: "platform/chrome: cros_ec_typec: Avoid setting usb role twice during disconnect"
* New patch added.
Azhar Shaikh (2):
platform/chrome: cros_ec_typec: Send enum values to
usb_role_switch_set_role()
platform/chrome: cros_ec_typec: Avoid setting usb role twice during
disconnect
drivers/platform/chrome/cros_ec_typec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/2 platform/chrome: cros_ec_typec: Send enum values to usb_role_switch_set_role()
usb_role_switch_set_role() has the second argument as enum for usb_role. Currently depending upon the data role i.e. UFP(0) or DFP(1) is sent. This eventually translates to USB_ROLE_NONE in case of UFP and USB_ROLE_DEVICE in case of DFP. Correct this by sending correct enum values as USB_ROLE_DEVICE in case of UFP and USB_ROLE_HOST in case of DFP.
--- drivers/platform/chrome/cros_ec_typec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_ec_typec.c +2 -1
@@ -590,7 +590,8 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)dev_warn (typec->dev,"Configure muxes failed, err = %d\n" , ret);return usb_role_switch_set_role (typec->ports[port_num]->role_sw, - !!(resp.role &PD_CTRL_RESP_ROLE_DATA )); + resp.role &PD_CTRL_RESP_ROLE_DATA + ?USB_ROLE_HOST :USB_ROLE_DEVICE ); }static int cros_typec_get_cmd_version (struct cros_typec_data *typec)
Signature · 1 line
2.17.1
Re: [PATCH v2 1/2] platform/chrome: cros_ec_typec: Send enum values to usb_role_switch_set_role()
Quoted 7 lines · Azhar Shaikh
usb_role_switch_set_role()has the second argument as enum forusb_role. Currently depending upon the data role i.e. UFP(0) or DFP(1) is sent. This eventually translates toUSB_ROLE_NONEin case of UFP andUSB_ROLE_DEVICEin case of DFP. Correct this by sending correct enum values asUSB_ROLE_DEVICEin case of UFP andUSB_ROLE_HOSTin case of DFP.
Quoted 5 lines
Fixes 7e7def15fa4b ("platform/chrome: cros_ec_typec: Add USB mux control")Signed-off-by Azhar Shaikh <[email protected]>Cc Prashant Malani <[email protected]>Reviewed-by Prashant Malani <[email protected]>
Quoted 20 lines
--- drivers/platform/chrome/cros_ec_typec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/platform/chrome/cros_ec_typec.c +2
-1@@ -590,7 +590,8 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)dev_warn (typec->dev,"Configure muxes failed, err = %d\n" , ret);return usb_role_switch_set_role (typec->ports[port_num]->role_sw, - !!(resp.role &PD_CTRL_RESP_ROLE_DATA )); + resp.role &PD_CTRL_RESP_ROLE_DATA + ?USB_ROLE_HOST :USB_ROLE_DEVICE ); }static int cros_typec_get_cmd_version (struct cros_typec_data *typec)Signature · 1 line
2.17.1
Signature · 1 line
heikki
PATCH 1/1 platform/chrome: cros_ec_typec: Avoid setting usb role twice during disconnect
In reply to Azhar ShaikhOn disconnect port partner is removed and usb role is set to NONE. But then in cros_typec_port_update() the role is set again. Avoid this by moving usb_role_switch_set_role() to cros_typec_configure_mux().
--- drivers/platform/chrome/cros_ec_typec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +7 -3
@@ -515,6 +515,12 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,if (ret)return ret; + ret =usb_role_switch_set_role (typec->ports[port_num]->role_sw, + pd_ctrl->role &PD_CTRL_RESP_ROLE_DATA + ?USB_ROLE_HOST :USB_ROLE_DEVICE ); +if (ret) +return ret; +if (mux_flags &USB_PD_MUX_TBT_COMPAT_ENABLED ) { ret =cros_typec_enable_tbt (typec, port_num, pd_ctrl); }else if (mux_flags &USB_PD_MUX_DP_ENABLED ) {
@@ -589,9 +595,7 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)if (ret)dev_warn (typec->dev,"Configure muxes failed, err = %d\n" , ret); -return usb_role_switch_set_role (typec->ports[port_num]->role_sw, - resp.role &PD_CTRL_RESP_ROLE_DATA - ?USB_ROLE_HOST :USB_ROLE_DEVICE ); +return ret; }static int cros_typec_get_cmd_version (struct cros_typec_data *typec)
Signature · 1 line
2.17.1
Re: [PATCH] platform/chrome: cros_ec_typec: Avoid setting usb role twice during disconnect
Hi,
I guess this is was supposed to be PATCH v2 2/2, right?
Quoted 7 lines · Azhar Shaikh
On disconnect port partner is removed and usb role is set to NONE. But then in
cros_typec_port_update()the role is set again. Avoid this by movingusb_role_switch_set_role()tocros_typec_configure_mux().Signed-off-by Azhar Shaikh <[email protected]>Suggested-by Prashant Malani <[email protected]>
Quoted 34 lines
--- drivers/platform/chrome/cros_ec_typec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/platform/chrome/cros_ec_typec.c +7
-3@@ -515,6 +515,12 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,if (ret)return ret; + ret =usb_role_switch_set_role (typec->ports[port_num]->role_sw, + pd_ctrl->role &PD_CTRL_RESP_ROLE_DATA + ?USB_ROLE_HOST :USB_ROLE_DEVICE ); +if (ret) +return ret; +if (mux_flags &USB_PD_MUX_TBT_COMPAT_ENABLED ) { ret =cros_typec_enable_tbt (typec, port_num, pd_ctrl); }else if (mux_flags &USB_PD_MUX_DP_ENABLED ) {@@ -589,9 +595,7 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)if (ret)dev_warn (typec->dev,"Configure muxes failed, err = %d\n" , ret); -return usb_role_switch_set_role (typec->ports[port_num]->role_sw, - resp.role &PD_CTRL_RESP_ROLE_DATA - ?USB_ROLE_HOST :USB_ROLE_DEVICE ); +return ret; }static int cros_typec_get_cmd_version (struct cros_typec_data *typec)Signature · 1 line
2.17.1
thanks,
Signature · 1 line
heikki
RE: [PATCH] platform/chrome: cros_ec_typec: Avoid setting usb role twice during disconnect
Hi,
Quoted 12 lines
-----Original Message-----
From: Heikki Krogerus <[email protected]>
Sent: Friday, July 31, 2020 6:37 AM
To: Shaikh, Azhar <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Patel, Utkarsh H <[email protected]>; Bowman, Casey G <[email protected]>; Mani, Rajmohan <[email protected]>
Subject: Re: [PATCH] platform/chrome:cros_ec_typec: Avoid setting usb role twice during disconnect
Quoted 4 lines
Hi,
I guess this is was supposed to be PATCH v2 2/2, right?
That is correct.
Quoted 57 lines · Azhar Shaikh
Quoted 7 lines
On disconnect port partner is removed and usb role is set to NONE. But then in
cros_typec_port_update()the role is set again. Avoid this by movingusb_role_switch_set_role()tocros_typec_configure_mux().Signed-off-by Azhar Shaikh <[email protected]>Suggested-by Prashant Malani <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>drivers/platform/chrome/cros_ec_typec.c static int cros_typec_configure_mux(struct
Quoted 10 lines
--- drivers/platform/chrome/cros_ec_typec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/platform/chrome/cros_ec_typec.c +0
-0@@ -515,6 +515,12 @@ static int cros_typec_configure_mux(struct
cros_typec_data*typec, intport_num,drivers/platform/chrome/cros_ec_typec.c static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
Quoted 5 lines
drivers/platform/chrome/cros_ec_typec.c +2
-0if (ret)return ret; + ret = usb_role_switch_set_role(typec->ports[port_num]->role_sw, + pd_ctrl->role &
PD_CTRL_RESP_ROLE_DATAdrivers/platform/chrome/cros_ec_typec.c static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
Quoted 7 lines
drivers/platform/chrome/cros_ec_typec.c +4
-0+ ? USB_ROLE_HOST : USB_ROLE_DEVICE); +if (ret) +return ret; +if (mux_flags &USB_PD_MUX_TBT_COMPAT_ENABLED ) { ret =cros_typec_enable_tbt (typec, port_num, pd_ctrl); } else if (mux_flags & USB_PD_MUX_DP_ENABLED) { @@ -589,9+595,7 @@
Quoted 1 line
static int cros_typec_port_update(struct
cros_typec_data*typec, int
port_num)drivers/platform/chrome/cros_ec_typec.c
Quoted 2 lines
drivers/platform/chrome/cros_ec_typec.c +0
-0if (ret) dev_warn(typec->dev, "Configure muxes failed, err = %d\n",ret);
Quoted 11 lines
drivers/platform/chrome/cros_ec_typec.c +0
-1- return usb_role_switch_set_role(typec->ports[port_num]-
role_sw,drivers/platform/chrome/cros_ec_typec.c +1
-3- resp.role &PD_CTRL_RESP_ROLE_DATA - ? USB_ROLE_HOST : USB_ROLE_DEVICE); +return ret; }static int cros_typec_get_cmd_version (struct cros_typec_data *typec) --2.17.1
thanks,
--
heikki