From patchwork Mon Aug 17 13:40:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 247790 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2645875ilo; Mon, 17 Aug 2020 06:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8+2Xo2/upm4iMrIkA8svmqokri6DsmlkG6vHWRsbrIcDPC9dHQT6yV0Tz1nWWVMB99EYY X-Received: by 2002:a05:6402:84e:: with SMTP id b14mr14646376edz.115.1597671741904; Mon, 17 Aug 2020 06:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597671741; cv=none; d=google.com; s=arc-20160816; b=GwBZfUoU7Q8zB8Om4h+vN/FTvDkIV7h+OtVKt+4zccRF56kcvAug7mU+2l8yhcdzxI X8mmFJGaDb2pFL/jatRevkxkhyH/Gy/uMfpll8DfMyBSLgHkuPPPUXJeBa+nVIv4M6e0 L07FzxAKrecVh4UnryqX2ZDAKY6zA5JWz8ZuV9Afoa0cw8DfBgBip+d4ceZWiX7KrSwH hZZLQcW42tYNOG6RBhOf0djxDgLRsVyWJXJa+wgACk8qNxfd59TeTvD2qCJogicPex2n 7T0c7EGfECNUZpNeBB/+C9N7k89DaPeNgMUAFbZdqrkaUK6fbdkyi4CYfjSzJIGtyOn1 bobw== 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; bh=Oe4tacp/96y2oKOUNNpzoTA6Aq+PNNKI08nVOHEYABg=; b=kID3am73nsac/ENK2rWdmQIBiOXLNCJj6fdI6RDugnGfs5XmyDWIV2Zr3nXJEFjdAm Pg/SAcyg92op1sVPDj4qiYZlq420youc5O1H0xuXPolazr/afPU8VI+YnALOIbPxwEtb lP5jMj3h/I+7gBekxy7WxI23AU28j/X5QhFLDf12Xd0ZCCDgZE318xOfo0MEXiyeYDV0 OGtwvqJnzjk1dgNznYSMbS4Uun/HEY89JkiHcKOAy9lSXDG4pTadAzN8gfDXa12/m9Ba 3kM4BJyhRdcKRyMl53OUxwi+8VrBGlAXaKuegWOSH5FFzpXn5IA7QTgkR9tuhh+OR5mO ELRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FEt/nY+X"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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. [23.128.96.18]) by mx.google.com with ESMTP id c11si11460043edy.260.2020.08.17.06.42.21; Mon, 17 Aug 2020 06:42:21 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FEt/nY+X"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S1728760AbgHQNmT (ORCPT + 6 others); Mon, 17 Aug 2020 09:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728665AbgHQNlj (ORCPT ); Mon, 17 Aug 2020 09:41:39 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46176C06134D for ; Mon, 17 Aug 2020 06:41:01 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id v9so17526554ljk.6 for ; Mon, 17 Aug 2020 06:41:00 -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=Oe4tacp/96y2oKOUNNpzoTA6Aq+PNNKI08nVOHEYABg=; b=FEt/nY+X/hsm906RgF6Fdze5arGgWN3YHF2GKPU9D1DtvaC6ZsUtuNxJ4I4TIoLhnD oGb1dgjjYJKHr4Y/pQKbEbEd9+rKWAFGryvnhZJ/djwJTmX32LQhtYY0q/hv/lqWWWr6 plE17wGz9J/ALORcLUnMpnKkxj9LqhMyNhqBmf9ZcssnjwIhwJKRztOXuua5qMK3RPAQ 2nrINQrPVjTcN8kdWVniIfV0Qi1r5KdxXPeqQgeyonA0d2nhWhse8SPyynJbkxf+7U8Y Ck/F0WHCdm1WPLCrdjU+g+s6iRpzovkyRvXK7+UpdziWcy+wHoIPTXzAuw+PQ5paOsqn jS1Q== 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=Oe4tacp/96y2oKOUNNpzoTA6Aq+PNNKI08nVOHEYABg=; b=ia/Zdji+YGReWZPfsoqdiuZQtw87Std5CVynwLuVsYB9GM2cLJqq8ecLAne9cQ+8Er L/Jlb1gAK+LmwhsYou4gRWqbG2jUOPkJRFhj+KaigzXUNyhWlp00PKCsTHuAMKP7KVI9 lNyHiEVxRXjkFupx7iVIp7NBh5vOBCaxEOkah+6xLtQjU2fP7eUxhfHBNYIU2ta7Z7Pk omJ4fp3N2xCZnfjVTiLu4xewcmrZ6TCHVh2BHEe6ZBG/PMPShv+ujlewT1n+7v5Cxv8W oOnVSRY/ZuD/fNEF39BMek5nauA+dT0VOsNXRIUAraQV8eSprrDB+L7jCrI7P0MYcIsN 2rsQ== X-Gm-Message-State: AOAM532WvOp6XFDUjV/Jj+AgQfgf5RHWOeTkQERgX+mmJzTqILWmd+cW tEHD+JGoMauYxBmQCAGVvS2wYg== X-Received: by 2002:a2e:a586:: with SMTP id m6mr7944732ljp.458.1597671659321; Mon, 17 Aug 2020 06:40:59 -0700 (PDT) Received: from gilgamesh.semihalf.com (193-106-246-138.noc.fibertech.net.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id g22sm3443791lja.29.2020.08.17.06.40.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Aug 2020 06:40:58 -0700 (PDT) From: Grzegorz Jaszczyk To: tglx@linutronix.de, jason@lakedaemon.net, maz@kernel.org, s-anna@ti.com Cc: grzegorz.jaszczyk@linaro.org, robh+dt@kernel.org, lee.jones@linaro.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, david@lechnology.com, praneeth@ti.com Subject: [PATCH v5 4/5] irqchip/irq-pruss-intc: Implement irq_{get, set}_irqchip_state ops Date: Mon, 17 Aug 2020 15:40:12 +0200 Message-Id: <1597671613-20879-5-git-send-email-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1597671613-20879-1-git-send-email-grzegorz.jaszczyk@linaro.org> References: <1597671613-20879-1-git-send-email-grzegorz.jaszczyk@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: David Lechner This implements the irq_get_irqchip_state and irq_set_irqchip_state callbacks for the TI PRUSS INTC driver. The set callback can be used by drivers to "kick" a PRU by injecting a PRU system event. Example: irq_set_irqchip_state(irq, IRQCHIP_STATE_PENDING, true); Signed-off-by: David Lechner Signed-off-by: Suman Anna Signed-off-by: Grzegorz Jaszczyk Reviewed-by: Lee Jones --- v4->v5: - No change. v3->v4: - Update commit message v2->v3: - Get rid of unnecessary pruss_intc_check_write() and use pruss_intc_write_reg directly. v1->v2: - https://patchwork.kernel.org/patch/11069769/ --- drivers/irqchip/irq-pruss-intc.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) -- 2.7.4 diff --git a/drivers/irqchip/irq-pruss-intc.c b/drivers/irqchip/irq-pruss-intc.c index 1a72591..15f0407 100644 --- a/drivers/irqchip/irq-pruss-intc.c +++ b/drivers/irqchip/irq-pruss-intc.c @@ -9,6 +9,7 @@ * Copyright (C) 2019 David Lechner */ +#include #include #include #include @@ -319,6 +320,43 @@ static void pruss_intc_irq_relres(struct irq_data *data) module_put(THIS_MODULE); } +static int pruss_intc_irq_get_irqchip_state(struct irq_data *data, + enum irqchip_irq_state which, + bool *state) +{ + struct pruss_intc *intc = irq_data_get_irq_chip_data(data); + u32 reg, mask, srsr; + + if (which != IRQCHIP_STATE_PENDING) + return -EINVAL; + + reg = PRU_INTC_SRSR(data->hwirq / 32); + mask = BIT(data->hwirq % 32); + + srsr = pruss_intc_read_reg(intc, reg); + + *state = !!(srsr & mask); + + return 0; +} + +static int pruss_intc_irq_set_irqchip_state(struct irq_data *data, + enum irqchip_irq_state which, + bool state) +{ + struct pruss_intc *intc = irq_data_get_irq_chip_data(data); + + if (which != IRQCHIP_STATE_PENDING) + return -EINVAL; + + if (state) + pruss_intc_write_reg(intc, PRU_INTC_SISR, data->hwirq); + else + pruss_intc_write_reg(intc, PRU_INTC_SICR, data->hwirq); + + return 0; +} + static struct irq_chip pruss_irqchip = { .name = "pruss-intc", .irq_ack = pruss_intc_irq_ack, @@ -326,6 +364,8 @@ static struct irq_chip pruss_irqchip = { .irq_unmask = pruss_intc_irq_unmask, .irq_request_resources = pruss_intc_irq_reqres, .irq_release_resources = pruss_intc_irq_relres, + .irq_get_irqchip_state = pruss_intc_irq_get_irqchip_state, + .irq_set_irqchip_state = pruss_intc_irq_set_irqchip_state, }; static int pruss_intc_validate_mapping(struct pruss_intc *intc, int event,