From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: RD Babiera <rdbabiera@google.com>
Cc: linux@roeck-us.net, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
badhri@google.com
Subject: Re: [PATCH v1 2/2] usb: typec: tcpci: add vconn over current fault handling to maxim_core
Date: Tue, 28 Nov 2023 09:59:20 +0200 [thread overview]
Message-ID: <ZWWd2AU+rJOWzzvx@kuha.fi.intel.com> (raw)
In-Reply-To: <20231121203845.170234-6-rdbabiera@google.com>
On Tue, Nov 21, 2023 at 08:38:48PM +0000, RD Babiera wrote:
> Add TCPC_FAULT_STATUS_VCONN_OC constant and corresponding mask definition.
> Maxim TCPC is capable of detecting VConn over current faults, so add
> fault to alert mask. When a Vconn over current fault is triggered, put the
> port in an error recovery state via tcpm_port_error_recovery.
>
> Signed-off-by: RD Babiera <rdbabiera@google.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tcpm/tcpci_maxim_core.c | 20 +++++++++++++++++++-
> include/linux/usb/tcpci.h | 5 ++++-
> 2 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> index 9454b12a073c..7fb966fd639b 100644
> --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> @@ -92,11 +92,16 @@ static void max_tcpci_init_regs(struct max_tcpci_chip *chip)
> return;
> }
>
> + /* Vconn Over Current Protection */
> + ret = max_tcpci_write8(chip, TCPC_FAULT_STATUS_MASK, TCPC_FAULT_STATUS_MASK_VCONN_OC);
> + if (ret < 0)
> + return;
> +
> alert_mask = TCPC_ALERT_TX_SUCCESS | TCPC_ALERT_TX_DISCARDED | TCPC_ALERT_TX_FAILED |
> TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_RX_STATUS | TCPC_ALERT_CC_STATUS |
> TCPC_ALERT_VBUS_DISCNCT | TCPC_ALERT_RX_BUF_OVF | TCPC_ALERT_POWER_STATUS |
> /* Enable Extended alert for detecting Fast Role Swap Signal */
> - TCPC_ALERT_EXTND | TCPC_ALERT_EXTENDED_STATUS;
> + TCPC_ALERT_EXTND | TCPC_ALERT_EXTENDED_STATUS | TCPC_ALERT_FAULT;
>
> ret = max_tcpci_write16(chip, TCPC_ALERT_MASK, alert_mask);
> if (ret < 0) {
> @@ -295,6 +300,19 @@ static irqreturn_t _max_tcpci_irq(struct max_tcpci_chip *chip, u16 status)
> }
> }
>
> + if (status & TCPC_ALERT_FAULT) {
> + ret = max_tcpci_read8(chip, TCPC_FAULT_STATUS, ®_status);
> + if (ret < 0)
> + return ret;
> +
> + ret = max_tcpci_write8(chip, TCPC_FAULT_STATUS, reg_status);
> + if (ret < 0)
> + return ret;
> +
> + if (reg_status & TCPC_FAULT_STATUS_VCONN_OC)
> + tcpm_port_error_recovery(chip->port);
> + }
> +
> if (status & TCPC_ALERT_EXTND) {
> ret = max_tcpci_read8(chip, TCPC_ALERT_EXTENDED, ®_status);
> if (ret < 0)
> diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h
> index 83376473ac76..467e8045e9f8 100644
> --- a/include/linux/usb/tcpci.h
> +++ b/include/linux/usb/tcpci.h
> @@ -36,7 +36,9 @@
>
> #define TCPC_ALERT_MASK 0x12
> #define TCPC_POWER_STATUS_MASK 0x14
> -#define TCPC_FAULT_STATUS_MASK 0x15
> +
> +#define TCPC_FAULT_STATUS_MASK 0x15
> +#define TCPC_FAULT_STATUS_MASK_VCONN_OC BIT(1)
>
> #define TCPC_EXTENDED_STATUS_MASK 0x16
> #define TCPC_EXTENDED_STATUS_MASK_VSAFE0V BIT(0)
> @@ -104,6 +106,7 @@
>
> #define TCPC_FAULT_STATUS 0x1f
> #define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT BIT(7)
> +#define TCPC_FAULT_STATUS_VCONN_OC BIT(1)
>
> #define TCPC_ALERT_EXTENDED 0x21
>
> --
> 2.43.0.rc1.413.gea7ed67945-goog
--
heikki
next prev parent reply other threads:[~2023-11-28 7:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 20:38 [PATCH v1 0/2] usb: typec: handle tcpc vconn oc fault by triggering tcpm error recovery RD Babiera
2023-11-21 20:38 ` [PATCH v1 1/2] usb: typec: tcpm: add tcpm_port_error_recovery symbol RD Babiera
2023-11-28 7:57 ` Heikki Krogerus
2023-11-28 15:10 ` Guenter Roeck
2023-11-21 20:38 ` [PATCH v1 2/2] usb: typec: tcpci: add vconn over current fault handling to maxim_core RD Babiera
2023-11-28 7:59 ` Heikki Krogerus [this message]
2023-11-28 15:11 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZWWd2AU+rJOWzzvx@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=rdbabiera@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®