From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B0E7C10F0E for ; Tue, 9 Apr 2019 17:17:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E19420883 for ; Tue, 9 Apr 2019 17:17:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CSGgVF1v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E19420883 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:In-Reply-To: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=4CVIRhFbjRiPbFJHUYa+IzQZoKeLtyNj/odAvWZgDFY=; b=CSGgVF1vLGnm9Z ZYo9UC4Yx2Jp4Hicc4mFIDd5y0t964mUyXjR923OD9B7Q6xq+nGfLSTnd3QchxM/I/UeMoEKyO4xs kG1rE4nwkqJzv8PA0YLjtufNGoWI9SSUvNkU/jwqG7pRVxeqr+GdvSZ+GXYBKKWicfKix2Ye6XRbx fgD5dGQ4aUvWqLYwKg897qie/YETGkB/C+9MSZKGLFIMZehLa38vNQsEx7HuxV1KsykzLGDtMxDUk ce5/dE/gGky1sTTEEAIq5gD7a53uc9/5jSFR42QMzs0+6ca03GNtNbLXkxaJsS9umVHLYs/ACYuLE v1eaNkrNK/qBm/KQwImQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDuNb-0000cm-8v; Tue, 09 Apr 2019 17:17:51 +0000 Received: from iolanthe.rowland.org ([192.131.102.54]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDuNX-0000bu-Pw for linux-arm-kernel@lists.infradead.org; Tue, 09 Apr 2019 17:17:49 +0000 Received: (qmail 5532 invoked by uid 2102); 9 Apr 2019 13:17:44 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 9 Apr 2019 13:17:44 -0400 Date: Tue, 9 Apr 2019 13:17:44 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Bartosz Golaszewski Subject: Re: [PATCH v3 3/6] usb: ohci-da8xx: disable the regulator if the overcurrent irq fired In-Reply-To: <20190409082855.15373-4-brgl@bgdev.pl> Message-ID: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190409_101747_984537_F9B0F258 X-CRM114-Status: GOOD ( 18.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Hilman , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Sekhar Nori , linux-kernel@vger.kernel.org, Bartosz Golaszewski , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 9 Apr 2019, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > Historically the power supply management in this driver has been handled > in two separate places in parallel. Device-tree users simply defined an > appropriate regulator, while two boards with no DT support (da830-evm and > omapl138-hawk) passed functions defined in their respective board files > over platform data. These functions simply used legacy GPIO calls to > watch the oc GPIO for interrupts and disable the vbus GPIO when the irq > fires. > > Commit d193abf1c913 ("usb: ohci-da8xx: add vbus and overcurrent gpios") > updated these GPIO calls to the modern API and moved them inside the > driver. > > This however is not the optimal solution for the vbus GPIO which should > be modeled as a fixed regulator that can be controlled with a GPIO. > > In order to keep the overcurrent protection available once we move the > board files to using fixed regulators we need to disable the enable_reg > regulator when the overcurrent indicator interrupt fires. Since we > cannot call regulator_disable() from interrupt context, we need to > switch to using a oneshot threaded interrupt. > > Signed-off-by: Bartosz Golaszewski > --- > drivers/usb/host/ohci-da8xx.c | 23 ++++++++++++++++++----- > 1 file changed, 18 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c > index 9c6d1f03b871..108fe0a1b962 100644 > --- a/drivers/usb/host/ohci-da8xx.c > +++ b/drivers/usb/host/ohci-da8xx.c > @@ -202,12 +202,24 @@ static int ohci_da8xx_regulator_event(struct notifier_block *nb, > return 0; > } > > -static irqreturn_t ohci_da8xx_oc_handler(int irq, void *data) > +static irqreturn_t ohci_da8xx_oc_thread(int irq, void *data) > { > struct da8xx_ohci_hcd *da8xx_ohci = data; > + struct device *dev = da8xx_ohci->hcd->self.controller; > + int ret; > > - if (gpiod_get_value(da8xx_ohci->oc_gpio)) > - gpiod_set_value(da8xx_ohci->vbus_gpio, 0); > + if (gpiod_get_value_cansleep(da8xx_ohci->oc_gpio)) { > + if (da8xx_ohci->vbus_gpio) { > + gpiod_set_value_cansleep(da8xx_ohci->vbus_gpio, 0); > + } else if (da8xx_ohci->vbus_reg) { > + ret = regulator_disable(da8xx_ohci->vbus_reg); > + if (ret) > + dev_err(dev, > + "Failed to disable regulator: %d\n", > + ret); > + } > + > + } > > return IRQ_HANDLED; > } > @@ -434,8 +446,9 @@ static int ohci_da8xx_probe(struct platform_device *pdev) > if (oc_irq < 0) > goto err; > > - error = devm_request_irq(dev, oc_irq, ohci_da8xx_oc_handler, > - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, > + error = devm_request_threaded_irq(dev, oc_irq, NULL, > + ohci_da8xx_oc_thread, IRQF_TRIGGER_RISING | > + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, > "OHCI over-current indicator", da8xx_ohci); > if (error) > goto err; > Acked-by: Alan Stern _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel