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: 184404 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp869799ile; Wed, 11 Mar 2020 10:21:19 -0700 (PDT) X-Received: by 2002:a63:5206:: with SMTP id g6mr3934561pgb.419.1583947279232; Wed, 11 Mar 2020 10:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583947279; cv=none; d=google.com; s=arc-20160816; b=ctp1D3ds7FVw80hltAd+OoF589GOqk3OCrgYHpZmJhrEKZ3QG1s6K2IrZjRRRgX1dT u0wkWXI5uHJwHZs6msa62cZ4GPra+84JiBrM/KqjMFNbJgKIStORfYFr6uAx7NA0ExVe Qdq69/LKI8O2WroT2M0KOOCjdoJBjQbN3W1GNG7S1HT7ya3K4fAMTGt1jLY87K5FUgJQ FJkqLIfiVE5tZJRz6oxZ7qVI1xCgphhGEU74rAyydDqAXxCIRqoP1hu1ROKd96HOmF9S 0twcRUA8J6qcISuaIDSU2iK7J9iyNve/qYRJy5cFQF49LckSAiX44aZ2g1jMwJ0dDI8e Cn0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WAV7i9DpkYyptymNiUj/uooXSddOTDPzEmF8/rLdzNA=; b=K//opsxwTfeMbvcqEqnI+RKhDbytZq8WNHUODFO6VL1QisuFtmuGxcV9sxpa5jMdgy 6DsSF+Njj2DyAPaH9cou8sR3kk1mE5DGWT8to0mbQ0D/L9tkpurw84qsCz5+5oPCVtQK TeuQZ0JqEMKOLI31+3SjjiXhjmeQvaMaNowzQydcdQLOt9wL8+50kxqNTK/O8cljPn67 qwetmWCnPFd2aN1EJCmf3g0YiaIugmuJxVRuMx8z3gbQSf2rJsG3WpZtZztWt27byIFD O87/NN6c36WS/8G04S0Gbpd3BDDX1x95Ik8eqq4etv6LMMTaJjOH8t/exeXXKIXPuk5h P9qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v90sNn9X; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x5sor3213614pgb.44.2020.03.11.10.21.19 for (Google Transport Security); Wed, 11 Mar 2020 10:21:19 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v90sNn9X; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=RUHbPhQLSmTlB3Kzevc9KGjNFYBbJWXYgPH2pDrOWm0obCa+ujjMykQqSmu9mrsTMT x/yOadjhjF9FvGKoaMpY24QfoffOJpLjm5BEIUgAZ3sSuecb+ugE0NIhafeTyjQrBfxc N0aUs6JZa3/PQ+c35M75+h6Od4DvEl6/lhXg7Tob/WR2fOGkUhcE9WjMj7XVcGuFGiJ0 05fxeROuVwn+ubyquz81ywlcmRkM9okF2g9gTLezsclIs0xCNbmikuD3lkT2/LvHN1qb wRO5l5w9TIaBlsUiMAEPNOCqWa8Tlaf792uCOD5ZGXmipt1l5kvU/0MrcxEQlKYNxHQP 8nlg== X-Gm-Message-State: ANhLgQ095fSyw6DhBOMod2v+u18qIuQtwntq+714f2GkSoIHpVaP+u1w IxqapCm5nhq4c3KdQ0RWWyjr8nq8 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) Return-Path: 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> 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(-) -- 2.17.1 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: 184405 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp869824ile; Wed, 11 Mar 2020 10:21:20 -0700 (PDT) X-Received: by 2002:a17:902:6b48:: with SMTP id g8mr3921238plt.149.1583947280783; Wed, 11 Mar 2020 10:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583947280; cv=none; d=google.com; s=arc-20160816; b=Zayy8fDqhJnHwJc6KDr+B3G9TaT/TSgdZyoSQMolz6mVh+fe21GsbJr90VFf3PULSm BAof/d+9xkwEXzrXwzjTjiifRqFB6xEDkP6buYKcXluPNRGKHrhPznTB7QoJ6LH2r4pD iqs+ehsSS8x0PowrWgN2dnyAaA8+p7z/6rHfr0P7fBPvsTaJ//xoutlWY8RIR/8mJcTz lMstj2mLlTy2b3+WYaL1eTwf0PY9OxWYo2XjF5Hf8hI+gM5qR+z+w1YjyZm52YGcraeb WwL/L1KG8PKF2oJDuqYJQStxbku5XU0LcMBjDz+BbxR4oDzVTlpmyq10pINFyGj6eZzI AvPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BvrsPeqWN8PtkcsNQt8nmKsbCOyaPIU6nwAu5WHHWq8=; b=CmrpgYtHvdy6GNrXApST4x6JsO6sqzYq1OnsZtXzE2SVSQ5mt6iAp+ocPuSjDlIs0E AN7oqj07ARGszivNJ6nPKtsXn9ayhN+tXl/DNFnAI4dxqtKfgrBxTgKpqL6YgvjnHRPg jn9ieBSKbacrULXdtkVaKCKp+KZwqktCg2UhvF272twQYU4Sjt68VDr5ItyNbt1WWock UH6nxqOd9omJT2yebkKIh/z12CUebAeg/zblUrw2FloGT9eTjwaaQUn/3mJp1ilJKNNt EP9711sOmUK66/z5+y5hUwlQNK8JlplflDca/O09WFdeN05hAEqikGfLGYeEdByVrwW7 qleQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TfYJfPNX; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s4sor2739849pji.12.2020.03.11.10.21.20 for (Google Transport Security); Wed, 11 Mar 2020 10:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TfYJfPNX; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=jvud6BXSvJ6qKROgBMOVYvZqev1DZxOPOegzaEnVN2qM8cjeIBXEfupU5fOr4bK5H4 RG6SBHfhqt6eFkL/tMWltdtdBNNwzZ9o3grBf0c/WY62IFLL/9kMLtPNR/rrUwTnXawW m6n233K8z+Woy7K5F8/FkqWE0pUT9ir9tuSupzTNY4CGUFv1NNS2K042j6+V7nkBFWHK 0QeMNR+pEg+z2K3PKZmcZkYNPA9Yqcoa2a86+m+xrpnzdQILeJzX4QBertmYnO5ndK1C HkejnB7xEmsOEuP1EuATiBh00hfups6aQHBqDq5RlOfuKmN1eePrFqrIyZv9eM3Dza1j oceQ== X-Gm-Message-State: ANhLgQ07bTk/uimtsRvnl7QYbfCvrUBMLwnPjYPJRuAzJnnXicDDyqw3 n6E7w2s3oaIzxRFrpug3x0QkJgd9 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) Return-Path: 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> 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(+) -- 2.17.1 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: 184406 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp869854ile; Wed, 11 Mar 2020 10:21:22 -0700 (PDT) X-Received: by 2002:a17:90a:a588:: with SMTP id b8mr4481913pjq.182.1583947282380; Wed, 11 Mar 2020 10:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583947282; cv=none; d=google.com; s=arc-20160816; b=AksPH70HT0Poo0QRBdcJEI1Z145mrFzGqVnYc6BjbJ5IDYGrolpnPNV092ZRz38BmV apgNyWoz2VYoB8sSqWL/x3qXB9G+IK4MEhYZexEEZQcHO0XcTnd9ZRgA+3c9JoVjcaAp wY9UU00amkOaXpdewTnSGxkWkvkfjuZ0L/RtutNcw3a8Y+69+osvlkqg3Tehv+hJCy0S klaui5fi/MsMEyh5vk4s/7fiVUrOj+xWzvQHbbFQuAfsuMhqCXRLrqaTG0ZnKF6qmzHY hWs9MvLOgDRI4z85ChuGTRwUl9uXV8VLAgv8k1CXF5T2vXECYKvlzKDJCNQ1U35lUVuf JFGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qTnHuEFnXMMcLEn+/gKdeCOo8JW3ThjOO4eEIBgF+Bo=; b=iwgFX2mdpw9ZhQOFkSsmFaJGlh33y3q9WxO/I7oxQk3tvvvOgvFDWb75/LeTnj1gRX HojEYd8poLG6Gol6Diu0MIuPMEpLrUcBTlGI/NKl6vNDQLbrXiC/XAShIk9UuiAo9Ext GqtcdWGWyKvG//vCABG3GpAXomE0ypIbF9PxYuyt4pIrHx64HYU/8a8GOCe6IKECTaH8 E6WsWoozkMZbmQ1c6AOZIJY3okHTCO/4ggImKSS/OjrxdSMPjNNX8P+Kpr2nC40cvF7T pYrAsoGnmNPWREo/ndbcjGu9sVXey9zimGyV/KIHAdyg78Zv26yVHzTfe8HfkTqUpAPw x8Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VXK3bQgC; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q19sor3220779pgt.23.2020.03.11.10.21.22 for (Google Transport Security); Wed, 11 Mar 2020 10:21:22 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VXK3bQgC; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=ndIO4w7krfcXAAr6lxCCItMSyPHvjWufUMdutNTaJM/ZV9aCymWXXWr1vWDEqZdObR WSHvqVDIFMx6uC3kDS/Rq1GyDmAZDye7kjTRf0gcfCn37iJtbl7YG5ZbGKyOj1p6rtXe M7NWGUVgjxyFagMoMtNbenCQK7jUtUh2IgJTcpfbKC90rq371QH9QHNvTm/KN7XtxFgq /0apBnkuVn3qy+VyK9xv27FVtEjNKMkHsPkHhVct8Yoxzc+ssiz3x52m/MO7E9PQO5JF il+MpmKWKfuyueAnteHHmGJL7EOqXs0sYQihIeVuafe3rhIoTt82XsbrAibyc9EXW0NH I4UA== X-Gm-Message-State: ANhLgQ07NtoXSM7bN6Kznw1UPauvtXB4FadkgzjOG8fhHLVIoKWNAxcU DH4FAoEcNN6Xq4u7uogBivSKL/WH 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) Return-Path: 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> 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(-) -- 2.17.1 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: 184407 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp869913ile; Wed, 11 Mar 2020 10:21:25 -0700 (PDT) X-Received: by 2002:aa7:95a1:: with SMTP id a1mr1817390pfk.279.1583947285399; Wed, 11 Mar 2020 10:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583947285; cv=none; d=google.com; s=arc-20160816; b=f4MQT2WsZKp/tQtAuS2iqVSejJJpwArn6LNMmkK80tk/4EB8sxcL8KB3FzEgwhx5Xh 0vztakNPIjI4nXm6A9AVNEfCbhpldQWMQr8W5d1xtlvxhAuJRYP2EXF2oJbGLwsz6eTL 4oL1t9/CBy8QHt59M9MRxc4GPeijctZndWIzumBlzgjrOrZ7TL8gW3jvruHNJyTCrAW3 v5huU65srWk3+na45a3X49emAUA97RGW0mNaK3ksxdd69ld/hJ89ma3Ecw0J9fkFAlO4 oTX7LXzAfwlx7jrTsszIwopB78UV0tHToLtHK1fnEQ/t+JhGIWBtNsx70Ru9WBVpMMc5 cvFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jz3XZ9gPuD/g+1P6LY7Aq8wTOFKwQIrTyqi7Mx3AGIU=; b=sOBzYW/NbIc2oHtbTKEPIdkjdL5NQDYOOjt1uulbkCMW+vu2oyHn22TebOc9WD6Eq/ YIpJU56o/qwRUNwzEBWiDF2uTrI7sXsdnAvjqvkZuSpQmEbWZijx5MpU4tj4FXRweZgj iTMfp6nvg2s3yEbzmxMmtiEgP3LB8NmLd+9+P2AaJCNoTDbY+duW6A0gkQpgp4e02I6G neBSnFRfl4o4+SGHE26OTfAw0AcmbKeiIj0gDLuN8kgIu874Ga2//a69EQ95JvohL/4m 3orHkuH8uAFSxhQkd0wzR8PH74OMsoHVsUKgAeqZu2MpkfnfP8DGa75el5Kwdv5ycw/N DxSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rO+x2ooT; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x8sor3288267plr.46.2020.03.11.10.21.25 for (Google Transport Security); Wed, 11 Mar 2020 10:21:25 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rO+x2ooT; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=LBK43AeJv2IC40q/MWZSWwoV3ctSL9rs+eCW2HIKWNHDtN5WUFVV8RxdW19klik4bE azHjxUb3ZlkMSnAifthNiL0syP1tSUqsLfIYEEw7St0uGAc013FbERg1t1ww0oEfkLt9 0y6yDYL8PTf6VICnyZgzpXei7LvPkihc72Fbelsqmb3BttmeRyZbyNSIgJYbQBknrcoL 57aKy4EbmkwLcf70aPa1YeTMj7l349fcahL0JJj32ENTWfI6PBT/z9w4c628jAM2pSJz Nbx/QqIoeZHIkelphkheyDajEm+OEEO2HZOVFImCi92yzkIJ2MuLadq1x1S/PrGNt7WC a//Q== X-Gm-Message-State: ANhLgQ3BfA2AvRqvwBbVZCgEsC+nH4trvk5rdpSM3PaD/jwk72GspyiW /0bFs85hqY13SPNdmsaucqf32dEo 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) Return-Path: 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> 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(-) -- 2.17.1 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: 184408 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp869943ile; Wed, 11 Mar 2020 10:21:27 -0700 (PDT) X-Received: by 2002:a17:902:bd43:: with SMTP id b3mr3758044plx.230.1583947286887; Wed, 11 Mar 2020 10:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583947286; cv=none; d=google.com; s=arc-20160816; b=mOAmun9dps+qUhqsd4K8FSGk0asPvl2sCL9BX2X5pDyfxuuPC53TAlQPAOPIpUfgjY bxifBO4bdK/bEKuqXkU+v3CO6KMsl7aY7qukQ+m3I//aFfCdYULJsLE7DzRnhwkVFrxR +FI7hR5225J20f2g6xEyhqgQaiod1N73yIX5je7qXvgRLMK/x35UoDeEQkOfJ1FZCZ8p RdE6CrxFHqjvSsQ6FVaGtB3HZi0F/UxaZ9Dp68Ql6HJgtnu+jZcaetcZ0w/ahiSv8Tpi Rqea3yICDXd9o66ETw0WGXM1pSrB/YTOUg0HlntjUk5ra1pfV8d4zz6xIS27oCltg7QT TmNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CpmywWyp6aExqYXO2nsoyNHZG6T/FiFmGDy6H1VmZYo=; b=d0VmCpn0hie8Rgz5aK5B5dbk1bxLmDFjqdtVuUpCRl5GwM5nQKatxUR6aJTaDHaSQv iRs/jT/njVCeSiLF/LoChWllOpz5L5cQ/wI/PikNtJ4e9nj+LzGyuoXAVvAMdYPaFkhK ZQZWmqooDNjMfsIA9SmjZXRhlTAIZnzxkGcxZOaE5Jri0S/tBwDTn6+s6jVKWCC5E8cG KPJ0yEqPkMurIpyHGqBL/CjwvIucnYbS5xQcf9PkbVvqisiMD5S3p/8qbsLxCRmrqk4q UgE0YCQH/8RUQHsb3vYoprRPvc+bmkHXUdYJjcnFMOverD5jA4qQC1mJw4fuQ5izzy0z JNtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=znQttMIz; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x7sor2845656pfb.40.2020.03.11.10.21.26 for (Google Transport Security); Wed, 11 Mar 2020 10:21:26 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=znQttMIz; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=lOzNFza3UG0Te/viS+Ntrxv0gD2VcfCJBw5Fu0o54FDdqVRt4mXFYMAKNZRoCQcTfH Pb93rgZFXb5dPxWlKoyzhwBMszvBzLotnz238KtxLHM/tyY7jJJL8vU4myBvmJqh/qm7 Qyqq7SLUN+I0iD2Uvu9LaV+ECWOGDwmM49upsrKkJQb0wCHpNtudTM3U0CEtahNpFs0E obV4m6+Q630xKpYIvGqb55okq6IJjLqhUb5rurYtf8dX+WJZth+fHG+SGVrm5VN2I5SS gH3phDNGlgFNoHmJrFRdkyuIn6xJ51qLu6YQblLlXqTlYeAFq4Qeo/fQrR/3YbFmDwbI oTVA== X-Gm-Message-State: ANhLgQ1R8yjxus1dMu3eVEL3f7tyPoYxbgbdCUAKR7oTH+RYiRo5rmlM RcPl83+9Pmsgf28hW61Nk0DL75JX 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) Return-Path: 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> 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(-) -- 2.17.1 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: 184409 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp869965ile; Wed, 11 Mar 2020 10:21:28 -0700 (PDT) X-Received: by 2002:a63:5c4:: with SMTP id 187mr3972216pgf.348.1583947288308; Wed, 11 Mar 2020 10:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583947288; cv=none; d=google.com; s=arc-20160816; b=Jh+oReolrlPGEev+9dSybvapSNWq3e0OaSs8Lk/1l7mSKlKnj6Zv83/QoYc/0bregD 9EQdi4TA7zflNjKEehmjrdZeiCxpWfjTyQyP9mQvyS523vcquzLqY+mhczlc+rkWxHBC n99h9lcJ4p6ymierprZnO5We2OL/wVaB9xNHFUGBx7LpOj0nt7LHYXuewP4C8zVbfMSo xq+s8ELipHzG0X+1IYhPr2wM84ZCPCZMNv4a+HCAWsrXBU/6KkXIC6aWbdnRtgIwB7q9 RKPp1pjTnH4p6BLoTb8kIEaPq0HRelEZ1iMsnuiq2EftUdTsskh/KaHKZ+otzgBr99Mo YFTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EGHWPlxApQjuktMa4xDP9Q063H+hJfu1b6AJ+NVENyk=; b=UXfla/Unzc0nRK8mRj4vM1D4af5AqRhUSrrlJDCaoV5r69wk4Q6gQveEpYPmBxAwEw +P02v5CZgiKzJwrRZ2R1Weoc/+hmG9fIdBhsXkpU5f3tOS1VPmwYKVwDwOL6sNf/HKrV dY5xbLVCH+DkJZa7GyD9Py+53lfbME+NmNX/53RN371cXhXxnC0OWs0XWL1/0m2XrLFg nJGAibhGDx5rsP/hFjow2ecCTIlwBpEfeCtp1Hvn+dPbPJKC42VjGm6UxB1LLdaP2N1f gPCtZwVcW1E3PFd0BVUs2k8vn/d7YziPR6zxQbnEqikjtG22iA58UInruv/ZegdAbwDL z17Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wzs9yWYI; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i11sor2874889pfq.36.2020.03.11.10.21.28 for (Google Transport Security); Wed, 11 Mar 2020 10:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wzs9yWYI; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=RzS3icMBk2pQp2P2oxm32D2AGDCXL9CUw8jGRrAzlv5VBzONRCkeYLCnVnuOuD1Vgu 6DTHLMM6obuMXyWSNbCQLoxE2zT1EkVEpWnpuvChc4nYYAcGLeUfj7cmHVykZrjxjqOH gGaCp2+uCN8jjsZLpi8k6hlKGsTimIwo8ScK0yiP0mgIUsFVP+kSZvpEPyLRAbXRIr63 4FK6/fH+u/cUBkW2kXdjhr5p15foVUQB4dFcOjj/JzYM8aJnglk/2U3YfesQPI1thXdY 7nH1DhgRZLpNYotcG8s0MmFtKwC9XwWLEcOSUlg5DFwRtLE5LmUGRBE91IU1W7vzxeGH RDbg== X-Gm-Message-State: ANhLgQ2jKZvMshjnJRHyEjlgIYZA9KrhS0glo9UegQVQrX53yHpqfEQR QOnYH9Daj/1eJMWo2DCNsA3eHYsj 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) Return-Path: 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> 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(-) -- 2.17.1 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);