Chrome platform driver development
 help / color / mirror / Atom feed
* [PATCH v1 0/2] usb: typec: ucsi: Recover from CrOS EC sysjump
@ 2025-02-04  2:45 Jameson Thies
  2025-02-04  2:45 ` [PATCH v1 1/2] platform/chrome: add PD_EVENT_INIT bit definition Jameson Thies
  2025-02-04  2:45 ` [PATCH v1 2/2] usb: typec: ucsi: resume work after EC init Jameson Thies
  0 siblings, 2 replies; 8+ messages in thread
From: Jameson Thies @ 2025-02-04  2:45 UTC (permalink / raw)
  To: ukaszb, tzungbi, linux-usb, chrome-platform
  Cc: bleung, heikki.krogerus, gregkh, dmitry.baryshkov, abhishekpandit,
	akuchynski, Jameson Thies

An EC sysjump can break communication with the cros_ec_ucsi driver by
clearing any previously enabled notifications. This updates the
cros_ec_ucsi driver to monitor for PD initialization events from the EC
and re-enable notifications by treating the init event as a system
resume.

Jameson Thies (2):
  platform/chrome: add PD_EVENT_INIT bit definition
  usb: typec: ucsi: resume work after EC init

 drivers/usb/typec/ucsi/cros_ec_ucsi.c          | 17 ++++++++++++-----
 include/linux/platform_data/cros_ec_commands.h |  1 +
 2 files changed, 13 insertions(+), 5 deletions(-)


base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
-- 
2.48.1.362.g079036d154-goog


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v1 1/2] platform/chrome: add PD_EVENT_INIT bit definition
  2025-02-04  2:45 [PATCH v1 0/2] usb: typec: ucsi: Recover from CrOS EC sysjump Jameson Thies
@ 2025-02-04  2:45 ` Jameson Thies
  2025-02-04 14:35   ` Benson Leung
  2025-02-05  4:27   ` Tzung-Bi Shih
  2025-02-04  2:45 ` [PATCH v1 2/2] usb: typec: ucsi: resume work after EC init Jameson Thies
  1 sibling, 2 replies; 8+ messages in thread
From: Jameson Thies @ 2025-02-04  2:45 UTC (permalink / raw)
  To: ukaszb, tzungbi, linux-usb, chrome-platform
  Cc: bleung, heikki.krogerus, gregkh, dmitry.baryshkov, abhishekpandit,
	akuchynski, Jameson Thies

Update cros_ec_commands.h to include a definition for PD_EVENT_INIT.
On platforms supporting UCSI, this host event type is sent when the PPM
initializes.

Signed-off-by: Jameson Thies <jthies@google.com>
---
 include/linux/platform_data/cros_ec_commands.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h
