From patchwork Mon Oct 28 21:59:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216703 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E1C1139A for ; Mon, 28 Oct 2019 22:00:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A3D9218AC for ; Mon, 28 Oct 2019 22:00:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aiGKojzf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390042AbfJ1V71 (ORCPT ); Mon, 28 Oct 2019 17:59:27 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37383 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389866AbfJ1V7Z (ORCPT ); Mon, 28 Oct 2019 17:59:25 -0400 Received: by mail-pg1-f194.google.com with SMTP id p1so7909278pgi.4 for ; Mon, 28 Oct 2019 14:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GYRc8Evk3wu8EUiuELp77RSTyUut+SJabJSgyybQCKc=; b=aiGKojzfX0avTva88b+Xf7Ycb1D84K+JUiiDZe8pxySNsgiNblOjP/0rEBus9uVwFy ry7jgeDbO5rYlhDY3nigJVxjosnZT+JsbJwQQMwTADrRUPh1W6luNUOyK/bKwsZop+V0 tv4rLM+oQ4ikK7IlwEgNicJh1z7AL3q/L+EPrECleyeatF29bxEdswku9u4yzoZ5Aexs ULxCVuo4HEcivtAM8axTxG7Dx6uqJKmuwi48dMUCXUdQF0n/EcPJlK/HDz9pYQ9UH0Vx 6BPRmIG4CPgtqSxeBpJc0cZx/KCEIewJ4TbVg8G0KbGRGmaEZcHxjTLjezesX65OejFs FLcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GYRc8Evk3wu8EUiuELp77RSTyUut+SJabJSgyybQCKc=; b=EswESa9NtE6LkGCPG7avLspPtAemIN9TMYIBdKCDYHvosa+mZCrKB9s5EQIHTxRdLW eqGFROze3kuumfFY2eFeuqEEEwLijSHob225PAs2AgcNHs0TeNSMRmSkzRYclj1e2Wd3 gn3ZNLz+pkO9hptvcyYf15UJ0dHeElV1kPvx2JCtkkvaDxKOAx8v7fsDSwD1WcyvNjhO Lan8NkDTzEitNHLfos1sC8X+tkrApmOx/cRH+FVIlFYVMKsNAlR1GKlijwE9tR12gk1Y RR8yBBVyB2AMI0GWZt17hkVzpSK9G1ici1+1GKJ4P6fSzu2YlAQNB2hRwN/ldqY6cx3M otMg== X-Gm-Message-State: APjAAAWaI7svI4EQ3m2Y+y0tF0W2q558FmTHnSFGBiQ6gcByNWw1CzQ3 TFOtsvsd9mlycnTAS8CeberD0w== X-Google-Smtp-Source: APXvYqyBQEq+GyX9s9DcVAsO/5XEDStC7aBeHJL3KSIfp2K/5xIaHqQr6/nGowmVcOrYfSGZ5tHZhA== X-Received: by 2002:a65:4bcd:: with SMTP id p13mr23366871pgr.80.1572299964451; Mon, 28 Oct 2019 14:59:24 -0700 (PDT) Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:23 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Yu Chen , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 1/9] dt-bindings: usb: rt1711h: Add connector bindings Date: Mon, 28 Oct 2019 21:59:11 +0000 Message-Id: <20191028215919.83697-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add connector binding documentation for Richtek RT1711H Type-C chip driver It was noted by Rob Herring that the rt1711h binding docs doesn't include the connector binding. Thus this patch adds such documentation following the details in Documentation/devicetree/bindings/usb/typec-tcpci.txt Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Reviewed-by: Rob Herring Signed-off-by: John Stultz --- .../bindings/usb/richtek,rt1711h.txt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt b/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt index d4cf53c071d9..e3fc57e605ed 100644 --- a/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt +++ b/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt @@ -6,10 +6,39 @@ Required properties: - interrupts : where a is the interrupt number and b represents an encoding of the sense and level information for the interrupt. +Required sub-node: +- connector: The "usb-c-connector" attached to the tcpci chip, the bindings + of connector node are specified in + Documentation/devicetree/bindings/connector/usb-connector.txt + Example : rt1711h@4e { compatible = "richtek,rt1711h"; reg = <0x4e>; interrupt-parent = <&gpio26>; interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + + usb_con: connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + power-role = "dual"; + try-power-role = "sink"; + source-pdos = ; + sink-pdos = ; + op-sink-microwatt = <10000000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + usb_con_ss: endpoint { + remote-endpoint = <&usb3_data_ss>; + }; + }; + }; + }; }; From patchwork Mon Oct 28 21:59:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216705 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEADA139A for ; Mon, 28 Oct 2019 22:00:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A38821835 for ; Mon, 28 Oct 2019 22:00:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uaUmY97o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389904AbfJ1V71 (ORCPT ); Mon, 28 Oct 2019 17:59:27 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35056 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389644AbfJ1V70 (ORCPT ); Mon, 28 Oct 2019 17:59:26 -0400 Received: by mail-pg1-f194.google.com with SMTP id c8so7916073pgb.2 for ; Mon, 28 Oct 2019 14:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+L6QotxBXClg8Fe4NEIvH2M7vhWfz5AENh5gfCd6GV4=; b=uaUmY97oSQxJQiygHKDaQ20ZTGg8dHh2CBe6oCjliV/RN29TrGpIx4ib9OqXas8o3L VGfHqIuml3QwWjby0s2prmA2YMmiKWQVFFb1lAwmvGl498yOYU5Uls0CSQZ34KDFix43 G6JAmKHK8ywTaqFjTUQP00S7zXpDubMfH1Tir+VrVpTGeF7pp/x/zIimRziEyXRoQMht x7W2cxF8KEa5n6o6m8KFmj7LejeivOjoMf2XtSHXLftGcJYpn6KXhdcqvG0pZZJ4idlx kQxDcknr/f6WferMNpA/Vd7V+YIZo/bspA5ekOGZIugueMatX0phDtpfNMw5J5ckn8sF 6leg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+L6QotxBXClg8Fe4NEIvH2M7vhWfz5AENh5gfCd6GV4=; b=K5BgwjagSgl4FbunXr6VQ8W9qYuB+6sfiV0Ucf/Z93s2C/ePZn2HyWret1aSXQuJlp Y4fPIXi8Ky5JH0HIal5rCYUJ6Ok+vQYxAR3esv9wNgPuvAnIIo4UOQwC/RAqS/KrNlZ2 Fzp6S9YBmvNGVZm6FeTewQS/eJoBD2KFKnkpuAWogbVGkBU5jjkZDTGT26DIJ7AVEXSH laM8/49n9FGC3re+DjRCSkC9FNo43WH5mJD0xYTCjodhFM8kSh+EtQlblBf3G8PldJ/v yULWCqkssVWxNhwbnXOmwaPpTxijaYh5LbLO6LD80wBgCmt7WC0uk6LEKb47mELAvrq3 vMoA== X-Gm-Message-State: APjAAAWkt4RempnQzRMJnsCiRWnRwWiUvTZGxUse/fxIHBjS77Fbgb00 Va00WAudmm6+c2r9Bnvfi7IwdQ== X-Google-Smtp-Source: APXvYqwoT7ayq2aO4CF8CK+7fEOHyKKj3eXU3Enm6OGIp8+0wievgg8RmOqjN0WXhlj2nCmqsIIU7g== X-Received: by 2002:a63:f923:: with SMTP id h35mr23802494pgi.323.1572299965657; Mon, 28 Oct 2019 14:59:25 -0700 (PDT) Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:25 -0700 (PDT) From: John Stultz To: lkml Cc: Yu Chen , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, John Stultz Subject: [PATCH v4 2/9] usb: dwc3: Execute GCTL Core Soft Reset while switch modes Date: Mon, 28 Oct 2019 21:59:12 +0000 Message-Id: <20191028215919.83697-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Yu Chen On the HiKey960, we need to do a GCTL soft reset when switching modes. Jack Pham also noted that in the Synopsys databook it mentions performing a GCTL CoreSoftReset when changing the PrtCapDir between device & host modes. So this patch always does a GCTL Core Soft Reset when changing the mode. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: Yu Chen Signed-off-by: John Stultz --- v3: Remove quirk conditional, as Jack Pham noted the Synopsis databook states this should be done generally. Also, at Jacks' suggestion, make the reset call before changing the prtcap direction. --- drivers/usb/dwc3/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 999ce5e84d3c..a039e35ec7ad 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -112,6 +112,19 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) dwc->current_dr_role = mode; } +static void dwc3_gctl_core_soft_reset(struct dwc3 *dwc) +{ + u32 reg; + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg |= DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg &= ~DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); +} + static void __dwc3_set_mode(struct work_struct *work) { struct dwc3 *dwc = work_to_dwc(work); @@ -154,6 +167,9 @@ static void __dwc3_set_mode(struct work_struct *work) spin_lock_irqsave(&dwc->lock, flags); + /* Execute a GCTL Core Soft Reset when switch mode */ + dwc3_gctl_core_soft_reset(dwc); + dwc3_set_prtcap(dwc, dwc->desired_dr_role); spin_unlock_irqrestore(&dwc->lock, flags); From patchwork Mon Oct 28 21:59:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48BAD1599 for ; Mon, 28 Oct 2019 22:00:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 24F2F218AC for ; Mon, 28 Oct 2019 22:00:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="eKVqOuBe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbfJ1V74 (ORCPT ); Mon, 28 Oct 2019 17:59:56 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:43756 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390025AbfJ1V72 (ORCPT ); Mon, 28 Oct 2019 17:59:28 -0400 Received: by mail-pf1-f193.google.com with SMTP id 3so7872289pfb.10 for ; Mon, 28 Oct 2019 14:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NtLLzsDOIuiH39rP2uuMmF0oaTj9DHzaakbaIjXt74A=; b=eKVqOuBe2qG/OSWZsaD3gbQVQnORi6YUJToqthQFixtmU1bAKAXU6V1ldupWC6VvTw RsTMuqOIvs7Az8gxZhBzjgrhkGKRmX9qGZW+fIrHiDuDEeJLZMgyj+Yiz23bw9wfOREr 1gy4gtJ5MEfAGjn5SKvx5ks/STelDtQ4g6DKlAX9MLoSJ7+ETf+rl3nxipwO/X0YbJ04 kid2Lg+PjKbhGtco88Xw2DyknmmFVdZYVERdIKGLgbwv1F2AXXjq7WjmRyIVT9oJRoR5 I+dQGFLedmEvEqVeXZO4y+jfXBTe37AQds4D07d5UF/oXDarJbpUt6Jj34ERRyreJ5JA JttQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NtLLzsDOIuiH39rP2uuMmF0oaTj9DHzaakbaIjXt74A=; b=JtD4KQ+9DndSP7je1URItJ5zQPwkmYkoZ57EQ/Jl5B9MO6CjYuV48/lS9DSrwOfEsa cm2T5Pn2ytNNeOSsrn/C3sBajeFLQc09M6QX4izyI3/NnrYCEJvytBbnaPXKbBbrQHA9 a+ksOklowFUZ8rCxENPIYUwm2/RSTb2VXAc0IDveLPVTYTo3wDy2h5imgJgeJOQnWrf+ ezAnJu59rxuAHF3HGbaqnWPweoQDmTMTPdohjXVz2uxXlcC3WtIHXjUk/QB/IN5J3WOe LuzhrGgLsZJdC6BK2kosS2715dPiF6tdrJEn+1H5MPTqYjU6tYEM0+N7BulgGrQUw46l nroA== X-Gm-Message-State: APjAAAU9+8+F1LHrtAB0c7qnETbWtqrTF8NorY2vlHtWAQqYt3yKCGvX dBTAXD0Km7x1YU6WhbJuDia+bA== X-Google-Smtp-Source: APXvYqygibWkWPMAb7wZK/7S2yus1n7uqa1S6UdpudK6pIw6iG7qeF5t6FQaHX/vFB83z9Il5b0N2g== X-Received: by 2002:a63:67c3:: with SMTP id b186mr12427931pgc.152.1572299967053; Mon, 28 Oct 2019 14:59:27 -0700 (PDT) Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:26 -0700 (PDT) From: John Stultz To: lkml Cc: Yu Chen , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, John Stultz Subject: [PATCH v4 3/9] usb: dwc3: Increase timeout for CmdAct cleared by device controller Date: Mon, 28 Oct 2019 21:59:13 +0000 Message-Id: <20191028215919.83697-4-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Yu Chen It needs more time for the device controller to clear the CmdAct of DEPCMD on Hisilicon Kirin Soc. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: Yu Chen Signed-off-by: John Stultz --- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 86dc1db788a9..168eb4a0a9b0 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -270,7 +270,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd, { const struct usb_endpoint_descriptor *desc = dep->endpoint.desc; struct dwc3 *dwc = dep->dwc; - u32 timeout = 1000; + u32 timeout = 5000; u32 saved_config = 0; u32 reg; From patchwork Mon Oct 28 21:59:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216689 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D2A01599 for ; Mon, 28 Oct 2019 21:59:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE12221920 for ; Mon, 28 Oct 2019 21:59:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OooiMpJl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390302AbfJ1V73 (ORCPT ); Mon, 28 Oct 2019 17:59:29 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35268 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390276AbfJ1V73 (ORCPT ); Mon, 28 Oct 2019 17:59:29 -0400 Received: by mail-pf1-f195.google.com with SMTP id d13so6833698pfq.2 for ; Mon, 28 Oct 2019 14:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0d8c9xxXfq9azaoIMnpd7T7O6Htbc+6dqNsLBH6goLs=; b=OooiMpJlnthfCoHkNbKk5+ZkhnJ4zgwcMFUsDAdDdjsrni+Ym/oIzxMeoxGTl3a3Ma pj0Kyj2In07BwtHsqyedhyDIRyzCFk8VWca0Obw0bNYJee8KpxoiSfVZn9h/lVDEimRR 5Q7G8PZYX9o9NcyIuCmaj57UB8KFcVl0IMa/vqB9XHsr6tObAeq8UoChUCRlr0A+tg+y FDiVVTyCiU7MPfSums1k96+5GW/yFF3TomG9NIwun5QiuwETMTfBqMgs5F+ynDLBgAis N6Yvgsv0rfanq46H8AWZ5R45RtHTXclUhZzTB9Vxgy8K7aSh8KBxgHcQ7X1TH0E3GqOh ZeMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0d8c9xxXfq9azaoIMnpd7T7O6Htbc+6dqNsLBH6goLs=; b=uH6NQtUm2gakLf6PI+gAJbC/YA3g/tZN5qjyPPqVOHdJ9uq8jTsGqo7DLMrkDyxbGy XbL2Bira1bpIlMB9CBhN8KtAmz+eGZUaDF6jM2THOBi/vcYTyE0Km1Tfwkn28XYAZ7id ANZPbpTmNpdZHOeMQLij347/bBRbDRuIibQ+uV0zSKsEeZcU16QlacAjergxY12IjF6A 2bo24vV17560Fg8+RCcVwEHefD9r6gkOe+cn9wfh8xH1RSCooguOCqeJaAoq6LZYhGDl PLuuUnJ/+c0FagTBuRBA2ZJdppwPNeAxEQQKqFud/yc5mK29YZsf/8v+gWcVtTxCYJoq Uhkg== X-Gm-Message-State: APjAAAXyZ78MCezjTuG+Z04hNvs1iRPgxorMnfKRcgnwcHzNb3YfVju6 2Krsp6KdyTUZVVHa4vO/lrxmnA== X-Google-Smtp-Source: APXvYqxETt1r4GGA30YA4LQzxZEzUJ5jkilalooGWqJqTN8Hrs56L/j9noamumHZ8snA1JUFcFgYqA== X-Received: by 2002:a17:90a:8d82:: with SMTP id d2mr1932147pjo.31.1572299968324; Mon, 28 Oct 2019 14:59:28 -0700 (PDT) Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:27 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Yu Chen , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 4/9] dt-bindings: usb: dwc3: Allow clock list & resets to be more flexible Date: Mon, 28 Oct 2019 21:59:14 +0000 Message-Id: <20191028215919.83697-5-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Rather then adding another device specific binding to support hikey960, Rob Herring suggested we expand the current dwc3 binding to allow for variable numbers of clocks and resets. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Rob Herring Reviewed-by: Rob Herring Signed-off-by: John Stultz --- Documentation/devicetree/bindings/usb/dwc3.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 66780a47ad85..29768b0ca923 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -7,7 +7,8 @@ Required properties: - compatible: must be "snps,dwc3" - reg : Address and length of the register set for the device - interrupts: Interrupts used by the dwc3 controller. - - clock-names: should contain "ref", "bus_early", "suspend" + - clock-names: list of clock names. Ideally should be "ref", + "bus_early", "suspend" but may be less or more. - clocks: list of phandle and clock specifier pairs corresponding to entries in the clock-names property. @@ -36,7 +37,7 @@ Optional properties: - phys: from the *Generic PHY* bindings - phy-names: from the *Generic PHY* bindings; supported names are "usb2-phy" or "usb3-phy". - - resets: a single pair of phandle and reset specifier + - resets: set of phandle and reset specifier pairs - snps,usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable - snps,dis-start-transfer-quirk: when set, disable isoc START TRANSFER command From patchwork Mon Oct 28 21:59:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89A62913 for ; Mon, 28 Oct 2019 21:59:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6715121924 for ; Mon, 28 Oct 2019 21:59:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lMEc5oJe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390341AbfJ1V7b (ORCPT ); Mon, 28 Oct 2019 17:59:31 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38788 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390321AbfJ1V7a (ORCPT ); Mon, 28 Oct 2019 17:59:30 -0400 Received: by mail-pf1-f196.google.com with SMTP id c13so7892498pfp.5 for ; Mon, 28 Oct 2019 14:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Sf5eKNCSIBpNdFo6pBKVICUJYVHElXUrV/RD8eO146c=; b=lMEc5oJeuYWUcVxXpphSMAIRavQ29nAcI5d2oKIF5KsDKcFZnIO8Rcwx8rlC2A8Zf/ CF5EjelirIgQYnWaDQFgrG7r+Oh+liDGWYseTgIuogkTucMwvA9ZsP/LheVHE/zFsbcS MpnCEZ0dr7M6+w8sAnEgZXE/TPEx6kssrdjMLA9cAPy4zvF/Q7Z084sRASR5cfwrE156 Dq2WaWlxclZJyvBepM8NvQKGSkQV4UrmPKJjFOsfHATm/IoZihLaQwjrWyKTuHXgICUq DI5KCli3WtY+muIL2MpvQmZSAfF1FcdKcY0GT06yRWMhwtT4FmfKoizuKQyE3WTTIj8a t4yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Sf5eKNCSIBpNdFo6pBKVICUJYVHElXUrV/RD8eO146c=; b=Jh9pgYi48jekfOWDocx1Bux/MLL0ys5FZAdfGCdoQZLCaNAAHdiCJ65ad9wvTGnhK7 pBFoDF8TcMKkLqxqFmkCR3dxcrZ1yw185an1OvlrT0sElKaX7t/nBtp/jZsU3d0VSXGd q9J7klEclifDefkCeitvR8UBN3hzUmhPCi0WSOkIIKCf5cuqnp4uvWiJ8fLK69uHcHNg okEzfvxwp8sKTbnRYxcmipgPAhzpcpx8kNCsGVr/iQv6kllqKn160XVLTFkTo5ZfpGvX Le9sHz3R8ZV82G++hbR7IOM0Fh+HsBfKR4fwiz39hRXKfjfldUfO65qbmmKR8aG/pBKX sMWQ== X-Gm-Message-State: APjAAAXUBz36yx26l0+asbGCaXRyNuEYSAprjFhIPZG5gvIYEpHkOBRd N6I3WkWJqbzmqXVKscKFDVRjZQ== X-Google-Smtp-Source: APXvYqzV4dIrv4WayXRoBFG9n15lx1cNIer3M6DVGTDjqIPPzgjtWxEe21YsXYhKjId/Zy5mg6XkmQ== X-Received: by 2002:a62:5c07:: with SMTP id q7mr22638078pfb.159.1572299969484; Mon, 28 Oct 2019 14:59:29 -0700 (PDT) Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:28 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Yu Chen , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 5/9] usb: dwc3: Rework clock initialization to be more flexible Date: Mon, 28 Oct 2019 21:59:15 +0000 Message-Id: <20191028215919.83697-6-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The dwc3 core binding specifies three clocks: ref, bus_early, and suspend which are all controlled in the driver together. However some variants of the hardware my not have all three clks So this patch reworks the reading of the clks from the dts to use devm_clk_bulk_get_all() will will fetch all the clocks specified in the dts together. This patch was reccomended by Rob Herring as an alternative to creating multiple bindings for each variant of hardware when the only unique bits were clocks and resets. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Rob Herring Signed-off-by: John Stultz --- v3: Rework dwc3 core rather then adding another dwc-of-simple binding. --- drivers/usb/dwc3/core.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a039e35ec7ad..4d4f1836b62c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -305,12 +305,6 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) return 0; } -static const struct clk_bulk_data dwc3_core_clks[] = { - { .id = "ref" }, - { .id = "bus_early" }, - { .id = "suspend" }, -}; - /* * dwc3_frame_length_adjustment - Adjusts frame length if required * @dwc3: Pointer to our controller context structure @@ -1418,11 +1412,6 @@ static int dwc3_probe(struct platform_device *pdev) if (!dwc) return -ENOMEM; - dwc->clks = devm_kmemdup(dev, dwc3_core_clks, sizeof(dwc3_core_clks), - GFP_KERNEL); - if (!dwc->clks) - return -ENOMEM; - dwc->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1458,17 +1447,18 @@ static int dwc3_probe(struct platform_device *pdev) return PTR_ERR(dwc->reset); if (dev->of_node) { - dwc->num_clks = ARRAY_SIZE(dwc3_core_clks); - - ret = devm_clk_bulk_get(dev, dwc->num_clks, dwc->clks); + ret = devm_clk_bulk_get_all(dev, &dwc->clks); if (ret == -EPROBE_DEFER) return ret; /* * Clocks are optional, but new DT platforms should support all * clocks as required by the DT-binding. */ - if (ret) + if (ret < 0) dwc->num_clks = 0; + else + dwc->num_clks = ret; + } ret = reset_control_deassert(dwc->reset); From patchwork Mon Oct 28 21:59:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216697 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D38F2913 for ; Mon, 28 Oct 2019 21:59:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1DF321924 for ; Mon, 28 Oct 2019 21:59:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ai1HB2gk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733172AbfJ1V7v (ORCPT ); Mon, 28 Oct 2019 17:59:51 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34474 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390333AbfJ1V7b (ORCPT ); Mon, 28 Oct 2019 17:59:31 -0400 Received: by mail-pg1-f196.google.com with SMTP id e4so3609980pgs.1 for ; Mon, 28 Oct 2019 14:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7OkAbKqeK5UAQaAqjCwbs8uW675j/BSDdsRWiE3W8aU=; b=Ai1HB2gk9lrqHztEC4ZHzPtyWt6AhILNoXDJsOU4uocb3Mo/r7ybCc2lWBLviVG2N4 2WfVuv1aWQtHng83gZz0etX1FhVI9HBvVDGvYj4oHX7GLNHq6c7IqOVFfFmlsEJ3u6V2 01kHeUfxJOkJsRUMTL7H/2IMUmPIRLQyYYkYzgYMM7GYjCFqWaEsAfxq9yg2r0HLw5gx d+dlFHHWxtXtR7TBChXd90oVqVYIHxOgcRJyOiw3zfcoappJREjdXKXhbPPe700BWOHl vKLkbx8vDz8s5mBsPYA/b56+OkDHPAHSKuWohftBaNZf+cnRCSNHOkBwDpEWHEe2MWd3 zEgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7OkAbKqeK5UAQaAqjCwbs8uW675j/BSDdsRWiE3W8aU=; b=qS7WaPYCcqQJ7LroNe4iN3SSu3VSzWE/IW4pLzjXY5kkfVS4YBH4Q+ORhtUKHDfgzi t1JqEnPiJarhxwFVwoBzS5d/bZkAHfw6hJHwyQaEi+LWbZG16xO/ax4uO5QXawbLXxGE ZvAbH70wp+aMFshkjpyxtW1WRizNiJu28vnS+B9bDh/KLpC2YHvdB1reXgFy9qiWgI3t sKYa87JVdImuSWYuhg6Ra9UN0i3AMzgetxVO0L3A1rVKqOG/wEDd3YnL/wSNBDR+duNo k8o6IyUuxfNmCBbKb592ul8CjyDWqHNKlsLVT/xaiNmg5DSAuYrd/3+cvnEEYO40+lDm hCOw== X-Gm-Message-State: APjAAAWpNsJO5iRvWJuCrAGw/Uj1dexRYLw9IzrGx1WfbOwuYEngA5Y6 zpeZkNpi8RKTBlfcSvxGmHGCGw== X-Google-Smtp-Source: APXvYqxHxifqq5Xfv4B4vIzQhfZKh/YWkRZppo1k5WzU2a3NOH7qey4U6MAmtNictRTF7mgCEmNVYg== X-Received: by 2002:a17:90a:a406:: with SMTP id y6mr1962404pjp.106.1572299970594; Mon, 28 Oct 2019 14:59:30 -0700 (PDT) Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:30 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Yu Chen , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 6/9] usb: dwc3: Rework resets initialization to be more flexible Date: Mon, 28 Oct 2019 21:59:16 +0000 Message-Id: <20191028215919.83697-7-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The dwc3 core binding specifies one reset. However some variants of the hardware my not have more. So this patch reworks the reading of the resets to fetch all the resets specified in the dts together. This patch was reccomended by Rob Herring as an alternative to creating multiple bindings for each variant of hardware when the only unique bits were clocks and resets. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Rob Herring Signed-off-by: John Stultz --- v3: Rework dwc3 core rather then adding another dwc-of-simple binding. --- drivers/usb/dwc3/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 4d4f1836b62c..ef52ffa5d6cb 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1442,7 +1442,7 @@ static int dwc3_probe(struct platform_device *pdev) dwc3_get_properties(dwc); - dwc->reset = devm_reset_control_get_optional_shared(dev, NULL); + dwc->reset = devm_reset_control_array_get(dev, true, true); if (IS_ERR(dwc->reset)) return PTR_ERR(dwc->reset); From patchwork Mon Oct 28 21:59:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 214F11599 for ; Mon, 28 Oct 2019 21:59:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8DD3218AC for ; Mon, 28 Oct 2019 21:59:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jtq8DkDU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390533AbfJ1V7p (ORCPT ); Mon, 28 Oct 2019 17:59:45 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34476 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390380AbfJ1V7c (ORCPT ); Mon, 28 Oct 2019 17:59:32 -0400 Received: by mail-pg1-f195.google.com with SMTP id e4so3610011pgs.1 for ; Mon, 28 Oct 2019 14:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2PoKh0+SG7fHxZLJh2y0Lp0GiZzbHmOzaEb4WWk+/NM=; b=jtq8DkDU85+tWa5fMiuxfSrNXrOQgEmC8+IDRnrHBezQLj247d9yekLtAIznO6Prie wPUz7MSxEShqqeJSanC/nCU7uStI9N8Lk2om8Wh/BJaRZjP3HAaB3BOi97vojCn5RFy2 KGz5xu43Vt0XSePO993dqP8VwNOOdXzgk+0ycp50RguFNhXcYWqitoF0HNR1fCs4kQqi a3f+DCBzla+HnfQ5FoKqIZdnXYXfT3ZNnMcMSqukeWLdSdO/9HkMXPeUATZ5LIDj6Fgz lGFxZWIKIK+ipsTqIe4ZZI/MHbNgC6Tvq991FpdeTZVkp8uAmWhOJ0WoXrFpvsnYyMVw 3jsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2PoKh0+SG7fHxZLJh2y0Lp0GiZzbHmOzaEb4WWk+/NM=; b=ZH4YMH/yuWLtd4bBK3lYNKvheKl+AuJQs3hVzVKwwYlutrKfIkH0u4fLQttogg1nCO VYFvl+/tKswXp9VOb5Dkqc923ogRAdoRds2kRPWcNCZOWW6Fy2G0hDeTpxcPrJvJX7jn jr+uIuaGq6hjYgyEPZSrrbVY4j+nAP3/84FQQADXDbMGy0m424r4CBWlSt+OKrBnmyFn nkbZsEnF5/f60mZdfZnfFTyJ2qPIZdkw28qn6BrVvVYY1lwzDWcghxALcm9pgvDM9K0n WoS5DywfH04MUB5UWpPM36NN/tk+B2VIEv3EcpYQVETyJCA8Pwvl6hSWGgVwr7xGX85u jdRw== X-Gm-Message-State: APjAAAUOd3x4W5ZvyKutH9kilWw2e0ANzUPb5wvhTWWOhVr1dmxjB5Xs szaKzonENQIGC2hm7wJN6JLTwA== X-Google-Smtp-Source: APXvYqyB0veo2JoPN5PQxtdCEJGuF1tkFG2bXoqpXtYA4SKF7I8LnvDDhFJGFXhzdbKdmtPQDJMhkA== X-Received: by 2002:a62:e10c:: with SMTP id q12mr13903809pfh.248.1572299971714; Mon, 28 Oct 2019 14:59:31 -0700 (PDT) Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:31 -0700 (PDT) From: John Stultz To: lkml Cc: Yu Chen , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, John Stultz Subject: [PATCH v4 7/9] usb: dwc3: Registering a role switch in the DRD code. Date: Mon, 28 Oct 2019 21:59:17 +0000 Message-Id: <20191028215919.83697-8-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Yu Chen The Type-C drivers use USB role switch API to inform the system about the negotiated data role, so registering a role switch in the DRD code in order to support platforms with USB Type-C connectors. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Heikki Krogerus Signed-off-by: Yu Chen Signed-off-by: John Stultz --- v2: Fix role_sw and role_switch_default_mode descriptions as reported by kbuild test robot v3: Split out the role-switch-default-host logic into its own patch --- drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/core.h | 3 ++ drivers/usb/dwc3/drd.c | 66 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 89abc6078703..1104745c41a9 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -44,6 +44,7 @@ config USB_DWC3_DUAL_ROLE bool "Dual Role mode" depends on ((USB=y || USB=USB_DWC3) && (USB_GADGET=y || USB_GADGET=USB_DWC3)) depends on (EXTCON=y || EXTCON=USB_DWC3) + select USB_ROLE_SWITCH help This is the default mode of working of DWC3 controller where both host and gadget features are enabled. diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 1c8b349379af..6f19e9891767 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -951,6 +952,7 @@ struct dwc3_scratchpad_array { * @hsphy_mode: UTMI phy mode, one of following: * - USBPHY_INTERFACE_MODE_UTMI * - USBPHY_INTERFACE_MODE_UTMIW + * @role_sw: usb_role_switch handle * @usb2_phy: pointer to USB2 PHY * @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY @@ -1084,6 +1086,7 @@ struct dwc3 { struct extcon_dev *edev; struct notifier_block edev_nb; enum usb_phy_interface hsphy_mode; + struct usb_role_switch *role_sw; u32 fladj; u32 irq_gadget; diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index c946d64142ad..61d4fd8aead4 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -476,6 +476,52 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) return edev; } +static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role) +{ + struct dwc3 *dwc = dev_get_drvdata(dev); + u32 mode; + + switch (role) { + case USB_ROLE_HOST: + mode = DWC3_GCTL_PRTCAP_HOST; + break; + case USB_ROLE_DEVICE: + mode = DWC3_GCTL_PRTCAP_DEVICE; + break; + default: + mode = DWC3_GCTL_PRTCAP_DEVICE; + break; + } + + dwc3_set_mode(dwc, mode); + return 0; +} + +static enum usb_role dwc3_usb_role_switch_get(struct device *dev) +{ + struct dwc3 *dwc = dev_get_drvdata(dev); + unsigned long flags; + enum usb_role role; + + spin_lock_irqsave(&dwc->lock, flags); + switch (dwc->current_dr_role) { + case DWC3_GCTL_PRTCAP_HOST: + role = USB_ROLE_HOST; + break; + case DWC3_GCTL_PRTCAP_DEVICE: + role = USB_ROLE_DEVICE; + break; + case DWC3_GCTL_PRTCAP_OTG: + role = dwc->current_otg_role; + break; + default: + role = USB_ROLE_DEVICE; + break; + } + spin_unlock_irqrestore(&dwc->lock, flags); + return role; +} + int dwc3_drd_init(struct dwc3 *dwc) { int ret, irq; @@ -484,7 +530,22 @@ int dwc3_drd_init(struct dwc3 *dwc) if (IS_ERR(dwc->edev)) return PTR_ERR(dwc->edev); - if (dwc->edev) { + if (device_property_read_bool(dwc->dev, "usb-role-switch")) { + struct usb_role_switch_desc dwc3_role_switch = {NULL}; + u32 mode; + + mode = DWC3_GCTL_PRTCAP_DEVICE; + + dwc3_role_switch.fwnode = dev_fwnode(dwc->dev); + dwc3_role_switch.set = dwc3_usb_role_switch_set; + dwc3_role_switch.get = dwc3_usb_role_switch_get; + dwc->role_sw = usb_role_switch_register(dwc->dev, + &dwc3_role_switch); + if (IS_ERR(dwc->role_sw)) + return PTR_ERR(dwc->role_sw); + + dwc3_set_mode(dwc, mode); + } else if (dwc->edev) { dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST, &dwc->edev_nb); @@ -531,6 +592,9 @@ void dwc3_drd_exit(struct dwc3 *dwc) { unsigned long flags; + if (dwc->role_sw) + usb_role_switch_unregister(dwc->role_sw); + if (dwc->edev) extcon_unregister_notifier(dwc->edev, EXTCON_USB_HOST, &dwc->edev_nb); From patchwork Mon Oct 28 21:59:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE1491599 for ; Mon, 28 Oct 2019 21:59:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB07A21924 for ; Mon, 28 Oct 2019 21:59:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yK8XTi+y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390436AbfJ1V7e (ORCPT ); Mon, 28 Oct 2019 17:59:34 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41103 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390423AbfJ1V7d (ORCPT ); Mon, 28 Oct 2019 17:59:33 -0400 Received: by mail-pg1-f193.google.com with SMTP id l3so7891565pgr.8 for ; Mon, 28 Oct 2019 14:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PwMMZk9WZCsU4Du96enXrC4F3u/XmD+gFRyu+Xx8uI0=; b=yK8XTi+yTqTvJtzBmsrxxZLC61ETTwPZxqGYnTbkgxYjA6GIs/gPQoC01K2sxBxzFl MMEwxtYn+EJXpjSvIP6eGGl7wmPAW+jGbqWOHspOj7EiQko05VJsEfSp1MN18G1jOUEU /5vTuSj/FWaKNs2T4pu58ii6asJl3R5vuhWgK6r81QFP2V0ka7iE7k4OCpik8Nm6QAy/ 60it1XUz8BIpKv+SwD5N6xFqcNCU49JuBRhvm4ufv4JLjR081Bk5Hwi2cJwsZDpPF1/P DuxqNluasrbfqixUPmc41KVHc9FIFjCHiqGdjiSmYwyl9wuBRQpRJs6hkDEtjHnf22EU /0MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PwMMZk9WZCsU4Du96enXrC4F3u/XmD+gFRyu+Xx8uI0=; b=FZMdSiWa3gKJ/JdKN9by+K7CQPhEqtdC1ORMIYQ4nRSUxscwxYzLFyVFHStdmeZTJz IIMYHybGzsVqHq376ckm0vZauRJwJIEl3XOTQDCX3FVEM634U0MuzOpk6qwqpYI6w8dG 2UE9+MqADGlLzWuZhstlN7GzyyXCwXRKMhFVLI1f5qQOyZ7WS06eHhVbt2h7SF7AUzIK 9bAJvuiqpXYWhUgRAtHT5AKNzd5ZtSHS5Nw9ol2juZIsaRfDFEgzwsvIM8eNpbewLUui kXtinBMZF9V233RGpXDHrxjLNHGYE8dRL4SaORtGFn7KwsZNRsK4z2lWFbpw4a5PYYcZ 15BA== X-Gm-Message-State: APjAAAUgD1iV0FUkaNll1cyjdxpbrlwlDm6Eo/ITEbLUPizOIf0sKfql fEicp3RrD3UOrNY4JLOIBrLcrQ== X-Google-Smtp-Source: APXvYqw+lIWkxCOYZfgUieLhn03j3Firptukiq0WcBWbrHmeAQRBK9que/SoMHJEv+L5UyY/O19Z1Q== X-Received: by 2002:a17:90a:a616:: with SMTP id c22mr1907346pjq.61.1572299972866; Mon, 28 Oct 2019 14:59:32 -0700 (PDT) Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:32 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Yu Chen , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 8/9] dt-bindings: usb: generic: Add role-switch-default-host binding Date: Mon, 28 Oct 2019 21:59:18 +0000 Message-Id: <20191028215919.83697-9-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add binding to configure the default role the controller assumes is host mode when the usb role is USB_ROLE_NONE. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Reviewed-by: Rob Herring Signed-off-by: John Stultz --- Documentation/devicetree/bindings/usb/generic.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt index cf5a1ad456e6..013782fde293 100644 --- a/Documentation/devicetree/bindings/usb/generic.txt +++ b/Documentation/devicetree/bindings/usb/generic.txt @@ -34,6 +34,11 @@ Optional properties: the USB data role (USB host or USB device) for a given USB connector, such as Type-C, Type-B(micro). see connector/usb-connector.txt. + - role-switch-default-host: boolean, indicating if usb-role-switch is enabled + the device default operation mode of controller while + usb role is USB_ROLE_NONE is host mode. If this is not + set or false, it will be assumed the default is device + mode. This is an attribute to a USB controller such as: From patchwork Mon Oct 28 21:59:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11216691 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B7DF913 for ; Mon, 28 Oct 2019 21:59:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D473A21835 for ; Mon, 28 Oct 2019 21:59:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ks8Q41j1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390485AbfJ1V7g (ORCPT ); Mon, 28 Oct 2019 17:59:36 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35927 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390397AbfJ1V7f (ORCPT ); Mon, 28 Oct 2019 17:59:35 -0400 Received: by mail-pf1-f193.google.com with SMTP id v19so7896220pfm.3 for ; Mon, 28 Oct 2019 14:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9P5p/4dcNs8ql4OyOSsDmP/Eo0cfZOKgwuYqI45wfJg=; b=ks8Q41j1ZqA/QKFHT472CH12EK/nGPhBNjUH0WKFQdpFsYiFWCGlWyyocdHfUnLMFa ilBT83QeApQCioM8MCcBVzcBTr7L16ZzSYSrlsZ3svQz3Qbmu5mSay4FCb/9m1XsUVU2 c1YR0FZ10+gBGjO9pUj9XMLVRV8DYgv7q+bju8Xop7n6vZQ9f1jfJDxhERBpjloaB6fy zHrBQ6YHV8IMq095CL+xzpfQDJxCaC6+b2Lj4lm6/v2LPLFB/3kHTtdPCO9b075ZTy59 KdY31qCinVxER1+Qe5BFmn6E1SYTIZ5dzMigy+dADU7kWpKK4lDLBXZWyamHz7NfObM5 BpUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9P5p/4dcNs8ql4OyOSsDmP/Eo0cfZOKgwuYqI45wfJg=; b=RCT1MOm3qsKcXAMgpaibPLYW3B+fJyAUTB18ifyebY1rAABmppMTcFym/JKlZhF1L9 4C9JtrUSC9SHFeTPXQmCdefSgZRXXT1hGk04rwRtBJPsmi7GsFoCV4pCJ1PPBfDTRRke kzJcFPkSIC6ZoF16EIdy8p2w8vv6fScr2Uaz4uWFSRH4qQ3Em+Ou2tSdjPJ2qG0pDRXN 1mT7NXoiphXjhAe1kWI/28z8e4K5JsfWTTv2l0p8Hi0bup9g/9nT7MePFhYqGbObLCJ0 OkRAEhioHM+ed4Vmgc+layUdEWXK1m7M8nqy5pPaAKqPQ1EAuByMTbhmLXN6rGFK81xL I4hg== X-Gm-Message-State: APjAAAU5qV02J+taWfTLPEcW2rkCllDanAZWuqN+qzrPiS7DQnNpyOvY RwIfvaLwXI5z5HJ/g4W2ord8vw== X-Google-Smtp-Source: APXvYqyzWZOig+RfCXgpnHo7l5IBFBeACyeBjNjdSXrji1GSa9dz+HugwTGG5QUBsQUIQSVHRSs/1A== X-Received: by 2002:a17:90a:1050:: with SMTP id y16mr1902116pjd.59.1572299974196; Mon, 28 Oct 2019 14:59:34 -0700 (PDT) Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:33 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Yu Chen , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 9/9] usb: dwc3: Add host-mode as default support Date: Mon, 28 Oct 2019 21:59:19 +0000 Message-Id: <20191028215919.83697-10-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Support configuring the default role the controller assumes as host mode when the usb role is USB_ROLE_NONE This patch was split out from a larger patch originally by Yu Chen Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: John Stultz --- v3: Split this patch out from addition of usb-role-switch handling --- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/drd.c | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 6f19e9891767..3c879c9ab1aa 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -953,6 +953,8 @@ struct dwc3_scratchpad_array { * - USBPHY_INTERFACE_MODE_UTMI * - USBPHY_INTERFACE_MODE_UTMIW * @role_sw: usb_role_switch handle + * @role_switch_default_mode: default operation mode of controller while + * usb role is USB_ROLE_NONE. * @usb2_phy: pointer to USB2 PHY * @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY @@ -1087,6 +1089,7 @@ struct dwc3 { struct notifier_block edev_nb; enum usb_phy_interface hsphy_mode; struct usb_role_switch *role_sw; + enum usb_dr_mode role_switch_default_mode; u32 fladj; u32 irq_gadget; diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 61d4fd8aead4..0e3466fe5ac4 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -489,7 +489,10 @@ static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role) mode = DWC3_GCTL_PRTCAP_DEVICE; break; default: - mode = DWC3_GCTL_PRTCAP_DEVICE; + if (dwc->role_switch_default_mode == USB_DR_MODE_HOST) + mode = DWC3_GCTL_PRTCAP_HOST; + else + mode = DWC3_GCTL_PRTCAP_DEVICE; break; } @@ -515,7 +518,10 @@ static enum usb_role dwc3_usb_role_switch_get(struct device *dev) role = dwc->current_otg_role; break; default: - role = USB_ROLE_DEVICE; + if (dwc->role_switch_default_mode == USB_DR_MODE_HOST) + role = USB_ROLE_HOST; + else + role = USB_ROLE_DEVICE; break; } spin_unlock_irqrestore(&dwc->lock, flags); @@ -534,8 +540,14 @@ int dwc3_drd_init(struct dwc3 *dwc) struct usb_role_switch_desc dwc3_role_switch = {NULL}; u32 mode; - mode = DWC3_GCTL_PRTCAP_DEVICE; - + if (device_property_read_bool(dwc->dev, + "role-switch-default-host")) { + dwc->role_switch_default_mode = USB_DR_MODE_HOST; + mode = DWC3_GCTL_PRTCAP_HOST; + } else { + dwc->role_switch_default_mode = USB_DR_MODE_PERIPHERAL; + mode = DWC3_GCTL_PRTCAP_DEVICE; + } dwc3_role_switch.fwnode = dev_fwnode(dwc->dev); dwc3_role_switch.set = dwc3_usb_role_switch_set; dwc3_role_switch.get = dwc3_usb_role_switch_get;