From patchwork Mon Mar 13 16:50:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco Dolcini X-Patchwork-Id: 68938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1296338wrd; Mon, 13 Mar 2023 09:58:24 -0700 (PDT) X-Google-Smtp-Source: AK7set8wTlvjS8iFq+AugNRT1THUj7i3dbxHtvw0PCJZ5w5VeVGl307F+6eZX3NDHizM/S2sBa6n X-Received: by 2002:a17:903:187:b0:19f:2328:beee with SMTP id z7-20020a170903018700b0019f2328beeemr10565178plg.11.1678726704177; Mon, 13 Mar 2023 09:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678726704; cv=none; d=google.com; s=arc-20160816; b=XyMQvxVGW0X417B26abpfzMQbWLRnFfjuC5qv3ng8vrSsMCncUqwltw1L+u3O67tMy 3tsEzABjcWFOfu0nJ61xiTUMtMb4eL1Pt/kSmzPJT5OlI3y6n/3fvYgMFbI2B9MsORuI elycliAorid/zKJh3FFTaPUrIvwUxPItYS2vL3V5ra5Ec6ag8hxlp9dMdjijwqcb+Q/R VXt8gK4Brzo1RNUldeZ6VCJEcCCz3D5O/aSkKuJXzWhyqLCnyy/pduusvtb79T0UhdaJ YptyQWWKq3acfbnkqKz2mX9WlxotY/rMfYC+RGDpMAi+M9fztZTZD1/YvRoKS6lGyiq5 mf0Q== 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=17GUsGKWfAL6uQKRoT6YmOYvpdLmhQ4pjDr84dQgdYI=; b=xPyhsKMu3Z3EXn2lcy0f7lpf8mr9+3gS9gtLFRdsfVQgO0woF2sGsiyNuaJkwQvjs3 5fFSdD/A0AYlaYG5T88rpFJhchX7f+1UBI1fOd4WSmJ0GFo7GXsycPaXEYFAZ74T4JFn IgHRQHH2W5hwKZdxCRY91oRJx8XKF7vDZBznGrG9PoVQyxMcW2EdQowgxNvGCWghEWz6 QdJmz28vNy/B8ge1IU6UZb3rALqCXnb+th6Q1uih4/siwxNpK0QzBSpoG7C6T0u/fWV2 lD67jLqbNZU6r0E/abQ8vkOMu1W5HwWwXFls25FlUHCMZYdN60Qr1pUvYqcwM2KQBNG2 4PSA== 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 16-20020a630b10000000b0050017d1b7c6si6785675pgl.767.2023.03.13.09.58.09; Mon, 13 Mar 2023 09:58:24 -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 S231286AbjCMQ4x (ORCPT + 99 others); Mon, 13 Mar 2023 12:56:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbjCMQ4r (ORCPT ); Mon, 13 Mar 2023 12:56:47 -0400 Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E60FD56159; 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 B874921E29; Mon, 13 Mar 2023 17:50:44 +0100 (CET) From: Francesco Dolcini To: linux-usb@vger.kernel.org, devicetree@vger.kernel.org Cc: Emanuele Ghidoli , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Dongjin Kim , Francesco Dolcini Subject: [PATCH v1 1/3] dt-bindings: usb: smsc,usb3503: Add usb3803 Date: Mon, 13 Mar 2023 17:50:37 +0100 Message-Id: <20230313165039.255579-2-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?1760272532964065258?= X-GMAIL-MSGID: =?utf-8?q?1760272532964065258?= From: Emanuele Ghidoli Add support for usb3803, compared to usb3503 it uses a regular USB connection to upstream instead of HSIC, it has an additional low power mode (bypass) and an additional control signal (BYPASS_N). In bypass mode the downstream port 3 is connected to the upstream port with low switch resistance R_on. Signed-off-by: Emanuele Ghidoli Signed-off-by: Francesco Dolcini Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/usb/smsc,usb3503.yaml | 54 ++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/smsc,usb3503.yaml b/Documentation/devicetree/bindings/usb/smsc,usb3503.yaml index a09f4528aea3..6156dc26e65c 100644 --- a/Documentation/devicetree/bindings/usb/smsc,usb3503.yaml +++ b/Documentation/devicetree/bindings/usb/smsc,usb3503.yaml @@ -14,6 +14,7 @@ properties: enum: - smsc,usb3503 - smsc,usb3503a + - smsc,usb3803 reg: maxItems: 1 @@ -33,6 +34,12 @@ properties: description: > GPIO for reset + bypass-gpios: + maxItems: 1 + description: > + GPIO for bypass. + Control signal to select between HUB MODE and BYPASS MODE. + disabled-ports: $ref: /schemas/types.yaml#/definitions/uint32-array minItems: 1 @@ -46,9 +53,10 @@ properties: initial-mode: $ref: /schemas/types.yaml#/definitions/uint32 - enum: [1, 2] description: > - Specifies initial mode. 1 for Hub mode, 2 for standby mode. + Specifies initial mode. 1 for Hub mode, 2 for standby mode and 3 for bypass mode. + In bypass mode the downstream port 3 is connected to the upstream port with low + switch resistance R_on. clocks: maxItems: 1 @@ -71,6 +79,29 @@ properties: required: - compatible +allOf: + - if: + not: + properties: + compatible: + enum: + - smsc,usb3803 + then: + properties: + bypass-gpios: false + + - if: + required: + - bypass-gpios + then: + properties: + initial-mode: + enum: [1, 2, 3] + else: + properties: + initial-mode: + enum: [1, 2] + additionalProperties: false examples: @@ -92,6 +123,25 @@ examples: }; }; + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + usb-hub@8 { + compatible = "smsc,usb3803"; + reg = <0x08>; + connect-gpios = <&gpx3 0 1>; + disabled-ports = <2 3>; + intn-gpios = <&gpx3 4 1>; + reset-gpios = <&gpx3 5 1>; + bypass-gpios = <&gpx3 6 1>; + initial-mode = <3>; + clocks = <&clks 80>; + clock-names = "refclk"; + }; + }; + - | #include From patchwork Mon Mar 13 16:50:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco Dolcini X-Patchwork-Id: 68970 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1308727wrd; Mon, 13 Mar 2023 10:20:48 -0700 (PDT) X-Google-Smtp-Source: AK7set/ZDd2aFsNa6WgBD4ErUD/3msKsVI0uYmX2jBTDmj3hh/bv7LGoXFU9qmrmxksxPXFbbHZS X-Received: by 2002:a05:6a20:1446:b0:d0:4f09:219a with SMTP id a6-20020a056a20144600b000d04f09219amr26058737pzi.39.1678728048614; Mon, 13 Mar 2023 10:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678728048; cv=none; d=google.com; s=arc-20160816; b=0iYg53eXM7LzcvXsxA2qzEGlUieBHJfHjh7Tgizuy06aBw5JVb0SXVjD/AUI3+lGFg EUS6HMFIaj9kjzf+IwOr+m+ryV4R4/ODYxJArLaDKu2sUqMkEHtt/tptkepy8D8r7Zjr UW7rGRRKVwt072J/IcTINrYcz1DQmW4sX2hICYlJaaW3DmTwrnG/yqZ+S8o1ggb1GNz8 B2T8b1iNQsVaf6CYRIPFeSRyYLINbwWAzTKVKduPA7deLfInV/I6ReIRwYlmcvXIaNch oaGNP1WL3jdbMJTT0PXhQbKMZE0xfH0L97EJQbLN347XC9bg5YSf1XHNkFpiZDCz7dyo tuEA== 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=nasbzwN0xB3MOq5gUlrdHJZcOlFJw7ZcAfo6atxX/2Y=; b=P0339Ot9Sfi8QScnYfzIfNmmbBObwc8G5kJhFJ258F/mlAJFylRMnuB3WRppiCdnQ7 mAFo0j52pVQRq5yUaGxDQQ85Ql23w16CbTonlvVmJkXAVPrQS8EqE1qFX2/IOIUJtHRd fT5LWPjsStor8FD35Gvzqj+j6zlsSk+AdVVBghUf4GJgrdcggUczNtLeLDcXf7rTTuZp 9AomlPbIug5ki5gAbcKufTJTIoyfz53d6h6mYk6mKPCwfMgdi+inY5KGUVlbRqf0lRrd owQTOCyf/Q4DY6eUBLHnD1wOgZFz+pBeMoVdWLdVow35UxEW4rPKAIJK/+0mPDzX++Xb HZ9g== 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 13-20020a62170d000000b005a91e757a39si6860273pfx.169.2023.03.13.10.20.35; Mon, 13 Mar 2023 10:20:48 -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 S231161AbjCMQ45 (ORCPT + 99 others); Mon, 13 Mar 2023 12:56:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230325AbjCMQ4r (ORCPT ); Mon, 13 Mar 2023 12:56:47 -0400 Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AF070402; 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 23A2F21E2A; 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 2/3] usb: misc: usb3503: refactor code to prepare for usb3803 addition Date: Mon, 13 Mar 2023 17:50:38 +0100 Message-Id: <20230313165039.255579-3-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?1760273941871639590?= X-GMAIL-MSGID: =?utf-8?q?1760273941871639590?= From: Emanuele Ghidoli Refactor code to simplify adding support for USB3803 and bypass mode. Remove static usb3503_reset() and move it to usb3503_switch_mode(), with the addition of the bypass mode we need to drive the various control signals to the expected configuration, not just to assert/release the reset. In addition to that the usb3503_connect() needs to be called only for HUB mode. No functional changes expected nor intended because of this change. Signed-off-by: Emanuele Ghidoli Signed-off-by: Francesco Dolcini --- drivers/usb/misc/usb3503.c | 44 ++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index bd47c4437ca4..3044db9fd8aa 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -52,28 +52,11 @@ struct usb3503 { bool secondary_ref_clk; }; -static int usb3503_reset(struct usb3503 *hub, int state) -{ - if (!state && hub->connect) - gpiod_set_value_cansleep(hub->connect, 0); - - if (hub->reset) - gpiod_set_value_cansleep(hub->reset, !state); - - /* Wait T_HUBINIT == 4ms for hub logic to stabilize */ - if (state) - usleep_range(4000, 10000); - - return 0; -} - static int usb3503_connect(struct usb3503 *hub) { struct device *dev = hub->dev; int err; - usb3503_reset(hub, 1); - if (hub->regmap) { /* SP_ILOCK: set connect_n, config_n for config */ err = regmap_write(hub->regmap, USB3503_SP_ILOCK, @@ -126,25 +109,36 @@ 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 err = 0; + int rst, conn; switch (mode) { case USB3503_MODE_HUB: - err = usb3503_connect(hub); + conn = 1; + rst = 0; break; - case USB3503_MODE_STANDBY: - usb3503_reset(hub, 0); + conn = 0; + rst = 1; dev_info(dev, "switched to STANDBY mode\n"); break; - default: dev_err(dev, "unknown mode is requested\n"); - err = -EINVAL; - break; + return -EINVAL; } - return err; + if (!conn && hub->connect) + gpiod_set_value_cansleep(hub->connect, 0); + + if (hub->reset) + gpiod_set_value_cansleep(hub->reset, rst); + + if (conn) { + /* Wait T_HUBINIT == 4ms for hub logic to stabilize */ + usleep_range(4000, 10000); + return usb3503_connect(hub); + } + + return 0; } static const struct regmap_config usb3503_regmap_config = { 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 {