TypeC Connector Class driver improvements
v5 cover TypeC Connector Class driver improvements
Changes in v5:
* Patch 1: "platform/chrome: cros_ec_typec: Send enum values to
usb_role_switch_set_role()"
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
* Patch 2: "platform/chrome: cros_ec_typec: Avoid setting usb role twice during disconnect"
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
- Added Reviewed-by from v4
* Patch 3: "platform/chrome: cros_ec_typec: Re-order connector configuration steps"
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
- Added Reviewed-by from v4
Changes in v4:
* Patch 1: "platform/chrome: cros_ec_typec: Send enum values to
usb_role_switch_set_role()"
- Remove extra line between Fixes and Signed-off tag.
- Added Reviewed-by and Cc tags from v1 and v2.
* Patch 2: "platform/chrome: cros_ec_typec: Avoid setting usb role twice during disconnect"
- Added Suggested-by from v2.
* Patch 3: "platform/chrome: cros_ec_typec: Re-order connector configuration steps"
- No change
Changes in v3:
* Patch 1: "platform/chrome: cros_ec_typec: Send enum values to
usb_role_switch_set_role()"
- No change
* Patch 2: "platform/chrome: cros_ec_typec: Avoid setting usb role twice during disconnect"
- Move the location of calling usb_role_switch_set_role() to end of function in cros_typec_configure_mux() to avoid any change in code flow.
* Patch 3: "platform/chrome: cros_ec_typec: Re-order connector configuration steps"
- New patch added
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 (3):
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
platform/chrome: cros_ec_typec: Re-order connector configuration steps
drivers/platform/chrome/cros_ec_typec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
PATCH v5 1/3 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.
---
Changes in v5:
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
Changes in v4:
- Remove extra line between Fixes and Signed-off tag.
- Added Reviewed-by and Cc tags from v1 and v2.
Changes in v3:
- No changes
Changes in v2:
- Update the commit message to change 'USB_ROLE_HOST in case of UFP.' to '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
@@ -622,7 +622,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
PATCH v5 2/3 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().
---
Changes in v5:
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
- Added Reviewed-by from v4
Changes in v4:
- Added Suggested-by from v2.
Changes in v3:
- Move the location of calling usb_role_switch_set_role() to end of function in cros_typec_configure_mux() to avoid any change in code flow.
Changes in v2:
- New patch added
drivers/platform/chrome/cros_ec_typec.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +7 -4
@@ -564,7 +564,12 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, ret = -ENOTSUPP ; } -return ret; +if (ret) +return ret; + +return 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 ); }static int cros_typec_port_update (struct cros_typec_data *typec,int port_num)
@@ -621,9 +626,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
PATCH v5 3/3 platform/chrome: cros_ec_typec: Re-order connector configuration steps
In reply to Azhar ShaikhAs per USB Type-C Spec R2.0 section 4.5.1.2 (Connecting Sources and Sinks) and section 4.5.2.2 (Connection State Machine Requirements), the typical flow for configuring a device connected to a typeC port is as below:
1. Source/sink detection
2. Orientation
3. Data role
4. VCONN
5. VBUS (USB Type-C currents)
6. The connector is now configured. We can start the PD communication that should lead into configuration of the mux if we enter a mode.
But in existing code data role was set after the connector and mux are already configured. So fix this by following the spec to set the data role before the connector and mux are configured.
---
Changes in v5:
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
- Added Reviewed-by from v4
Changes in v4:
- No change
Changes in v3:
- New patch added
drivers/platform/chrome/cros_ec_typec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +7 -6
@@ -545,6 +545,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_USB4_ENABLED ) { ret =cros_typec_enable_usb4 (typec, port_num, pd_ctrl); }else if (mux_flags &USB_PD_MUX_TBT_COMPAT_ENABLED ) {
@@ -564,12 +570,7 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, ret = -ENOTSUPP ; } -if (ret) -return ret; - -return 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 ); +return ret; }static int cros_typec_port_update (struct cros_typec_data *typec,int port_num)
Signature · 1 line
2.17.1
Hi Azhar,
Quoted 62 lines · Azhar Shaikh
Changes in v5:
* Patch 1: "platform/chrome:
cros_ec_typec: Send enum values tousb_role_switch_set_role()"- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
* Patch 2: "platform/chrome:
cros_ec_typec: Avoid setting usb role twice during disconnect"
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
- Added Reviewed-by from v4* Patch 3: "platform/chrome:
cros_ec_typec: Re-order connector configuration steps"
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
- Added Reviewed-by from v4Changes in v4:
* Patch 1: "platform/chrome:cros_ec_typec: Send enum values tousb_role_switch_set_role()"- Remove extra line between Fixes and Signed-off tag.
- Added Reviewed-by and Cc tags from v1 and v2.* Patch 2: "platform/chrome:
cros_ec_typec: Avoid setting usb role twice during disconnect"
- Added Suggested-by from v2.* Patch 3: "platform/chrome:
cros_ec_typec: Re-order connector configuration steps"
- No changeChanges in v3:
* Patch 1: "platform/chrome:cros_ec_typec: Send enum values tousb_role_switch_set_role()"- No change
* Patch 2: "platform/chrome:
cros_ec_typec: Avoid setting usb role twice during disconnect"
- Move the location of callingusb_role_switch_set_role()to end of function incros_typec_configure_mux()to avoid any change in code flow.* Patch 3: "platform/chrome:
cros_ec_typec: Re-order connector configuration steps"
- New patch addedChanges in v2:
* Patch 1: "platform/chrome:cros_ec_typec: Send enum values tousb_role_switch_set_role()"- Update the commit message to change '
USB_ROLE_HOSTin case of UFP.' to 'USB_ROLE_HOSTin case of DFP.'* Patch 2: "platform/chrome:
cros_ec_typec: Avoid setting usb role twice during disconnect"
- New patch added.Azhar Shaikh (3):
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
platform/chrome:cros_ec_typec: Re-order connector configuration steps
Quoted 3 lines
drivers/platform/chrome/cros_ec_typec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
The three patches of this series have been queued for 5.10.
Thanks,
Enric
Thank you Enric!
Quoted 85 lines
-----Original Message-----
From: Enric Balletbo i Serra <[email protected]>
Sent: Tuesday, September 1, 2020 2:07 AM
To: Shaikh, Azhar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Mani, Rajmohan <[email protected]>; Patel, Utkarsh H <[email protected]>; Bowman, Casey G <[email protected]>
Subject: Re: [PATCH v5 0/3] TypeC Connector Class driver improvementsHi Azhar,
Quoted 62 lines · Azhar Shaikh
Changes in v5:
* Patch 1: "platform/chrome:
cros_ec_typec: Send enum values tousb_role_switch_set_role()"- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
* Patch 2: "platform/chrome:
cros_ec_typec: Avoid setting usb role twice during disconnect"
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
- Added Reviewed-by from v4* Patch 3: "platform/chrome:
cros_ec_typec: Re-order connector configuration steps"
- Rebased on top of https://lkml.org/lkml/2020/7/10/1063
- Added Reviewed-by from v4Changes in v4:
* Patch 1: "platform/chrome:cros_ec_typec: Send enum values tousb_role_switch_set_role()"- Remove extra line between Fixes and Signed-off tag.
- Added Reviewed-by and Cc tags from v1 and v2.* Patch 2: "platform/chrome:
cros_ec_typec: Avoid setting usb role twice during disconnect"
- Added Suggested-by from v2.* Patch 3: "platform/chrome:
cros_ec_typec: Re-order connector configuration steps"
- No changeChanges in v3:
* Patch 1: "platform/chrome:cros_ec_typec: Send enum values tousb_role_switch_set_role()"- No change
* Patch 2: "platform/chrome:
cros_ec_typec: Avoid setting usb role twice during disconnect"
- Move the location of callingusb_role_switch_set_role()to end of function incros_typec_configure_mux()to avoid any change in code flow.* Patch 3: "platform/chrome:
cros_ec_typec: Re-order connector configuration steps"
- New patch addedChanges in v2:
* Patch 1: "platform/chrome:cros_ec_typec: Send enum values tousb_role_switch_set_role()"- Update the commit message to change '
USB_ROLE_HOSTin case of UFP.' to 'USB_ROLE_HOSTin case of DFP.'* Patch 2: "platform/chrome:
cros_ec_typec: Avoid setting usb role twice during disconnect"
- New patch added.Azhar Shaikh (3):
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
platform/chrome:cros_ec_typec: Re-order connector configuration stepsQuoted 3 lines
drivers/platform/chrome/cros_ec_typec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)The three patches of this series have been queued for 5.10.
Thanks,
Enric