Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1513211ybt; Thu, 2 Jul 2020 07:21:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS5h+I77Dns/bhCUMf9m0SmIwRWPNLsvcRw9R4uNjCDSEEYBwVQJQdMEOwZqPR8T/VGtyx X-Received: by 2002:aa7:c450:: with SMTP id n16mr30866663edr.53.1593699667943; Thu, 02 Jul 2020 07:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593699667; cv=none; d=google.com; s=arc-20160816; b=NfpJRMpVAPhWbNOhykUC+H6b5OihdU7uCleakpJBDp1wOA/FYW9YH+Cqu301t5AE+w RyA5C3Dtt1F1sNHbJB18ffbqmx7QLQbvh2PDcGDjG836t1y3A+3fEOl+GpSFURbwVYav W8pQaBn9kv2Gi1+0mjozH09aEV5QIRESUb7nV+9DXITQ16zYADNvnQzDhZe//KJC0Ul+ qmvSVkuHevTIJ39rCYmAfXBiCJrTCWGguFbi1a1A1EKaze69UWNj46YjjFn/hGxrpfHF Qr4eBTVQw2vp7v0SGtCpFV+N9jH8p/wd8DWmrZnOTvMdXORndZw2wUGGZlPcbRKzctYI lcKw== 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=4HO8KIlLqlwP/f8Ruj28glCZZ5K9Sse59aSvMxbiXe4=; b=a5kiqpQo17Nfhf2KtU68MzL44rxiVF5AvyUR4n+khqUKkJV9ETLVLgHwDCss1Ox1fb MTHUAJaQgYq5VvlTUAkiqyKVAC6JQdKPAVe4sFPDK+JdSLxJ5wwX8Wx5auucq7XYo/ht A2lzG62i+MI2uNF9DHGip2pqgKtfTD19cGobVlGfdgjMxwEG6yyxsP7/+JGr0aEL29kI nbbRcHxLwaQv/EUbCv7DvEwEjMtKRDlumUoGUXhM6cZYZtkGB6JCvP8CJ0sK/kyKulpW qbNjmnrHy37FD6hzOS5ve8DkxEkjp9gihjNupKAAqIpnUDB/WYm0o/KQvuEjxEsIQhwz /RDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NVq8KjQj; 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 ci27si3384224ejc.199.2020.07.02.07.20.44; Thu, 02 Jul 2020 07:21:07 -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=NVq8KjQj; 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 S1729768AbgGBOUL (ORCPT + 99 others); Thu, 2 Jul 2020 10:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729752AbgGBOUI (ORCPT ); Thu, 2 Jul 2020 10:20:08 -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 7CDE4C08C5DD for ; Thu, 2 Jul 2020 07:20:08 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id b25so28799324ljp.6 for ; Thu, 02 Jul 2020 07:20:08 -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=4HO8KIlLqlwP/f8Ruj28glCZZ5K9Sse59aSvMxbiXe4=; b=NVq8KjQj97pZ12DfuDX6ObhQONPpx/XLwguVE7MeHvMriwV3ZpTcy5F3yNAwmciTo3 piNKbV7bXjATmWytRK9un5tZckGbMaIkUPi1Ty6/ovHoLgHd+TrSwF82jtVj0d7b+amR GQcYfyGAS6qpR3QiIhsE1NR0PD11MCyHhkJnn/nwWCiMbYwM6foJ6gFV9E3sIsUeOMmm i3OmQyS7TnPi/O3+1sGIy6kRdIBGXm79RoZhFmXV2b2Y5uuj0P5nfo9aX5Fkq6B6RD0M Z6zKn3L5yTSgEaLl85/tpdp3pqryd3JTPo/l/DqMik2PATKjrwduG4jEYdjxwfzvTZhy nKow== 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=4HO8KIlLqlwP/f8Ruj28glCZZ5K9Sse59aSvMxbiXe4=; b=fpADDb2LubAl/wMOLkAMD8y6o/KfEQQ9LLm90JEP6qjbDv960ZmpwGjcnMAP49Xbm/ YWW9AhH3ZKuHLw8CeE9Q5U2TKeDHJkZql2nHsp3V0Xr2lU4iF3yXdacxK1yCphS/5P4/ vaJRV1/i2J+PAiPtCEVqckTaYg8DfiEq9EbFmdypOsIRJ8uxJMWxNDYs25aTcCe3N5V+ ZE9ef8XMZnxq++3ywPlbFLvZbE2vYPznpOs3EYglQP3MtaENeL0mKngCTYsMbfZVoyEW UvcnMBiNYb94SsLYlIV2fo7PUXqrhoJM7cuWyUpyJt6Fg+9epEOyKyM7eYM9PWQ8YF/9 xruA== X-Gm-Message-State: AOAM530vy0nk3+8lAz5eSVU1FUP1rVbyRKCqIUlhYWs0YPLuDV/pc7+2 VD9QMauDTAX1tN9FnisBOTlgPw== X-Received: by 2002:a2e:91da:: with SMTP id u26mr10525805ljg.311.1593699606933; Thu, 02 Jul 2020 07:20:06 -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 v10sm692581ljg.113.2020.07.02.07.20.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2020 07:20:06 -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, wmills@ti.com Subject: [PATCHv3 4/6] irqchip/irq-pruss-intc: Implement irq_{get,set}_irqchip_state ops Date: Thu, 2 Jul 2020 16:17:57 +0200 Message-Id: <1593699479-1445-5-git-send-email-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593699479-1445-1-git-send-email-grzegorz.jaszczyk@linaro.org> References: <1593699479-1445-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 enabling 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 --- 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 | 43 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-pruss-intc.c b/drivers/irqchip/irq-pruss-intc.c index 49c936f..19b3d38 100644 --- a/drivers/irqchip/irq-pruss-intc.c +++ b/drivers/irqchip/irq-pruss-intc.c @@ -7,6 +7,7 @@ * Suman Anna */ +#include #include #include #include @@ -39,8 +40,7 @@ #define PRU_INTC_HIEISR 0x0034 #define PRU_INTC_HIDISR 0x0038 #define PRU_INTC_GPIR 0x0080 -#define PRU_INTC_SRSR0 0x0200 -#define PRU_INTC_SRSR1 0x0204 +#define PRU_INTC_SRSR(x) (0x0200 + (x) * 4) #define PRU_INTC_SECR0 0x0280 #define PRU_INTC_SECR1 0x0284 #define PRU_INTC_ESR0 0x0300 @@ -145,6 +145,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, @@ -152,6 +189,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_irq_domain_map(struct irq_domain *d, unsigned int virq, -- 2.7.4