2020-08-20 23:38:54

by Azhar Shaikh

[permalink] [raw]
Subject: [PATCH v4 0/3] TypeC Connector Class driver improvements


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(-)

--
2.17.1


2020-08-20 23:40:35

by Azhar Shaikh

[permalink] [raw]
Subject: [PATCH v4 2/3] platform/chrome: cros_ec_typec: Avoid setting usb role twice during disconnect

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 moving usb_role_switch_set_role() to
cros_typec_configure_mux().

Suggested-by: Prashant Malani <[email protected]>
Signed-off-by: Azhar Shaikh <[email protected]>
---
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(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 06108212ee94..2b43e1176e73 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -533,7 +533,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)
@@ -590,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)
--
2.17.1

2020-08-20 23:40:47

by Azhar Shaikh

[permalink] [raw]
Subject: [PATCH v4 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.

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]>
Reviewed-by: Heikki Krogerus <[email protected]>
---
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(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 3fcd27ec9ad8..06108212ee94 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -591,7 +591,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)
--
2.17.1

2020-08-21 07:16:24

by Enric Balletbo i Serra

[permalink] [raw]
Subject: Re: [PATCH v4 0/3] TypeC Connector Class driver improvements

Hi Azhar,

I got a merge conflict because I applied [1] before these patches, fix the
conflict is trivial but, as I can't test, can you rebase your patches on top of
[1] and test and resend to make sure everything is working?

Thanks,
Enric

[1] https://lkml.org/lkml/2020/7/10/1063


On 21/8/20 1:38, Azhar Shaikh wrote:
> 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(-)
>

2020-08-21 13:37:53

by Azhar Shaikh

[permalink] [raw]
Subject: RE: [PATCH v4 0/3] TypeC Connector Class driver improvements

Hi Enric,

Sure, I will rebase, test and upload a new revision.

Regards,
Azhar Shaikh

> -----Original Message-----
> From: Enric Balletbo i Serra <[email protected]>
> Sent: Friday, August 21, 2020 12:13 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 v4 0/3] TypeC Connector Class driver improvements
>
> Hi Azhar,
>
> I got a merge conflict because I applied [1] before these patches, fix the
> conflict is trivial but, as I can't test, can you rebase your patches on top of [1]
> and test and resend to make sure everything is working?
>
> Thanks,
> Enric
>
> [1] https://lkml.org/lkml/2020/7/10/1063
>
>
> On 21/8/20 1:38, Azhar Shaikh wrote:
> > 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(-)
> >

2020-08-21 13:38:00

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH v4 0/3] TypeC Connector Class driver improvements

On Fri, Aug 21, 2020 at 01:34:46PM +0000, Shaikh, Azhar wrote:
> Hi Enric,
>
> Sure, I will rebase, test and upload a new revision.

I don't think I have anything to add, so FWIW:

Reviewed-by: Heikki Krogerus <[email protected]>

> Regards,
> Azhar Shaikh
>
> > -----Original Message-----
> > From: Enric Balletbo i Serra <[email protected]>
> > Sent: Friday, August 21, 2020 12:13 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 v4 0/3] TypeC Connector Class driver improvements
> >
> > Hi Azhar,
> >
> > I got a merge conflict because I applied [1] before these patches, fix the
> > conflict is trivial but, as I can't test, can you rebase your patches on top of [1]
> > and test and resend to make sure everything is working?
> >
> > Thanks,
> > Enric
> >
> > [1] https://lkml.org/lkml/2020/7/10/1063
> >
> >
> > On 21/8/20 1:38, Azhar Shaikh wrote:
> > > 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(-)
> > >

thanks,

--
heikki