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: 145162 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3975540ljw; Mon, 27 Aug 2018 02:33:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbnkNLfpbogIiDyCgK9xGbQOQPEQxVPXhBN6/mtKVZF5hXPMplw1H5Jte0QmseZoZ4EiyFB X-Received: by 2002:a62:4fd9:: with SMTP id f86-v6mr13699272pfj.110.1535362420712; Mon, 27 Aug 2018 02:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535362420; cv=none; d=google.com; s=arc-20160816; b=MhYdbTyaKwn1MRvSVAGyS/YS1a/LLFX2Vcq0FJiAc2usi1En2OwlpZI0TRzBksKOHI OKcgFTmXrEpfFuHH4puo3xvEcQ7MZB7ueMTrApeGt+W82yvCyrf50uDTVCk7/cTsOKBB FukWdsCms3e8RpzXuzDBbali+ILiQoQNZnoOohBJjx8WfUc21gcaNZueDtArFhffKVIA 10AY69rtpzl28yj+xH2i752Y6rv5ZeAuyVuPRlRprJQyl/lIon7LlThl3vLJ+ypgE3Z4 m3qTn4B/OMQn//1cGB66KOifanz1BZKomif/z6A3R7JCvITRvqUJPKg01K5oRDvYyNSC suGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=7hwg7iwuKZ5uZKb4tYvRSPSR6S8BEdgvJekXN1LZzwU=; b=OZ6lRLMVDJ4U2N9DQyoAhBDJsEbFHnmQCFAcBiNlO5Ae+OTN1U/7SeXYBhKjlYUUDL VYhycj4bai1N33pLS6n2jOCq51qzqWm3hD2OzgNQjEIe21ia/XVoikA4OpYYoVMq3GJ4 8/NHGsBwJF59Xmfis/UPt8Ttq1AWpu/iwwlGDFb05SM1q1jrUKN52F11jAyOM+E7fVdu cxjKLCFM4y2LivDd4nRH0JX2hDLiFRWyYpZDsrQpxMCdm6zfd6/R8WzttUmLl5or96Xq tRC+sKtrKW7TT7ccB+MU5P1eqjbXlKlpul+/Nb3kSG3t28y5LPFs9lJ6EeNYpJ5bM6HP XPpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JUmNnzQY; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1-v6si13854007pgf.146.2018.08.27.02.33.40; Mon, 27 Aug 2018 02:33:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JUmNnzQY; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726926AbeH0NTc (ORCPT + 5 others); 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-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 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(+) -- 2.7.4 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: 145163 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3975566ljw; Mon, 27 Aug 2018 02:33:42 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda0sq8OeRHcIn+gIgE59wHPR/PHGa7ublAfSWLlLVtDDy6GVp+p3ur4AC/W1A+0B42sMIMP X-Received: by 2002:a62:c288:: with SMTP id w8-v6mr13610990pfk.92.1535362422580; Mon, 27 Aug 2018 02:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535362422; cv=none; d=google.com; s=arc-20160816; b=OX14OOaegDBdcG4kSevtEW3RFBn7zMRPXY7wu6KnWvk3XrKa9NaMl58mWoCdG/p2GB uEh0+ixQVdahbB7vKHXe3M3eesOU2w/cumwwy+m/kyJE/JAtq2LTgw4NtxWbiCXlRDkL dGeUkeHjcrxDosj6pDHy9/puVHt/IRCBEJdzbbYohCAFGpZluN7ouK1GGDoBok8MsgPa rP95DeX8A+lZvS9CGeLV26hQDKBeEbSNbSkRmNqA7+/JknEP/LVxmDpVBFTJoEKIEnYH Zb20wcim/Hm+7NrbJ/GsXJr20x1Dunf67NWiLMntYyFZHvNM99LPmT+7aiBlL/JaAT0U mGkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=5K0e0i3GZ/tcRJJZ2Jk9vcHhwL11OJhvOLLUvTWJ+w0=; b=W81XCCTyNHOu8llgLXpCr6GNimWTeYeTV/dm18jWNK9HYEKZMfcjXHQQKrJ1bpIE0t RVTpSrS+HrcEW8oIlw82n8JOMKEEbrvi5U4nQUZPkV2UOTrKxWIn4hXw4VgC1NM/vRil KGj2r6ZeppfDlENetjlrvoVUF5ZmEV9iiGH0koVWQuxi8kRi6WB2pCKyAPSsd++vqMc+ u+DlOF1j7PJX1T06xNHhyYe4cJ8BOt/XzMDjfp7JC42Qcq/spX/8cVSfZ9Kh+WPZ5dJA o9WZCfU4jaDhiyASEJoYRVglnvMSbEjANj/FhxTxoJPnKKNVXbX0UkN4xeRlbin+Dd7b DAkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=edaPMFRH; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1-v6si13854007pgf.146.2018.08.27.02.33.42; Mon, 27 Aug 2018 02:33:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=edaPMFRH; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbeH0NTe (ORCPT + 5 others); 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-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 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(+) -- 2.7.4 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: 145164 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3975599ljw; Mon, 27 Aug 2018 02:33:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYnjnOPjKsC0YMCKDhBzBZH39ScMws841lXnk3XmBkVt/7hq5QHwNkzJ79MldwHXyPsaoWE X-Received: by 2002:a63:c60:: with SMTP id 32-v6mr11636915pgm.155.1535362425091; Mon, 27 Aug 2018 02:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535362425; cv=none; d=google.com; s=arc-20160816; b=H2UafIYQkLSmOaYY0aGDtQkEsMRPoVrBv/yD8E8I/4lLsD6iWmgI9Xk9segI3EuhoR y/J+0fgwEVn+87D606hoMrCpEFMzsW1XGPvcrYUc9CPsNSNOj6dkiQd0MwFmfQGQUMZD Caq7crNGZKYf8P4TZCI1KaFqhpt3lMUJJ+YIDa/eeVugd49ijnpq7xN7IBRCEMgd/Gqk +/zqqjj+2dYT0VTSG+IilPkxbQjqH5xnlJ9K2FcBI60eMVy5bpHvWtX7nqHdGFB4mZnc ZnlIjXlXmt22bJiaArhggC6sKvfJ7fF6cNO86Fpq4d6IOtphnI338VzXCNF4P9R0Vw3p 9thQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=eKBz1fhih9+3Kb3HMlACxUt1yzcIHKdIj++GVtqzNHI=; b=ryTD+2x6BeUtSokAiuQwLC26tdqwHh0fmopOBh47EzXMnvV1ZRc/Dc6nQYF5jfPWI8 pasPzJ4LmKiL/dXwxgkfyGgXrxB4p1XLbmqk7sHXmbkhXKLnZC+7z1P0FrFD2xFC+NDZ Kr94lk1cZiAaGYbQk19Mm9qnKRj+F+H/P0GeTFNHgd6CSLdYMkv/iFaazSmVpHEZWldX 9x8s5RE+rzZPc9foxUdBNJUPdQ1qQqnstZRpgWS+8kGWC5rs+JGIsc/0ZstednEc8DWd vAXS+Vd46AvmB4d1+k+mgoDb3C5wIikEX+GFjag5O7r6prDbOAUZa18+WcHK2TCQaxSY TQZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FpcjuVkW; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1-v6si13854007pgf.146.2018.08.27.02.33.44; Mon, 27 Aug 2018 02:33:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FpcjuVkW; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727389AbeH0NTg (ORCPT + 5 others); 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-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 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(+) -- 2.7.4 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: 145165 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3975649ljw; Mon, 27 Aug 2018 02:33:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYhdV445dHT01bl/F1aR3pjn8t1RFhJTi7+TTTQcTrZ3/DhTPCyIVlpwSxWAeZ002oh3h1h X-Received: by 2002:a17:902:47:: with SMTP id 65-v6mr12365901pla.35.1535362428436; Mon, 27 Aug 2018 02:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535362428; cv=none; d=google.com; s=arc-20160816; b=hkZqFRLTb6Te6xZh9xKr7VxvMJbH1WZ7LKlHTrndtQ6n0x9tcM5MJc46GjhcHEOcp6 NH1AWevhY2bMMbiJenVqQNVos4otY/ZF71JexgDSRrNxw//pDVPpDjfo31N5/1lcJF+d G09KHRINvToU7eg8so89uNvWB2fPARQDhFPztV7bmFcV0tmwo+cYK36TU7Z93t6XtRQT 6D6ZGIjoPcoVh0Nc/0haOyLGYqAgfmEbU7347gZDHjQ7V7jrEIZDZC89USgUXoXHrMOJ EFBN56RlVNQ4kKYPwxMOSSi3MFMhTl7NXyDAEJ34QyFMiRbptMUP7dHUZGjtQ4UPbSxF 9oeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=w0SISw5b9iFA4GoR2xVxw/w2+Ij5SPyf9tqQwIA9cgc=; b=kCxCNVbZmh1iJxD+BTtfV/AgFugJs3JTRatc0USyE3FztQzB0SrSmn19I5KL0sKzH6 6+S/PbyqG/uBkT0K/h7/Pndp78nxKyC03CmRvmiRfTjTtmDZ78GVVCE5CVBmwyP9QLwO tQm0zN0bvdMuo4CjbPrexBHoQJZMALGqL0GiK9gl6wUSPU5dn7mTGLG9QgxgRUIKqs3m gRy52ArSJXu2VQ32LnMkyKLhnwcFKARjWj1KvFiWsfuhimz6nYV7D74U1PD54XTJyDoP aS6xha77gY3gHDW2Yks8U6ejYSSzq5IlMp1Ey6HyoqIGXH6xljbDzh1lYfelm5y626ww pcbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nngwsn0W; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 35-v6si13216871pla.453.2018.08.27.02.33.48; Mon, 27 Aug 2018 02:33:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nngwsn0W; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727474AbeH0NTh (ORCPT + 5 others); 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-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 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(-) -- 2.7.4 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: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: 145167 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3975677ljw; Mon, 27 Aug 2018 02:33:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYhjXb8tvsfdKOg0Lupe/+x/X5bjlVzTKDsqRgK/Q8jJ+c99USqbzW+Aw8jT3G6Y4AGJfoK X-Received: by 2002:a65:4384:: with SMTP id m4-v6mr11455002pgp.265.1535362430212; Mon, 27 Aug 2018 02:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535362430; cv=none; d=google.com; s=arc-20160816; b=oVIzMY9W9kCY/PT1hC9ebYcOTpN3SuZ+JABhXSFPg84a90cBKOt099dM1FTmZCFJpn MA6+wxJYKQpvOwHJUKDKBbMSLIlv9A7rZcNjYxyizxDF/pvtPXhaOa7AGHq7Dy5afYey aBj8cJPUtgyG2abYzttarmI5iCg7fD+7Mmt+CkfV94kbL+Xs59cT0AcsCNknZJi6eySA 1YiVeA0EPIXnvwM+mlmqMYF+czcs7RG7SQXtQwSR6Qndcgp0vie0y4IoxER1dqNKms9F r4nGO8D5IBbUIK2e5GDpVBQwme6SkmMFSrihbXgs0h3S7sA40A9KMPfz2JqyGxaLrIug 0FWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=kNnuvVHNDO72JJfSiBNDsx5kesLdzgcvxXm8Qay3N2o=; b=io06x0Ak6kyWgM1DPpw3atyiVEPytE6Bl2n4KbK7t67+a1yKxEer8jshJJ7fNJ+dFO 0kHLRVetNdt4JBOmzIqzaBS5WMl7/gbU8cBYwUu//Q0JYiSJ1QypLMeb8goPSegkNF4b 5GOIqpfzHVYUCHpZBGo8Udt7Tuw9NZHPNtnKaJDJjogVYeUOjVO/BoyuG6fCFmOT6Ncg GtVo8U6hLGhVKE6nZZEo0ypYlshhz9PgpmUvK3YJXO3++Dyz5cpmKJUISFAikfRBJhFW yjlluDZMwHDIWySK0vvNG3QbzY5H0hyLadyTf9NOYEdJYWMI81tMpyGjZxpq7sZA3Xa+ OTtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XeEUV6lf; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 35-v6si13216871pla.453.2018.08.27.02.33.50; Mon, 27 Aug 2018 02:33:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XeEUV6lf; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727510AbeH0NTl (ORCPT + 5 others); 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-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 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(-) -- 2.7.4 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);