From patchwork Wed Mar 11 17:21:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11432347 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 71DF314B7 for ; Wed, 11 Mar 2020 17:21:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1441B20746 for ; Wed, 11 Mar 2020 17:21:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="v90sNn9X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730440AbgCKRVU (ORCPT ); Wed, 11 Mar 2020 13:21:20 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40483 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730386AbgCKRVT (ORCPT ); Wed, 11 Mar 2020 13:21:19 -0400 Received: by mail-pg1-f194.google.com with SMTP id t24so1555173pgj.7 for ; Wed, 11 Mar 2020 10:21:19 -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=WAV7i9DpkYyptymNiUj/uooXSddOTDPzEmF8/rLdzNA=; b=v90sNn9X8BRpEKbFTfSlIt7FhpVLPNq1rrz4UZ7BYSmcgkeS70mPrFQdBay6B2aYbc Wc24d+bXbldbfKuYcztn/Sxpn/Vorbs7SKjHroXEeGHiW4jgp+7sliYnr9hqgXo+kZxS VmoKRdgQRScp0c6BfVlLCYO9+St3c+3uV40jsxs9HETJxMMJYk3nVIo/wAR6L/mcK54c 1wBFH0MKtHl/7lhS8EhQBry7zOu7W0vX4ImD6kR1Xm0pTBNPnHskBiB4KNgW3NfaeSE5 LTlrHOKFur2u2ndk8PQWPoCWPC2GJmZlpVdsLOwaRLgHQ0BsWtcjNL9dIYdf1pjMfqd+ i+iw== 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=WAV7i9DpkYyptymNiUj/uooXSddOTDPzEmF8/rLdzNA=; b=VL/PATDTvIByrKzEKuNXz3j/jjLUADopaT684XIFDLUdiBXDNbfAMc77erdD1sxRfu CsAdJG5DbdEEubFMQbrJZ8c30Fxfc56kCVTUjGQLOFJ2ZDA/RlNesTqguXGKWXwkeCeZ jyQFD5sZSJ6b+0COgg3yaSDOBzxnZxxsh1ENMQHC0wLJIeF8rG/Pddw7fUd/D+o3+uUi XcW3bWaoePYdVy1OCEB9sMJQhhn1Ekth3OYvT08eDpDp9PL0bCrspsWwbm/CD/iHyoAu ty7HhFdYkrUhK+EdbdP9ZHesMZFoleXNu+WPWMPmQIl+EW+v4m50rrhTAXZ8eDIcREvG KG/Q== X-Gm-Message-State: ANhLgQ1VmfKngqf75e4Y4KKk2kjboZXd2lxHtSIMtagQNCwCyM4d3Az+ Kjb7SUR+W7Bap2+RZ/8MMNCutQ== X-Google-Smtp-Source: ADFU+vtzBoZFcIDWNjK9MIBKHCBmyqHTO+sxRnhI5ba4B3NJdzaRPyIUlCz+gPylTkgIih79KI+8Yg== X-Received: by 2002:a63:a06e:: with SMTP id u46mr3790733pgn.140.1583947278772; Wed, 11 Mar 2020 10:21:18 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b24sm14914053pfi.52.2020.03.11.10.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 10:21:18 -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 , Guillaume Gardet , Jack Pham , Bryan O'Donoghue , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, John Stultz Subject: [RESEND][PATCH v8 1/6] usb: dwc3: Registering a role switch in the DRD code. Date: Wed, 11 Mar 2020 17:21:04 +0000 Message-Id: <20200311172109.45134-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200311172109.45134-1-john.stultz@linaro.org> References: <20200311172109.45134-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: Guillaume Gardet Cc: Jack Pham Cc: Bryan O'Donoghue Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Heikki Krogerus Tested-by: Bryan O'Donoghue 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 v5: Drop selecting CONFIG_USB_ROLE_SWITCH & ifdef dependent code v6: Fix build issue Reported-by: kbuild test robot v7: Minor fix for CONFIG_USB_ROLE_SWITCH=m case not building the role switch handling code, reported by Guillaume Gardet --- drivers/usb/dwc3/core.h | 3 ++ drivers/usb/dwc3/drd.c | 77 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 77c4a9abe365..a99e57636172 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -953,6 +954,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 @@ -1086,6 +1088,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..331c6e997f0c 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -476,6 +476,73 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) return edev; } +#if IS_ENABLED(CONFIG_USB_ROLE_SWITCH) +#define ROLE_SWITCH 1 +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; +} + +static int dwc3_setup_role_switch(struct dwc3 *dwc) +{ + struct usb_role_switch_desc dwc3_role_switch = {NULL}; + + 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, DWC3_GCTL_PRTCAP_DEVICE); + return 0; +} +#else +#define ROLE_SWITCH 0 +#define dwc3_setup_role_switch(x) 0 +#endif + int dwc3_drd_init(struct dwc3 *dwc) { int ret, irq; @@ -484,7 +551,12 @@ int dwc3_drd_init(struct dwc3 *dwc) if (IS_ERR(dwc->edev)) return PTR_ERR(dwc->edev); - if (dwc->edev) { + if (ROLE_SWITCH && + device_property_read_bool(dwc->dev, "usb-role-switch")) { + ret = dwc3_setup_role_switch(dwc); + if (ret < 0) + return ret; + } 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 +603,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 Wed Mar 11 17:21:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11432357 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 33E191392 for ; Wed, 11 Mar 2020 17:21:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D053E2074B for ; Wed, 11 Mar 2020 17:21:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TfYJfPNX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730608AbgCKRVu (ORCPT ); Wed, 11 Mar 2020 13:21:50 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36976 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730516AbgCKRVV (ORCPT ); Wed, 11 Mar 2020 13:21:21 -0400 Received: by mail-pl1-f195.google.com with SMTP id f16so1404720plj.4 for ; Wed, 11 Mar 2020 10:21:20 -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=BvrsPeqWN8PtkcsNQt8nmKsbCOyaPIU6nwAu5WHHWq8=; b=TfYJfPNXDyg7iWT/Fd3jB7IH6WKr/zMsvJ/gTE5hEguO2A3zg+wjjQxZg/cPmIojfA cKBJKHCfLfAOqFDrSuM+KQ84YqXozsJ4LwtT2mAB+ZD/OV8kyP9AjFfazLce0v7E3izJ ahAYskc18sFP0iYb4bjjdG8tGkrP+TAGNuBEZgqnSoTjI0V2ne6LozkbFwwd0OkiBgnu X9bkB45h5OHWLGqTkTrjIrd5KxXIz/Yp7uxPgNG5fKiF/3BqXF18pKQjTptae8oVVDrl 2HQF5kcQrEfjYyz8ZyG9TIkgKrAENB+1UgeqD5AanPNV3wtDt7B3CGTD6W/O+nwhgHCo W9IA== 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=BvrsPeqWN8PtkcsNQt8nmKsbCOyaPIU6nwAu5WHHWq8=; b=nhqdpfQPlyMdO8j80VLSX26NPzomc+XrnxFcJywdWrUyXeXjD3Qgpp+rhHWfQirDoG 2l5pQ1ytd8PAPOz8JyVEF+rBLjYIm8dp4PzRRhJzLTk6/R12YB5Uxp5JBJ1iHGJnVGtb KcHuSPWzG+Iv0QpMuTM4oVvUYwjXgQ/vcWTWZbbdNUuccc7F0rkmlr28XBWmd5ZTTMMK PLk0onFWYPU47CUgr4lt9mUhWkJehNrPpEyf5DtH92+ZnnjFCleVl2AkM96I/YuLifXy +rLahuJQSYMTicgvj2RoWk1Ejnv9RSLPDsu4tFOiexb1GOQAWJfLT0TWncmE/qKNK7IB tVEA== X-Gm-Message-State: ANhLgQ2MldF4JtLGiN5T5qKNDI9PNZ1JavPCpvuTC6zlGmqGkGKNYBFh WghhatG7e3yK9hKS3nI7B76DpA== X-Google-Smtp-Source: ADFU+vtC1b03FsBk1BpWenvotET0rYCstf8uvZMELbv4ZkHpP4tW/T/5xcVCLk7efl+kVQr7Studug== X-Received: by 2002:a17:90a:b10d:: with SMTP id z13mr4563816pjq.132.1583947280382; Wed, 11 Mar 2020 10:21:20 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b24sm14914053pfi.52.2020.03.11.10.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 10:21:19 -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 , Guillaume Gardet , Jack Pham , Bryan O'Donoghue , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [RESEND][PATCH v8 2/6] dt-bindings: usb: generic: Add role-switch-default-mode binding Date: Wed, 11 Mar 2020 17:21:05 +0000 Message-Id: <20200311172109.45134-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200311172109.45134-1-john.stultz@linaro.org> References: <20200311172109.45134-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: Guillaume Gardet Cc: Jack Pham Cc: Bryan O'Donoghue Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Reviewed-by: Rob Herring Signed-off-by: John Stultz --- v5: Switch to string rather then a bool --- Documentation/devicetree/bindings/usb/generic.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt index e6790d2a4da9..67c51759a642 100644 --- a/Documentation/devicetree/bindings/usb/generic.txt +++ b/Documentation/devicetree/bindings/usb/generic.txt @@ -35,6 +35,12 @@ 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-mode: indicating if usb-role-switch is enabled, the + device default operation mode of controller while usb + role is USB_ROLE_NONE. Valid arguments are "host" and + "peripheral". Defaults to "peripheral" if not + specified. + This is an attribute to a USB controller such as: From patchwork Wed Mar 11 17:21:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11432349 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 59E101392 for ; Wed, 11 Mar 2020 17:21:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF15820746 for ; Wed, 11 Mar 2020 17:21:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VXK3bQgC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730538AbgCKRVY (ORCPT ); Wed, 11 Mar 2020 13:21:24 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42374 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730532AbgCKRVX (ORCPT ); Wed, 11 Mar 2020 13:21:23 -0400 Received: by mail-pf1-f194.google.com with SMTP id x2so1333606pfn.9 for ; Wed, 11 Mar 2020 10:21:22 -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=qTnHuEFnXMMcLEn+/gKdeCOo8JW3ThjOO4eEIBgF+Bo=; b=VXK3bQgCvD6TjxmvJBXMC8DVOQe5Y6aIre76TSbJXk0iESbSd3s5SiDgI7Q7RL/ZXf 2MQl+wDQ2D5wSntF+gwX+zQWHP+43Hn2EC71sJzY7y/+sztyq8mpoJl/cngDbm6WwE4o VAWeVMuNGqj0Wnld6JAgtQEh4Z+7qnDKRD8rKCHKj98nsGRlL+3GfpdLZGtSs4dYg6Ip 11Sb04D/mhIvSgZzWTFnrckGTBYw1Zq9AfW4DELaax5HB/dds89OiuM/sy0KmsH2AKfE 8MehfV5yEZ5ENetGdDkTuNRz+0dZiWQ5VkLV+SfE6rz1dKATaYaHkRvCfrbTwLoe2XTh 3Izg== 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=qTnHuEFnXMMcLEn+/gKdeCOo8JW3ThjOO4eEIBgF+Bo=; b=C3tNpQ6w3IL8816Bj3gZeLXJItW7HRqCeqYGAz+TUiq+utD2GtHx9Udi9zyWrMxJJ2 Z+kUE/tpQVuYeqGbQLBNM4wgcyLP03FDoTbjyCKWNP7aobLmq6HFz5aiOapslsdCSfGo KeSzcLPLMhXYe2Z91LSTn0hbX84y92Zk8kReaGBYzXhrUwIBiVCWOzRe1WIYIjcPbuxl cTdDkPxZz1vayhlpBe4oJchR3EwdwUITq16vZTvD8dymU6bGdeaBGqv21LNqTzlO+kpz t2q7K3gimM8K5JZlWZ98uTrRACHyV+4kWzaaqzblDPwZHqfbaQDe1iuKSVC8XTnZu/3H KcEg== X-Gm-Message-State: ANhLgQ3HBbK5ew9+wZ2552XhUZ8c/MDIKiLl2hfg6Y4d2vwP8k9I1Sr+ jkuGyCc/TcI3u6vNbSpJ60FhOw== X-Google-Smtp-Source: ADFU+vvicIkCsgtyFOBaL8KKXg3plymFVoCC7/AjdJ0y7Hbjx3nMzvgxPdsd1uu+9wsTF69hVptQig== X-Received: by 2002:a63:ba05:: with SMTP id k5mr3775967pgf.174.1583947281853; Wed, 11 Mar 2020 10:21:21 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b24sm14914053pfi.52.2020.03.11.10.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 10:21:21 -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 , Guillaume Gardet , Bryan O'Donoghue , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [RESEND][PATCH v8 3/6] usb: dwc3: Add support for role-switch-default-mode binding Date: Wed, 11 Mar 2020 17:21:06 +0000 Message-Id: <20200311172109.45134-4-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200311172109.45134-1-john.stultz@linaro.org> References: <20200311172109.45134-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 the new role-switch-default-mode binding for configuring the default role the controller assumes as 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: Guillaume Gardet Cc: Bryan O'Donoghue Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Tested-by: Bryan O'Donoghue Signed-off-by: John Stultz --- v3: Split this patch out from addition of usb-role-switch handling v5: Reworked to use string based role-switch-default-mode --- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/drd.c | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index a99e57636172..57d549a1ad0b 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -955,6 +955,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 @@ -1089,6 +1091,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 331c6e997f0c..db68d48c2267 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -491,7 +491,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; } @@ -517,7 +520,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); @@ -527,6 +533,19 @@ static enum usb_role dwc3_usb_role_switch_get(struct device *dev) static int dwc3_setup_role_switch(struct dwc3 *dwc) { struct usb_role_switch_desc dwc3_role_switch = {NULL}; + const char *str; + u32 mode; + int ret; + + ret = device_property_read_string(dwc->dev, "role-switch-default-mode", + &str); + if (ret >= 0 && !strncmp(str, "host", strlen("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; @@ -535,7 +554,7 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc) if (IS_ERR(dwc->role_sw)) return PTR_ERR(dwc->role_sw); - dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); + dwc3_set_mode(dwc, mode); return 0; } #else From patchwork Wed Mar 11 17:21:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11432351 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 8F5651392 for ; Wed, 11 Mar 2020 17:21:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A8912074F for ; Wed, 11 Mar 2020 17:21:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rO+x2ooT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730552AbgCKRV1 (ORCPT ); Wed, 11 Mar 2020 13:21:27 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:38928 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730551AbgCKRV0 (ORCPT ); Wed, 11 Mar 2020 13:21:26 -0400 Received: by mail-pj1-f67.google.com with SMTP id d8so1348820pje.4 for ; Wed, 11 Mar 2020 10:21: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=jz3XZ9gPuD/g+1P6LY7Aq8wTOFKwQIrTyqi7Mx3AGIU=; b=rO+x2ooTJs6RHFaCLJeavaPqt1U0ldl4u5LGBhrS3ghIhNbtJ/WxxbmpLS6TJs3w01 kD2a2IMWmNi21t80CVUXRc13YMG7cAtzmsqnbBK6MBcGf5iSpF5uYvpizqQb2zgC1gNW YWgvnFoGWncG1yk9vgnbuJ5eRbLorjb5fCobeqTv3+krW82txy+FBsVQuIEAY8RmI5mT VC/QJyG/46z1Nn2Lfza1LbC59YDkh63IKsk09Z91z2HfEI5+wSK3/vqazrRF/ywOUIEj IG+/KOEXs9LFceA10o3rwGyBgwqJH8XjJ+ifdsPbFGBv2e1zJij43YC+bPbbTVEogRnv zGwg== 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=jz3XZ9gPuD/g+1P6LY7Aq8wTOFKwQIrTyqi7Mx3AGIU=; b=Z1mp2UK3XPbgD2638R54Aph45YVGIbDkc9zLh0br2D5my4YP1jvU1JfCS0RbMZL8hA F+bCyShWLZuOMyqihl3+cqJxvDeUJ0rn8RyK3YFjl4HZTMq74NJfClX9QXslzcORFve1 t4XTB/IRzVJ5iAK5B7msJNEDzOjfrwyxPts9V2KkuMTQ2nvlrwqpYpBWozqNnmEEXLee XdMoCHDsk3aXrXkYpxq8t7BV2RKHxtf6YRYvBfGBT+DjdZeQTK8cXFWESHe21IBJpK9v XaOc8daJTIcpZ1+S1U2usrQOQxOlyx5V9wTOnH1CUEYq4nfU19lTQJogBObYEpAaYhdr cFpg== X-Gm-Message-State: ANhLgQ0Of1WeURrxUwhFAAJa43dYHwuqznLtSB5Wuyr5JLbPMNv/g2JV JUgJJPdceal0yeewssAnm1NNAA== X-Google-Smtp-Source: ADFU+vu2RYb/ys4TWWZMX1MZdw6Mdk95kbzQ9iGo2QeQeW5PGe1fsCKa7TEStuItFnNw2Np1vUjKiw== X-Received: by 2002:a17:902:61:: with SMTP id 88mr3962846pla.313.1583947284955; Wed, 11 Mar 2020 10:21:24 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b24sm14914053pfi.52.2020.03.11.10.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 10:21:24 -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 , Guillaume Gardet , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [RESEND][PATCH v8 4/6] dt-bindings: usb: dwc3: Allow clock list & resets to be more flexible Date: Wed, 11 Mar 2020 17:21:07 +0000 Message-Id: <20200311172109.45134-5-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200311172109.45134-1-john.stultz@linaro.org> References: <20200311172109.45134-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: Guillaume Gardet 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 Wed Mar 11 17:21:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11432353 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 A05C414E5 for ; Wed, 11 Mar 2020 17:21:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BB8D20750 for ; Wed, 11 Mar 2020 17:21:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="znQttMIz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730568AbgCKRV2 (ORCPT ); Wed, 11 Mar 2020 13:21:28 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:38928 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730556AbgCKRV1 (ORCPT ); Wed, 11 Mar 2020 13:21:27 -0400 Received: by mail-pj1-f65.google.com with SMTP id d8so1348848pje.4 for ; Wed, 11 Mar 2020 10:21: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=CpmywWyp6aExqYXO2nsoyNHZG6T/FiFmGDy6H1VmZYo=; b=znQttMIzLhlauM/O9plxveT/fNrNaEDEifiJ5H0Am0jZ8/lTIHyXlHg0yknkHJiADu 9kR8VtlZGdEdod+7vB5Oxm0Z8GKCvxdCT9LqcNp7XKTJYI+DkdgngFyvvW9OLgEJQx8Q IK9rG8mgyRvlrAM53TgYZxF8UCtZzrdzrfR2hy2tOzQ/s5RF0TJyZHYO0s19r1C5tav4 QwMI+KfyoMaztfRLMF4mzN/jvm1SxRcxJQBY2ap3p48leqUmNYqOMlYyOwu4PiOvcMeW YIm2SeipEb3FeP/t33f8fg9qDGH/t/Ms5OMgia3XPUBPIugzSIvdpzidGf5zAyPaZsXV Xhlw== 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=CpmywWyp6aExqYXO2nsoyNHZG6T/FiFmGDy6H1VmZYo=; b=VCbytW18mHF2xAdFluRgW+tYFXfJlrZrrj9aXqzVG9FbGxDsFpY5ZEZfR5ook7zH5u SWQKhY6aPghOrSqQ6s9QhTCmlT6MCWdUYOLIS8BjUbfIS25wBrnn85zNLN/iufWd1ObU SMadP8K6DZjgkyic+rzpXtDZimVdpVoOgTlWJA9+iCvdGEcjuxCwHiedR9xHRWbCjWuh vP8YVrOoH0kTrwDsvDRq3ewaVqKiB/Ga2VaLyy4YtSUH/XBcWFbCMSGCmLtsDKd8maWP ogDei96Ihm4kgUUZrYW37jL0Qd5/Wjrf/18rDunRh4i7RhZOl+jvp/Fmw6LSMbId///q rcEg== X-Gm-Message-State: ANhLgQ3wbEdTtEGaORCxeCOL3WdhJJMDOOV1KGMp/ukZCs0PmVfR3MEV iKw19Ac14OIQdEoPn+Ez2UUAjA== X-Google-Smtp-Source: ADFU+vuRBKnrKmXU0JZNUQ5/lnkIEqkKhvu5m1kBFMbNPnH6c1//Ozyk0auxbkjc1uDgkvgSp6FZyw== X-Received: by 2002:a17:902:a58a:: with SMTP id az10mr4002764plb.20.1583947286400; Wed, 11 Mar 2020 10:21:26 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b24sm14914053pfi.52.2020.03.11.10.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 10:21:25 -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 , Guillaume Gardet , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [RESEND][PATCH v8 5/6] usb: dwc3: Rework clock initialization to be more flexible Date: Wed, 11 Mar 2020 17:21:08 +0000 Message-Id: <20200311172109.45134-6-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200311172109.45134-1-john.stultz@linaro.org> References: <20200311172109.45134-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, or some may have more. Usually this was handled by using the dwc3-of-simple glue driver, but that resulted in a proliferation of bindings for for every variant, when the only difference was the clocks and resets lists. 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 recommended by Rob Herring as an alternative to creating multiple bindings for each variant of hardware. 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: Guillaume Gardet 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. v6: Re-introduce this patch, on Rob's suggestion --- 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 1d85c42b9c67..ba21af5c1204 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -289,12 +289,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 @@ -1441,11 +1435,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); @@ -1481,17 +1470,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 Wed Mar 11 17:21:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11432355 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 B226714B7 for ; Wed, 11 Mar 2020 17:21:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C53420750 for ; Wed, 11 Mar 2020 17:21:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wzs9yWYI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730573AbgCKRVa (ORCPT ); Wed, 11 Mar 2020 13:21:30 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35399 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730564AbgCKRV3 (ORCPT ); Wed, 11 Mar 2020 13:21:29 -0400 Received: by mail-pg1-f194.google.com with SMTP id 7so1568090pgr.2 for ; Wed, 11 Mar 2020 10:21: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=EGHWPlxApQjuktMa4xDP9Q063H+hJfu1b6AJ+NVENyk=; b=wzs9yWYIHxuZrh+l83G2npKrDy1oqKA1xypVVS2U3HsnbNYgw41X9lhRBnp5I2yzT1 g5VgsJUrdt4LeNiaK2vJ/mH7MyOeWmpLGprY3DMJa9CbNM0R9zNZPcoJYAiL9T2Rdcj9 +LcoDzpvuTgfkwpvij9j9ByGn7+WdlzBB7svWaFuqsRzYYOtH7AnAG602VatDxsx6EF9 594VtuNPghhGM6IC4h6UAS0/ANrg2roTguqX5Lx8EvmYVVJDXFkKA9wFpYUK84uDLvjJ Qk+4ms1LaPNgumDoE2yBA9ihADez2A0VyLMvk8/f567jxhIes7jevL9y497QVZCU0BzV poOw== 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=EGHWPlxApQjuktMa4xDP9Q063H+hJfu1b6AJ+NVENyk=; b=PtE8pMdB5zN2oJK+HQaIruzizeQJDA6Pojia6NrVF1zcKsSHJYoslw1deGIho4jrlX ktK2euX/pm0U+UOBF6FtW6pBGF9UiIK+A8T/pYeAw60vN8+Oe5DVRe/TBsivxy/Ir56X YtnKB43KKW6FjS37sv5N8VvBdxOTeIUtnzpAfDGF64OJY5j/IildiiipHppqq1WzabT9 d2IkrQseFSZkWgXCLf+CZ+UvGzQbXc1HGKLvWpH1B+0ITxcJwqYP2ogQEfTu6DQKDIja YUa6DhMykmTkxm+g7YjAFHKHlinqPG7vyXpqZc48LvLyOcQCxG2cIrvrgio22YiiLMPe d0Sg== X-Gm-Message-State: ANhLgQ0x7MzZVVVS8FWSG7eaOHjury1nTAPSVKB1hHvBEKOAfWfaN2Fz CKpEGZvGwKFqsStUvsnjIDUXvw== X-Google-Smtp-Source: ADFU+vsIQvS6vI9A6/ZJeX7p5NOAE/vGwSitovbBlSU6A/ubzt4w/w/19x/VN1rAPQPkC6KZ7bZHVw== X-Received: by 2002:a62:382:: with SMTP id 124mr3867452pfd.11.1583947287937; Wed, 11 Mar 2020 10:21:27 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b24sm14914053pfi.52.2020.03.11.10.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 10:21: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 , Guillaume Gardet , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [RESEND][PATCH v8 6/6] usb: dwc3: Rework resets initialization to be more flexible Date: Wed, 11 Mar 2020 17:21:09 +0000 Message-Id: <20200311172109.45134-7-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200311172109.45134-1-john.stultz@linaro.org> References: <20200311172109.45134-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 may have more. Previously this was handled by using the dwc3-of-simple glue driver, but that resulted in a proliferation of bindings for for every variant, when the only difference was the clocks and resets lists. So this patch reworks the reading of the resets to fetch all the resets specified in the dts together. This patch was recommended by Rob Herring as an alternative to creating multiple bindings for each variant of hardware. 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: Guillaume Gardet 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. v6: Re-introduce this patch, on Rob's suggestion --- 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 ba21af5c1204..2afcc04da338 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1465,7 +1465,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);