From patchwork Tue Aug 21 13:55:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10571697 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 8E1E814BD for ; Tue, 21 Aug 2018 13:56:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FE882A36E for ; Tue, 21 Aug 2018 13:56:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D2F12A35E; Tue, 21 Aug 2018 13:56:02 +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 17EB32A3A7 for ; Tue, 21 Aug 2018 13:56:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727162AbeHURQP (ORCPT ); Tue, 21 Aug 2018 13:16:15 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40577 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727094AbeHURQP (ORCPT ); Tue, 21 Aug 2018 13:16:15 -0400 Received: by mail-wm0-f68.google.com with SMTP id y9-v6so2940693wma.5 for ; Tue, 21 Aug 2018 06:55:59 -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=Aliud5qkHWFHnlXE71yeRM0s4uv6gb9kNd4H2LghQsg=; b=K3NxjPX4qL/IBVbLG+eL6gRx0we5J1WNGI8iFC4Udt40SLsXQCT+ecix5mS3YAhuqF 3QjyYdlTEctf6KkuWHY9F5pChHcIfWuJPI/Bkbmwc/1XhvZZBu2vvLmtYtufBOlRgSmI Xya1UmA5JWcJOklvf1l2CpLbMpWNYaVEQAb+8= 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=Aliud5qkHWFHnlXE71yeRM0s4uv6gb9kNd4H2LghQsg=; b=fjP9+7W3cCdzxG1YJdQ6xi+1I3KwRA2sHFWcVaEkfS9/lfZiWzwlDYmaJkEyxtYqtl Li0Rb+vvNcoeGRdnCvDuOKlOgm19WGEXTEaFKcNi53if4yPTKO4PwSFK9azw3YmxwGek 8whCywz9S+tnMDz1Io6rYtz40csz6OJP6UzCjo77xavrzxUrxlre7hm65f0hPbeAwAQs F/eKHn8tVw+VfdjU9HcHwO+Ha8kpVV7RWWAedrS/aR0QUHys2G5Ke15GT0fb0jDe6Avn rak1CncZ/h91ru0kxj1kSHKybJfh+ggFpSN7DZzUBAa/enkjEFwWb1wR6/qKEiexkEFh yhiw== X-Gm-Message-State: APzg51DXJ76wDsKIVoZyN2uyC4vvH79Q6D+2y8iatZWMON7ixZNiukpW /dbIoF6QOL40KlPdZnfRCtVpGg== X-Google-Smtp-Source: ANB0Vdb3QO8rSwd4CQbm6Zr9cAbP7YJ2ydWC/Mhq5QwQizFSuDAOmAv+8cJj7TR0EcaMbNeW8MwqmQ== X-Received: by 2002:a1c:ea9d:: with SMTP id g29-v6mr2270169wmi.152.1534859758613; Tue, 21 Aug 2018 06:55:58 -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 l24-v6sm16728523wrb.65.2018.08.21.06.55.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Aug 2018 06:55:57 -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, Loic Poulain Subject: [PATCH 1/6] usb: chipidea: Add dynamic pinctrl selection Date: Tue, 21 Aug 2018 15:55:51 +0200 Message-Id: <1534859756-6955-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 --- 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 85fc6db..03e52fc 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -723,6 +724,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 af45aa32..55dbd49 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../host/ehci.h" @@ -150,6 +151,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; @@ -194,6 +199,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 9852ec5..c04384e 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "ci.h" #include "udc.h" @@ -1965,6 +1966,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, @@ -1983,6 +1988,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 Tue Aug 21 13:55:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10571699 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 E0D3813B6 for ; Tue, 21 Aug 2018 13:56:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D13C22A33F for ; Tue, 21 Aug 2018 13:56:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF5202A3AB; Tue, 21 Aug 2018 13:56:03 +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 7CD282A386 for ; Tue, 21 Aug 2018 13:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727306AbeHURQR (ORCPT ); Tue, 21 Aug 2018 13:16:17 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42098 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727252AbeHURQR (ORCPT ); Tue, 21 Aug 2018 13:16:17 -0400 Received: by mail-wr1-f66.google.com with SMTP id v17-v6so1324129wrr.9 for ; Tue, 21 Aug 2018 06:56:01 -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=T16gbVCP6TPIcumFu0woImacmMgPy6bKhyqUl+bq5LE=; b=FTo6HcaYZ8iuUmXMVLP8yIl008bSIoNQwT9yw/4Lnc1SqaByuXqd/WSokQE/5X6nsg m2buIkbaDVM9DPiEj7OooVCrW6lKWT4DpkNGNJ/mWPQO/fj2yYtvOQDPTdbMivCXcNmM lQBpuC5WSEjx1xKS0hsbNYBybwE+6H2VQPJko= 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=T16gbVCP6TPIcumFu0woImacmMgPy6bKhyqUl+bq5LE=; b=jvBOT+5IjI+SeopGV7haE+sVbtZJq1ET2TmPOhsZKyMrgFNHLyBV7pV/6s4fORi1VA 9mT4vqW6oxNMWIlBUaoqdH5MgJbNMdf0RxWnxqxOzjPYbIApUDVC9LKn3WtBlSKL2PcJ WKXeuWuTckdd4LELwbDGcJlS5EIDV71uvnvTp4kNDwK2eQjh5UpiKCXiHjzacAIpBRwL DI5U60WvTn5Yvfcywslx0Mchlsv1RZ4eKcDiNayZ1B8uDx6R6bBeXrbUiP5z1hVAXk08 4i8+Uj7ng1d8lwn+76B2o6CnH5V7hvGtZ2jXl3QCtbXGS6PUUfoCbMgRRuAWjM8CwMfM tUpQ== X-Gm-Message-State: APzg51DyrOxHRnIEIBw2IQ+eZlWHKg25ZxjJvVAJchR8K0tiBq7iJZYX aoS7kDz75WJLWpX80rhym3/bQg3rlyw= X-Google-Smtp-Source: ANB0VdYOhSzflE9/Fa2O7lF5aBPgZfU9fqjJNi40aSHTTczNrSVWSPP6hjDzBuqnOMBbGO4ZJocsbw== X-Received: by 2002:adf:ea92:: with SMTP id s18-v6mr1316053wrm.284.1534859761228; Tue, 21 Aug 2018 06:56:01 -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 l24-v6sm16728523wrb.65.2018.08.21.06.56.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Aug 2018 06:56:00 -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, Loic Poulain Subject: [PATCH 2/6] usb: chipidea: Support generic usb extcon Date: Tue, 21 Aug 2018 15:55:52 +0200 Message-Id: <1534859756-6955-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534859756-6955-1-git-send-email-loic.poulain@linaro.org> References: <1534859756-6955-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 --- 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 03e52fc..c595718 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -699,6 +699,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 Tue Aug 21 13:55:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10571703 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 C554F14BD for ; Tue, 21 Aug 2018 13:56:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B69702A39D for ; Tue, 21 Aug 2018 13:56:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4B042A385; Tue, 21 Aug 2018 13:56:05 +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 66A172A386 for ; Tue, 21 Aug 2018 13:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727345AbeHURQT (ORCPT ); Tue, 21 Aug 2018 13:16:19 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43771 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727252AbeHURQS (ORCPT ); Tue, 21 Aug 2018 13:16:18 -0400 Received: by mail-wr1-f66.google.com with SMTP id k5-v6so4411707wre.10 for ; Tue, 21 Aug 2018 06:56:03 -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=K+768cvU4pPkRaQ3YhlP5lEiMFUDD4Pvl2Aw6Stu7VM=; b=aV4isIV01NCTUOo6lJhKgs30jUfcFF3l/qpAEyM49F48jfqvWCfTmU8gZmHLTWkwdz V1IXZoSNK2KngMx0OwWYclZCROMzyfim8waLfH+vxKyqu59zYH2BcjzHSKWfjFnkz4UT avvxY2ZMyM6baGcvj8yzI3mvlOuzRUS872nzw= 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=K+768cvU4pPkRaQ3YhlP5lEiMFUDD4Pvl2Aw6Stu7VM=; b=OG4MRRdNwJybLFnD8nprYy/u43/oxdcaab1LtyxMyAwSoApRp+yL0sjz5RuCMzVZqB uxjPfH7avSJu8RZdv58WVttD1YZm9CcZF+TFt1kSmYaRAdRTd4/TWkVnf3Lc0Sjr0P+w Nd2F6ztcNvK938UAA/CL0AQ8as2L0ErarFahg8cWk6pANnmbJMP4iaw2dOQ+CTpQRQPn 6Np0xkRRH4nvbE1FFSoLA0UcGTIPHVjHjOZScD4QWgk02IKAWNLYRnTE/UI+kf9gKt5J 5QnuhY0TvIsMugm5hSRX993QaVq8V8Sq4QD1/fwAmCIb6IZvZt0BIENWDLDkZ2R1jjtL nsfw== X-Gm-Message-State: APzg51Cido8XaqbrGNRTKtqA8/fC5LvuWe5oQqxoKzrCmihaOXa+KzMl sz6RIgguRJyUYq47U+YlDIxEVw== X-Google-Smtp-Source: ANB0VdaVXwid/Kyho2nyvo4eVJR+izDT0k1NOORRcj+DdEzIkdTEiSbdDuahpRJfmYpbeOvjPfNbEQ== X-Received: by 2002:a5d:4fc3:: with SMTP id h3-v6mr3183393wrw.261.1534859762734; Tue, 21 Aug 2018 06:56:02 -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 l24-v6sm16728523wrb.65.2018.08.21.06.56.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Aug 2018 06:56:02 -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, Loic Poulain Subject: [PATCH 3/6] usb: chipidea: Prevent unbalanced IRQ disable Date: Tue, 21 Aug 2018 15:55:53 +0200 Message-Id: <1534859756-6955-3-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534859756-6955-1-git-send-email-loic.poulain@linaro.org> References: <1534859756-6955-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 --- 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 7e7428e..4f8b817 100644 --- a/drivers/usb/chipidea/otg.h +++ b/drivers/usb/chipidea/otg.h @@ -17,7 +17,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 Tue Aug 21 13:55:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10571709 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 6BCF01579 for ; Tue, 21 Aug 2018 13:56:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D5F92A3AF for ; Tue, 21 Aug 2018 13:56:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49C7B2A3AE; Tue, 21 Aug 2018 13:56:07 +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 0A6602A38F for ; Tue, 21 Aug 2018 13:56:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727362AbeHURQU (ORCPT ); Tue, 21 Aug 2018 13:16:20 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:51077 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727322AbeHURQU (ORCPT ); Tue, 21 Aug 2018 13:16:20 -0400 Received: by mail-wm0-f66.google.com with SMTP id s12-v6so3060460wmc.0 for ; Tue, 21 Aug 2018 06:56:04 -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=BUph3hiZ4V2ZG+wCVMKvEWc9ax1VLC2ty6Rm5d8QiGc=; b=YaYF/GBpEDKs9QiQ2BmGdxqFdxlUmsQS+Tr7MHEpfWIP0Ke0ZECC/0Kf0hmA1QgNdQ al41hdCS894To9nqvqIG8gZS5FFZzk3RlbgWNhNYBU5bathxAXOLdYi+UOSMF8lJSBNv nyA/c6dJSQ2/icWjtEK/ACXekKvkL6vfrDDWw= 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=BUph3hiZ4V2ZG+wCVMKvEWc9ax1VLC2ty6Rm5d8QiGc=; b=U2XwxZAIq4fITD4Z+5OM3ds9S/Pu4mHcx7ClcWWGMlWxEQyBauPxsQcztyPmYseGAq lFYfIRsuzp2DVmyY4SuI3N7oBXA933uOZbQoYfE6avVjNGrq0BLgCwkbo4zO+eBMQ0pn h+TPUSCtRdCDnZiYFm1N/nTtg7vIP+2VQBBu25G6WdUy+hr/3GAVLqfxxeI6EW4FqSKe hLT9bCA1AdCoxL+D3enjHZ5V2qRUbM4p4TUQDSAqk42UQGS8/8iliJILEE60Ysl5TyQu eiw33eJw1hZyf2UacrHQ9Nnyk9xm1DqY0XAugnL1v7Eg/6Wm05/iswa61B1dYExuxc32 EOkw== X-Gm-Message-State: AOUpUlEEGKInDr/Sc2WYrKXT8UH9YP8u3eu3G3fiQCuczfxNh/abctyH AaiatT7g8xn/4Jg648U+kXHXPA== X-Google-Smtp-Source: AA+uWPwGvt9j6tJt35/GZqSolWUTqieD/9+cFovYYL0AxLJL65VdyjrVKiy7h6AFD1+kRUyxmXefmw== X-Received: by 2002:a1c:64d5:: with SMTP id y204-v6mr28114037wmb.14.1534859764345; Tue, 21 Aug 2018 06:56:04 -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 l24-v6sm16728523wrb.65.2018.08.21.06.56.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Aug 2018 06:56:03 -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, Loic Poulain Subject: [PATCH 4/6] usb: chipidea: Fix otg event handler Date: Tue, 21 Aug 2018 15:55:54 +0200 Message-Id: <1534859756-6955-4-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534859756-6955-1-git-send-email-loic.poulain@linaro.org> References: <1534859756-6955-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 --- 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 db4ceff..f25d482 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -203,14 +203,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 Tue Aug 21 13:55:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10571713 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 905B313B6 for ; Tue, 21 Aug 2018 13:56:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82AB92A23C for ; Tue, 21 Aug 2018 13:56:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80D722A399; Tue, 21 Aug 2018 13:56:09 +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 8CB2D2A37E for ; Tue, 21 Aug 2018 13:56:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727383AbeHURQW (ORCPT ); Tue, 21 Aug 2018 13:16:22 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35386 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727363AbeHURQW (ORCPT ); Tue, 21 Aug 2018 13:16:22 -0400 Received: by mail-wm0-f65.google.com with SMTP id o18-v6so2976667wmc.0 for ; Tue, 21 Aug 2018 06:56:06 -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=Rud9e58rlzxkEYqPSUxDiFrZuB739LO+zK7RVW9bYas=; b=iYx2VMAA1elRQI9t9pnjzbTtc4GFaahiAsbVQxlXj4KUGoodjusifp1eO/A6v62Det P4G2/qIyp3HfQvlYTCuBCgzlXoS7Ryy/XkBRda2s1/4+VF0NpEJ9uU1XOaAnIx1oPQaj FLbmIqecPazIeKsUdu1ble9yDNm9iOrzFsZFo= 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=Rud9e58rlzxkEYqPSUxDiFrZuB739LO+zK7RVW9bYas=; b=n7EnXD8Iz8G9YoGdLFBUPWyks5GwK0rayOp248a+pK2d/exIQ+i5l+f4MFV2G2aluh l+n60KYEYuGPPJIAVaEFTvyW2qQbL9JLNwJwKpYggF8dmLULVV4Ky8knPTBfCy8dBcQ5 kJA3Cf7M7oXzhAiMH7UcPTqOmBGnNTunobuqZlLKUQ6eLQgxvJgIJHmVWosU/OAsvzyU iXQmR81KItJqfLS8k6wfUouoRDghm1hbqOXZn4L4k7gk+TeyxEDu5mLfv3W4iQ2wjXoX 0P1j+rHWggO/TNG0/1uijkq4PIFaxLsR88L3GLnEjBG4r9eP39a7UPjTYVnktzh3yJlV 9gTw== X-Gm-Message-State: APzg51A8v2ege8jjzHKivjh6sZEClwuvVc+aZxRIBJ4df1Rp0SN/MzJ5 TmDAOdJ3/L4JTpz2pHVRWrETcw== X-Google-Smtp-Source: ANB0VdYzBDSkPpJkzEydK56A2Ja1BDFz2Es0VgxL8eWLXEYcOtXBdhetnlsPB3UinV9D9mUtWs8WqA== X-Received: by 2002:a1c:1d87:: with SMTP id d129-v6mr1668452wmd.34.1534859765793; Tue, 21 Aug 2018 06:56:05 -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 l24-v6sm16728523wrb.65.2018.08.21.06.56.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Aug 2018 06:56:05 -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, Loic Poulain Subject: [PATCH 5/6] phy: qcom-usb-hs: Fix unbalanced notifier registration Date: Tue, 21 Aug 2018 15:55:55 +0200 Message-Id: <1534859756-6955-5-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534859756-6955-1-git-send-email-loic.poulain@linaro.org> References: <1534859756-6955-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 --- drivers/phy/qualcomm/phy-qcom-usb-hs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-usb-hs.c b/drivers/phy/qualcomm/phy-qcom-usb-hs.c index 2d0c70b..92e9d94 100644 --- a/drivers/phy/qualcomm/phy-qcom-usb-hs.c +++ b/drivers/phy/qualcomm/phy-qcom-usb-hs.c @@ -181,6 +181,12 @@ 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) { + devm_extcon_unregister_notifier(&uphy->ulpi->dev, + uphy->vbus_edev, EXTCON_USB, + &uphy->vbus_notify); + } + regulator_disable(uphy->v3p3); regulator_disable(uphy->v1p8); clk_disable_unprepare(uphy->sleep_clk); From patchwork Tue Aug 21 13:55:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10571717 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 F1C2D1579 for ; Tue, 21 Aug 2018 13:56:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E415B2A37E for ; Tue, 21 Aug 2018 13:56:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E22FF2A3AD; Tue, 21 Aug 2018 13:56:10 +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 8FD3E2A37E for ; Tue, 21 Aug 2018 13:56:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727409AbeHURQY (ORCPT ); Tue, 21 Aug 2018 13:16:24 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:40584 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727385AbeHURQY (ORCPT ); Tue, 21 Aug 2018 13:16:24 -0400 Received: by mail-wm0-f65.google.com with SMTP id y9-v6so2941142wma.5 for ; Tue, 21 Aug 2018 06:56:07 -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=e4SKYjlE3u47S6xKDWQmkCnhWECoXQ3uJDRZ9YU4/5g=; b=HoFqJPPpultVXCDcTaSORroN84Tk2Clv8A3TpnCdARgEO3XWcJGEZYCM56WfvJcDOg jTpqeKZgtY4FtiT8WUaQY9ohJBMwKHd5kKNugxv6bXJbLWTIhyvMk7UUlF1bcBQGuXI7 Kl3VuhlmhVzqTnXfImeoHBQCcII/Gbiwm9fYg= 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=e4SKYjlE3u47S6xKDWQmkCnhWECoXQ3uJDRZ9YU4/5g=; b=NQr80dGnD3xlzN3FJrF+xp6GVYojqrbC98bgoYY1PyfIX/4BEmZIppmqorrUuf3aig HNNDhdR6ZzVhieZujItxuxtXV/czhXfHm8NDkzTgECNMCLZF4luUbc43ffLgMk4dapTU qvmEPOYJBKJt79b/5S0rxLJJ5kFWxzBusjvcV86meH81B+2BgaNAuzGx2rdYEzagAs3E XG3KHbXH0dizgZL0vTsQ34PDmehwryOsUzJ3E5tqxsY953SBWa0wAaWoBkm2qGAk/eBs gxirR6ADUiYAx5pGMKVgOMSvlHUIfBFQulk3cvGIOfCpJ48jNJIOrgDEDt8xITbYNWb8 Ggjw== X-Gm-Message-State: AOUpUlEkQ4tH2NEHw5alD9dhJFSEVHbKljBFs6JVlU+Fb91JVDvGcsBD OfBCbomi2sCsKr8njAqsfxAJgQ== X-Google-Smtp-Source: AA+uWPzc4CvJmB5HZNUa9aNzICA13/svGw/J36M4EbuGspmDQzQkOx4x7P1UDZAeABEMGc6L0XybWQ== X-Received: by 2002:a1c:1188:: with SMTP id 130-v6mr28049696wmr.138.1534859767247; Tue, 21 Aug 2018 06:56:07 -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 l24-v6sm16728523wrb.65.2018.08.21.06.56.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Aug 2018 06:56:06 -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, Loic Poulain Subject: [PATCH 6/6] arm: dts: qcom: db410c: Enable USB OTG support Date: Tue, 21 Aug 2018 15:55:56 +0200 Message-Id: <1534859756-6955-6-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534859756-6955-1-git-send-email-loic.poulain@linaro.org> References: <1534859756-6955-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 --- 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 ec2f0de..99787cc 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 9ff8487..661a7fd 100644 --- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi +++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi @@ -371,9 +371,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>; @@ -512,7 +513,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>; };