From patchwork Thu May 4 13:46:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 13231257 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2006C7EE29 for ; Thu, 4 May 2023 13:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Qcmyywpe4kLqA5vdisu7Pq5UQE7w+6GHeUXengA9H0w=; b=W+jeGvVuDEqGwk xKvrPMGHgKOzyXtOB5CuJnTdVs60MwC/p9Ff02RXQ4t/A73l0Pc2JpHGyHPsW3IndDqxaSbRr0+3l ki2o79aGSJSHR2RoB4WRRejVN/XjN5AtxPY9x6GkUchfbSXzyGMGkcuAwBpCk/050trxf2Fn1jGx3 bm+lqYVsD658WsXmRolKbMg+WEdG+O5VTqhO4m7LN+HcC7bCkUwQFCanc+i2NZ9ayrnLP/I3MBXPf utrX1Obl9HBRV78usQ17jZw60DjB0+Y7f2k2yJSC3PeJGPjW6BR7PnR3tHKvvI3vAp0J1YjFDiVac gfELhYlQ56ob0EJReRlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puZJ7-007zwE-0j; Thu, 04 May 2023 13:47:41 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puZJ1-007zu3-0b for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 13:47:36 +0000 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 ) id 1puZIU-0004SX-82; Thu, 04 May 2023 15:47:02 +0200 From: Marco Felsch Date: Thu, 04 May 2023 15:46:50 +0200 Subject: [PATCH v2 1/4] dt-bindings: usb: gpio-sbu-mux: add support for ss-data lanes mux MIME-Version: 1.0 Message-Id: <20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-1-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 , Rob Herring , Krzysztof Kozlowski , Bjorn Andersson , Heikki Krogerus , Guenter Roeck , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Marco Felsch 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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230504_064735_230543_3FB4C7FE X-CRM114-Status: GOOD ( 12.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This adds the support for GPIO based USB-C SS data lane muxing. Signed-off-by: Marco Felsch --- .../devicetree/bindings/usb/gpio-sbu-mux.yaml | 82 +++++++++++++++++++--- 1 file changed, 71 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml b/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml index bf4b1d016e1f..796f3283ac02 100644 --- a/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml +++ b/Documentation/devicetree/bindings/usb/gpio-sbu-mux.yaml @@ -4,24 +4,26 @@ $id: "http://devicetree.org/schemas/usb/gpio-sbu-mux.yaml#" $schema: "http://devicetree.org/meta-schemas/core.yaml#" -title: GPIO-based SBU mux +title: GPIO-based SS/SBU mux maintainers: - Bjorn Andersson description: - In USB Type-C applications the SBU lines needs to be connected, disconnected - and swapped depending on the altmode and orientation. This binding describes - a family of hardware solutions which switches between these modes using GPIO - signals. + In USB Type-C applications the SS/SBU lines needs to be connected, + disconnected and swapped depending on the altmode and orientation. This + binding describes a family of hardware solutions which switches between these + modes using GPIO signals. properties: compatible: - items: - - enum: - - onnn,fsusb43l10x - - pericom,pi3usb102 - - const: gpio-sbu-mux + oneOf: + - items: + - enum: + - onnn,fsusb43l10x + - pericom,pi3usb102 + - const: gpio-sbu-mux + - const: gpio-ss-mux enable-gpios: description: Switch enable GPIO @@ -50,10 +52,18 @@ required: - compatible - enable-gpios - select-gpios - - mode-switch - orientation-switch - port +if: + properties: + compatible: + contains: + const: gpio-sbu-mux +then: + required: + - mode-switch + additionalProperties: false examples: @@ -107,4 +117,54 @@ examples: }; }; }; + + - | + #include + + tcpm { + connector { + compatible = "usb-c-connector"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + tcpm_hs_out: endpoint { + remote-endpoint = <&usb_hs_phy_in>; + }; + }; + + port@1 { + reg = <1>; + tcpm_ss_out: endpoint { + remote-endpoint = <&usb_ss_phy_in>; + }; + }; + + port@2 { + reg = <2>; + tcpm_ss_mux_out: endpoint { + remote-endpoint = <&ss_mux_in>; + }; + }; + }; + }; + }; + + usb-ss-mux { + compatible = "gpio-ss-mux"; + + enable-gpios = <&tlmm 101 GPIO_ACTIVE_LOW>; + select-gpios = <&tlmm 164 GPIO_ACTIVE_HIGH>; + + orientation-switch; + + port { + ss_mux_in: endpoint { + remote-endpoint = <&tcpm_ss_mux_out>; + }; + }; + }; ... From patchwork Thu May 4 13:46:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 13231256 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACE18C7EE23 for ; Thu, 4 May 2023 13:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=o1SvQDc91hjckmlGDDEZZ+CDAjky7UDbmTx/KUg/FSw=; b=RwjIgRqvw+4cwl Vxj3MelsgHZN0C5X+t1tk8JpBLcEaxF86rlI7Td+lHxiVM15+II2zr5m96hRFmlEaRFvmGPk4iOHC ZBm9PSA2K5XKp4iDy2HZfdGLYmeIb3lRadVSMcNlTK7KBnOmQlK7PpkigdDmRqXhmu1Ptvwf4fukd TQCq7qyMc+ei/wJXJuZg3SLBrYLG56CbxsUt3uDMDsYTLNcmLZ94BX3mz03+3FDEndfc3lutUqNTA WWy6tvD1JundERbUpfVoKE7QlFfleEFsHZXRtefnVOGy5adTUwAD7W9hzu5kCRLgu840qfGljZBVL yQ5UTmF3igp4TpaOgvGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puZJA-007zwg-0N; Thu, 04 May 2023 13:47:44 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puZJ1-007zu5-0c for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 13:47:38 +0000 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 ) id 1puZIV-0004SX-2D; Thu, 04 May 2023 15:47:03 +0200 From: Marco Felsch Date: Thu, 04 May 2023 15:46:51 +0200 Subject: [PATCH v2 2/4] usb: typec: mux: gpio-sbu-mux: add support for ss data lane muxing MIME-Version: 1.0 Message-Id: <20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-2-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 , Rob Herring , Krzysztof Kozlowski , Bjorn Andersson , Heikki Krogerus , Guenter Roeck , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Marco Felsch 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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230504_064735_247091_E2F2F643 X-CRM114-Status: GOOD ( 19.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The commit adds the support to handle gpio based usb-c ss data lanes muxes as well. The only difference is the data lanes enable handling. The data lanes don't depend on the alt-mode settings instead they depend on the usb-c cable orientation (connected, not connected). Signed-off-by: Marco Felsch --- drivers/usb/typec/mux/Kconfig | 5 +++-- drivers/usb/typec/mux/gpio-sbu-mux.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/mux/Kconfig b/drivers/usb/typec/mux/Kconfig index c46fa4f9d3df..68438e7722d0 100644 --- a/drivers/usb/typec/mux/Kconfig +++ b/drivers/usb/typec/mux/Kconfig @@ -13,10 +13,11 @@ config TYPEC_MUX_FSA4480 If compiled as a module, the module will be named fsa4480. config TYPEC_MUX_GPIO_SBU - tristate "Generic GPIO based SBU mux for USB Type-C applications" + tristate "Generic GPIO based SS/SBU mux for USB Type-C applications" help Say Y or M if your system uses a GPIO based mux for managing the - connected state and the swapping of the SBU lines in a Type-C port. + connected state and the swapping of the SS or SBU lines in a Type-C + port. config TYPEC_MUX_PI3USB30532 tristate "Pericom PI3USB30532 Type-C cross switch driver" diff --git a/drivers/usb/typec/mux/gpio-sbu-mux.c b/drivers/usb/typec/mux/gpio-sbu-mux.c index f62516dafe8f..a1a560a085b8 100644 --- a/drivers/usb/typec/mux/gpio-sbu-mux.c +++ b/drivers/usb/typec/mux/gpio-sbu-mux.c @@ -14,12 +14,18 @@ #include #include +enum gpio_sbu_mux_type { + MUX_TYPE_SBU, + MUX_TYPE_SS, +}; + struct gpio_sbu_mux { struct gpio_desc *enable_gpio; struct gpio_desc *select_gpio; struct typec_switch_dev *sw; struct typec_mux_dev *mux; + enum gpio_sbu_mux_type type; struct mutex lock; /* protect enabled and swapped */ bool enabled; @@ -38,6 +44,13 @@ static int gpio_sbu_switch_set(struct typec_switch_dev *sw, enabled = sbu_mux->enabled; swapped = sbu_mux->swapped; + /* + * In case of muxing the SS data lanes the enable status depends only on + * the orientation and not on the TYPEC_DP_STATE_* + */ + if (sbu_mux->type == MUX_TYPE_SS) + enabled = true; + switch (orientation) { case TYPEC_ORIENTATION_NONE: enabled = false; @@ -103,6 +116,8 @@ static int gpio_sbu_mux_probe(struct platform_device *pdev) if (!sbu_mux) return -ENOMEM; + sbu_mux->type = (enum gpio_sbu_mux_type)device_get_match_data(&pdev->dev); + mutex_init(&sbu_mux->lock); sbu_mux->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); @@ -153,7 +168,8 @@ static int gpio_sbu_mux_remove(struct platform_device *pdev) } static const struct of_device_id gpio_sbu_mux_match[] = { - { .compatible = "gpio-sbu-mux", }, + { .compatible = "gpio-sbu-mux", .data = (void *)MUX_TYPE_SBU }, + { .compatible = "gpio-ss-mux", .data = (void *)MUX_TYPE_SS }, {} }; MODULE_DEVICE_TABLE(of, gpio_sbu_mux_match); From patchwork Thu May 4 13:46:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 13231258 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7937CC7EE21 for ; Thu, 4 May 2023 13:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tXiSRI+cZJk3HdOsx2mZmYEaddKTkyYCk9xwZ0VY9ac=; b=VS99M8y/XLCqAi IGvzW6+fDYBVTf/oPqhWKz8VZ/xsH94+W00O/dBrPzefmVt49c3IlZBb5r7ExHHr2fNHgEBT0Pfdo 5gCW7jnY5n1LodgBHrllQaqE39TISNysPNunHco09MovAxKc4xauCdYQJnRaIIDls1+rcKtGSPA2v lhFp1IQY9Shh1dXoUyv2aX/d05IUZObrzRUuExSqiSdjMcY2hNRbuLQ4XaOpL41bJM5u2e7UTvVp2 O5xhDfNCbFHX8P9rOhfQlnQqC9RTPLLP/FElGzy2YB1fY0n2lL1HOPkuZefQjmM92LyADDI32EiZU FO6AGU2F8h6gUImsE/7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puZJ4-007zvn-00; Thu, 04 May 2023 13:47:38 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puZJ1-007zu2-0b for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 13:47:36 +0000 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 ) id 1puZIV-0004SX-S9; Thu, 04 May 2023 15:47:03 +0200 From: Marco Felsch 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 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 , Rob Herring , Krzysztof Kozlowski , Bjorn Andersson , Heikki Krogerus , Guenter Roeck , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Marco Felsch 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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230504_064735_234995_2164BC51 X-CRM114-Status: GOOD ( 12.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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, ®); + 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 From patchwork Thu May 4 13:46:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 13231255 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1BC6C7EE21 for ; Thu, 4 May 2023 13:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6lZALYaO03iswlN/kGA6x3y4YnZYYG7OmI0ZUzqz1cs=; b=27h3OOZKJkXwfU ZsLRrI37OO1zvgIuKvVXTvkiSmhnL23U4rENA59dzVvbyClDM4CKtxbT1ZkghLG1LOxoKzEMONR5e h4EcZbLK+ing6Y8cHxjmp2rRjXZookSTaNZjq6a25VO7QEAr4pEXd8lJ9eVRs7vr00taA5pyqCCV2 ipbbQP9jsmSnnvmKeSTm9Tbz5KIpq8ijhsKcneNzNtEjsFn6n+NfkanJnMPOTT3uD8hdoWrphGue1 2hJH5zOjEAIzxkMbBNqTeAVIIlL1TJHOlYRZoc9LzbWV8bryHPllyHHHj+dW6We0n48/O+txRgk5U 5OGYmM4/HVwg3J7LMJeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puZJ9-007zwX-0V; Thu, 04 May 2023 13:47:43 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puZJ1-007zu6-0c for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 13:47:38 +0000 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 ) id 1puZIW-0004SX-OF; Thu, 04 May 2023 15:47:04 +0200 From: Marco Felsch Date: Thu, 04 May 2023 15:46:53 +0200 Subject: [PATCH v2 4/4] arm64: dts: imx8mp-evk: add dual-role usb port1 support MIME-Version: 1.0 Message-Id: <20230504-b4-v6-3-topic-boards-imx8mp-evk-dual-role-usb-v2-4-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 , Rob Herring , Krzysztof Kozlowski , Bjorn Andersson , Heikki Krogerus , Guenter Roeck , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Marco Felsch 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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230504_064735_230646_C148A995 X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The i.MX8MP-EVK has a dual-role usb-type-c port marked as PORT1. By this commit the dual-role support is added which allows the user-space to assign usb-gadget functions to it via the configFS. Below is the test results of a basic usbgadget-ethernet test using by iperf3. Accepted connection from 192.168.60.1, port 48172 [ 5] local 192.168.60.2 port 5201 connected to 192.168.60.1 port 48176 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 101 MBytes 850 Mbits/sec [ 5] 1.00-2.00 sec 105 MBytes 883 Mbits/sec [ 5] 2.00-3.00 sec 105 MBytes 885 Mbits/sec ... - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate [ 5] 0.00-100.04 sec 10.3 GBytes 882 Mbits/sec receiver Accepted connection from 192.168.60.1, port 42104 [ 5] local 192.168.60.2 port 5201 connected to 192.168.60.1 port 42110 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 110 MBytes 925 Mbits/sec 0 540 KBytes [ 5] 1.00-2.00 sec 112 MBytes 938 Mbits/sec 0 566 KBytes [ 5] 2.00-3.00 sec 115 MBytes 969 Mbits/sec 0 566 KBytes ... - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-37.00 sec 4.27 GBytes 990 Mbits/sec 0 sender Signed-off-by: Marco Felsch --- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 88 ++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts index 7816853162b3..20c3c41d6209 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts @@ -5,7 +5,9 @@ /dts-v1/; +#include #include +#include #include "imx8mp.dtsi" / { @@ -83,6 +85,22 @@ reg_usdhc2_vmmc: regulator-usdhc2 { gpio = <&gpio2 19 GPIO_ACTIVE_HIGH>; enable-active-high; }; + + usb-ss-mux { + compatible = "gpio-ss-mux"; + enable-gpios = <&gpio2 20 GPIO_ACTIVE_LOW>; + select-gpios = <&gpio4 20 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_usb_ss_mux>; + + orientation-switch; + + port { + usb_ss_mux: endpoint { + remote-endpoint = <&usb_con_ss_mux>; + }; + }; + }; }; &flexspi { @@ -336,6 +354,40 @@ &i2c2 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_i2c2>; status = "okay"; + + tcpc@50 { + compatible = "nxp,ptn5110"; + reg = <0x50>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_tcpc>; + interrupt-parent = <&gpio4>; + interrupts = <19 IRQ_TYPE_LEVEL_LOW>; + + connector { + compatible = "usb-c-connector"; + label = "USB-C"; + power-role = "dual"; + data-role = "dual"; + try-power-role = "sink"; + source-pdos = ; + sink-pdos = ; + op-sink-microwatt = <15000000>; + self-powered; + + port { + usb_con_ss_mux: endpoint { + remote-endpoint = <&usb_ss_mux>; + }; + }; + }; + + port { + usb_con_ss: endpoint { + remote-endpoint = <&usb_dwc3_0_drd>; + }; + }; + }; }; &i2c3 { @@ -442,14 +494,37 @@ &uart2 { status = "okay"; }; +&usb3_phy0 { + status = "okay"; +}; + &usb3_phy1 { status = "okay"; }; +&usb3_0 { + status = "okay"; +}; + &usb3_1 { status = "okay"; }; +&usb_dwc3_0 { + dr_mode = "otg"; + hnp-disable; + srp-disable; + adp-disable; + usb-role-switch; + status = "okay"; + + port { + usb_dwc3_0_drd: endpoint { + remote-endpoint = <&usb_con_ss>; + }; + }; +}; + &usb_dwc3_1 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_usb1_vbus>; @@ -659,6 +734,12 @@ MX8MP_IOMUXC_SD2_RESET_B__GPIO2_IO19 0x40 >; }; + pinctrl_tcpc: tcpcgrp { + fsl,pins = < + MX8MP_IOMUXC_SAI1_TXD7__GPIO4_IO19 0x1e0 + >; + }; + pinctrl_uart1: uart1grp { fsl,pins = < MX8MP_IOMUXC_UART1_RXD__UART1_DCE_RX 0x140 @@ -690,6 +771,13 @@ MX8MP_IOMUXC_ECSPI1_MISO__UART3_DCE_CTS 0x140 >; }; + pinctrl_usb_ss_mux: usbssmuxgrp { + fsl,pins = < + MX8MP_IOMUXC_SD2_WP__GPIO2_IO20 0x104 + MX8MP_IOMUXC_SAI1_MCLK__GPIO4_IO20 0x144 + >; + }; + pinctrl_usdhc2: usdhc2grp { fsl,pins = < MX8MP_IOMUXC_SD2_CLK__USDHC2_CLK 0x190