From patchwork Tue Apr 30 14:14:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13649336 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 36CA91C68A9; Tue, 30 Apr 2024 14:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714486512; cv=none; b=SXR7VAX+4J6THhZqXRQLpmR6P5EHVZvFREe2QJo9uXyUqPAY81c/CHRNCumclAKpdaFFO9ecFI0PHuKFl9yUPazWbKk/iHI/GNK4bWOL5Czk6ty6ZJ7HTyTk4Cib1ePoW+8/LZV++oQq4Pkpq2EomP47dQ1IzDh49gElhMcPCfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714486512; c=relaxed/simple; bh=H1f/cjbXVrukZwHoRkAAwV+1+emj9a4hTyz8Updt7oU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=snxF+2sfgYSSuDTtBNR/ZGNe2zxnGOtl8I5PBeINMg9wHr4xPdNQzoqJP9Z5PS2FMAL4x4o/GLG6z1HlO3DclOKFEVkSY5ieZL/p5xC7AlsKFvmquNoQ9uLV64m21QelgHE/ix1L4q068lZPgPgMV5fM0OKlTYRUh0HXeTDUwDw= 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=lhViLikG; arc=none smtp.client-ip=209.85.216.54 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lhViLikG" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2b27eec1eb1so585159a91.0; Tue, 30 Apr 2024 07:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714486509; x=1715091309; 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=U2Y2kGGbmaaifliYlhou15ypxyrXTa5jJJJEbBWlCRE=; b=lhViLikG8D6GCHyf5nfQOWJZyFRIfmX2bFfHfyvb0fEW0jgCC3nSvHev5j7wNuXFKc 1tkIsrA+qP6Peb2zpLcKR1w6hxuK7/TO2LR5TfG8vkAaHJ7jk7JRk5EGqFhunVeyoDcq BDIE//n6LwC83nrWg2Rl4sk7vj9zzjac+EazlkvkmfOMAd0UZT8OElwqlzE1o6QE8uj9 TCRPtKx30SW9z47vf0cp0OEhkdJTgQ9bxNg3SXECmpWAJXKKqDs2Oy1bYKQFooPs1xUd JoyIjdme/nmpuDRZs8LVu9iFFoOIOvQVdMnuQG7Ezni+1CgE40QnhP0GZZQeF9aYVAW2 Wn1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714486509; x=1715091309; 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=U2Y2kGGbmaaifliYlhou15ypxyrXTa5jJJJEbBWlCRE=; b=mtwHX77N1rhJjIMoBDLPYWt9oWqe2+WXwG0aCGgOqpPjnFjsvJTrBjH0jbhuQhm+Oc oGoTIBBB3MlslPwz0Z1r82FICRr2YoUv4ulUU05RKwmXz0cui/xwbN8weAhTOoN6kAY2 RyVjufcjtcucAyT5nJ6wvZ/aOLFr8d8Wmxsd7lXLDAwFFDLbRGewZUsGQnS8gb/nPO5y yOc8D8a2qfKVEisJX+Bessx+1nF0qaPA7s7jTH1MmVgkbhEXodHeOXa4zgxmDy/40Vvs kg19NoNP7FVtGQBl3WDz6JnrYOGrz2kmwF2CW0JrbobwnckCx+3AWRxYGmr9SkvnEkF/ USow== X-Forwarded-Encrypted: i=1; AJvYcCVYaqiDh4l9xvagYAB4hK069Cv8lz/C7cntkO3/CsHUYT7gV1J84nSoo55v3j7hXdh8UZE+wVxkZqroSkZzCeLAF89/qq9fONkKFFxpHyXGzqwWKUinfWASKgrDd3fDDnGVTT5cvWwK0Aba3VMX X-Gm-Message-State: AOJu0YzWBXJc2oBtrzzesNssShiLLz3ikmVRNvv4jt8tAkGhpC44Tgiu 9Lk/36tiVWL33XB4IE7cirXU3JRFUufLZMSaeAROt/m6PTAcNiLx X-Google-Smtp-Source: AGHT+IHP6FVNC2v9adI7AWskBEGCEOXQ3VNHcLtolk/uKaGKkx1QbyuMK3r5uLpYWO5KjNJP2qgl+Q== X-Received: by 2002:a17:90a:d58b:b0:2b2:765d:1de3 with SMTP id v11-20020a17090ad58b00b002b2765d1de3mr2378771pju.8.1714486509362; Tue, 30 Apr 2024 07:15:09 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 07:15:08 -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 , Krzysztof Kozlowski Subject: [PATCH v4 1/2] dt-bindings: interrupt-controller: renesas,rzg2l-irqc: Document RZ/Five SoC Date: Tue, 30 Apr 2024 15:14:37 +0100 Message-Id: <20240430141438.132838-2-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Document RZ/Five (R9A07G043F) IRQC bindings. The IRQC block on the RZ/Five SoC is almost identical to the one found on the RZ/G2L SoC, with the only difference being that it has additional mask control registers for NMI/IRQ/TINT. Hence new compatible string "renesas,r9a07g043f-irqc" is added for RZ/Five SoC. Signed-off-by: Lad Prabhakar Acked-by: Krzysztof Kozlowski Reviewed-by: Geert Uytterhoeven --- v3->v4 - No change v2->v3 - Dropped items for rz/five - Collected the RB tags v1->v2 - Dropped the checks for interrupts as its already handled - Added SoC specific compat string --- .../renesas,rzg2l-irqc.yaml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/interrupt-controller/renesas,rzg2l-irqc.yaml b/Documentation/devicetree/bindings/interrupt-controller/renesas,rzg2l-irqc.yaml index daef4ee06f4e..44b6ae5fc802 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/renesas,rzg2l-irqc.yaml +++ b/Documentation/devicetree/bindings/interrupt-controller/renesas,rzg2l-irqc.yaml @@ -21,13 +21,16 @@ description: | properties: compatible: - items: - - enum: - - renesas,r9a07g043u-irqc # RZ/G2UL - - renesas,r9a07g044-irqc # RZ/G2{L,LC} - - renesas,r9a07g054-irqc # RZ/V2L - - renesas,r9a08g045-irqc # RZ/G3S - - const: renesas,rzg2l-irqc + oneOf: + - items: + - enum: + - renesas,r9a07g043u-irqc # RZ/G2UL + - renesas,r9a07g044-irqc # RZ/G2{L,LC} + - renesas,r9a07g054-irqc # RZ/V2L + - renesas,r9a08g045-irqc # RZ/G3S + - const: renesas,rzg2l-irqc + + - const: renesas,r9a07g043f-irqc # RZ/Five '#interrupt-cells': description: The first cell should contain a macro RZG2L_{NMI,IRQX} included in the From patchwork Tue Apr 30 14:14:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13649337 X-Patchwork-Delegate: geert@linux-m68k.org 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dYEUoiKA" 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-Google-Smtp-Source: AGHT+IGJbxv+kbcFM+zqC0SF72sh/VAH4+dUGSFPQasHNb9jjjyVSODWR9oXdJEidc1M951AMnto+Q== 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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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");