From patchwork Mon Aug 27 09:33:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10576761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CB6F174A for ; Mon, 27 Aug 2018 09:33:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F0AF2847D for ; Mon, 27 Aug 2018 09:33:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62F7F297B8; Mon, 27 Aug 2018 09:33:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C23A62847D for ; Mon, 27 Aug 2018 09:33:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726926AbeH0NTc (ORCPT ); Mon, 27 Aug 2018 09:19:32 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43222 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbeH0NTc (ORCPT ); Mon, 27 Aug 2018 09:19:32 -0400 Received: by mail-wr1-f66.google.com with SMTP id k5-v6so12961006wre.10 for ; Mon, 27 Aug 2018 02:33:38 -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; bh=7hwg7iwuKZ5uZKb4tYvRSPSR6S8BEdgvJekXN1LZzwU=; b=JUmNnzQYtWiz+OXI7+9YhO+w5W+FvkLgS3LtVxAhDeU2smXne7xvSoABHWKmehZNY9 WL7elFaE2jGUsV3fB+q+tRdvqNJkty3BJHI3h5APRbTGm1bneVoWdo5/KAN1yuLaJuUR WwtV/wsl4qoJL+WBmHzjO6yd1l9k6S2o3mx8Y= 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; bh=7hwg7iwuKZ5uZKb4tYvRSPSR6S8BEdgvJekXN1LZzwU=; b=rd5DD3WhL58mty5YfnuwiV2qLg0BryMxSxLOcP6Hg8JZEFeRjpvN20snf8Ctd0Lnlw okTZrn+RfZbNYQuiVkD975v9GWerfYBlVP0Kl7b/nAdp2O5k2uaS5t/2FfPHEkPz6mji AkeTlJxD+KkxMANevYKWV92XXrSN0ek63G8ipkRxMbV0j6P+SqA5aGzTCNL7BkiJDWBP EcHy0yrj+KqAzkeOhKjoyByUZpzzb1dWql2yjxWlagMSsjkXiM8m63PXPYyBSrMl8Q8o u5UP/xsHuwJP3PW6yocWJbJgCdb1xasjJ+r+zvBzqRjuBLfltFf96mnku2K0a7YQCs8Z H3Jg== X-Gm-Message-State: APzg51D6G0g/9DLGCztLu2fCbLLF4pb6CF5q9u+R7k9h35z2r/Sp/Y6U OQvuS6mitLzvEU8UGb0rWEj9pA== X-Google-Smtp-Source: ANB0VdYLeM6W6C6SRYlUeBjdv8vs5H/a68LCrNKuBq1bz0roQJbCbr+crAW9TT6HgDk/Rznu5G7DRA== X-Received: by 2002:adf:9d1c:: with SMTP id k28-v6mr8539539wre.104.1535362417759; Mon, 27 Aug 2018 02:33:37 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (AToulouse-655-1-762-165.w109-220.abo.wanadoo.fr. [109.220.142.165]) by smtp.gmail.com with ESMTPSA id y203-v6sm8022828wmd.1.2018.08.27.02.33.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 02:33:37 -0700 (PDT) From: Loic Poulain To: Peter.Chen@nxp.com Cc: linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, david.brown@linaro.org, robh+dt@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, andy.shevchenko@gmail.com, Loic Poulain Subject: [PATCH v2 1/7] usb: chipidea: Add dynamic pinctrl selection Date: Mon, 27 Aug 2018 11:33:29 +0200 Message-Id: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some hardware implementations require to configure pins differently according to the USB role (host/device), this can be an update of the pins routing or a simple GPIO value change. This patch introduces new optional "host" and "device" pinctrls. If these pinctrls are defined by the device, they are respectively selected on host/device role start. If a default pinctrl exist, it is restored on host/device role stop. Signed-off-by: Loic Poulain --- v2: includes ordering drivers/usb/chipidea/core.c | 19 +++++++++++++++++++ drivers/usb/chipidea/host.c | 9 +++++++++ drivers/usb/chipidea/udc.c | 9 +++++++++ include/linux/usb/chipidea.h | 6 ++++++ 4 files changed, 43 insertions(+) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 43ea5fb..cdac778 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -726,6 +727,24 @@ static int ci_get_platdata(struct device *dev, else cable->connected = false; } + + platdata->pctl = devm_pinctrl_get(dev); + if (!IS_ERR(platdata->pctl)) { + struct pinctrl_state *p; + + p = pinctrl_lookup_state(platdata->pctl, "default"); + if (!IS_ERR(p)) + platdata->pins_default = p; + + p = pinctrl_lookup_state(platdata->pctl, "host"); + if (!IS_ERR(p)) + platdata->pins_host = p; + + p = pinctrl_lookup_state(platdata->pctl, "device"); + if (!IS_ERR(p)) + platdata->pins_device = p; + } + return 0; } diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 18cb8e4..3729672 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "../host/ehci.h" @@ -164,6 +165,10 @@ static int host_start(struct ci_hdrc *ci) } } + if (ci->platdata->pins_host) + pinctrl_select_state(ci->platdata->pctl, + ci->platdata->pins_host); + ret = usb_add_hcd(hcd, 0, 0); if (ret) { goto disable_reg; @@ -208,6 +213,10 @@ static void host_stop(struct ci_hdrc *ci) } ci->hcd = NULL; ci->otg.host = NULL; + + if (ci->platdata->pins_host && ci->platdata->pins_default) + pinctrl_select_state(ci->platdata->pctl, + ci->platdata->pins_default); } diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index fe8a905..3f09a0d 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1964,6 +1965,10 @@ void ci_hdrc_gadget_destroy(struct ci_hdrc *ci) static int udc_id_switch_for_device(struct ci_hdrc *ci) { + if (ci->platdata->pins_device) + pinctrl_select_state(ci->platdata->pctl, + ci->platdata->pins_device); + if (ci->is_otg) /* Clear and enable BSV irq */ hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE, @@ -1982,6 +1987,10 @@ static void udc_id_switch_for_host(struct ci_hdrc *ci) hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS); ci->vbus_active = 0; + + if (ci->platdata->pins_device && ci->platdata->pins_default) + pinctrl_select_state(ci->platdata->pctl, + ci->platdata->pins_default); } /** diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 07f9936..63758c3 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -77,6 +77,12 @@ struct ci_hdrc_platform_data { struct ci_hdrc_cable vbus_extcon; struct ci_hdrc_cable id_extcon; u32 phy_clkgate_delay_us; + + /* pins */ + struct pinctrl *pctl; + struct pinctrl_state *pins_default; + struct pinctrl_state *pins_host; + struct pinctrl_state *pins_device; }; /* Default offset of capability registers */ From patchwork Mon Aug 27 09:33:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10576765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D6E5D13B8 for ; Mon, 27 Aug 2018 09:33:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9B582847D for ; Mon, 27 Aug 2018 09:33:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD914297A9; Mon, 27 Aug 2018 09:33:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DB852847D for ; Mon, 27 Aug 2018 09:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbeH0NTe (ORCPT ); Mon, 27 Aug 2018 09:19:34 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45335 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726887AbeH0NTe (ORCPT ); Mon, 27 Aug 2018 09:19:34 -0400 Received: by mail-wr1-f68.google.com with SMTP id 20-v6so12944018wrb.12 for ; Mon, 27 Aug 2018 02:33:40 -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=5K0e0i3GZ/tcRJJZ2Jk9vcHhwL11OJhvOLLUvTWJ+w0=; b=edaPMFRHdvZwnO2D8O6iyp+rJa5sikogJqM77L6yfZ1n4wvsVM09aueY3xqgL9YeD9 fXQV8SPEGb/HvRnX+fxfIZvt05KjuMEcoehfnKpZZ+b/MOpWvVCF6Iu2NlZXBMh0LTL2 4Li5gt2OpAN/IGZXtVVnTBfk4eOD+3S3uLDeY= 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=5K0e0i3GZ/tcRJJZ2Jk9vcHhwL11OJhvOLLUvTWJ+w0=; b=rEHT863b0avbqpCBgYprw7s8iABe9V/sNgu+/fbp0WWV/DR++V4nxVVvA5aUc8sX4o iVLcVl8yTSOscQ9EU1gUuXhVRSQWioWFnhdTRpvxhAMQYAoUjJgICsJs0+xuFcveDNex ZsuEppKsmh6RoLyUp/f3IIOka0zGBURLQqjwwfesYc1TMEbRu3jaStzi/LqUmXwWzuft 5LV5ylKcLME6xYL5PnPG2wxB+xREkREWK1QZIoq9kort6Sjy5K0tULoO4xo1mA3+h/uw yKLdN5Kq2NNs8KJJ2h4Nv74aQIZsSlJvpTZHIvnAG5iK46SWRHegZ8SBhFYGa9Fjmv4p +9Hg== X-Gm-Message-State: APzg51D8P7WlMRXxJbgKIzLwSIxk6c1sbMjf5e1fiiZB5Xo4hwCd1hee XFYqwU6UlxiRSB6D9vQLlPziTg== X-Google-Smtp-Source: ANB0Vdalr8ZZTzS1tPqs24subm4EZIiZMlxJ0I0hvfAXmyxRStNe2bFABu2oE3PTBpLpgZqAgKeJTA== X-Received: by 2002:adf:9142:: with SMTP id j60-v6mr8112818wrj.180.1535362419962; Mon, 27 Aug 2018 02:33:39 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (AToulouse-655-1-762-165.w109-220.abo.wanadoo.fr. [109.220.142.165]) by smtp.gmail.com with ESMTPSA id y203-v6sm8022828wmd.1.2018.08.27.02.33.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 02:33:39 -0700 (PDT) From: Loic Poulain To: Peter.Chen@nxp.com Cc: linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, david.brown@linaro.org, robh+dt@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, andy.shevchenko@gmail.com, Loic Poulain Subject: [PATCH v2 2/7] doc: usb: ci-hdrc-usb2: Add pinctrl properties definition Date: Mon, 27 Aug 2018 11:33:30 +0200 Message-Id: <1535362415-16559-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> References: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some hardware implementations require to configure pins differently according to the USB role (host/device), this can be an update of the pins routing or a simple GPIO value change. This patch introduces new optional "host" and "device" pinctrls. If these pinctrls are defined by the device, they are respectively selected on host/device role start. Signed-off-by: Loic Poulain --- v2: Add new pin modes documentation (host, device) Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt index 0e03344..ea7033c 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt @@ -76,6 +76,8 @@ Optional properties: needs to make sure it does not send more than 90% maximum_periodic_data_per_frame. The use case is multiple transactions, but less frame rate. +- pinctrl-names: Names for optional pin modes in "default", "host", "device" +- pinctrl-n: alternate pin modes i.mx specific properties - fsl,usbmisc: phandler of non-core register device, with one From patchwork Mon Aug 27 09:33:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10576769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 495A713B8 for ; Mon, 27 Aug 2018 09:33:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B5222847D for ; Mon, 27 Aug 2018 09:33:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F2AA297A9; Mon, 27 Aug 2018 09:33:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8A732847D for ; Mon, 27 Aug 2018 09:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727389AbeH0NTg (ORCPT ); Mon, 27 Aug 2018 09:19:36 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34861 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727078AbeH0NTf (ORCPT ); Mon, 27 Aug 2018 09:19:35 -0400 Received: by mail-wm0-f66.google.com with SMTP id o18-v6so7655345wmc.0 for ; Mon, 27 Aug 2018 02:33:42 -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=eKBz1fhih9+3Kb3HMlACxUt1yzcIHKdIj++GVtqzNHI=; b=FpcjuVkWQCKnlcVVTJPQS/UQsJBpsOsTaKqKsQ+VnzG2lQzPDLV8HxZfhIrdLGU2fL e8kRY/mazjWRd9STVwc/PkqfBCn7ukmog7jb3k6J7fMbg3U+hcJMft8AhmfheZDwl5Gw isXvVnSN2JAMFGLwZwy/UWqUeEKbJSEFOXpNM= 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=eKBz1fhih9+3Kb3HMlACxUt1yzcIHKdIj++GVtqzNHI=; b=g8mgBE/dUd7vb+qPDNeBY+LFBXjXx+DlzJLhSuW1cj/UlPnGGSUtUsAhNngxwFnhIk Bz5VeiaJ+XCbzpw3hz4LJem7huT1LdYzhVfi5llhhaJfe7XhqRzA1pre30WVdFCxF8sx mZq5yk1Fu0pkA8Fj3RiUPz0oAhyCJxuoZyQWLqd5YvBTbpUMwyExJDWqj7COvCfyZSQB UCYvDlra486vxBay21ra5Qrc/KWW1sQpCa9ehdoh3FIeNX3Gr74NXvukO9nt+6ng8vN1 s6eTxJFvOFvQbjHOG/g/IwJ5rart0ZLZ/pQd0VUHmSA0uAbdL72E5bsjwv3qYgn4Gsm0 wx7w== X-Gm-Message-State: APzg51D6gfRVNNR7dtQxfntW08rgw0w9+zISG72EJkSm0IO5LIcw5WPu XLscaT4is7QcjO3ZzjhCkcMr9A== X-Google-Smtp-Source: ANB0VdaW5qAyrZbPemYsKUKtCPpZ+IHK1589hr6tcddfm3WWZINkfX/nsdyS5l1WWcwKRKV1LRjlUA== X-Received: by 2002:a1c:b54b:: with SMTP id e72-v6mr2024624wmf.117.1535362421510; Mon, 27 Aug 2018 02:33:41 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (AToulouse-655-1-762-165.w109-220.abo.wanadoo.fr. [109.220.142.165]) by smtp.gmail.com with ESMTPSA id y203-v6sm8022828wmd.1.2018.08.27.02.33.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 02:33:40 -0700 (PDT) From: Loic Poulain To: Peter.Chen@nxp.com Cc: linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, david.brown@linaro.org, robh+dt@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, andy.shevchenko@gmail.com, Loic Poulain Subject: [PATCH v2 3/7] usb: chipidea: Support generic usb extcon Date: Mon, 27 Aug 2018 11:33:31 +0200 Message-Id: <1535362415-16559-3-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> References: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add compatibility for extcon-usb-gpio which can handle more than one cable per instance, allowing coherency of USB cable states (USB/USB-HOST). These states can be generated from ID or/and VBUS pins. In case only one extcon device is associated to the USB device, and this device supports USB and USB-HOST cable states, we now use it for both VBUS (USB) and ID (USB-HOST) notifier. Signed-off-by: Loic Poulain --- v2: no change drivers/usb/chipidea/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index cdac778..afe85e2 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -702,6 +702,17 @@ static int ci_get_platdata(struct device *dev, ext_id = extcon_get_edev_by_phandle(dev, 1); if (IS_ERR(ext_id) && PTR_ERR(ext_id) != -ENODEV) return PTR_ERR(ext_id); + + /* + * Some extcon devices like extcon-usb-gpio have only one + * instance for both USB and USB-HOST cable states. + */ + if (!IS_ERR(ext_vbus) && IS_ERR(ext_id)) { + if (extcon_get_state(ext_vbus, EXTCON_USB) >= 0 && + extcon_get_state(ext_vbus, EXTCON_USB_HOST) >= 0) { + ext_id = ext_vbus; + } + } } cable = &platdata->vbus_extcon; From patchwork Mon Aug 27 09:33:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10576775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CC361803 for ; Mon, 27 Aug 2018 09:33:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FFFE2847D for ; Mon, 27 Aug 2018 09:33:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8447D297D4; Mon, 27 Aug 2018 09:33:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B1092847D for ; Mon, 27 Aug 2018 09:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727474AbeH0NTh (ORCPT ); Mon, 27 Aug 2018 09:19:37 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33241 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727356AbeH0NTh (ORCPT ); Mon, 27 Aug 2018 09:19:37 -0400 Received: by mail-wr1-f65.google.com with SMTP id v90-v6so12980781wrc.0 for ; Mon, 27 Aug 2018 02:33:43 -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=w0SISw5b9iFA4GoR2xVxw/w2+Ij5SPyf9tqQwIA9cgc=; b=Nngwsn0WRiyiamsxTbhvVfQ5snPb8IwluoRd3vFNjb8/bUSXQ81DnSznEQFo5Afeug NGlpq7oacOrz4R695noRyoAYgDlvl0kQVfm4KBDVA3YKTzL9A63C0Sb+Yaak0zQxl6f4 RgXs+ItSn6+L47Z4XDk23wdhKtz1M+A/49Y2Y= 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=w0SISw5b9iFA4GoR2xVxw/w2+Ij5SPyf9tqQwIA9cgc=; b=QyCWsmtmlNwRxsq13drZX1+oaghsFYaOne1swI0BSq1G0nyD+CW7bFBaKgDxRuRe9B uKgE8vz/tRjbMdrR0PojbhihaKZvh26SMMsv45utx0gr5B90be9/zflfl1T3599cWr4B oiKknJmye+Z5xWz1ZeQtOjowy8qATsfHmt26sGpxb/EQWOcXa0tf7XVM5RcKHyTiDZCo vgJhAyvpRi2GOP9ZXZOv12WIJCTsvwez5FdKTGfP9T81mWxcqJLMMFj7y6Nv/j/HL6dK QfOKsObBDvaSdfUlYuT3aqUFepD4CCkt8L39hjhYNmx+ZX8RQSt0VCgj8rCJbQp8E/jh 4R+w== X-Gm-Message-State: APzg51B/hupMXaKjRabbkNaww6dog1dhxIqIv65E7wXq/AmWBDWLsWuo R4zqq32QFoMLXpjrviOXDMXPAA== X-Google-Smtp-Source: ANB0VdapV8vz0YBbwvoaycNfLIxkWoER6FHQnOzOt8g+na1h3GgNTV/5CMulm1W1plZ6nil6QbjVYQ== X-Received: by 2002:adf:c38e:: with SMTP id p14-v6mr8516615wrf.68.1535362422994; Mon, 27 Aug 2018 02:33:42 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (AToulouse-655-1-762-165.w109-220.abo.wanadoo.fr. [109.220.142.165]) by smtp.gmail.com with ESMTPSA id y203-v6sm8022828wmd.1.2018.08.27.02.33.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 02:33:42 -0700 (PDT) From: Loic Poulain To: Peter.Chen@nxp.com Cc: linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, david.brown@linaro.org, robh+dt@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, andy.shevchenko@gmail.com, Loic Poulain Subject: [PATCH v2 4/7] usb: chipidea: Prevent unbalanced IRQ disable Date: Mon, 27 Aug 2018 11:33:32 +0200 Message-Id: <1535362415-16559-4-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> References: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ChipIdea IRQ is disabled before scheduling the otg work and re-enabled on otg work completion. However if the job is already scheduled we have to undo the effect of disable_irq int order to balance the IRQ disable-depth value. Fixes: be6b0c1bd0be ("usb: chipidea: using one inline function to cover queue work operations") Signed-off-by: Loic Poulain --- v2: no change drivers/usb/chipidea/otg.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h index 9ecb598..a5557c7 100644 --- a/drivers/usb/chipidea/otg.h +++ b/drivers/usb/chipidea/otg.h @@ -20,7 +20,8 @@ void ci_handle_vbus_change(struct ci_hdrc *ci); static inline void ci_otg_queue_work(struct ci_hdrc *ci) { disable_irq_nosync(ci->irq); - queue_work(ci->wq, &ci->work); + if (queue_work(ci->wq, &ci->work) == false) + enable_irq(ci->irq); } #endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */ From patchwork Mon Aug 27 09:33:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10576779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A34E81805 for ; Mon, 27 Aug 2018 09:33:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96E412847D for ; Mon, 27 Aug 2018 09:33:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AC052977F; Mon, 27 Aug 2018 09:33:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BA77297A9 for ; Mon, 27 Aug 2018 09:33:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727499AbeH0NTj (ORCPT ); Mon, 27 Aug 2018 09:19:39 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45336 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727495AbeH0NTj (ORCPT ); Mon, 27 Aug 2018 09:19:39 -0400 Received: by mail-wr1-f65.google.com with SMTP id 20-v6so12944256wrb.12 for ; Mon, 27 Aug 2018 02:33:45 -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=KMRezuJX1BEb4nHpMgT72/6xOEnl//0HUPcftOfNpT4=; b=VO4gYZbF0n56KnRRrOfwAZ8emcMueAUtiSaEVbCr9UGPCGuMWD57jn1jqfDoI+tHCj E+jYlPGgkOWNekyvunmrK3ggQE8nBLTPeqgE3Vs3dV35bpEG1MK/rEJyuBdNvWlW0n4B SxLjrHq30tBvCxkx+iC8fUhHY7rQY2UauxFnM= 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=KMRezuJX1BEb4nHpMgT72/6xOEnl//0HUPcftOfNpT4=; b=dZcUqRqHAOPNB4ku5PU+x/0lr1u+Uh8CgwIoxEbaCDj8ielpS65cVr6KbJkURUass7 7emhdm0YkVAw2BeJE1KHUdZUsw1kSkrdLoRrX/hGFRVAmfVl4fJG1+bGbrma+VNcLy/J FWmYYwa7ZZXqLio+ZGJPu6SYkRiwWv6hg2UlGe/kQXEvXn13eI2c1OV52HxgeFeWnYIw u7uE8RR+EtaC8zSkfJXtGKwAiRve/xqn229dIJLog2Z5giaCZBvm992XN4eE1dOCfmtR il9GtAbwSK7I8Zd1NbpeHldiBTdlN52VObSm6UZoK+RkpeGVKATYDgVvGOxsqCheJZky pcVw== X-Gm-Message-State: APzg51Ay/HmhPb4SYsQO+WWwn7J5w4tu1N6iIbNFH+skpirE/fkE1vNz BFTYa45zSwXQjDDs3ZUo30FiYw== X-Google-Smtp-Source: ANB0VdYfpnGniBjmdQ2QohOldJ/TbQxIgg5L5XScJui0m5aFZk4t487I1TnLCfUVwvBgsEssag4UYA== X-Received: by 2002:adf:db11:: with SMTP id s17-v6mr8488372wri.221.1535362424564; Mon, 27 Aug 2018 02:33:44 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (AToulouse-655-1-762-165.w109-220.abo.wanadoo.fr. [109.220.142.165]) by smtp.gmail.com with ESMTPSA id y203-v6sm8022828wmd.1.2018.08.27.02.33.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 02:33:43 -0700 (PDT) From: Loic Poulain To: Peter.Chen@nxp.com Cc: linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, david.brown@linaro.org, robh+dt@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, andy.shevchenko@gmail.com, Loic Poulain Subject: [PATCH v2 5/7] usb: chipidea: Fix otg event handler Date: Mon, 27 Aug 2018 11:33:33 +0200 Message-Id: <1535362415-16559-5-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> References: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP At OTG work running time, it's possible that several events need to be addressed (e.g. ID and VBUS events). The current implementation handles only one event at a time which leads to ignoring the other one. Fix it. Signed-off-by: Loic Poulain --- v2: no change drivers/usb/chipidea/otg.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 10236fe..8bf4032 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -206,14 +206,17 @@ static void ci_otg_work(struct work_struct *work) } pm_runtime_get_sync(ci->dev); + if (ci->id_event) { ci->id_event = false; ci_handle_id_switch(ci); - } else if (ci->b_sess_valid_event) { + } + + if (ci->b_sess_valid_event) { ci->b_sess_valid_event = false; ci_handle_vbus_change(ci); - } else - dev_err(ci->dev, "unexpected event occurs at %s\n", __func__); + } + pm_runtime_put_sync(ci->dev); enable_irq(ci->irq); From patchwork Mon Aug 27 09:33:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10576781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7020A13B8 for ; Mon, 27 Aug 2018 09:33:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 625DA2847D for ; Mon, 27 Aug 2018 09:33:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56B5E297A9; Mon, 27 Aug 2018 09:33:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0961B2847D for ; Mon, 27 Aug 2018 09:33:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727510AbeH0NTl (ORCPT ); Mon, 27 Aug 2018 09:19:41 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38861 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727505AbeH0NTl (ORCPT ); Mon, 27 Aug 2018 09:19:41 -0400 Received: by mail-wm0-f66.google.com with SMTP id t25-v6so7609105wmi.3 for ; Mon, 27 Aug 2018 02:33:47 -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=kNnuvVHNDO72JJfSiBNDsx5kesLdzgcvxXm8Qay3N2o=; b=XeEUV6lf6MjQOt1Fb5KG8H5r9UoDYS/z86+YbL/omuzZwWSJ9SWhkxU3/HGj1A5Jfq inJoBXiIfKKhYO/ucxYwh7A7r7OIxVBg3msglBGh0Rgmcqf5CdXZFgv61bFZvUljZtVs FGEQcjiD7xo4VBPhoud3TTxFwfluVZVDz7v08= 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=kNnuvVHNDO72JJfSiBNDsx5kesLdzgcvxXm8Qay3N2o=; b=qGFjtDS6+53NsyaWiur1p/iYAwNo988Doo+mdfQmnXocR7hTz6U7RV/KQxxnV/1ynl eHMtxtepKQakYc3VExdF+/cGMCHKLV4a+wJcEPCmvH7wnYGyptj06VEJMW4KHgBIfc78 kYV6OeGMEUYA83KlS+9tLRLasb97ebaC/en4/sqU8l7aNJgJv5g1sqeoNqgTt+pNE3Ip 0KkDE9uxQFa+PFL7qUc+sXP/TZxSRRvDMmYGuJAMbRRPiHndktW9h2tHrQpLTKBIyNPl dpg9+D9Fc1XyifICajYALLAhVR3Otxrs81M8EP0+ikVhMJR4QnezloZksQHZMjhYOU/H NIJw== X-Gm-Message-State: APzg51AqT7mzaRLQlIXvnI+4uFfHes78h77j7Nvl0uSdx92mZzEyWuIc rCrIfuR906ifQD1HHFzWWr9Jpg== X-Google-Smtp-Source: ANB0VdYYjgLAsdeQqgLHZ7r2TBWd/APLGiab4PpbrwGtRCzaNuL9p8inAIOE0VmjdorwuvQBV2usJA== X-Received: by 2002:a1c:d1c3:: with SMTP id i186-v6mr5183018wmg.5.1535362426017; Mon, 27 Aug 2018 02:33:46 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (AToulouse-655-1-762-165.w109-220.abo.wanadoo.fr. [109.220.142.165]) by smtp.gmail.com with ESMTPSA id y203-v6sm8022828wmd.1.2018.08.27.02.33.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 02:33:45 -0700 (PDT) From: Loic Poulain To: Peter.Chen@nxp.com Cc: linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, david.brown@linaro.org, robh+dt@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, andy.shevchenko@gmail.com, Loic Poulain Subject: [PATCH v2 6/7] phy: qcom-usb-hs: Fix unbalanced notifier registration Date: Mon, 27 Aug 2018 11:33:34 +0200 Message-Id: <1535362415-16559-6-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> References: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Phy power on/off cycle can happen several times during device life. We then need to balance the extcon notifier registration accordingly. Fixes: f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API") Signed-off-by: Loic Poulain --- v2: don't use devres version (power-on always followed by power-off) drivers/phy/qualcomm/phy-qcom-usb-hs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-usb-hs.c b/drivers/phy/qualcomm/phy-qcom-usb-hs.c index 2d0c70b..18da6e2 100644 --- a/drivers/phy/qualcomm/phy-qcom-usb-hs.c +++ b/drivers/phy/qualcomm/phy-qcom-usb-hs.c @@ -159,8 +159,8 @@ static int qcom_usb_hs_phy_power_on(struct phy *phy) /* setup initial state */ qcom_usb_hs_phy_vbus_notifier(&uphy->vbus_notify, state, uphy->vbus_edev); - ret = devm_extcon_register_notifier(&ulpi->dev, uphy->vbus_edev, - EXTCON_USB, &uphy->vbus_notify); + ret = extcon_register_notifier(uphy->vbus_edev, EXTCON_USB, + &uphy->vbus_notify); if (ret) goto err_ulpi; } @@ -181,6 +181,11 @@ static int qcom_usb_hs_phy_power_off(struct phy *phy) { struct qcom_usb_hs_phy *uphy = phy_get_drvdata(phy); + if (uphy->vbus_edev) { + extcon_unregister_notifier(uphy->vbus_edev, EXTCON_USB, + &uphy->vbus_notify); + } + regulator_disable(uphy->v3p3); regulator_disable(uphy->v1p8); clk_disable_unprepare(uphy->sleep_clk); From patchwork Mon Aug 27 09:33:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10576787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B62D1803 for ; Mon, 27 Aug 2018 09:33:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E2972847D for ; Mon, 27 Aug 2018 09:33:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01BE2297A9; Mon, 27 Aug 2018 09:33:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97C802977F for ; Mon, 27 Aug 2018 09:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727505AbeH0NTm (ORCPT ); Mon, 27 Aug 2018 09:19:42 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38862 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727506AbeH0NTm (ORCPT ); Mon, 27 Aug 2018 09:19:42 -0400 Received: by mail-wm0-f66.google.com with SMTP id t25-v6so7609179wmi.3 for ; Mon, 27 Aug 2018 02:33:48 -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=JeJb7DryKO3XusEPSjpyjqH1xykE5CUKjBZfRbD7nh4=; b=ITEaBBjfpEl6SzPahRyug8ws0RXeGSkccLg000IE56Lipcn1Xbt3HIjXZ1gKi4f5GN 1OZ98giQPLdeBNqVk36IRdD48hbXWDhbjEPGh7fLSHsHrC5usKnUb0qbrjwALFAJvJMa tcIr8C1yaeTUu/h3yq91XyfMWxqsK9Ro8fLqQ= 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=JeJb7DryKO3XusEPSjpyjqH1xykE5CUKjBZfRbD7nh4=; b=E9HD/nNlSrcrc0XA+0WGk1uly3LKj2Yw4ZVpjBN7VbJ5pXZydndrp1EUF9Fcx8ftc7 1YAUlRMUbdftpewYtNgdYgfo3Pht93fthAS7WKGPKP6Etra+VceijCT2bmS9wiJzhzY9 VgOT9PyoCAcV9plRqIAZH9aa5wUynLCe0ya1QMvokqJx+8kGFW7PbwDDLdT9wS4PgzTV nmNrSv5RPLSUJWfc7Z/8LZULhoD/tFXv0VYJvcMwvcjioiR+3lZzohiXPKEnBcKXxteG nLyAOxy7cYkP0Ih45r+STM29/DsEVfwQvzJAhSdxM881boYNrpVpNHhiSI3PAaMdWYnz GNHw== X-Gm-Message-State: APzg51C0kMwXl+wpzxDtz2SFCDN2IdtrY1+kvA552OhleBg3wxNpBHm8 gTglsbTwLJyzyQINYTLBhrUzew== X-Google-Smtp-Source: ANB0Vdbmg+CuETmDbEoJaZ+rTELLLi32cd0WfnqEZTQjVTC7Vi7fQSg5JGAZypOYh5MXbtPxHkTjfQ== X-Received: by 2002:a1c:dc41:: with SMTP id t62-v6mr5535879wmg.137.1535362427604; Mon, 27 Aug 2018 02:33:47 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (AToulouse-655-1-762-165.w109-220.abo.wanadoo.fr. [109.220.142.165]) by smtp.gmail.com with ESMTPSA id y203-v6sm8022828wmd.1.2018.08.27.02.33.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 02:33:46 -0700 (PDT) From: Loic Poulain To: Peter.Chen@nxp.com Cc: linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, david.brown@linaro.org, robh+dt@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, andy.shevchenko@gmail.com, Loic Poulain Subject: [PATCH v2 7/7] arm: dts: qcom: db410c: Enable USB OTG support Date: Mon, 27 Aug 2018 11:33:35 +0200 Message-Id: <1535362415-16559-7-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> References: <1535362415-16559-1-git-send-email-loic.poulain@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Dragonboard-410c is able to act either as USB Host or Device. The role can be determined at runtime via the USB_HS_ID pin which is derived from the micro-usb port VBUS pin. In Host role, SoC USB D+/D- are routed to the onboard USB 2.0 HUB. In Device role, SoC USB D+/D- are routed to the USB 2.0 micro B port. Routing is selected via USB_SW_SEL_PM gpio. In device role USB HUB can be held in reset. Signed-off-by: Loic Poulain --- v2: no change arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi | 20 ++++++++++++++++++++ arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi | 9 +++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi b/arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi index 16c1f1b..7229ad9 100644 --- a/arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi +++ b/arch/arm64/boot/dts/qcom/apq8016-sbc-pmic-pins.dtsi @@ -8,6 +8,16 @@ pinconf { pins = "gpio3"; function = PMIC_GPIO_FUNC_NORMAL; + input-disable; + output-high; + }; + }; + + usb_hub_reset_pm_device: usb_hub_reset_pm_device { + pinconf { + pins = "gpio3"; + function = PMIC_GPIO_FUNC_NORMAL; + input-disable; output-low; }; }; @@ -22,6 +32,16 @@ }; }; + usb_sw_sel_pm_device: usb_sw_sel_pm_device { + pinconf { + pins = "gpio4"; + function = PMIC_GPIO_FUNC_NORMAL; + power-source = ; + input-disable; + output-low; + }; + }; + pm8916_gpios_leds: pm8916_gpios_leds { pinconf { pins = "gpio1", "gpio2"; diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi index 4c3dda5..c619dea 100644 --- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi +++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi @@ -221,9 +221,10 @@ adp-disable; hnp-disable; srp-disable; - dr_mode = "host"; - pinctrl-names = "default"; - pinctrl-0 = <&usb_sw_sel_pm>; + dr_mode = "otg"; + pinctrl-names = "default", "device"; + pinctrl-0 = <&usb_sw_sel_pm &usb_hub_reset_pm>; + pinctrl-1 = <&usb_sw_sel_pm_device &usb_hub_reset_pm_device>; ulpi { phy { v1p8-supply = <&pm8916_l7>; @@ -464,7 +465,7 @@ usb_id: usb-id { compatible = "linux,extcon-usb-gpio"; - vbus-gpio = <&msmgpio 121 GPIO_ACTIVE_HIGH>; + id-gpio = <&msmgpio 121 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; pinctrl-0 = <&usb_id_default>; };