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: 90099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp358937vqo; Thu, 4 May 2023 07:24:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6J9hCPrqDWNbRR1JNYncY38BYt5yYp6Z02FgYbcd7VQttG9EHAcQY98HRDLsU8CuBtlTKL X-Received: by 2002:a17:902:74c1:b0:1a1:d366:b085 with SMTP id f1-20020a17090274c100b001a1d366b085mr4136937plt.21.1683210279088; Thu, 04 May 2023 07:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683210279; cv=none; d=google.com; s=arc-20160816; b=cl7AycycbKci18iCjx3W4n4JUVMLpd6l04oiT0J0wgCuQ5FjEyH8lXolEqLMCM2zGv rqjknb+uTPlMEV6wFbsA9YsHDj4b6mWEXxRxkKYrz40e/TeHU+0yVIw1/WtFhtYNtYpT X+g7gynAjiS8tsUQX2InsKNEVezoIRfmTCKp+bPJCZ+nvmSFsl2Oh/8o/482c11pxxTf 5ospRMSfXJvq/jQRlT2IHVoeiQ5SMieuIDUl0tw2ASCk/V3M2xgWha4M68sAskvLw52O Hye67QR5JpvM5PKMY76R6cFP6pC26YXVYJH0LXAGuOFniMBELHgOzblZVvXTDJLddV+E PIOw== 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=iCF6kaz8A43nX8jgdfxz1dXn1T+yO8BZWcFHtSLbJuE=; b=Z/mI+CJzIU/5tKqNWW+8WtOyC9PwqxlHcBUnkcWiDV1HhhO07MJWvVKE9sm/OmEa1w 1EM/rUhgAtkRrPScIDtpUXM7sCe+dIP0UdHAevETaeQYhcLTWanY6nt+A7txIFnSuxQI Krfn/8AgnpRwuC73AJgDaf+2CdIj0DvEsb3Vas+uXve5Sv8sHEvJZyLWmptLXk/klbeL /GRxs3/1PQI4szOZZfd8934OMTE51k5BAB+g7VDD1eFFeoGLBaQXXZGXbdT90lcIIG/+ uivuUfJQ0Lf3mBwSD7M6EBv2PBF6uPZHTWgYmA7hyNQ05hJIq3J+A8l3XjbZhbrZ6/PE Cpmg== 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 c11-20020a170902d48b00b001a97c1afb8asi27743943plg.622.2023.05.04.07.24.24; Thu, 04 May 2023 07:24:39 -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 S231235AbjEDNrv (ORCPT + 99 others); Thu, 4 May 2023 09:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231225AbjEDNrl (ORCPT ); Thu, 4 May 2023 09:47:41 -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 B31937D9D for ; Thu, 4 May 2023 06:47:39 -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 ) 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-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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764973901776470502?= X-GMAIL-MSGID: =?utf-8?q?1764973901776470502?= 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);