Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp64537pxk; Tue, 15 Sep 2020 17:58:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz83Q/QnJJ0KWnHF7C4TocSEQmxIrQ6gRasw51H5mns/fAdZH/nUFBf4Az/b+g4sgeJ0LFV X-Received: by 2002:a50:abc3:: with SMTP id u61mr24420459edc.129.1600217909685; Tue, 15 Sep 2020 17:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600217909; cv=none; d=google.com; s=arc-20160816; b=yMW/KvPKovC/nUjZBU1OXgyo11TbUKJAMPlrlnh2xLmadXQ/iaY7460Xasqg6iJqfy wL1hLn6IQ1LFR6gYCPDhe2BrzcBfK7WGKttx714mPRGpDoXW8YvbapWqQV6ub9vUUGD7 LD+3Fboiy1NzBq+FD34PQ22GFwHE3euXpf7aVBmdA85xVFJInzYrtIKYlw2pz9/utgS4 E/c2pLPW1q7aSAcf8iSiLiiLDa4PXw7UUfSDxoeC0ZN/WQpFZOtZxdJoU3MG8cnCmQBd 8bjBLwKZ6rr1yHmQbpRA30hAkO1K683WBD2Ay4vnrmTATT1euWhfLRtbctl+am8fSHYL 3ZkA== 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=0bFMdRSpPXTVw6FkASDzFuci7f9roVwhgsTsGiODYGg=; b=GiZnSIyrRKKtyd7l8syGhgqdJc/Vb2Mul1gQGX0HzQzoLEa4hdGmRro0fesbxLqo+Y aUwDb/x59H93N6uyUfI5OOvvxXkmvboVq0PxES103tX/C7kdRIAH4sVf76/jkpJqJJpH t/UbKkpnlPh1m6VQQKA8X0ZEjFZ7RtbexIwCGc0xraQgACxUmLRegRY40ETs0aRrYH4I idaprB5bq88V4ATh86QGGXpOOSYYgVJjJFTt2qI7T45AENtaPNEs6uwxZQqGDAJ048ii zYFyhMfu/n+TX/kMmzx4sjCZ7sTfdhHMPj4SYRLaj7NFEwrDCby6A7HmQ2cIH2joiBt6 Wyew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bu9PMoyx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 bf4si2417042edb.290.2020.09.15.17.58.08; Tue, 15 Sep 2020 17:58:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=bu9PMoyx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726061AbgIPA52 (ORCPT + 99 others); Tue, 15 Sep 2020 20:57:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726180AbgIOLPB (ORCPT ); Tue, 15 Sep 2020 07:15:01 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19192C0612F2 for ; Tue, 15 Sep 2020 04:01:27 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id b12so2597104lfp.9 for ; Tue, 15 Sep 2020 04:01:26 -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=0bFMdRSpPXTVw6FkASDzFuci7f9roVwhgsTsGiODYGg=; b=bu9PMoyxQXeCQJXQTnO4uU92zugPEP+32GJTwTJGhFmLd0RKGN8bQMrRnrKu/zSoeW GHnIGVzICEGX5Pcf0CeO2+Vx2PIVKlddZLpPH53MSxEf3QsDaWP9sxmMvToBFOJpJqXG R3YHAgG2fzOpyA+PLcgFr5shCpOAsw7ncEZGKNcuLmrZ8IswbWdlBJDRYLAPLj/OKHTR QGOISTSf5PVYJsjPvlHeeE7eNFI087vR7/7dGkIjI+4lO4+qRZYbVvDoH0baNiQRGZJH l0oBFry2v5TM9hZWyFzXSFUNlc2QdW8s/A2tMXdKHLu8VVG0wIUW078NKWlFvKuaIHs5 PHNw== 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=0bFMdRSpPXTVw6FkASDzFuci7f9roVwhgsTsGiODYGg=; b=IhNhyZKm2fm9+El6eXmoXgDBWnNun7I1Movf7i4zJ/rN1Af3CkT2AqQahxKjHdxcI/ tmlFGwcJFq7ZbZ/gcoU6O7a4gxyiIZL9+STtgjnEiWTvkezjqs08Wd3YWqlexpUj4o52 1R6xiakuHsHLLEjYExfUcCxXT8rjgVedhd+3l4jxu5Jx6Hl2ALNinbnJ2ev17CZc1/KY I027u0p+eTnYRTyw55qC5LPti3d9DYPzXgmhYOkhjSpN/QZbzQk7ZNwTEv54M7yeXFTR Poh0j3dvRSx13gp8taJQYIwQT22gd41KNDTdD9wUX4DTQAGxijfvPKyR8yeSYwjUoD00 G+Jg== X-Gm-Message-State: AOAM531GMSCXR7+obbJtZb6kO9HybY2AiqlX0wne1XQwN+6sJb05nRT7 5/C+QK+fcbh94pD9wREXrrpEQA== X-Received: by 2002:a19:d95:: with SMTP id 143mr5883867lfn.4.1600167684008; Tue, 15 Sep 2020 04:01:24 -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 n3sm4588916ljj.59.2020.09.15.04.01.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 04:01:23 -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 v6 4/5] irqchip/irq-pruss-intc: Implement irq_{get,set}_irqchip_state ops Date: Tue, 15 Sep 2020 13:00:50 +0200 Message-Id: <1600167651-20851-5-git-send-email-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600167651-20851-1-git-send-email-grzegorz.jaszczyk@linaro.org> References: <1600167651-20851-1-git-send-email-grzegorz.jaszczyk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Signed-off-by: David Lechner Signed-off-by: Suman Anna Signed-off-by: Grzegorz Jaszczyk Reviewed-by: Lee Jones --- v5->v6: - Drop example from the commit log 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(+) diff --git a/drivers/irqchip/irq-pruss-intc.c b/drivers/irqchip/irq-pruss-intc.c index 396dc55..41c6271 100644 --- a/drivers/irqchip/irq-pruss-intc.c +++ b/drivers/irqchip/irq-pruss-intc.c @@ -12,6 +12,7 @@ * Copyright (C) 2019 David Lechner */ +#include #include #include #include @@ -323,6 +324,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, @@ -330,6 +368,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, -- 2.7.4