Message ID | 20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-3-3889b1b2050c@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp358362vqo; Thu, 4 May 2023 07:23:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Ot7/41r/aQEuaEgtJojt7q66Jue8z+FfTxMfJxqLxMHdubpgXxXH1uapS9QMlLWk9QHn0 X-Received: by 2002:a17:903:22c9:b0:1a5:22a6:4e6a with SMTP id y9-20020a17090322c900b001a522a64e6amr4612120plg.51.1683210230557; Thu, 04 May 2023 07:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683210230; cv=none; d=google.com; s=arc-20160816; b=FeTAQXQIw/gGDye02udTM9fISol6qh6jXQbmSpjQzgyTtG9pSvsfj8Fj/gGR/zBWK9 vGXvA9rImw6gKfRlAdfVqt8UtTPj9GfJ036F2Ex2LewShW04T4yr1WiaMFoCArtyKyxT VkM6S8dLxFFT3biTlYZeDAcrq9YpZK8nOvzFoQh+D8TxANQkzWszvofNDKixFmsIQKrS bXahYHG0x1DXTxKY3R8T0wzKrRCitcZGBpEYLmMCETl1o7kx76QP3cC+N9PdOxeEtq+N l3nTythFI+7MMKfQ+FlV/hyU9cnsc+7sUMhkfhew9t5Wda5b4i2dSfewFm107ymzteX2 z4hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=hGwUzuOQID0h6XkyzYjAS7zaFyA0FPpMEkxSvHgc0Mk=; b=JHi+RfYdzteDcuzFcmtP/19UvKB494qjhPp+rYhd7eSTEcacKZkSNF0Q5fMXIhfgt6 v05rvbPiTURtyHPwaLHPB0cU/kIUvunAiAbjsmXF/mqmIPRqFGP9i0XfLeMACzjM0mRr T3KXWb5PCfEsujsQmZQl+D/0XXGkeKP+bscM9bZxtubnr2jiTtMUCINZwE9FbWCeSAy3 mj02QR5Sy01736x5JHwSjMB9jzw54Eor0ZUBBXHXbl5x7gDVemABHZ/ft0tBELxUj/fz D2u3R+ylHGKW48oidUMuNnQsD0STLt3GNY3VT0HoUjRceqO2QXVUNhXGniJkJ6D/N5ki ZNqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a170902e88c00b001a656596b9esi37528371plg.608.2023.05.04.07.23.35; Thu, 04 May 2023 07:23:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231228AbjEDNrm (ORCPT <rfc822;b08248@gmail.com> + 99 others); Thu, 4 May 2023 09:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbjEDNrk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 4 May 2023 09:47: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 4CF487AB7 for <linux-kernel@vger.kernel.org>; Thu, 4 May 2023 06:47:38 -0700 (PDT) Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from <m.felsch@pengutronix.de>) id 1puZIV-0004SX-S9; Thu, 04 May 2023 15:47:03 +0200 From: Marco Felsch <m.felsch@pengutronix.de> Date: Thu, 04 May 2023 15:46:52 +0200 Subject: [PATCH v2 3/4] usb: typec: tcpci: clear the fault status bit MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-3-3889b1b2050c@pengutronix.de> References: <20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-0-3889b1b2050c@pengutronix.de> In-Reply-To: <20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-0-3889b1b2050c@pengutronix.de> To: andreas@fatal.se, jun.li@nxp.com, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Bjorn Andersson <andersson@kernel.org>, Heikki Krogerus <heikki.krogerus@linux.intel.com>, Guenter Roeck <linux@roeck-us.net>, Shawn Guo <shawnguo@kernel.org>, Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix Kernel Team <kernel@pengutronix.de>, Fabio Estevam <festevam@gmail.com>, NXP Linux Team <linux-imx@nxp.com> Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Marco Felsch <m.felsch@pengutronix.de> X-Mailer: b4 0.12.1 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764973850747508071?= X-GMAIL-MSGID: =?utf-8?q?1764973850747508071?= |
Series |
Add i.MX8MP-EVK USB Gadget Support
|
|
Commit Message
Marco Felsch
May 4, 2023, 1:46 p.m. UTC
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
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
bit-7.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/usb/typec/tcpm/tcpci.c | 5 +++++
include/linux/usb/tcpci.h | 1 +
2 files changed, 6 insertions(+)
Comments
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 ? > 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 ? corresponding > bit-7. > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> > --- > 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. 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 ? Also, why not just write the bit unconditionally, similar to TCPC_ALERT ? 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 > >
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 <m.felsch@pengutronix.de> > > --- > > 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 > > > >
On 5/4/23 07:27, Marco Felsch wrote: > 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. > instead of "reseted" which isn't really a word. >>> 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 <m.felsch@pengutronix.de> >>> --- >>> 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 >>> >> >>
On 23-05-04, Guenter Roeck wrote: > On 5/4/23 07:27, Marco Felsch wrote: > > 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. > > > > instead of "reseted" which isn't really a word. Sure, thanks. Regards, Marco
On 23-08-16, Fabio Estevam wrote: > Hi Marco, > > On Thu, May 4, 2023 at 11:27 AM Marco Felsch <m.felsch@pengutronix.de> wrote: > > > > Also, why not just write the bit unconditionally, similar > > > to TCPC_ALERT ? > > > > Thought about this too.. I will change it in the v3. > > Was there ever a v3 for this patch? Nope, thanks for sending it separate :) Regards, Marco
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, ®); + 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