From patchwork Mon Mar 13 16:50:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco Dolcini X-Patchwork-Id: 68937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1296220wrd; Mon, 13 Mar 2023 09:58:09 -0700 (PDT) X-Google-Smtp-Source: AK7set/b2Apy1cYGEukILp0TnP/+kh/Nj1HD6N2yqoo1B662zHYjLR22/zXJHUI4rkLyezD6zpud X-Received: by 2002:a05:6a20:729e:b0:d4:77a6:156f with SMTP id o30-20020a056a20729e00b000d477a6156fmr3175056pzk.53.1678726689030; Mon, 13 Mar 2023 09:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678726689; cv=none; d=google.com; s=arc-20160816; b=UWkz2qZiZLPuCoPuvyrDMhpi6ECO5mdfjCl9cIRN1nK6Ze1VEy9gYQ21VCgmzJDk2L U5FIOynmzVO6PzMsbFCxfaCqZDmXtoiG/Zs1tRVQLDKNTr12AHKh1IcGv4FvwS3fv6BR 7XMn1Rkx01F7hjN2dUvJp4162oMrnN4zB4s0n+t5vtGgf21ldGITGPUbrxYfUBYBvHSo gxVVbOJQdPIeXGLsPzLeChVvcDEuUkQGbQq5qZLB/A54I7O1jHnELVB0oQORFBAdeWPK Bv1/1uLZsliI2Zfhv8ngqVSBNYcGOFMDuLNyAegODNFNRiMMC2OIXA2CNukeXgIh5vMf C/JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=o6DK4JoZPgY2ImhxBUUgqsHrWwPfp7AvIfknI4SgAwY=; b=MfHTYQ43w58qPPG6Tp2peMuuuqykIOhHpybhhCAPyiOV2dyu19QhZIqPKTHlUCJke0 S43BtoaihIOIZ7VohHrZTzceOuSToM57UyUqZYi36tiZQW9APGae0cPLmU5jJ4Mzu1QE ODvYh9B2TrAMxS3jSupDSIBzWfupm14HH2/Q+dCLMQPYGnj9GpTc0FUmGe9X6L3v4fce 3SUumaKPZIOCPIM3zS4n4Nolk+cHLcxTuRFnCS5gDOfdgJRfa3TGWUVGy6WzwqASVuPr KuoMABQbpFN2/C0iFaJseeZh0suB5eORxjTpK+1taL183NnZWjCBFtbzrlh8LjEJhqa+ HAag== 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 q202-20020a632ad3000000b00502e3fd615esi7261277pgq.365.2023.03.13.09.57.53; Mon, 13 Mar 2023 09:58:09 -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 S230517AbjCMQ4v (ORCPT + 99 others); Mon, 13 Mar 2023 12:56:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbjCMQ4r (ORCPT ); Mon, 13 Mar 2023 12:56:47 -0400 X-Greylist: delayed 341 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 13 Mar 2023 09:56:30 PDT Received: from mail11.truemail.it (mail11.truemail.it [IPv6:2001:4b7e:0:8::81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7BB47043D; Mon, 13 Mar 2023 09:56:28 -0700 (PDT) Received: from francesco-nb.pivistrello.it (93-49-2-63.ip317.fastwebnet.it [93.49.2.63]) by mail11.truemail.it (Postfix) with ESMTPA id 6FDAB21E2B; Mon, 13 Mar 2023 17:50:45 +0100 (CET) From: Francesco Dolcini To: linux-usb@vger.kernel.org Cc: Emanuele Ghidoli , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Francesco Dolcini Subject: [PATCH v1 3/3] usb: misc: usb3503: support usb3803 and bypass mode Date: Mon, 13 Mar 2023 17:50:39 +0100 Message-Id: <20230313165039.255579-4-francesco@dolcini.it> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230313165039.255579-1-francesco@dolcini.it> References: <20230313165039.255579-1-francesco@dolcini.it> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, SPF_HELO_PASS,T_SPF_TEMPERROR autolearn=no 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?1760272516598715919?= X-GMAIL-MSGID: =?utf-8?q?1760272516598715919?= From: Emanuele Ghidoli Add support for USB3803 and bypass mode, with this change is also possible to move the component out of bypass mode. In bypass mode the downstream port 3 is connected to the upstream port with low switch resistance R_on. Controlling mode of operations: | RESET_N | BYPASS_N | Mode | -------------------------------- | 0 | 0 | standby | | 1 | 0 | bypass | | 1 | 1 | hub | Datasheet: https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/DataSheets/00001691D.pdf Signed-off-by: Emanuele Ghidoli Signed-off-by: Francesco Dolcini --- drivers/usb/misc/usb3503.c | 22 +++++++++++++++++++++- include/linux/platform_data/usb3503.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index 3044db9fd8aa..c6cfd1edaf76 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -46,6 +46,7 @@ struct usb3503 { struct device *dev; struct clk *clk; u8 port_off_mask; + struct gpio_desc *bypass; struct gpio_desc *intn; struct gpio_desc *reset; struct gpio_desc *connect; @@ -109,18 +110,25 @@ static int usb3503_connect(struct usb3503 *hub) static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode) { struct device *dev = hub->dev; - int rst, conn; + int rst, bypass, conn; switch (mode) { case USB3503_MODE_HUB: conn = 1; rst = 0; + bypass = 0; break; case USB3503_MODE_STANDBY: conn = 0; rst = 1; + bypass = 1; dev_info(dev, "switched to STANDBY mode\n"); break; + case USB3503_MODE_BYPASS: + conn = 0; + rst = 0; + bypass = 1; + break; default: dev_err(dev, "unknown mode is requested\n"); return -EINVAL; @@ -132,6 +140,9 @@ static int usb3503_switch_mode(struct usb3503 *hub, enum usb3503_mode mode) if (hub->reset) gpiod_set_value_cansleep(hub->reset, rst); + if (hub->bypass) + gpiod_set_value_cansleep(hub->bypass, bypass); + if (conn) { /* Wait T_HUBINIT == 4ms for hub logic to stabilize */ usleep_range(4000, 10000); @@ -247,6 +258,14 @@ static int usb3503_probe(struct usb3503 *hub) if (hub->connect) gpiod_set_consumer_name(hub->connect, "usb3503 connect"); + hub->bypass = devm_gpiod_get_optional(dev, "bypass", GPIOD_OUT_HIGH); + if (IS_ERR(hub->bypass)) { + err = PTR_ERR(hub->bypass); + goto err_clk; + } + if (hub->bypass) + gpiod_set_consumer_name(hub->bypass, "usb3503 bypass"); + hub->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(hub->reset)) { err = PTR_ERR(hub->reset); @@ -382,6 +401,7 @@ MODULE_DEVICE_TABLE(i2c, usb3503_id); static const struct of_device_id usb3503_of_match[] = { { .compatible = "smsc,usb3503", }, { .compatible = "smsc,usb3503a", }, + { .compatible = "smsc,usb3803", }, {}, }; MODULE_DEVICE_TABLE(of, usb3503_of_match); diff --git a/include/linux/platform_data/usb3503.h b/include/linux/platform_data/usb3503.h index d01ef97ddf36..f3c942f396f8 100644 --- a/include/linux/platform_data/usb3503.h +++ b/include/linux/platform_data/usb3503.h @@ -12,6 +12,7 @@ enum usb3503_mode { USB3503_MODE_UNKNOWN, USB3503_MODE_HUB, USB3503_MODE_STANDBY, + USB3503_MODE_BYPASS, }; struct usb3503_platform_data {