Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6410485imm; Mon, 27 Aug 2018 15:36:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY7YhgpGMk17VTa5MutkpaRipWOqPNlRSTrtZ5ipCiUbny9+tR7G61UG1HjaeDiO00PtyHm X-Received: by 2002:a62:da0b:: with SMTP id c11-v6mr16246287pfh.68.1535409388499; Mon, 27 Aug 2018 15:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535409388; cv=none; d=google.com; s=arc-20160816; b=UMACbS90tjYSVu9PsdCpjdOIE89ln6eMxlAHShujVQs5sJLHX2YFinTGy4khq513hj JadEeRJril5Gd6H6daBWebhbc4q5gsh7xprYCOF8PExwF2t9n3MN3KLYCUj3Lcg5WWWa 0dZz1ekJDIXrbQAWL3OOQSMYp3fLehjnHSaRPI4QxWJWPbj8O0oGnVYxHUerHDubQuii WFVue606DhQFwo+maa9Ys45ZELuukZxA4NEwkOeJ8Uc5ZhUFtzL798URJKYVJkePDtLi IzMnv6kyT5NdJis+ylbsM4/+8U7RS1rgV/YfR5P9kmWAQZhHxF5K+nRsTGvxAT3lzITM ISCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=gzVeIPpsLkbxjtBj6QAbwHTi3/dUO1i8WdVkudFXSFo=; b=wP832Py/Fo4ZT3Yz1ZQys9d1z//Z2ieNUBNq5pPOVqHE+qliC5neIBq1cl++4inVFE dWGN6D/eTebXO9Vbe3iERyvsebxHG/ugqumA0xpg1AmF8H7436mBfb20sd4lFbfaq4d4 OR9a28O/uZI81blpL0G83CRbBX1J4dgF1+mHAVO4F56TD9PzZuTuDckmEFIl/v7PTeAy fIeVqKE7g8msRVO0tGUzw8fGTjEvNLOYU+AXLD1hYNt9ZT61ZBvwJR1vxvpKPDiTnCty E8aktTmggmbQ048TprvHSlcER2mSF2TWbqu5PYXMBqBhLn+VE8KndJqSrISB1lH+K/wb f8ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Sbk8Cjzo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12-v6si405861pls.372.2018.08.27.15.36.12; Mon, 27 Aug 2018 15:36:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@chromium.org header.s=google header.b=Sbk8Cjzo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727344AbeH1CXk (ORCPT + 99 others); Mon, 27 Aug 2018 22:23:40 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41223 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbeH1CXk (ORCPT ); Mon, 27 Aug 2018 22:23:40 -0400 Received: by mail-pf1-f196.google.com with SMTP id h79-v6so237035pfk.8 for ; Mon, 27 Aug 2018 15:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=gzVeIPpsLkbxjtBj6QAbwHTi3/dUO1i8WdVkudFXSFo=; b=Sbk8CjzovgZ1fdoYBEjCCI00LCruSOZ9jElym28kIO5bqAAZz8DOGRgyxW2ajqVA43 T2+FWQH7Kky0QuWdRwn2T19mNvNn3Bq66vrtbQJV+5Vun9WqLVilytgsU7H5s3Xh5xMl nktJ4kXgwjBqECXJrmncmjjLgqxaS2txwHQoo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=gzVeIPpsLkbxjtBj6QAbwHTi3/dUO1i8WdVkudFXSFo=; b=RfT/f0wmRRc+OTG7+X+LlAoBI3gWPZup4ZRenONUu70VwY6Vil/pCzgDIexo7FQhCO oUCpCYIRSTKyITOFAgWEK5nhHZQPpx3Y2Ch2glhT0NpVWDt4Pria4S3KjVc1ZlaWwNCF p87K1WLlkiOW4WBKABQPn/MnKOpzHjXywYso86HuFn7A6EbIKRhhM9SQNviuUPIM1KXP 6Ut0h4RqG5rqC8116eitB++GaTD6jorlwXmKEcAytf0rZNrlleQtsF8BNPk+iQGj6Rbk 0KSFHGf3NFw82tYdMbZbAWGnRTUdw/gCnAAfSIWZNkKdFtbYFQTTpqHJYnq/y7nn8f1+ wAgA== X-Gm-Message-State: APzg51DkHms7C9PmsrPYLFMaBIJ/tw8BwW4WadF08Y88iXUlIJ+TpTfV D/Us+JH7N/5yLFsQcBPJoi30Kg== X-Received: by 2002:a63:2503:: with SMTP id l3-v6mr13630529pgl.237.1535409303561; Mon, 27 Aug 2018 15:35:03 -0700 (PDT) Received: from localhost ([2620:15c:202:1:b6af:f85:ed6c:ac6a]) by smtp.gmail.com with ESMTPSA id 1-v6sm460745pfk.134.2018.08.27.15.35.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Aug 2018 15:35:02 -0700 (PDT) Date: Mon, 27 Aug 2018 15:35:02 -0700 From: Matthias Kaehlcke To: Lina Iyer Cc: marc.zyngier@arm.com, bjorn.andersson@linaro.org, sboyd@kernel.org, evgreen@chromium.org, linus.walleij@linaro.org, rplsssn@codeaurora.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, rnayak@codeaurora.org, devicetree@vger.kernel.org, andy.gross@linaro.org, dianders@chromium.org Subject: Re: [PATCH v2 1/5] drivers: pinctrl: qcom: add wakeup capability to GPIO Message-ID: <20180827223502.GV160295@google.com> References: <20180824200157.9993-1-ilina@codeaurora.org> <20180824200157.9993-2-ilina@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180824200157.9993-2-ilina@codeaurora.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lina, On Fri, Aug 24, 2018 at 02:01:53PM -0600, Lina Iyer wrote: > QCOM SoC's that have Power Domain Controller (PDC) chip in the always-on > domain can wakeup the SoC, when interrupts and GPIOs are routed to the > its interrupt controller. Only select GPIOs that are deemed wakeup wording nit: "are routed to the|its interrupt controller" > capable are routed to specific PDC pins. During low power state, the > pinmux interrupt controller may be non-functional but the PDC would be. > The PDC can detect the wakeup GPIO is triggered and bring the TLMM to an > operational state. > > Interrupts that are level triggered will be detected at the TLMM when > the controller becomes operational. Edge interrupts however need to be > replayed again. > > Request the corresponding PDC IRQ, when the GPIO is requested as an IRQ, > but keep it disabled. During suspend, we can enable the PDC IRQ instead > of the GPIO IRQ, which may or not be detected. > > Signed-off-by: Lina Iyer > --- > Changes in v2: > - Remove IRQF_NO_SUSPEND and IRQF_ONE_SHOT from PDC IRQ > Changes in v1: > - Trigger GPIO in h/w from PDC IRQ handler > - Avoid big tables for GPIO-PDC map, pick from DT instead > - Use handler_data > --- > drivers/pinctrl/qcom/pinctrl-msm.c | 96 ++++++++++++++++++++++++++++++ > 1 file changed, 96 insertions(+) > > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c > index 0e22f52b2a19..b675ea56a4ff 100644 > --- a/drivers/pinctrl/qcom/pinctrl-msm.c > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c > @@ -687,11 +687,15 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type) > const struct msm_pingroup *g; > unsigned long flags; > u32 val; > + struct irq_data *pdc_irqd = irq_get_handler_data(d->irq); > > g = &pctrl->soc->groups[d->hwirq]; > > raw_spin_lock_irqsave(&pctrl->lock, flags); > > + if (pdc_irqd) > + irq_set_irq_type(pdc_irqd->irq, type); > + > /* > * For hw without possibility of detecting both edges > */ > @@ -779,9 +783,13 @@ static int msm_gpio_irq_set_wake(struct irq_data *d, unsigned int on) > struct gpio_chip *gc = irq_data_get_irq_chip_data(d); > struct msm_pinctrl *pctrl = gpiochip_get_data(gc); > unsigned long flags; > + struct irq_data *pdc_irqd = irq_get_handler_data(d->irq); > > raw_spin_lock_irqsave(&pctrl->lock, flags); > > + if (pdc_irqd) > + irq_set_irq_wake(pdc_irqd->irq, on); > + > irq_set_irq_wake(pctrl->irq, on); > > raw_spin_unlock_irqrestore(&pctrl->lock, flags); > @@ -863,6 +871,92 @@ static bool msm_gpio_needs_valid_mask(struct msm_pinctrl *pctrl) > return device_property_read_u16_array(pctrl->dev, "gpios", NULL, 0) > 0; > } > > +static irqreturn_t wake_irq_gpio_handler(int irq, void *data) > +{ > + struct irq_data *irqd = data; > + struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); > + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); > + const struct msm_pingroup *g; > + unsigned long flags; > + u32 val; > + > + if (!irqd_is_level_type(irqd)) { > + g = &pctrl->soc->groups[irqd->hwirq]; > + raw_spin_lock_irqsave(&pctrl->lock, flags); > + val = BIT(g->intr_status_bit); > + writel(val, pctrl->regs + g->intr_status_reg); > + raw_spin_unlock_irqrestore(&pctrl->lock, flags); > + } > + > + return IRQ_HANDLED; > +} > + > +static int msm_gpio_pdc_pin_request(struct irq_data *d) > +{ > + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); > + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); > + struct platform_device *pdev = to_platform_device(pctrl->dev); > + const char *pin_name; > + int irq; > + int ret; > + > + pin_name = kasprintf(GFP_KERNEL, "gpio%lu", d->hwirq); > + if (!pin_name) > + return -ENOMEM; > + > + irq = platform_get_irq_byname(pdev, pin_name); > + if (irq < 0) { > + kfree(pin_name); > + return 0; Do I understand correctly that this is the case where the pin isn't routed to the PDC? > + } > + > + ret = request_irq(irq, wake_irq_gpio_handler, irqd_get_trigger_type(d), > + pin_name, d); > + if (ret) { > + pr_warn("GPIO-%lu could not be set up as wakeup", d->hwirq); '\n' is missing > + kfree(pin_name); > + return ret; > + } > + > + irq_set_handler_data(d->irq, irq_get_irq_data(irq)); > + disable_irq(irq); > + > + return 0; > +} > + > +static int msm_gpio_pdc_pin_release(struct irq_data *d) > +{ > + struct irq_data *pdc_irqd = irq_get_handler_data(d->irq); > + > + if (pdc_irqd) { > + irq_set_handler_data(d->irq, NULL); > + free_irq(pdc_irqd->irq, d); You need to free 'pin_name' allocated in msm_gpio_pdc_pin_request(). IIUC it should be available in irq_desc->action->name. Cheers Matthias