Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2070167lqa; Tue, 30 Apr 2024 07:28:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4HuEfPMSd+uGsG2yB1idF+NkGM80eG7GnIBzTaRVSgu7O2CgUjORY0p+ji92botsOuLhZEXVYvDVUI/C9TAUW3nHzmBrsI/EJfBSxiA== X-Google-Smtp-Source: AGHT+IFaKfqrnBgGdZljudVVMKGNhfwXMBR2MdWRRXZq6q6jbrnPMHT2QTOxsdjXYJYviX3m2am1 X-Received: by 2002:a05:6a20:12c1:b0:1a7:63ac:a3aa with SMTP id v1-20020a056a2012c100b001a763aca3aamr3760592pzg.30.1714487296669; Tue, 30 Apr 2024 07:28:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714487296; cv=pass; d=google.com; s=arc-20160816; b=N9CNOA/nmKIv+T8NlVCVJiGiOkeguskzgtF0PynKwCHcHtTbKfLUP2cT+hFseyuMag SgTXLWlceQHdwWTZQWcW24L9sg1WmIm/iV7x3pFb6+Bjeyx4sU1aslontqxJf+0NvgpW 9QR7c4RP0mbqAKRvdh8EsJrBoh72u+m/Ik+EJe5rqRnfHHIdySXyBO0Tk+P4hSwYuKji 35MUakx02iNbjSk4xbwMOA5rmbl2Y49YWu8m7WcVHYIya/Mv3fmdEbjnschIq7p0e2Us 7Gne3yC5nTGwTarEVXXrCAyt0GZ0B6Dn09LFqNWC4DFNqvRBBwT4D197UtdhCqqQeDTJ XK7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5kv+AH2AjQwed6PGaED+AOOlkw433dBO11c9HZx9xXs=; fh=7/F96/Ct8M4/1US8X9pdy/qRrLXm0tI5YraBvE/QzXU=; b=SsRgUNnrNC8gL0r0mm8PWdhzrB+0GCuy7mEai0VD5bByyGHcp2TaC3MQ0QAXq2oqkz 69BNvHLqtR29zTLNO0knXAR3bNcyU261VMtRTrf5r9bgh/vexnfe/mi32iez6nKGUkMT Tt4rNiAJKIXUCzGAYC+2Ip9l9brX0n2x3UPmCnmFuCj5kREGw3HbiGzPK8hSxutsQcFI eQ5/+K54FLss7hlxyq1IwBwhJKALUhJIFXDQEHh0jbNC+Cit7YNeTzVGn6S/wzyfboOQ D/GEXY8jtvPv2TL/bMdw18G6YZulZQk9NG7U0JukvNgy00kYG/8zIHSvXGfza0XcoRhS C5xA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dYEUoiKA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-164125-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164125-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bd9-20020a056a00278900b006f0293ef76dsi22223610pfb.74.2024.04.30.07.28.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 07:28:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164125-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dYEUoiKA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-164125-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164125-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 124E828258B for ; Tue, 30 Apr 2024 14:28:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 615D51C8FBF; Tue, 30 Apr 2024 14:15:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dYEUoiKA" Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2AAE1C8FA3; Tue, 30 Apr 2024 14:15:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714486516; cv=none; b=XeI1iybcz1f9wIwU8a4BcWiwcOuuQQp3RCfb5hZ3WsVRKsv3qh7jzdD8Ayv5Nen4EfwsPTICL5Z+AbgCrMI54gYbG3N/OS++TT0D7aP5uY0a6e+Q08lzNHKtj3W167tIVN6aVNcah/N7MwtUK+duCUwYC4MGUl0sNW18onrEt54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714486516; c=relaxed/simple; bh=MuncWkwuwfVa8wYmiFLN1XCnZXYluzh649G4ohOiNVI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s8HFn8Pnsf5XoelJfcN7dta84dfnwta9m1LQP7r0L287uA3+D0KZxmYddSB5L/H5AHb28D9ZsbgOHNrzNSzdK2czq8FetsiSlVdwMq78t17Iibq+y/5oJ7dKvR5J/EKxpeaOFBZIkW2YmcjkkP7cBjtl2JiczLEF7PxexSEpteE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dYEUoiKA; arc=none smtp.client-ip=209.85.216.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2ad8919ba0cso5053941a91.0; Tue, 30 Apr 2024 07:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714486514; x=1715091314; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5kv+AH2AjQwed6PGaED+AOOlkw433dBO11c9HZx9xXs=; b=dYEUoiKArK9Fqbx9LUPEFFpu8QLKfKrGr3TfeAsFk1zE3dtU/f/CXBPhxjmXEvCxf3 mz4FixZqcmc6fUEJldYRHClQE7uFxAkfl7UxE3oZR9BMs+vKV66+UuMFNuqffQANkRP/ QfTy4A+akhvdAHZOxFNgLCJm1DuAYkcnFLwMG+r5Dq4WZ4Tt89diR0jmeuL4+ILMKpDL /KbAZ9rAHwE9CjgodekjbOyNdPb+gJbDB5nM7+OuuPGDvRIZIouWUXoWoHbV6b+fl3p/ +/CF9WzvMXz2zwQigZdbntPXxVsYymXp8Ut+0Kr97+0QLE+asB+Px6gQspLkA7CyiXm8 0nvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714486514; x=1715091314; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5kv+AH2AjQwed6PGaED+AOOlkw433dBO11c9HZx9xXs=; b=c8ngFHDtrmzK8DbBeqKwxrQRGo1AsgQd2PIIYWR07nfcYKqs3qzOa/ZLeVc8Q5pkai yP2qyq7YoP3tdx2ZwasbFYt1B4UwUjdX+jdaXQHFf/mnm69iu2Nh2ztEQmqSuPbJm6lk +O7v1WTboh6slbvjhKrxdJoHQ0X+78cbuTv5Yo+x0Sw5pX3t2+6uKrZN1J4ZQEQSIg1r 3/lArMwyj/TYLkpEaIX/Ip5eFdSvPi/7JrjkgkfNwqYQbLF3pbV5LMcyE6aw4xEloCt1 X3CJ1qWv4JS3MIjsrzQTxuJVjduz8Da3NDqdYjfVblvDmXzjmSYPG8jAUtJwkvjEn26N rByA== X-Forwarded-Encrypted: i=1; AJvYcCX3DZDjYQ1sVoL+L9fjmKkLHLSgA2mqvN8eXwBdQkhDom3VkC8kX0zb0tjFPkubLLpaJWIV6u7jTlgORxsLpDrfRuBHRq/WwNVGPmJsTeeFy85dDeIfYKg3W6eOx55fEKRAz2e1OI0QhpDyMNW9 X-Gm-Message-State: AOJu0Yyj3QwqyHaj33592301PmXVqblvmqOesiXiLKMPvpk/4RM8+MJw 4sSJG/gYzaJRTfIPM7kZHhyF6jJiEmOQZbcf10kgOOh3OnKf/iDz X-Received: by 2002:a17:90b:4c49:b0:2b0:7f15:9155 with SMTP id np9-20020a17090b4c4900b002b07f159155mr3003910pjb.31.1714486513677; Tue, 30 Apr 2024 07:15:13 -0700 (PDT) Received: from prasmi.domain.name ([103.219.60.80]) by smtp.gmail.com with ESMTPSA id az24-20020a17090b029800b0029bacd0f271sm22883227pjb.31.2024.04.30.07.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 07:15:13 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: [PATCH v4 2/2] irqchip/renesas-rzg2l: Add support for RZ/Five SoC Date: Tue, 30 Apr 2024 15:14:38 +0100 Message-Id: <20240430141438.132838-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240430141438.132838-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240430141438.132838-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Lad Prabhakar The IX45 block has additional mask registers (NMSK/IMSK/TMSK) compared to the RZ/G2L (family) SoC. A new rzfive_irqc_chip irq_chip is introduced for RZ/Five, where function pointers for irq_(un)mask and irq_(dis/en)able handle the (un)masking of the interrupts. The irq_chip pointer is now passed as an init callback and stored in the priv pointer to differentiate between RZ/G2L and RZ/Five. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- v3->v4 - Renamed rzg2l_irqc_init_helper -> rzg2l_irqc_common_init - Moved the locks into callers for (un)mask and (en/dis)able functions - Collected RB tag from Geert v2->v3 - Added RZ/Five specific irqchip instead of polluting the functions - Fixed review comments pointed by Biju and Geert - Updated commit message - moved locking to respective read/write functions v1->v2 - Added IRQCHIP_MATCH() for RZ/Five - Retaining a copy of OF data in priv - Rebased the changes --- drivers/irqchip/irq-renesas-rzg2l.c | 148 +++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-renesas-rzg2l.c b/drivers/irqchip/irq-renesas-rzg2l.c index f6484bf15e0b..98a6a339fe43 100644 --- a/drivers/irqchip/irq-renesas-rzg2l.c +++ b/drivers/irqchip/irq-renesas-rzg2l.c @@ -37,6 +37,8 @@ #define TSSEL_SHIFT(n) (8 * (n)) #define TSSEL_MASK GENMASK(7, 0) #define IRQ_MASK 0x3 +#define IMSK 0x10010 +#define TMSK 0x10020 #define TSSR_OFFSET(n) ((n) % 4) #define TSSR_INDEX(n) ((n) / 4) @@ -69,12 +71,14 @@ struct rzg2l_irqc_reg_cache { /** * struct rzg2l_irqc_priv - IRQ controller private data structure * @base: Controller's base address + * @irqchip: Pointer to struct irq_chip * @fwspec: IRQ firmware specific data * @lock: Lock to serialize access to hardware registers * @cache: Registers cache for suspend/resume */ static struct rzg2l_irqc_priv { void __iomem *base; + const struct irq_chip *irqchip; struct irq_fwspec fwspec[IRQC_NUM_IRQ]; raw_spinlock_t lock; struct rzg2l_irqc_reg_cache cache; @@ -138,6 +142,111 @@ static void rzg2l_irqc_eoi(struct irq_data *d) irq_chip_eoi_parent(d); } +static void rzfive_irqc_mask_irq_interrupt(struct rzg2l_irqc_priv *priv, + unsigned int hwirq) +{ + u32 bit = BIT(hwirq - IRQC_IRQ_START); + + writel_relaxed(readl_relaxed(priv->base + IMSK) | bit, priv->base + IMSK); +} + +static void rzfive_irqc_unmask_irq_interrupt(struct rzg2l_irqc_priv *priv, + unsigned int hwirq) +{ + u32 bit = BIT(hwirq - IRQC_IRQ_START); + + writel_relaxed(readl_relaxed(priv->base + IMSK) & ~bit, priv->base + IMSK); +} + +static void rzfive_irqc_mask_tint_interrupt(struct rzg2l_irqc_priv *priv, + unsigned int hwirq) +{ + u32 bit = BIT(hwirq - IRQC_TINT_START); + + writel_relaxed(readl_relaxed(priv->base + TMSK) | bit, priv->base + TMSK); +} + +static void rzfive_irqc_unmask_tint_interrupt(struct rzg2l_irqc_priv *priv, + unsigned int hwirq) +{ + u32 bit = BIT(hwirq - IRQC_TINT_START); + + writel_relaxed(readl_relaxed(priv->base + TMSK) & ~bit, priv->base + TMSK); +} + +static void rzfive_irqc_mask(struct irq_data *d) +{ + struct rzg2l_irqc_priv *priv = irq_data_to_priv(d); + unsigned int hwirq = irqd_to_hwirq(d); + + raw_spin_lock(&priv->lock); + if (hwirq >= IRQC_IRQ_START && hwirq <= IRQC_IRQ_COUNT) + rzfive_irqc_mask_irq_interrupt(priv, hwirq); + else if (hwirq >= IRQC_TINT_START && hwirq < IRQC_NUM_IRQ) + rzfive_irqc_mask_tint_interrupt(priv, hwirq); + raw_spin_unlock(&priv->lock); + irq_chip_mask_parent(d); +} + +static void rzfive_irqc_unmask(struct irq_data *d) +{ + struct rzg2l_irqc_priv *priv = irq_data_to_priv(d); + unsigned int hwirq = irqd_to_hwirq(d); + + raw_spin_lock(&priv->lock); + if (hwirq >= IRQC_IRQ_START && hwirq <= IRQC_IRQ_COUNT) + rzfive_irqc_unmask_irq_interrupt(priv, hwirq); + else if (hwirq >= IRQC_TINT_START && hwirq < IRQC_NUM_IRQ) + rzfive_irqc_unmask_tint_interrupt(priv, hwirq); + raw_spin_unlock(&priv->lock); + irq_chip_unmask_parent(d); +} + +static void rzfive_tint_irq_endisable(struct irq_data *d, bool enable) +{ + struct rzg2l_irqc_priv *priv = irq_data_to_priv(d); + unsigned int hwirq = irqd_to_hwirq(d); + + if (hwirq >= IRQC_TINT_START && hwirq < IRQC_NUM_IRQ) { + u32 offset = hwirq - IRQC_TINT_START; + u32 tssr_offset = TSSR_OFFSET(offset); + u8 tssr_index = TSSR_INDEX(offset); + u32 reg; + + raw_spin_lock(&priv->lock); + if (enable) + rzfive_irqc_unmask_tint_interrupt(priv, hwirq); + else + rzfive_irqc_mask_tint_interrupt(priv, hwirq); + reg = readl_relaxed(priv->base + TSSR(tssr_index)); + if (enable) + reg |= TIEN << TSSEL_SHIFT(tssr_offset); + else + reg &= ~(TIEN << TSSEL_SHIFT(tssr_offset)); + writel_relaxed(reg, priv->base + TSSR(tssr_index)); + raw_spin_unlock(&priv->lock); + } else { + raw_spin_lock(&priv->lock); + if (enable) + rzfive_irqc_unmask_irq_interrupt(priv, hwirq); + else + rzfive_irqc_mask_irq_interrupt(priv, hwirq); + raw_spin_unlock(&priv->lock); + } +} + +static void rzfive_irqc_irq_disable(struct irq_data *d) +{ + rzfive_tint_irq_endisable(d, false); + irq_chip_disable_parent(d); +} + +static void rzfive_irqc_irq_enable(struct irq_data *d) +{ + rzfive_tint_irq_endisable(d, true); + irq_chip_enable_parent(d); +} + static void rzg2l_tint_irq_endisable(struct irq_data *d, bool enable) { unsigned int hw_irq = irqd_to_hwirq(d); @@ -321,7 +430,7 @@ static struct syscore_ops rzg2l_irqc_syscore_ops = { .resume = rzg2l_irqc_irq_resume, }; -static const struct irq_chip irqc_chip = { +static const struct irq_chip rzg2l_irqc_chip = { .name = "rzg2l-irqc", .irq_eoi = rzg2l_irqc_eoi, .irq_mask = irq_chip_mask_parent, @@ -338,6 +447,23 @@ static const struct irq_chip irqc_chip = { IRQCHIP_SKIP_SET_WAKE, }; +static const struct irq_chip rzfive_irqc_chip = { + .name = "rzfive-irqc", + .irq_eoi = rzg2l_irqc_eoi, + .irq_mask = rzfive_irqc_mask, + .irq_unmask = rzfive_irqc_unmask, + .irq_disable = rzfive_irqc_irq_disable, + .irq_enable = rzfive_irqc_irq_enable, + .irq_get_irqchip_state = irq_chip_get_parent_state, + .irq_set_irqchip_state = irq_chip_set_parent_state, + .irq_retrigger = irq_chip_retrigger_hierarchy, + .irq_set_type = rzg2l_irqc_set_type, + .irq_set_affinity = irq_chip_set_affinity_parent, + .flags = IRQCHIP_MASK_ON_SUSPEND | + IRQCHIP_SET_TYPE_MASKED | + IRQCHIP_SKIP_SET_WAKE, +}; + static int rzg2l_irqc_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *arg) { @@ -369,7 +495,7 @@ static int rzg2l_irqc_alloc(struct irq_domain *domain, unsigned int virq, if (hwirq > (IRQC_NUM_IRQ - 1)) return -EINVAL; - ret = irq_domain_set_hwirq_and_chip(domain, virq, hwirq, &irqc_chip, + ret = irq_domain_set_hwirq_and_chip(domain, virq, hwirq, priv->irqchip, (void *)(uintptr_t)tint); if (ret) return ret; @@ -401,7 +527,8 @@ static int rzg2l_irqc_parse_interrupts(struct rzg2l_irqc_priv *priv, return 0; } -static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) +static int rzg2l_irqc_common_init(struct device_node *node, struct device_node *parent, + const struct irq_chip *irq_chip) { struct irq_domain *irq_domain, *parent_domain; struct platform_device *pdev; @@ -422,6 +549,8 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) if (!rzg2l_irqc_data) return -ENOMEM; + rzg2l_irqc_data->irqchip = irq_chip; + rzg2l_irqc_data->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL); if (IS_ERR(rzg2l_irqc_data->base)) return PTR_ERR(rzg2l_irqc_data->base); @@ -472,8 +601,21 @@ static int rzg2l_irqc_init(struct device_node *node, struct device_node *parent) return ret; } +static int __init rzg2l_irqc_init(struct device_node *node, + struct device_node *parent) +{ + return rzg2l_irqc_common_init(node, parent, &rzg2l_irqc_chip); +} + +static int __init rzfive_irqc_init(struct device_node *node, + struct device_node *parent) +{ + return rzg2l_irqc_common_init(node, parent, &rzfive_irqc_chip); +} + IRQCHIP_PLATFORM_DRIVER_BEGIN(rzg2l_irqc) IRQCHIP_MATCH("renesas,rzg2l-irqc", rzg2l_irqc_init) +IRQCHIP_MATCH("renesas,r9a07g043f-irqc", rzfive_irqc_init) IRQCHIP_PLATFORM_DRIVER_END(rzg2l_irqc) MODULE_AUTHOR("Lad Prabhakar "); MODULE_DESCRIPTION("Renesas RZ/G2L IRQC Driver"); -- 2.34.1