index ecf290a0c98f..1f4e4f2b89bb 100644
--- a/include/linux/platform_data/cros_ec_commands.h
+++ b/include/linux/platform_data/cros_ec_commands.h
@@ -5046,6 +5046,7 @@ struct ec_response_pd_status {
 #define PD_EVENT_DATA_SWAP         BIT(3)
 #define PD_EVENT_TYPEC             BIT(4)
 #define PD_EVENT_PPM               BIT(5)
+#define PD_EVENT_INIT              BIT(6)
 
 struct ec_response_host_event_status {
 	uint32_t status; /* PD MCU host event status */
-- 
2.48.1.362.g079036d154-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v1 2/2] usb: typec: ucsi: resume work after EC init
  2025-02-04  2:45 [PATCH v1 0/2] usb: typec: ucsi: Recover from CrOS EC sysjump Jameson Thies
  2025-02-04  2:45 ` [PATCH v1 1/2] platform/chrome: add PD_EVENT_INIT bit definition Jameson Thies
@ 2025-02-04  2:45 ` Jameson Thies
  2025-02-04 14:34   ` Benson Leung
  1 sibling, 1 reply; 8+ messages in thread
From: Jameson Thies @ 2025-02-04  2:45 UTC (permalink / raw)
  To: ukaszb, tzungbi, linux-usb, chrome-platform
  Cc: bleung, heikki.krogerus, gregkh, dmitry.baryshkov, abhishekpandit,
	akuchynski, Jameson Thies

A manual EC sysjump will restart the PPM and break communication with
the UCSI driver by disabling notifications in the initial PPM state.
Update cros_ec_ucsi to listen for PPM init events and treat them as a
system resume to re-establish communication with the PPM (ChromeOS EC).

Signed-off-by: Jameson Thies <jthies@google.com>
---
 drivers/usb/typec/ucsi/cros_ec_ucsi.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
index c605c8616726..5f17fcbda059 100644
--- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c
+++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
@@ -205,12 +205,19 @@ static int cros_ucsi_event(struct notifier_block *nb,
 {
 	struct cros_ucsi_data *udata = container_of(nb, struct cros_ucsi_data, nb);
 
-	if (!(host_event & PD_EVENT_PPM))
-		return NOTIFY_OK;
+	if (host_event & PD_EVENT_INIT) {
+		/* Late init event received from ChromeOS EC. Treat this as a
+		 * system resume to re-enable communication with the PPM.
+		 */
+		dev_dbg(udata->dev, "Late PD init received\n");
+		ucsi_resume(udata->ucsi);
+	}
 
-	dev_dbg(udata->dev, "UCSI notification received\n");
-	flush_work(&udata->work);
-	schedule_work(&udata->work);
+	if (host_event & PD_EVENT_PPM) {
+		dev_dbg(udata->dev, "UCSI notification received\n");
+		flush_work(&udata->work);
+		schedule_work(&udata->work);
+	}
 
 	return NOTIFY_OK;
 }
-- 
2.48.1.362.g079036d154-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] usb: typec: ucsi: resume work after EC init
  2025-02-04  2:45 ` [PATCH v1 2/2] usb: typec: ucsi: resume work after EC init Jameson Thies
@ 2025-02-04 14:34   ` Benson Leung
  2025-02-04 15:12     ` Łukasz Bartosik
  0 siblings, 1 reply; 8+ messages in thread
From: Benson Leung @ 2025-02-04 14:34 UTC (permalink / raw)
  To: Jameson Thies
  Cc: ukaszb, tzungbi, linux-usb, chrome-platform, bleung,
	heikki.krogerus, gregkh, dmitry.baryshkov, abhishekpandit,
	akuchynski

[-- Attachment #1: Type: text/plain, Size: 1724 bytes --]

Hi Jameson,

On Tue, Feb 04, 2025 at 02:45:59AM +0000, Jameson Thies wrote:
> A manual EC sysjump will restart the PPM and break communication with
> the UCSI driver by disabling notifications in the initial PPM state.
> Update cros_ec_ucsi to listen for PPM init events and treat them as a
> system resume to re-establish communication with the PPM (ChromeOS EC).
> 
> Signed-off-by: Jameson Thies <jthies@google.com>

Reviewed-by: Benson Leung <bleung@chromium.org>

> ---
>  drivers/usb/typec/ucsi/cros_ec_ucsi.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> index c605c8616726..5f17fcbda059 100644
> --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> @@ -205,12 +205,19 @@ static int cros_ucsi_event(struct notifier_block *nb,
>  {
>  	struct cros_ucsi_data *udata = container_of(nb, struct cros_ucsi_data, nb);
>  
> -	if (!(host_event & PD_EVENT_PPM))
> -		return NOTIFY_OK;
> +	if (host_event & PD_EVENT_INIT) {
> +		/* Late init event received from ChromeOS EC. Treat this as a
> +		 * system resume to re-enable communication with the PPM.
> +		 */
> +		dev_dbg(udata->dev, "Late PD init received\n");
> +		ucsi_resume(udata->ucsi);
> +	}
>  
> -	dev_dbg(udata->dev, "UCSI notification received\n");
> -	flush_work(&udata->work);
> -	schedule_work(&udata->work);
> +	if (host_event & PD_EVENT_PPM) {
> +		dev_dbg(udata->dev, "UCSI notification received\n");
> +		flush_work(&udata->work);
> +		schedule_work(&udata->work);
> +	}
>  
>  	return NOTIFY_OK;
>  }
> -- 
> 2.48.1.362.g079036d154-goog
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] platform/chrome: add PD_EVENT_INIT bit definition
  2025-02-04  2:45 ` [PATCH v1 1/2] platform/chrome: add PD_EVENT_INIT bit definition Jameson Thies
@ 2025-02-04 14:35   ` Benson Leung
  2025-02-04 15:01     ` Łukasz Bartosik
  2025-02-05  4:27   ` Tzung-Bi Shih
  1 sibling, 1 reply; 8+ messages in thread
From: Benson Leung @ 2025-02-04 14:35 UTC (permalink / raw)
  To: Jameson Thies
  Cc: ukaszb, tzungbi, linux-usb, chrome-platform, bleung,
	heikki.krogerus, gregkh, dmitry.baryshkov, abhishekpandit,
	akuchynski

[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]

Hi Jameson,

On Tue, Feb 04, 2025 at 02:45:58AM +0000, Jameson Thies wrote:
> Update cros_ec_commands.h to include a definition for PD_EVENT_INIT.
> On platforms supporting UCSI, this host event type is sent when the PPM
> initializes.
> 
> Signed-off-by: Jameson Thies <jthies@google.com>

Reviewed-by: Benson Leung <bleung@chromium.org>

> ---
>  include/linux/platform_data/cros_ec_commands.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h
> index ecf290a0c98f..1f4e4f2b89bb 100644
> --- a/include/linux/platform_data/cros_ec_commands.h
> +++ b/include/linux/platform_data/cros_ec_commands.h
> @@ -5046,6 +5046,7 @@ struct ec_response_pd_status {
>  #define PD_EVENT_DATA_SWAP         BIT(3)
>  #define PD_EVENT_TYPEC             BIT(4)
>  #define PD_EVENT_PPM               BIT(5)
> +#define PD_EVENT_INIT              BIT(6)
>  
>  struct ec_response_host_event_status {
>  	uint32_t status; /* PD MCU host event status */
> -- 
> 2.48.1.362.g079036d154-goog
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] platform/chrome: add PD_EVENT_INIT bit definition
  2025-02-04 14:35   ` Benson Leung
@ 2025-02-04 15:01     ` Łukasz Bartosik
  0 siblings, 0 replies; 8+ messages in thread
From: Łukasz Bartosik @ 2025-02-04 15:01 UTC (permalink / raw)
  To: Jameson Thies
  Cc: tzungbi, linux-usb, chrome-platform, bleung, heikki.krogerus,
	Benson Leung, gregkh, dmitry.baryshkov, abhishekpandit,
	akuchynski

On Tue, Feb 4, 2025 at 3:35 PM Benson Leung <bleung@google.com> wrote:
>
> Hi Jameson,
>
> On Tue, Feb 04, 2025 at 02:45:58AM +0000, Jameson Thies wrote:
> > Update cros_ec_commands.h to include a definition for PD_EVENT_INIT.
> > On platforms supporting UCSI, this host event type is sent when the PPM
> > initializes.
> >
> > Signed-off-by: Jameson Thies <jthies@google.com>
>
> Reviewed-by: Benson Leung <bleung@chromium.org>
>

Reviewed-by: Łukasz Bartosik <ukaszb@chromium.org>

> > ---
> >  include/linux/platform_data/cros_ec_commands.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h
> > index ecf290a0c98f..1f4e4f2b89bb 100644
> > --- a/include/linux/platform_data/cros_ec_commands.h
> > +++ b/include/linux/platform_data/cros_ec_commands.h
> > @@ -5046,6 +5046,7 @@ struct ec_response_pd_status {
> >  #define PD_EVENT_DATA_SWAP         BIT(3)
> >  #define PD_EVENT_TYPEC             BIT(4)
> >  #define PD_EVENT_PPM               BIT(5)
> > +#define PD_EVENT_INIT              BIT(6)
> >
> >  struct ec_response_host_event_status {
> >       uint32_t status; /* PD MCU host event status */
> > --
> > 2.48.1.362.g079036d154-goog
> >

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] usb: typec: ucsi: resume work after EC init
  2025-02-04 14:34   ` Benson Leung
@ 2025-02-04 15:12     ` Łukasz Bartosik
  0 siblings, 0 replies; 8+ messages in thread
From: Łukasz Bartosik @ 2025-02-04 15:12 UTC (permalink / raw)
  To: Jameson Thies
  Cc: tzungbi, linux-usb, chrome-platform, bleung, heikki.krogerus,
	gregkh, dmitry.baryshkov, abhishekpandit, akuchynski,
	Benson Leung

On Tue, Feb 4, 2025 at 3:34 PM Benson Leung <bleung@google.com> wrote:
>
> Hi Jameson,
>
> On Tue, Feb 04, 2025 at 02:45:59AM +0000, Jameson Thies wrote:
> > A manual EC sysjump will restart the PPM and break communication with
> > the UCSI driver by disabling notifications in the initial PPM state.
> > Update cros_ec_ucsi to listen for PPM init events and treat them as a
> > system resume to re-establish communication with the PPM (ChromeOS EC).
> >
> > Signed-off-by: Jameson Thies <jthies@google.com>
>
> Reviewed-by: Benson Leung <bleung@chromium.org>
>

Reviewed-by: Łukasz Bartosik <ukaszb@chromium.org>

> > ---
> >  drivers/usb/typec/ucsi/cros_ec_ucsi.c | 17 ++++++++++++-----
> >  1 file changed, 12 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> > index c605c8616726..5f17fcbda059 100644
> > --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> > +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> > @@ -205,12 +205,19 @@ static int cros_ucsi_event(struct notifier_block *nb,
> >  {
> >       struct cros_ucsi_data *udata = container_of(nb, struct cros_ucsi_data, nb);
> >
> > -     if (!(host_event & PD_EVENT_PPM))
> > -             return NOTIFY_OK;
> > +     if (host_event & PD_EVENT_INIT) {
> > +             /* Late init event received from ChromeOS EC. Treat this as a
> > +              * system resume to re-enable communication with the PPM.
> > +              */
> > +             dev_dbg(udata->dev, "Late PD init received\n");
> > +             ucsi_resume(udata->ucsi);
> > +     }
> >
> > -     dev_dbg(udata->dev, "UCSI notification received\n");
> > -     flush_work(&udata->work);
> > -     schedule_work(&udata->work);
> > +     if (host_event & PD_EVENT_PPM) {
> > +             dev_dbg(udata->dev, "UCSI notification received\n");
> > +             flush_work(&udata->work);
> > +             schedule_work(&udata->work);
> > +     }
> >
> >       return NOTIFY_OK;
> >  }
> > --
> > 2.48.1.362.g079036d154-goog
> >

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] platform/chrome: add PD_EVENT_INIT bit definition
  2025-02-04  2:45 ` [PATCH v1 1/2] platform/chrome: add PD_EVENT_INIT bit definition Jameson Thies
  2025-02-04 14:35   ` Benson Leung
@ 2025-02-05  4:27   ` Tzung-Bi Shih
  1 sibling, 0 replies; 8+ messages in thread
From: Tzung-Bi Shih @ 2025-02-05  4:27 UTC (permalink / raw)
  To: Jameson Thies
  Cc: ukaszb, linux-usb, chrome-platform, bleung, heikki.krogerus,
	gregkh, dmitry.baryshkov, abhishekpandit, akuchynski

On Tue, Feb 04, 2025 at 02:45:58AM +0000, Jameson Thies wrote:
> Update cros_ec_commands.h to include a definition for PD_EVENT_INIT.
> On platforms supporting UCSI, this host event type is sent when the PPM
> initializes.
> 
> Signed-off-by: Jameson Thies <jthies@google.com>

Acked-by: Tzung-Bi Shih <tzungbi@kernel.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-02-05  4:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-04  2:45 [PATCH v1 0/2] usb: typec: ucsi: Recover from CrOS EC sysjump Jameson Thies
2025-02-04  2:45 ` [PATCH v1 1/2] platform/chrome: add PD_EVENT_INIT bit definition Jameson Thies
2025-02-04 14:35   ` Benson Leung
2025-02-04 15:01     ` Łukasz Bartosik
2025-02-05  4:27   ` Tzung-Bi Shih
2025-02-04  2:45 ` [PATCH v1 2/2] usb: typec: ucsi: resume work after EC init Jameson Thies
2025-02-04 14:34   ` Benson Leung
2025-02-04 15:12     ` Łukasz Bartosik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox