From patchwork Mon Nov 6 08:32:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 161885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2515758vqu; Mon, 6 Nov 2023 00:35:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdfox96JfaEljHioh4NgxA+1p9TaCu4hsSpL3n8qIZGLhHCKuH1ttKxycWcUeD3kaV3+SX X-Received: by 2002:a05:6358:7e55:b0:169:57f3:7551 with SMTP id p21-20020a0563587e5500b0016957f37551mr18582988rwm.23.1699259756592; Mon, 06 Nov 2023 00:35:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699259756; cv=none; d=google.com; s=arc-20160816; b=YTSixn2DbuRtB6MaHYssKJsx+cy9s6aEC/kGdCCzzAI8b/vZe/tMDZ+nh0c3Fg89my t0OV7nQFth/niQuzUs9vo4eQwBCnWSMvU7h6PbXnFhIPfX48DNjtfjbvuQt56YoIoboE ny2rWVo+FmCo4fkZimk6HBGBGmqUQCYZGbDcTgm0P++Vzrr1B5a8Li3ANq6cbbrnkCpR dSZbyVKtJC6y4z6gPD/w2eZcsy6JtnovhYqVl/OK+9uinwYat52/1D0Bwky/R2k7zVTi FJMOK0BAUYe0c+jEjoQcWxP1NFuSNtVdHbIOLIc1HmZvj2QR2L7IsybuENBCaBaPKgyA bjzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=AxlJw5UNV+rlgblcRjV4UgoJ4/zH+BZUAC88c6BgYGE=; fh=zqMzEY4/itW58u5XYNFSMtUM9KB8MQpW5EPhQRh3o/E=; b=FSxPTrkDW1ZMFbA61fSfUuyJIBrpQ4PTSOVeDyrnC1gajfLiMQbOeGSqJwWo0wRrp/ W4j9pxeognue4WxXWGjmUiYqLaS1ZDsGH5JhnJd27mS7dd59GlHaUA/na1HspArQ0tfE daU6FLWukAw7uHVRlU3yWOLpPlLyFF0o6ySJNlv9BJe3m5Ko3pLt+G3bqG9g2ZTrgUyu ifplp2zlYj2Ycq82VNrr7cbY8wMeXkyUI1liQ/bjkaaPuD7Yxzi0EdYR5rxNwUbyDKh5 lnzRHx1wGBTkwY7ARs6kwST9H5cV1+DeSJ5shrvdbbmUATLrBu/+mRFFcIJKyhJaDsIy NzAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UJzHza1c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id p27-20020a635b1b000000b005b92db1e113si7487460pgb.702.2023.11.06.00.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 00:35:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UJzHza1c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 01EC58087DF5; Mon, 6 Nov 2023 00:35:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbjKFIcr (ORCPT + 35 others); Mon, 6 Nov 2023 03:32:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231217AbjKFIcn (ORCPT ); Mon, 6 Nov 2023 03:32:43 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4CF1BB for ; Mon, 6 Nov 2023 00:32:39 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4083ac51d8aso32191355e9.2 for ; Mon, 06 Nov 2023 00:32:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699259558; x=1699864358; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AxlJw5UNV+rlgblcRjV4UgoJ4/zH+BZUAC88c6BgYGE=; b=UJzHza1cH+40NgqtjEP8bjny5/4Fs7S0MF4DzjTrcxYAWPwaCBhBDu1t/Q5hTyuYOn poTOOYZKyLjzk5/iTg4FoPZhyf4tlME9CDXnAEaoZ8e+lPL/bWOMJMHDqnGit9puhJmr khmF3X8jZSxTXUeo2eTfEjE0RYw5GVrUZzIasXO2GQku3XoRMVgX+GCbI2XqQ5UhxIJg eyR9s+ZCG1Hw2uLN2lXv5HTRfmzdznWm+bUdshZ0wVkI3lYvnTHDGHJXj0EQp+vqS3q5 l/xIQVUAuhqD2SW4IvkMMzYLJ31K3ezONgoq2crdUjtM+FntWYEjWu/q8YwDWI3jEMo8 ox8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699259558; x=1699864358; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AxlJw5UNV+rlgblcRjV4UgoJ4/zH+BZUAC88c6BgYGE=; b=hhlAKXr7k09p7f9QJ1nzHGPft0/2nOZR2ziuyC1Lu4vkr6qI68ppNAS+CsXTEUxBm0 Kq2drGdee2iW6vh6GSkOB8FyJnCIF1polCRIGL76RwDOGhNFWuS/HYPgJhuX7XPT4Agw +pG075xKRBvj8xzLM416PqQlARjhaFD3XLahYCbOH7Yw25sSjV36f2iJsQuyftVDG2DV W34y6NqgMHWz+0XhXwVC7A2QvQiiT0stYD5rET9t/Fb+VQgEf9h4zz/2XiyWbI7fRWtD sK20dkdKawZbPh6J8mZPUQp40fsD5v+vAyebf9X5LkVXYWnB2Sgb8MJgCYJHa+Ey0dkY 8Atg== X-Gm-Message-State: AOJu0YzS86RDMUomDQuEbBaLJnZWKPDB29VQVG0zh7AmbDX6ZhhTjYyS OpWB/drHqmmzYXWW11ARyL2QCA== X-Received: by 2002:a05:600c:3502:b0:407:8e85:899f with SMTP id h2-20020a05600c350200b004078e85899fmr23326543wmq.16.1699259558292; Mon, 06 Nov 2023 00:32:38 -0800 (PST) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 12-20020a05600c020c00b004063ea92492sm11405241wmi.22.2023.11.06.00.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 00:32:37 -0800 (PST) From: Neil Armstrong Date: Mon, 06 Nov 2023 09:32:31 +0100 Subject: [PATCH v3 2/3] pinctrl: qcom: handle intr_target_reg wakeup_present/enable bits MIME-Version: 1.0 Message-Id: <20231106-topic-sm8650-upstream-tlmm-v3-2-0e179c368933@linaro.org> References: <20231106-topic-sm8650-upstream-tlmm-v3-0-0e179c368933@linaro.org> In-Reply-To: <20231106-topic-sm8650-upstream-tlmm-v3-0-0e179c368933@linaro.org> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Linus Walleij , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong , Krzysztof Kozlowski X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4470; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=nXfUF7+mDQza/JlKoXvW/NLuYwJxWqbFi2iOF/Gxevs=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBlSKSimT7GG484UX6Wh2GpNvex8PjVZoaqDMtzT7um G2151QeJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZUikogAKCRB33NvayMhJ0URtD/ 9ko49hqyeYNN5ZKyMSVujrqeUSMsVvwErOvuRcsjKN/wA9E58Tt/5W2nPKH9fayw61ATYlGj96K0k0 +KZWhRhXgUZ/1xsh4zJNc7/XwRkKXbXPWSH0RMTFvMcfbXBMlGZQs25++fHxvEJADIJkaG308rYpgY gaA8P/1HMehZuxNQpo3apSXdAi0MV3RRxh6t659STmvReUlo6ySWZwKfbaCpGmrFyy4/MPRRfx1zR1 +m0exeDjPZIagjAGpdd3BTg+dKkY7ADm+RSuGD3MjRWs9lGi0Ciql67EKAxkOk5fMH/Wy2C/atJ8eM eN/nZDbOiKYOpaL6595yQaKT37Tj6tVFLhqgIUNMFLzPif4Q3s1eqMCbIj0zNFnkiEzPLX6oNH8hiA d0nhdNjo95t9BzcHNA71Wal/wTkZNsKL6+2VSpivTnEeM35jw532KnkIaHgAQUvtDyjriR69IgRf5U wasuJ9YeHsM69tKbm5cd2xxZHrKXYLk0jAyXAQkfV+mhtEtzSo/Q0uNIr79bvRuiTPyT/z7Wj6xE+s Jf6wsUy6GEwapYw7Sio0SG1fitni3FEq4rFhftai3Ojrv61xgkZO/F+vIJynpC32loSQ08yFMkG5wG m7Xj1goTjbB7Z5zQeDjgwSgnQBEHi1c+/BFYVSjrP5E9X4Bo3qqKSdf/opHg== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 00:35:20 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781802998752982570 X-GMAIL-MSGID: 1781802998752982570 New platforms uses a new set of bits to control the wakeirq delivery to the PDC block. The intr_wakeup_present_bit indicates if the GPIO supports wakeirq and intr_wakeup_enable_bit enables wakeirq delivery to the PDC block. While the name seems to imply this only enables wakeup events, it is required to allow interrupts events to the PDC block. Enable this bit in the irq resource request/free if: - gpio is in wakeirq map - has the intr_wakeup_present_bit - the intr_wakeup_enable_bit is set Reviewed-by: Krzysztof Kozlowski Signed-off-by: Neil Armstrong --- drivers/pinctrl/qcom/pinctrl-msm.c | 42 ++++++++++++++++++++++++++++++++++++++ drivers/pinctrl/qcom/pinctrl-msm.h | 5 +++++ 2 files changed, 47 insertions(+) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index 395040346d0f..207b41018580 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -1196,6 +1196,8 @@ static int msm_gpio_irq_reqres(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct msm_pinctrl *pctrl = gpiochip_get_data(gc); + const struct msm_pingroup *g = &pctrl->soc->groups[d->hwirq]; + unsigned long flags; int ret; if (!try_module_get(gc->owner)) @@ -1221,6 +1223,28 @@ static int msm_gpio_irq_reqres(struct irq_data *d) */ irq_set_status_flags(d->irq, IRQ_DISABLE_UNLAZY); + /* + * If the wakeup_enable bit is present and marked as available for the + * requested GPIO, it should be enabled when the GPIO is marked as + * wake irq in order to allow the interrupt event to be transfered to + * the PDC HW. + * While the name implies only the wakeup event, it's also required for + * the interrupt event. + */ + if (test_bit(d->hwirq, pctrl->skip_wake_irqs) && g->intr_wakeup_present_bit) { + u32 intr_cfg; + + raw_spin_lock_irqsave(&pctrl->lock, flags); + + intr_cfg = msm_readl_intr_cfg(pctrl, g); + if (intr_cfg & BIT(g->intr_wakeup_present_bit)) { + intr_cfg |= BIT(g->intr_wakeup_enable_bit); + msm_writel_intr_cfg(intr_cfg, pctrl, g); + } + + raw_spin_unlock_irqrestore(&pctrl->lock, flags); + } + return 0; out: module_put(gc->owner); @@ -1230,6 +1254,24 @@ static int msm_gpio_irq_reqres(struct irq_data *d) static void msm_gpio_irq_relres(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); + const struct msm_pingroup *g = &pctrl->soc->groups[d->hwirq]; + unsigned long flags; + + /* Disable the wakeup_enable bit if it has been set in msm_gpio_irq_reqres() */ + if (test_bit(d->hwirq, pctrl->skip_wake_irqs) && g->intr_wakeup_present_bit) { + u32 intr_cfg; + + raw_spin_lock_irqsave(&pctrl->lock, flags); + + intr_cfg = msm_readl_intr_cfg(pctrl, g); + if (intr_cfg & BIT(g->intr_wakeup_present_bit)) { + intr_cfg &= ~BIT(g->intr_wakeup_enable_bit); + msm_writel_intr_cfg(intr_cfg, pctrl, g); + } + + raw_spin_unlock_irqrestore(&pctrl->lock, flags); + } gpiochip_unlock_as_irq(gc, d->hwirq); module_put(gc->owner); diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h index 4968d08a384d..63852ed70295 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.h +++ b/drivers/pinctrl/qcom/pinctrl-msm.h @@ -58,6 +58,9 @@ struct pinctrl_pin_desc; * @intr_enable_bit: Offset in @intr_cfg_reg for enabling the interrupt for this group. * @intr_status_bit: Offset in @intr_status_reg for reading and acking the interrupt * status. + * @intr_wakeup_present_bit: Offset in @intr_target_reg specifying the GPIO can generate + * wakeup events. + * @intr_wakeup_enable_bit: Offset in @intr_target_reg to enable wakeup events for the GPIO. * @intr_target_bit: Offset in @intr_target_reg for configuring the interrupt routing. * @intr_target_width: Number of bits used for specifying interrupt routing target. * @intr_target_kpss_val: Value in @intr_target_bit for specifying that the interrupt from @@ -100,6 +103,8 @@ struct msm_pingroup { unsigned intr_status_bit:5; unsigned intr_ack_high:1; + unsigned intr_wakeup_present_bit:5; + unsigned intr_wakeup_enable_bit:5; unsigned intr_target_bit:5; unsigned intr_target_width:5; unsigned intr_target_kpss_val:5;