public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] usb: typec: tcpci: Add FAULT_ALERT handling
       [not found] <GVAP278MB0662D8077733604B9B103187974C2@GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM>
@ 2024-10-22 18:01 ` RD Babiera
       [not found]   ` <GVAP278MB06628A1811E2DE44BAE6AC8D974C2@GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM>
  2024-10-23  5:08 ` gregkh
  1 sibling, 1 reply; 3+ messages in thread
From: RD Babiera @ 2024-10-22 18:01 UTC (permalink / raw)
  To: Yanik Fuchs
  Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
	m.felsch@pengutronix.de, u.kleine-koenig@baylibre.com,
	Emanuele Ghidoli, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org

Hi Yanik,

> +   /*
> +   * some chips asert fault alert, even if it is masked.
> +   * The FAULT_STATUS is read and
> +   */
> +   if (status & TCPC_ALERT_FAULT)
> +       regmap_read(tcpci->regmap, TCPC_FAULT_STATUS, &raw);
> +       regmap_write(tcpci->regmap, TCPC_FAULT_STATUS, raw);

Would it make sense to register TCPC_ALERT_FAULT to the alert mask as well?
If TCPC_ALERT_FAULT would be the only alert to trigger an IRQ, will tcpci_irq
still run if it is masked? i.e., can this patch only read/clear the
fault status because
it piggybacks off of another alert?

Best,
RD

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

* Re: [PATCH] usb: typec: tcpci: Add FAULT_ALERT handling
       [not found] <GVAP278MB0662D8077733604B9B103187974C2@GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM>
  2024-10-22 18:01 ` [PATCH] usb: typec: tcpci: Add FAULT_ALERT handling RD Babiera
@ 2024-10-23  5:08 ` gregkh
  1 sibling, 0 replies; 3+ messages in thread
From: gregkh @ 2024-10-23  5:08 UTC (permalink / raw)
  To: Yanik Fuchs
  Cc: heikki.krogerus@linux.intel.com, m.felsch@pengutronix.de,
	rdbabiera@google.com, u.kleine-koenig@baylibre.com,
	Emanuele Ghidoli, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Tue, Oct 22, 2024 at 05:06:46PM +0000, Yanik Fuchs wrote:
> Good Evening
> 
> This is my first Pull request for the Linux Kernel, I hope, I have formatted it correctly.
> The info about the Patch should be clear from the message I added, I hope.
> 
> 
> Freundliche Grüsse
> 
> Best regards
> 
> 
> Yanik Fuchs
> [cid:239faadc-5aa5-4417-b69c-5afc0ce01589]<https://www.mbv.ch/en/>
> MBV AG
> Microbiology and Bioanalytic
> Industriestrasse 9, CH-8712 Stäfa
> [cid:a21e1738-fbcb-44ca-b6ba-611f60800d18]<https://www.linkedin.com/company/25071130/>  [cid:9c47fbef-89db-4406-89ee-a2b4487eeaf2] <https://www.youtube.com/channel/UC3vLuuteeanNc1wX9OTARDQ>     Legal disclaimer<https://www.mbv.ch/en/about-us/imprint/>
> 
> [cid:bc59151f-ea88-4e9b-ac75-03cfb28b780f]<https://www.mbv.ch/en/about-mbv/events/>
> 
> >From 133cda1dff7e87f999506164533bbb1cfaf8fe7e Mon Sep 17 00:00:00 2001
> From: yfu <yanikfuchs@me.com>
> Date: Tue, 22 Oct 2024 18:27:49 +0200
> Subject: [PATCH] usb: typec: tcpci: Add FAULT_ALERT handling
>  message
> 
> I encountered an issue, where I was not able to communicate with other
> i2c devices, if ptn5110 was initiated while it was seeing Vbus.
> 
> i2c analysis did show, that ALERT_FAULT pin is asserted and
> reasserts on try to acknowledge it, because there is still an asserted
> pin in FAULT_STATUS. This results in Alert GPIO being always low.
> 
> With this Commit, I add a function to the IRQ handler, which acknowledges
> all asserted Pins in FAULT_STATUS register. With this patch, ALERT_STATUS can be acknowledged without issues.
> ---
>  drivers/usb/typec/tcpm/tcpci.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index ed32583829be..eb885aa4171c 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -714,6 +714,13 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
>     irq_ret = status & tcpci->alert_mask;
> 
>  process_status:
> +   /*
> +   * some chips asert fault alert, even if it is masked.
> +   * The FAULT_STATUS is read and
> +   */
> +   if (status & TCPC_ALERT_FAULT)
> +       regmap_read(tcpci->regmap, TCPC_FAULT_STATUS, &raw);
> +       regmap_write(tcpci->regmap, TCPC_FAULT_STATUS, raw);
>     /*
>      * Clear alert status for everything except RX_STATUS, which shouldn't
>      * be cleared until we have successfully retrieved message.
> --
> 2.34.1
> 
> 
> 



Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch was sent in html email format, making it impossible to
  apply and automatically rejected by the mailing lists.

- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
  and can not be applied.  Please read the file,
  Documentation/process/email-clients.rst in order to fix this.

- Your patch was attached, please place it inline so that it can be
  applied directly from the email message itself.

- Your patch does not have a Signed-off-by: line.  Please read the
  kernel file, Documentation/process/submitting-patches.rst and resend
  it after adding that line.  Note, the line needs to be in the body of
  the email, before the patch, not at the bottom of the patch or in the
  email signature.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

* AW: [PATCH] usb: typec: tcpci: Add FAULT_ALERT handling
       [not found]   ` <GVAP278MB06628A1811E2DE44BAE6AC8D974C2@GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM>
