From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E193C7EE21 for ; Thu, 4 May 2023 14:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbjEDO1k (ORCPT ); Thu, 4 May 2023 10:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbjEDO1k (ORCPT ); Thu, 4 May 2023 10:27:40 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 106596EA9 for ; Thu, 4 May 2023 07:27:39 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1puZvK-0002Nr-OF; Thu, 04 May 2023 16:27:10 +0200 Received: from mfe by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1puZvI-0003dF-IR; Thu, 04 May 2023 16:27:08 +0200 Date: Thu, 4 May 2023 16:27:08 +0200 From: Marco Felsch To: Guenter Roeck Cc: andreas@fatal.se, jun.li@nxp.com, Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Bjorn Andersson , Heikki Krogerus , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 3/4] usb: typec: tcpci: clear the fault status bit Message-ID: <20230504142708.l4xo4sbl7wzsrbql@pengutronix.de> References: <20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-0-3889b1b2050c@pengutronix.de> <20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-3-3889b1b2050c@pengutronix.de> <6a894ff0-3232-4ef0-5e26-95471cc33ed9@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6a894ff0-3232-4ef0-5e26-95471cc33ed9@roeck-us.net> User-Agent: NeoMutt/20180716 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On 23-05-04, Guenter Roeck wrote: > On 5/4/23 06:46, Marco Felsch wrote: > > According the "USB Type-C Port Controller Interface Specification v2.0" > > the TCPC sets the fault status register bit-7 > > (AllRegistersResetToDefault) once the registers have been reseted to > > cleared ? set ? Sry. I don't get this. > > their default values. > > > > This triggers an alert(-irq) on PTN5110 devices albeit we do mask the > > fault-irq. Fix this gernally by writing a one to the correspondig > > generically ? Sure, thanks. > corresponding Of course! > > bit-7. > > > > Signed-off-by: Marco Felsch > > --- > > drivers/usb/typec/tcpm/tcpci.c | 5 +++++ > > include/linux/usb/tcpci.h | 1 + > > 2 files changed, 6 insertions(+) > > > > diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c > > index 8da23240afbe..15632d023e4c 100644 > > --- a/drivers/usb/typec/tcpm/tcpci.c > > +++ b/drivers/usb/typec/tcpm/tcpci.c > > @@ -602,6 +602,11 @@ static int tcpci_init(struct tcpc_dev *tcpc) > > if (time_after(jiffies, timeout)) > > return -ETIMEDOUT; > > + regmap_read(tcpci->regmap, TCPC_FAULT_STATUS, ®); > > Needs error check. I will add this. > Also, I am not sure if this is the correct place for this code. The alert > status is cleared after vendor initialization. Should the same be done > here ? According the spec the bit must be cleared before the TCPC_ALERT is cleared. Of course the vendor-init can (re-)trigger the bit, therefore we should move behind the vendor init and right before the TCPC_ALERT clear. > Also, why not just write the bit unconditionally, similar > to TCPC_ALERT ? Thought about this too.. I will change it in the v3. Thanks for the feedback, Marco > > Thanks, > Guenter > > > + if (reg & TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT) > > + tcpci_write16(tcpci, TCPC_FAULT_STATUS, > > + TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT); > > + > > /* Handle vendor init */ > > if (tcpci->data->init) { > > ret = tcpci->data->init(tcpci, tcpci->data); > > diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h > > index 85e95a3251d3..83376473ac76 100644 > > --- a/include/linux/usb/tcpci.h > > +++ b/include/linux/usb/tcpci.h > > @@ -103,6 +103,7 @@ > > #define TCPC_POWER_STATUS_SINKING_VBUS BIT(0) > > #define TCPC_FAULT_STATUS 0x1f > > +#define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT BIT(7) > > #define TCPC_ALERT_EXTENDED 0x21 > > > >