From patchwork Tue Sep 15 11:00:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 11776193 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A6B6618 for ; Tue, 15 Sep 2020 11:11:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 8FEC4218AC for ; Tue, 15 Sep 2020 11:11:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AnKnJ1QO"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bu9PMoyx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FEC4218AC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5MnhcpPfGmRivZKiM0Ravwi9Ykw10qLIsEauPTyJL/s=; b=AnKnJ1QOZQoasqXwpaGtqZOXlK aVkVkJ2D3c88OwC1ESI6Qo9AGoaBemH+2rvltzxZkMvOGoZpHtqinBlqU7mvpgNO/7/KcE4b5+lZX s6llYuHbMuugiWxB8GfnZnkVje999wdtM/iS3fb6M0o6Nzaddc+w6nxEPaZAabdvgRSHUjBmN5hCD huxjbv2qvG0mVZRNSM5SukWb0+E/ArbeI4wmWZ57yCQv+me2GiRjyHBLbmAGquBcfyWgwIVT7dyic gwV9+knXx0/jnZS+q+l4zMEY1O7lrICMy77+eg0U2h1rt+Oss6LMJ4tA6DKfPDxTYKsZKQpB6kn9T BeUr0otg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI8pZ-0001n9-9R; Tue, 15 Sep 2020 11:09:02 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI8iF-0006z0-NN for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2020 11:01:34 +0000 Received: by mail-lf1-x141.google.com with SMTP id b22so2568817lfs.13 for ; Tue, 15 Sep 2020 04:01:25 -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=lb/mFl69xCVhbl8PtHcEwFweRXaOMufe6QhIFPJRLYsNOZlgN2hSWbs5P6rxVL9bY3 ii7u6mWzzlFFHgo2fhUAwPmiyqp8dx6fGZDDN0ZDQSzZlZZtssfCtX6Hi7oME6trLPKV b/6TX837wkklnQF+o6Qh2ADnFScy6WeMg7Iohh7XRg1Bhjeroz9maJgQ3EDx3mjEETwN 6uMpdAjF8Fvzt2NRIWuOSkkgi4FTu3NESNAPGMuwrSxMDO22h5eYpgR3tWFGGhK3hCw8 HHSjgR3R5WfENiXHmBoyLw+t5SqCqgviXvXuPAQ8iu8XNqIlnqs24FhM5hYfPmqevoWY o8lQ== X-Gm-Message-State: AOAM533NZ9UrogIKx9iNn0OBAZnAn9UCCKifmasQLUqt3UEZBIeEwEEo jYegSa9bKdzqRDCPWpAuQSFStg== X-Google-Smtp-Source: ABdhPJzp9MBZN/pyDF9GzMLHUJeD6RV5x2JiSkBUFmjYlSIsuOj7jjb30r36nAQxW4uhgqAt4m+WVg== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200915_070128_624770_F8D0507D X-CRM114-Status: GOOD ( 18.04 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:141 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, grzegorz.jaszczyk@linaro.org, david@lechnology.com, praneeth@ti.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-omap@vger.kernel.org, lee.jones@linaro.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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,