From patchwork Wed Sep 16 16:36:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 312686 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp788696ilg; Wed, 16 Sep 2020 13:37:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvbUXVNvlt3PSa5iDjcIkaL8hdfkTtExGalfxrULINAgIFXylBSCxlBPyq9xsrKZl9ab78 X-Received: by 2002:a50:ec12:: with SMTP id g18mr20185796edr.309.1600288661587; Wed, 16 Sep 2020 13:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600288661; cv=none; d=google.com; s=arc-20160816; b=pAd0Y2mK36g9U2EmHhiphCAO5ehrklyT1N3mD2aGfkMXDelr2dpXXVvaV1lu8fF9zN 9+qvY25ptVf2HF09hYtfgmPckNyj6xXPXnglqVkqiv9lc2mwuB8XMQC4ZXQJ0tXjlyUL VtrKqcC9z8+6jhS8zGiVa+/kEBSkccEo/T2cr9kh6oY4wtjmiFHKGGfrX8WIxuq/fu8e UhX0aVGXH9TkGteFcJJH4X4QrdVTwOn6WjoSdCLaNfljnvMZXS0Cly6a/Lc7CJtaq52s qxC3WsfA+LYRocwONmwCvZZH0ugYs7abU9BxR/yz5sdyNNq4HASNFDZ9KI00nTytid61 3m+g== 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=EkdGaMAWsiITjixL8vtqkk4znvOu3Q/xzFs2YIEcfEY=; b=T/UnDp1Ww6vHp3+LHkPRB6hj2bvDZJiwlVoSD1XyvM4UV7MfwcPHyhfyGgMsS08w41 tWTU45k5XjH50XarwOF2xX8rvtvNlXBO6QtJe4UZ35HhpuLvdgnGrpTqrn4fVgCQ2KEY 0dkzepbo8nKaqYoRNXyOS7xRfCydu5WV8+opKdxANsiXsCPUoUIHCGDobyQPQo4ZJk0R y2veciOnble43ly8liEPw5FJZv0mVZz7WZJQU6pDs+kvwcLSrlZg2dxVsF5tTZh0EkCg JafjlnOHoPBSvUhYz1sH9o6OyD3udJFh//+Gkn4NN3KSAOunesGYyA7SDokivLweLowy ITNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dpvpqsnv; 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 o22si14097743edr.356.2020.09.16.13.37.41; Wed, 16 Sep 2020 13:37:41 -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=dpvpqsnv; 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 S1726361AbgIPUhh (ORCPT + 6 others); Wed, 16 Sep 2020 16:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726672AbgIPRKN (ORCPT ); Wed, 16 Sep 2020 13:10:13 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F05D4C02C2B6 for ; Wed, 16 Sep 2020 09:37:09 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id b19so6457707lji.11 for ; Wed, 16 Sep 2020 09:37:09 -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=EkdGaMAWsiITjixL8vtqkk4znvOu3Q/xzFs2YIEcfEY=; b=dpvpqsnv1se+B+N0B3X73ZARW0xp0qYtrllJbwUMEaTaPYAhDr3QA1JvBn8NUzvi/Z s8/YO99GSsIQU66VS4Y21URWzrqFy3MCSfvxw+pZqn4rifzBbNx2BJgMeksakO170Z52 JPksnTeACT5MlZRIedoBUIaPfuTTJMYrmuNm4nBCXCwlym2M+aUB2z4kYkJ0ouJaSY00 70k7LERJHRRCJjPRwRId0KijyzilqRY9bkwG2n2Sba11nDKP2TEzW5F79CkYt4U8RCAV +RMne5o9ys2+dp6NFUda1mLsnvldt8KlUv+Tr51FA+G/lZn1INDC4VhR7AUJMAsKGndQ DMuQ== 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=EkdGaMAWsiITjixL8vtqkk4znvOu3Q/xzFs2YIEcfEY=; b=TWcJfIEjnTm1wFdJjkogXPeGJG2Z2oblhy9TrakDfYAakr1uGgrN9amdPx6w53nlgG hqKL5DNYWcnyPH5TesGE+q6si8CcAMJSpsrzwUWKgcdDd4ftpk02nI+kDdDulHBGE841 agwOJYsDglxr7IIPgJhPMZxeoc8wgYE8ufzvJbZ9bxVpu++Nn6m8RZCCU8juGBGIF/EP WkreUZ+KqamGOKrfHgCbJz/lvw/5ercnNgYeZVK+LdY4JWASPgmcdBI0n3kEwoFHD9CS M4Gvx/jgkQk7tlX+PInjMsF2u5W5GCjPUb8wqdrTrKRT9kbPoIzXv3+efRSp6/0Zeeag R29Q== X-Gm-Message-State: AOAM5310bMOSC/URL7HWhS914v4qd004b+suuqANyGY+XgzHOH+cgPIk UxdCXoHBeampdaVLEfanOGcZvw== X-Received: by 2002:a2e:a587:: with SMTP id m7mr8896222ljp.133.1600274227566; Wed, 16 Sep 2020 09:37:07 -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 o15sm4684400lfo.188.2020.09.16.09.37.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 09:37:07 -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 v7 4/5] irqchip/irq-pruss-intc: Implement irq_{get, set}_irqchip_state ops Date: Wed, 16 Sep 2020 18:36:37 +0200 Message-Id: <1600274198-30470-2-git-send-email-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600274198-30470-1-git-send-email-grzegorz.jaszczyk@linaro.org> References: <1600274198-30470-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. Co-developed-by: Suman Anna Signed-off-by: Suman Anna Signed-off-by: David Lechner Co-developed-by: Grzegorz Jaszczyk Signed-off-by: Grzegorz Jaszczyk Reviewed-by: Lee Jones --- v6->v7: - Add Co-developed-by tags. 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(+) -- 2.7.4 diff --git a/drivers/irqchip/irq-pruss-intc.c b/drivers/irqchip/irq-pruss-intc.c index e7ba358..bfe529a 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,