@ 2024-10-24 22:29     ` Yanik Fuchs
  0 siblings, 0 replies; 3+ messages in thread
From: Yanik Fuchs @ 2024-10-24 22:29 UTC (permalink / raw)
  To: RD Babiera
  Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
	m.felsch@pengutronix.de, u.kleine-koenig@baylibre.com,
	Emanuele Ghidoli, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org

From 031c09076392422235fc79b982cc4ab052a565b9 Mon Sep 17 00:00:00 2001
From: Yanik Fuchs <yanikfuchs@me.com>
Date: Thu, 24 Oct 2024 23:36:25 +0200
Subject: [PATCH v2] usb: typec: tcpci: Add FAULT_ALERT handling
 message


Good evening

Thank you very much for the feedback! I have now
updated the patch to register the fault pin.

Changes since v1:
- added TCPC_ALERT_FAULT to pins to unmask in tcpci_init
- Added missing "{}" in if statement
- checked patch using ./scripts/checkpatch.pl

Conversation:

>________________________________________
>Von: Yanik Fuchs <Yanik.fuchs@mbv.ch>
>Gesendet: Dienstag, 22. Oktober 2024 21:13
>An: RD Babiera <rdbabiera@google.com>
> 
>Thank you for your fast response!
>
>I agree, since the Chip seems to need Fault alert acknowledged to work properly, it would, in my opinion, make sense to unmask the fault_alert at the init >phase prior IRQ, where the others alerts get unmasked. But I do not know if all, or just some faults trigger the fault_alert pin even if it is masked and if that >then would be an issue (like uneeded traffic on i2c). 
>
>Best regards 
>Yanik Fuchs
>
>________________________________________
>From: RD Babiera <rdbabiera@google.com>
>Sent: Tuesday, October 22, 2024 8:01:38 PM
>To: Yanik Fuchs <Yanik.fuchs@mbv.ch>
>
>Hi Yanik,
>
>> +   /*
>> +   * some chips asert fault alert, even if it is masked.
> >+   * The FAULT_STATUS is read and
> >+   */
> >+   if (status & TCPC_ALERT_FAULT)
> >+       regmap_read(tcpci->regmap, TCPC_FAULT_STATUS, &raw);
> >+       regmap_write(tcpci->regmap, TCPC_FAULT_STATUS, raw);
>
>Would it make sense to register TCPC_ALERT_FAULT to the alert mask as well?
>If TCPC_ALERT_FAULT would be the only alert to trigger an IRQ, will tcpci_irq
>still run if it is masked? i.e., can this patch only read/clear the
>fault status because
>it piggybacks off of another alert?
>
>Best,
>RD

I am looking forward to hear more feedback :)

Best regards
Yanik Fuchs

Signed-off-by: Yanik Fuchs <yanikfuchs@me.com>
---
 drivers/usb/typec/tcpm/tcpci.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index ed32583829be..eb6dee2f0c53 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -686,7 +686,8 @@ static int tcpci_init(struct tcpc_dev *tcpc)
 
 	reg = TCPC_ALERT_TX_SUCCESS | TCPC_ALERT_TX_FAILED |
 		TCPC_ALERT_TX_DISCARDED | TCPC_ALERT_RX_STATUS |
-		TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_CC_STATUS;
+		TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_CC_STATUS |
+		TCPC_ALERT_FAULT;
 	if (tcpci->controls_vbus)
 		reg |= TCPC_ALERT_POWER_STATUS;
 	/* Enable VSAFE0V status interrupt when detecting VSAFE0V is supported */
@@ -714,6 +715,14 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci)
 	irq_ret = status & tcpci->alert_mask;
 
 process_status:
+	/*
+	 * some chips asert fault alert, even if it is masked.
+	 * The FAULT_STATUS is read and written after to acknolige
+	 */
+	if (status & TCPC_ALERT_FAULT) {
+		regmap_read(tcpci->regmap, TCPC_FAULT_STATUS, &raw);
+		regmap_write(tcpci->regmap, TCPC_FAULT_STATUS, raw);
+	}
 	/*
 	 * Clear alert status for everything except RX_STATUS, which shouldn't
 	 * be cleared until we have successfully retrieved message.
-- 
2.34.1

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

end of thread, other threads:[~2024-10-24 22:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <GVAP278MB0662D8077733604B9B103187974C2@GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM>
2024-10-22 18:01 ` [PATCH] usb: typec: tcpci: Add FAULT_ALERT handling RD Babiera
     [not found]   ` <GVAP278MB06628A1811E2DE44BAE6AC8D974C2@GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM>
2024-10-24 22:29     ` AW: " Yanik Fuchs
2024-10-23  5:08 ` gregkh

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